mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
gst/elements/gstfdsrc.*: Let's implement the URI interface.
Original commit message from CVS: * gst/elements/gstfdsrc.c: (_do_init), (gst_fdsrc_class_init), (gst_fdsrc_dispose), (gst_fdsrc_init), (gst_fdsrc_set_property), (gst_fdsrc_uri_get_type), (gst_fdsrc_uri_get_protocols), (gst_fdsrc_uri_get_uri), (gst_fdsrc_uri_set_uri), (gst_fdsrc_uri_handler_init): * gst/elements/gstfdsrc.h: Let's implement the URI interface.
This commit is contained in:
parent
f0423be7c0
commit
d985215629
5 changed files with 184 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-03-14 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
|
* gst/elements/gstfdsrc.c: (_do_init), (gst_fdsrc_class_init),
|
||||||
|
(gst_fdsrc_dispose), (gst_fdsrc_init), (gst_fdsrc_set_property),
|
||||||
|
(gst_fdsrc_uri_get_type), (gst_fdsrc_uri_get_protocols),
|
||||||
|
(gst_fdsrc_uri_get_uri), (gst_fdsrc_uri_set_uri),
|
||||||
|
(gst_fdsrc_uri_handler_init):
|
||||||
|
* gst/elements/gstfdsrc.h:
|
||||||
|
Let's implement the URI interface.
|
||||||
|
|
||||||
2005-03-13 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
2005-03-13 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
* gst/gsterror.c: (_gst_library_errors_init):
|
* gst/gsterror.c: (_gst_library_errors_init):
|
||||||
|
|
|
@ -74,19 +74,33 @@ enum
|
||||||
|
|
||||||
static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
#define _do_init(bla) \
|
static void gst_fdsrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element");
|
|
||||||
|
static void
|
||||||
|
_do_init (GType fdsrc_type)
|
||||||
|
{
|
||||||
|
static const GInterfaceInfo urihandler_info = {
|
||||||
|
gst_fdsrc_uri_handler_init,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
g_type_add_interface_static (fdsrc_type, GST_TYPE_URI_HANDLER,
|
||||||
|
&urihandler_info);
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element");
|
||||||
|
}
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT,
|
GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT,
|
||||||
_do_init);
|
_do_init);
|
||||||
|
|
||||||
|
static void gst_fdsrc_dispose (GObject * obj);
|
||||||
static void gst_fdsrc_set_property (GObject * object, guint prop_id,
|
static void gst_fdsrc_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_fdsrc_get_property (GObject * object, guint prop_id,
|
static void gst_fdsrc_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstElementStateReturn gst_fdsrc_change_state (GstElement * element);
|
static GstElementStateReturn gst_fdsrc_change_state (GstElement * element);
|
||||||
|
|
||||||
static GstData *gst_fdsrc_get (GstPad * pad);
|
static GstData *gst_fdsrc_get (GstPad * pad);
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,10 +139,22 @@ gst_fdsrc_class_init (GstFdSrcClass * klass)
|
||||||
|
|
||||||
gobject_class->set_property = gst_fdsrc_set_property;
|
gobject_class->set_property = gst_fdsrc_set_property;
|
||||||
gobject_class->get_property = gst_fdsrc_get_property;
|
gobject_class->get_property = gst_fdsrc_get_property;
|
||||||
|
gobject_class->dispose = gst_fdsrc_dispose;
|
||||||
|
|
||||||
gstelement_class->change_state = gst_fdsrc_change_state;
|
gstelement_class->change_state = gst_fdsrc_change_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_fdsrc_dispose (GObject * obj)
|
||||||
|
{
|
||||||
|
GstFdSrc *src = GST_FDSRC (obj);
|
||||||
|
|
||||||
|
g_free (src->uri);
|
||||||
|
src->uri = NULL;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_fdsrc_init (GstFdSrc * fdsrc)
|
gst_fdsrc_init (GstFdSrc * fdsrc)
|
||||||
{
|
{
|
||||||
|
@ -140,6 +166,7 @@ gst_fdsrc_init (GstFdSrc * fdsrc)
|
||||||
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
|
||||||
|
|
||||||
fdsrc->fd = 0;
|
fdsrc->fd = 0;
|
||||||
|
fdsrc->uri = g_strdup_printf ("fd://%d", fdsrc->fd);
|
||||||
fdsrc->curoffset = 0;
|
fdsrc->curoffset = 0;
|
||||||
fdsrc->blocksize = DEFAULT_BLOCKSIZE;
|
fdsrc->blocksize = DEFAULT_BLOCKSIZE;
|
||||||
fdsrc->timeout = 0;
|
fdsrc->timeout = 0;
|
||||||
|
@ -186,6 +213,8 @@ gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_FD:
|
case ARG_FD:
|
||||||
src->fd = g_value_get_int (value);
|
src->fd = g_value_get_int (value);
|
||||||
|
g_free (src->uri);
|
||||||
|
src->uri = g_strdup_printf ("fd://%d", src->fd);
|
||||||
break;
|
break;
|
||||||
case ARG_BLOCKSIZE:
|
case ARG_BLOCKSIZE:
|
||||||
src->blocksize = g_value_get_ulong (value);
|
src->blocksize = g_value_get_ulong (value);
|
||||||
|
@ -291,3 +320,57 @@ gst_fdsrc_get (GstPad * pad)
|
||||||
return GST_DATA (gst_event_new (GST_EVENT_EOS));
|
return GST_DATA (gst_event_new (GST_EVENT_EOS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** GSTURIHANDLER INTERFACE *************************************************/
|
||||||
|
|
||||||
|
static guint
|
||||||
|
gst_fdsrc_uri_get_type (void)
|
||||||
|
{
|
||||||
|
return GST_URI_SRC;
|
||||||
|
}
|
||||||
|
static gchar **
|
||||||
|
gst_fdsrc_uri_get_protocols (void)
|
||||||
|
{
|
||||||
|
static gchar *protocols[] = { "fd", NULL };
|
||||||
|
|
||||||
|
return protocols;
|
||||||
|
}
|
||||||
|
static const gchar *
|
||||||
|
gst_fdsrc_uri_get_uri (GstURIHandler * handler)
|
||||||
|
{
|
||||||
|
GstFdSrc *src = GST_FDSRC (handler);
|
||||||
|
|
||||||
|
return src->uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_fdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
|
||||||
|
{
|
||||||
|
gchar *protocol;
|
||||||
|
GstFdSrc *src = GST_FDSRC (handler);
|
||||||
|
gint fd = src->fd;
|
||||||
|
|
||||||
|
protocol = gst_uri_get_protocol (uri);
|
||||||
|
if (strcmp (protocol, "fd") != 0) {
|
||||||
|
g_free (protocol);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
g_free (protocol);
|
||||||
|
sscanf (uri, "fd://%d", &fd);
|
||||||
|
src->fd = fd;
|
||||||
|
g_free (src->uri);
|
||||||
|
src->uri = g_strdup (uri);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_fdsrc_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
||||||
|
{
|
||||||
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
|
||||||
|
|
||||||
|
iface->get_type = gst_fdsrc_uri_get_type;
|
||||||
|
iface->get_protocols = gst_fdsrc_uri_get_protocols;
|
||||||
|
iface->get_uri = gst_fdsrc_uri_get_uri;
|
||||||
|
iface->set_uri = gst_fdsrc_uri_set_uri;
|
||||||
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct _GstFdSrc {
|
||||||
|
|
||||||
/* fd */
|
/* fd */
|
||||||
gint fd;
|
gint fd;
|
||||||
|
gchar *uri;
|
||||||
|
|
||||||
gulong curoffset; /* current offset in file */
|
gulong curoffset; /* current offset in file */
|
||||||
gulong blocksize; /* bytes per read */
|
gulong blocksize; /* bytes per read */
|
||||||
|
|
|
@ -74,19 +74,33 @@ enum
|
||||||
|
|
||||||
static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
#define _do_init(bla) \
|
static void gst_fdsrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element");
|
|
||||||
|
static void
|
||||||
|
_do_init (GType fdsrc_type)
|
||||||
|
{
|
||||||
|
static const GInterfaceInfo urihandler_info = {
|
||||||
|
gst_fdsrc_uri_handler_init,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
g_type_add_interface_static (fdsrc_type, GST_TYPE_URI_HANDLER,
|
||||||
|
&urihandler_info);
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element");
|
||||||
|
}
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT,
|
GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT,
|
||||||
_do_init);
|
_do_init);
|
||||||
|
|
||||||
|
static void gst_fdsrc_dispose (GObject * obj);
|
||||||
static void gst_fdsrc_set_property (GObject * object, guint prop_id,
|
static void gst_fdsrc_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_fdsrc_get_property (GObject * object, guint prop_id,
|
static void gst_fdsrc_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstElementStateReturn gst_fdsrc_change_state (GstElement * element);
|
static GstElementStateReturn gst_fdsrc_change_state (GstElement * element);
|
||||||
|
|
||||||
static GstData *gst_fdsrc_get (GstPad * pad);
|
static GstData *gst_fdsrc_get (GstPad * pad);
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,10 +139,22 @@ gst_fdsrc_class_init (GstFdSrcClass * klass)
|
||||||
|
|
||||||
gobject_class->set_property = gst_fdsrc_set_property;
|
gobject_class->set_property = gst_fdsrc_set_property;
|
||||||
gobject_class->get_property = gst_fdsrc_get_property;
|
gobject_class->get_property = gst_fdsrc_get_property;
|
||||||
|
gobject_class->dispose = gst_fdsrc_dispose;
|
||||||
|
|
||||||
gstelement_class->change_state = gst_fdsrc_change_state;
|
gstelement_class->change_state = gst_fdsrc_change_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_fdsrc_dispose (GObject * obj)
|
||||||
|
{
|
||||||
|
GstFdSrc *src = GST_FDSRC (obj);
|
||||||
|
|
||||||
|
g_free (src->uri);
|
||||||
|
src->uri = NULL;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_fdsrc_init (GstFdSrc * fdsrc)
|
gst_fdsrc_init (GstFdSrc * fdsrc)
|
||||||
{
|
{
|
||||||
|
@ -140,6 +166,7 @@ gst_fdsrc_init (GstFdSrc * fdsrc)
|
||||||
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
|
||||||
|
|
||||||
fdsrc->fd = 0;
|
fdsrc->fd = 0;
|
||||||
|
fdsrc->uri = g_strdup_printf ("fd://%d", fdsrc->fd);
|
||||||
fdsrc->curoffset = 0;
|
fdsrc->curoffset = 0;
|
||||||
fdsrc->blocksize = DEFAULT_BLOCKSIZE;
|
fdsrc->blocksize = DEFAULT_BLOCKSIZE;
|
||||||
fdsrc->timeout = 0;
|
fdsrc->timeout = 0;
|
||||||
|
@ -186,6 +213,8 @@ gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_FD:
|
case ARG_FD:
|
||||||
src->fd = g_value_get_int (value);
|
src->fd = g_value_get_int (value);
|
||||||
|
g_free (src->uri);
|
||||||
|
src->uri = g_strdup_printf ("fd://%d", src->fd);
|
||||||
break;
|
break;
|
||||||
case ARG_BLOCKSIZE:
|
case ARG_BLOCKSIZE:
|
||||||
src->blocksize = g_value_get_ulong (value);
|
src->blocksize = g_value_get_ulong (value);
|
||||||
|
@ -291,3 +320,57 @@ gst_fdsrc_get (GstPad * pad)
|
||||||
return GST_DATA (gst_event_new (GST_EVENT_EOS));
|
return GST_DATA (gst_event_new (GST_EVENT_EOS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** GSTURIHANDLER INTERFACE *************************************************/
|
||||||
|
|
||||||
|
static guint
|
||||||
|
gst_fdsrc_uri_get_type (void)
|
||||||
|
{
|
||||||
|
return GST_URI_SRC;
|
||||||
|
}
|
||||||
|
static gchar **
|
||||||
|
gst_fdsrc_uri_get_protocols (void)
|
||||||
|
{
|
||||||
|
static gchar *protocols[] = { "fd", NULL };
|
||||||
|
|
||||||
|
return protocols;
|
||||||
|
}
|
||||||
|
static const gchar *
|
||||||
|
gst_fdsrc_uri_get_uri (GstURIHandler * handler)
|
||||||
|
{
|
||||||
|
GstFdSrc *src = GST_FDSRC (handler);
|
||||||
|
|
||||||
|
return src->uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_fdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
|
||||||
|
{
|
||||||
|
gchar *protocol;
|
||||||
|
GstFdSrc *src = GST_FDSRC (handler);
|
||||||
|
gint fd = src->fd;
|
||||||
|
|
||||||
|
protocol = gst_uri_get_protocol (uri);
|
||||||
|
if (strcmp (protocol, "fd") != 0) {
|
||||||
|
g_free (protocol);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
g_free (protocol);
|
||||||
|
sscanf (uri, "fd://%d", &fd);
|
||||||
|
src->fd = fd;
|
||||||
|
g_free (src->uri);
|
||||||
|
src->uri = g_strdup (uri);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_fdsrc_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
||||||
|
{
|
||||||
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
|
||||||
|
|
||||||
|
iface->get_type = gst_fdsrc_uri_get_type;
|
||||||
|
iface->get_protocols = gst_fdsrc_uri_get_protocols;
|
||||||
|
iface->get_uri = gst_fdsrc_uri_get_uri;
|
||||||
|
iface->set_uri = gst_fdsrc_uri_set_uri;
|
||||||
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct _GstFdSrc {
|
||||||
|
|
||||||
/* fd */
|
/* fd */
|
||||||
gint fd;
|
gint fd;
|
||||||
|
gchar *uri;
|
||||||
|
|
||||||
gulong curoffset; /* current offset in file */
|
gulong curoffset; /* current offset in file */
|
||||||
gulong blocksize; /* bytes per read */
|
gulong blocksize; /* bytes per read */
|
||||||
|
|
Loading…
Reference in a new issue