2006-03-11 22:50:03 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2006-09-02 14:28:55 +00:00
|
|
|
* 2006 Edgard Lima <edgard.lima@indt.org.br>
|
|
|
|
*
|
2006-10-03 13:18:59 +00:00
|
|
|
* gstv4l2src.c: Video4Linux2 source element
|
2002-09-09 07:14:35 +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.
|
|
|
|
*/
|
|
|
|
|
2006-04-17 19:43:32 +00:00
|
|
|
/**
|
2006-09-26 14:17:54 +00:00
|
|
|
* SECTION:element-v4l2src
|
2006-04-17 19:43:32 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* v4l2src can be used to capture video from v4l2 devices, like webcams and tv cards.
|
2007-07-18 11:55:13 +00:00
|
|
|
* <title>Example launch lines</title>
|
2006-04-17 19:43:32 +00:00
|
|
|
* <para>
|
|
|
|
* <programlisting>
|
|
|
|
* gst-launch v4l2src ! xvimagesink
|
|
|
|
* </programlisting>
|
2006-10-03 13:18:59 +00:00
|
|
|
* This pipeline shows the video captured from /dev/video0 tv card and for
|
|
|
|
* webcams.
|
2006-04-17 19:43:32 +00:00
|
|
|
* </para>
|
2007-07-18 11:55:13 +00:00
|
|
|
* <para>
|
|
|
|
* <programlisting>
|
|
|
|
* gst-launch-0.10 v4l2src ! jpegdec ! xvimagesink
|
|
|
|
* </programlisting>
|
|
|
|
* This pipeline shows the video captured from a webcam that delivers jpeg
|
|
|
|
* images.
|
|
|
|
* </para>
|
2006-04-17 19:43:32 +00:00
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
2003-07-03 15:55:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2006-03-11 22:50:03 +00:00
|
|
|
#include <config.h>
|
2003-07-03 15:55:12 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-09 07:14:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "v4l2src_calls.h"
|
2006-03-11 22:50:03 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
#include "gstv4l2colorbalance.h"
|
|
|
|
#include "gstv4l2tuner.h"
|
2008-05-17 10:38:18 +00:00
|
|
|
#if 0 /* overlay is still not implemented #ifdef HAVE_XVIDEO */
|
2006-05-11 17:59:59 +00:00
|
|
|
#include "gstv4l2xoverlay.h"
|
2008-05-17 10:38:18 +00:00
|
|
|
#endif
|
2006-09-19 13:08:35 +00:00
|
|
|
#include "gstv4l2vidorient.h"
|
2006-03-11 22:50:03 +00:00
|
|
|
|
2006-04-25 21:56:38 +00:00
|
|
|
static const GstElementDetails gst_v4l2src_details =
|
2006-03-11 22:50:03 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Video (video4linux2/raw) Source",
|
|
|
|
"Source/Video",
|
|
|
|
"Reads raw frames from a video4linux2 (BT8x8) device",
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>,"
|
|
|
|
" Edgard Lima <edgard.lima@indt.org.br>");
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
GST_DEBUG_CATEGORY (v4l2src_debug);
|
|
|
|
#define GST_CAT_DEFAULT v4l2src_debug
|
|
|
|
|
2007-11-15 12:22:10 +00:00
|
|
|
#define DEFAULT_PROP_ALWAYS_COPY TRUE
|
|
|
|
|
2006-05-18 19:34:47 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
V4L2_STD_OBJECT_PROPS,
|
2007-11-15 12:22:10 +00:00
|
|
|
PROP_QUEUE_SIZE,
|
|
|
|
PROP_ALWAYS_COPY
|
2006-05-18 19:34:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const guint32 gst_v4l2_formats[] = {
|
2006-03-11 22:50:03 +00:00
|
|
|
/* from Linux 2.6.15 videodev2.h */
|
|
|
|
V4L2_PIX_FMT_RGB332,
|
|
|
|
V4L2_PIX_FMT_RGB555,
|
|
|
|
V4L2_PIX_FMT_RGB565,
|
|
|
|
V4L2_PIX_FMT_RGB555X,
|
|
|
|
V4L2_PIX_FMT_RGB565X,
|
|
|
|
V4L2_PIX_FMT_BGR24,
|
|
|
|
V4L2_PIX_FMT_RGB24,
|
|
|
|
V4L2_PIX_FMT_BGR32,
|
|
|
|
V4L2_PIX_FMT_RGB32,
|
|
|
|
V4L2_PIX_FMT_GREY,
|
|
|
|
V4L2_PIX_FMT_YVU410,
|
|
|
|
V4L2_PIX_FMT_YVU420,
|
|
|
|
V4L2_PIX_FMT_YUYV,
|
|
|
|
V4L2_PIX_FMT_UYVY,
|
|
|
|
V4L2_PIX_FMT_YUV422P,
|
|
|
|
V4L2_PIX_FMT_YUV411P,
|
|
|
|
V4L2_PIX_FMT_Y41P,
|
|
|
|
|
|
|
|
/* two planes -- one Y, one Cr + Cb interleaved */
|
|
|
|
V4L2_PIX_FMT_NV12,
|
|
|
|
V4L2_PIX_FMT_NV21,
|
|
|
|
|
|
|
|
/* The following formats are not defined in the V4L2 specification */
|
|
|
|
V4L2_PIX_FMT_YUV410,
|
|
|
|
V4L2_PIX_FMT_YUV420,
|
|
|
|
V4L2_PIX_FMT_YYUV,
|
|
|
|
V4L2_PIX_FMT_HI240,
|
|
|
|
|
|
|
|
/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
|
2006-04-20 17:29:56 +00:00
|
|
|
#ifdef V4L2_PIX_FMT_SBGGR8
|
2006-03-11 22:50:03 +00:00
|
|
|
V4L2_PIX_FMT_SBGGR8,
|
2006-04-20 17:29:56 +00:00
|
|
|
#endif
|
2006-03-11 22:50:03 +00:00
|
|
|
|
|
|
|
/* compressed formats */
|
|
|
|
V4L2_PIX_FMT_MJPEG,
|
|
|
|
V4L2_PIX_FMT_JPEG,
|
|
|
|
V4L2_PIX_FMT_DV,
|
|
|
|
V4L2_PIX_FMT_MPEG,
|
|
|
|
|
|
|
|
/* Vendor-specific formats */
|
2006-04-20 17:29:56 +00:00
|
|
|
V4L2_PIX_FMT_WNVA,
|
|
|
|
|
|
|
|
#ifdef V4L2_PIX_FMT_SN9C10X
|
|
|
|
V4L2_PIX_FMT_SN9C10X,
|
|
|
|
#endif
|
|
|
|
#ifdef V4L2_PIX_FMT_PWC1
|
|
|
|
V4L2_PIX_FMT_PWC1,
|
|
|
|
#endif
|
|
|
|
#ifdef V4L2_PIX_FMT_PWC2
|
|
|
|
V4L2_PIX_FMT_PWC2,
|
|
|
|
#endif
|
2004-01-12 02:19:57 +00:00
|
|
|
};
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
#define GST_V4L2_FORMAT_COUNT (G_N_ELEMENTS (gst_v4l2_formats))
|
|
|
|
|
2006-05-18 19:34:47 +00:00
|
|
|
GST_IMPLEMENT_V4L2_PROBE_METHODS (GstV4l2SrcClass, gst_v4l2src);
|
|
|
|
GST_IMPLEMENT_V4L2_COLOR_BALANCE_METHODS (GstV4l2Src, gst_v4l2src);
|
|
|
|
GST_IMPLEMENT_V4L2_TUNER_METHODS (GstV4l2Src, gst_v4l2src);
|
2006-11-01 19:48:26 +00:00
|
|
|
#if 0 /* overlay is still not implemented #ifdef HAVE_XVIDEO */
|
2006-05-18 19:34:47 +00:00
|
|
|
GST_IMPLEMENT_V4L2_XOVERLAY_METHODS (GstV4l2Src, gst_v4l2src);
|
2006-05-11 17:59:59 +00:00
|
|
|
#endif
|
2006-09-19 13:08:35 +00:00
|
|
|
GST_IMPLEMENT_V4L2_VIDORIENT_METHODS (GstV4l2Src, gst_v4l2src);
|
2006-05-18 19:34:47 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_iface_supported (GstImplementsInterface * iface, GType iface_type)
|
2006-05-11 17:59:59 +00:00
|
|
|
{
|
|
|
|
GstV4l2Object *v4l2object = GST_V4L2SRC (iface)->v4l2object;
|
|
|
|
|
2006-11-01 19:48:26 +00:00
|
|
|
#if 0 /* overlay is still not implemented #ifdef HAVE_XVIDEO */
|
2006-05-11 17:59:59 +00:00
|
|
|
g_assert (iface_type == GST_TYPE_TUNER ||
|
2006-09-19 13:08:35 +00:00
|
|
|
iface_type == GST_TYPE_X_OVERLAY ||
|
|
|
|
iface_type == GST_TYPE_COLOR_BALANCE ||
|
|
|
|
iface_type == GST_TYPE_VIDEO_ORIENTATION);
|
2006-05-11 17:59:59 +00:00
|
|
|
#else
|
|
|
|
g_assert (iface_type == GST_TYPE_TUNER ||
|
2006-09-19 13:08:35 +00:00
|
|
|
iface_type == GST_TYPE_COLOR_BALANCE ||
|
|
|
|
iface_type == GST_TYPE_VIDEO_ORIENTATION);
|
2006-05-11 17:59:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (v4l2object->video_fd == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
2006-11-01 19:48:26 +00:00
|
|
|
#if 0 /* overlay is still not implemented #ifdef HAVE_XVIDEO */
|
2006-05-11 17:59:59 +00:00
|
|
|
if (iface_type == GST_TYPE_X_OVERLAY && !GST_V4L2_IS_OVERLAY (v4l2object))
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
static void
|
|
|
|
gst_v4l2src_interface_init (GstImplementsInterfaceClass * klass)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* default virtual functions
|
|
|
|
*/
|
|
|
|
klass->supported = gst_v4l2src_iface_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_v4l2src_init_interfaces (GType type)
|
|
|
|
{
|
|
|
|
static const GInterfaceInfo v4l2iface_info = {
|
|
|
|
(GInterfaceInitFunc) gst_v4l2src_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
static const GInterfaceInfo v4l2_tuner_info = {
|
|
|
|
(GInterfaceInitFunc) gst_v4l2src_tuner_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
2006-11-01 19:48:26 +00:00
|
|
|
#if 0 /* overlay is still not implemented #ifdef HAVE_XVIDEO */
|
2006-05-11 17:59:59 +00:00
|
|
|
static const GInterfaceInfo v4l2_xoverlay_info = {
|
|
|
|
(GInterfaceInitFunc) gst_v4l2src_xoverlay_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
static const GInterfaceInfo v4l2_colorbalance_info = {
|
|
|
|
(GInterfaceInitFunc) gst_v4l2src_color_balance_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
2006-09-19 13:08:35 +00:00
|
|
|
static const GInterfaceInfo v4l2_videoorientation_info = {
|
|
|
|
(GInterfaceInitFunc) gst_v4l2src_video_orientation_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
2006-05-11 17:59:59 +00:00
|
|
|
static const GInterfaceInfo v4l2_propertyprobe_info = {
|
|
|
|
(GInterfaceInitFunc) gst_v4l2src_property_probe_interface_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
g_type_add_interface_static (type,
|
|
|
|
GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info);
|
|
|
|
g_type_add_interface_static (type, GST_TYPE_TUNER, &v4l2_tuner_info);
|
2006-11-01 19:48:26 +00:00
|
|
|
#if 0 /* overlay is still not implemented #ifdef HAVE_XVIDEO */
|
2006-05-11 17:59:59 +00:00
|
|
|
g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info);
|
|
|
|
#endif
|
|
|
|
g_type_add_interface_static (type,
|
|
|
|
GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info);
|
2006-09-19 13:08:35 +00:00
|
|
|
g_type_add_interface_static (type,
|
|
|
|
GST_TYPE_VIDEO_ORIENTATION, &v4l2_videoorientation_info);
|
2006-05-11 17:59:59 +00:00
|
|
|
g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
|
|
|
|
&v4l2_propertyprobe_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_BOILERPLATE_FULL (GstV4l2Src, gst_v4l2src, GstPushSrc, GST_TYPE_PUSH_SRC,
|
|
|
|
gst_v4l2src_init_interfaces);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-04-13 21:45:57 +00:00
|
|
|
static void gst_v4l2src_dispose (GObject * object);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
Fix a bunch of leaks shown by the newly-added states test.
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flac_enc_finalize):
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init),
(gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize):
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init),
(gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose),
(gst_gconf_audio_src_finalize), (do_toggle_element):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init),
(gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init),
(gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose),
(gst_gconf_video_src_finalize), (do_toggle_element):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init),
(gst_switch_sink_reset), (gst_switch_sink_set_child):
* ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init):
* ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init):
* ext/shout2/gstshout2.c: (gst_shout2send_class_init),
(gst_shout2send_init), (gst_shout2send_finalize):
* gst/debug/testplugin.c: (gst_test_class_init),
(gst_test_finalize):
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(gst_flxdec_dispose):
* gst/multipart/multipartmux.c: (gst_multipart_mux_finalize):
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize):
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init),
(gst_rtspsrc_finalize):
* gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context):
* gst/rtsp/rtspextwms.h:
* gst/smpte/gstsmpte.c: (gst_smpte_class_init),
(gst_smpte_finalize):
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize):
* gst/udp/gstudpsink.c: (gst_udpsink_class_init),
(gst_udpsink_finalize):
* gst/wavparse/gstwavparse.c: (gst_wavparse_dispose),
(gst_wavparse_sink_activate):
* sys/oss/gstosssink.c: (gst_oss_sink_finalise):
* sys/oss/gstosssrc.c: (gst_oss_src_class_init),
(gst_oss_src_finalize):
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_finalize):
* sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get):
Fix a bunch of leaks shown by the newly-added states test.
2007-03-04 13:52:03 +00:00
|
|
|
static void gst_v4l2src_finalize (GstV4l2Src * v4l2src);
|
2003-05-02 21:16:56 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
/* basesrc methods */
|
|
|
|
static gboolean gst_v4l2src_start (GstBaseSrc * src);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static gboolean gst_v4l2src_stop (GstBaseSrc * src);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static gboolean gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static GstCaps *gst_v4l2src_get_caps (GstBaseSrc * src);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2007-09-05 14:43:16 +00:00
|
|
|
static gboolean gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static GstFlowReturn gst_v4l2src_create (GstPushSrc * src, GstBuffer ** out);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2007-10-13 12:03:44 +00:00
|
|
|
static void gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2008-06-04 17:39:31 +00:00
|
|
|
static gboolean gst_v4l2src_negotiate (GstBaseSrc * basesrc);
|
|
|
|
|
2006-05-18 19:34:47 +00:00
|
|
|
static void gst_v4l2src_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
2006-03-25 05:31:28 +00:00
|
|
|
static void gst_v4l2src_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2006-03-11 22:50:03 +00:00
|
|
|
|
|
|
|
static GstCaps *gst_v4l2src_get_all_caps (void);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2003-11-02 17:02:51 +00:00
|
|
|
static void
|
2004-01-12 02:19:57 +00:00
|
|
|
gst_v4l2src_base_init (gpointer g_class)
|
2003-11-02 17:02:51 +00:00
|
|
|
{
|
2004-01-12 02:19:57 +00:00
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
GstV4l2SrcClass *gstv4l2src_class = GST_V4L2SRC_CLASS (g_class);
|
|
|
|
|
|
|
|
gstv4l2src_class->v4l2_class_devices = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-03-14 17:24:03 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "V4L2 source element");
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
gst_element_class_set_details (gstelement_class, &gst_v4l2src_details);
|
2003-11-02 17:02:51 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
gst_element_class_add_pad_template
|
|
|
|
(gstelement_class,
|
|
|
|
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
|
|
|
gst_v4l2src_get_all_caps ()));
|
2003-11-02 17:02:51 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
static void
|
2006-03-11 22:50:03 +00:00
|
|
|
gst_v4l2src_class_init (GstV4l2SrcClass * klass)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2006-03-11 22:50:03 +00:00
|
|
|
GObjectClass *gobject_class;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
GstBaseSrcClass *basesrc_class;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
GstPushSrcClass *pushsrc_class;
|
2004-01-12 02:19:57 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
basesrc_class = GST_BASE_SRC_CLASS (klass);
|
|
|
|
pushsrc_class = GST_PUSH_SRC_CLASS (klass);
|
2004-01-12 02:19:57 +00:00
|
|
|
|
2006-09-26 13:18:06 +00:00
|
|
|
gobject_class->dispose = gst_v4l2src_dispose;
|
Fix a bunch of leaks shown by the newly-added states test.
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flac_enc_finalize):
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init),
(gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize):
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init),
(gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose),
(gst_gconf_audio_src_finalize), (do_toggle_element):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init),
(gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init),
(gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose),
(gst_gconf_video_src_finalize), (do_toggle_element):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init),
(gst_switch_sink_reset), (gst_switch_sink_set_child):
* ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init):
* ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init):
* ext/shout2/gstshout2.c: (gst_shout2send_class_init),
(gst_shout2send_init), (gst_shout2send_finalize):
* gst/debug/testplugin.c: (gst_test_class_init),
(gst_test_finalize):
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(gst_flxdec_dispose):
* gst/multipart/multipartmux.c: (gst_multipart_mux_finalize):
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize):
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init),
(gst_rtspsrc_finalize):
* gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context):
* gst/rtsp/rtspextwms.h:
* gst/smpte/gstsmpte.c: (gst_smpte_class_init),
(gst_smpte_finalize):
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize):
* gst/udp/gstudpsink.c: (gst_udpsink_class_init),
(gst_udpsink_finalize):
* gst/wavparse/gstwavparse.c: (gst_wavparse_dispose),
(gst_wavparse_sink_activate):
* sys/oss/gstosssink.c: (gst_oss_sink_finalise):
* sys/oss/gstosssrc.c: (gst_oss_src_class_init),
(gst_oss_src_finalize):
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_finalize):
* sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get):
Fix a bunch of leaks shown by the newly-added states test.
2007-03-04 13:52:03 +00:00
|
|
|
gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2src_finalize;
|
2004-01-12 02:19:57 +00:00
|
|
|
gobject_class->set_property = gst_v4l2src_set_property;
|
|
|
|
gobject_class->get_property = gst_v4l2src_get_property;
|
|
|
|
|
2006-05-19 18:31:25 +00:00
|
|
|
gst_v4l2_object_install_properties_helper (gobject_class);
|
sys/v4l2/: Fix EIO handing when capturing. Add new property to specify the number of buffers to enque (and remove the...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_set_property),
(gst_v4l2src_get_property), (gst_v4l2src_set_caps):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_deinit):
Fix EIO handing when capturing. Add new property to specify the number of
buffers to enque (and remove the borked num-buffers usage).
2007-01-17 14:30:50 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_QUEUE_SIZE,
|
|
|
|
g_param_spec_uint ("queue-size", "Queue size",
|
|
|
|
"Number of buffers to be enqueud in the driver",
|
|
|
|
GST_V4L2_MIN_BUFFERS, GST_V4L2_MAX_BUFFERS, GST_V4L2_MIN_BUFFERS,
|
|
|
|
G_PARAM_READWRITE));
|
2007-11-15 12:22:10 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_ALWAYS_COPY,
|
|
|
|
g_param_spec_boolean ("always-copy", "Always Copy",
|
|
|
|
"If the buffer will or not be used directly from mmap",
|
|
|
|
DEFAULT_PROP_ALWAYS_COPY, G_PARAM_READWRITE));
|
2006-05-11 17:59:59 +00:00
|
|
|
|
2007-09-05 14:43:16 +00:00
|
|
|
basesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2src_get_caps);
|
|
|
|
basesrc_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2src_set_caps);
|
|
|
|
basesrc_class->start = GST_DEBUG_FUNCPTR (gst_v4l2src_start);
|
|
|
|
basesrc_class->stop = GST_DEBUG_FUNCPTR (gst_v4l2src_stop);
|
|
|
|
basesrc_class->query = GST_DEBUG_FUNCPTR (gst_v4l2src_query);
|
2007-10-13 12:03:44 +00:00
|
|
|
basesrc_class->fixate = GST_DEBUG_FUNCPTR (gst_v4l2src_fixate);
|
2008-06-04 17:39:31 +00:00
|
|
|
basesrc_class->negotiate = GST_DEBUG_FUNCPTR (gst_v4l2src_negotiate);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2007-09-05 14:43:16 +00:00
|
|
|
pushsrc_class->create = GST_DEBUG_FUNCPTR (gst_v4l2src_create);
|
2006-03-11 22:50:03 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
static void
|
2006-03-11 22:50:03 +00:00
|
|
|
gst_v4l2src_init (GstV4l2Src * v4l2src, GstV4l2SrcClass * klass)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
/* fixme: give an update_fps_function */
|
2006-05-19 18:31:25 +00:00
|
|
|
v4l2src->v4l2object = gst_v4l2_object_new (GST_ELEMENT (v4l2src),
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
gst_v4l2_get_input, gst_v4l2_set_input, NULL);
|
2006-05-11 17:59:59 +00:00
|
|
|
|
sys/v4l2/: Fix EIO handing when capturing. Add new property to specify the number of buffers to enque (and remove the...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_set_property),
(gst_v4l2src_get_property), (gst_v4l2src_set_caps):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_deinit):
Fix EIO handing when capturing. Add new property to specify the number of
buffers to enque (and remove the borked num-buffers usage).
2007-01-17 14:30:50 +00:00
|
|
|
/* number of buffers requested */
|
2007-07-18 11:42:33 +00:00
|
|
|
v4l2src->num_buffers = GST_V4L2_MIN_BUFFERS;
|
2002-11-13 12:35:56 +00:00
|
|
|
|
2007-11-15 12:22:10 +00:00
|
|
|
v4l2src->always_copy = DEFAULT_PROP_ALWAYS_COPY;
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
v4l2src->formats = NULL;
|
2003-05-02 21:16:56 +00:00
|
|
|
|
2004-10-24 15:47:40 +00:00
|
|
|
v4l2src->is_capturing = FALSE;
|
2002-11-13 12:35:56 +00:00
|
|
|
|
2006-08-30 13:30:13 +00:00
|
|
|
gst_base_src_set_format (GST_BASE_SRC (v4l2src), GST_FORMAT_TIME);
|
2006-03-11 22:50:03 +00:00
|
|
|
gst_base_src_set_live (GST_BASE_SRC (v4l2src), TRUE);
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
v4l2src->fps_d = 0;
|
|
|
|
v4l2src->fps_n = 0;
|
2002-11-13 12:35:56 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 21:45:57 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_v4l2src_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (object);
|
|
|
|
|
|
|
|
if (v4l2src->formats) {
|
|
|
|
gst_v4l2src_clear_format_list (v4l2src);
|
|
|
|
}
|
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2006-04-13 21:45:57 +00:00
|
|
|
}
|
|
|
|
|
2007-07-17 11:35:29 +00:00
|
|
|
|
Fix a bunch of leaks shown by the newly-added states test.
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flac_enc_finalize):
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_class_init),
(gst_gconf_audio_sink_dispose), (gst_gconf_audio_sink_finalize):
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init),
(gst_gconf_audio_src_class_init), (gst_gconf_audio_src_dispose),
(gst_gconf_audio_src_finalize), (do_toggle_element):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init),
(gst_gconf_video_sink_class_init), (gst_gconf_video_sink_finalize),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init),
(gst_gconf_video_src_class_init), (gst_gconf_video_src_dispose),
(gst_gconf_video_src_finalize), (do_toggle_element):
* ext/gconf/gstswitchsink.c: (gst_switch_sink_class_init),
(gst_switch_sink_reset), (gst_switch_sink_set_child):
* ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init):
* ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init):
* ext/shout2/gstshout2.c: (gst_shout2send_class_init),
(gst_shout2send_init), (gst_shout2send_finalize):
* gst/debug/testplugin.c: (gst_test_class_init),
(gst_test_finalize):
* gst/flx/gstflxdec.c: (gst_flxdec_class_init),
(gst_flxdec_dispose):
* gst/multipart/multipartmux.c: (gst_multipart_mux_finalize):
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize):
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_init),
(gst_rtspsrc_finalize):
* gst/rtsp/rtspextwms.c: (rtsp_ext_wms_free_context):
* gst/rtsp/rtspextwms.h:
* gst/smpte/gstsmpte.c: (gst_smpte_class_init),
(gst_smpte_finalize):
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_finalize):
* gst/udp/gstudpsink.c: (gst_udpsink_class_init),
(gst_udpsink_finalize):
* gst/wavparse/gstwavparse.c: (gst_wavparse_dispose),
(gst_wavparse_sink_activate):
* sys/oss/gstosssink.c: (gst_oss_sink_finalise):
* sys/oss/gstosssrc.c: (gst_oss_src_class_init),
(gst_oss_src_finalize):
* sys/v4l2/gstv4l2object.c: (gst_v4l2_object_destroy):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_finalize):
* sys/ximage/gstximagesrc.c: (gst_ximage_src_ximage_get):
Fix a bunch of leaks shown by the newly-added states test.
2007-03-04 13:52:03 +00:00
|
|
|
static void
|
|
|
|
gst_v4l2src_finalize (GstV4l2Src * v4l2src)
|
|
|
|
{
|
|
|
|
gst_v4l2_object_destroy (v4l2src->v4l2object);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (v4l2src));
|
|
|
|
}
|
2006-04-13 21:45:57 +00:00
|
|
|
|
2007-07-17 11:35:29 +00:00
|
|
|
|
2002-11-13 12:35:56 +00:00
|
|
|
static void
|
2006-03-11 22:50:03 +00:00
|
|
|
gst_v4l2src_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2002-11-13 12:35:56 +00:00
|
|
|
{
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (object);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-05-19 18:31:25 +00:00
|
|
|
if (!gst_v4l2_object_set_property_helper (v4l2src->v4l2object,
|
2006-05-11 17:59:59 +00:00
|
|
|
prop_id, value, pspec)) {
|
|
|
|
switch (prop_id) {
|
sys/v4l2/: Fix EIO handing when capturing. Add new property to specify the number of buffers to enque (and remove the...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_set_property),
(gst_v4l2src_get_property), (gst_v4l2src_set_caps):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_deinit):
Fix EIO handing when capturing. Add new property to specify the number of
buffers to enque (and remove the borked num-buffers usage).
2007-01-17 14:30:50 +00:00
|
|
|
case PROP_QUEUE_SIZE:
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
v4l2src->num_buffers = g_value_get_uint (value);
|
sys/v4l2/: Fix EIO handing when capturing. Add new property to specify the number of buffers to enque (and remove the...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_set_property),
(gst_v4l2src_get_property), (gst_v4l2src_set_caps):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_deinit):
Fix EIO handing when capturing. Add new property to specify the number of
buffers to enque (and remove the borked num-buffers usage).
2007-01-17 14:30:50 +00:00
|
|
|
break;
|
2007-11-15 12:22:10 +00:00
|
|
|
case PROP_ALWAYS_COPY:
|
|
|
|
v4l2src->always_copy = g_value_get_boolean (value);
|
|
|
|
break;
|
2006-05-11 17:59:59 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2006-03-11 22:50:03 +00:00
|
|
|
}
|
2002-09-16 21:01:43 +00:00
|
|
|
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static void
|
|
|
|
gst_v4l2src_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-05-19 18:31:25 +00:00
|
|
|
if (!gst_v4l2_object_get_property_helper (v4l2src->v4l2object,
|
2006-05-11 17:59:59 +00:00
|
|
|
prop_id, value, pspec)) {
|
|
|
|
switch (prop_id) {
|
sys/v4l2/: Fix EIO handing when capturing. Add new property to specify the number of buffers to enque (and remove the...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_set_property),
(gst_v4l2src_get_property), (gst_v4l2src_set_caps):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_deinit):
Fix EIO handing when capturing. Add new property to specify the number of
buffers to enque (and remove the borked num-buffers usage).
2007-01-17 14:30:50 +00:00
|
|
|
case PROP_QUEUE_SIZE:
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
g_value_set_uint (value, v4l2src->num_buffers);
|
sys/v4l2/: Fix EIO handing when capturing. Add new property to specify the number of buffers to enque (and remove the...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_set_property),
(gst_v4l2src_get_property), (gst_v4l2src_set_caps):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_deinit):
Fix EIO handing when capturing. Add new property to specify the number of
buffers to enque (and remove the borked num-buffers usage).
2007-01-17 14:30:50 +00:00
|
|
|
break;
|
2007-11-15 12:22:10 +00:00
|
|
|
case PROP_ALWAYS_COPY:
|
|
|
|
g_value_set_boolean (value, v4l2src->always_copy);
|
|
|
|
break;
|
2006-05-11 17:59:59 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2002-09-16 21:01:43 +00:00
|
|
|
}
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
/* this function is a bit of a last resort */
|
|
|
|
static void
|
2007-10-13 12:03:44 +00:00
|
|
|
gst_v4l2src_fixate (GstBaseSrc * basesrc, 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
|
|
|
{
|
2006-03-11 22:50:03 +00:00
|
|
|
GstStructure *structure;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
gint i;
|
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
|
|
|
|
2007-10-13 12:03:44 +00:00
|
|
|
GST_DEBUG_OBJECT (basesrc, "fixating caps %" GST_PTR_FORMAT, 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
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
for (i = 0; i < gst_caps_get_size (caps); ++i) {
|
|
|
|
const GValue *v;
|
|
|
|
|
2008-07-08 12:51:34 +00:00
|
|
|
structure = gst_caps_get_structure (caps, i);
|
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
/* FIXME such sizes? we usually fixate to something in the 320x200
|
|
|
|
* range... */
|
2006-09-27 15:14:07 +00:00
|
|
|
/* We are fixating to greater possble size (limited to GST_V4L2_MAX_SIZE)
|
2008-06-04 17:39:31 +00:00
|
|
|
and the maximum framerate resolution for that size */
|
2006-09-27 15:14:07 +00:00
|
|
|
gst_structure_fixate_field_nearest_int (structure, "width",
|
|
|
|
GST_V4L2_MAX_SIZE);
|
|
|
|
gst_structure_fixate_field_nearest_int (structure, "height",
|
|
|
|
GST_V4L2_MAX_SIZE);
|
2008-06-04 17:39:31 +00:00
|
|
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate",
|
|
|
|
G_MAXINT, 1);
|
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
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
v = gst_structure_get_value (structure, "format");
|
|
|
|
if (v && G_VALUE_TYPE (v) != GST_TYPE_FOURCC) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2008-06-04 17:39:31 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, 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
|
|
|
}
|
|
|
|
|
2008-06-04 17:39:31 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_negotiate (GstBaseSrc * basesrc)
|
|
|
|
{
|
|
|
|
GstCaps *thiscaps;
|
|
|
|
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
|
|
|
GstCaps *peercaps = NULL;
|
|
|
|
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
|
|
|
/* first see what is possible on our source pad */
|
|
|
|
thiscaps = gst_pad_get_caps (GST_BASE_SRC_PAD (basesrc));
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps);
|
|
|
|
/* nothing or anything is allowed, we're done */
|
|
|
|
if (thiscaps == NULL || gst_caps_is_any (thiscaps))
|
|
|
|
goto no_nego_needed;
|
|
|
|
|
|
|
|
/* get the peer caps */
|
|
|
|
peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc));
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps);
|
|
|
|
if (peercaps && !gst_caps_is_any (peercaps)) {
|
2008-07-17 13:54:38 +00:00
|
|
|
GstCaps *icaps = NULL;
|
2008-06-04 17:39:31 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Prefer the first caps we are compatible with that the peer proposed */
|
|
|
|
for (i = 0; i < gst_caps_get_size (peercaps); i++) {
|
|
|
|
/* get intersection */
|
|
|
|
GstCaps *ipcaps = gst_caps_copy_nth (peercaps, i);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "peer: %" GST_PTR_FORMAT, ipcaps);
|
|
|
|
|
|
|
|
icaps = gst_caps_intersect (thiscaps, ipcaps);
|
|
|
|
gst_caps_unref (ipcaps);
|
|
|
|
|
|
|
|
if (!gst_caps_is_empty (icaps))
|
|
|
|
break;
|
|
|
|
|
|
|
|
gst_caps_unref (icaps);
|
|
|
|
icaps = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "intersect: %" GST_PTR_FORMAT, icaps);
|
|
|
|
if (icaps) {
|
2008-06-09 08:52:04 +00:00
|
|
|
/* If there are multiple intersections pick the one with the smallest
|
|
|
|
* resolution strictly bigger then the first peer caps */
|
|
|
|
if (gst_caps_get_size (icaps) > 1) {
|
|
|
|
GstStructure *s = gst_caps_get_structure (peercaps, 0);
|
|
|
|
|
|
|
|
int best = 0;
|
|
|
|
|
|
|
|
int twidth, theight;
|
|
|
|
|
|
|
|
int width = G_MAXINT, height = G_MAXINT;
|
|
|
|
|
|
|
|
if (gst_structure_get_int (s, "width", &twidth)
|
|
|
|
&& gst_structure_get_int (s, "height", &theight)) {
|
|
|
|
|
|
|
|
/* Walk the structure backwards to get the first entry of the
|
|
|
|
* smallest resolution bigger (or equal to) the preferred resolution)
|
|
|
|
*/
|
|
|
|
for (i = gst_caps_get_size (icaps) - 1; i >= 0; i--) {
|
|
|
|
GstStructure *is = gst_caps_get_structure (icaps, i);
|
|
|
|
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
if (gst_structure_get_int (is, "width", &w)
|
|
|
|
&& gst_structure_get_int (is, "height", &h)) {
|
|
|
|
if (w >= twidth && w <= width && h >= theight && h <= height) {
|
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
best = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
caps = gst_caps_copy_nth (icaps, best);
|
|
|
|
gst_caps_unref (icaps);
|
|
|
|
} else {
|
|
|
|
caps = icaps;
|
|
|
|
}
|
2008-06-04 17:39:31 +00:00
|
|
|
}
|
2008-06-09 08:52:04 +00:00
|
|
|
gst_caps_unref (thiscaps);
|
|
|
|
gst_caps_unref (peercaps);
|
2008-06-04 17:39:31 +00:00
|
|
|
} else {
|
|
|
|
/* no peer or peer have ANY caps, work with our own caps then */
|
|
|
|
caps = thiscaps;
|
|
|
|
}
|
|
|
|
if (caps) {
|
|
|
|
caps = gst_caps_make_writable (caps);
|
|
|
|
gst_caps_truncate (caps);
|
|
|
|
|
|
|
|
/* now fixate */
|
|
|
|
if (!gst_caps_is_empty (caps)) {
|
|
|
|
gst_pad_fixate_caps (GST_BASE_SRC_PAD (basesrc), caps);
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps);
|
|
|
|
|
|
|
|
if (gst_caps_is_any (caps)) {
|
|
|
|
/* hmm, still anything, so element can do anything and
|
|
|
|
* nego is not needed */
|
|
|
|
result = TRUE;
|
|
|
|
} else if (gst_caps_is_fixed (caps)) {
|
|
|
|
/* yay, fixed caps, use those then */
|
|
|
|
gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), caps);
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
|
|
|
|
no_nego_needed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "no negotiation needed");
|
|
|
|
if (thiscaps)
|
|
|
|
gst_caps_unref (thiscaps);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStructure *
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
gst_v4l2src_v4l2fourcc_to_structure (guint32 fourcc)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2004-01-12 02:19:57 +00:00
|
|
|
GstStructure *structure = NULL;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2007-02-12 12:57:22 +00:00
|
|
|
/* FIXME: new FourCCs
|
|
|
|
camera: ZC0301 PC Camera
|
|
|
|
driver: zc0301
|
|
|
|
BA81, S910, PWC1, PWC2
|
|
|
|
|
|
|
|
camera:
|
|
|
|
driver:
|
|
|
|
*/
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
switch (fourcc) {
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
|
|
|
|
case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
|
2004-10-24 15:47:40 +00:00
|
|
|
structure = gst_structure_new ("image/jpeg", NULL);
|
2004-01-12 02:19:57 +00:00
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_RGB332:
|
|
|
|
case V4L2_PIX_FMT_RGB555:
|
|
|
|
case V4L2_PIX_FMT_RGB555X:
|
|
|
|
case V4L2_PIX_FMT_RGB565:
|
|
|
|
case V4L2_PIX_FMT_RGB565X:
|
|
|
|
case V4L2_PIX_FMT_RGB24:
|
|
|
|
case V4L2_PIX_FMT_BGR24:
|
|
|
|
case V4L2_PIX_FMT_RGB32:
|
2004-03-14 22:34:33 +00:00
|
|
|
case V4L2_PIX_FMT_BGR32:{
|
|
|
|
guint depth = 0, bpp = 0;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
gint endianness = 0;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
guint32 r_mask = 0, b_mask = 0, g_mask = 0;
|
|
|
|
|
|
|
|
switch (fourcc) {
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_RGB332:
|
|
|
|
bpp = depth = 8;
|
|
|
|
endianness = G_BYTE_ORDER; /* 'like, whatever' */
|
|
|
|
r_mask = 0xe0;
|
|
|
|
g_mask = 0x1c;
|
|
|
|
b_mask = 0x03;
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_RGB555:
|
|
|
|
case V4L2_PIX_FMT_RGB555X:
|
|
|
|
bpp = 16;
|
|
|
|
depth = 15;
|
|
|
|
endianness =
|
|
|
|
fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
|
|
|
|
r_mask = 0x7c00;
|
|
|
|
g_mask = 0x03e0;
|
|
|
|
b_mask = 0x001f;
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_RGB565:
|
|
|
|
case V4L2_PIX_FMT_RGB565X:
|
|
|
|
bpp = depth = 16;
|
|
|
|
endianness =
|
|
|
|
fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
|
|
|
|
r_mask = 0xf800;
|
|
|
|
g_mask = 0x07e0;
|
|
|
|
b_mask = 0x001f;
|
2004-05-07 23:47:00 +00:00
|
|
|
break;
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_RGB24:
|
|
|
|
bpp = depth = 24;
|
|
|
|
endianness = G_BIG_ENDIAN;
|
|
|
|
r_mask = 0xff0000;
|
|
|
|
g_mask = 0x00ff00;
|
|
|
|
b_mask = 0x0000ff;
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_BGR24:
|
|
|
|
bpp = depth = 24;
|
|
|
|
endianness = G_BIG_ENDIAN;
|
|
|
|
r_mask = 0x0000ff;
|
|
|
|
g_mask = 0x00ff00;
|
|
|
|
b_mask = 0xff0000;
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_RGB32:
|
|
|
|
bpp = depth = 32;
|
|
|
|
endianness = G_BIG_ENDIAN;
|
|
|
|
r_mask = 0xff000000;
|
|
|
|
g_mask = 0x00ff0000;
|
|
|
|
b_mask = 0x0000ff00;
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_BGR32:
|
|
|
|
bpp = depth = 32;
|
|
|
|
endianness = G_BIG_ENDIAN;
|
|
|
|
r_mask = 0x000000ff;
|
|
|
|
g_mask = 0x0000ff00;
|
|
|
|
b_mask = 0x00ff0000;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2004-01-12 02:19:57 +00:00
|
|
|
}
|
|
|
|
structure = gst_structure_new ("video/x-raw-rgb",
|
2004-03-15 19:32:27 +00:00
|
|
|
"bpp", G_TYPE_INT, bpp,
|
|
|
|
"depth", G_TYPE_INT, depth,
|
|
|
|
"red_mask", G_TYPE_INT, r_mask,
|
|
|
|
"green_mask", G_TYPE_INT, g_mask,
|
|
|
|
"blue_mask", G_TYPE_INT, b_mask,
|
|
|
|
"endianness", G_TYPE_INT, endianness, NULL);
|
2004-01-12 02:19:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
|
|
|
|
case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
|
|
|
|
case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
|
2004-01-12 02:19:57 +00:00
|
|
|
/* FIXME: get correct fourccs here */
|
|
|
|
break;
|
2008-05-26 14:52:51 +00:00
|
|
|
case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
|
|
|
|
case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
|
2004-01-12 02:19:57 +00:00
|
|
|
case V4L2_PIX_FMT_YVU410:
|
|
|
|
case V4L2_PIX_FMT_YUV410:
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
|
2004-01-12 02:19:57 +00:00
|
|
|
case V4L2_PIX_FMT_YUYV:
|
|
|
|
case V4L2_PIX_FMT_YVU420:
|
|
|
|
case V4L2_PIX_FMT_UYVY:
|
2004-04-10 12:20:20 +00:00
|
|
|
case V4L2_PIX_FMT_Y41P:
|
|
|
|
case V4L2_PIX_FMT_YUV422P:
|
|
|
|
case V4L2_PIX_FMT_YUV411P:{
|
2004-01-12 02:19:57 +00:00
|
|
|
guint32 fcc = 0;
|
|
|
|
|
|
|
|
switch (fourcc) {
|
2008-05-26 14:52:51 +00:00
|
|
|
case V4L2_PIX_FMT_NV12:
|
|
|
|
fcc = GST_MAKE_FOURCC ('N', 'V', '1', '2');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_NV21:
|
|
|
|
fcc = GST_MAKE_FOURCC ('N', 'V', '2', '1');
|
|
|
|
break;
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_YVU410:
|
|
|
|
fcc = GST_MAKE_FOURCC ('Y', 'V', 'U', '9');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_YUV410:
|
|
|
|
fcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_YUV420:
|
|
|
|
fcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_YUYV:
|
|
|
|
fcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_YVU420:
|
|
|
|
fcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_UYVY:
|
|
|
|
fcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_Y41P:
|
2004-04-10 12:20:20 +00:00
|
|
|
fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'P');
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_YUV411P:
|
2004-03-15 19:32:27 +00:00
|
|
|
fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
|
|
|
|
break;
|
2004-04-10 12:20:20 +00:00
|
|
|
case V4L2_PIX_FMT_YUV422P:
|
|
|
|
fcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
|
|
|
|
break;
|
2004-03-15 19:32:27 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2004-01-12 02:19:57 +00:00
|
|
|
}
|
|
|
|
structure = gst_structure_new ("video/x-raw-yuv",
|
2004-03-15 19:32:27 +00:00
|
|
|
"format", GST_TYPE_FOURCC, fcc, NULL);
|
2004-01-12 02:19:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case V4L2_PIX_FMT_DV:
|
2004-03-14 22:34:33 +00:00
|
|
|
structure =
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_structure_new ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE,
|
|
|
|
NULL);
|
2004-01-12 02:19:57 +00:00
|
|
|
break;
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_MPEG: /* MPEG */
|
2004-01-12 02:19:57 +00:00
|
|
|
/* someone figure out the MPEG format used... */
|
|
|
|
break;
|
2004-03-15 19:32:27 +00:00
|
|
|
case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
|
2004-01-12 02:19:57 +00:00
|
|
|
break;
|
2007-05-15 02:56:23 +00:00
|
|
|
case V4L2_PIX_FMT_SBGGR8:
|
|
|
|
structure = gst_structure_new ("video/x-raw-bayer", NULL);
|
|
|
|
break;
|
2004-01-12 02:19:57 +00:00
|
|
|
default:
|
2006-05-08 19:21:18 +00:00
|
|
|
GST_DEBUG ("Unknown fourcc 0x%08x %" GST_FOURCC_FORMAT,
|
2004-03-15 19:32:27 +00:00
|
|
|
fourcc, GST_FOURCC_ARGS (fourcc));
|
2004-01-12 02:19:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
return structure;
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static struct v4l2_fmtdesc *
|
|
|
|
gst_v4l2src_get_format_from_fourcc (GstV4l2Src * v4l2src, guint32 fourcc)
|
|
|
|
{
|
|
|
|
struct v4l2_fmtdesc *fmt;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
GSList *walk;
|
|
|
|
|
|
|
|
if (fourcc == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
walk = v4l2src->formats;
|
|
|
|
while (walk) {
|
|
|
|
fmt = (struct v4l2_fmtdesc *) walk->data;
|
|
|
|
if (fmt->pixelformat == fourcc)
|
|
|
|
return fmt;
|
|
|
|
/* special case for jpeg */
|
|
|
|
if ((fmt->pixelformat == V4L2_PIX_FMT_MJPEG && fourcc == V4L2_PIX_FMT_JPEG)
|
|
|
|
|| (fmt->pixelformat == V4L2_PIX_FMT_JPEG
|
|
|
|
&& fourcc == V4L2_PIX_FMT_MJPEG)) {
|
|
|
|
return fmt;
|
|
|
|
}
|
|
|
|
walk = g_slist_next (walk);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps *
|
2004-01-12 02:19:57 +00:00
|
|
|
gst_v4l2src_get_all_caps (void)
|
|
|
|
{
|
|
|
|
static GstCaps *caps = NULL;
|
|
|
|
|
|
|
|
if (caps == NULL) {
|
|
|
|
GstStructure *structure;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
caps = gst_caps_new_empty ();
|
|
|
|
for (i = 0; i < GST_V4L2_FORMAT_COUNT; i++) {
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
structure = gst_v4l2src_v4l2fourcc_to_structure (gst_v4l2_formats[i]);
|
2004-01-12 02:19:57 +00:00
|
|
|
if (structure) {
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_structure_set (structure,
|
2006-09-27 15:14:07 +00:00
|
|
|
"width", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,
|
|
|
|
"height", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,
|
2006-09-28 17:08:47 +00:00
|
|
|
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 100, 1, NULL);
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_caps_append_structure (caps, structure);
|
2004-01-12 02:19:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
return caps;
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
static GstCaps *
|
2006-03-11 22:50:03 +00:00
|
|
|
gst_v4l2src_get_caps (GstBaseSrc * src)
|
2002-09-20 09:28:46 +00:00
|
|
|
{
|
2006-03-11 22:50:03 +00:00
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
GstCaps *ret;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
GSList *walk;
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2src->v4l2object)) {
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
/* FIXME: copy? */
|
2006-03-11 22:50:03 +00:00
|
|
|
return
|
|
|
|
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
|
|
|
|
(v4l2src)));
|
2004-01-12 02:19:57 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
if (v4l2src->probed_caps)
|
|
|
|
return gst_caps_ref (v4l2src->probed_caps);
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
if (!v4l2src->formats)
|
|
|
|
gst_v4l2src_fill_format_list (v4l2src);
|
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
ret = gst_caps_new_empty ();
|
|
|
|
|
|
|
|
for (walk = v4l2src->formats; walk; walk = walk->next) {
|
|
|
|
struct v4l2_fmtdesc *format;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
GstStructure *template;
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
format = (struct v4l2_fmtdesc *) walk->data;
|
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
template = gst_v4l2src_v4l2fourcc_to_structure (format->pixelformat);
|
|
|
|
|
|
|
|
if (template) {
|
|
|
|
GstCaps *tmp;
|
|
|
|
|
|
|
|
tmp = gst_v4l2src_probe_caps_for_format (v4l2src, format->pixelformat,
|
|
|
|
template);
|
|
|
|
if (tmp)
|
|
|
|
gst_caps_append (ret, tmp);
|
|
|
|
|
|
|
|
gst_structure_free (template);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (v4l2src, "unknown format %u", format->pixelformat);
|
2004-01-12 02:19:57 +00:00
|
|
|
}
|
|
|
|
}
|
2002-09-20 09:28:46 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
v4l2src->probed_caps = gst_caps_ref (ret);
|
|
|
|
|
2007-10-13 12:03:44 +00:00
|
|
|
GST_INFO_OBJECT (v4l2src, "probed caps: %" GST_PTR_FORMAT, ret);
|
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
return ret;
|
2002-09-20 09:28:46 +00:00
|
|
|
}
|
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
/* collect data for the given caps
|
|
|
|
* @caps: given input caps
|
|
|
|
* @format: location for the v4l format
|
|
|
|
* @w/@h: location for width and height
|
|
|
|
* @fps_n/@fps_d: location for framerate
|
|
|
|
* @size: location for expected size of the frame or 0 if unknown
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
gst_v4l2_get_caps_info (GstV4l2Src * v4l2src, GstCaps * caps,
|
|
|
|
struct v4l2_fmtdesc **format, gint * w, gint * h, guint * fps_n,
|
|
|
|
guint * fps_d, guint * size)
|
|
|
|
{
|
|
|
|
GstStructure *structure;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
const GValue *framerate;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
guint32 fourcc;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
const gchar *mimetype;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
guint outsize;
|
|
|
|
|
|
|
|
/* default unknown values */
|
|
|
|
fourcc = 0;
|
|
|
|
outsize = 0;
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
if (!gst_structure_get_int (structure, "width", w))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!gst_structure_get_int (structure, "height", h))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
framerate = gst_structure_get_value (structure, "framerate");
|
|
|
|
if (!framerate)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*fps_n = gst_value_get_fraction_numerator (framerate);
|
|
|
|
*fps_d = gst_value_get_fraction_denominator (framerate);
|
|
|
|
|
|
|
|
mimetype = gst_structure_get_name (structure);
|
|
|
|
|
|
|
|
if (!strcmp (mimetype, "video/x-raw-yuv")) {
|
|
|
|
gst_structure_get_fourcc (structure, "format", &fourcc);
|
|
|
|
|
|
|
|
switch (fourcc) {
|
|
|
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
|
|
|
case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'):
|
|
|
|
fourcc = V4L2_PIX_FMT_YUV420;
|
|
|
|
outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
|
|
|
|
outsize += 2 * ((GST_ROUND_UP_8 (*w) / 2) * (GST_ROUND_UP_2 (*h) / 2));
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
|
|
|
|
fourcc = V4L2_PIX_FMT_YUYV;
|
|
|
|
outsize = (GST_ROUND_UP_2 (*w) * 2) * *h;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
|
|
|
|
fourcc = V4L2_PIX_FMT_Y41P;
|
|
|
|
outsize = (GST_ROUND_UP_2 (*w) * 2) * *h;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
|
|
|
|
fourcc = V4L2_PIX_FMT_UYVY;
|
|
|
|
outsize = (GST_ROUND_UP_2 (*w) * 2) * *h;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
|
|
|
|
fourcc = V4L2_PIX_FMT_YVU420;
|
|
|
|
outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
|
|
|
|
outsize += 2 * ((GST_ROUND_UP_8 (*w) / 2) * (GST_ROUND_UP_2 (*h) / 2));
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
|
|
|
|
fourcc = V4L2_PIX_FMT_YUV411P;
|
|
|
|
outsize = GST_ROUND_UP_4 (*w) * *h;
|
|
|
|
outsize += 2 * ((GST_ROUND_UP_8 (*w) / 4) * *h);
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
|
|
|
|
fourcc = V4L2_PIX_FMT_YUV422P;
|
|
|
|
outsize = GST_ROUND_UP_4 (*w) * *h;
|
|
|
|
outsize += 2 * ((GST_ROUND_UP_8 (*w) / 2) * *h);
|
|
|
|
break;
|
2008-05-26 14:52:51 +00:00
|
|
|
case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
|
|
|
|
fourcc = V4L2_PIX_FMT_NV12;
|
|
|
|
outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
|
|
|
|
outsize += (GST_ROUND_UP_4 (*w) * *h) / 2;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
|
|
|
|
fourcc = V4L2_PIX_FMT_NV21;
|
|
|
|
outsize = GST_ROUND_UP_4 (*w) * GST_ROUND_UP_2 (*h);
|
|
|
|
outsize += (GST_ROUND_UP_4 (*w) * *h) / 2;
|
|
|
|
break;
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
}
|
|
|
|
} else if (!strcmp (mimetype, "video/x-raw-rgb")) {
|
|
|
|
gint depth, endianness, r_mask;
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "depth", &depth);
|
|
|
|
gst_structure_get_int (structure, "endianness", &endianness);
|
|
|
|
gst_structure_get_int (structure, "red_mask", &r_mask);
|
|
|
|
|
|
|
|
switch (depth) {
|
|
|
|
case 8:
|
|
|
|
fourcc = V4L2_PIX_FMT_RGB332;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
fourcc = (endianness == G_LITTLE_ENDIAN) ?
|
|
|
|
V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
fourcc = (endianness == G_LITTLE_ENDIAN) ?
|
|
|
|
V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR24 : V4L2_PIX_FMT_RGB24;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR32 : V4L2_PIX_FMT_RGB32;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (strcmp (mimetype, "video/x-dv") == 0) {
|
|
|
|
fourcc = V4L2_PIX_FMT_DV;
|
|
|
|
} else if (strcmp (mimetype, "image/jpeg") == 0) {
|
|
|
|
fourcc = V4L2_PIX_FMT_JPEG;
|
2008-05-26 14:52:51 +00:00
|
|
|
} else if (strcmp (mimetype, "video/x-raw-bayer") == 0) {
|
|
|
|
fourcc = V4L2_PIX_FMT_SBGGR8;
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fourcc == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*format = gst_v4l2src_get_format_from_fourcc (v4l2src, fourcc);
|
|
|
|
*size = outsize;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2004-01-12 02:19:57 +00:00
|
|
|
GstV4l2Src *v4l2src;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-11-01 19:48:26 +00:00
|
|
|
gint w = 0, h = 0;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
struct v4l2_fmtdesc *format;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-08-29 20:59:47 +00:00
|
|
|
guint fps_n, fps_d;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
guint size;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
v4l2src = GST_V4L2SRC (src);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
/* if we're not open, punt -- we'll get setcaps'd later via negotiate */
|
2006-05-11 17:59:59 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (v4l2src->v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* make sure we stop capturing and dealloc buffers */
|
2006-05-11 17:59:59 +00:00
|
|
|
if (GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)) {
|
sys/v4l2/: Fix EIO handing when capturing. Add new property to specify the number of buffers to enque (and remove the...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
(gst_v4l2_object_install_properties_helper),
(gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_set_property),
(gst_v4l2src_get_property), (gst_v4l2src_set_caps):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_grab_frame), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_deinit):
Fix EIO handing when capturing. Add new property to specify the number of
buffers to enque (and remove the borked num-buffers usage).
2007-01-17 14:30:50 +00:00
|
|
|
/* both will throw an element-error on failure */
|
2006-03-11 22:50:03 +00:00
|
|
|
if (!gst_v4l2src_capture_stop (v4l2src))
|
|
|
|
return FALSE;
|
|
|
|
if (!gst_v4l2src_capture_deinit (v4l2src))
|
|
|
|
return FALSE;
|
2004-01-12 02:19:57 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
/* we want our own v4l2 type of fourcc codes */
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
if (!gst_v4l2_get_caps_info (v4l2src, caps, &format, &w, &h, &fps_n, &fps_d,
|
|
|
|
&size)) {
|
|
|
|
GST_DEBUG_OBJECT (v4l2src,
|
|
|
|
"can't get capture format from caps %" GST_PTR_FORMAT, caps);
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
GST_DEBUG_OBJECT (v4l2src, "trying to set_capture %dx%d at %d/%d fps, "
|
|
|
|
"format %s", w, h, fps_n, fps_d, format->description);
|
2006-08-29 20:59:47 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
if (!gst_v4l2src_set_capture (v4l2src, format->pixelformat, w, h, fps_n,
|
|
|
|
fps_d))
|
|
|
|
/* error already posted */
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2006-08-24 00:40:07 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize) (gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
Original commit message from CVS:
2007-06-12 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize)
(gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
(gst_v4l2_buffer_new): Behave more like ximagesink's buffers, with
finalization and resuscitation. No longer public.
(gst_v4l2_buffer_pool_finalize, gst_v4l2_buffer_pool_init)
(gst_v4l2_buffer_pool_class_init, gst_v4l2_buffer_pool_get_type)
(gst_v4l2_buffer_pool_new, gst_v4l2_buffer_pool_activate)
(gst_v4l2_buffer_pool_destroy): Make the pool follow common
miniobject semantics, and be threadsafe.
(gst_v4l2src_queue_frame): Remove this function, as we just call
the ioctls directly in the two places where we queue buffers.
(gst_v4l2src_grab_frame): Return a flowreturn and fill the buffer
directly.
(gst_v4l2src_capture_init): Use the new buffer_pool_new function
to allocate the pool, which also preallocates the GstBuffers.
(gst_v4l2src_capture_start): Call buffer_pool_activate instead of
queueing the frames directly.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2BufferPool): Make this a
real MiniObject instead of rolling our own refcounting and
finalizing. Give it a lock.
(struct _GstV4l2Buffer): Remove one intermediary object, having
the buffers hold the struct v4l2_buffer directly.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_set_caps): Pass the caps to
capture_init so that it can set them on the buffers that it will
create.
(gst_v4l2src_get_read): For better or for worse, include the
timestamping and offsetting code here; really we should be using
bufferalloc though.
(gst_v4l2src_get_mmap): Just make grab_frame return one of our
preallocated, mmap'd buffers.
2007-06-12 11:23:01 +00:00
|
|
|
if (!gst_v4l2src_capture_init (v4l2src, caps))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!gst_v4l2src_capture_start (v4l2src))
|
|
|
|
return FALSE;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
/* now store the expected output size */
|
|
|
|
v4l2src->frame_byte_size = size;
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
return TRUE;
|
2004-01-12 02:19:57 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2007-09-05 14:43:16 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstV4l2Src *src;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2007-09-05 14:43:16 +00:00
|
|
|
gboolean res = FALSE;
|
|
|
|
|
|
|
|
src = GST_V4L2SRC (bsrc);
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_LATENCY:{
|
|
|
|
GstClockTime min_latency, max_latency;
|
|
|
|
|
|
|
|
/* device must be open */
|
2008-08-12 12:04:24 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (src->v4l2object)) {
|
|
|
|
GST_WARNING_OBJECT (src,
|
|
|
|
"Can't give latency since device isn't open !");
|
2007-09-05 14:43:16 +00:00
|
|
|
goto done;
|
2008-08-12 12:04:24 +00:00
|
|
|
}
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
/* we must have a framerate */
|
2008-08-12 12:04:24 +00:00
|
|
|
if (src->fps_n <= 0 || src->fps_d <= 0) {
|
|
|
|
GST_WARNING_OBJECT (src,
|
|
|
|
"Can't give latency since framerate isn't fixated !");
|
2007-09-05 14:43:16 +00:00
|
|
|
goto done;
|
2008-08-12 12:04:24 +00:00
|
|
|
}
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
/* min latency is the time to capture one frame */
|
|
|
|
min_latency =
|
|
|
|
gst_util_uint64_scale_int (GST_SECOND, src->fps_d, src->fps_n);
|
|
|
|
|
|
|
|
/* max latency is total duration of the frame buffer */
|
2008-08-13 08:33:57 +00:00
|
|
|
max_latency = src->num_buffers * min_latency;
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
/* start and stop are not symmetric -- start will open the device, but not start
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2006-03-11 22:50:03 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_start (GstBaseSrc * src)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2006-03-11 22:50:03 +00:00
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2007-06-05 14:17:25 +00:00
|
|
|
/* open the device */
|
2006-05-19 18:31:25 +00:00
|
|
|
if (!gst_v4l2_object_start (v4l2src->v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
v4l2src->offset = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_stop (GstBaseSrc * src)
|
|
|
|
{
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (GST_V4L2_IS_ACTIVE (v4l2src->v4l2object)
|
|
|
|
&& !gst_v4l2src_capture_stop (v4l2src))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
if (v4l2src->v4l2object->buffer != NULL) {
|
2006-03-11 22:50:03 +00:00
|
|
|
if (!gst_v4l2src_capture_deinit (v4l2src))
|
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2007-06-05 14:17:25 +00:00
|
|
|
/* close the device */
|
2006-05-19 18:31:25 +00:00
|
|
|
if (!gst_v4l2_object_stop (v4l2src->v4l2object))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2007-09-05 14:43:16 +00:00
|
|
|
v4l2src->fps_d = 0;
|
|
|
|
v4l2src->fps_n = 0;
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_v4l2src_get_read (GstV4l2Src * v4l2src, GstBuffer ** buf)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
2006-03-11 22:50:03 +00:00
|
|
|
gint amount;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
gint buffersize;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
buffersize = v4l2src->frame_byte_size;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize) (gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
Original commit message from CVS:
2007-06-12 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize)
(gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
(gst_v4l2_buffer_new): Behave more like ximagesink's buffers, with
finalization and resuscitation. No longer public.
(gst_v4l2_buffer_pool_finalize, gst_v4l2_buffer_pool_init)
(gst_v4l2_buffer_pool_class_init, gst_v4l2_buffer_pool_get_type)
(gst_v4l2_buffer_pool_new, gst_v4l2_buffer_pool_activate)
(gst_v4l2_buffer_pool_destroy): Make the pool follow common
miniobject semantics, and be threadsafe.
(gst_v4l2src_queue_frame): Remove this function, as we just call
the ioctls directly in the two places where we queue buffers.
(gst_v4l2src_grab_frame): Return a flowreturn and fill the buffer
directly.
(gst_v4l2src_capture_init): Use the new buffer_pool_new function
to allocate the pool, which also preallocates the GstBuffers.
(gst_v4l2src_capture_start): Call buffer_pool_activate instead of
queueing the frames directly.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2BufferPool): Make this a
real MiniObject instead of rolling our own refcounting and
finalizing. Give it a lock.
(struct _GstV4l2Buffer): Remove one intermediary object, having
the buffers hold the struct v4l2_buffer directly.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_set_caps): Pass the caps to
capture_init so that it can set them on the buffers that it will
create.
(gst_v4l2src_get_read): For better or for worse, include the
timestamping and offsetting code here; really we should be using
bufferalloc though.
(gst_v4l2src_get_mmap): Just make grab_frame return one of our
preallocated, mmap'd buffers.
2007-06-12 11:23:01 +00:00
|
|
|
*buf = gst_buffer_new_and_alloc (buffersize);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
do {
|
2006-03-11 22:50:03 +00:00
|
|
|
amount =
|
2006-05-11 17:59:59 +00:00
|
|
|
read (v4l2src->v4l2object->video_fd, GST_BUFFER_DATA (*buf),
|
2006-03-11 22:50:03 +00:00
|
|
|
buffersize);
|
|
|
|
if (amount == buffersize) {
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
2006-03-11 22:50:03 +00:00
|
|
|
} else if (amount == -1) {
|
|
|
|
if (errno == EAGAIN || errno == EINTR) {
|
|
|
|
continue;
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
} else
|
|
|
|
goto read_error;
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
} else {
|
|
|
|
/* short reads can happen if a signal interrupts the read */
|
|
|
|
continue;
|
|
|
|
}
|
2006-03-11 22:50:03 +00:00
|
|
|
} while (TRUE);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize) (gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
Original commit message from CVS:
2007-06-12 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize)
(gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
(gst_v4l2_buffer_new): Behave more like ximagesink's buffers, with
finalization and resuscitation. No longer public.
(gst_v4l2_buffer_pool_finalize, gst_v4l2_buffer_pool_init)
(gst_v4l2_buffer_pool_class_init, gst_v4l2_buffer_pool_get_type)
(gst_v4l2_buffer_pool_new, gst_v4l2_buffer_pool_activate)
(gst_v4l2_buffer_pool_destroy): Make the pool follow common
miniobject semantics, and be threadsafe.
(gst_v4l2src_queue_frame): Remove this function, as we just call
the ioctls directly in the two places where we queue buffers.
(gst_v4l2src_grab_frame): Return a flowreturn and fill the buffer
directly.
(gst_v4l2src_capture_init): Use the new buffer_pool_new function
to allocate the pool, which also preallocates the GstBuffers.
(gst_v4l2src_capture_start): Call buffer_pool_activate instead of
queueing the frames directly.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2BufferPool): Make this a
real MiniObject instead of rolling our own refcounting and
finalizing. Give it a lock.
(struct _GstV4l2Buffer): Remove one intermediary object, having
the buffers hold the struct v4l2_buffer directly.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_set_caps): Pass the caps to
capture_init so that it can set them on the buffers that it will
create.
(gst_v4l2src_get_read): For better or for worse, include the
timestamping and offsetting code here; really we should be using
bufferalloc though.
(gst_v4l2src_get_mmap): Just make grab_frame return one of our
preallocated, mmap'd buffers.
2007-06-12 11:23:01 +00:00
|
|
|
GST_BUFFER_OFFSET (*buf) = v4l2src->offset++;
|
|
|
|
GST_BUFFER_OFFSET_END (*buf) = v4l2src->offset;
|
|
|
|
/* timestamps, LOCK to get clock and base time. */
|
|
|
|
{
|
|
|
|
GstClock *clock;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize) (gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
Original commit message from CVS:
2007-06-12 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize)
(gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
(gst_v4l2_buffer_new): Behave more like ximagesink's buffers, with
finalization and resuscitation. No longer public.
(gst_v4l2_buffer_pool_finalize, gst_v4l2_buffer_pool_init)
(gst_v4l2_buffer_pool_class_init, gst_v4l2_buffer_pool_get_type)
(gst_v4l2_buffer_pool_new, gst_v4l2_buffer_pool_activate)
(gst_v4l2_buffer_pool_destroy): Make the pool follow common
miniobject semantics, and be threadsafe.
(gst_v4l2src_queue_frame): Remove this function, as we just call
the ioctls directly in the two places where we queue buffers.
(gst_v4l2src_grab_frame): Return a flowreturn and fill the buffer
directly.
(gst_v4l2src_capture_init): Use the new buffer_pool_new function
to allocate the pool, which also preallocates the GstBuffers.
(gst_v4l2src_capture_start): Call buffer_pool_activate instead of
queueing the frames directly.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2BufferPool): Make this a
real MiniObject instead of rolling our own refcounting and
finalizing. Give it a lock.
(struct _GstV4l2Buffer): Remove one intermediary object, having
the buffers hold the struct v4l2_buffer directly.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_set_caps): Pass the caps to
capture_init so that it can set them on the buffers that it will
create.
(gst_v4l2src_get_read): For better or for worse, include the
timestamping and offsetting code here; really we should be using
bufferalloc though.
(gst_v4l2src_get_mmap): Just make grab_frame return one of our
preallocated, mmap'd buffers.
2007-06-12 11:23:01 +00:00
|
|
|
GstClockTime timestamp;
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (v4l2src);
|
|
|
|
if ((clock = GST_ELEMENT_CLOCK (v4l2src))) {
|
|
|
|
/* we have a clock, get base time and ref clock */
|
|
|
|
timestamp = GST_ELEMENT (v4l2src)->base_time;
|
|
|
|
gst_object_ref (clock);
|
|
|
|
} else {
|
|
|
|
/* no clock, can't set timestamps */
|
|
|
|
timestamp = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (v4l2src);
|
|
|
|
|
|
|
|
if (clock) {
|
2007-09-05 14:43:16 +00:00
|
|
|
GstClockTime latency;
|
|
|
|
|
sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize) (gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
Original commit message from CVS:
2007-06-12 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize)
(gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
(gst_v4l2_buffer_new): Behave more like ximagesink's buffers, with
finalization and resuscitation. No longer public.
(gst_v4l2_buffer_pool_finalize, gst_v4l2_buffer_pool_init)
(gst_v4l2_buffer_pool_class_init, gst_v4l2_buffer_pool_get_type)
(gst_v4l2_buffer_pool_new, gst_v4l2_buffer_pool_activate)
(gst_v4l2_buffer_pool_destroy): Make the pool follow common
miniobject semantics, and be threadsafe.
(gst_v4l2src_queue_frame): Remove this function, as we just call
the ioctls directly in the two places where we queue buffers.
(gst_v4l2src_grab_frame): Return a flowreturn and fill the buffer
directly.
(gst_v4l2src_capture_init): Use the new buffer_pool_new function
to allocate the pool, which also preallocates the GstBuffers.
(gst_v4l2src_capture_start): Call buffer_pool_activate instead of
queueing the frames directly.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2BufferPool): Make this a
real MiniObject instead of rolling our own refcounting and
finalizing. Give it a lock.
(struct _GstV4l2Buffer): Remove one intermediary object, having
the buffers hold the struct v4l2_buffer directly.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_set_caps): Pass the caps to
capture_init so that it can set them on the buffers that it will
create.
(gst_v4l2src_get_read): For better or for worse, include the
timestamping and offsetting code here; really we should be using
bufferalloc though.
(gst_v4l2src_get_mmap): Just make grab_frame return one of our
preallocated, mmap'd buffers.
2007-06-12 11:23:01 +00:00
|
|
|
/* the time now is the time of the clock minus the base time */
|
|
|
|
timestamp = gst_clock_get_time (clock) - timestamp;
|
|
|
|
gst_object_unref (clock);
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
latency =
|
|
|
|
gst_util_uint64_scale_int (GST_SECOND, v4l2src->fps_d,
|
|
|
|
v4l2src->fps_n);
|
|
|
|
|
|
|
|
if (timestamp > latency)
|
|
|
|
timestamp -= latency;
|
|
|
|
else
|
|
|
|
timestamp = 0;
|
sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize) (gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
Original commit message from CVS:
2007-06-12 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.c (gst_v4l2_buffer_finalize)
(gst_v4l2_buffer_class_init, gst_v4l2_buffer_get_type)
(gst_v4l2_buffer_new): Behave more like ximagesink's buffers, with
finalization and resuscitation. No longer public.
(gst_v4l2_buffer_pool_finalize, gst_v4l2_buffer_pool_init)
(gst_v4l2_buffer_pool_class_init, gst_v4l2_buffer_pool_get_type)
(gst_v4l2_buffer_pool_new, gst_v4l2_buffer_pool_activate)
(gst_v4l2_buffer_pool_destroy): Make the pool follow common
miniobject semantics, and be threadsafe.
(gst_v4l2src_queue_frame): Remove this function, as we just call
the ioctls directly in the two places where we queue buffers.
(gst_v4l2src_grab_frame): Return a flowreturn and fill the buffer
directly.
(gst_v4l2src_capture_init): Use the new buffer_pool_new function
to allocate the pool, which also preallocates the GstBuffers.
(gst_v4l2src_capture_start): Call buffer_pool_activate instead of
queueing the frames directly.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2BufferPool): Make this a
real MiniObject instead of rolling our own refcounting and
finalizing. Give it a lock.
(struct _GstV4l2Buffer): Remove one intermediary object, having
the buffers hold the struct v4l2_buffer directly.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_set_caps): Pass the caps to
capture_init so that it can set them on the buffers that it will
create.
(gst_v4l2src_get_read): For better or for worse, include the
timestamping and offsetting code here; really we should be using
bufferalloc though.
(gst_v4l2src_get_mmap): Just make grab_frame return one of our
preallocated, mmap'd buffers.
2007-06-12 11:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: use the timestamp from the buffer itself! */
|
|
|
|
GST_BUFFER_TIMESTAMP (*buf) = timestamp;
|
|
|
|
}
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
return GST_FLOW_OK;
|
2003-05-02 21:16:56 +00:00
|
|
|
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
/* ERRORS */
|
|
|
|
read_error:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC,
|
2006-11-01 19:48:26 +00:00
|
|
|
(_("Error read()ing %d bytes on device '%s'."),
|
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices),
(gst_v4l2_probe_needs_probe),
(gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new),
(gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper),
(gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults),
(gst_v4l2_object_start), (gst_v4l2_object_stop):
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init),
(gst_v4l2src_init), (gst_v4l2src_dispose),
(gst_v4l2src_set_property), (gst_v4l2src_get_property),
(gst_v4l2src_fixate), (gst_v4l2src_get_caps),
(gst_v4l2src_set_caps), (gst_v4l2src_get_read),
(gst_v4l2src_get_mmap), (gst_v4l2src_create):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm),
(gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame),
(gst_v4l2src_get_capture), (gst_v4l2src_set_capture),
(gst_v4l2src_capture_init), (gst_v4l2src_capture_start),
(gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit),
(gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps),
(gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize),
(gst_v4l2src_buffer_new):
Fix pass at code cleanups, move errors cases out of the normal
flow for additional code clarity.
2006-09-26 11:06:17 +00:00
|
|
|
buffersize, v4l2src->v4l2object->videodev), GST_ERROR_SYSTEM);
|
|
|
|
gst_buffer_unref (*buf);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_v4l2src_get_mmap (GstV4l2Src * v4l2src, GstBuffer ** buf)
|
2002-09-09 07:14:35 +00:00
|
|
|
{
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GstBuffer *temp;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
GstFlowReturn ret;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
guint size;
|
2008-06-04 17:39:31 +00:00
|
|
|
|
sys/v4l2/gstv4l2src.c: Restructure the setcaps function so that we can also compute the expected GStreamer output siz...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2_get_caps_info),
(gst_v4l2src_set_caps), (gst_v4l2src_get_mmap):
Restructure the setcaps function so that we can also compute the
expected GStreamer output size of the video frames.
Set frame_byte_size correctly so that read-based devices have a chance
of working correctly.
When grabbing a frame, discard frames that are not of the expected size.
Some cameras don't output the right framesize for the first buffer.
Try only a couple of times to get a valid frame, else error out.
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_get_input):
Add some more debug info when scanning the device.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_new),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init):
Add some more debug info when dequeing a frame.
2007-09-04 16:40:05 +00:00
|
|
|
guint count;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
again:
|
|
|
|
ret = gst_v4l2src_grab_frame (v4l2src, &temp);
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (v4l2src->frame_byte_size > 0) {
|
|
|
|
size = GST_BUFFER_SIZE (temp);
|
|
|
|
|
|
|
|
/* if size does not match what we expected, try again */
|
|
|
|
if (size != v4l2src->frame_byte_size) {
|
|
|
|
GST_ELEMENT_WARNING (v4l2src, RESOURCE, READ,
|
|
|
|
(_("Got unexpected frame size of %u instead of %u."),
|
|
|
|
size, v4l2src->frame_byte_size), (NULL));
|
|
|
|
gst_buffer_unref (temp);
|
|
|
|
if (count++ > 50)
|
|
|
|
goto size_error;
|
|
|
|
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*buf = temp;
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
size_error:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
|
|
|
|
(_("Error read()ing %d bytes on device '%s'."),
|
|
|
|
v4l2src->frame_byte_size, v4l2src->v4l2object->videodev), (NULL));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_v4l2src_create (GstPushSrc * src, GstBuffer ** buf)
|
2003-05-02 21:16:56 +00:00
|
|
|
{
|
2006-03-11 22:50:03 +00:00
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
GstFlowReturn ret;
|
|
|
|
|
sys/v4l2/v4l2src_calls.*: Store the format list in the order that the driver gives it to us.
Original commit message from CVS:
2007-05-30 Andy Wingo <wingo@pobox.com>
* sys/v4l2/v4l2src_calls.h:
* sys/v4l2/v4l2src_calls.c (gst_v4l2src_fill_format_list): Store
the format list in the order that the driver gives it to us.
(gst_v4l2src_probe_caps_for_format_and_size)
(gst_v4l2src_probe_caps_for_format): New functions, fill GstCaps
based on the capabilities of the device.
(gst_v4l2src_grab_frame): Update for object variable renaming.
(gst_v4l2src_set_capture): Update to be strict in its parameters,
as in the set_caps below.
(gst_v4l2src_capture_init): Update for object variable renaming,
and reflow.
(gst_v4l2src_capture_start, gst_v4l2src_capture_stop)
(gst_v4l2src_capture_deinit): Update for object variable renaming.
(gst_v4l2src_update_fps, gst_v4l2src_set_fps)
(gst_v4l2src_get_fps): Remove; these functions don't have much
meaning outside of an atomic set_caps method.
(gst_v4l2src_buffer_new): Don't set buffer duration, it is not
known.
* sys/v4l2/gstv4l2tuner.c (gst_v4l2_tuner_set_channel): Remove
call to update_fps; not sure about this change.
(gst_v4l2_tuner_set_norm): Work around the fact that for the
moment we don't have an update_fps_func.
* sys/v4l2/gstv4l2src.h (struct _GstV4l2Src): Don't put v4l2
structures in the object, just store what we need. Do store the
probed caps of the device. Don't store the current frame rate.
* sys/v4l2/gstv4l2src.c (gst_v4l2src_init): Remove the
update_fps_function, for now. Update for new object variable
naming.
(gst_v4l2src_set_property, gst_v4l2src_get_property): Update for
new object variable naming.
(gst_v4l2src_v4l2fourcc_to_structure): Rename from ..._to_caps.
(gst_v4l2_structure_to_v4l2fourcc): Rename from ...caps_to_....
(gst_v4l2src_get_caps): Rework to probe the device for supported
frame sizes and frame rates.
(gst_v4l2src_set_caps): Rework to be strict in the given
parameters: if someone asks us to have a certain size and rate,
that is what we configure.
(gst_v4l2src_get_read): Update for object variable naming. Don't
leak buffers on short reads.
(gst_v4l2src_get_mmap): Update for object variable naming, and add
comments.
(gst_v4l2src_create): Update for object variable naming.
2007-05-30 14:40:53 +00:00
|
|
|
if (v4l2src->use_mmap) {
|
2006-03-11 22:50:03 +00:00
|
|
|
ret = gst_v4l2src_get_mmap (v4l2src, buf);
|
|
|
|
} else {
|
|
|
|
ret = gst_v4l2src_get_read (v4l2src, buf);
|
|
|
|
}
|
|
|
|
return ret;
|
2003-05-02 21:16:56 +00:00
|
|
|
}
|