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
|
|
|
*
|
2009-01-29 08:10:08 +00:00
|
|
|
* v4l2src can be used to capture video from v4l2 devices, like webcams and tv
|
|
|
|
* cards.
|
|
|
|
*
|
2006-04-17 19:43:32 +00:00
|
|
|
* <refsect2>
|
2007-07-18 11:55:13 +00:00
|
|
|
* <title>Example launch lines</title>
|
2009-01-29 08:10:08 +00:00
|
|
|
* |[
|
2006-04-17 19:43:32 +00:00
|
|
|
* gst-launch v4l2src ! xvimagesink
|
2009-01-29 08:10:08 +00:00
|
|
|
* ]| This pipeline shows the video captured from /dev/video0 tv card and for
|
2006-10-03 13:18:59 +00:00
|
|
|
* webcams.
|
2009-01-29 08:10:08 +00:00
|
|
|
* |[
|
2009-01-29 09:07:59 +00:00
|
|
|
* gst-launch v4l2src ! jpegdec ! xvimagesink
|
2009-01-29 08:10:08 +00:00
|
|
|
* ]| This pipeline shows the video captured from a webcam that delivers jpeg
|
2007-07-18 11:55:13 +00:00
|
|
|
* images.
|
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
|
|
|
|
|
2011-01-03 01:18:06 +00:00
|
|
|
#undef HAVE_XVIDEO
|
|
|
|
|
2002-09-09 07:14:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
2006-03-11 22:50:03 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2011-10-31 01:24:04 +00:00
|
|
|
#include "gst/video/gstvideometa.h"
|
2011-07-29 15:21:03 +00:00
|
|
|
#include "gst/video/gstvideopool.h"
|
2011-07-27 11:43:08 +00:00
|
|
|
|
2011-07-13 16:32:00 +00:00
|
|
|
#include "gstv4l2src.h"
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
#include "gstv4l2colorbalance.h"
|
|
|
|
#include "gstv4l2tuner.h"
|
2010-04-04 11:37:16 +00:00
|
|
|
#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
|
|
|
|
2009-08-04 07:14:20 +00:00
|
|
|
#include "gst/gst-i18n-plugin.h"
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
GST_DEBUG_CATEGORY (v4l2src_debug);
|
|
|
|
#define GST_CAT_DEFAULT v4l2src_debug
|
|
|
|
|
2009-05-26 13:20:35 +00:00
|
|
|
#define PROP_DEF_ALWAYS_COPY TRUE
|
2009-06-29 18:43:07 +00:00
|
|
|
#define PROP_DEF_DECIMATE 1
|
2007-11-15 12:22:10 +00:00
|
|
|
|
2009-08-04 07:14:20 +00:00
|
|
|
#define DEFAULT_PROP_DEVICE "/dev/video0"
|
|
|
|
|
2006-05-18 19:34:47 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
V4L2_STD_OBJECT_PROPS,
|
2009-06-29 18:43:07 +00:00
|
|
|
PROP_ALWAYS_COPY,
|
|
|
|
PROP_DECIMATE
|
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);
|
2010-04-04 11:37:16 +00:00
|
|
|
#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
|
|
|
|
2009-11-08 10:49:14 +00:00
|
|
|
static void gst_v4l2src_uri_handler_init (gpointer g_iface,
|
|
|
|
gpointer iface_data);
|
|
|
|
|
2011-07-08 10:49:12 +00:00
|
|
|
#define gst_v4l2src_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstV4l2Src, gst_v4l2src, GST_TYPE_PUSH_SRC,
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_v4l2src_uri_handler_init);
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER, gst_v4l2src_tuner_interface_init);
|
2010-04-04 11:37:16 +00:00
|
|
|
#ifdef HAVE_XVIDEO
|
2011-07-08 10:49:12 +00:00
|
|
|
/* FIXME: does GstXOverlay for v4l2src make sense in a GStreamer context? */
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_X_OVERLAY,
|
|
|
|
gst_v4l2src_xoverlay_interface_init);
|
2006-05-11 17:59:59 +00:00
|
|
|
#endif
|
2011-07-08 10:49:12 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE,
|
|
|
|
gst_v4l2src_color_balance_interface_init);
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION,
|
|
|
|
gst_v4l2src_video_orientation_interface_init);
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_PROPERTY_PROBE,
|
|
|
|
gst_v4l2src_property_probe_interface_init));
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-04-13 21:45:57 +00:00
|
|
|
static void gst_v4l2src_dispose (GObject * object);
|
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
|
|
|
|
2009-06-22 12:56:58 +00:00
|
|
|
/* element methods */
|
|
|
|
static GstStateChangeReturn gst_v4l2src_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
/* basesrc methods */
|
|
|
|
static gboolean gst_v4l2src_start (GstBaseSrc * src);
|
2009-03-01 18:55:26 +00:00
|
|
|
static gboolean gst_v4l2src_unlock (GstBaseSrc * src);
|
|
|
|
static gboolean gst_v4l2src_unlock_stop (GstBaseSrc * src);
|
2006-03-11 22:50:03 +00:00
|
|
|
static gboolean gst_v4l2src_stop (GstBaseSrc * src);
|
|
|
|
static gboolean gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps);
|
2011-07-08 10:49:12 +00:00
|
|
|
static GstCaps *gst_v4l2src_get_caps (GstBaseSrc * src, GstCaps * filter);
|
2007-09-05 14:43:16 +00:00
|
|
|
static gboolean gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query);
|
2011-08-26 12:20:49 +00:00
|
|
|
static gboolean gst_v4l2src_decide_allocation (GstBaseSrc * src,
|
2011-07-15 14:55:50 +00:00
|
|
|
GstQuery * query);
|
2011-07-18 16:54:49 +00:00
|
|
|
static GstFlowReturn gst_v4l2src_fill (GstPushSrc * src, GstBuffer * out);
|
2007-10-13 12:03:44 +00:00
|
|
|
static void gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps);
|
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
|
|
|
|
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;
|
2009-06-22 12:56:58 +00:00
|
|
|
GstElementClass *element_class;
|
2006-03-11 22:50:03 +00:00
|
|
|
GstBaseSrcClass *basesrc_class;
|
|
|
|
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);
|
2009-06-22 12:56:58 +00:00
|
|
|
element_class = GST_ELEMENT_CLASS (klass);
|
2006-03-11 22:50:03 +00:00
|
|
|
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;
|
|
|
|
|
2009-06-22 12:56:58 +00:00
|
|
|
element_class->change_state = gst_v4l2src_change_state;
|
|
|
|
|
2009-08-04 07:14:20 +00:00
|
|
|
gst_v4l2_object_install_properties_helper (gobject_class,
|
|
|
|
DEFAULT_PROP_DEVICE);
|
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",
|
2010-06-21 09:15:14 +00:00
|
|
|
PROP_DEF_ALWAYS_COPY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2010-09-15 16:02:57 +00:00
|
|
|
/**
|
|
|
|
* GstV4l2Src:decimate
|
|
|
|
*
|
|
|
|
* Only use every nth frame
|
|
|
|
*
|
|
|
|
* Since: 0.10.26
|
|
|
|
*/
|
2009-06-29 18:43:07 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_DECIMATE,
|
|
|
|
g_param_spec_int ("decimate", "Decimate",
|
|
|
|
"Only use every nth frame", 1, G_MAXINT,
|
|
|
|
PROP_DEF_DECIMATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2006-05-11 17:59:59 +00:00
|
|
|
|
2011-07-08 10:49:12 +00:00
|
|
|
gst_element_class_set_details_simple (element_class,
|
|
|
|
"Video (video4linux2) Source", "Source/Video",
|
|
|
|
"Reads frames from a Video4Linux2 device",
|
2011-07-11 10:04:57 +00:00
|
|
|
"Edgard Lima <edgard.lima@indt.org.br>, "
|
|
|
|
"Stefan Kost <ensonic@users.sf.net>");
|
2011-07-08 10:49:12 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template
|
|
|
|
(element_class,
|
|
|
|
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
|
|
|
gst_v4l2_object_get_all_caps ()));
|
|
|
|
|
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);
|
2009-03-01 18:55:26 +00:00
|
|
|
basesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_v4l2src_unlock);
|
|
|
|
basesrc_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_v4l2src_unlock_stop);
|
2007-09-05 14:43:16 +00:00
|
|
|
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);
|
2011-08-26 12:20:49 +00:00
|
|
|
basesrc_class->decide_allocation =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_v4l2src_decide_allocation);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
pushsrc_class->fill = GST_DEBUG_FUNCPTR (gst_v4l2src_fill);
|
2011-07-08 10:49:12 +00:00
|
|
|
|
|
|
|
klass->v4l2_class_devices = NULL;
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "V4L2 source element");
|
2006-03-11 22:50:03 +00:00
|
|
|
}
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
static void
|
2011-07-08 10:49:12 +00:00
|
|
|
gst_v4l2src_init (GstV4l2Src * v4l2src)
|
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),
|
2009-08-04 07:14:20 +00:00
|
|
|
V4L2_BUF_TYPE_VIDEO_CAPTURE, DEFAULT_PROP_DEVICE,
|
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
|
|
|
|
2011-07-13 16:32:00 +00:00
|
|
|
v4l2src->v4l2object->always_copy = PROP_DEF_ALWAYS_COPY;
|
2009-06-29 18:43:07 +00:00
|
|
|
v4l2src->decimate = PROP_DEF_DECIMATE;
|
2007-11-15 12:22:10 +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);
|
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);
|
|
|
|
|
2008-08-26 12:27:11 +00:00
|
|
|
if (v4l2src->probed_caps) {
|
|
|
|
gst_caps_unref (v4l2src->probed_caps);
|
|
|
|
}
|
|
|
|
|
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) {
|
2007-11-15 12:22:10 +00:00
|
|
|
case PROP_ALWAYS_COPY:
|
2011-07-13 16:32:00 +00:00
|
|
|
v4l2src->v4l2object->always_copy = g_value_get_boolean (value);
|
2007-11-15 12:22:10 +00:00
|
|
|
break;
|
2009-06-29 18:43:07 +00:00
|
|
|
case PROP_DECIMATE:
|
|
|
|
v4l2src->decimate = g_value_get_int (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) {
|
2007-11-15 12:22:10 +00:00
|
|
|
case PROP_ALWAYS_COPY:
|
2011-07-13 16:32:00 +00:00
|
|
|
g_value_set_boolean (value, v4l2src->v4l2object->always_copy);
|
2007-11-15 12:22:10 +00:00
|
|
|
break;
|
2009-06-29 18:43:07 +00:00
|
|
|
case PROP_DECIMATE:
|
|
|
|
g_value_set_int (value, v4l2src->decimate);
|
|
|
|
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-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;
|
|
|
|
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) {
|
2008-07-08 12:51:34 +00:00
|
|
|
structure = gst_caps_get_structure (caps, i);
|
|
|
|
|
2011-07-11 10:04:57 +00:00
|
|
|
/* We are fixating to a resonable 320x200 resolution
|
2008-06-04 17:39:31 +00:00
|
|
|
and the maximum framerate resolution for that size */
|
2011-07-11 10:04:57 +00:00
|
|
|
gst_structure_fixate_field_nearest_int (structure, "width", 320);
|
|
|
|
gst_structure_fixate_field_nearest_int (structure, "height", 200);
|
2008-06-04 17:39:31 +00:00
|
|
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate",
|
|
|
|
G_MAXINT, 1);
|
2011-08-17 15:57:11 +00:00
|
|
|
gst_structure_fixate_field (structure, "format");
|
2006-03-11 22:50:03 +00:00
|
|
|
}
|
2008-06-04 17:39:31 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps);
|
2011-08-17 15:57:11 +00:00
|
|
|
|
|
|
|
GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, 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 */
|
2011-11-15 15:55:27 +00:00
|
|
|
thiscaps = gst_pad_query_caps (GST_BASE_SRC_PAD (basesrc), NULL);
|
2008-06-04 17:39:31 +00:00
|
|
|
GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps);
|
2009-08-04 07:14:20 +00:00
|
|
|
LOG_CAPS (basesrc, thiscaps);
|
|
|
|
|
2008-06-04 17:39:31 +00:00
|
|
|
/* nothing or anything is allowed, we're done */
|
|
|
|
if (thiscaps == NULL || gst_caps_is_any (thiscaps))
|
|
|
|
goto no_nego_needed;
|
|
|
|
|
|
|
|
/* get the peer caps */
|
2011-11-15 16:29:45 +00:00
|
|
|
peercaps = gst_pad_peer_query_caps (GST_BASE_SRC_PAD (basesrc), thiscaps);
|
2008-06-04 17:39:31 +00:00
|
|
|
GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps);
|
2009-08-04 07:14:20 +00:00
|
|
|
LOG_CAPS (basesrc, peercaps);
|
2008-06-04 17:39:31 +00:00
|
|
|
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);
|
2009-08-04 07:14:20 +00:00
|
|
|
LOG_CAPS (basesrc, ipcaps);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
|
|
|
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);
|
2009-08-04 07:14:20 +00:00
|
|
|
LOG_CAPS (basesrc, icaps);
|
2008-06-04 17:39:31 +00:00
|
|
|
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)) {
|
2011-11-10 10:03:18 +00:00
|
|
|
gst_v4l2src_fixate (basesrc, caps);
|
2008-06-04 17:39:31 +00:00
|
|
|
GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps);
|
2009-08-04 07:14:20 +00:00
|
|
|
LOG_CAPS (basesrc, caps);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
|
|
|
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 */
|
2011-08-04 14:35:46 +00:00
|
|
|
result = gst_base_src_set_caps (basesrc, caps);
|
2008-06-04 17:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
|
|
|
|
no_nego_needed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (basesrc, "no negotiation needed");
|
|
|
|
if (thiscaps)
|
|
|
|
gst_caps_unref (thiscaps);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
static GstCaps *
|
2011-07-08 10:49:12 +00:00
|
|
|
gst_v4l2src_get_caps (GstBaseSrc * src, GstCaps * filter)
|
2002-09-20 09:28:46 +00:00
|
|
|
{
|
2011-07-13 14:33:58 +00:00
|
|
|
GstV4l2Src *v4l2src;
|
|
|
|
GstV4l2Object *obj;
|
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;
|
2004-01-12 02:19:57 +00:00
|
|
|
GSList *walk;
|
2009-08-04 07:14:20 +00:00
|
|
|
GSList *formats;
|
2004-01-12 02:19:57 +00:00
|
|
|
|
2011-07-13 14:33:58 +00:00
|
|
|
v4l2src = GST_V4L2SRC (src);
|
|
|
|
obj = v4l2src->v4l2object;
|
|
|
|
|
|
|
|
if (!GST_V4L2_IS_OPEN (obj)) {
|
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);
|
|
|
|
|
2011-07-13 14:33:58 +00:00
|
|
|
formats = gst_v4l2_object_get_format_list (obj);
|
2006-03-11 22:50:03 +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
|
|
|
ret = gst_caps_new_empty ();
|
|
|
|
|
2011-04-15 13:47:24 +00:00
|
|
|
for (walk = formats; walk; walk = walk->next) {
|
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
|
|
|
struct v4l2_fmtdesc *format;
|
|
|
|
GstStructure *template;
|
|
|
|
|
2004-01-12 02:19:57 +00:00
|
|
|
format = (struct v4l2_fmtdesc *) walk->data;
|
|
|
|
|
2009-08-04 07:14:20 +00:00
|
|
|
template = gst_v4l2_object_v4l2fourcc_to_structure (format->pixelformat);
|
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 (template) {
|
|
|
|
GstCaps *tmp;
|
|
|
|
|
2009-08-04 07:14:20 +00:00
|
|
|
tmp =
|
2011-07-13 14:33:58 +00:00
|
|
|
gst_v4l2_object_probe_caps_for_format (obj,
|
2009-08-04 07:14:20 +00:00
|
|
|
format->pixelformat, template);
|
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 (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
|
|
|
}
|
|
|
|
|
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;
|
2011-07-13 14:33:58 +00:00
|
|
|
GstV4l2Object *obj;
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
v4l2src = GST_V4L2SRC (src);
|
2011-07-13 14:33:58 +00:00
|
|
|
obj = v4l2src->v4l2object;
|
2006-03-11 22:50:03 +00:00
|
|
|
|
|
|
|
/* make sure we stop capturing and dealloc buffers */
|
2011-07-13 14:33:58 +00:00
|
|
|
if (!gst_v4l2_object_stop (obj))
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
2006-08-24 00:40:07 +00:00
|
|
|
|
2011-07-13 14:33:58 +00:00
|
|
|
if (!gst_v4l2_object_set_format (obj, caps))
|
|
|
|
/* error already posted */
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
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
|
2011-08-26 12:20:49 +00:00
|
|
|
gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
|
2007-09-05 14:43:16 +00:00
|
|
|
{
|
|
|
|
GstV4l2Src *src;
|
2011-07-18 16:54:49 +00:00
|
|
|
GstV4l2Object *obj;
|
2011-07-15 14:55:50 +00:00
|
|
|
GstBufferPool *pool;
|
|
|
|
guint size, min, max, prefix, alignment;
|
|
|
|
|
|
|
|
src = GST_V4L2SRC (bsrc);
|
2011-07-18 16:54:49 +00:00
|
|
|
obj = src->v4l2object;
|
2011-07-15 14:55:50 +00:00
|
|
|
|
|
|
|
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
|
|
|
|
&alignment, &pool);
|
2008-06-04 17:39:31 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
GST_DEBUG_OBJECT (src, "allocation: size:%u min:%u max:%u prefix:%u "
|
|
|
|
"align:%u pool:%" GST_PTR_FORMAT, size, min, max, prefix, alignment,
|
|
|
|
pool);
|
|
|
|
|
|
|
|
if (min != 0) {
|
|
|
|
/* if there is a min-buffers suggestion, use it. We add 1 because we need 1
|
|
|
|
* buffer extra to capture while the other two buffers are downstream */
|
|
|
|
min += 1;
|
|
|
|
} else {
|
2011-07-27 14:46:46 +00:00
|
|
|
min = 2;
|
2011-07-18 16:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* select a pool */
|
|
|
|
switch (obj->mode) {
|
|
|
|
case GST_V4L2_IO_RW:
|
|
|
|
if (pool == NULL) {
|
|
|
|
/* no downstream pool, use our own then */
|
|
|
|
GST_DEBUG_OBJECT (src,
|
|
|
|
"read/write mode: no downstream pool, using our own");
|
2011-07-27 14:46:46 +00:00
|
|
|
pool = GST_BUFFER_POOL_CAST (obj->pool);
|
2011-07-26 14:15:05 +00:00
|
|
|
size = obj->sizeimage;
|
2011-07-18 16:54:49 +00:00
|
|
|
} else {
|
|
|
|
/* in READ/WRITE mode, prefer a downstream pool because our own pool
|
|
|
|
* doesn't help much, we have to write to it as well */
|
|
|
|
GST_DEBUG_OBJECT (src, "read/write mode: using downstream pool");
|
|
|
|
/* use the bigest size, when we use our own pool we can't really do any
|
|
|
|
* other size than what the hardware gives us but for downstream pools
|
|
|
|
* we can try */
|
2011-07-26 14:15:05 +00:00
|
|
|
size = MAX (size, obj->sizeimage);
|
2011-07-18 16:54:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_V4L2_IO_MMAP:
|
|
|
|
case GST_V4L2_IO_USERPTR:
|
|
|
|
/* in streaming mode, prefer our own pool */
|
2011-07-27 14:46:46 +00:00
|
|
|
pool = GST_BUFFER_POOL_CAST (obj->pool);
|
2011-07-26 14:15:05 +00:00
|
|
|
size = obj->sizeimage;
|
2011-07-18 16:54:49 +00:00
|
|
|
GST_DEBUG_OBJECT (src,
|
|
|
|
"streaming mode: using our own pool %" GST_PTR_FORMAT, pool);
|
|
|
|
break;
|
|
|
|
case GST_V4L2_IO_AUTO:
|
|
|
|
default:
|
|
|
|
GST_WARNING_OBJECT (src, "unhandled mode");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pool) {
|
|
|
|
GstStructure *config;
|
|
|
|
const GstCaps *caps;
|
|
|
|
|
|
|
|
config = gst_buffer_pool_get_config (pool);
|
|
|
|
gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
gst_buffer_pool_config_set (config, caps, size, min, max, prefix,
|
|
|
|
alignment);
|
2011-07-27 11:43:08 +00:00
|
|
|
|
|
|
|
/* if downstream supports video metadata, add this to the pool config */
|
2011-10-31 01:24:04 +00:00
|
|
|
if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API))
|
2011-07-29 15:21:03 +00:00
|
|
|
gst_buffer_pool_config_add_option (config,
|
2011-10-31 01:24:04 +00:00
|
|
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
2011-07-27 11:43:08 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
gst_buffer_pool_set_config (pool, config);
|
|
|
|
}
|
2011-07-15 14:55:50 +00:00
|
|
|
|
|
|
|
gst_query_set_allocation_params (query, size, min, max, prefix,
|
|
|
|
alignment, pool);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstV4l2Src *src;
|
2011-07-27 14:46:46 +00:00
|
|
|
GstV4l2Object *obj;
|
2007-09-05 14:43:16 +00:00
|
|
|
gboolean res = FALSE;
|
|
|
|
|
|
|
|
src = GST_V4L2SRC (bsrc);
|
2011-07-27 14:46:46 +00:00
|
|
|
obj = src->v4l2object;
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_LATENCY:{
|
|
|
|
GstClockTime min_latency, max_latency;
|
2011-07-13 09:19:28 +00:00
|
|
|
guint32 fps_n, fps_d;
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
/* device must be open */
|
2011-07-27 14:46:46 +00:00
|
|
|
if (!GST_V4L2_IS_OPEN (obj)) {
|
2008-08-12 12:04:24 +00:00
|
|
|
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
|
|
|
|
2011-07-27 14:46:46 +00:00
|
|
|
fps_n = GST_V4L2_FPS_N (obj);
|
|
|
|
fps_d = GST_V4L2_FPS_D (obj);
|
2011-07-13 09:19:28 +00:00
|
|
|
|
2007-09-05 14:43:16 +00:00
|
|
|
/* we must have a framerate */
|
2011-07-13 09:19:28 +00:00
|
|
|
if (fps_n <= 0 || fps_d <= 0) {
|
2008-08-12 12:04:24 +00:00
|
|
|
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 */
|
2011-07-13 09:19:28 +00:00
|
|
|
min_latency = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);
|
2007-09-05 14:43:16 +00:00
|
|
|
|
|
|
|
/* max latency is total duration of the frame buffer */
|
2011-08-04 11:50:01 +00:00
|
|
|
max_latency =
|
|
|
|
GST_V4L2_BUFFER_POOL_CAST (obj->pool)->max_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
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
v4l2src->offset = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2010-06-22 12:48:04 +00:00
|
|
|
/* activate settings for first frame */
|
|
|
|
v4l2src->ctrl_time = 0;
|
2011-11-04 17:41:36 +00:00
|
|
|
gst_object_sync_values (GST_OBJECT (src), v4l2src->ctrl_time);
|
2010-06-22 12:48:04 +00:00
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2009-03-01 18:55:26 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_unlock (GstBaseSrc * src)
|
|
|
|
{
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
2011-07-18 16:54:49 +00:00
|
|
|
return gst_v4l2_object_unlock (v4l2src->v4l2object);
|
2009-03-01 18:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_unlock_stop (GstBaseSrc * src)
|
|
|
|
{
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
2011-07-18 16:54:49 +00:00
|
|
|
return gst_v4l2_object_unlock_stop (v4l2src->v4l2object);
|
2009-03-01 18:55:26 +00:00
|
|
|
}
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4l2src_stop (GstBaseSrc * src)
|
|
|
|
{
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
|
2011-07-13 14:33:58 +00:00
|
|
|
GstV4l2Object *obj = v4l2src->v4l2object;
|
2006-03-11 22:50:03 +00:00
|
|
|
|
2011-07-13 14:33:58 +00:00
|
|
|
if (GST_V4L2_IS_ACTIVE (obj)) {
|
|
|
|
if (!gst_v4l2_object_stop (obj))
|
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
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-06-22 12:56:58 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_v4l2src_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (element);
|
2011-07-13 14:33:58 +00:00
|
|
|
GstV4l2Object *obj = v4l2src->v4l2object;
|
2009-06-22 12:56:58 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
|
|
|
/* open the device */
|
2011-07-13 14:33:58 +00:00
|
|
|
if (!gst_v4l2_object_open (obj))
|
2009-06-22 12:56:58 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
|
|
/* close the device */
|
2011-07-13 14:33:58 +00:00
|
|
|
if (!gst_v4l2_object_close (obj))
|
2009-06-22 12:56:58 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2009-08-14 08:11:25 +00:00
|
|
|
|
|
|
|
if (v4l2src->probed_caps) {
|
|
|
|
gst_caps_unref (v4l2src->probed_caps);
|
|
|
|
v4l2src->probed_caps = NULL;
|
|
|
|
}
|
2009-06-22 12:56:58 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
static GstFlowReturn
|
2011-07-18 16:54:49 +00:00
|
|
|
gst_v4l2src_fill (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);
|
2011-07-13 16:32:00 +00:00
|
|
|
GstV4l2Object *obj = v4l2src->v4l2object;
|
2006-03-11 22:50:03 +00:00
|
|
|
GstFlowReturn ret;
|
2011-07-18 16:54:49 +00:00
|
|
|
GstClock *clock;
|
|
|
|
GstClockTime timestamp, duration;
|
2006-03-11 22:50:03 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
#if 0
|
|
|
|
int i;
|
2011-07-11 10:04:57 +00:00
|
|
|
/* decimate, just capture and throw away frames */
|
2009-06-29 18:43:07 +00:00
|
|
|
for (i = 0; i < v4l2src->decimate - 1; i++) {
|
2011-07-18 16:54:49 +00:00
|
|
|
ret = gst_v4l2_buffer_pool_process (obj, buf);
|
2009-06-29 18:43:07 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
gst_buffer_unref (*buf);
|
|
|
|
}
|
2011-07-18 16:54:49 +00:00
|
|
|
#endif
|
2009-06-29 18:43:07 +00:00
|
|
|
|
2011-08-04 11:50:01 +00:00
|
|
|
ret =
|
|
|
|
gst_v4l2_buffer_pool_process (GST_V4L2_BUFFER_POOL_CAST (obj->pool), buf);
|
2009-06-29 18:43:07 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
|
|
|
goto error;
|
2009-03-25 08:08:41 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
/* set buffer metadata */
|
|
|
|
GST_BUFFER_OFFSET (buf) = v4l2src->offset++;
|
|
|
|
GST_BUFFER_OFFSET_END (buf) = v4l2src->offset;
|
|
|
|
|
|
|
|
/* timestamps, LOCK to get clock and base time. */
|
|
|
|
/* FIXME: element clock and base_time is rarely changing */
|
|
|
|
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);
|
2011-07-13 09:19:28 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
duration = obj->duration;
|
2009-03-25 08:08:41 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
if (G_LIKELY (clock)) {
|
|
|
|
/* the time now is the time of the clock minus the base time */
|
|
|
|
timestamp = gst_clock_get_time (clock) - timestamp;
|
|
|
|
gst_object_unref (clock);
|
2009-03-25 08:08:41 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
/* if we have a framerate adjust timestamp for frame latency */
|
2011-07-13 09:19:28 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (duration)) {
|
2011-07-18 16:54:49 +00:00
|
|
|
if (timestamp > duration)
|
|
|
|
timestamp -= duration;
|
|
|
|
else
|
|
|
|
timestamp = 0;
|
2010-06-22 12:48:04 +00:00
|
|
|
}
|
2011-07-18 16:54:49 +00:00
|
|
|
}
|
2010-06-22 12:48:04 +00:00
|
|
|
|
2011-07-18 16:54:49 +00:00
|
|
|
/* activate settings for next frame */
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (duration)) {
|
|
|
|
v4l2src->ctrl_time += duration;
|
|
|
|
} else {
|
|
|
|
/* this is not very good (as it should be the next timestamp),
|
|
|
|
* still good enough for linear fades (as long as it is not -1)
|
|
|
|
*/
|
|
|
|
v4l2src->ctrl_time = timestamp;
|
2009-03-25 08:08:41 +00:00
|
|
|
}
|
2011-11-04 17:41:36 +00:00
|
|
|
gst_object_sync_values (GST_OBJECT (src), v4l2src->ctrl_time);
|
2011-07-18 16:54:49 +00:00
|
|
|
GST_INFO_OBJECT (src, "sync to %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (v4l2src->ctrl_time));
|
|
|
|
|
|
|
|
/* FIXME: use the timestamp from the buffer itself! */
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = timestamp;
|
|
|
|
GST_BUFFER_DURATION (buf) = duration;
|
|
|
|
|
2006-03-11 22:50:03 +00:00
|
|
|
return ret;
|
2011-07-18 16:54:49 +00:00
|
|
|
|
|
|
|
/* ERROR */
|
|
|
|
error:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (src, "error processing buffer");
|
|
|
|
return ret;
|
|
|
|
}
|
2003-05-02 21:16:56 +00:00
|
|
|
}
|
2009-11-08 10:49:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* GstURIHandler interface */
|
|
|
|
static GstURIType
|
2011-07-08 10:49:12 +00:00
|
|
|
gst_v4l2src_uri_get_type (GType type)
|
2009-11-08 10:49:14 +00:00
|
|
|
{
|
|
|
|
return GST_URI_SRC;
|
|
|
|
}
|
|
|
|
|
2011-11-13 23:42:44 +00:00
|
|
|
static const gchar *const *
|
2011-07-08 10:49:12 +00:00
|
|
|
gst_v4l2src_uri_get_protocols (GType type)
|
2009-11-08 10:49:14 +00:00
|
|
|
{
|
2011-11-13 23:42:44 +00:00
|
|
|
static const gchar *protocols[] = { "v4l2", NULL };
|
2009-11-08 10:49:14 +00:00
|
|
|
|
|
|
|
return protocols;
|
|
|
|
}
|
|
|
|
|
2011-11-13 18:50:51 +00:00
|
|
|
static gchar *
|
2009-11-08 10:49:14 +00:00
|
|
|
gst_v4l2src_uri_get_uri (GstURIHandler * handler)
|
|
|
|
{
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (handler);
|
|
|
|
|
2010-01-05 09:47:00 +00:00
|
|
|
if (v4l2src->v4l2object->videodev != NULL) {
|
2011-11-13 18:50:51 +00:00
|
|
|
return g_strdup_printf ("v4l2://%s", v4l2src->v4l2object->videodev);
|
2010-01-05 09:47:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-13 18:50:51 +00:00
|
|
|
return g_strdup ("v4l2://");
|
2009-11-08 10:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-13 18:50:51 +00:00
|
|
|
gst_v4l2src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
|
|
|
|
GError ** error)
|
2009-11-08 10:49:14 +00:00
|
|
|
{
|
|
|
|
GstV4l2Src *v4l2src = GST_V4L2SRC (handler);
|
|
|
|
const gchar *device = DEFAULT_PROP_DEVICE;
|
|
|
|
|
|
|
|
if (strcmp (uri, "v4l2://") != 0) {
|
|
|
|
device = uri + 7;
|
|
|
|
}
|
|
|
|
g_object_set (v4l2src, "device", device, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_v4l2src_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
|
|
|
{
|
|
|
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
|
|
|
|
|
|
|
|
iface->get_type = gst_v4l2src_uri_get_type;
|
|
|
|
iface->get_protocols = gst_v4l2src_uri_get_protocols;
|
|
|
|
iface->get_uri = gst_v4l2src_uri_get_uri;
|
|
|
|
iface->set_uri = gst_v4l2src_uri_set_uri;
|
|
|
|
}
|