From 8d55304d61a6a7e970a2e00f8129378921899b99 Mon Sep 17 00:00:00 2001 From: Onkar Shinde Date: Wed, 28 May 2008 08:53:00 +0000 Subject: sys/vcd/vcdsrc.c: Allow the track to be set by using the uri. Fixes #535043. Original commit message from CVS: Based on patch by: * sys/vcd/vcdsrc.c: (gst_vcdsrc_uri_get_uri), (gst_vcdsrc_uri_set_uri): Allow the track to be set by using the uri. Fixes #535043. --- ChangeLog | 8 +++++++ sys/vcd/vcdsrc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 973fdc08..26962d36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-05-28 Wim Taymans + + Based on patch by: + + * sys/vcd/vcdsrc.c: (gst_vcdsrc_uri_get_uri), + (gst_vcdsrc_uri_set_uri): + Allow the track to be set by using the uri. Fixes #535043. + 2008-05-28 Sebastian Dröge * gst/interleave/interleave.c: (gst_interleave_src_query_duration), diff --git a/sys/vcd/vcdsrc.c b/sys/vcd/vcdsrc.c index 0ccebc33..a96efd70 100644 --- a/sys/vcd/vcdsrc.c +++ b/sys/vcd/vcdsrc.c @@ -470,21 +470,80 @@ gst_vcdsrc_uri_get_protocols (void) static const gchar * gst_vcdsrc_uri_get_uri (GstURIHandler * handler) { - return "vcd://"; + GstVCDSrc *src = GST_VCDSRC (handler); + gchar *result; + + GST_OBJECT_LOCK (src); + result = g_strdup_printf ("vcd://%d", src->track); + GST_OBJECT_UNLOCK (src); + + return result; } static gboolean gst_vcdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri) { - gboolean ret; + GstVCDSrc *src = GST_VCDSRC (handler); gchar *protocol; + gchar *location = NULL; + gint tracknr; + + GST_DEBUG_OBJECT (src, "setting uri '%s'", uri); protocol = gst_uri_get_protocol (uri); - ret = (protocol && !strcmp (protocol, "vcd")) ? TRUE : FALSE; + if (protocol == NULL || strcmp (protocol, "vcd")) + goto wrong_protocol; + + GST_DEBUG_OBJECT (src, "have protocol '%s'", protocol); g_free (protocol); - return ret; + /* parse out the track in the location */ + if (!(location = gst_uri_get_location (uri))) + goto no_location; + + GST_DEBUG_OBJECT (src, "have location '%s'", location); + + if (*location == '\0') { + /* empty location selects track 1 */ + tracknr = 1; + } else { + /* scan the track number */ + if (sscanf (location, "%d", &tracknr) != 1) + goto invalid_location; + + if (tracknr < 1) + goto invalid_location; + } + + GST_OBJECT_LOCK (src); + src->track = tracknr; + GST_DEBUG_OBJECT (src, "configured track %d", src->track); + GST_OBJECT_UNLOCK (src); + + g_free (location); + + return TRUE; + + /* ERRORS */ +wrong_protocol: + { + GST_ERROR_OBJECT (src, "wrong protocol %s specified", + GST_STR_NULL (protocol)); + g_free (protocol); + return FALSE; + } +no_location: + { + GST_ERROR_OBJECT (src, "no location specified"); + return FALSE; + } +invalid_location: + { + GST_ERROR_OBJECT (src, "Invalid location %s in URI '%s'", location, uri); + g_free (location); + return FALSE; + } } static void -- cgit v1.2.1