mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
gst/elements/gstfdsrc.*: Port fd:// URI handler from 0.8 to fdsrc
Original commit message from CVS: * gst/elements/gstfdsrc.c: (_do_init), (gst_fdsrc_class_init), (gst_fdsrc_init), (gst_fdsrc_dispose), (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: Port fd:// URI handler from 0.8 to fdsrc
This commit is contained in:
parent
29ea4a0bb0
commit
58acf5f046
5 changed files with 192 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-11-21 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
|
* gst/elements/gstfdsrc.c: (_do_init), (gst_fdsrc_class_init),
|
||||||
|
(gst_fdsrc_init), (gst_fdsrc_dispose), (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:
|
||||||
|
Port fd:// URI handler from 0.8 to fdsrc
|
||||||
|
|
||||||
2005-11-21 Tim-Philipp Müller <tim at centricular dot net>
|
2005-11-21 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst/gstvalue.c: (gst_value_transform_fourcc_string),
|
* gst/gstvalue.c: (gst_value_transform_fourcc_string),
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <io.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -72,15 +75,28 @@ static GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ("Disk Source",
|
||||||
"Synchronous read from a file",
|
"Synchronous read from a file",
|
||||||
"Erik Walthinsen <omega@cse.ogi.edu>");
|
"Erik Walthinsen <omega@cse.ogi.edu>");
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_FD,
|
PROP_FD,
|
||||||
};
|
};
|
||||||
|
|
||||||
#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_PUSH_SRC,
|
GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_PUSH_SRC,
|
||||||
_do_init);
|
_do_init);
|
||||||
|
@ -89,6 +105,7 @@ 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 void gst_fdsrc_dispose (GObject * obj);
|
||||||
|
|
||||||
static gboolean gst_fdsrc_start (GstBaseSrc * bsrc);
|
static gboolean gst_fdsrc_start (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_fdsrc_stop (GstBaseSrc * bsrc);
|
static gboolean gst_fdsrc_stop (GstBaseSrc * bsrc);
|
||||||
|
@ -123,6 +140,7 @@ 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;
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FD,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FD,
|
||||||
g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
|
g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
|
||||||
|
@ -143,9 +161,21 @@ gst_fdsrc_init (GstFdSrc * fdsrc, GstFdSrcClass * klass)
|
||||||
gst_base_src_set_live (GST_BASE_SRC (fdsrc), TRUE);
|
gst_base_src_set_live (GST_BASE_SRC (fdsrc), TRUE);
|
||||||
|
|
||||||
fdsrc->fd = 0;
|
fdsrc->fd = 0;
|
||||||
|
fdsrc->uri = g_strdup_printf ("fd://%d", fdsrc->fd);
|
||||||
fdsrc->curoffset = 0;
|
fdsrc->curoffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 gboolean
|
static gboolean
|
||||||
gst_fdsrc_start (GstBaseSrc * bsrc)
|
gst_fdsrc_start (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
|
@ -204,6 +234,8 @@ gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_FD:
|
case PROP_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;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -328,3 +360,57 @@ read_error:
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** 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;
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ struct _GstFdSrc {
|
||||||
gint control_sock[2];
|
gint control_sock[2];
|
||||||
|
|
||||||
gulong curoffset; /* current offset in file */
|
gulong curoffset; /* current offset in file */
|
||||||
|
|
||||||
|
gchar *uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstFdSrcClass {
|
struct _GstFdSrcClass {
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <io.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -72,15 +75,28 @@ static GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ("Disk Source",
|
||||||
"Synchronous read from a file",
|
"Synchronous read from a file",
|
||||||
"Erik Walthinsen <omega@cse.ogi.edu>");
|
"Erik Walthinsen <omega@cse.ogi.edu>");
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_FD,
|
PROP_FD,
|
||||||
};
|
};
|
||||||
|
|
||||||
#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_PUSH_SRC,
|
GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_PUSH_SRC,
|
||||||
_do_init);
|
_do_init);
|
||||||
|
@ -89,6 +105,7 @@ 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 void gst_fdsrc_dispose (GObject * obj);
|
||||||
|
|
||||||
static gboolean gst_fdsrc_start (GstBaseSrc * bsrc);
|
static gboolean gst_fdsrc_start (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_fdsrc_stop (GstBaseSrc * bsrc);
|
static gboolean gst_fdsrc_stop (GstBaseSrc * bsrc);
|
||||||
|
@ -123,6 +140,7 @@ 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;
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FD,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FD,
|
||||||
g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
|
g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
|
||||||
|
@ -143,9 +161,21 @@ gst_fdsrc_init (GstFdSrc * fdsrc, GstFdSrcClass * klass)
|
||||||
gst_base_src_set_live (GST_BASE_SRC (fdsrc), TRUE);
|
gst_base_src_set_live (GST_BASE_SRC (fdsrc), TRUE);
|
||||||
|
|
||||||
fdsrc->fd = 0;
|
fdsrc->fd = 0;
|
||||||
|
fdsrc->uri = g_strdup_printf ("fd://%d", fdsrc->fd);
|
||||||
fdsrc->curoffset = 0;
|
fdsrc->curoffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 gboolean
|
static gboolean
|
||||||
gst_fdsrc_start (GstBaseSrc * bsrc)
|
gst_fdsrc_start (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
|
@ -204,6 +234,8 @@ gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_FD:
|
case PROP_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;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -328,3 +360,57 @@ read_error:
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** 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;
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ struct _GstFdSrc {
|
||||||
gint control_sock[2];
|
gint control_sock[2];
|
||||||
|
|
||||||
gulong curoffset; /* current offset in file */
|
gulong curoffset; /* current offset in file */
|
||||||
|
|
||||||
|
gchar *uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstFdSrcClass {
|
struct _GstFdSrcClass {
|
||||||
|
|
Loading…
Reference in a new issue