2004-06-15 09:11:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* gstv4lsrc.c: BT8x8/V4L source element
|
|
|
|
*
|
2002-01-31 22:22:42 +00:00
|
|
|
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2001-12-17 19:03:14 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-03-09 15:07:53 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
#include <string.h>
|
2001-12-23 15:31:15 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include "v4lsrc_calls.h"
|
2004-06-09 11:32:39 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
/* FIXME: small cheat */
|
|
|
|
gboolean gst_v4l_set_window_properties (GstV4lElement * v4lelement);
|
2004-06-17 17:06:24 +00:00
|
|
|
gboolean gst_v4l_get_capabilities (GstV4lElement * v4lelement);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2002-09-18 19:02:52 +00:00
|
|
|
/* elementfactory information */
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstElementDetails gst_v4lsrc_details =
|
|
|
|
GST_ELEMENT_DETAILS ("Video (video4linux/raw) Source",
|
|
|
|
"Source/Video",
|
|
|
|
"Reads raw frames from a video4linux (BT8x8) device",
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
GST_DEBUG_CATEGORY (v4lsrc_debug);
|
|
|
|
#define GST_CAT_DEFAULT v4lsrc_debug
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
/* V4lSrc signals and args */
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-17 19:03:14 +00:00
|
|
|
/* FILL ME */
|
2003-05-02 21:16:55 +00:00
|
|
|
SIGNAL_FRAME_CAPTURE,
|
|
|
|
SIGNAL_FRAME_DROP,
|
|
|
|
SIGNAL_FRAME_INSERT,
|
2001-12-17 19:03:14 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-06-16 15:07:58 +00:00
|
|
|
#define DEFAULT_SYNC_MODE GST_V4LSRC_SYNC_MODE_CLOCK
|
|
|
|
#define DEFAULT_COPY_MODE FALSE
|
2001-12-23 15:31:15 +00:00
|
|
|
/* arguments */
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-17 19:03:14 +00:00
|
|
|
ARG_0,
|
2002-01-07 09:31:34 +00:00
|
|
|
ARG_NUMBUFS,
|
2003-05-02 21:16:55 +00:00
|
|
|
ARG_BUFSIZE,
|
2004-06-16 15:07:58 +00:00
|
|
|
ARG_SYNC_MODE,
|
2004-06-17 17:06:24 +00:00
|
|
|
ARG_COPY_MODE,
|
2004-06-26 15:58:35 +00:00
|
|
|
ARG_AUTOPROBE,
|
|
|
|
ARG_LATENCY_OFFSET
|
2001-12-17 19:03:14 +00:00
|
|
|
};
|
|
|
|
|
configure.ac: Improve mpeg2enc detection. This is for distributions that do ship mjpegtools, but without mpeg2enc. Al...
Original commit message from CVS:
2003-12-21 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Improve mpeg2enc detection. This is for distributions that do
ship mjpegtools, but without mpeg2enc. Also does object check
for might there ever be ABI incompatibility.
* ext/mpeg2enc/gstmpeg2enc.cc:
Add Andrew as second maintainer (he's helping me), and also add
an error if no caps was set. This happens if I pull before capsnego
and that's something I should solve sometime else.
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_parse_blockgroup):
Fix time parsing.
* gst/matroska/matroska-mux.c: (gst_matroska_mux_audio_pad_link),
(gst_matroska_mux_track_header):
Add caps to templates.
* gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_sink_factory):
Add mpegversion=1 to prevent confusion with MPEG/AAC.
* gst/mpegstream/gstmpegdemux.c:
Remove layer since it causes warnings about unfixed caps.
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_get):
Fix obvious typo (we error out if caps were set, we should of
course error out if *no* caps were set).
* sys/oss/gstosselement.c: (gst_osselement_convert):
Fix format conversion, we confused bits/bytes.
* sys/oss/gstosselement.h:
Improve documentation for 'bps'.
* sys/v4l/TODO:
Remove stuff about plugins that need removing - this was done
ages ago.
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_init),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query):
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_init), (gst_v4lsrc_src_convert),
(gst_v4lsrc_src_query):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init),
(gst_v4l2src_src_convert), (gst_v4l2src_src_query):
Add get_query_types(), get_formats() and query() functions.
2003-12-21 18:44:34 +00:00
|
|
|
GST_FORMATS_FUNCTION (GstPad *, gst_v4lsrc_get_formats,
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
|
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
|
|
|
GST_QUERY_TYPE_FUNCTION (GstPad *, gst_v4lsrc_get_query_types,
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_QUERY_POSITION);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-06-16 10:13:51 +00:00
|
|
|
#define GST_TYPE_V4LSRC_SYNC_MODE (gst_v4lsrc_sync_mode_get_type())
|
|
|
|
static GType
|
|
|
|
gst_v4lsrc_sync_mode_get_type (void)
|
|
|
|
{
|
|
|
|
static GType v4lsrc_sync_mode_type = 0;
|
|
|
|
static GEnumValue v4lsrc_sync_mode[] = {
|
|
|
|
{GST_V4LSRC_SYNC_MODE_CLOCK, "0", "Sync to the pipeline clock"},
|
|
|
|
{GST_V4LSRC_SYNC_MODE_PRIVATE_CLOCK, "1", "Sync to a private clock"},
|
|
|
|
{GST_V4LSRC_SYNC_MODE_FIXED_FPS, "2", "Use Fixed fps"},
|
|
|
|
{GST_V4LSRC_SYNC_MODE_NONE, "3", "No Sync"},
|
|
|
|
{0, NULL, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!v4lsrc_sync_mode_type) {
|
|
|
|
v4lsrc_sync_mode_type =
|
|
|
|
g_enum_register_static ("GstV4lSrcSyncMode", v4lsrc_sync_mode);
|
|
|
|
}
|
|
|
|
return v4lsrc_sync_mode_type;
|
|
|
|
}
|
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
/* structure for buffer private data referencing element and frame number */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
|
|
|
int num;
|
|
|
|
}
|
|
|
|
v4lsrc_private_t;
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* init functions */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lsrc_base_init (gpointer g_class);
|
|
|
|
static void gst_v4lsrc_class_init (GstV4lSrcClass * klass);
|
|
|
|
static void gst_v4lsrc_init (GstV4lSrc * v4lsrc);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-01-28 21:16:01 +00:00
|
|
|
/* parent class virtual functions */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lsrc_open (GstElement * element, const gchar * device);
|
|
|
|
static void gst_v4lsrc_close (GstElement * element, const gchar * device);
|
2004-01-28 21:16:01 +00:00
|
|
|
|
configure.ac: Improve mpeg2enc detection. This is for distributions that do ship mjpegtools, but without mpeg2enc. Al...
Original commit message from CVS:
2003-12-21 Ronald Bultje <rbultje@ronald.bitfreak.net>
* configure.ac:
Improve mpeg2enc detection. This is for distributions that do
ship mjpegtools, but without mpeg2enc. Also does object check
for might there ever be ABI incompatibility.
* ext/mpeg2enc/gstmpeg2enc.cc:
Add Andrew as second maintainer (he's helping me), and also add
an error if no caps was set. This happens if I pull before capsnego
and that's something I should solve sometime else.
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_parse_blockgroup):
Fix time parsing.
* gst/matroska/matroska-mux.c: (gst_matroska_mux_audio_pad_link),
(gst_matroska_mux_track_header):
Add caps to templates.
* gst/mpegaudioparse/gstmpegaudioparse.c: (mp3_sink_factory):
Add mpegversion=1 to prevent confusion with MPEG/AAC.
* gst/mpegstream/gstmpegdemux.c:
Remove layer since it causes warnings about unfixed caps.
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_get):
Fix obvious typo (we error out if caps were set, we should of
course error out if *no* caps were set).
* sys/oss/gstosselement.c: (gst_osselement_convert):
Fix format conversion, we confused bits/bytes.
* sys/oss/gstosselement.h:
Improve documentation for 'bps'.
* sys/v4l/TODO:
Remove stuff about plugins that need removing - this was done
ages ago.
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_init),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query):
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_init), (gst_v4lsrc_src_convert),
(gst_v4lsrc_src_query):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init),
(gst_v4l2src_src_convert), (gst_v4l2src_src_query):
Add get_query_types(), get_formats() and query() functions.
2003-12-21 18:44:34 +00:00
|
|
|
/* pad/info functions */
|
2004-03-14 22:34:34 +00:00
|
|
|
static gboolean gst_v4lsrc_src_convert (GstPad * pad,
|
|
|
|
GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
|
|
|
static gboolean gst_v4lsrc_src_query (GstPad * pad,
|
|
|
|
GstQueryType type, GstFormat * format, gint64 * value);
|
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
|
|
|
|
|
|
|
/* buffer functions */
|
2004-06-17 17:06:24 +00:00
|
|
|
static GstPadLinkReturn gst_v4lsrc_src_link (GstPad * pad,
|
2004-03-14 22:34:34 +00:00
|
|
|
const GstCaps * caps);
|
2004-04-27 15:08:27 +00:00
|
|
|
static GstCaps *gst_v4lsrc_fixate (GstPad * pad, const GstCaps * caps);
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstCaps *gst_v4lsrc_getcaps (GstPad * pad);
|
|
|
|
static GstData *gst_v4lsrc_get (GstPad * pad);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* get/set params */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lsrc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_v4lsrc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* state handling */
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstElementStateReturn gst_v4lsrc_change_state (GstElement * element);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
/* set_clock function for a/V sync */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lsrc_set_clock (GstElement * element, GstClock * clock);
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2004-01-06 20:15:21 +00:00
|
|
|
/* requeue buffer if it's back available */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lsrc_buffer_free (GstBuffer * buffer);
|
2004-01-06 20:15:21 +00:00
|
|
|
|
2003-05-10 14:36:34 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
2003-05-02 21:16:55 +00:00
|
|
|
static guint gst_v4lsrc_signals[LAST_SIGNAL] = { 0 };
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_v4lsrc_get_type (void)
|
|
|
|
{
|
|
|
|
static GType v4lsrc_type = 0;
|
|
|
|
|
|
|
|
if (!v4lsrc_type) {
|
|
|
|
static const GTypeInfo v4lsrc_info = {
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstV4lSrcClass),
|
2003-11-02 14:47:52 +00:00
|
|
|
gst_v4lsrc_base_init,
|
2001-12-17 19:03:14 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GClassInitFunc) gst_v4lsrc_class_init,
|
2001-12-17 19:03:14 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstV4lSrc),
|
2001-12-17 19:03:14 +00:00
|
|
|
0,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GInstanceInitFunc) gst_v4lsrc_init,
|
2001-12-17 19:03:14 +00:00
|
|
|
NULL
|
|
|
|
};
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc_type =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_type_register_static (GST_TYPE_V4LELEMENT, "GstV4lSrc", &v4lsrc_info,
|
|
|
|
0);
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
return v4lsrc_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 14:47:52 +00:00
|
|
|
static void
|
|
|
|
gst_v4lsrc_base_init (gpointer g_class)
|
|
|
|
{
|
2004-01-02 21:57:10 +00:00
|
|
|
GstPadTemplate *src_template;
|
2003-11-02 14:47:52 +00:00
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2003-11-02 14:47:52 +00:00
|
|
|
gst_element_class_set_details (gstelement_class, &gst_v4lsrc_details);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
src_template = gst_pad_template_new ("src",
|
2004-04-22 03:29:01 +00:00
|
|
|
GST_PAD_SRC, GST_PAD_ALWAYS, gst_caps_new_any ());
|
2003-11-02 14:47:52 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (gstelement_class, src_template);
|
|
|
|
}
|
2004-01-28 21:16:01 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_class_init (GstV4lSrcClass * klass)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2004-01-28 21:16:01 +00:00
|
|
|
GstV4lElementClass *v4lelement_class;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2004-01-28 21:16:01 +00:00
|
|
|
v4lelement_class = (GstV4lElementClass *) klass;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_V4LELEMENT);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUMBUFS,
|
|
|
|
g_param_spec_int ("num_buffers", "Num Buffers", "Number of buffers",
|
2004-05-03 16:46:03 +00:00
|
|
|
0, G_MAXINT, 0, G_PARAM_READABLE));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
|
|
|
|
g_param_spec_int ("buffer_size", "Buffer Size", "Size of buffers",
|
2004-05-03 16:46:03 +00:00
|
|
|
0, G_MAXINT, 0, G_PARAM_READABLE));
|
2004-06-16 10:13:51 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC_MODE,
|
|
|
|
g_param_spec_enum ("sync_mode", "Sync mode",
|
|
|
|
"Method to use for timestamping captured frames",
|
|
|
|
GST_TYPE_V4LSRC_SYNC_MODE, DEFAULT_SYNC_MODE, G_PARAM_READWRITE));
|
2004-06-16 15:07:58 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COPY_MODE,
|
|
|
|
g_param_spec_boolean ("copy_mode", "Copy mode",
|
|
|
|
"Don't send out HW buffers, send copy instead", DEFAULT_COPY_MODE,
|
|
|
|
G_PARAM_READWRITE));
|
2004-06-17 17:06:24 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_AUTOPROBE,
|
|
|
|
g_param_spec_boolean ("autoprobe", "Autoprobe",
|
|
|
|
"Whether the device should be probed for all possible features",
|
|
|
|
TRUE, G_PARAM_READWRITE));
|
2004-06-26 15:58:35 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LATENCY_OFFSET,
|
|
|
|
g_param_spec_int ("latency-offset", "Latency offset",
|
|
|
|
"A latency offset subtracted from timestamps set on buffers (in ns)",
|
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
/* signals */
|
|
|
|
gst_v4lsrc_signals[SIGNAL_FRAME_CAPTURE] =
|
2004-03-14 22:34:34 +00:00
|
|
|
g_signal_new ("frame-capture", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4lSrcClass, frame_capture), NULL,
|
|
|
|
NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-05-02 21:16:55 +00:00
|
|
|
gst_v4lsrc_signals[SIGNAL_FRAME_DROP] =
|
2004-03-14 22:34:34 +00:00
|
|
|
g_signal_new ("frame-drop", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstV4lSrcClass, frame_drop), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-05-02 21:16:55 +00:00
|
|
|
gst_v4lsrc_signals[SIGNAL_FRAME_INSERT] =
|
2004-03-14 22:34:34 +00:00
|
|
|
g_signal_new ("frame-insert", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4lSrcClass, frame_insert), NULL,
|
|
|
|
NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (v4lsrc_debug, "v4lsrc", 0, "V4L source element");
|
2001-12-17 19:03:14 +00:00
|
|
|
gobject_class->set_property = gst_v4lsrc_set_property;
|
|
|
|
gobject_class->get_property = gst_v4lsrc_get_property;
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_v4lsrc_change_state;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
gstelement_class->set_clock = gst_v4lsrc_set_clock;
|
2004-01-28 21:16:01 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lelement_class->open = gst_v4lsrc_open;
|
2004-01-28 21:16:01 +00:00
|
|
|
v4lelement_class->close = gst_v4lsrc_close;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_init (GstV4lSrc * v4lsrc)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2004-01-02 21:57:10 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (v4lsrc);
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_FLAG_SET (GST_ELEMENT (v4lsrc), GST_ELEMENT_THREAD_SUGGESTED);
|
2003-05-21 06:33:18 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
2004-03-15 19:32:28 +00:00
|
|
|
"src"), "src");
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (v4lsrc), v4lsrc->srcpad);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
gst_pad_set_get_function (v4lsrc->srcpad, gst_v4lsrc_get);
|
2003-05-10 14:36:34 +00:00
|
|
|
gst_pad_set_getcaps_function (v4lsrc->srcpad, gst_v4lsrc_getcaps);
|
2004-04-27 15:08:27 +00:00
|
|
|
gst_pad_set_fixate_function (v4lsrc->srcpad, gst_v4lsrc_fixate);
|
2004-06-17 17:06:24 +00:00
|
|
|
gst_pad_set_link_function (v4lsrc->srcpad, gst_v4lsrc_src_link);
|
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
|
|
|
gst_pad_set_convert_function (v4lsrc->srcpad, gst_v4lsrc_src_convert);
|
|
|
|
gst_pad_set_formats_function (v4lsrc->srcpad, gst_v4lsrc_get_formats);
|
|
|
|
gst_pad_set_query_function (v4lsrc->srcpad, gst_v4lsrc_src_query);
|
|
|
|
gst_pad_set_query_type_function (v4lsrc->srcpad, gst_v4lsrc_get_query_types);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-09-09 07:12:29 +00:00
|
|
|
v4lsrc->buffer_size = 0;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
/* no clock */
|
|
|
|
v4lsrc->clock = NULL;
|
|
|
|
|
2004-01-28 21:16:01 +00:00
|
|
|
/* no colourspaces */
|
|
|
|
v4lsrc->colourspaces = NULL;
|
|
|
|
|
2004-06-16 10:13:51 +00:00
|
|
|
v4lsrc->syncmode = DEFAULT_SYNC_MODE;
|
2004-06-16 15:07:58 +00:00
|
|
|
v4lsrc->copy_mode = DEFAULT_COPY_MODE;
|
2004-01-28 21:16:01 +00:00
|
|
|
|
|
|
|
v4lsrc->is_capturing = FALSE;
|
2004-06-17 17:06:24 +00:00
|
|
|
v4lsrc->autoprobe = TRUE;
|
2004-06-26 15:58:35 +00:00
|
|
|
|
|
|
|
v4lsrc->latency_offset = 0;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2004-01-28 21:16:01 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_open (GstElement * element, const gchar * device)
|
2004-01-28 21:16:01 +00:00
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (element);
|
2004-06-17 17:06:24 +00:00
|
|
|
GstV4lElement *v4l = GST_V4LELEMENT (v4lsrc);
|
|
|
|
gint width = v4l->vcap.minwidth;
|
|
|
|
gint height = v4l->vcap.minheight;
|
|
|
|
|
2004-01-28 21:16:01 +00:00
|
|
|
int palette[] = {
|
|
|
|
VIDEO_PALETTE_YUV422,
|
|
|
|
VIDEO_PALETTE_YUV420P,
|
|
|
|
VIDEO_PALETTE_UYVY,
|
|
|
|
VIDEO_PALETTE_YUV411P,
|
|
|
|
VIDEO_PALETTE_YUV422P,
|
|
|
|
VIDEO_PALETTE_YUV410P,
|
|
|
|
VIDEO_PALETTE_YUV411,
|
|
|
|
VIDEO_PALETTE_RGB555,
|
|
|
|
VIDEO_PALETTE_RGB565,
|
|
|
|
VIDEO_PALETTE_RGB24,
|
|
|
|
VIDEO_PALETTE_RGB32,
|
|
|
|
-1
|
|
|
|
}, i;
|
|
|
|
|
|
|
|
for (i = 0; palette[i] != -1; i++) {
|
|
|
|
/* try palette out */
|
2004-06-17 17:06:24 +00:00
|
|
|
if (!gst_v4lsrc_try_capture (v4lsrc, width, height, palette[i]))
|
2004-01-28 21:16:01 +00:00
|
|
|
continue;
|
|
|
|
v4lsrc->colourspaces = g_list_append (v4lsrc->colourspaces,
|
2004-03-15 19:32:28 +00:00
|
|
|
GINT_TO_POINTER (palette[i]));
|
2004-01-28 21:16:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_close (GstElement * element, const gchar * device)
|
2004-01-28 21:16:01 +00:00
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (element);
|
|
|
|
|
|
|
|
g_list_free (v4lsrc->colourspaces);
|
|
|
|
v4lsrc->colourspaces = NULL;
|
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-06-09 11:32:39 +00:00
|
|
|
/* get a list of possible framerates
|
|
|
|
* this is only done for webcams;
|
|
|
|
* other devices return NULL here.
|
|
|
|
*/
|
|
|
|
static GValue *
|
|
|
|
gst_v4lsrc_get_fps_list (GstV4lSrc * v4lsrc)
|
|
|
|
{
|
|
|
|
gint fps_index;
|
|
|
|
gfloat fps;
|
|
|
|
struct video_window *vwin = &GST_V4LELEMENT (v4lsrc)->vwin;
|
|
|
|
GstV4lElement *v4lelement = GST_V4LELEMENT (v4lsrc);
|
|
|
|
|
|
|
|
/* check if we have vwin window properties giving a framerate,
|
|
|
|
* as is done for webcams
|
|
|
|
* See http://www.smcc.demon.nl/webcam/api.html
|
|
|
|
* which is used for the Philips and qce-ga drivers */
|
|
|
|
fps_index = (vwin->flags >> 16) & 0x3F; /* 6 bit index for framerate */
|
|
|
|
|
|
|
|
/* webcams have a non-zero fps_index */
|
|
|
|
if (fps_index == 0) {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "fps_index is 0, no webcam");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "fps_index is %d, so webcam", fps_index);
|
|
|
|
|
|
|
|
{
|
|
|
|
gfloat current_fps;
|
|
|
|
int i;
|
|
|
|
GValue *list = NULL;
|
|
|
|
GValue value = { 0 };
|
|
|
|
|
|
|
|
/* webcam detected, so try all framerates and return a list */
|
|
|
|
|
|
|
|
list = g_new0 (GValue, 1);
|
|
|
|
g_value_init (list, GST_TYPE_LIST);
|
|
|
|
|
|
|
|
/* index of 16 corresponds to 15 fps */
|
|
|
|
current_fps = fps_index * 15.0 / 16;
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "device reports fps of %.4f", current_fps);
|
2004-06-15 09:11:06 +00:00
|
|
|
for (i = 0; i < 63; ++i) {
|
2004-06-09 11:32:39 +00:00
|
|
|
/* set bits 16 to 21 to 0 */
|
|
|
|
vwin->flags &= (0x3F00 - 1);
|
|
|
|
/* set bits 16 to 21 to the index */
|
|
|
|
vwin->flags |= i << 16;
|
|
|
|
if (gst_v4l_set_window_properties (v4lelement)) {
|
|
|
|
/* setting it succeeded. FIXME: get it and check. */
|
|
|
|
fps = i * 15.0 / 16;
|
|
|
|
g_value_init (&value, G_TYPE_DOUBLE);
|
|
|
|
g_value_set_double (&value, fps);
|
|
|
|
gst_value_list_append_value (list, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* FIXME: set back the original fps_index */
|
|
|
|
vwin->flags &= (0x3F00 - 1);
|
|
|
|
vwin->flags |= fps_index << 16;
|
|
|
|
gst_v4l_set_window_properties (v4lelement);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
static gfloat
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_get_fps (GstV4lSrc * v4lsrc)
|
2002-09-16 21:01:42 +00:00
|
|
|
{
|
|
|
|
gint norm;
|
2004-05-03 17:26:43 +00:00
|
|
|
gint fps_index;
|
2003-07-06 20:49:52 +00:00
|
|
|
gfloat fps;
|
2004-05-03 17:26:43 +00:00
|
|
|
struct video_window *vwin = &GST_V4LELEMENT (v4lsrc)->vwin;
|
|
|
|
|
|
|
|
/* check if we have vwin window properties giving a framerate,
|
|
|
|
* as is done for webcams
|
|
|
|
* See http://www.smcc.demon.nl/webcam/api.html
|
|
|
|
* which is used for the Philips and qce-ga drivers */
|
|
|
|
fps_index = (vwin->flags >> 16) & 0x3F; /* 6 bit index for framerate */
|
2004-06-09 11:32:39 +00:00
|
|
|
|
|
|
|
/* webcams have a non-zero fps_index */
|
|
|
|
if (fps_index != 0) {
|
|
|
|
gfloat current_fps;
|
|
|
|
|
2004-05-03 17:26:43 +00:00
|
|
|
/* index of 16 corresponds to 15 fps */
|
2004-06-09 11:32:39 +00:00
|
|
|
current_fps = fps_index * 15.0 / 16;
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "device reports fps of %.4f", current_fps);
|
2004-06-09 11:32:39 +00:00
|
|
|
return current_fps;
|
|
|
|
}
|
2002-09-16 21:01:42 +00:00
|
|
|
|
2004-06-16 10:13:51 +00:00
|
|
|
if (!(v4lsrc->syncmode == GST_V4LSRC_SYNC_MODE_FIXED_FPS) &&
|
|
|
|
v4lsrc->clock != NULL && v4lsrc->handled > 0) {
|
2003-05-02 21:16:55 +00:00
|
|
|
/* try to get time from clock master and calculate fps */
|
2004-03-14 22:34:34 +00:00
|
|
|
GstClockTime time =
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_clock_get_time (v4lsrc->clock) - v4lsrc->substract_time;
|
2003-05-02 21:16:55 +00:00
|
|
|
return v4lsrc->handled * GST_SECOND / time;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if that failed ... */
|
2002-09-16 21:01:42 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc)))
|
2003-05-02 21:16:55 +00:00
|
|
|
return 0.;
|
2002-09-16 21:01:42 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4l_get_chan_norm (GST_V4LELEMENT (v4lsrc), NULL, &norm))
|
2003-05-02 21:16:55 +00:00
|
|
|
return 0.;
|
2002-09-16 21:01:42 +00:00
|
|
|
|
|
|
|
if (norm == VIDEO_MODE_NTSC)
|
2004-03-14 22:34:34 +00:00
|
|
|
fps = 30000 / 1001;
|
2002-09-16 21:01:42 +00:00
|
|
|
else
|
|
|
|
fps = 25.;
|
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
return fps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_src_convert (GstPad * pad,
|
|
|
|
GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
|
2003-05-02 21:16:55 +00:00
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
|
|
|
gdouble fps;
|
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if ((fps = gst_v4lsrc_get_fps (v4lsrc)) == 0)
|
2003-05-02 21:16:55 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2002-09-16 21:01:42 +00:00
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:28 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_value = src_value * fps / GST_SECOND;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2002-09-16 21:01:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-05-24 10:46:31 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
2002-09-16 21:01:42 +00:00
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:28 +00:00
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*dest_value = src_value * GST_SECOND / fps;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2002-09-16 21:01:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_src_query (GstPad * pad,
|
|
|
|
GstQueryType type, GstFormat * format, gint64 * value)
|
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
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
|
|
|
gboolean res = TRUE;
|
|
|
|
gdouble fps;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if ((fps = gst_v4lsrc_get_fps (v4lsrc)) == 0)
|
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
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case GST_QUERY_POSITION:
|
|
|
|
switch (*format) {
|
2004-03-15 19:32:28 +00:00
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*value = v4lsrc->handled * GST_SECOND / fps;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*value = v4lsrc->handled;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
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
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2003-05-10 14:36:34 +00:00
|
|
|
static GstCaps *
|
2004-01-28 21:16:01 +00:00
|
|
|
gst_v4lsrc_palette_to_caps (int palette)
|
2003-05-10 14:36:34 +00:00
|
|
|
{
|
|
|
|
guint32 fourcc;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
switch (palette) {
|
|
|
|
case VIDEO_PALETTE_YUV422:
|
|
|
|
case VIDEO_PALETTE_YUYV:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
|
|
|
case VIDEO_PALETTE_YUV420P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
|
|
|
case VIDEO_PALETTE_UYVY:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
2004-01-06 20:15:21 +00:00
|
|
|
case VIDEO_PALETTE_YUV411P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_YUV411:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'P');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
2004-01-06 20:15:21 +00:00
|
|
|
case VIDEO_PALETTE_YUV422P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
|
|
|
case VIDEO_PALETTE_YUV410P:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB555:
|
|
|
|
case VIDEO_PALETTE_RGB565:
|
|
|
|
case VIDEO_PALETTE_RGB24:
|
|
|
|
case VIDEO_PALETTE_RGB32:
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
|
2003-05-10 14:36:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (fourcc == GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
|
2003-05-10 14:36:34 +00:00
|
|
|
switch (palette) {
|
|
|
|
case VIDEO_PALETTE_RGB555:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
|
|
|
"bpp = (int) 16, "
|
|
|
|
"depth = (int) 15, "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"red_mask = 0x7c00, " "green_mask = 0x03e0, " "blue_mask = 0x001f");
|
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB565:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
|
|
|
"bpp = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"red_mask = 0xf800, " "green_mask = 0x07f0, " "blue_mask = 0x001f");
|
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB24:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
|
|
|
"bpp = (int) 24, "
|
|
|
|
"depth = (int) 24, "
|
|
|
|
"endianness = (int) BIG_ENDIAN, "
|
|
|
|
"red_mask = 0xFF0000, "
|
|
|
|
"green_mask = 0x00FF00, " "blue_mask = 0x0000FF");
|
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
case VIDEO_PALETTE_RGB32:
|
2004-03-15 19:32:28 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb, "
|
|
|
|
"bpp = (int) 24, "
|
|
|
|
"depth = (int) 32, "
|
|
|
|
"endianness = (int) BIG_ENDIAN, "
|
|
|
|
"red_mask = 0xFF000000, "
|
|
|
|
"green_mask = 0x00FF0000, " "blue_mask = 0x0000FF00");
|
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
default:
|
2004-03-15 19:32:28 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
2003-12-22 01:47:09 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
2004-03-15 19:32:28 +00:00
|
|
|
"format", GST_TYPE_FOURCC, fourcc, NULL);
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-06-17 17:06:24 +00:00
|
|
|
gst_v4lsrc_src_link (GstPad * pad, const GstCaps * vscapslist)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
2003-12-22 01:47:09 +00:00
|
|
|
guint32 fourcc;
|
2004-01-06 20:15:21 +00:00
|
|
|
gint bpp, depth, w, h, palette = -1;
|
|
|
|
gdouble fps;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2004-01-28 21:16:01 +00:00
|
|
|
gboolean was_capturing;
|
2004-06-17 17:06:24 +00:00
|
|
|
struct video_window *vwin;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
2004-06-17 17:06:24 +00:00
|
|
|
vwin = &GST_V4LELEMENT (v4lsrc)->vwin;
|
2004-01-28 21:16:01 +00:00
|
|
|
was_capturing = v4lsrc->is_capturing;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2002-09-09 07:12:29 +00:00
|
|
|
/* in case the buffers are active (which means that we already
|
|
|
|
* did capsnego before and didn't clean up), clean up anyways */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc))) {
|
2004-01-28 21:16:01 +00:00
|
|
|
if (was_capturing) {
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_stop (v4lsrc))
|
2004-03-15 19:32:28 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2004-01-28 21:16:01 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_deinit (v4lsrc))
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2004-03-14 22:34:34 +00:00
|
|
|
} else if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_DELAYED;
|
2002-09-18 10:57:56 +00:00
|
|
|
}
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (vscapslist, 0);
|
2002-03-30 17:06:26 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!strcmp (gst_structure_get_name (structure), "video/x-raw-yuv"))
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_fourcc (structure, "format", &fourcc);
|
|
|
|
else
|
2004-03-14 22:34:34 +00:00
|
|
|
fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_int (structure, "width", &w);
|
|
|
|
gst_structure_get_int (structure, "height", &h);
|
2004-01-06 20:15:21 +00:00
|
|
|
gst_structure_get_double (structure, "framerate", &fps);
|
|
|
|
|
2004-06-09 11:32:39 +00:00
|
|
|
/* set framerate if it's not already correct */
|
|
|
|
if (fps != gst_v4lsrc_get_fps (v4lsrc)) {
|
|
|
|
int fps_index = fps / 15.0 * 16;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "Trying to set fps index %d", fps_index);
|
|
|
|
/* set bits 16 to 21 to 0 */
|
|
|
|
vwin->flags &= (0x3F00 - 1);
|
|
|
|
/* set bits 16 to 21 to the index */
|
|
|
|
vwin->flags |= fps_index << 16;
|
|
|
|
if (!gst_v4l_set_window_properties (GST_V4LELEMENT (v4lsrc))) {
|
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Could not set framerate of %d fps", fps));
|
|
|
|
}
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (fourcc) {
|
|
|
|
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV420P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * ((h + 1) & ~1) * 1.5;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV422;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_UYVY;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
|
2004-01-06 20:15:21 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV411P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 3) & ~3) * h * 1.5;
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
|
2003-12-22 01:47:09 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV411;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 3) & ~3) * h * 1.5;
|
2003-12-22 01:47:09 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
|
2004-01-06 20:15:21 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV410P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 3) & ~3) * ((h + 3) & ~3) * 1.125;
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
|
2004-01-06 20:15:21 +00:00
|
|
|
palette = VIDEO_PALETTE_YUV422P;
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->buffer_size = ((w + 1) & ~1) * h * 2;
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
|
2004-01-06 20:15:21 +00:00
|
|
|
gst_structure_get_int (structure, "depth", &depth);
|
2004-03-14 22:34:34 +00:00
|
|
|
switch (depth) {
|
2004-03-15 19:32:28 +00:00
|
|
|
case 15:
|
|
|
|
palette = VIDEO_PALETTE_RGB555;
|
|
|
|
v4lsrc->buffer_size = w * h * 2;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
palette = VIDEO_PALETTE_RGB565;
|
|
|
|
v4lsrc->buffer_size = w * h * 2;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
gst_structure_get_int (structure, "bpp", &bpp);
|
|
|
|
switch (bpp) {
|
|
|
|
case 24:
|
|
|
|
palette = VIDEO_PALETTE_RGB24;
|
|
|
|
v4lsrc->buffer_size = w * h * 3;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
palette = VIDEO_PALETTE_RGB32;
|
|
|
|
v4lsrc->buffer_size = w * h * 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
2003-12-22 01:47:09 +00:00
|
|
|
default:
|
2004-01-06 20:15:21 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-01-20 16:03:10 +00:00
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
if (palette == -1) {
|
2004-06-17 17:43:18 +00:00
|
|
|
GST_WARNING_OBJECT (v4lsrc, "palette is -1, refusing link");
|
2004-06-17 17:06:24 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "trying to set_capture %dx%d, palette %d",
|
|
|
|
w, h, palette);
|
|
|
|
if (!gst_v4lsrc_set_capture (v4lsrc, w, h, palette)) {
|
2004-06-17 17:43:18 +00:00
|
|
|
GST_WARNING_OBJECT (v4lsrc, "could not set_capture %dx%d, palette %d",
|
2004-06-17 17:06:24 +00:00
|
|
|
w, h, palette);
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2004-06-17 17:06:24 +00:00
|
|
|
}
|
2002-09-20 09:28:46 +00:00
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
/* first try the negotiated settings using try_capture */
|
|
|
|
if (!gst_v4lsrc_try_capture (v4lsrc, w, h, palette)) {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "failed trying palette %d for w/h", palette);
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
|
|
|
if (!gst_v4l_get_capabilities (GST_V4LELEMENT (v4lsrc)))
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "failed getting capabilities");
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "done checking, with w %d h %d palette %d\n",
|
|
|
|
vwin->width, vwin->height, palette);
|
|
|
|
if (vwin->width != v4lsrc->mmap.width) {
|
|
|
|
/* We consider this a device error since it was called with fixed
|
|
|
|
* caps that the device doesn't accept. Still, there should be
|
|
|
|
* a way to handle this more gracefully, maybe provide a fixate
|
|
|
|
* function */
|
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Tried setting %dx%d but got %dx%d back as suggestion",
|
|
|
|
v4lsrc->mmap.width, v4lsrc->mmap.height, vwin->width,
|
|
|
|
vwin->height));
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
|
|
|
if (vwin->height != v4lsrc->mmap.height) {
|
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SETTINGS, (NULL),
|
|
|
|
("Tried setting %dx%d but got %dx%d back as suggestion",
|
|
|
|
v4lsrc->mmap.width, v4lsrc->mmap.height, vwin->width,
|
|
|
|
vwin->height));
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2004-06-17 17:06:24 +00:00
|
|
|
}
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_init (v4lsrc))
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-01-28 21:16:01 +00:00
|
|
|
if (was_capturing) {
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_start (v4lsrc))
|
2004-01-28 21:16:01 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
|
|
|
|
2004-01-06 20:15:21 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2004-04-27 15:08:27 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_v4lsrc_fixate (GstPad * pad, const GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
GstCaps *newcaps;
|
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
|
|
|
struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
|
|
|
|
|
|
|
|
if (gst_caps_get_size (caps) > 1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!vcap) {
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "don't have device caps, cannot fixate");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
newcaps = gst_caps_copy (caps);
|
|
|
|
structure = gst_caps_get_structure (newcaps, 0);
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "device reported w: %d-%d, h: %d-%d",
|
|
|
|
vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight);
|
|
|
|
|
|
|
|
if (gst_caps_structure_fixate_field_nearest_int (structure, "width",
|
|
|
|
vcap->maxwidth)) {
|
|
|
|
return newcaps;
|
|
|
|
}
|
|
|
|
if (gst_caps_structure_fixate_field_nearest_int (structure, "height",
|
|
|
|
vcap->maxheight)) {
|
|
|
|
return newcaps;
|
|
|
|
}
|
|
|
|
gst_caps_free (newcaps);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-05-10 14:36:34 +00:00
|
|
|
static GstCaps *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_getcaps (GstPad * pad)
|
2003-05-10 14:36:34 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
GstCaps *list;
|
2004-03-14 22:34:34 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
|
|
|
struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
|
2004-06-09 11:32:39 +00:00
|
|
|
gfloat fps = 0.0;
|
2004-01-28 21:16:01 +00:00
|
|
|
GList *item;
|
2004-06-09 11:32:39 +00:00
|
|
|
static GValue *fps_list; /* FIXME: this should be done in a hash table
|
|
|
|
* on device name instead */
|
2003-05-10 14:36:34 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
|
2004-01-06 20:15:21 +00:00
|
|
|
return gst_caps_new_any ();
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
2004-06-17 17:06:24 +00:00
|
|
|
if (!v4lsrc->autoprobe) {
|
|
|
|
/* FIXME: query current caps and return those, with _any appended */
|
|
|
|
return gst_caps_new_any ();
|
|
|
|
}
|
|
|
|
|
2004-06-09 11:32:39 +00:00
|
|
|
/* if not cached from last run, get it */
|
|
|
|
if (!fps_list)
|
|
|
|
fps_list = gst_v4lsrc_get_fps_list (v4lsrc);
|
|
|
|
if (!fps_list)
|
|
|
|
fps = gst_v4lsrc_get_fps (v4lsrc);
|
2004-05-03 17:26:43 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
list = gst_caps_new_empty ();
|
2004-01-28 21:16:01 +00:00
|
|
|
for (item = v4lsrc->colourspaces; item != NULL; item = item->next) {
|
2003-05-10 14:36:34 +00:00
|
|
|
GstCaps *one;
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
one = gst_v4lsrc_palette_to_caps (GPOINTER_TO_INT (item->data));
|
2004-01-28 21:16:01 +00:00
|
|
|
if (!one)
|
2004-03-14 22:34:34 +00:00
|
|
|
g_print ("Palette %d gave no caps\n", GPOINTER_TO_INT (item->data));
|
2004-05-03 16:46:03 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc,
|
|
|
|
"Device reports w: %d-%d, h: %d-%d, fps: %f for palette %d",
|
|
|
|
vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight, fps,
|
|
|
|
GPOINTER_TO_INT (item->data));
|
|
|
|
|
2004-04-27 15:08:27 +00:00
|
|
|
gst_caps_set_simple (one, "width", GST_TYPE_INT_RANGE, vcap->minwidth,
|
|
|
|
vcap->maxwidth, "height", GST_TYPE_INT_RANGE, vcap->minheight,
|
2004-06-09 11:32:39 +00:00
|
|
|
vcap->maxheight, NULL);
|
|
|
|
|
|
|
|
if (fps_list) {
|
|
|
|
GstStructure *structure = gst_caps_get_structure (one, 0);
|
|
|
|
|
|
|
|
gst_structure_set_value (structure, "framerate", fps_list);
|
|
|
|
} else {
|
|
|
|
GstStructure *structure = gst_caps_get_structure (one, 0);
|
|
|
|
|
|
|
|
gst_structure_set (structure, "framerate", G_TYPE_DOUBLE, fps, NULL);
|
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "caps: %" GST_PTR_FORMAT, one);
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_caps_append (list, one);
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
static GstData *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_get (GstPad * pad)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
2001-12-23 15:31:15 +00:00
|
|
|
GstBuffer *buf;
|
|
|
|
gint num;
|
2003-05-02 21:16:55 +00:00
|
|
|
gdouble fps = 0.;
|
2004-04-27 11:33:52 +00:00
|
|
|
v4lsrc_private_t *v4lsrc_private = NULL;
|
2004-05-13 10:13:41 +00:00
|
|
|
GstClockTime now, until;
|
2004-06-16 10:13:51 +00:00
|
|
|
gboolean fixed_fps;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (pad != NULL, NULL);
|
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
|
2004-06-15 09:11:06 +00:00
|
|
|
fps = gst_v4lsrc_get_fps (v4lsrc);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-06-16 10:13:51 +00:00
|
|
|
fixed_fps = v4lsrc->syncmode == GST_V4LSRC_SYNC_MODE_FIXED_FPS;
|
|
|
|
|
|
|
|
if (fixed_fps && fps == 0.0)
|
2003-05-02 21:16:55 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (v4lsrc->need_writes > 0) {
|
|
|
|
/* use last frame */
|
|
|
|
num = v4lsrc->last_frame;
|
|
|
|
v4lsrc->need_writes--;
|
2004-06-16 10:13:51 +00:00
|
|
|
} else if (v4lsrc->clock && fixed_fps) {
|
2003-05-02 21:16:55 +00:00
|
|
|
GstClockTime time;
|
|
|
|
gboolean have_frame = FALSE;
|
|
|
|
|
|
|
|
do {
|
|
|
|
/* by default, we use the frame once */
|
|
|
|
v4lsrc->need_writes = 1;
|
|
|
|
|
|
|
|
/* grab a frame from the device */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_grab_frame (v4lsrc, &num))
|
2004-03-15 19:32:28 +00:00
|
|
|
return NULL;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
v4lsrc->last_frame = num;
|
2003-05-21 06:33:18 +00:00
|
|
|
time = v4lsrc->timestamp_sync - v4lsrc->substract_time;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
/* decide how often we're going to write the frame - set
|
|
|
|
* v4lsrc->need_writes to (that-1) and have_frame to TRUE
|
|
|
|
* if we're going to write it - else, just continue.
|
|
|
|
*
|
|
|
|
* time is generally the system or audio clock. Let's
|
|
|
|
* say that we've written one second of audio, then we want
|
|
|
|
* to have written one second of video too, within the same
|
|
|
|
* timeframe. This means that if time - begin_time = X sec,
|
|
|
|
* we want to have written X*fps frames. If we've written
|
|
|
|
* more - drop, if we've written less - dup... */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (v4lsrc->handled * (GST_SECOND / fps) - time >
|
2004-03-15 19:32:28 +00:00
|
|
|
1.5 * (GST_SECOND / fps)) {
|
|
|
|
/* yo dude, we've got too many frames here! Drop! DROP! */
|
|
|
|
v4lsrc->need_writes--; /* -= (v4lsrc->handled - (time / fps)); */
|
|
|
|
g_signal_emit (G_OBJECT (v4lsrc),
|
|
|
|
gst_v4lsrc_signals[SIGNAL_FRAME_DROP], 0);
|
2004-03-14 22:34:34 +00:00
|
|
|
} else if (v4lsrc->handled * (GST_SECOND / fps) - time <
|
2004-03-15 19:32:28 +00:00
|
|
|
-1.5 * (GST_SECOND / fps)) {
|
|
|
|
/* this means we're lagging far behind */
|
|
|
|
v4lsrc->need_writes++; /* += ((time / fps) - v4lsrc->handled); */
|
|
|
|
g_signal_emit (G_OBJECT (v4lsrc),
|
|
|
|
gst_v4lsrc_signals[SIGNAL_FRAME_INSERT], 0);
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (v4lsrc->need_writes > 0) {
|
2004-03-15 19:32:28 +00:00
|
|
|
have_frame = TRUE;
|
|
|
|
v4lsrc->use_num_times[num] = v4lsrc->need_writes;
|
|
|
|
v4lsrc->need_writes--;
|
2003-05-02 21:16:55 +00:00
|
|
|
} else {
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_v4lsrc_requeue_frame (v4lsrc, num);
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
} while (!have_frame);
|
|
|
|
} else {
|
|
|
|
/* grab a frame from the device */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_grab_frame (v4lsrc, &num))
|
2003-05-02 21:16:55 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
v4lsrc->use_num_times[num] = 1;
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
buf = gst_buffer_new ();
|
2004-01-12 03:21:40 +00:00
|
|
|
GST_BUFFER_FREE_DATA_FUNC (buf) = gst_v4lsrc_buffer_free;
|
2004-04-27 11:33:52 +00:00
|
|
|
/* to requeue buffers, we need a ref to the element, as well as the frame
|
|
|
|
number we got this buffer from */
|
|
|
|
v4lsrc_private = g_malloc (sizeof (v4lsrc_private_t));
|
|
|
|
v4lsrc_private->v4lsrc = v4lsrc;
|
|
|
|
v4lsrc_private->num = num;
|
|
|
|
GST_BUFFER_PRIVATE (buf) = v4lsrc_private;
|
|
|
|
|
2004-06-16 15:07:58 +00:00
|
|
|
/* don't | the flags, they are integers, not bits!! */
|
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY);
|
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_BUFFER_DATA (buf) = gst_v4lsrc_get_buffer (v4lsrc, num);
|
2004-01-06 20:15:21 +00:00
|
|
|
GST_BUFFER_MAXSIZE (buf) = v4lsrc->mbuf.size / v4lsrc->mbuf.frames;
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_BUFFER_SIZE (buf) = v4lsrc->buffer_size;
|
2004-06-16 10:13:51 +00:00
|
|
|
|
2004-06-16 15:07:58 +00:00
|
|
|
if (v4lsrc->copy_mode) {
|
|
|
|
GstBuffer *copy = gst_buffer_copy (buf);
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
buf = copy;
|
|
|
|
}
|
2004-06-16 10:13:51 +00:00
|
|
|
|
|
|
|
switch (v4lsrc->syncmode) {
|
|
|
|
case GST_V4LSRC_SYNC_MODE_FIXED_FPS:
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = v4lsrc->handled * GST_SECOND / fps;
|
|
|
|
break;
|
|
|
|
case GST_V4LSRC_SYNC_MODE_PRIVATE_CLOCK:
|
|
|
|
/* calculate time based on our own clock */
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) =
|
|
|
|
v4lsrc->timestamp_sync - v4lsrc->substract_time;
|
|
|
|
break;
|
|
|
|
case GST_V4LSRC_SYNC_MODE_CLOCK:
|
|
|
|
if (v4lsrc->clock) {
|
|
|
|
GstClockTime time = gst_element_get_time (GST_ELEMENT (v4lsrc));
|
2004-06-26 15:58:35 +00:00
|
|
|
GstClockTimeDiff target_ts = 0;
|
|
|
|
|
|
|
|
/* we can't go negative for timestamps. FIXME: latency querying
|
|
|
|
* in the core generally should solve this */
|
|
|
|
target_ts = GST_CLOCK_DIFF (time, v4lsrc->latency_offset);
|
|
|
|
if (target_ts < 0)
|
|
|
|
target_ts = 0;
|
|
|
|
/* FIXME: create GST_TIME_DIFF_ARGS for target_ts */
|
|
|
|
GST_LOG_OBJECT (v4lsrc, "time: %" GST_TIME_FORMAT
|
|
|
|
", latency-offset: %" GST_TIME_FORMAT
|
|
|
|
", timestamp: %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (time), GST_TIME_ARGS (v4lsrc->latency_offset),
|
|
|
|
GST_TIME_ARGS (target_ts));
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = target_ts;
|
2004-06-16 10:13:51 +00:00
|
|
|
} else {
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_V4LSRC_SYNC_MODE_NONE:
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-05-13 10:13:41 +00:00
|
|
|
}
|
2004-06-16 10:13:51 +00:00
|
|
|
GST_BUFFER_DURATION (buf) = GST_SECOND / fps;
|
|
|
|
|
2004-05-13 10:13:41 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "outgoing buffer duration: %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
v4lsrc->handled++;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_signal_emit (G_OBJECT (v4lsrc),
|
|
|
|
gst_v4lsrc_signals[SIGNAL_FRAME_CAPTURE], 0);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
/* this is the current timestamp */
|
2004-05-13 10:13:41 +00:00
|
|
|
now = gst_element_get_time (GST_ELEMENT (v4lsrc));
|
2004-06-15 09:11:06 +00:00
|
|
|
|
|
|
|
until = GST_BUFFER_TIMESTAMP (buf);
|
2004-05-13 10:13:41 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (v4lsrc, "Current time %" GST_TIME_FORMAT
|
|
|
|
", buffer timestamp %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (now), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
|
|
|
if (now < until) {
|
|
|
|
GST_LOG_OBJECT (v4lsrc, "waiting until %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (until));
|
|
|
|
if (!gst_element_wait (GST_ELEMENT (v4lsrc), until))
|
2004-06-15 09:11:06 +00:00
|
|
|
g_warning ("waiting from now %" GST_TIME_FORMAT
|
|
|
|
" until %" GST_TIME_FORMAT " failed",
|
|
|
|
GST_TIME_ARGS (now), GST_TIME_ARGS (until));
|
|
|
|
GST_LOG_OBJECT (v4lsrc, "wait done.");
|
2004-05-13 10:13:41 +00:00
|
|
|
}
|
|
|
|
/* check for discont; we do it after grabbing so that we drop the
|
|
|
|
* first frame grabbed, but get an accurate discont event */
|
|
|
|
if (v4lsrc->need_discont) {
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
v4lsrc->need_discont = FALSE;
|
|
|
|
|
|
|
|
/* drop the buffer we made */
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
/* get time for discont */
|
|
|
|
now = gst_element_get_time (GST_ELEMENT (v4lsrc));
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "sending time discont with %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (now));
|
|
|
|
|
|
|
|
/* store discont internally so we can wait when sending buffers too soon */
|
|
|
|
v4lsrc->last_discont = now;
|
|
|
|
|
|
|
|
/* return event */
|
|
|
|
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, now, NULL);
|
|
|
|
return GST_DATA (event);
|
|
|
|
}
|
2003-10-08 16:08:22 +00:00
|
|
|
return GST_DATA (buf);
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_return_if_fail (GST_IS_V4LSRC (object));
|
|
|
|
v4lsrc = GST_V4LSRC (object);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2004-06-16 10:13:51 +00:00
|
|
|
case ARG_SYNC_MODE:
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc))) {
|
2004-06-16 10:13:51 +00:00
|
|
|
v4lsrc->syncmode = g_value_get_enum (value);
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-06-16 15:07:58 +00:00
|
|
|
case ARG_COPY_MODE:
|
|
|
|
v4lsrc->copy_mode = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
case ARG_AUTOPROBE:
|
|
|
|
if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc))) {
|
|
|
|
v4lsrc->autoprobe = g_value_get_boolean (value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-06-26 15:58:35 +00:00
|
|
|
case ARG_LATENCY_OFFSET:
|
|
|
|
v4lsrc->latency_offset = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
default:
|
2002-01-15 15:52:09 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_return_if_fail (GST_IS_V4LSRC (object));
|
|
|
|
v4lsrc = GST_V4LSRC (object);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2002-01-07 09:31:34 +00:00
|
|
|
case ARG_NUMBUFS:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_int (value, v4lsrc->mbuf.frames);
|
2002-01-07 09:31:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ARG_BUFSIZE:
|
2002-04-14 10:27:10 +00:00
|
|
|
if (v4lsrc->mbuf.frames == 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
g_value_set_int (value, 0);
|
2002-04-14 10:27:10 +00:00
|
|
|
else
|
2004-03-15 19:32:28 +00:00
|
|
|
g_value_set_int (value,
|
|
|
|
v4lsrc->mbuf.size / (v4lsrc->mbuf.frames * 1024));
|
2002-01-07 09:31:34 +00:00
|
|
|
break;
|
|
|
|
|
2004-06-16 10:13:51 +00:00
|
|
|
case ARG_SYNC_MODE:
|
|
|
|
g_value_set_enum (value, v4lsrc->syncmode);
|
2003-05-02 21:16:55 +00:00
|
|
|
break;
|
|
|
|
|
2004-06-16 15:07:58 +00:00
|
|
|
case ARG_COPY_MODE:
|
|
|
|
g_value_set_boolean (value, v4lsrc->copy_mode);
|
|
|
|
break;
|
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
case ARG_AUTOPROBE:
|
|
|
|
g_value_set_boolean (value, v4lsrc->autoprobe);
|
|
|
|
break;
|
|
|
|
|
2004-06-26 15:58:35 +00:00
|
|
|
case ARG_LATENCY_OFFSET:
|
|
|
|
g_value_set_int (value, v4lsrc->latency_offset);
|
|
|
|
break;
|
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
default:
|
2002-01-15 15:52:09 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-17 19:03:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_change_state (GstElement * element)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
2003-05-02 21:16:55 +00:00
|
|
|
GTimeVal time;
|
2002-01-20 16:03:10 +00:00
|
|
|
gint transition = GST_STATE_TRANSITION (element);
|
2002-01-04 23:58:11 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_return_val_if_fail (GST_IS_V4LSRC (element), GST_STATE_FAILURE);
|
|
|
|
|
|
|
|
v4lsrc = GST_V4LSRC (element);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2002-01-20 16:03:10 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
break;
|
2001-12-28 19:54:23 +00:00
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
2003-05-02 21:16:55 +00:00
|
|
|
v4lsrc->handled = 0;
|
2004-05-13 10:13:41 +00:00
|
|
|
v4lsrc->need_discont = TRUE;
|
|
|
|
v4lsrc->last_discont = 0;
|
2003-05-02 21:16:55 +00:00
|
|
|
v4lsrc->need_writes = 0;
|
|
|
|
v4lsrc->last_frame = 0;
|
|
|
|
v4lsrc->substract_time = 0;
|
2002-09-09 07:12:29 +00:00
|
|
|
/* buffer setup used to be done here, but I moved it to
|
|
|
|
* capsnego */
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
2001-12-28 19:54:23 +00:00
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
2001-12-23 15:31:15 +00:00
|
|
|
/* queue all buffer, start streaming capture */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_start (v4lsrc))
|
2004-03-15 19:32:28 +00:00
|
|
|
return GST_STATE_FAILURE;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_get_current_time (&time);
|
|
|
|
v4lsrc->substract_time =
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_TIMEVAL_TO_TIME (time) - v4lsrc->substract_time;
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
2001-12-28 19:54:23 +00:00
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
|
|
|
/* de-queue all queued buffers */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_stop (v4lsrc))
|
2004-03-15 19:32:28 +00:00
|
|
|
return GST_STATE_FAILURE;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_get_current_time (&time);
|
|
|
|
v4lsrc->substract_time =
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_TIMEVAL_TO_TIME (time) - v4lsrc->substract_time;
|
2001-12-28 19:54:23 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
/* stop capturing, unmap all buffers */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_capture_deinit (v4lsrc))
|
2004-03-15 19:32:28 +00:00
|
|
|
return GST_STATE_FAILURE;
|
2001-12-28 19:54:23 +00:00
|
|
|
break;
|
2002-01-20 16:03:10 +00:00
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
break;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2002-01-04 23:58:11 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
2003-05-02 21:16:55 +00:00
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
2002-01-04 23:58:11 +00:00
|
|
|
|
2001-12-17 19:03:14 +00:00
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
#if 0
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstBuffer *
|
|
|
|
gst_v4lsrc_buffer_new (GstBufferPool * pool,
|
|
|
|
guint64 offset, guint size, gpointer user_data)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
2004-03-14 22:34:34 +00:00
|
|
|
GstV4lSrc *v4lsrc = GST_V4LSRC (user_data);
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc)))
|
2002-09-20 09:28:46 +00:00
|
|
|
return NULL;
|
2001-12-17 19:03:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
buffer = gst_buffer_new ();
|
2002-09-20 09:28:46 +00:00
|
|
|
if (!buffer)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* TODO: add interlacing info to buffer as metadata
|
|
|
|
* (height>288 or 240 = topfieldfirst, else noninterlaced) */
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_BUFFER_MAXSIZE (buffer) = v4lsrc->mbuf.size / v4lsrc->mbuf.frames;
|
|
|
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return buffer;
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
#endif
|
2001-12-17 19:03:14 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_buffer_free (GstBuffer * buf)
|
2001-12-17 19:03:14 +00:00
|
|
|
{
|
2004-04-27 11:33:52 +00:00
|
|
|
v4lsrc_private_t *v4lsrc_private;
|
|
|
|
GstV4lSrc *v4lsrc;
|
|
|
|
int num;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
v4lsrc_private = GST_BUFFER_PRIVATE (buf);
|
|
|
|
g_assert (v4lsrc_private);
|
|
|
|
v4lsrc = v4lsrc_private->v4lsrc;
|
|
|
|
num = v4lsrc_private->num;
|
|
|
|
g_free (v4lsrc_private);
|
|
|
|
GST_BUFFER_PRIVATE (buf) = 0;
|
|
|
|
|
2004-05-03 17:26:43 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "freeing buffer %p with refcount %d for frame %d",
|
2004-04-27 11:33:52 +00:00
|
|
|
buf, GST_BUFFER_REFCOUNT_VALUE (buf), num);
|
2004-03-14 22:34:34 +00:00
|
|
|
if (gst_element_get_state (GST_ELEMENT (v4lsrc)) != GST_STATE_PLAYING)
|
2004-03-15 19:32:28 +00:00
|
|
|
return; /* we've already cleaned up ourselves */
|
2002-09-20 09:28:46 +00:00
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
v4lsrc->use_num_times[num]--;
|
|
|
|
if (v4lsrc->use_num_times[num] <= 0) {
|
2004-05-03 17:26:43 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "requeueing frame %d", num);
|
2004-04-27 11:33:52 +00:00
|
|
|
gst_v4lsrc_requeue_frame (v4lsrc, num);
|
|
|
|
}
|
2001-12-17 19:03:14 +00:00
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_set_clock (GstElement * element, GstClock * clock)
|
2003-05-02 21:16:55 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4LSRC (element)->clock = clock;
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|