summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--sys/vcd/vcdsrc.c67
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 <wim.taymans@collabora.co.uk>
+
+ Based on patch by: <onkarshinde at gmail dot com>
+
+ * 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 <slomo@circular-chaos.org>
* 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