gstreamer/tools/gstreamer-launch.c
Wim Taymans 86bdfc6663 Escape spaces in the cmdline args with "\\ " so that parse can handle it.
Original commit message from CVS:
Escape spaces in the cmdline args with "\\ " so that parse can handle it.
2001-05-20 20:06:09 +00:00

49 lines
1 KiB
C

#include <glib.h>
#include <gst/gst.h>
#include <gst/gstparse.h>
#include <string.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
GstElement *pipeline;
char **argvn;
gchar *cmdline;
int i;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("launch");
// make a null-terminated version of argv
argvn = g_new0 (char *,argc);
memcpy (argvn, argv+1, sizeof (char*) * (argc-1));
// escape spaces
for (i=0; i<argc-1; i++) {
gchar **split;
split = g_strsplit (argvn[i], " ", 0);
argvn[i] = g_strjoinv ("\\ ", split);
g_strfreev (split);
}
// join the argvs together
cmdline = g_strjoinv (" ", argvn);
// free the null-terminated argv
g_free (argvn);
gst_parse_launch (cmdline, GST_BIN (pipeline));
xmlSaveFile("gstreamer-launch.gst",gst_xml_write(pipeline));
fprintf(stderr,"RUNNING pipeline\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL);
return 0;
}