// we have the start of a name of the preceding element.
// rename previous element to next arg.
if (arg[1] != '\0') {
- fprintf(stderr,"error, unexpected junk after [\n");
- exit(-1);
+ fprintf(stderr,"error, unexpected junk after [\n");
+ return GST_PARSE_ERROR_SYNTAX;
}
i++;
if (i < argc) {
- gst_element_set_name(previous, argv[i]);
+ gst_element_set_name(previous, argv[i]);
} else {
- fprintf(stderr,"error, expected element name, found end of arguments\n");
- exit(-1);
+ fprintf(stderr,"error, expected element name, found end of arguments\n");
+ return GST_PARSE_ERROR_SYNTAX;
}
i++;
if (i >= argc) {
- fprintf(stderr,"error, expected ], found end of arguments\n");
- exit(-1);
+ fprintf(stderr,"error, expected ], found end of arguments\n");
+ return GST_PARSE_ERROR_SYNTAX;
} else if (strcmp(argv[i], "]") != 0) {
- fprintf(stderr,"error, expected ], found '%s'\n", argv[i]);
- exit(-1);
+ fprintf(stderr,"error, expected ], found '%s'\n", argv[i]);
+ return GST_PARSE_ERROR_SYNTAX;
}
} else {
DEBUG("have element or bin/thread\n");
element = gst_bin_new(g_strdup_printf("bin%d",priv->bincount++));
if (!element) {
fprintf(stderr,"Couldn't create a bin!\n");
-// exit(-1);
+ return GST_PARSE_ERROR_CREATING_ELEMENT;
}
GST_DEBUG(0,"CREATED bin %s\n",GST_ELEMENT_NAME(element));
} else if (arg[0] == '{') {
element = gst_thread_new(g_strdup_printf("thread%d",priv->threadcount++));
if (!element) {
fprintf(stderr,"Couldn't create a thread!\n");
-// exit(-1);
+ return GST_PARSE_ERROR_CREATING_ELEMENT;
}
GST_DEBUG(0,"CREATED thread %s\n",GST_ELEMENT_NAME(element));
} else {
continue;
}
- i += gst_parse_launch_cmdline(argc - i, argv + i + 1, GST_BIN (element), priv);
+ j = gst_parse_launch_cmdline(argc - i, argv + i + 1, GST_BIN (element), priv);
+ //check for parse error
+ if (j < 0) return j;
+ i += j;
} else {
// we have an element
#else
fprintf(stderr,"Couldn't create a '%s', no such element or need to load pluginn?\n",arg);
#endif
- exit(-1);
+ return GST_PARSE_ERROR_NOSUCH_ELEMENT;
}
GST_DEBUG(0,"CREATED element %s\n",GST_ELEMENT_NAME(element));
}
GtkWidget *tree_item = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(widget), "tree_item");
gchar *last_pipe = (gchar*)gtk_object_get_data(GTK_OBJECT(widget), "last_pipe");
gchar *try_pipe = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(pipe_combo)->entry));
-
+ gint parse_result;
+
if (pipeline){
g_print("unreffing\n");
gst_object_unref (GST_OBJECT (pipeline));
g_print ("trying pipeline: %s\n", try_pipe);
pipeline = gst_pipeline_new ("launch");
- gst_parse_launch (try_pipe, GST_BIN (pipeline));
+ parse_result = gst_parse_launch (try_pipe, GST_BIN (pipeline));
+ if (parse_result < 0){
+ switch(parse_result){
+ case GST_PARSE_ERROR_SYNTAX:
+ gtk_label_set_text(GTK_LABEL(status), "error parsing syntax of pipeline");
+ break;
+ case GST_PARSE_ERROR_CREATING_ELEMENT:
+ gtk_label_set_text(GTK_LABEL(status), "error creating a core element");
+ break;
+ case GST_PARSE_ERROR_NOSUCH_ELEMENT:
+ gtk_label_set_text(GTK_LABEL(status), "error finding an element which was requested");
+ break;
+ default:
+ gtk_label_set_text(GTK_LABEL(status), "unknown error parsing pipeline");
+ break;
+ }
+ gst_object_unref (GST_OBJECT (pipeline));
+ return;
+ }
gtk_widget_set_sensitive(GTK_WIDGET(start_but), TRUE);
build_tree(tree_item, GST_BIN(pipeline));