[xiph-cvs] cvs commit: ices/src config.c config.h stream.c
Michael Smith
msmith at xiph.org
Sun Aug 11 06:09:59 PDT 2002
msmith 02/08/11 09:09:59
Modified: src config.c config.h stream.c
Log:
Allow a metadata element inside <instance> as well as globally to override
metadata per-instance. Useful to be able to set description on each instance
differently (such as "Test stream (low bandwidth)" and "Test stream (high
bandwidth)"
Revision Changes Path
1.12 +32 -18 ices/src/config.c
Index: config.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/config.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- config.c 10 Aug 2002 03:31:27 -0000 1.11
+++ config.c 11 Aug 2002 13:09:59 -0000 1.12
@@ -1,7 +1,7 @@
/* config.c
* - config file reading code, plus default settings.
*
- * $Id: config.c,v 1.11 2002/08/10 03:31:27 msmith Exp $
+ * $Id: config.c,v 1.12 2002/08/11 13:09:59 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -179,6 +179,34 @@
}
+static void _parse_metadata(instance_t *instance, config_t *config,
+ xmlDocPtr doc, xmlNodePtr node)
+{
+ do
+ {
+ if (node == NULL) break;
+ if (xmlIsBlankNode(node)) continue;
+
+ if (strcmp(node->name, "name") == 0) {
+ if(instance)
+ SET_STRING(instance->stream_name);
+ else
+ SET_STRING(config->stream_name);
+ }
+ else if (strcmp(node->name, "genre") == 0) {
+ if(instance)
+ SET_STRING(instance->stream_genre);
+ else
+ SET_STRING(config->stream_genre);
+ }
+ else if (strcmp(node->name, "description") == 0) {
+ if(instance)
+ SET_STRING(instance->stream_description);
+ else
+ SET_STRING(config->stream_description);
+ }
+ } while ((node = node->next));
+}
static void _parse_instance(config_t *config, xmlDocPtr doc, xmlNodePtr node)
{
@@ -214,6 +242,8 @@
_parse_resample(instance, doc, node->xmlChildrenNode);
else if (strcmp(node->name, "encode") == 0)
_parse_encode(instance, doc, node->xmlChildrenNode);
+ else if (strcmp(node->name, "metadata") == 0)
+ _parse_metadata(instance, config, doc, node->xmlChildrenNode);
} while ((node = node->next));
instance->next = NULL;
@@ -268,22 +298,6 @@
} while ((node = node->next));
}
-static void _parse_metadata(config_t *config, xmlDocPtr doc, xmlNodePtr node)
-{
- do
- {
- if (node == NULL) break;
- if (xmlIsBlankNode(node)) continue;
-
- if (strcmp(node->name, "name") == 0)
- SET_STRING(config->stream_name);
- else if (strcmp(node->name, "genre") == 0)
- SET_STRING(config->stream_genre);
- else if (strcmp(node->name, "description") == 0)
- SET_STRING(config->stream_description);
- } while ((node = node->next));
-}
-
static void _parse_stream(config_t *config, xmlDocPtr doc, xmlNodePtr node)
{
do
@@ -292,7 +306,7 @@
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "metadata") == 0)
- _parse_metadata(config, doc, node->xmlChildrenNode);
+ _parse_metadata(NULL, config, doc, node->xmlChildrenNode);
else if (strcmp(node->name, "input") == 0)
_parse_input(config, doc, node->xmlChildrenNode);
else if (strcmp(node->name, "instance") == 0)
<p><p>1.13 +6 -1 ices/src/config.h
Index: config.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/config.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- config.h 3 Aug 2002 08:14:54 -0000 1.12
+++ config.h 11 Aug 2002 13:09:59 -0000 1.13
@@ -1,7 +1,7 @@
/* config.h
* - configuration, and global structures built from config
*
- * $Id: config.h,v 1.12 2002/08/03 08:14:54 msmith Exp $
+ * $Id: config.h,v 1.13 2002/08/11 13:09:59 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -42,6 +42,11 @@
int resampleoutrate;
int max_queue_length;
char *savefilename;
+
+ /* local metadata */
+ char *stream_name;
+ char *stream_genre;
+ char *stream_description;
/* Parameters for re-encoding */
int managed;
<p><p>1.19 +23 -7 ices/src/stream.c
Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- stream.c 11 Aug 2002 09:45:34 -0000 1.18
+++ stream.c 11 Aug 2002 13:09:59 -0000 1.19
@@ -1,7 +1,7 @@
/* stream.c
* - Core streaming functions/main loop.
*
- * $Id: stream.c,v 1.18 2002/08/11 09:45:34 msmith Exp $
+ * $Id: stream.c,v 1.19 2002/08/11 13:09:59 msmith Exp $
*
* Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
*
@@ -55,6 +55,7 @@
input_module_t *inmod = sdsc->input;
int reencoding = (inmod->type == ICES_INPUT_VORBIS) && stream->encode;
int encoding = (inmod->type == ICES_INPUT_PCM) && stream->encode;
+ char *stream_name = NULL, *stream_genre = NULL, *stream_description = NULL;
vorbis_comment_init(&sdsc->vc);
@@ -97,22 +98,37 @@
}
/* set the metadata for the stream */
- if (ices_config->stream_name)
- if (!(shout_set_name(sdsc->shout, ices_config->stream_name)) == SHOUTERR_SUCCESS) {
+ if(stream->stream_name)
+ stream_name = stream->stream_name;
+ else if (ices_config->stream_name)
+ stream_name = ices_config->stream_name;
+
+ if(stream->stream_description)
+ stream_description = stream->stream_description;
+ else if (ices_config->stream_description)
+ stream_description = ices_config->stream_description;
+
+ if(stream->stream_genre)
+ stream_genre = stream->stream_genre;
+ else if (ices_config->stream_genre)
+ stream_genre = ices_config->stream_genre;
+
+ if(stream_name)
+ if (!(shout_set_name(sdsc->shout, stream_name)) == SHOUTERR_SUCCESS) {
LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
free(connip);
stream->died = 1;
return NULL;
}
- if (ices_config->stream_genre)
- if (!(shout_set_genre(sdsc->shout, ices_config->stream_genre)) == SHOUTERR_SUCCESS) {
+ if (stream_genre)
+ if (!(shout_set_genre(sdsc->shout, stream_genre)) == SHOUTERR_SUCCESS) {
LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
free(connip);
stream->died = 1;
return NULL;
}
- if (ices_config->stream_description)
- if (!(shout_set_description(sdsc->shout, ices_config->stream_description)) == SHOUTERR_SUCCESS) {
+ if (stream_description)
+ if (!(shout_set_description(sdsc->shout, stream_description)) == SHOUTERR_SUCCESS) {
LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
free(connip);
stream->died = 1;
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list