parent a105af22
......@@ -417,7 +417,7 @@ GST_PLUGINS_NONPORTED=" cdxaparse \
patchdetect real \
sdi tta \
videomeasure \
linsys vcd \
linsys \
apexsink dc1394 \
gsettings \
musepack nas sdl timidity \
......
......@@ -62,22 +62,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_vcdsrc_debug);
#define GST_CAT_DEFAULT gst_vcdsrc_debug
static void gst_vcdsrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
static void
gst_vcdsrc_setup_interfaces (GType type)
{
static const GInterfaceInfo urihandler_info = {
gst_vcdsrc_uri_handler_init,
NULL,
NULL,
};
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
}
GST_BOILERPLATE_FULL (GstVCDSrc, gst_vcdsrc, GstPushSrc, GST_TYPE_PUSH_SRC,
gst_vcdsrc_setup_interfaces);
#define gst_vcdsrc_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstVCDSrc, gst_vcdsrc, GST_TYPE_PUSH_SRC,
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_vcdsrc_uri_handler_init));
static void gst_vcdsrc_finalize (GObject * object);
......@@ -90,29 +77,19 @@ static gboolean gst_vcdsrc_start (GstBaseSrc * src);
static gboolean gst_vcdsrc_stop (GstBaseSrc * src);
static GstFlowReturn gst_vcdsrc_create (GstPushSrc * src, GstBuffer ** out);
static void
gst_vcdsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_static_metadata (element_class, "VCD Source",
"Source/File",
"Asynchronous read from VCD disk", "Erik Walthinsen <omega@cse.ogi.edu>");
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&srctemplate));
}
static void
gst_vcdsrc_class_init (GstVCDSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *element_class;
GstBaseSrcClass *basesrc_class;
GstPushSrcClass *pushsrc_class;
gobject_class = (GObjectClass *) klass;
basesrc_class = (GstBaseSrcClass *) klass;
pushsrc_class = (GstPushSrcClass *) klass;
element_class = (GstElementClass *) klass;
gobject_class->set_property = gst_vcdsrc_set_property;
gobject_class->get_property = gst_vcdsrc_get_property;
......@@ -136,10 +113,17 @@ gst_vcdsrc_class_init (GstVCDSrcClass * klass)
GST_DEBUG_CATEGORY_INIT (gst_vcdsrc_debug, "vcdsrc", 0,
"VideoCD Source element");
gst_element_class_set_static_metadata (element_class, "VCD Source",
"Source/File",
"Asynchronous read from VCD disk", "Erik Walthinsen <omega@cse.ogi.edu>");
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&srctemplate));
}
static void
gst_vcdsrc_init (GstVCDSrc * vcdsrc, GstVCDSrcClass * klass)
gst_vcdsrc_init (GstVCDSrc * vcdsrc)
{
vcdsrc->device = g_strdup (DEFAULT_DEVICE);
vcdsrc->track = 1;
......@@ -317,6 +301,7 @@ gst_vcdsrc_create (GstPushSrc * src, GstBuffer ** buf)
{
GstVCDSrc *vcdsrc;
GstBuffer *outbuf;
GstMapInfo map_info;
gulong offset;
struct cdrom_msf *msf;
gint error_count = 0;
......@@ -328,8 +313,15 @@ gst_vcdsrc_create (GstPushSrc * src, GstBuffer ** buf)
goto eos;
/* create the buffer */
outbuf = gst_buffer_new_and_alloc (vcdsrc->bytes_per_read);
msf = (struct cdrom_msf *) GST_BUFFER_DATA (outbuf);
outbuf = gst_buffer_new_allocate (NULL, vcdsrc->bytes_per_read, NULL);
if (!outbuf)
goto error_unmapped;
if (!gst_buffer_map (outbuf, &map_info, GST_MAP_READWRITE))
goto error_unmapped;
msf = (struct cdrom_msf *) map_info.data;
read:
/* read it in from the device */
......@@ -351,21 +343,26 @@ read:
("Read from cdrom at %d:%d:%d failed: %s",
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0,
strerror (errno)));
return GST_FLOW_ERROR;
goto error_mapped;
}
GST_BUFFER_SIZE (outbuf) = vcdsrc->bytes_per_read;
gst_buffer_unmap (outbuf, &map_info);
vcdsrc->curoffset += 1;
*buf = outbuf;
return GST_FLOW_OK;
/* ERRORS */
error_mapped:
gst_buffer_unmap (outbuf, &map_info);
error_unmapped:
if (outbuf)
gst_buffer_unref (outbuf);
return GST_FLOW_ERROR;
eos:
{
GST_DEBUG_OBJECT (vcdsrc, "got eos");
return GST_FLOW_UNEXPECTED;
return GST_FLOW_EOS;
}
}
......@@ -463,21 +460,21 @@ gst_vcdsrc_stop (GstBaseSrc * bsrc)
* URI interface.
*/
static guint
gst_vcdsrc_uri_get_type (void)
static GstURIType
gst_vcdsrc_uri_get_type (GType type)
{
return GST_URI_SRC;
}
static gchar **
gst_vcdsrc_uri_get_protocols (void)
static const gchar *const *
gst_vcdsrc_uri_get_protocols (GType type)
{
static gchar *protocols[] = { (char *) "vcd", NULL };
static const gchar *protocols[] = { "vcd", NULL };
return protocols;
}
static const gchar *
static gchar *
gst_vcdsrc_uri_get_uri (GstURIHandler * handler)
{
GstVCDSrc *src = GST_VCDSRC (handler);
......@@ -491,7 +488,8 @@ gst_vcdsrc_uri_get_uri (GstURIHandler * handler)
}
static gboolean
gst_vcdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
gst_vcdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
GstVCDSrc *src = GST_VCDSRC (handler);
gchar *location = NULL;
......@@ -548,17 +546,23 @@ gst_vcdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
/* ERRORS */
wrong_protocol:
{
GST_ERROR_OBJECT (src, "wrong protocol, uri = %s", uri);
GST_ERROR_OBJECT (src, "Wrong protocol, uri = %s", uri);
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_UNSUPPORTED_PROTOCOL,
"Wrong protocol, uri = %s", uri);
return FALSE;
}
no_location:
{
GST_ERROR_OBJECT (src, "no location specified");
GST_ERROR_OBJECT (src, "No location specified");
g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"No location specified");
return FALSE;
}
invalid_location:
{
GST_ERROR_OBJECT (src, "Invalid location %s in URI '%s'", location, uri);
GST_ERROR_OBJECT (src, "Invalid location '%s' in URI '%s'", location, uri);
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"Invalid location '%s' in URI '%s'", location, uri);
g_free (location);
return FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment