2001-12-23 15:31:15 +00:00
|
|
|
/* G-Streamer BT8x8/V4L frame grabber plugin
|
2002-01-31 22:22:42 +00:00
|
|
|
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2001-12-17 19:03:14 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-03-09 15:07:53 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
#include <string.h>
|
2001-12-23 15:31:15 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include "v4lsrc_calls.h"
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2002-09-18 19:02:52 +00:00
|
|
|
/* elementfactory information */
|
2001-12-17 19:03:14 +00:00
|
|
|
static GstElementDetails gst_v4lsrc_details = {
|
2001-12-23 15:31:15 +00:00
|
|
|
"Video (video4linux/raw) Source",
|
2001-12-17 19:03:14 +00:00
|
|
|
"Source/Video",
|
2002-09-18 19:02:52 +00:00
|
|
|
"LGPL",
|
2001-12-23 15:31:15 +00:00
|
|
|
"Reads raw frames from a video4linux (BT8x8) device",
|
2001-12-17 19:03:14 +00:00
|
|
|
VERSION,
|
2001-12-23 15:31:15 +00:00
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
|
|
|
|
"(C) 2001",
|
2001-12-17 19:03:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* V4lSrc signals and args */
|
|
|
|
enum {
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* arguments */
|
2001-12-17 19:03:14 +00:00
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
ARG_WIDTH,
|
|
|
|
ARG_HEIGHT,
|
2002-01-07 09:31:34 +00:00
|
|
|
ARG_PALETTE,
|
|
|
|
ARG_PALETTE_NAME,
|
|
|
|
ARG_NUMBUFS,
|
|
|
|
ARG_BUFSIZE
|
2001-12-17 19:03:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* init functions */
|
|
|
|
static void gst_v4lsrc_class_init (GstV4lSrcClass *klass);
|
|
|
|
static void gst_v4lsrc_init (GstV4lSrc *v4lsrc);
|
|
|
|
|
|
|
|
/* pad/buffer functions */
|
2002-09-16 21:01:42 +00:00
|
|
|
static gboolean gst_v4lsrc_srcconvert (GstPad *pad,
|
|
|
|
GstFormat src_format,
|
|
|
|
gint64 src_value,
|
|
|
|
GstFormat *dest_format,
|
|
|
|
gint64 *dest_value);
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn gst_v4lsrc_srcconnect (GstPad *pad,
|
2002-01-15 15:52:09 +00:00
|
|
|
GstCaps *caps);
|
2001-12-23 15:31:15 +00:00
|
|
|
static GstBuffer* gst_v4lsrc_get (GstPad *pad);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* get/set params */
|
|
|
|
static void gst_v4lsrc_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gst_v4lsrc_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* state handling */
|
|
|
|
static GstElementStateReturn gst_v4lsrc_change_state (GstElement *element);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* bufferpool functions */
|
|
|
|
static GstBuffer* gst_v4lsrc_buffer_new (GstBufferPool *pool,
|
2002-07-08 22:18:49 +00:00
|
|
|
guint64 offset,
|
|
|
|
guint size,
|
2001-12-23 15:31:15 +00:00
|
|
|
gpointer user_data);
|
2002-07-08 22:18:49 +00:00
|
|
|
static void gst_v4lsrc_buffer_free (GstBufferPool *pool,
|
|
|
|
GstBuffer *buf,
|
|
|
|
gpointer user_data);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
static GstCaps *capslist = NULL;
|
|
|
|
static GstPadTemplate *src_template;
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
static GstElementClass *parent_class = NULL;\
|
2002-03-19 04:10:06 +00:00
|
|
|
/*static guint gst_v4lsrc_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_v4lsrc_get_type (void)
|
|
|
|
{
|
|
|
|
static GType v4lsrc_type = 0;
|
|
|
|
|
|
|
|
if (!v4lsrc_type) {
|
|
|
|
static const GTypeInfo v4lsrc_info = {
|
2001-12-23 15:31:15 +00:00
|
|
|
sizeof(GstV4lSrcClass),
|
|
|
|
NULL,
|
2001-12-17 19:03:14 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc)gst_v4lsrc_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstV4lSrc),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc)gst_v4lsrc_init,
|
|
|
|
NULL
|
|
|
|
};
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lsrc_type = g_type_register_static(GST_TYPE_V4LELEMENT, "GstV4lSrc", &v4lsrc_info, 0);
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
return v4lsrc_type;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
|
|
|
gst_v4lsrc_class_init (GstV4lSrcClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass*)klass;
|
|
|
|
gstelement_class = (GstElementClass*)klass;
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
parent_class = g_type_class_ref(GST_TYPE_V4LELEMENT);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDTH,
|
2001-12-28 19:54:23 +00:00
|
|
|
g_param_spec_int("width","width","width",
|
|
|
|
G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
|
2001-12-17 19:03:14 +00:00
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HEIGHT,
|
2001-12-28 19:54:23 +00:00
|
|
|
g_param_spec_int("height","height","height",
|
|
|
|
G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
|
2001-12-23 15:31:15 +00:00
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PALETTE,
|
2001-12-28 19:54:23 +00:00
|
|
|
g_param_spec_int("palette","palette","palette",
|
2002-01-07 19:17:02 +00:00
|
|
|
G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
|
2002-01-07 09:31:34 +00:00
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PALETTE_NAME,
|
|
|
|
g_param_spec_string("palette_name","palette_name","palette_name",
|
|
|
|
NULL, G_PARAM_READABLE));
|
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUMBUFS,
|
|
|
|
g_param_spec_int("num_buffers","num_buffers","num_buffers",
|
|
|
|
G_MININT,G_MAXINT,0,G_PARAM_READABLE));
|
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFSIZE,
|
|
|
|
g_param_spec_int("buffer_size","buffer_size","buffer_size",
|
|
|
|
G_MININT,G_MAXINT,0,G_PARAM_READABLE));
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_v4lsrc_set_property;
|
|
|
|
gobject_class->get_property = gst_v4lsrc_get_property;
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_v4lsrc_change_state;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
|
|
|
gst_v4lsrc_init (GstV4lSrc *v4lsrc)
|
|
|
|
{
|
2002-01-15 15:52:09 +00:00
|
|
|
v4lsrc->srcpad = gst_pad_new_from_template (src_template, "src");
|
2001-12-23 15:31:15 +00:00
|
|
|
gst_element_add_pad(GST_ELEMENT(v4lsrc), v4lsrc->srcpad);
|
|
|
|
|
|
|
|
gst_pad_set_get_function (v4lsrc->srcpad, gst_v4lsrc_get);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_pad_set_link_function (v4lsrc->srcpad, gst_v4lsrc_srcconnect);
|
2002-09-16 21:01:42 +00:00
|
|
|
gst_pad_set_convert_function (v4lsrc->srcpad, gst_v4lsrc_srcconvert);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-07-08 22:18:49 +00:00
|
|
|
v4lsrc->bufferpool = gst_buffer_pool_new(
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2002-12-20 23:14:41 +00:00
|
|
|
(GstBufferPoolBufferNewFunction)gst_v4lsrc_buffer_new,
|
2002-09-20 09:28:46 +00:00
|
|
|
NULL,
|
2002-12-20 23:14:41 +00:00
|
|
|
(GstBufferPoolBufferFreeFunction)gst_v4lsrc_buffer_free,
|
2002-07-08 22:18:49 +00:00
|
|
|
v4lsrc);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
v4lsrc->palette = 0; /* means 'any' - user can specify a specific palette */
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lsrc->width = 160;
|
|
|
|
v4lsrc->height = 120;
|
2002-09-09 07:12:29 +00:00
|
|
|
v4lsrc->buffer_size = 0;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-09-16 21:01:42 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4lsrc_srcconvert (GstPad *pad,
|
|
|
|
GstFormat src_format,
|
|
|
|
gint64 src_value,
|
|
|
|
GstFormat *dest_format,
|
|
|
|
gint64 *dest_value)
|
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
|
|
|
gint norm;
|
|
|
|
gdouble fps;
|
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lsrc)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!gst_v4l_get_chan_norm(GST_V4LELEMENT(v4lsrc), NULL, &norm))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (norm == VIDEO_MODE_NTSC)
|
|
|
|
fps = 30000/1001;
|
|
|
|
else
|
|
|
|
fps = 25.;
|
|
|
|
|
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_format = GST_FORMAT_UNITS;
|
|
|
|
/* fall-through */
|
|
|
|
case GST_FORMAT_UNITS:
|
|
|
|
*dest_value = src_value * fps / GST_SECOND;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GST_FORMAT_UNITS:
|
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_format = GST_FORMAT_TIME;
|
|
|
|
/* fall-through */
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*dest_value = src_value * GST_SECOND / fps;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2002-01-15 15:52:09 +00:00
|
|
|
gst_v4lsrc_srcconnect (GstPad *pad,
|
|
|
|
GstCaps *vscapslist)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2003-01-10 13:38:32 +00:00
|
|
|
GstPadLinkReturn ret_val;
|
2001-12-17 19:03:14 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2002-01-15 15:52:09 +00:00
|
|
|
GstCaps *caps, *newcaps;
|
2002-01-20 12:27:11 +00:00
|
|
|
gint palette;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
|
|
|
|
2002-09-09 07:12:29 +00:00
|
|
|
/* in case the buffers are active (which means that we already
|
|
|
|
* did capsnego before and didn't clean up), clean up anyways */
|
|
|
|
if (GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc)))
|
2002-09-18 10:57:56 +00:00
|
|
|
{
|
2002-09-09 07:12:29 +00:00
|
|
|
if (!gst_v4lsrc_capture_deinit(v4lsrc))
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-09-18 10:57:56 +00:00
|
|
|
}
|
|
|
|
else if (!GST_V4L_IS_OPEN(GST_V4LELEMENT(v4lsrc)))
|
|
|
|
{
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_DELAYED;
|
2002-09-18 10:57:56 +00:00
|
|
|
}
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2002-01-20 12:27:11 +00:00
|
|
|
palette = v4lsrc->palette;
|
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
/* TODO: caps = gst_caps_normalize(capslist); */
|
|
|
|
for (caps = vscapslist ; caps != NULL ; caps = vscapslist = vscapslist->next)
|
|
|
|
{
|
2002-03-30 17:06:26 +00:00
|
|
|
guint32 fourcc;
|
|
|
|
gint depth;
|
|
|
|
|
|
|
|
gst_caps_get_fourcc_int (caps, "format", &fourcc);
|
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
if (v4lsrc->palette > 0)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2002-01-15 15:52:09 +00:00
|
|
|
switch (v4lsrc->palette)
|
|
|
|
{
|
|
|
|
case VIDEO_PALETTE_YUV420P:
|
2002-03-30 17:06:26 +00:00
|
|
|
if (fourcc != GST_MAKE_FOURCC('I','4','2','0') &&
|
|
|
|
fourcc != GST_MAKE_FOURCC('I','Y','U','V'))
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 1.5;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case VIDEO_PALETTE_YUV422:
|
|
|
|
case VIDEO_PALETTE_YUYV:
|
2002-03-30 17:06:26 +00:00
|
|
|
if (fourcc != GST_MAKE_FOURCC('Y','U','Y','2'))
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case VIDEO_PALETTE_UYVY:
|
2002-03-30 17:06:26 +00:00
|
|
|
if (fourcc != GST_MAKE_FOURCC('U','Y','V','Y'))
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case VIDEO_PALETTE_YUV411:
|
2002-03-30 17:06:26 +00:00
|
|
|
if (fourcc != GST_MAKE_FOURCC('Y','4','1','P'))
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 1.5;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
2001-12-23 15:31:15 +00:00
|
|
|
case VIDEO_PALETTE_RGB555:
|
2002-03-30 17:06:26 +00:00
|
|
|
depth = gst_caps_get_int (caps, "depth", &depth);
|
|
|
|
if (fourcc != GST_MAKE_FOURCC('R','G','B',' ') ||
|
|
|
|
depth != 15)
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
2001-12-23 15:31:15 +00:00
|
|
|
case VIDEO_PALETTE_RGB565:
|
2002-03-30 17:06:26 +00:00
|
|
|
depth = gst_caps_get_int (caps, "depth", &depth);
|
|
|
|
if (fourcc != GST_MAKE_FOURCC('R','G','B',' ') ||
|
|
|
|
depth != 16)
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
2001-12-23 15:31:15 +00:00
|
|
|
case VIDEO_PALETTE_RGB24:
|
2002-03-30 17:06:26 +00:00
|
|
|
depth = gst_caps_get_int (caps, "depth", &depth);
|
|
|
|
if (fourcc != GST_MAKE_FOURCC('R','G','B',' ') ||
|
|
|
|
depth != 24)
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 3;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
2001-12-23 15:31:15 +00:00
|
|
|
case VIDEO_PALETTE_RGB32:
|
2002-03-30 17:06:26 +00:00
|
|
|
depth = gst_caps_get_int (caps, "depth", &depth);
|
|
|
|
if (fourcc != GST_MAKE_FOURCC('R','G','B',' ') ||
|
|
|
|
depth != 32)
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_next;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 4;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
default:
|
|
|
|
goto try_next;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-15 15:52:09 +00:00
|
|
|
else
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2002-03-30 17:06:26 +00:00
|
|
|
switch (fourcc)
|
2002-01-15 15:52:09 +00:00
|
|
|
{
|
|
|
|
case GST_MAKE_FOURCC('I','4','2','0'):
|
|
|
|
case GST_MAKE_FOURCC('I','Y','U','V'):
|
|
|
|
palette = VIDEO_PALETTE_YUV420P;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 1.5;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case GST_MAKE_FOURCC('Y','U','Y','2'):
|
|
|
|
palette = VIDEO_PALETTE_YUV422;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case GST_MAKE_FOURCC('U','Y','V','Y'):
|
|
|
|
palette = VIDEO_PALETTE_UYVY;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case GST_MAKE_FOURCC('Y','4','1','P'):
|
|
|
|
palette = VIDEO_PALETTE_YUV411;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 1.5;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case GST_MAKE_FOURCC('R','G','B',' '):
|
2002-03-30 17:06:26 +00:00
|
|
|
depth = gst_caps_get_int (caps, "depth", &depth);
|
|
|
|
switch (depth)
|
2002-01-15 15:52:09 +00:00
|
|
|
{
|
|
|
|
case 15:
|
|
|
|
palette = VIDEO_PALETTE_RGB555;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case 16:
|
|
|
|
palette = VIDEO_PALETTE_RGB565;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 2;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case 24:
|
|
|
|
palette = VIDEO_PALETTE_RGB24;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 3;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
case 32:
|
|
|
|
palette = VIDEO_PALETTE_RGB32;
|
2002-01-20 16:03:10 +00:00
|
|
|
v4lsrc->buffer_size = v4lsrc->width * v4lsrc->height * 4;
|
2002-01-15 15:52:09 +00:00
|
|
|
goto try_caps;
|
|
|
|
default:
|
|
|
|
goto try_next;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
goto try_next;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
/* if this caps wasn't useful, try the next one */
|
|
|
|
try_next:
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* if this caps was useful, try it out */
|
|
|
|
try_caps:
|
2002-09-20 09:28:46 +00:00
|
|
|
/* try the current 'palette' out on the video device */
|
|
|
|
if (!gst_v4lsrc_try_palette(v4lsrc, palette))
|
2002-01-15 15:52:09 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* try to connect the pad/caps with the actual width/height */
|
2002-03-30 17:06:26 +00:00
|
|
|
if (palette >= VIDEO_PALETTE_RGB565 && palette <= VIDEO_PALETTE_RGB555) {
|
|
|
|
gint depth;
|
|
|
|
gint bpp;
|
|
|
|
|
|
|
|
gst_caps_get_int(caps, "bpp", &bpp),
|
|
|
|
gst_caps_get_int(caps, "depth", &depth),
|
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
newcaps = gst_caps_new("v4lsrc_caps",
|
|
|
|
"video/raw",
|
|
|
|
gst_props_new(
|
2002-03-30 17:06:26 +00:00
|
|
|
"format", GST_PROPS_FOURCC(fourcc),
|
2002-01-15 15:52:09 +00:00
|
|
|
"width", GST_PROPS_INT(v4lsrc->width),
|
2002-01-20 16:03:10 +00:00
|
|
|
"height", GST_PROPS_INT(v4lsrc->height),
|
2002-03-30 17:06:26 +00:00
|
|
|
"bpp", GST_PROPS_INT(bpp),
|
|
|
|
"depth", GST_PROPS_INT(depth),
|
2002-01-15 15:52:09 +00:00
|
|
|
NULL ) );
|
2002-03-30 17:06:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-01-15 15:52:09 +00:00
|
|
|
newcaps = gst_caps_new("v4lsrc_caps",
|
|
|
|
"video/raw",
|
|
|
|
gst_props_new(
|
2002-03-30 17:06:26 +00:00
|
|
|
"format", GST_PROPS_FOURCC(fourcc),
|
2002-01-15 15:52:09 +00:00
|
|
|
"width", GST_PROPS_INT(v4lsrc->width),
|
|
|
|
"height", GST_PROPS_INT(v4lsrc->height),
|
|
|
|
NULL ) );
|
2002-03-30 17:06:26 +00:00
|
|
|
}
|
2002-01-15 15:52:09 +00:00
|
|
|
|
2002-03-03 00:53:25 +00:00
|
|
|
gst_caps_debug (newcaps, "new caps to set on v4lsrc's src pad");
|
2002-01-20 16:03:10 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
if ((ret_val = gst_pad_try_set_caps(v4lsrc->srcpad, newcaps)) == GST_PAD_LINK_REFUSED)
|
2002-01-15 15:52:09 +00:00
|
|
|
continue;
|
2003-01-10 10:22:25 +00:00
|
|
|
else if (ret_val == GST_PAD_LINK_DELAYED)
|
|
|
|
return GST_PAD_LINK_DELAYED;
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2002-09-20 09:28:46 +00:00
|
|
|
if (!gst_v4lsrc_set_capture(v4lsrc, v4lsrc->width, v4lsrc->height, palette))
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-09-20 09:28:46 +00:00
|
|
|
|
2002-09-09 07:12:29 +00:00
|
|
|
if (!gst_v4lsrc_capture_init(v4lsrc))
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_DONE;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2002-01-15 15:52:09 +00:00
|
|
|
/* still nothing - no good caps */
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static GstBuffer*
|
|
|
|
gst_v4lsrc_get (GstPad *pad)
|
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
2001-12-23 15:31:15 +00:00
|
|
|
GstBuffer *buf;
|
|
|
|
gint num;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (pad != NULL, NULL);
|
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
buf = gst_buffer_new_from_pool(v4lsrc->bufferpool, 0, 0);
|
|
|
|
if (!buf)
|
|
|
|
{
|
|
|
|
gst_element_error(GST_ELEMENT(v4lsrc),
|
|
|
|
"Failed to create a new GstBuffer");
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* grab a frame from the device */
|
|
|
|
if (!gst_v4lsrc_grab_frame(v4lsrc, &num))
|
|
|
|
return NULL;
|
|
|
|
GST_BUFFER_DATA(buf) = gst_v4lsrc_get_buffer(v4lsrc, num);
|
|
|
|
GST_BUFFER_SIZE(buf) = v4lsrc->buffer_size;
|
2002-05-08 20:21:45 +00:00
|
|
|
|
2002-09-09 07:12:29 +00:00
|
|
|
if (!v4lsrc->first_timestamp)
|
2003-03-01 13:11:02 +00:00
|
|
|
v4lsrc->first_timestamp =
|
|
|
|
GST_TIMEVAL_TO_TIME(v4lsrc->timestamp_soft_sync[num]);
|
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP(buf) =
|
|
|
|
GST_TIMEVAL_TO_TIME(v4lsrc->timestamp_soft_sync[num]) -
|
|
|
|
v4lsrc->first_timestamp;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
2001-12-23 15:31:15 +00:00
|
|
|
gst_v4lsrc_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
g_return_if_fail(GST_IS_V4LSRC(object));
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lsrc = GST_V4LSRC(object);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_WIDTH:
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lsrc->width = g_value_get_int(value);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
case ARG_HEIGHT:
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lsrc->height = g_value_get_int(value);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
case ARG_PALETTE:
|
|
|
|
v4lsrc->palette = g_value_get_int(value);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
default:
|
2002-01-15 15:52:09 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
2001-12-23 15:31:15 +00:00
|
|
|
gst_v4lsrc_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
g_return_if_fail(GST_IS_V4LSRC(object));
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lsrc = GST_V4LSRC(object);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_WIDTH:
|
2001-12-23 15:31:15 +00:00
|
|
|
g_value_set_int(value, v4lsrc->mmap.width);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
case ARG_HEIGHT:
|
2001-12-23 15:31:15 +00:00
|
|
|
g_value_set_int(value, v4lsrc->mmap.height);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
case ARG_PALETTE:
|
|
|
|
g_value_set_int(value, v4lsrc->mmap.format);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-01-07 09:31:34 +00:00
|
|
|
case ARG_PALETTE_NAME:
|
|
|
|
g_value_set_string(value, g_strdup(palette_name[v4lsrc->mmap.format]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_NUMBUFS:
|
|
|
|
g_value_set_int(value, v4lsrc->mbuf.frames);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_BUFSIZE:
|
2002-04-14 10:27:10 +00:00
|
|
|
if (v4lsrc->mbuf.frames == 0)
|
|
|
|
g_value_set_int(value, 0);
|
|
|
|
else
|
|
|
|
g_value_set_int(value, v4lsrc->mbuf.size/(v4lsrc->mbuf.frames*1024));
|
2002-01-07 09:31:34 +00:00
|
|
|
break;
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
default:
|
2002-01-15 15:52:09 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static GstElementStateReturn
|
|
|
|
gst_v4lsrc_change_state (GstElement *element)
|
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2002-01-20 16:03:10 +00:00
|
|
|
gint transition = GST_STATE_TRANSITION (element);
|
2002-01-04 23:58:11 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail(GST_IS_V4LSRC(element), GST_STATE_FAILURE);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC(element);
|
|
|
|
|
2002-01-20 16:03:10 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
break;
|
2001-12-28 19:54:23 +00:00
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
2002-09-09 07:12:29 +00:00
|
|
|
v4lsrc->first_timestamp = 0;
|
|
|
|
/* buffer setup used to be done here, but I moved it to
|
|
|
|
* capsnego */
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
2001-12-28 19:54:23 +00:00
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
2001-12-23 15:31:15 +00:00
|
|
|
/* queue all buffer, start streaming capture */
|
|
|
|
if (!gst_v4lsrc_capture_start(v4lsrc))
|
|
|
|
return GST_STATE_FAILURE;
|
|
|
|
break;
|
2001-12-28 19:54:23 +00:00
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
|
|
|
/* de-queue all queued buffers */
|
|
|
|
if (!gst_v4lsrc_capture_stop(v4lsrc))
|
|
|
|
return GST_STATE_FAILURE;
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
/* stop capturing, unmap all buffers */
|
|
|
|
if (!gst_v4lsrc_capture_deinit(v4lsrc))
|
|
|
|
return GST_STATE_FAILURE;
|
|
|
|
break;
|
2002-01-20 16:03:10 +00:00
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
break;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2002-01-04 23:58:11 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
2002-01-20 16:03:10 +00:00
|
|
|
GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
/* FIXME, this gives a not supported error on my machine?
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
if ((GST_V4LELEMENT(v4lsrc)->norm >= VIDEO_MODE_PAL ||
|
|
|
|
GST_V4LELEMENT(v4lsrc)->norm < VIDEO_MODE_AUTO) ||
|
|
|
|
GST_V4LELEMENT(v4lsrc)->channel < 0)
|
|
|
|
if (!gst_v4l_set_chan_norm(GST_V4LELEMENT(v4lsrc),
|
|
|
|
0, GST_V4LELEMENT(v4lsrc)->norm))
|
|
|
|
return GST_STATE_FAILURE;
|
|
|
|
break;
|
2002-01-04 23:58:11 +00:00
|
|
|
}
|
2002-01-20 16:03:10 +00:00
|
|
|
*/
|
2002-01-04 23:58:11 +00:00
|
|
|
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
static GstBuffer*
|
|
|
|
gst_v4lsrc_buffer_new (GstBufferPool *pool,
|
2002-07-08 22:18:49 +00:00
|
|
|
guint64 offset,
|
|
|
|
guint size,
|
2001-12-23 15:31:15 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
2002-09-20 09:28:46 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC(user_data);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2002-09-20 09:28:46 +00:00
|
|
|
if (!GST_V4L_IS_ACTIVE(GST_V4LELEMENT(v4lsrc)))
|
|
|
|
return NULL;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
buffer = gst_buffer_new();
|
2002-09-20 09:28:46 +00:00
|
|
|
if (!buffer)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* TODO: add interlacing info to buffer as metadata
|
|
|
|
* (height>288 or 240 = topfieldfirst, else noninterlaced) */
|
|
|
|
GST_BUFFER_MAXSIZE(buffer) = v4lsrc->mbuf.size / v4lsrc->mbuf.frames;
|
|
|
|
GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_DONTFREE);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return buffer;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
2002-07-08 22:18:49 +00:00
|
|
|
gst_v4lsrc_buffer_free (GstBufferPool *pool, GstBuffer *buf, gpointer user_data)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2002-07-08 22:18:49 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (user_data);
|
2001-12-23 15:31:15 +00:00
|
|
|
int n;
|
|
|
|
|
2002-09-20 09:28:46 +00:00
|
|
|
if (gst_element_get_state(GST_ELEMENT(v4lsrc)) != GST_STATE_PLAYING)
|
|
|
|
return; /* we've already cleaned up ourselves */
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
for (n=0;n<v4lsrc->mbuf.frames;n++)
|
|
|
|
if (GST_BUFFER_DATA(buf) == gst_v4lsrc_get_buffer(v4lsrc, n))
|
|
|
|
{
|
|
|
|
gst_v4lsrc_requeue_frame(v4lsrc, n);
|
2002-09-20 09:28:46 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2002-09-20 09:28:46 +00:00
|
|
|
if (n == v4lsrc->mbuf.frames)
|
|
|
|
gst_element_error(GST_ELEMENT(v4lsrc),
|
|
|
|
"Couldn\'t find the buffer");
|
|
|
|
|
|
|
|
/* free struct */
|
|
|
|
gst_buffer_default_free(buf);
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static gboolean
|
2001-12-23 15:31:15 +00:00
|
|
|
plugin_init (GModule *module,
|
|
|
|
GstPlugin *plugin)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
|
|
|
GstElementFactory *factory;
|
2002-01-15 15:52:09 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
gint i;
|
|
|
|
gulong format[5] = { GST_MAKE_FOURCC('Y','U','Y','2'), /* VIDEO_PALETTE_YUV422/_YUYV */
|
|
|
|
GST_MAKE_FOURCC('I','4','2','0'), /* VIDEO_PALETTE_YUV420P */
|
|
|
|
GST_MAKE_FOURCC('I','Y','U','V'), /* VIDEO_PALETTE_YUV420P */
|
|
|
|
GST_MAKE_FOURCC('U','Y','V','Y'), /* VIDEO_PALETTE_UYVY */
|
|
|
|
GST_MAKE_FOURCC('Y','4','1','P') /* VIDEO_PALETTE_YUV411 */
|
|
|
|
};
|
2002-01-20 16:03:10 +00:00
|
|
|
gint rgb_bpp[4] = { 16, 16, 24, 32 };
|
2002-01-15 15:52:09 +00:00
|
|
|
gint rgb_depth[4] = { 15, 16, 24, 32 };
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* create an elementfactory for the v4lsrc */
|
2002-04-11 20:42:27 +00:00
|
|
|
factory = gst_element_factory_new("v4lsrc",GST_TYPE_V4LSRC,
|
2001-12-17 19:03:14 +00:00
|
|
|
&gst_v4lsrc_details);
|
|
|
|
g_return_val_if_fail(factory != NULL, FALSE);
|
2002-01-15 15:52:09 +00:00
|
|
|
|
|
|
|
/* make a list of all available caps - first the YUV formats */
|
|
|
|
for (i=0;i<5;i++)
|
|
|
|
{
|
|
|
|
caps = gst_caps_new ("v4lsrc_caps",
|
|
|
|
"video/raw",
|
|
|
|
gst_props_new (
|
|
|
|
"format", GST_PROPS_FOURCC(format[i]),
|
|
|
|
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
|
|
|
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
|
|
|
NULL )
|
|
|
|
);
|
|
|
|
capslist = gst_caps_append(capslist, caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now all the RGB formats */
|
|
|
|
for (i=0;i<4;i++)
|
|
|
|
{
|
|
|
|
caps = gst_caps_new ("v4lsrc_caps",
|
|
|
|
"video/raw",
|
|
|
|
gst_props_new (
|
|
|
|
"format", GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')),
|
|
|
|
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
|
|
|
"height", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
|
|
|
"bpp", GST_PROPS_INT(rgb_bpp[i]),
|
|
|
|
"depth", GST_PROPS_INT(rgb_depth[i]),
|
|
|
|
NULL )
|
|
|
|
);
|
|
|
|
capslist = gst_caps_append(capslist, caps);
|
|
|
|
}
|
|
|
|
|
2002-04-11 20:42:27 +00:00
|
|
|
src_template = gst_pad_template_new (
|
2002-01-15 15:52:09 +00:00
|
|
|
"src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
capslist, NULL);
|
|
|
|
|
2002-04-11 20:42:27 +00:00
|
|
|
gst_element_factory_add_pad_template (factory, src_template);
|
2002-01-15 15:52:09 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
GstPluginDesc plugin_desc = {
|
|
|
|
GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"v4lsrc",
|
|
|
|
plugin_init
|
|
|
|
};
|