From: Andy W. <wi...@us...> - 2002-01-15 05:57:17
|
Update of /cvsroot/gstreamer/gstreamer/tools In directory usw-pr-cvs1:/tmp/cvs-serv23108 Modified Files: Makefile.am gst-launch.c Log Message: gst-xmllaunch works now. it's a separate target built from gst-launch.c, just with a different name. it can set the properties of elements by name, as in element.property=value. craete pipelines using gst-launch -o file.xml <pipeline description> Index: Makefile.am =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/tools/Makefile.am,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- Makefile.am 2002/01/04 19:46:40 1.28 +++ Makefile.am 2002/01/15 05:57:14 1.29 @@ -7,7 +7,7 @@ if GST_DISABLE_LOADSAVE GST_LOADSAVE_SRC = else -GST_LOADSAVE_SRC = gst-compprep +GST_LOADSAVE_SRC = gst-compprep gst-xmllaunch endif bin_PROGRAMS = gst-launch \ @@ -36,6 +36,10 @@ if !GST_DISABLE_LOADSAVE gst_compprep_LDADD = $(GST_LIBS) gst_compprep_CFLAGS = $(GST_CFLAGS) -DGST_CONFIG_DIR=\"$(GST_CONFIG_DIR)\" + +gst_xmllaunch_SOURCES = gst-launch.c +gst_xmllaunch_LDADD = $(GST_LIBS) +gst_xmllaunch_CFLAGS = $(GST_CFLAGS) -DGST_CONFIG_DIR=\"$(GST_CONFIG_DIR)\" endif EXTRA_DIST = $(man_MANS) Index: gst-launch.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/tools/gst-launch.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gst-launch.c 2002/01/14 07:18:43 1.4 +++ gst-launch.c 2002/01/15 05:57:14 1.5 @@ -81,27 +81,63 @@ } static GstElement* -xmllaunch_parse_cmdline (gint argc, const gchar **argv) +xmllaunch_parse_cmdline (const gchar *argv[]) { - GstElement *pipeline = NULL; + GstElement *pipeline = NULL, *e; GstXML *xml; gboolean err; + const gchar *arg; + gchar *element, *property, *value; GList *l; + gint i = 0; - if (argc < 2) { - g_print ("usage: %s <file.xml> [ element.property=value ... ]\n", argv[0]); + if (!(arg = argv[0])) { + g_print ("usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n", arg[0]); exit (1); } xml = gst_xml_new (); - err = gst_xml_parse_file(xml, argv[1], NULL); + err = gst_xml_parse_file(xml, arg, NULL); if (err != TRUE) { - fprintf (stderr, "ERROR: parse of xml file '%s' failed\n", argv[1]); + fprintf (stderr, "ERROR: parse of xml file '%s' failed\n", arg); exit (1); } l = gst_xml_get_topelements (xml); + if (!l) { + fprintf (stderr, "ERROR: no toplevel pipeline element in file '%s'\n", arg); + exit (1); + } + + if (l->next) + g_warning ("only one toplevel element is supported at this time"); + + pipeline = GST_ELEMENT (l->data); + + while ((arg = argv[++i])) { + element = g_strdup (arg); + property = strchr (element, '.'); + value = strchr (element, '='); + + if (!(element < property && property < value)) { + fprintf (stderr, "ERROR: could not parse command line argument %d: %s", i, element); + g_free (element); + exit (1); + } + + *property++ = '\0'; + *value++ = '\0'; + + g_print ("%s, %s, %s\n", element, property, value); + e = gst_bin_get_by_name (GST_BIN (pipeline), element); + if (!e) { + g_warning ("element named '%s' not found", element); + } else { + gst_util_set_object_arg (G_OBJECT (e), property, value); + } + } + if (!l) return NULL; else @@ -112,7 +148,7 @@ main(int argc, char *argv[]) { GstElement *pipeline; - char **argvn; + gchar **argvn; gchar *cmdline; int i; gboolean save_pipeline = FALSE; @@ -135,12 +171,12 @@ launch_argc = argc; launch_argv = argv; + /* make a null-terminated version of argv */ + argvn = g_new0 (char *,argc); + memcpy (argvn, argv+1, sizeof (char*) * (argc-1)); if (strstr (argv[0], "gst-xmllaunch")) { - pipeline = xmllaunch_parse_cmdline (argc, argv); + pipeline = xmllaunch_parse_cmdline (argvn); } else { - /* make a null-terminated version of argv */ - argvn = g_new0 (char *,argc); - memcpy (argvn, argv+1, sizeof (char*) * (argc-1)); pipeline = (GstElement*) gst_parse_launchv (argvn); } |