[xiph-commits] r17301 - in trunk/ezstream: . doc examples src

moritz at svn.xiph.org moritz at svn.xiph.org
Mon Jun 21 11:39:26 PDT 2010


Author: moritz
Date: 2010-06-21 11:39:26 -0700 (Mon, 21 Jun 2010)
New Revision: 17301

Modified:
   trunk/ezstream/NEWS
   trunk/ezstream/doc/ezstream.1.in.in
   trunk/ezstream/examples/ezstream_metadata.xml
   trunk/ezstream/src/configfile.c
   trunk/ezstream/src/configfile.h
   trunk/ezstream/src/ezstream.c
Log:
Add new <metadata_refreshinterval/> feature and configuration option. Based on
a patch by Matthew Adams (thanks!), with minor changes and documentation
additions by me.


Modified: trunk/ezstream/NEWS
===================================================================
--- trunk/ezstream/NEWS	2010-06-21 18:10:48 UTC (rev 17300)
+++ trunk/ezstream/NEWS	2010-06-21 18:39:26 UTC (rev 17301)
@@ -1,3 +1,13 @@
+Changes in 0.5.7, released on XXXX-XX-XX:
+
+ * various:
+   - [NEW]   Add new <metadata_refreshinterval/> feature from Matthew Adams
+             (with minor changes plus documentation.) This allows for recurring
+             and custom metadata updates inbetween song changes via
+             <metadata_progname/>.
+
+
+
 Changes in 0.5.6, released on 2009-08-31:
 
  * ezstream-file.sh:

Modified: trunk/ezstream/doc/ezstream.1.in.in
===================================================================
--- trunk/ezstream/doc/ezstream.1.in.in	2010-06-21 18:10:48 UTC (rev 17300)
+++ trunk/ezstream/doc/ezstream.1.in.in	2010-06-21 18:39:26 UTC (rev 17301)
@@ -275,6 +275,17 @@
 .Sy METADATA
 section for details on how metadata is handled by
 .Nm .
+.It Sy \&<metadata_refreshinterval\ /\&>
+.Pq Optional.
+Configures the time
+.Pq in seconds
+inbetween additional metadata updates via
+.Li \&<metadata_progname/\&> .
+A value of 0
+.Pq zero
+triggers updates as fast as possible, while a value of \&-1
+.Pq minus one
+or the absence of this configuration element disables this feature.
 .It Sy \&<stream_once\ /\&>
 Set to
 .Sy 1

Modified: trunk/ezstream/examples/ezstream_metadata.xml
===================================================================
--- trunk/ezstream/examples/ezstream_metadata.xml	2010-06-21 18:10:48 UTC (rev 17300)
+++ trunk/ezstream/examples/ezstream_metadata.xml	2010-06-21 18:39:26 UTC (rev 17301)
@@ -20,6 +20,8 @@
     <metadata_progname>meta.sh</metadata_progname>
     <!-- Set the metadata string according to this format: -->
     <metadata_format>@s@: @a@ - @t@</metadata_format>
+    <!-- Update metadata from meta.sh at least once every 10 seconds: -->
+    <metadata_refreshinterval>10</metadata_refreshinterval>
     <!--
       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

Modified: trunk/ezstream/src/configfile.c
===================================================================
--- trunk/ezstream/src/configfile.c	2010-06-21 18:10:48 UTC (rev 17300)
+++ trunk/ezstream/src/configfile.c	2010-06-21 18:39:26 UTC (rev 17301)
@@ -89,7 +89,8 @@
 	xmlNodePtr	 cur;
 	char		*ls_xmlContentPtr;
 	int		 program_set, reconnect_set, shuffle_set,
-			 streamOnce_set, svrinfopublic_set;
+			 streamOnce_set, svrinfopublic_set,
+			 refresh_set;
 	unsigned int	 config_error;
 
 	xmlLineNumbersDefault(1);
@@ -106,14 +107,17 @@
 		return (0);
 	}
 
-	memset(&ezConfig, '\000', sizeof(ezConfig));
+	memset(&ezConfig, 0, sizeof(ezConfig));
+	ezConfig.metadataRefreshInterval = -1;
 
 	config_error = 0;
 	program_set = 0;
 	reconnect_set = 0;
+	refresh_set = 0;
 	shuffle_set = 0;
 	streamOnce_set = 0;
 	svrinfopublic_set = 0;
+
 	for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
 		if (!xmlStrcmp(cur->name, (const xmlChar *)"url")) {
 			if (ezConfig.URL != NULL) {
@@ -230,6 +234,27 @@
 				}
 			}
 		}
