summaryrefslogtreecommitdiff
path: root/sys/vcd
diff options
context:
space:
mode:
authorOnkar Shinde <onkarshinde@gmail.com>2008-05-28 08:53:00 +0000
committerWim Taymans <wim.taymans@gmail.com>2008-05-28 08:53:00 +0000
commit8d55304d61a6a7e970a2e00f8129378921899b99 (patch)
tree6adab9bedb1f81b1ff1d39acc3b820f0f79fc4e7 /sys/vcd
parente5a3ccfa81784021472ec961c08c3d1a1ffc3687 (diff)
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: <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.
Diffstat (limited to 'sys/vcd')
-rw-r--r--sys/vcd/vcdsrc.c67
1 files changed, 63 insertions, 4 deletions
diff --git a/sys/vcd/vcdsrc.c b/sys/vcd/vcdsrc.c
index 0ccebc330..a96efd70b 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