mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-14 07:32:50 +00:00
parent
a105af22f2
commit
89eb1e9a03
2 changed files with 50 additions and 46 deletions
|
@ -417,7 +417,7 @@ GST_PLUGINS_NONPORTED=" cdxaparse \
|
||||||
patchdetect real \
|
patchdetect real \
|
||||||
sdi tta \
|
sdi tta \
|
||||||
videomeasure \
|
videomeasure \
|
||||||
linsys vcd \
|
linsys \
|
||||||
apexsink dc1394 \
|
apexsink dc1394 \
|
||||||
gsettings \
|
gsettings \
|
||||||
musepack nas sdl timidity \
|
musepack nas sdl timidity \
|
||||||
|
|
|
@ -62,22 +62,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_vcdsrc_debug);
|
||||||
#define GST_CAT_DEFAULT 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_uri_handler_init (gpointer g_iface, gpointer iface_data);
|
||||||
|
#define gst_vcdsrc_parent_class parent_class
|
||||||
static void
|
G_DEFINE_TYPE_WITH_CODE (GstVCDSrc, gst_vcdsrc, GST_TYPE_PUSH_SRC,
|
||||||
gst_vcdsrc_setup_interfaces (GType type)
|
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_vcdsrc_uri_handler_init));
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
static void gst_vcdsrc_finalize (GObject * object);
|
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 gboolean gst_vcdsrc_stop (GstBaseSrc * src);
|
||||||
static GstFlowReturn gst_vcdsrc_create (GstPushSrc * src, GstBuffer ** out);
|
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
|
static void
|
||||||
gst_vcdsrc_class_init (GstVCDSrcClass * klass)
|
gst_vcdsrc_class_init (GstVCDSrcClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *element_class;
|
||||||
GstBaseSrcClass *basesrc_class;
|
GstBaseSrcClass *basesrc_class;
|
||||||
GstPushSrcClass *pushsrc_class;
|
GstPushSrcClass *pushsrc_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
basesrc_class = (GstBaseSrcClass *) klass;
|
basesrc_class = (GstBaseSrcClass *) klass;
|
||||||
pushsrc_class = (GstPushSrcClass *) klass;
|
pushsrc_class = (GstPushSrcClass *) klass;
|
||||||
|
element_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
gobject_class->set_property = gst_vcdsrc_set_property;
|
gobject_class->set_property = gst_vcdsrc_set_property;
|
||||||
gobject_class->get_property = gst_vcdsrc_get_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,
|
GST_DEBUG_CATEGORY_INIT (gst_vcdsrc_debug, "vcdsrc", 0,
|
||||||
"VideoCD Source element");
|
"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
|
static void
|
||||||
gst_vcdsrc_init (GstVCDSrc * vcdsrc, GstVCDSrcClass * klass)
|
gst_vcdsrc_init (GstVCDSrc * vcdsrc)
|
||||||
{
|
{
|
||||||
vcdsrc->device = g_strdup (DEFAULT_DEVICE);
|
vcdsrc->device = g_strdup (DEFAULT_DEVICE);
|
||||||
vcdsrc->track = 1;
|
vcdsrc->track = 1;
|
||||||
|
@ -317,6 +301,7 @@ gst_vcdsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
||||||
{
|
{
|
||||||
GstVCDSrc *vcdsrc;
|
GstVCDSrc *vcdsrc;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
GstMapInfo map_info;
|
||||||
gulong offset;
|
gulong offset;
|
||||||
struct cdrom_msf *msf;
|
struct cdrom_msf *msf;
|
||||||
gint error_count = 0;
|
gint error_count = 0;
|
||||||
|
@ -328,8 +313,15 @@ gst_vcdsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
outbuf = gst_buffer_new_and_alloc (vcdsrc->bytes_per_read);
|
outbuf = gst_buffer_new_allocate (NULL, vcdsrc->bytes_per_read, NULL);
|
||||||
msf = (struct cdrom_msf *) GST_BUFFER_DATA (outbuf);
|
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:
|
||||||
/* read it in from the device */
|
/* read it in from the device */
|
||||||
|
@ -351,21 +343,26 @@ read:
|
||||||
("Read from cdrom at %d:%d:%d failed: %s",
|
("Read from cdrom at %d:%d:%d failed: %s",
|
||||||
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0,
|
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0,
|
||||||
strerror (errno)));
|
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;
|
vcdsrc->curoffset += 1;
|
||||||
|
|
||||||
*buf = outbuf;
|
*buf = outbuf;
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
error_mapped:
|
||||||
|
gst_buffer_unmap (outbuf, &map_info);
|
||||||
|
error_unmapped:
|
||||||
|
if (outbuf)
|
||||||
|
gst_buffer_unref (outbuf);
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
eos:
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (vcdsrc, "got 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.
|
* URI interface.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static guint
|
static GstURIType
|
||||||
gst_vcdsrc_uri_get_type (void)
|
gst_vcdsrc_uri_get_type (GType type)
|
||||||
{
|
{
|
||||||
return GST_URI_SRC;
|
return GST_URI_SRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar **
|
static const gchar *const *
|
||||||
gst_vcdsrc_uri_get_protocols (void)
|
gst_vcdsrc_uri_get_protocols (GType type)
|
||||||
{
|
{
|
||||||
static gchar *protocols[] = { (char *) "vcd", NULL };
|
static const gchar *protocols[] = { "vcd", NULL };
|
||||||
|
|
||||||
return protocols;
|
return protocols;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar *
|
static gchar *
|
||||||
gst_vcdsrc_uri_get_uri (GstURIHandler * handler)
|
gst_vcdsrc_uri_get_uri (GstURIHandler * handler)
|
||||||
{
|
{
|
||||||
GstVCDSrc *src = GST_VCDSRC (handler);
|
GstVCDSrc *src = GST_VCDSRC (handler);
|
||||||
|
@ -491,7 +488,8 @@ gst_vcdsrc_uri_get_uri (GstURIHandler * handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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);
|
GstVCDSrc *src = GST_VCDSRC (handler);
|
||||||
gchar *location = NULL;
|
gchar *location = NULL;
|
||||||
|
@ -548,17 +546,23 @@ gst_vcdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
wrong_protocol:
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
no_location:
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
invalid_location:
|
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);
|
g_free (location);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue