Commit acf3bcdf authored by Tim-Philipp Müller's avatar Tim-Philipp Müller

gst/playback/gstplaybasebin.c: Attempt at a better error message in case we don't have the required

Original commit message from CVS:
* gst/playback/gstplaybasebin.c: (setup_subtitle),
(gen_source_element), (gst_play_base_bin_change_state):
Attempt at a better error message in case we don't have the required
URI handler installed; post missing-plugin message also when we're
missing an URI handler for the subtitle URI; clean up properly also
when an error occurs and we never made it to PAUSED state.
* tests/check/elements/playbin.c: (GST_START_TEST),
(playbin_suite):
Check that we're also getting a missing-plugin messsage for a
missing subtitle URI handler (and clean up properly).
parent 638dbd7b
2007-01-19 Tim-Philipp Müller <tim at centricular dot net>
* gst/playback/gstplaybasebin.c: (setup_subtitle),
(gen_source_element), (gst_play_base_bin_change_state):
Attempt at a better error message in case we don't have the required
URI handler installed; post missing-plugin message also when we're
missing an URI handler for the subtitle URI; clean up properly also
when an error occurs and we never made it to PAUSED state.
* tests/check/elements/playbin.c: (GST_START_TEST),
(playbin_suite):
Check that we're also getting a missing-plugin messsage for a
missing subtitle URI handler (and clean up properly).
2007-01-19 Tim-Philipp Müller <tim at centricular dot net>
* gst/playback/gstplaybasebin.c: (analyse_source), (setup_source):
......@@ -1443,8 +1443,17 @@ unknown_uri:
gchar *prot = gst_uri_get_protocol (sub_uri);
if (prot) {
gchar *desc;
gst_element_post_message (GST_ELEMENT (play_base_bin),
gst_missing_uri_source_message_new (GST_ELEMENT (play_base_bin),
prot));
desc = gst_base_utils_get_source_description (prot);
GST_ELEMENT_ERROR (play_base_bin, CORE, MISSING_PLUGIN,
(_("No URI handler implemented for \"%s\"."), prot), (NULL));
(_("A %s plugin is required to play this stream, but not installed."),
desc), ("No URI handler to handle sub_uri: %s", sub_uri));
g_free (desc);
g_free (prot);
} else
goto invalid_uri;
......@@ -1560,14 +1569,17 @@ no_source:
/* whoops, could not create the source element, dig a little deeper to
* figure out what might be wrong. */
if (prot) {
GstElement *this = GST_ELEMENT_CAST (play_base_bin);
GstMessage *msg;
gchar *desc;
msg = gst_missing_uri_source_message_new (this, prot);
gst_element_post_message (this, msg);
gst_element_post_message (GST_ELEMENT (play_base_bin),
gst_missing_uri_source_message_new (GST_ELEMENT (play_base_bin),
prot));
desc = gst_base_utils_get_source_description (prot);
GST_ELEMENT_ERROR (play_base_bin, CORE, MISSING_PLUGIN,
(_("No URI handler implemented for \"%s\"."), prot), (NULL));
(_("A %s plugin is required to play this stream, but not installed."),
desc), ("No URI handler for %s", prot));
g_free (desc);
g_free (prot);
} else
goto invalid_uri;
......@@ -2552,7 +2564,9 @@ gst_play_base_bin_change_state (GstElement * element, GstStateChange transition)
finish_source (play_base_bin);
break;
/* clean-up in both cases, READY=>NULL clean-up is if there was an error */
case GST_STATE_CHANGE_PAUSED_TO_READY:
case GST_STATE_CHANGE_READY_TO_NULL:
play_base_bin->need_rebuild = TRUE;
remove_decoders (play_base_bin);
remove_groups (play_base_bin);
......
......@@ -238,6 +238,58 @@ GST_START_TEST (test_missing_urisource_handler)
GST_END_TEST;
GST_START_TEST (test_missing_suburisource_handler)
{
GstStructure *s;
GstMessage *msg;
GstElement *playbin;
GError *err = NULL;
GstBus *bus;
playbin = create_playbin ("file:///does/not/exis.t");
g_object_set (playbin, "suburi", "cookie://withahint.of/cinnamon", NULL);
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
GST_STATE_CHANGE_SUCCESS);
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
GST_STATE_CHANGE_FAILURE);
/* there should be at least a missing-plugin message on the bus now and an
* error message; the missing-plugin message should be first */
bus = gst_element_get_bus (playbin);
msg = gst_bus_poll (bus, GST_MESSAGE_ELEMENT | GST_MESSAGE_ERROR, -1);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
fail_unless (msg->structure != NULL);
s = msg->structure;
fail_unless (gst_structure_has_name (s, "missing-plugin"));
fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "detail"), "cookie");
fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisource");
gst_message_unref (msg);
msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, -1);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ERROR);
/* make sure the error is a CORE MISSING_PLUGIN one */
gst_message_parse_error (msg, &err, NULL);
fail_unless (err != NULL);
fail_unless (err->domain == GST_CORE_ERROR, "error has wrong error domain "
"%s instead of core-error-quark", g_quark_to_string (err->domain));
fail_unless (err->code == GST_CORE_ERROR_MISSING_PLUGIN, "error has wrong "
"code %u instead of GST_CORE_ERROR_MISSING_PLUGIN", err->code);
g_error_free (err);
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (playbin, GST_STATE_NULL);
gst_object_unref (playbin);
}
GST_END_TEST;
GST_START_TEST (test_missing_primary_decoder)
{
GstStructure *s;
......@@ -536,6 +588,7 @@ playbin_suite (void)
tcase_add_test (tc_chain, test_suburi_error_invalidfile);
tcase_add_test (tc_chain, test_suburi_error_unknowntype);
tcase_add_test (tc_chain, test_missing_urisource_handler);
tcase_add_test (tc_chain, test_missing_suburisource_handler);
tcase_add_test (tc_chain, test_missing_primary_decoder);
/* one day we might also want to have the following checks:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment