diff --git a/ChangeLog b/ChangeLog index ab9d173ff5..1e75f79e73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-25 Tim-Philipp Müller + + * gst/parse/grammar.y: + * tests/check/pipelines/parse-launch.c: + Get all missing elements from a parse launch string if possible + (ie. if the FATAL_ERRORS flag has been specified). Fixes #528178. + 2008-05-24 Tim-Philipp Müller * tests/check/Makefile.am: diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y index a6cbdbb373..cd2b938e9d 100644 --- a/gst/parse/grammar.y +++ b/gst/parse/grammar.y @@ -321,6 +321,10 @@ gst_parse_element_set (gchar *value, GstElement *element, graph_t *graph) GstObject *target = NULL; GType value_type; + /* do nothing if assignment is for missing element */ + if (element == NULL) + goto out; + /* parse the string, so the property name is null-terminated an pos points to the beginning of the value */ while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++; @@ -565,8 +569,13 @@ element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL); if ($$ == NULL) { ADD_MISSING_ELEMENT ((graph_t *) graph, $1); SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), $1); - gst_parse_strfree ($1); - YYERROR; + /* if FATAL_ERRORS flag is set, we don't have to worry about backwards + * compatibility and can continue parsing and check for other missing + * elements */ + if ((((graph_t *) graph)->flags & GST_PARSE_FLAG_FATAL_ERRORS) == 0) { + gst_parse_strfree ($1); + YYERROR; + } } gst_parse_strfree ($1); } @@ -879,8 +888,12 @@ _gst_parse_launch (const gchar *str, GError **error, GstParseContext *ctx, } } if (!l->src) { - SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, - "No element named \"%s\" - omitting link", l->src_name); + if (l->src_name) { + SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, + "No element named \"%s\" - omitting link", l->src_name); + } else { + /* probably a missing element which we've handled already */ + } gst_parse_free_link (l); continue; } @@ -896,8 +909,12 @@ _gst_parse_launch (const gchar *str, GError **error, GstParseContext *ctx, } } if (!l->sink) { - SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, - "No element named \"%s\" - omitting link", l->sink_name); + if (l->sink_name) { + SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, + "No element named \"%s\" - omitting link", l->sink_name); + } else { + /* probably a missing element which we've handled already */ + } gst_parse_free_link (l); continue; } diff --git a/tests/check/pipelines/parse-launch.c b/tests/check/pipelines/parse-launch.c index 15c49c87bd..d8f3b7a941 100644 --- a/tests/check/pipelines/parse-launch.c +++ b/tests/check/pipelines/parse-launch.c @@ -546,6 +546,7 @@ GST_START_TEST (test_missing_elements) if (!g_getenv ("GST_DEBUG")) gst_debug_set_default_threshold (GST_LEVEL_NONE); + /* one missing element */ ctx = gst_parse_context_new (); element = gst_parse_launch_full ("fakesrc ! coffeesink", ctx, GST_PARSE_FLAG_FATAL_ERRORS, &err); @@ -560,6 +561,43 @@ GST_START_TEST (test_missing_elements) gst_parse_context_free (ctx); g_error_free (err); err = NULL; + + /* multiple missing elements */ + ctx = gst_parse_context_new (); + element = gst_parse_launch_full ("fakesrc ! bogusenc ! identity ! goomux ! " + "fakesink", ctx, GST_PARSE_FLAG_FATAL_ERRORS, &err); + fail_unless (err != NULL, "expected error"); + fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); + fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); + arr = gst_parse_context_get_missing_elements (ctx); + fail_unless (arr != NULL, "expected missing elements"); + fail_unless_equals_string (arr[0], "bogusenc"); + fail_unless_equals_string (arr[1], "goomux"); + fail_unless (arr[2] == NULL); + g_strfreev (arr); + gst_parse_context_free (ctx); + g_error_free (err); + err = NULL; + + /* multiple missing elements, different link pattern */ + ctx = gst_parse_context_new (); + element = gst_parse_launch_full ("fakesrc ! bogusenc ! mux.sink " + "blahsrc ! goomux name=mux ! fakesink fakesrc ! goosink", ctx, + GST_PARSE_FLAG_FATAL_ERRORS, &err); + fail_unless (err != NULL, "expected error"); + fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); + fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); + arr = gst_parse_context_get_missing_elements (ctx); + fail_unless (arr != NULL, "expected missing elements"); + fail_unless_equals_string (arr[0], "bogusenc"); + fail_unless_equals_string (arr[1], "blahsrc"); + fail_unless_equals_string (arr[2], "goomux"); + fail_unless_equals_string (arr[3], "goosink"); + fail_unless (arr[4] == NULL); + g_strfreev (arr); + gst_parse_context_free (ctx); + g_error_free (err); + err = NULL; } GST_END_TEST;