uridecodebin: don't report 'no uri handler found' if the URI was rejected by a source

If a source element could be created for a URI, but all elements rejected
the URI for some reason, propagate the error from the URI handler instead
of reporting a 'no uri handler found for protocol xyz' error, which is
confusing. Fixes error reporting with dvb:// URIs when the channel config
file could not be found or not be parsed or the channel isn't listed.

https://bugzilla.gnome.org/show_bug.cgi?id=678892
This commit is contained in:
Tim-Philipp Müller 2013-04-21 17:24:55 +01:00
parent fbe80a688d
commit 830926e47d

View file

@ -1255,6 +1255,7 @@ gen_source_element (GstURIDecodeBin * decoder)
GParamSpec *pspec; GParamSpec *pspec;
GstQuery *query; GstQuery *query;
GstSchedulingFlags flags; GstSchedulingFlags flags;
GError *err = NULL;
if (!decoder->uri) if (!decoder->uri)
goto no_uri; goto no_uri;
@ -1268,7 +1269,7 @@ gen_source_element (GstURIDecodeBin * decoder)
goto uri_blacklisted; goto uri_blacklisted;
source = source =
gst_element_make_from_uri (GST_URI_SRC, decoder->uri, "source", NULL); gst_element_make_from_uri (GST_URI_SRC, decoder->uri, "source", &err);
if (!source) if (!source)
goto no_source; goto no_source;
@ -1357,6 +1358,7 @@ invalid_uri:
{ {
GST_ELEMENT_ERROR (decoder, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (decoder, RESOURCE, NOT_FOUND,
(_("Invalid URI \"%s\"."), decoder->uri), (NULL)); (_("Invalid URI \"%s\"."), decoder->uri), (NULL));
g_clear_error (&err);
return NULL; return NULL;
} }
uri_blacklisted: uri_blacklisted:
@ -1367,23 +1369,29 @@ uri_blacklisted:
} }
no_source: no_source:
{ {
gchar *prot = gst_uri_get_protocol (decoder->uri);
/* whoops, could not create the source element, dig a little deeper to /* whoops, could not create the source element, dig a little deeper to
* figure out what might be wrong. */ * figure out what might be wrong. */
if (prot) { if (err != NULL && err->code == GST_URI_ERROR_UNSUPPORTED_PROTOCOL) {
GstMessage *msg; gchar *prot;
msg = prot = gst_uri_get_protocol (decoder->uri);
gst_missing_uri_source_message_new (GST_ELEMENT_CAST (decoder), prot); if (prot == NULL)
gst_element_post_message (GST_ELEMENT_CAST (decoder), msg); goto invalid_uri;
gst_element_post_message (GST_ELEMENT_CAST (decoder),
gst_missing_uri_source_message_new (GST_ELEMENT (decoder), prot));
GST_ELEMENT_ERROR (decoder, CORE, MISSING_PLUGIN, GST_ELEMENT_ERROR (decoder, CORE, MISSING_PLUGIN,
(_("No URI handler implemented for \"%s\"."), prot), (NULL)); (_("No URI handler implemented for \"%s\"."), prot), (NULL));
g_free (prot);
} else
goto invalid_uri;
g_free (prot);
} else {
GST_ELEMENT_ERROR (decoder, RESOURCE, NOT_FOUND,
("%s", (err) ? err->message : "URI was not accepted by any element"),
("No element accepted URI '%s'", decoder->uri));
}
g_clear_error (&err);
return NULL; return NULL;
} }
} }