From 0a5fbd4d3b4244e30c6703a58230c04a42754573 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 16 Oct 2015 11:54:18 +0100 Subject: [PATCH] docs: manual: improve advanced metadata example a bit Accept both filename and a URI as argument, and print the error from the error message if there's an error. https://bugzilla.gnome.org/show_bug.cgi?id=756630 --- docs/manual/advanced-metadata.xml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/manual/advanced-metadata.xml b/docs/manual/advanced-metadata.xml index 78a3677..f975409 100644 --- a/docs/manual/advanced-metadata.xml +++ b/docs/manual/advanced-metadata.xml @@ -107,16 +107,23 @@ main (int argc, char ** argv) { GstElement *pipe, *dec, *sink; GstMessage *msg; + gchar *uri; gst_init (&argc, &argv); - if (argc < 2 || !gst_uri_is_valid (argv[1])) - g_error ("Usage: %s file:///path/to/file", argv[0]); + if (argc < 2) + g_error ("Usage: %s FILE or URI", argv[0]); + + if (gst_uri_is_valid (argv[1])) { + uri = g_strdup (argv[1]); + } else { + uri = gst_filename_to_uri (argv[1], NULL); + } pipe = gst_pipeline_new ("pipeline"); dec = gst_element_factory_make ("uridecodebin", NULL); - g_object_set (dec, "uri", argv[1], NULL); + g_object_set (dec, "uri", uri, NULL); gst_bin_add (GST_BIN (pipe), dec); sink = gst_element_factory_make ("fakesink", NULL); @@ -144,14 +151,20 @@ main (int argc, char ** argv) gst_tag_list_unref (tags); gst_message_unref (msg); - }; + } - if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) - g_error ("Got error"); + if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) { + GError *err = NULL; + + gst_message_parse_error (msg, &err, NULL); + g_printerr ("Got error: %s\n", err->message); + g_error_free (err); + } gst_message_unref (msg); gst_element_set_state (pipe, GST_STATE_NULL); gst_object_unref (pipe); + g_free (uri); return 0; } -- 2.7.4