summaryrefslogtreecommitdiff
path: root/sys/vcd
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2010-04-08 16:05:11 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-05-22 10:30:44 +0100
commitaf97600798d5d32ad05877b4e5a999a16a19b7c0 (patch)
tree32ea41b3a6f6db4e45ce314c2c68034f3af13e54 /sys/vcd
parent179555c45b8c58dded73acf7f600b14615fa167f (diff)
downloadgstreamer-plugins-bad-af97600798d5d32ad05877b4e5a999a16a19b7c0.tar.gz
vcdsrc: change VCD URI handler to the DVD scheme
The current URI parsing code doesn't allow setting the "device" from which the VCD should be read. Use the same structure as the DVD URI handling instead, so that devices can be passed in the URI, as well as track number. Up the rank of the VCD plugin so that it can be auto-plugged and used by Totem. https://bugzilla.gnome.org/show_bug.cgi?id=340986
Diffstat (limited to 'sys/vcd')
-rw-r--r--sys/vcd/vcdsrc.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/sys/vcd/vcdsrc.c b/sys/vcd/vcdsrc.c
index fa6f0439c..1f5718a1b 100644
--- a/sys/vcd/vcdsrc.c
+++ b/sys/vcd/vcdsrc.c
@@ -36,6 +36,8 @@
#include "vcdsrc.h"
+#define DEFAULT_DEVICE "/dev/cdrom"
+
/* VCDSrc signals and args */
enum
{
@@ -139,7 +141,7 @@ gst_vcdsrc_class_init (GstVCDSrcClass * klass)
static void
gst_vcdsrc_init (GstVCDSrc * vcdsrc, GstVCDSrcClass * klass)
{
- vcdsrc->device = g_strdup ("/dev/cdrom");
+ vcdsrc->device = g_strdup (DEFAULT_DEVICE);
vcdsrc->track = 1;
vcdsrc->fd = 0;
vcdsrc->trackoffset = 0;
@@ -373,12 +375,24 @@ gst_vcdsrc_start (GstBaseSrc * bsrc)
{
int i;
GstVCDSrc *src = GST_VCDSRC (bsrc);
+ struct stat buf;
/* open the device */
src->fd = open (src->device, O_RDONLY);
if (src->fd < 0)
goto open_failed;
+ if (fstat (src->fd, &buf) < 0)
+ goto toc_failed;
+ /* If it's not a block device, then we need to try and
+ * parse the cue file if there is one
+ * FIXME implement */
+ if (!S_ISBLK (buf.st_mode)) {
+ GST_DEBUG ("Reading CUE files not handled yet, cannot process %s",
+ GST_STR_NULL (src->device));
+ goto toc_failed;
+ }
+
/* read the table of contents */
if (ioctl (src->fd, CDROMREADTOCHDR, &src->tochdr))
goto toc_failed;
@@ -500,16 +514,32 @@ gst_vcdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
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;
+ /*
+ * URI structure: vcd:///path/to/device,track-num
+ */
+ if (g_str_has_prefix (uri, "vcd://")) {
+ GST_OBJECT_LOCK (src);
+ g_free (src->device);
+ if (strlen (uri) > 6)
+ src->device = g_strdup (uri + 6);
+ else
+ src->device = g_strdup (DEFAULT_DEVICE);
+ GST_DEBUG_OBJECT (src, "configured device %s", src->device);
+ GST_OBJECT_UNLOCK (src);
+ }
- if (tracknr < 1)
+ /* Parse the track number */
+ {
+ char **split;
+
+ split = g_strsplit (location, ",", 2);
+ if (split == NULL || *split == NULL || split[1] == NULL) {
+ tracknr = 1;
+ } else if (sscanf (split[1], "%d", &tracknr) != 1 || tracknr < 1) {
+ g_strfreev (split);
goto invalid_location;
+ }
+ g_strfreev (split);
}
GST_OBJECT_LOCK (src);
@@ -556,7 +586,7 @@ gst_vcdsrc_uri_handler_init (gpointer g_iface, gpointer iface_data)
static gboolean
plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "vcdsrc", GST_RANK_NONE,
+ return gst_element_register (plugin, "vcdsrc", GST_RANK_SECONDARY,
GST_TYPE_VCDSRC);
}