2004-06-15 09:11:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* gstv4lsrc.c: BT8x8/V4L source element
|
|
|
|
*
|
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,
|
2005-07-07 11:29:29 +00:00
|
|
|
* Boston, MA 02111-1307, USA.
|
2001-12-17 19:03:14 +00:00
|
|
|
*/
|
|
|
|
|
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"
|
2004-06-09 11:32:39 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2006-04-28 19:46:37 +00:00
|
|
|
static const GstElementDetails gst_v4lsrc_details =
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Video (video4linux/raw) Source",
|
|
|
|
"Source/Video",
|
2006-04-01 11:41:13 +00:00
|
|
|
"Reads raw frames from a video4linux device",
|
2009-08-24 18:34:35 +00:00
|
|
|
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2006-06-23 09:53:09 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (v4lsrc_debug);
|
2004-04-27 11:33:52 +00:00
|
|
|
#define GST_CAT_DEFAULT v4lsrc_debug
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2005-07-07 11:29:29 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_AUTOPROBE,
|
|
|
|
PROP_AUTOPROBE_FPS,
|
2005-07-12 17:14:33 +00:00
|
|
|
PROP_COPY_MODE,
|
2005-07-07 11:29:29 +00:00
|
|
|
PROP_TIMESTAMP_OFFSET
|
2001-12-17 19:03:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
GST_BOILERPLATE (GstV4lSrc, gst_v4lsrc, GstV4lElement, GST_TYPE_V4LELEMENT);
|
|
|
|
|
2008-12-12 10:54:45 +00:00
|
|
|
static GstStaticPadTemplate v4l_src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("ANY")
|
|
|
|
);
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
/* basesrc methods */
|
|
|
|
static gboolean gst_v4lsrc_start (GstBaseSrc * src);
|
|
|
|
static gboolean gst_v4lsrc_stop (GstBaseSrc * src);
|
|
|
|
static gboolean gst_v4lsrc_set_caps (GstBaseSrc * src, GstCaps * caps);
|
|
|
|
static GstCaps *gst_v4lsrc_get_caps (GstBaseSrc * src);
|
|
|
|
static GstFlowReturn gst_v4lsrc_create (GstPushSrc * src, GstBuffer ** out);
|
2007-02-28 15:05:03 +00:00
|
|
|
static gboolean gst_v4lsrc_query (GstBaseSrc * bsrc, GstQuery * query);
|
|
|
|
static void gst_v4lsrc_fixate (GstBaseSrc * bsrc, GstCaps * caps);
|
2004-06-16 10:13:51 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
2003-11-02 14:47:52 +00:00
|
|
|
static void
|
|
|
|
gst_v4lsrc_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2003-11-02 14:47:52 +00:00
|
|
|
gst_element_class_set_details (gstelement_class, &gst_v4lsrc_details);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
2008-12-12 10:54:45 +00:00
|
|
|
gst_static_pad_template_get (&v4l_src_template));
|
2003-11-02 14:47:52 +00:00
|
|
|
}
|
2004-01-28 21:16:01 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_class_init (GstV4lSrcClass * klass)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2005-07-07 11:29:29 +00:00
|
|
|
GstBaseSrcClass *basesrc_class;
|
|
|
|
GstPushSrcClass *pushsrc_class;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2005-07-07 11:29:29 +00:00
|
|
|
basesrc_class = (GstBaseSrcClass *) klass;
|
|
|
|
pushsrc_class = (GstPushSrcClass *) klass;
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_v4lsrc_set_property;
|
|
|
|
gobject_class->get_property = gst_v4lsrc_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_AUTOPROBE,
|
2004-06-17 17:06:24 +00:00
|
|
|
g_param_spec_boolean ("autoprobe", "Autoprobe",
|
|
|
|
"Whether the device should be probed for all possible features",
|
2008-03-22 15:00:53 +00:00
|
|
|
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-07-07 11:29:29 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_AUTOPROBE_FPS,
|
2004-11-09 20:29:44 +00:00
|
|
|
g_param_spec_boolean ("autoprobe-fps", "Autoprobe FPS",
|
|
|
|
"Whether the device should be probed for framerates",
|
2008-03-22 15:00:53 +00:00
|
|
|
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-07-12 17:14:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_COPY_MODE,
|
|
|
|
g_param_spec_boolean ("copy-mode", "Copy mode",
|
|
|
|
"Whether to send out copies of buffers, or direct pointers to the mmap region",
|
2008-03-22 15:00:53 +00:00
|
|
|
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-07-07 11:29:29 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
PROP_TIMESTAMP_OFFSET, g_param_spec_int64 ("timestamp-offset",
|
|
|
|
"Timestamp offset",
|
|
|
|
"A time offset subtracted from timestamps set on buffers (in ns)",
|
2008-03-22 15:00:53 +00:00
|
|
|
G_MININT64, G_MAXINT64, 0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (v4lsrc_debug, "v4lsrc", 0, "V4L source element");
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
basesrc_class->get_caps = gst_v4lsrc_get_caps;
|
|
|
|
basesrc_class->set_caps = gst_v4lsrc_set_caps;
|
|
|
|
basesrc_class->start = gst_v4lsrc_start;
|
|
|
|
basesrc_class->stop = gst_v4lsrc_stop;
|
2007-02-28 15:05:03 +00:00
|
|
|
basesrc_class->fixate = gst_v4lsrc_fixate;
|
|
|
|
basesrc_class->query = gst_v4lsrc_query;
|
2004-01-28 21:16:01 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
pushsrc_class->create = gst_v4lsrc_create;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-08-28 17:52:45 +00:00
|
|
|
gst_v4lsrc_init (GstV4lSrc * v4lsrc, GstV4lSrcClass * klass)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2002-09-09 07:12:29 +00:00
|
|
|
v4lsrc->buffer_size = 0;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
/* no colorspaces */
|
|
|
|
v4lsrc->colorspaces = NULL;
|
2004-01-28 21:16:01 +00:00
|
|
|
|
|
|
|
v4lsrc->is_capturing = FALSE;
|
2004-06-17 17:06:24 +00:00
|
|
|
v4lsrc->autoprobe = TRUE;
|
2004-11-09 20:29:44 +00:00
|
|
|
v4lsrc->autoprobe_fps = TRUE;
|
2005-07-12 17:14:33 +00:00
|
|
|
v4lsrc->copy_mode = TRUE;
|
2004-06-26 15:58:35 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
v4lsrc->timestamp_offset = 0;
|
2004-11-23 12:42:21 +00:00
|
|
|
|
|
|
|
v4lsrc->fps_list = NULL;
|
2005-07-05 14:54:19 +00:00
|
|
|
|
2007-06-05 16:37:09 +00:00
|
|
|
gst_base_src_set_format (GST_BASE_SRC (v4lsrc), GST_FORMAT_TIME);
|
2005-07-07 11:29:29 +00:00
|
|
|
gst_base_src_set_live (GST_BASE_SRC (v4lsrc), TRUE);
|
2004-01-28 21:16:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-07-07 11:29:29 +00:00
|
|
|
gst_v4lsrc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2004-01-28 21:16:01 +00:00
|
|
|
{
|
2005-07-07 11:29:29 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (object);
|
2004-01-28 21:16:01 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_AUTOPROBE:
|
|
|
|
g_return_if_fail (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc)));
|
|
|
|
v4lsrc->autoprobe = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case PROP_AUTOPROBE_FPS:
|
|
|
|
g_return_if_fail (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc)));
|
|
|
|
v4lsrc->autoprobe_fps = g_value_get_boolean (value);
|
|
|
|
break;
|
2005-07-12 17:14:33 +00:00
|
|
|
case PROP_COPY_MODE:
|
|
|
|
v4lsrc->copy_mode = g_value_get_boolean (value);
|
|
|
|
break;
|
2005-07-07 11:29:29 +00:00
|
|
|
case PROP_TIMESTAMP_OFFSET:
|
2005-08-31 08:58:03 +00:00
|
|
|
v4lsrc->timestamp_offset = g_value_get_int64 (value);
|
2005-07-07 11:29:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2004-06-09 11:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
static void
|
|
|
|
gst_v4lsrc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (object);
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_AUTOPROBE:
|
|
|
|
g_value_set_boolean (value, v4lsrc->autoprobe);
|
2002-09-16 21:01:42 +00:00
|
|
|
break;
|
2005-07-07 11:29:29 +00:00
|
|
|
case PROP_AUTOPROBE_FPS:
|
|
|
|
g_value_set_boolean (value, v4lsrc->autoprobe_fps);
|
|
|
|
break;
|
2005-07-12 17:14:33 +00:00
|
|
|
case PROP_COPY_MODE:
|
|
|
|
g_value_set_boolean (value, v4lsrc->copy_mode);
|
|
|
|
break;
|
2005-07-07 11:29:29 +00:00
|
|
|
case PROP_TIMESTAMP_OFFSET:
|
2005-08-31 08:58:03 +00:00
|
|
|
g_value_set_int64 (value, v4lsrc->timestamp_offset);
|
2002-09-16 21:01:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-07-07 11:29:29 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2002-09-16 21:01:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-07 14:01:07 +00:00
|
|
|
/* this function is a bit of a last resort */
|
|
|
|
static void
|
2007-02-28 15:05:03 +00:00
|
|
|
gst_v4lsrc_fixate (GstBaseSrc * bsrc, GstCaps * caps)
|
configure.ac: Improve mpeg2enc detection. This is for distributions that do ship mjpegtools, but without mpeg2enc. Al...
Original commit message from CVS:
2003-12-21 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Improve mpeg2enc detection. This is for distributions that do
ship mjpegtools, but without mpeg2enc. Also does object check
for might there ever be ABI incompatibility.
* ext/mpeg2enc/gstmpeg2enc.cc:
Add Andrew as second maintainer (he's helping me), and also add
an error if no caps was set. This happens if I pull before capsnego
and that's something I should solve sometime else.
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_parse_blockgroup):
Fix time parsing.
* gst/matroska/matroska-mux.c: (gst_matroska_mux_audio_pad_link),
(gst_matroska_mux_track_header):
Add caps to templates.
* gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_sink_factory):
Add mpegversion=1 to prevent confusion with MPEG/AAC.
* gst/mpegstream/gstmpegdemux.c:
Remove layer since it causes warnings about unfixed caps.
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_get):
Fix obvious typo (we error out if caps were set, we should of
course error out if *no* caps were set).
* sys/oss/gstosselement.c: (gst_osselement_convert):
Fix format conversion, we confused bits/bytes.
* sys/oss/gstosselement.h:
Improve documentation for 'bps'.
* sys/v4l/TODO:
Remove stuff about plugins that need removing - this was done
ages ago.
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_init),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query):
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_init), (gst_v4lsrc_src_convert),
(gst_v4lsrc_src_query):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init),
(gst_v4l2src_src_convert), (gst_v4l2src_src_query):
Add get_query_types(), get_formats() and query() functions.
2003-12-21 18:44:34 +00:00
|
|
|
{
|
2005-07-07 11:29:29 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
int i;
|
|
|
|
int targetwidth, targetheight;
|
2007-02-28 15:05:03 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (bsrc);
|
2005-07-07 11:29:29 +00:00
|
|
|
struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
|
|
|
|
struct video_window *vwin = &GST_V4LELEMENT (v4lsrc)->vwin;
|
configure.ac: Improve mpeg2enc detection. This is for distributions that do ship mjpegtools, but without mpeg2enc. Al...
Original commit message from CVS:
2003-12-21 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Improve mpeg2enc detection. This is for distributions that do
ship mjpegtools, but without mpeg2enc. Also does object check
for might there ever be ABI incompatibility.
* ext/mpeg2enc/gstmpeg2enc.cc:
Add Andrew as second maintainer (he's helping me), and also add
an error if no caps was set. This happens if I pull before capsnego
and that's something I should solve sometime else.
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_parse_blockgroup):
Fix time parsing.
* gst/matroska/matroska-mux.c: (gst_matroska_mux_audio_pad_link),
(gst_matroska_mux_track_header):
Add caps to templates.
* gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_sink_factory):
Add mpegversion=1 to prevent confusion with MPEG/AAC.
* gst/mpegstream/gstmpegdemux.c:
Remove layer since it causes warnings about unfixed caps.
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_get):
Fix obvious typo (we error out if caps were set, we should of
course error out if *no* caps were set).
* sys/oss/gstosselement.c: (gst_osselement_convert):
Fix format conversion, we confused bits/bytes.
* sys/oss/gstosselement.h:
Improve documentation for 'bps'.
* sys/v4l/TODO:
Remove stuff about plugins that need removing - this was done
ages ago.
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_init),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query):
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_init), (gst_v4lsrc_src_convert),
(gst_v4lsrc_src_query):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init),
(gst_v4l2src_src_convert), (gst_v4l2src_src_query):
Add get_query_types(), get_formats() and query() functions.
2003-12-21 18:44:34 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
if (GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "device reported w: %d-%d, h: %d-%d",
|
|
|
|
vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight);
|
|
|
|
targetwidth = vcap->minwidth;
|
|
|
|
targetheight = vcap->minheight;
|
|
|
|
/* if we can get the current vwin settings, we use those to fixate */
|
|
|
|
if (!gst_v4l_get_capabilities (GST_V4LELEMENT (v4lsrc)))
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "failed getting capabilities");
|
|
|
|
else {
|
|
|
|
targetwidth = vwin->width;
|
|
|
|
targetheight = vwin->height;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "device closed, guessing");
|
|
|
|
targetwidth = 320;
|
|
|
|
targetheight = 200;
|
configure.ac: Improve mpeg2enc detection. This is for distributions that do ship mjpegtools, but without mpeg2enc. Al...
Original commit message from CVS:
2003-12-21 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Improve mpeg2enc detection. This is for distributions that do
ship mjpegtools, but without mpeg2enc. Also does object check
for might there ever be ABI incompatibility.
* ext/mpeg2enc/gstmpeg2enc.cc:
Add Andrew as second maintainer (he's helping me), and also add
an error if no caps was set. This happens if I pull before capsnego
and that's something I should solve sometime else.
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_parse_blockgroup):
Fix time parsing.
* gst/matroska/matroska-mux.c: (gst_matroska_mux_audio_pad_link),
(gst_matroska_mux_track_header):
Add caps to templates.
* gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_sink_factory):
Add mpegversion=1 to prevent confusion with MPEG/AAC.
* gst/mpegstream/gstmpegdemux.c:
Remove layer since it causes warnings about unfixed caps.
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_get):
Fix obvious typo (we error out if caps were set, we should of
course error out if *no* caps were set).
* sys/oss/gstosselement.c: (gst_osselement_convert):
Fix format conversion, we confused bits/bytes.
* sys/oss/gstosselement.h:
Improve documentation for 'bps'.
* sys/v4l/TODO:
Remove stuff about plugins that need removing - this was done
ages ago.
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_init),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query):
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_init), (gst_v4lsrc_src_convert),
(gst_v4lsrc_src_query):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init),
(gst_v4l2src_src_convert), (gst_v4l2src_src_query):
Add get_query_types(), get_formats() and query() functions.
2003-12-21 18:44:34 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "targetting %dx%d", targetwidth, targetheight);
|
|
|
|
|
|
|
|
for (i = 0; i < gst_caps_get_size (caps); ++i) {
|
2005-07-13 17:00:40 +00:00
|
|
|
const GValue *v;
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2006-12-09 15:12:38 +00:00
|
|
|
structure = gst_caps_get_structure (caps, i);
|
2005-11-21 14:29:53 +00:00
|
|
|
gst_structure_fixate_field_nearest_int (structure, "width", targetwidth);
|
|
|
|
gst_structure_fixate_field_nearest_int (structure, "height", targetheight);
|
2006-01-31 15:36:13 +00:00
|
|
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate", 15, 2);
|
2005-07-13 17:00:40 +00:00
|
|
|
|
|
|
|
v = gst_structure_get_value (structure, "format");
|
2005-11-10 12:57:01 +00:00
|
|
|
if (v && G_VALUE_TYPE (v) != GST_TYPE_FOURCC) {
|
2005-07-13 17:00:40 +00:00
|
|
|
guint32 fourcc;
|
|
|
|
|
|
|
|
g_return_if_fail (G_VALUE_TYPE (v) == GST_TYPE_LIST);
|
|
|
|
|
|
|
|
fourcc = gst_value_get_fourcc (gst_value_list_get_value (v, 0));
|
|
|
|
gst_structure_set (structure, "format", GST_TYPE_FOURCC, fourcc, NULL);
|
|
|
|
}
|
2005-07-07 11:29:29 +00:00
|
|
|
}
|
configure.ac: Improve mpeg2enc detection. This is for distributions that do ship mjpegtools, but without mpeg2enc. Al...
Original commit message from CVS:
2003-12-21 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Improve mpeg2enc detection. This is for distributions that do
ship mjpegtools, but without mpeg2enc. Also does object check
for might there ever be ABI incompatibility.
* ext/mpeg2enc/gstmpeg2enc.cc:
Add Andrew as second maintainer (he's helping me), and also add
an error if no caps was set. This happens if I pull before capsnego
and that's something I should solve sometime else.
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_parse_blockgroup):
Fix time parsing.
* gst/matroska/matroska-mux.c: (gst_matroska_mux_audio_pad_link),
(gst_matroska_mux_track_header):
Add caps to templates.
* gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_sink_factory):
Add mpegversion=1 to prevent confusion with MPEG/AAC.
* gst/mpegstream/gstmpegdemux.c:
Remove layer since it causes warnings about unfixed caps.
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_get):
Fix obvious typo (we error out if caps were set, we should of
course error out if *no* caps were set).
* sys/oss/gstosselement.c: (gst_osselement_convert):
Fix format conversion, we confused bits/bytes.
* sys/oss/gstosselement.h:
Improve documentation for 'bps'.
* sys/v4l/TODO:
Remove stuff about plugins that need removing - this was done
ages ago.
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_init),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query):
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_init), (gst_v4lsrc_src_convert),
(gst_v4lsrc_src_query):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init),
(gst_v4l2src_src_convert), (gst_v4l2src_src_query):
Add get_query_types(), get_formats() and query() functions.
2003-12-21 18:44:34 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
static gint all_palettes[] = {
|
|
|
|
VIDEO_PALETTE_YUV422,
|
|
|
|
VIDEO_PALETTE_YUV420P,
|
|
|
|
VIDEO_PALETTE_UYVY,
|
|
|
|
VIDEO_PALETTE_YUV411P,
|
|
|
|
VIDEO_PALETTE_YUV422P,
|
|
|
|
VIDEO_PALETTE_YUV410P,
|
|
|
|
VIDEO_PALETTE_YUV411,
|
|
|
|
VIDEO_PALETTE_RGB555,
|
|
|
|
VIDEO_PALETTE_RGB565,
|
|
|
|
VIDEO_PALETTE_RGB24,
|
|
|
|
VIDEO_PALETTE_RGB32,
|
|
|
|
-1
|
|
|
|
};
|
|
|
|
|
2003-05-10 14:36:34 +00:00
|
|
|
static GstCaps *
|
2004-01-28 21:16:01 +00:00
|
|
|
gst_v4lsrc_palette_to_caps (int palette)
|
2003-05-10 14:36:34 +00:00
|
|
|
{
|
|
|
|
guint32 fourcc;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
switch (palette) {
|
|
|
|
case VIDEO_PALETTE_YUV422:
|
|
|
|
case VIDEO_PALETTE_YUYV:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
|
|
|
case VIDEO_PALETTE_YUV420P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
|
|
|
case VIDEO_PALETTE_UYVY:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
2004-01-06 20:15:21 +00:00
|
|
|
case VIDEO_PALETTE_YUV411P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_YUV411:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'P');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
2004-01-06 20:15:21 +00:00
|
|
|
case VIDEO_PALETTE_YUV422P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
|
|
|
case VIDEO_PALETTE_YUV410P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB555:
|
|
|
|
case VIDEO_PALETTE_RGB565:
|
|
|
|
case VIDEO_PALETTE_RGB24:
|
|
|
|
case VIDEO_PALETTE_RGB32:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (fourcc == GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
|
2003-05-10 14:36:34 +00:00
|
|
|
switch (palette) {
|
|
|
|
case VIDEO_PALETTE_RGB555:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
|
|
|
"bpp = (int) 16, "
|
|
|
|
"depth = (int) 15, "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"red_mask = 0x7c00, " "green_mask = 0x03e0, " "blue_mask = 0x001f");
|
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB565:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
|
|
|
"bpp = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"red_mask = 0xf800, " "green_mask = 0x07f0, " "blue_mask = 0x001f");
|
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB24:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
|
|
|
"bpp = (int) 24, "
|
|
|
|
"depth = (int) 24, "
|
|
|
|
"endianness = (int) BIG_ENDIAN, "
|
2007-08-21 15:43:24 +00:00
|
|
|
"red_mask = 0xFF0000, "
|
|
|
|
"green_mask = 0x00FF00, " "blue_mask = 0x0000FF");
|
2004-03-15 19:32:28 +00:00
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB32:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
2005-07-07 11:29:29 +00:00
|
|
|
"bpp = (int) 32, "
|
|
|
|
"depth = (int) 24, "
|
2004-03-15 19:32:28 +00:00
|
|
|
"endianness = (int) BIG_ENDIAN, "
|
|
|
|
"red_mask = 0xFF000000, "
|
|
|
|
"green_mask = 0x00FF0000, " "blue_mask = 0x0000FF00");
|
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
default:
|
2004-03-15 19:32:28 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
2003-12-22 01:47:09 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
2004-03-15 19:32:28 +00:00
|
|
|
"format", GST_TYPE_FOURCC, fourcc, NULL);
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2005-07-05 14:54:19 +00:00
|
|
|
static GstCaps *
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
gst_v4lsrc_get_any_caps (void)
|
2005-07-05 14:54:19 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GstCaps *caps = gst_caps_new_empty (), *one;
|
|
|
|
|
|
|
|
for (i = 0; all_palettes[i] != -1; i++) {
|
|
|
|
one = gst_v4lsrc_palette_to_caps (all_palettes[i]);
|
|
|
|
gst_caps_append (caps, one);
|
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_v4lsrc_get_caps (GstBaseSrc * src)
|
|
|
|
{
|
|
|
|
GstCaps *list;
|
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (src);
|
|
|
|
struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
|
|
|
|
gint width = GST_V4LELEMENT (src)->vcap.minwidth;
|
|
|
|
gint height = GST_V4LELEMENT (src)->vcap.minheight;
|
|
|
|
gint i;
|
2005-11-23 10:40:42 +00:00
|
|
|
gint fps_n, fps_d;
|
2005-07-07 11:29:29 +00:00
|
|
|
GList *item;
|
|
|
|
|
|
|
|
if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
|
|
|
|
return gst_v4lsrc_get_any_caps ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!v4lsrc->autoprobe) {
|
|
|
|
/* FIXME: query current caps and return those, with _any appended */
|
|
|
|
return gst_v4lsrc_get_any_caps ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!v4lsrc->colorspaces) {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "Checking supported palettes");
|
|
|
|
for (i = 0; all_palettes[i] != -1; i++) {
|
|
|
|
/* try palette out */
|
|
|
|
if (!gst_v4lsrc_try_capture (v4lsrc, width, height, all_palettes[i]))
|
|
|
|
continue;
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "Added palette %d (%s) to supported list",
|
|
|
|
all_palettes[i], gst_v4lsrc_palette_name (all_palettes[i]));
|
|
|
|
v4lsrc->colorspaces = g_list_append (v4lsrc->colorspaces,
|
|
|
|
GINT_TO_POINTER (all_palettes[i]));
|
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "%d palette(s) supported",
|
|
|
|
g_list_length (v4lsrc->colorspaces));
|
|
|
|
if (v4lsrc->autoprobe_fps) {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "autoprobing framerates");
|
|
|
|
v4lsrc->fps_list = gst_v4lsrc_get_fps_list (v4lsrc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
|
2005-11-23 10:40:42 +00:00
|
|
|
if (!gst_v4lsrc_get_fps (v4lsrc, &fps_n, &fps_d)) {
|
|
|
|
fps_n = 0;
|
|
|
|
fps_d = 1;
|
|
|
|
}
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
list = gst_caps_new_empty ();
|
|
|
|
for (item = v4lsrc->colorspaces; item != NULL; item = item->next) {
|
|
|
|
GstCaps *one;
|
|
|
|
|
|
|
|
one = gst_v4lsrc_palette_to_caps (GPOINTER_TO_INT (item->data));
|
|
|
|
if (!one) {
|
|
|
|
GST_WARNING_OBJECT (v4lsrc, "Palette %d gave no caps\n",
|
|
|
|
GPOINTER_TO_INT (item->data));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc,
|
2005-11-22 23:39:12 +00:00
|
|
|
"Device reports w: %d-%d, h: %d-%d, fps: %d/%d for palette %d",
|
|
|
|
vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight,
|
2005-11-23 10:40:42 +00:00
|
|
|
fps_n, fps_d, GPOINTER_TO_INT (item->data));
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
if (vcap->minwidth < vcap->maxwidth) {
|
|
|
|
gst_caps_set_simple (one, "width", GST_TYPE_INT_RANGE, vcap->minwidth,
|
|
|
|
vcap->maxwidth, NULL);
|
|
|
|
} else {
|
|
|
|
gst_caps_set_simple (one, "width", G_TYPE_INT, vcap->minwidth, NULL);
|
|
|
|
}
|
|
|
|
if (vcap->minheight < vcap->maxheight) {
|
|
|
|
gst_caps_set_simple (one, "height", GST_TYPE_INT_RANGE, vcap->minheight,
|
|
|
|
vcap->maxheight, NULL);
|
|
|
|
} else {
|
|
|
|
gst_caps_set_simple (one, "height", G_TYPE_INT, vcap->minheight, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v4lsrc->autoprobe_fps) {
|
2005-11-22 23:39:12 +00:00
|
|
|
GstStructure *structure = gst_caps_get_structure (one, 0);
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
if (v4lsrc->fps_list) {
|
2005-07-07 11:29:29 +00:00
|
|
|
gst_structure_set_value (structure, "framerate", v4lsrc->fps_list);
|
|
|
|
} else {
|
2005-11-23 10:40:42 +00:00
|
|
|
gst_structure_set (structure, "framerate", GST_TYPE_FRACTION,
|
|
|
|
fps_n, fps_d, NULL);
|
2005-07-07 11:29:29 +00:00
|
|
|
}
|
|
|
|
} else {
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_caps_set_simple (one, "framerate", GST_TYPE_FRACTION_RANGE,
|
|
|
|
1, 1, 100, 1, NULL);
|
2005-07-07 11:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "caps: %" GST_PTR_FORMAT, one);
|
|
|
|
gst_caps_append (list, one);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_v4lsrc_set_caps (GstBaseSrc * src, GstCaps * caps)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
2003-12-22 01:47:09 +00:00
|
|
|
guint32 fourcc;
|
2004-01-06 20:15:21 +00:00
|
|
|
gint bpp, depth, w, h, palette = -1;
|
2005-11-22 23:39:12 +00:00
|
|
|
const GValue *new_fps;
|
2005-11-23 10:40:42 +00:00
|
|
|
gint cur_fps_n, cur_fps_d;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2004-06-17 17:06:24 +00:00
|
|
|
struct video_window *vwin;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
v4lsrc = GST_V4LSRC (src);
|
2004-06-17 17:06:24 +00:00
|
|
|
vwin = &GST_V4LELEMENT (v4lsrc)->vwin;
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
/* if we're not open, punt -- we'll get setcaps'd later via negotiate */
|
|
|
|
if (!GST_V4L_IS_OPEN (v4lsrc))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* make sure we stop capturing and dealloc buffers */
|
|
|
|
if (GST_V4L_IS_ACTIVE (v4lsrc)) {
|
|
|
|
if (!gst_v4lsrc_capture_stop (v4lsrc))
|
|
|
|
return FALSE;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_deinit (v4lsrc))
|
2005-07-07 11:29:29 +00:00
|
|
|
return FALSE;
|
2002-09-18 10:57:56 +00:00
|
|
|
}
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
/* it's fixed, one struct */
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2002-03-30 17:06:26 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0)
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_fourcc (structure, "format", &fourcc);
|
|
|
|
else
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_int (structure, "width", &w);
|
|
|
|
gst_structure_get_int (structure, "height", &h);
|
2005-11-22 23:39:12 +00:00
|
|
|
new_fps = gst_structure_get_value (structure, "framerate");
|
|
|
|
|
2004-06-09 11:32:39 +00:00
|
|
|
/* set framerate if it's not already correct */
|
2005-11-23 10:40:42 +00:00
|
|
|
if (!gst_v4lsrc_get_fps (v4lsrc, &cur_fps_n, &cur_fps_d))
|
2005-11-22 23:39:12 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2006-01-31 15:36:13 +00:00
|
|
|
if (new_fps) {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "linking with %dx%d at %d/%d fps", w, h,
|
|
|
|
gst_value_get_fraction_numerator (new_fps),
|
|
|
|
gst_value_get_fraction_denominator (new_fps));
|
|
|
|
|
|
|
|
if (gst_value_get_fraction_numerator (new_fps) != cur_fps_n ||
|
|
|
|
gst_value_get_fraction_denominator (new_fps) != cur_fps_d) {
|
|
|
|
int fps_index = (gst_value_get_fraction_numerator (new_fps) * 16) /
|
|
|
|
(gst_value_get_fraction_denominator (new_fps) * 15);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "Trying to set fps index %d", fps_index);
|
|
|
|
/* set bits 16 to 21 to 0 */
|
|
|
|
vwin->flags &= (0x3F00 - 1);
|
|
|
|
/* set bits 16 to 21 to the index */
|
|
|
|
vwin->flags |= fps_index << 16;
|
|
|
|
if (!gst_v4l_set_window_properties (GST_V4LELEMENT (v4lsrc))) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-06-09 11:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-09 18:27:32 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (fourcc) {
|
|
|
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV420P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * ((h + 1) & ~1) * 1.5;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV422;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_UYVY;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
|
2004-01-06 20:15:21 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV411P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 3) & ~3) * h * 1.5;
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV411;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 3) & ~3) * h * 1.5;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
|
2004-01-06 20:15:21 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV410P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 3) & ~3) * ((h + 3) & ~3) * 1.125;
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
|
2004-01-06 20:15:21 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV422P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
|
2004-01-06 20:15:21 +00:00
|
|
|
gst_structure_get_int (structure, "depth", &depth);
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (depth) {
|
2004-03-15 19:32:28 +00:00
|
|
|
case 15:
|
|
|
|
palette = VIDEO_PALETTE_RGB555;
|
|
|
|
v4lsrc->buffer_size = w * h * 2;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
palette = VIDEO_PALETTE_RGB565;
|
|
|
|
v4lsrc->buffer_size = w * h * 2;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
gst_structure_get_int (structure, "bpp", &bpp);
|
|
|
|
switch (bpp) {
|
|
|
|
case 24:
|
|
|
|
palette = VIDEO_PALETTE_RGB24;
|
|
|
|
v4lsrc->buffer_size = w * h * 3;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
palette = VIDEO_PALETTE_RGB32;
|
|
|
|
v4lsrc->buffer_size = w * h * 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2003-12-22 01:47:09 +00:00
|
|
|
default:
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-01-20 16:03:10 +00:00
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
if (palette == -1) {
|
2005-11-21 13:32:36 +00:00
|
|
|
GST_WARNING_OBJECT (v4lsrc, "palette for fourcc %" GST_FOURCC_FORMAT
|
2004-11-09 18:27:32 +00:00
|
|
|
" is -1, refusing link", GST_FOURCC_ARGS (fourcc));
|
2005-07-07 11:29:29 +00:00
|
|
|
return FALSE;
|
2004-06-17 17:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "trying to set_capture %dx%d, palette %d",
|
|
|
|
w, h, palette);
|
2004-08-12 15:58:52 +00:00
|
|
|
/* this only fills in v4lsrc->mmap values */
|
2004-06-17 17:06:24 +00:00
|
|
|
if (!gst_v4lsrc_set_capture (v4lsrc, w, h, palette)) {
|
2004-06-17 17:43:18 +00:00
|
|
|
GST_WARNING_OBJECT (v4lsrc, "could not set_capture %dx%d, palette %d",
|
2004-06-17 17:06:24 +00:00
|
|
|
w, h, palette);
|
2005-07-07 11:29:29 +00:00
|
|
|
return FALSE;
|
2004-06-17 17:06:24 +00:00
|
|
|
}
|
2002-09-20 09:28:46 +00:00
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
/* first try the negotiated settings using try_capture */
|
|
|
|
if (!gst_v4lsrc_try_capture (v4lsrc, w, h, palette)) {
|
2004-08-12 15:58:52 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "failed trying palette %d for %dx%d", palette,
|
|
|
|
w, h);
|
2005-07-07 11:29:29 +00:00
|
|
|
return FALSE;
|
2004-06-17 17:06:24 +00:00
|
|
|
}
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_init (v4lsrc))
|
2005-07-07 11:29:29 +00:00
|
|
|
return FALSE;
|
2004-08-12 15:58:52 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
if (!gst_v4lsrc_capture_start (v4lsrc))
|
|
|
|
return FALSE;
|
2004-08-12 15:58:52 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
return TRUE;
|
2004-04-27 15:08:27 +00:00
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2007-02-28 15:05:03 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4lsrc_query (GstBaseSrc * bsrc, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
|
|
|
gboolean res = FALSE;
|
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (bsrc);
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_LATENCY:
|
|
|
|
{
|
|
|
|
GstClockTime min_latency, max_latency;
|
|
|
|
gint fps_n, fps_d;
|
|
|
|
|
|
|
|
/* device must be open */
|
|
|
|
if (!GST_V4L_IS_OPEN (v4lsrc))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* we must have a framerate */
|
|
|
|
if (!(res = gst_v4lsrc_get_fps (v4lsrc, &fps_n, &fps_d)))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* min latency is the time to capture one frame */
|
|
|
|
min_latency = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);
|
|
|
|
|
|
|
|
/* max latency is total duration of the frame buffer */
|
|
|
|
max_latency = v4lsrc->mbuf.frames * min_latency;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (bsrc,
|
|
|
|
"report latency min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency));
|
|
|
|
|
|
|
|
/* we are always live, the min latency is 1 frame and the max latency is
|
|
|
|
* the complete buffer of frames. */
|
|
|
|
gst_query_set_latency (query, TRUE, min_latency, max_latency);
|
|
|
|
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
/* start and stop are not symmetric -- start will open the device, but not start
|
|
|
|
capture. it's setcaps that will start capture, which is called via basesrc's
|
|
|
|
negotiate method. stop will both stop capture and close the device.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
gst_v4lsrc_start (GstBaseSrc * src)
|
2003-05-10 14:36:34 +00:00
|
|
|
{
|
2005-07-07 11:29:29 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (src);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
v4lsrc->offset = 0;
|
2003-05-10 14:36:34 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
return TRUE;
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4lsrc_stop (GstBaseSrc * src)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2005-07-07 11:29:29 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (src);
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2005-07-13 17:00:40 +00:00
|
|
|
if (GST_V4L_IS_ACTIVE (v4lsrc) && !gst_v4lsrc_capture_stop (v4lsrc))
|
2005-07-07 11:29:29 +00:00
|
|
|
return FALSE;
|
2004-05-13 10:13:41 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
if (GST_V4LELEMENT (v4lsrc)->buffer != NULL) {
|
|
|
|
if (!gst_v4lsrc_capture_deinit (v4lsrc))
|
|
|
|
return FALSE;
|
2004-05-13 10:13:41 +00:00
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
g_list_free (v4lsrc->colorspaces);
|
|
|
|
v4lsrc->colorspaces = NULL;
|
2004-06-26 15:58:35 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
if (v4lsrc->fps_list) {
|
|
|
|
g_value_unset (v4lsrc->fps_list);
|
|
|
|
g_free (v4lsrc->fps_list);
|
|
|
|
v4lsrc->fps_list = NULL;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
return TRUE;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_v4lsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2005-07-07 11:29:29 +00:00
|
|
|
gint num;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
v4lsrc = GST_V4LSRC (src);
|
2002-01-04 23:58:11 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
/* grab a frame from the device */
|
|
|
|
if (!gst_v4lsrc_grab_frame (v4lsrc, &num))
|
|
|
|
return GST_FLOW_ERROR;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
*buf = gst_v4lsrc_buffer_new (v4lsrc, num);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2005-07-12 17:14:33 +00:00
|
|
|
if (v4lsrc->copy_mode) {
|
|
|
|
GstBuffer *copy = gst_buffer_copy (*buf);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2005-07-12 17:14:33 +00:00
|
|
|
gst_buffer_unref (*buf);
|
|
|
|
*buf = copy;
|
|
|
|
}
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
return GST_FLOW_OK;
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|