Commit e20d6f0b authored by Wim Taymans's avatar Wim Taymans

v4l2: port to 0.11

parent a3a253af
......@@ -64,8 +64,8 @@ gst_meta_v4l2_get_info (void)
meta_info =
gst_meta_register ("GstMetaV4l2", "GstMetaV4l2",
sizeof (GstMetaV4l2), (GstMetaInitFunction) NULL,
(GstMetaFreeFunction) NULL, (GstMetaTransformFunction) NULL,
(GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
(GstMetaFreeFunction) NULL, (GstMetaCopyFunction) NULL,
(GstMetaTransformFunction) NULL);
}
return meta_info;
}
......@@ -110,7 +110,6 @@ gst_v4l2_buffer_dispose (GstBuffer * buffer)
/* FIXME: check that the caps didn't change */
GST_LOG_OBJECT (pool->v4l2elem, "reviving buffer %p, %d", buffer, index);
gst_buffer_ref (buffer);
GST_BUFFER_SIZE (buffer) = 0;
pool->buffers[index] = buffer;
}
......@@ -119,8 +118,8 @@ gst_v4l2_buffer_dispose (GstBuffer * buffer)
if (!resuscitated) {
GST_LOG_OBJECT (pool->v4l2elem,
"buffer %p (data %p, len %u) not recovered, unmapping",
buffer, GST_BUFFER_DATA (buffer), meta->vbuffer.length);
v4l2_munmap ((void *) GST_BUFFER_DATA (buffer), meta->vbuffer.length);
buffer, meta->mem, meta->vbuffer.length);
v4l2_munmap (meta->mem, meta->vbuffer.length);
g_object_unref (pool);
}
......@@ -130,7 +129,6 @@ static GstBuffer *
gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
{
GstBuffer *ret;
guint8 *mem;
GstMetaV4l2 *meta;
ret = gst_buffer_new ();
......@@ -163,19 +161,15 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
GST_LOG_OBJECT (pool->v4l2elem, " length: %u", meta->vbuffer.length);
GST_LOG_OBJECT (pool->v4l2elem, " input: %u", meta->vbuffer.input);
mem = (guint8 *) v4l2_mmap (0, meta->vbuffer.length,
meta->mem = v4l2_mmap (0, meta->vbuffer.length,
PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
meta->vbuffer.m.offset);
if (mem == MAP_FAILED)
if (meta->mem == MAP_FAILED)
goto mmap_failed;
GST_BUFFER_DATA (ret) = mem;
GST_BUFFER_SIZE (ret) = meta->vbuffer.length;
GST_BUFFER_FLAG_SET (ret, GST_BUFFER_FLAG_READONLY);
gst_buffer_set_caps (ret, caps);
gst_buffer_take_memory (ret, -1,
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
meta->mem, NULL, meta->vbuffer.length, 0, meta->vbuffer.length));
return ret;
......@@ -468,7 +462,7 @@ gst_v4l2_buffer_pool_get (GstV4l2BufferPool * pool, gboolean blocking)
GstMetaV4l2 *meta = GST_META_V4L2_GET (buf);
GST_V4L2_BUFFER_POOL_LOCK (pool);
GST_BUFFER_SIZE (buf) = meta->vbuffer.length;
gst_buffer_resize (buf, 0, meta->vbuffer.length);
GST_BUFFER_FLAG_UNSET (buf, 0xffffffff);
GST_V4L2_BUFFER_POOL_UNLOCK (pool);
}
......@@ -563,7 +557,7 @@ gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool)
GST_BUFFER_FLAG_UNSET (pool_buffer, GST_VIDEO_BUFFER_TFF);
/* this can change at every frame, esp. with jpeg */
GST_BUFFER_SIZE (pool_buffer) = buffer.bytesused;
gst_buffer_resize (pool_buffer, 0, buffer.bytesused);
GST_V4L2_BUFFER_POOL_UNLOCK (pool);
......
......@@ -69,6 +69,7 @@ struct _GstV4l2BufferPool
struct _GstMetaV4l2 {
GstMeta meta;
gpointer mem;
struct v4l2_buffer vbuffer;
/* FIXME: have GstV4l2Src* instead, as this has GstV4l2BufferPool* */
......
......@@ -29,14 +29,9 @@
#include "gstv4l2colorbalance.h"
#include "gstv4l2object.h"
GST_BOILERPLATE (GstV4l2ColorBalanceChannel,
gst_v4l2_color_balance_channel,
GstColorBalanceChannel, GST_TYPE_COLOR_BALANCE_CHANNEL);
static void
gst_v4l2_color_balance_channel_base_init (gpointer g_class)
{
}
#define gst_v4l2_color_balance_channel_parent_class parent_class
G_DEFINE_TYPE (GstV4l2ColorBalanceChannel,
gst_v4l2_color_balance_channel, GST_TYPE_COLOR_BALANCE_CHANNEL);
static void
gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
......@@ -45,8 +40,7 @@ gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
}
static void
gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel,
GstV4l2ColorBalanceChannelClass * klass)
gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel)
{
channel->id = (guint32) - 1;
}
......
......@@ -257,67 +257,20 @@ GST_IMPLEMENT_V4L2_TUNER_METHODS (GstV4l2Radio, gst_v4l2radio);
static void gst_v4l2radio_uri_handler_init (gpointer g_iface,
gpointer iface_data);
static gboolean
gst_v4l2radio_interface_supported (GstImplementsInterface * iface,
GType iface_type)
{
if (iface_type == GST_TYPE_TUNER)
return TRUE;
else
return FALSE;
}
static void
gst_v4l2radio_implements_interface_init (GstImplementsInterfaceClass * iface)
{
iface->supported = gst_v4l2radio_interface_supported;
}
static void
gst_v4l2radio_tuner_interface_reinit (GstTunerClass * iface)
{
gst_v4l2radio_tuner_interface_init (iface);
}
static void
gst_v4l2radio_interfaces (GType type)
{
static const GInterfaceInfo urihandler_info = {
(GInterfaceInitFunc) gst_v4l2radio_uri_handler_init,
NULL,
NULL
};
static const GInterfaceInfo implements_interface_info = {
(GInterfaceInitFunc) gst_v4l2radio_implements_interface_init,
NULL,
NULL,
};
static const GInterfaceInfo propertyprobe_info = {
(GInterfaceInitFunc) gst_v4l2radio_property_probe_interface_init,
NULL,
NULL,
};
static const GInterfaceInfo tuner_interface_info = {
(GInterfaceInitFunc) gst_v4l2radio_tuner_interface_reinit,
NULL,
NULL,
};
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
g_type_add_interface_static (type,
GST_TYPE_IMPLEMENTS_INTERFACE, &implements_interface_info);
g_type_add_interface_static (type, GST_TYPE_TUNER, &tuner_interface_info);
g_type_add_interface_static (type,
GST_TYPE_PROPERTY_PROBE, &propertyprobe_info);
}
GST_BOILERPLATE_FULL (GstV4l2Radio, gst_v4l2radio, GstElement, GST_TYPE_ELEMENT,
gst_v4l2radio_interfaces);
#define gst_v4l2radio_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstV4l2Radio, gst_v4l2radio, GST_TYPE_ELEMENT,
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
gst_v4l2radio_uri_handler_init);
G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER,
gst_v4l2radio_tuner_interface_reinit);
G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
gst_v4l2radio_property_probe_interface_init));
static void gst_v4l2radio_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
......@@ -328,24 +281,6 @@ static void gst_v4l2radio_dispose (GObject * object);
static GstStateChangeReturn gst_v4l2radio_change_state (GstElement * element,
GstStateChange transition);
static void
gst_v4l2radio_base_init (gpointer gclass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (gclass);
GstV4l2RadioClass *gstv4l2radio_class = GST_V4L2RADIO_CLASS (gclass);
GST_DEBUG_CATEGORY_INIT (v4l2radio_debug, "v4l2radio", 0,
"V4l2 radio element");
gstv4l2radio_class->v4l2_class_devices = NULL;
gst_element_class_set_details_simple (gstelement_class,
"Radio (video4linux2) Tuner",
"Tuner",
"Controls a Video4Linux2 radio device",
"Alexey Chernov <4ernov@gmail.com>");
}
static void
gst_v4l2radio_class_init (GstV4l2RadioClass * klass)
{
......@@ -355,6 +290,8 @@ gst_v4l2radio_class_init (GstV4l2RadioClass * klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gobject_class->dispose = gst_v4l2radio_dispose;
gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2radio_finalize;
gobject_class->set_property = gst_v4l2radio_set_property;
gobject_class->get_property = gst_v4l2radio_get_property;
......@@ -368,16 +305,23 @@ gst_v4l2radio_class_init (GstV4l2RadioClass * klass)
"Station frequency in Hz",
MIN_FREQUENCY, MAX_FREQUENCY, DEFAULT_FREQUENCY, G_PARAM_READWRITE));
gobject_class->dispose = gst_v4l2radio_dispose;
gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2radio_finalize;
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_v4l2radio_change_state);
gst_element_class_set_details_simple (gstelement_class,
"Radio (video4linux2) Tuner",
"Tuner",
"Controls a Video4Linux2 radio device",
"Alexey Chernov <4ernov@gmail.com>");
klass->v4l2_class_devices = NULL;
GST_DEBUG_CATEGORY_INIT (v4l2radio_debug, "v4l2radio", 0,
"V4l2 radio element");
}
static void
gst_v4l2radio_init (GstV4l2Radio * filter, GstV4l2RadioClass * gclass)
gst_v4l2radio_init (GstV4l2Radio * filter)
{
filter->v4l2object = gst_v4l2_object_new (GST_ELEMENT (filter),
V4L2_BUF_TYPE_VIDEO_CAPTURE, DEFAULT_PROP_DEVICE,
......@@ -563,13 +507,13 @@ gst_v4l2radio_get_property (GObject * object, guint prop_id,
/* GstURIHandler interface */
static GstURIType
gst_v4l2radio_uri_get_type (void)
gst_v4l2radio_uri_get_type (GType type)
{
return GST_URI_SRC;
}
static gchar **
gst_v4l2radio_uri_get_protocols (void)
gst_v4l2radio_uri_get_protocols (GType type)
{
static gchar *protocols[] = { (char *) "radio", NULL };
return protocols;
......
This diff is collapsed.
......@@ -165,7 +165,6 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf)
"running out of buffers, making a copy to reuse current one");
}
*buf = gst_buffer_copy (pool_buffer);
GST_BUFFER_FLAG_UNSET (*buf, GST_BUFFER_FLAG_READONLY);
/* this will requeue */
gst_buffer_unref (pool_buffer);
} else {
......
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