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++;
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);
}
}
}
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;
}
}
}
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;
}
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);
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;