[xiph-commits] r12592 - in trunk/ezstream: . conf doc src

moritz at svn.xiph.org moritz at svn.xiph.org
Wed Feb 28 13:48:08 PST 2007


Author: moritz
Date: 2007-02-28 13:48:01 -0800 (Wed, 28 Feb 2007)
New Revision: 12592

Modified:
   trunk/ezstream/NEWS
   trunk/ezstream/conf/ezstream_mp3.xml
   trunk/ezstream/conf/ezstream_vorbis.xml
   trunk/ezstream/doc/ezstream.1.in
   trunk/ezstream/src/configfile.c
   trunk/ezstream/src/configfile.h
   trunk/ezstream/src/ezstream.c
Log:
Add new <stream_once> configuration option for disabling continuous streaming.


Modified: trunk/ezstream/NEWS
===================================================================
--- trunk/ezstream/NEWS	2007-02-28 21:26:16 UTC (rev 12591)
+++ trunk/ezstream/NEWS	2007-02-28 21:48:01 UTC (rev 12592)
@@ -9,6 +9,8 @@
    - Playlist scripting support: Indicate that the executable in <filename>
      should be run each time to get a new media filename to stream, by setting
      the new <playlist_program> configuration option to 1.
+   - New <stream_once> configuration option, which makes ezstream play a media
+     file or playlist once and then exit.
    - Add feature to skip the currently streaming track, done by sending the
      SIGUSR1 signal to the ezstream process.
    - New command line option `-q': Suppress standard error output from external

Modified: trunk/ezstream/conf/ezstream_mp3.xml
===================================================================
--- trunk/ezstream/conf/ezstream_mp3.xml	2007-02-28 21:26:16 UTC (rev 12591)
+++ trunk/ezstream/conf/ezstream_mp3.xml	2007-02-28 21:48:01 UTC (rev 12592)
@@ -11,7 +11,9 @@
     <sourcepassword>hackme</sourcepassword>
     <format>MP3</format>
     <filename>playlist.m3u</filename>
-	  <!--
+    <!-- Once done streaming playlist.m3u, exit: -->
+    <stream_once>1</stream_once>
+    <!--
       The following settings are used to describe your stream to the server.
       It's up to you to make sure that the bitrate/samplerate/channels
       information matches up with your input stream files. Note that

Modified: trunk/ezstream/conf/ezstream_vorbis.xml
===================================================================
--- trunk/ezstream/conf/ezstream_vorbis.xml	2007-02-28 21:26:16 UTC (rev 12591)
+++ trunk/ezstream/conf/ezstream_vorbis.xml	2007-02-28 21:48:01 UTC (rev 12592)
@@ -11,7 +11,9 @@
     <sourcepassword>hackme</sourcepassword>
     <format>VORBIS</format>
     <filename>playlist.m3u</filename>
-	  <!--
+    <!-- For demonstrational purposes, explicitly set continuous streaming: -->
+    <stream_once>0</stream_once>
+    <!--
       The following settings are used to describe your stream to the server.
       It's up to you to make sure that the bitrate/quality/samplerate/channels
       information matches up with your input stream files.

Modified: trunk/ezstream/doc/ezstream.1.in
===================================================================
--- trunk/ezstream/doc/ezstream.1.in	2007-02-28 21:26:16 UTC (rev 12591)
+++ trunk/ezstream/doc/ezstream.1.in	2007-02-28 21:48:01 UTC (rev 12592)
@@ -160,11 +160,23 @@
 sign at the beginning of a line and ignored by
 .Nm .
 .It Sy \&<playlist_program\ /\&>
-Indicates that the file in \&<filename/\&> is actually an executable program
+.Pq Optional.
+Set to
+.Sy 1
+.Pq one
+to indicate that the file in \&<filename/\&> is actually an executable program
 or script.
 This program is supposed to print
 .Pq to standard output
 one line with the name of a file that should be streamed next and then exit.
+.Pp
+If set to
+.Sy 0
+.Pq zero ,
+\&<filename/\&> content is assumed to be a media file, playlist file or the
+keyword
+.Pa stdin
+.Pq the default .
 .It Sy \&<shuffle\ /\&>
 .Pq Optional.
 Set to
@@ -177,6 +189,15 @@
 or when the \&<shuffle/\&> element is absent.
 This option will be ignored if \&<playlist_program/\&> is set to 1
 .Pq one.
+.It Sy \&<stream_once\ /\&>
+Set to
+.Sy 1
+.Pq one
+to stream \&<filename/\&> content only once, and to
+.Sy 0
+.Pq zero
+for continuous streaming
+.Pq the default .
 .It Sy \&<svrinfoname\ /\&>
 .Pq Optional.
 Set the name of the broadcast.

Modified: trunk/ezstream/src/configfile.c
===================================================================
--- trunk/ezstream/src/configfile.c	2007-02-28 21:26:16 UTC (rev 12591)
+++ trunk/ezstream/src/configfile.c	2007-02-28 21:48:01 UTC (rev 12592)
@@ -140,7 +140,8 @@
 	xmlDocPtr	 doc;
 	xmlNodePtr	 cur;
 	char		*ls_xmlContentPtr;
-	int		 shuffle_set, svrinfopublic_set, program_set;
+	int		 program_set, shuffle_set, streamOnce_set,
+			 svrinfopublic_set;
 
 	xmlLineNumbersDefault(1);
 	if ((doc = xmlParseFile(fileName)) == NULL) {
@@ -158,9 +159,10 @@
 
 	memset(&ezConfig, '\000', sizeof(ezConfig));
 
+	program_set = 0;
 	shuffle_set = 0;
+	streamOnce_set = 0;
 	svrinfopublic_set = 0;
-	program_set = 0;
 	cur = cur->xmlChildrenNode;
 	while (cur != NULL) {
 		if (!xmlStrcmp(cur->name, BAD_CAST "url")) {
@@ -252,6 +254,22 @@
 				shuffle_set = 1;
 			}
 		}
+		if (!xmlStrcmp(cur->name, BAD_CAST "stream_once")) {
+			if (streamOnce_set) {
+				printf("%s[%ld]: Error: Cannot have multiple <stream_once> elements.\n",
+				       fileName, xmlGetLineNo(cur));
+				goto config_error;
+			}
+			if (cur->xmlChildrenNode != NULL) {
+				int tmp;
+
+				ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+				tmp = atoi(ls_xmlContentPtr);
+				ezConfig.streamOnce = (tmp == 0) ? 0 : 1;
+				xmlFree(ls_xmlContentPtr);
+				streamOnce_set = 1;
+			}
+		}
 		if (!xmlStrcmp(cur->name, BAD_CAST "svrinfoname")) {
 			if (ezConfig.serverName != NULL) {
 				printf("%s[%ld]: Error: Cannot have multiple <svrinfoname> elements.\n",

Modified: trunk/ezstream/src/configfile.h
===================================================================
--- trunk/ezstream/src/configfile.h	2007-02-28 21:26:16 UTC (rev 12591)
+++ trunk/ezstream/src/configfile.h	2007-02-28 21:48:01 UTC (rev 12592)
@@ -58,6 +58,7 @@
 	int		 numEncoderDecoders;
 	int		 shuffle;
 	int		 fileNameIsProgram;
+	int		 streamOnce;
 } EZCONFIG;
 
 EZCONFIG *	getEZConfig(void);

Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2007-02-28 21:26:16 UTC (rev 12591)
+++ trunk/ezstream/src/ezstream.c	2007-02-28 21:48:01 UTC (rev 12592)
@@ -775,7 +775,10 @@
 		}
 	}
 
-	return (1);
+	if (pezConfig->streamOnce)
+		return (0);
+	else
+		return (1);
 }
 
 /* Borrowed from OpenNTPd-portable's compat-openbsd/bsd-misc.c */
@@ -1123,8 +1126,11 @@
 			if (playlistMode)
 				ret = streamPlaylist(shout,
 						     pezConfig->fileName);
-			else
+			else {
 				ret = streamFile(shout, pezConfig->fileName);
+				if (pezConfig->streamOnce)
+					break;
+			}
 		} while (ret);
 	} else
 		printf("%s: Connection to http://%s:%d%s failed: %s\n", __progname,



More information about the commits mailing list