+		if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_refreshinterval")) {
+			if (refresh_set) {
+				printf("%s[%ld]: Error: Cannot have multiple <metadata_refreshinterval> elements\n",
+				       fileName, xmlGetLineNo(cur));
+				config_error++;
+				continue;
+			}
+			if (cur->xmlChildrenNode != NULL) {
+				const char *errstr;
+				ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+				ezConfig.metadataRefreshInterval = (unsigned int)strtonum(ls_xmlContentPtr, -1LL, (long long)INT_MAX, &errstr);
+				if (errstr) {
+					printf("%s[%ld]: Error: In <metadata_refreshinterval>: '%s' is %s\n",
+					       fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
+					config_error++;
+					continue;
+				}
+				xmlFree(ls_xmlContentPtr);
+				refresh_set = 1;
+			}
+		}
 		if (!xmlStrcmp(cur->name, (const xmlChar *)"playlist_program")) {
 			if (program_set) {
 				printf("%s[%ld]: Error: Cannot have multiple <playlist_program> elements\n",

Modified: trunk/ezstream/src/configfile.h
===================================================================
--- trunk/ezstream/src/configfile.h	2010-06-21 18:10:48 UTC (rev 17300)
+++ trunk/ezstream/src/configfile.h	2010-06-21 18:39:26 UTC (rev 17301)
@@ -66,6 +66,7 @@
 	int		 fileNameIsProgram;
 	int		 streamOnce;
 	unsigned int	 reconnectAttempts;
+	int		 metadataRefreshInterval;
 } EZCONFIG;
 
 EZCONFIG *	getEZConfig(void);

Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2010-06-21 18:10:48 UTC (rev 17300)
+++ trunk/ezstream/src/ezstream.c	2010-06-21 18:39:26 UTC (rev 17301)
@@ -750,6 +750,7 @@
 	int		 ret;
 	double		 kbps = -1.0;
 	struct timeval	 timeStamp, *startTime = tv;
+	struct timeval	 callTime, currentTime;
 
 	if (startTime == NULL) {
 		printf("%s: sendStream(): Internal error: startTime is NULL\n",
@@ -757,6 +758,8 @@
 		abort();
 	}
 
+	ez_gettimeofday((void *)&callTime);
+
 	timeStamp.tv_sec = startTime->tv_sec;
 	timeStamp.tv_usec = startTime->tv_usec;
 
@@ -795,7 +798,15 @@
 			ret = STREAM_SKIP;
 			break;
 		}
-		if (queryMetadata) {
+
+		ez_gettimeofday((void *)&currentTime);
+
+		if (queryMetadata ||
+		    (pezConfig->metadataRefreshInterval != -1
+		     && (currentTime.tv_sec - callTime.tv_sec
+			 >= pezConfig->metadataRefreshInterval)
+		    )
+		   ) {
 			queryMetadata = 0;
 			if (metadataFromProgram) {
 				ret = STREAM_UPDMDATA;
@@ -805,8 +816,7 @@
 
 		total += bytes_read;
 		if (qFlag && vFlag) {
-			struct timeval	tval;
-			double		oldTime, newTime;
+			double	oldTime, newTime;
 
 			if (!isStdin && playlistMode) {
 				if (pezConfig->fileNameIsProgram) {
@@ -822,20 +832,22 @@
 
 			oldTime = (double)timeStamp.tv_sec
 				+ (double)timeStamp.tv_usec / 1000000.0;
-			ez_gettimeofday((void *)&tval);
-			newTime = (double)tval.tv_sec
-				+ (double)tval.tv_usec / 1000000.0;
+			newTime = (double)currentTime.tv_sec
+				+ (double)currentTime.tv_usec / 1000000.0;
 			if (songLenStr == NULL)
 				printf("  [ %s]",
-				       getTimeString(tval.tv_sec - startTime->tv_sec));
+				       getTimeString(currentTime.tv_sec -
+						     startTime->tv_sec));
 			else
 				printf("  [ %s/%s]",
-				       getTimeString(tval.tv_sec - startTime->tv_sec),
+				       getTimeString(currentTime.tv_sec -
+						     startTime->tv_sec),
 				       songLenStr);
 			if (newTime - oldTime >= 1.0) {
-				kbps = (((double)(total - oldTotal) / (newTime - oldTime)) * 8.0) / 1000.0;
-				timeStamp.tv_sec = tval.tv_sec;
-				timeStamp.tv_usec = tval.tv_usec;
+				kbps = (((double)(total - oldTotal)
+					 / (newTime - oldTime)) * 8.0) / 1000.0;
+				timeStamp.tv_sec = currentTime.tv_sec;
+				timeStamp.tv_usec = currentTime.tv_usec;
 				oldTotal = total;
 			}
 			if (kbps < 0)
@@ -954,8 +966,9 @@
 						continue;
 					}
 					metadata_free(&prog_mdata);
-					printf("%s: New metadata: ``%s''\n",
-					       __progname, mdataStr);
+					if (vFlag > 1)
+						printf("%s: New metadata: ``%s''\n",
+						       __progname, mdataStr);
 					xfree(mdataStr);
 				}
 			}



More information about the commits mailing list