2004-06-15 09:11:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* gstv4lmjpegsrc.c: hardware MJPEG video source plugin
|
|
|
|
*
|
2002-01-31 22:22:42 +00:00
|
|
|
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2001-12-23 15:31:15 +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-23 15:31:15 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include "v4lmjpegsrc_calls.h"
|
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_CATEGORY (v4lmjpegsrc_debug);
|
|
|
|
#define GST_CAT_DEFAULT v4lmjpegsrc_debug
|
|
|
|
|
2002-09-18 19:02:52 +00:00
|
|
|
/* elementfactory information */
|
2006-04-28 19:46:37 +00:00
|
|
|
static const GstElementDetails gst_v4lmjpegsrc_details =
|
2006-03-24 10:42:11 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Video (video4linux/MJPEG) Source",
|
|
|
|
"Source/Video",
|
|
|
|
"Reads MJPEG-encoded frames from a zoran MJPEG/video4linux device",
|
2009-08-24 18:34:35 +00:00
|
|
|
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* V4lMjpegSrc signals and args */
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-05-02 21:16:55 +00:00
|
|
|
SIGNAL_FRAME_CAPTURE,
|
|
|
|
SIGNAL_FRAME_DROP,
|
|
|
|
SIGNAL_FRAME_INSERT,
|
|
|
|
SIGNAL_FRAME_LOST,
|
2001-12-23 15:31:15 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* arguments */
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 15:31:15 +00:00
|
|
|
ARG_0,
|
2003-05-10 14:36:34 +00:00
|
|
|
#if 0
|
2001-12-23 15:31:15 +00:00
|
|
|
ARG_X_OFFSET,
|
|
|
|
ARG_Y_OFFSET,
|
|
|
|
ARG_F_WIDTH,
|
|
|
|
ARG_F_HEIGHT,
|
2003-05-10 14:36:34 +00:00
|
|
|
/* normally, we would want to use subframe capture, however,
|
|
|
|
* for the time being it's easier if we disable it first */
|
|
|
|
#endif
|
2001-12-23 15:31:15 +00:00
|
|
|
ARG_QUALITY,
|
|
|
|
ARG_NUMBUFS,
|
2003-05-21 06:33:18 +00:00
|
|
|
ARG_BUFSIZE,
|
2003-05-02 21:16:55 +00:00
|
|
|
ARG_USE_FIXED_FPS
|
2001-12-23 15:31:15 +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_v4lmjpegsrc_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_v4lmjpegsrc_get_query_types,
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_QUERY_POSITION);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* init functions */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lmjpegsrc_base_init (gpointer g_class);
|
|
|
|
static void gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass * klass);
|
|
|
|
static void gst_v4lmjpegsrc_init (GstV4lMjpegSrc * v4lmjpegsrc);
|
2001-12-23 15:31:15 +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_v4lmjpegsrc_src_convert (GstPad * pad,
|
|
|
|
GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
|
|
|
static gboolean gst_v4lmjpegsrc_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-03-14 22:34:34 +00:00
|
|
|
static GstPadLinkReturn gst_v4lmjpegsrc_srcconnect (GstPad * pad,
|
|
|
|
const GstCaps * caps);
|
|
|
|
static GstData *gst_v4lmjpegsrc_get (GstPad * pad);
|
|
|
|
static GstCaps *gst_v4lmjpegsrc_getcaps (GstPad * pad);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* get/set params */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lmjpegsrc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_v4lmjpegsrc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2001-12-23 15:31:15 +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_v4lmjpegsrc_set_clock (GstElement * element, GstClock * clock);
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* state handling */
|
2005-09-02 15:43:18 +00:00
|
|
|
static GstStateChangeReturn gst_v4lmjpegsrc_change_state (GstElement * element);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-01-06 20:15:21 +00:00
|
|
|
/* requeue buffer after use */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_v4lmjpegsrc_buffer_free (GstBuffer * buffer);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2003-05-02 21:16:55 +00:00
|
|
|
static guint gst_v4lmjpegsrc_signals[LAST_SIGNAL] = { 0 };
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gst_v4lmjpegsrc_get_type (void)
|
|
|
|
{
|
|
|
|
static GType v4lmjpegsrc_type = 0;
|
|
|
|
|
|
|
|
if (!v4lmjpegsrc_type) {
|
|
|
|
static const GTypeInfo v4lmjpegsrc_info = {
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstV4lMjpegSrcClass),
|
2003-11-02 14:47:52 +00:00
|
|
|
gst_v4lmjpegsrc_base_init,
|
2001-12-23 15:31:15 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GClassInitFunc) gst_v4lmjpegsrc_class_init,
|
2001-12-23 15:31:15 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:34 +00:00
|
|
|
sizeof (GstV4lMjpegSrc),
|
2001-12-23 15:31:15 +00:00
|
|
|
0,
|
2004-03-14 22:34:34 +00:00
|
|
|
(GInstanceInitFunc) gst_v4lmjpegsrc_init,
|
2001-12-23 15:31:15 +00:00
|
|
|
NULL
|
|
|
|
};
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc_type =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_type_register_static (GST_TYPE_V4LELEMENT, "GstV4lMjpegSrc",
|
|
|
|
&v4lmjpegsrc_info, 0);
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
return v4lmjpegsrc_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-02 14:47:52 +00:00
|
|
|
static void
|
|
|
|
gst_v4lmjpegsrc_base_init (gpointer g_class)
|
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
GST_STATIC_CAPS ("image/jpeg, "
|
2004-03-15 19:32:28 +00:00
|
|
|
"width = (int) [ 0, MAX ], "
|
2005-11-22 23:39:12 +00:00
|
|
|
"height = (int) [ 0, MAX ], " "framerate = (fraction) [ 0, MAX ]")
|
2004-03-14 22:34:34 +00:00
|
|
|
);
|
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_v4lmjpegsrc_details);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&src_template));
|
2003-11-02 14:47:52 +00:00
|
|
|
}
|
2009-08-24 18:34:35 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass * klass)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2006-04-08 21:02:53 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-05-10 14:36:34 +00:00
|
|
|
#if 0
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_X_OFFSET,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_int ("x-offset", "x_offset", "x_offset",
|
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_Y_OFFSET,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_int ("y-offset", "y_offset", "y_offset",
|
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_F_WIDTH,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_int ("frame-width", "frame_width", "frame_width",
|
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_F_HEIGHT,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_int ("frame-height", "frame_height", "frame_height",
|
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
2003-05-10 14:36:34 +00:00
|
|
|
#endif
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
|
|
|
|
g_param_spec_int ("quality", "Quality", "JPEG frame quality",
|
2008-03-22 15:00:53 +00:00
|
|
|
1, 100, 50, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUMBUFS,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_int ("num-buffers", "Num Buffers", "Number of Buffers",
|
|
|
|
1, 256, 64, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_int ("buffer-size", "Buffer Size", "Size of buffers",
|
|
|
|
0, 512 * 1024, 128 * 1024,
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2003-05-02 21:16:55 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_FIXED_FPS,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_boolean ("use-fixed-fps", "Use Fixed FPS",
|
2004-03-15 19:32:28 +00:00
|
|
|
"Drop/Insert frames to reach a certain FPS (TRUE) "
|
2004-05-03 17:26:43 +00:00
|
|
|
"or adapt FPS to suit the number of grabbed frames",
|
2008-03-22 15:00:53 +00:00
|
|
|
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
/* signals */
|
|
|
|
gst_v4lmjpegsrc_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 (GstV4lMjpegSrcClass, frame_capture),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-05-02 21:16:55 +00:00
|
|
|
gst_v4lmjpegsrc_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 (GstV4lMjpegSrcClass, frame_drop), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-05-02 21:16:55 +00:00
|
|
|
gst_v4lmjpegsrc_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 (GstV4lMjpegSrcClass, frame_insert),
|
|
|
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-05-02 21:16:55 +00:00
|
|
|
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_LOST] =
|
2004-03-14 22:34:34 +00:00
|
|
|
g_signal_new ("frame-lost", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstV4lMjpegSrcClass, frame_lost), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (v4lmjpegsrc_debug, "v4lmjpegsrc", 0,
|
|
|
|
"V4L MJPEG source element");
|
2001-12-23 15:31:15 +00:00
|
|
|
gobject_class->set_property = gst_v4lmjpegsrc_set_property;
|
|
|
|
gobject_class->get_property = gst_v4lmjpegsrc_get_property;
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_v4lmjpegsrc_change_state;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
gstelement_class->set_clock = gst_v4lmjpegsrc_set_clock;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_init (GstV4lMjpegSrc * v4lmjpegsrc)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-01-02 21:57:10 +00:00
|
|
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (v4lmjpegsrc);
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_get),
(cdparanoia_open), (cdparanoia_close), (cdparanoia_event),
(cdparanoia_convert), (cdparanoia_query):
* ext/cdparanoia/gstcdparanoia.h:
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_init),
(gst_gnomevfssink_open_file), (gst_gnomevfssink_close_file),
(gst_gnomevfssink_chain), (gst_gnomevfssink_change_state):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_init):
* gst/audioscale/gstaudioscale.c: (gst_audioscale_init):
* gst/playback/gststreamselector.c: (gst_stream_selector_init):
* gst/tcp/gstmultifdsink.c: (gst_multifdsink_init),
(gst_multifdsink_render), (gst_multifdsink_start),
(gst_multifdsink_stop):
* gst/tcp/gstmultifdsink.h:
* gst/tcp/gsttcpclientsink.c: (gst_tcpclientsink_init),
(gst_tcpclientsink_render), (gst_tcpclientsink_start),
(gst_tcpclientsink_stop):
* gst/tcp/gsttcpclientsink.h:
* gst/tcp/gsttcpclientsrc.c: (gst_tcpclientsrc_init),
(gst_tcpclientsrc_getcaps), (gst_tcpclientsrc_create),
(gst_tcpclientsrc_start), (gst_tcpclientsrc_stop):
* gst/tcp/gsttcpclientsrc.h:
* gst/tcp/gsttcpserversink.h:
* gst/tcp/gsttcpserversrc.c: (gst_tcpserversrc_init),
(gst_tcpserversrc_create), (gst_tcpserversrc_start),
(gst_tcpserversrc_stop):
* gst/tcp/gsttcpserversrc.h:
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_init):
* sys/ximage/ximagesink.c: (gst_ximagesink_init):
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:32:29 +00:00
|
|
|
GST_OBJECT_FLAG_SET (GST_ELEMENT (v4lmjpegsrc), GST_ELEMENT_THREAD_SUGGESTED);
|
2003-05-21 06:33:18 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->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 (v4lmjpegsrc), v4lmjpegsrc->srcpad);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
gst_pad_set_get_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_get);
|
2003-05-10 14:36:34 +00:00
|
|
|
gst_pad_set_getcaps_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_getcaps);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_pad_set_link_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_srcconnect);
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_pad_set_convert_function (v4lmjpegsrc->srcpad,
|
|
|
|
gst_v4lmjpegsrc_src_convert);
|
|
|
|
gst_pad_set_formats_function (v4lmjpegsrc->srcpad,
|
|
|
|
gst_v4lmjpegsrc_get_formats);
|
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_query_function (v4lmjpegsrc->srcpad, gst_v4lmjpegsrc_src_query);
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_pad_set_query_type_function (v4lmjpegsrc->srcpad,
|
|
|
|
gst_v4lmjpegsrc_get_query_types);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-05-10 14:36:34 +00:00
|
|
|
#if 0
|
2001-12-23 15:31:15 +00:00
|
|
|
v4lmjpegsrc->frame_width = 0;
|
|
|
|
v4lmjpegsrc->frame_height = 0;
|
|
|
|
v4lmjpegsrc->x_offset = -1;
|
|
|
|
v4lmjpegsrc->y_offset = -1;
|
2003-05-10 14:36:34 +00:00
|
|
|
#endif
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
v4lmjpegsrc->quality = 50;
|
|
|
|
|
|
|
|
v4lmjpegsrc->numbufs = 64;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
/* no clock */
|
|
|
|
v4lmjpegsrc->clock = NULL;
|
|
|
|
|
|
|
|
/* fps */
|
|
|
|
v4lmjpegsrc->use_fixed_fps = TRUE;
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
|
|
|
|
v4lmjpegsrc->is_capturing = FALSE;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4lmjpegsrc_get_fps (GstV4lMjpegSrc * v4lmjpegsrc, GValue * fps)
|
2002-09-16 21:01:42 +00:00
|
|
|
{
|
|
|
|
gint norm;
|
2005-11-22 23:39:12 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION (fps), FALSE);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
if (!v4lmjpegsrc->use_fixed_fps &&
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->clock != NULL && v4lmjpegsrc->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 (v4lmjpegsrc->clock) - v4lmjpegsrc->substract_time;
|
2003-05-02 21:16:55 +00:00
|
|
|
return v4lmjpegsrc->handled * GST_SECOND / time;
|
|
|
|
}
|
2002-09-16 21:01:42 +00:00
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
/* 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 (v4lmjpegsrc)))
|
2005-11-22 23:39:12 +00:00
|
|
|
return FALSE;
|
2002-09-16 21:01:42 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4l_get_chan_norm (GST_V4LELEMENT (v4lmjpegsrc), NULL, &norm))
|
2005-11-22 23:39:12 +00:00
|
|
|
return FALSE;
|
2002-09-16 21:01:42 +00:00
|
|
|
|
|
|
|
if (norm == VIDEO_MODE_NTSC)
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_value_set_fraction (fps, 30000, 1001);
|
2002-09-16 21:01:42 +00:00
|
|
|
else
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_value_set_fraction (fps, 25, 1);
|
2002-09-16 21:01:42 +00:00
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
return TRUE;
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_src_convert (GstPad * pad,
|
|
|
|
GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
|
2003-05-02 21:16:55 +00:00
|
|
|
{
|
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc;
|
2005-11-22 23:39:12 +00:00
|
|
|
GValue fps = { 0 };
|
|
|
|
gboolean result = TRUE;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
g_value_init (&fps, GST_VALUE_FRACTION);
|
|
|
|
if (!gst_v4lmjpegsrc_get_fps (v4lmjpegsrc, &fps))
|
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:
|
2005-11-22 23:39:12 +00:00
|
|
|
*dest_value = gst_util_uint64_scale (src_value,
|
|
|
|
gst_value_get_fraction_numerator (&fps),
|
|
|
|
gst_value_get_fraction_denominator (&fps) * GST_SECOND);
|
2004-03-15 19:32:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-11-22 23:39:12 +00:00
|
|
|
result = 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:
|
Updates for API changes
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_src_setcaps), (get_buffer),
(gst_visual_chain):
* ext/theora/theoraenc.c: (theora_enc_sink_setcaps):
* gst/videorate/gstvideorate.c: (gst_videorate_setcaps),
(gst_videorate_chain):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_fixate), (gst_videotestsrc_create):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_get_fps),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query),
(gst_v4lmjpegsrc_get), (gst_v4lmjpegsrc_getcaps):
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_get_fps),
(gst_v4lsrc_get_fps_list), (gst_v4lsrc_buffer_new):
Updates for API changes
2005-11-23 13:25:54 +00:00
|
|
|
*dest_value = src_value * gst_util_uint64_scale_int (GST_SECOND,
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_value_get_fraction_denominator (&fps),
|
|
|
|
gst_value_get_fraction_numerator (&fps));
|
2004-03-15 19:32:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-11-22 23:39:12 +00:00
|
|
|
result = FALSE;
|
2002-09-16 21:01:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-11-22 23:39:12 +00:00
|
|
|
result = FALSE;
|
2002-09-16 21:01:42 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
g_value_unset (&fps);
|
|
|
|
return result;
|
2002-09-16 21:01:42 +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
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_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
|
|
|
{
|
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
|
|
|
|
gboolean res = TRUE;
|
2005-11-22 23:39:12 +00:00
|
|
|
GValue fps = { 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
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
g_value_init (&fps, GST_VALUE_FRACTION);
|
|
|
|
if (!gst_v4lmjpegsrc_get_fps (v4lmjpegsrc, &fps))
|
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:
|
Updates for API changes
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_src_setcaps), (get_buffer),
(gst_visual_chain):
* ext/theora/theoraenc.c: (theora_enc_sink_setcaps):
* gst/videorate/gstvideorate.c: (gst_videorate_setcaps),
(gst_videorate_chain):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_fixate), (gst_videotestsrc_create):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_get_fps),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query),
(gst_v4lmjpegsrc_get), (gst_v4lmjpegsrc_getcaps):
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_get_fps),
(gst_v4lsrc_get_fps_list), (gst_v4lsrc_buffer_new):
Updates for API changes
2005-11-23 13:25:54 +00:00
|
|
|
*value = v4lmjpegsrc->handled * gst_util_uint64_scale_int (GST_SECOND,
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_value_get_fraction_denominator (&fps),
|
|
|
|
gst_value_get_fraction_numerator (&fps));
|
2004-03-15 19:32:28 +00:00
|
|
|
break;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*value = v4lmjpegsrc->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;
|
|
|
|
}
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
g_value_unset (&fps);
|
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 res;
|
|
|
|
}
|
2002-09-16 21:01:42 +00:00
|
|
|
|
2003-05-10 14:36:34 +00:00
|
|
|
static inline gulong
|
2004-03-14 22:34:34 +00:00
|
|
|
calc_bufsize (int hor_dec, int ver_dec)
|
2003-05-10 14:36:34 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
guint8 div = hor_dec * ver_dec;
|
|
|
|
guint32 num = (1024 * 512) / (div);
|
|
|
|
guint32 result = 2;
|
|
|
|
|
|
|
|
num--;
|
|
|
|
while (num) {
|
|
|
|
num >>= 1;
|
|
|
|
result <<= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result > (512 * 1024))
|
|
|
|
return (512 * 1024);
|
|
|
|
if (result < 8192)
|
|
|
|
return 8192;
|
|
|
|
return result;
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_srcconnect (GstPad * pad, const GstCaps * caps)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
|
2003-05-10 14:36:34 +00:00
|
|
|
gint hor_dec, ver_dec;
|
|
|
|
gint w, h;
|
2004-03-14 22:34:34 +00:00
|
|
|
gint max_w = GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxwidth,
|
|
|
|
max_h = GST_V4LELEMENT (v4lmjpegsrc)->vcap.maxheight;
|
2003-05-10 14:36:34 +00:00
|
|
|
gulong bufsize;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
gboolean was_capturing;
|
2001-12-23 15:31:15 +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 */
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
if ((was_capturing = v4lmjpegsrc->is_capturing)) {
|
|
|
|
if (!gst_v4lmjpegsrc_capture_stop (v4lmjpegsrc))
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
if (GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc))) {
|
|
|
|
if (!gst_v4lmjpegsrc_capture_deinit (v4lmjpegsrc))
|
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 (v4lmjpegsrc))) {
|
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
|
|
|
|
|
|
|
/* Note: basically, we don't give a damn about the opposite caps here.
|
|
|
|
* that might seem odd, but it isn't. we know that the opposite caps is
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
* either NULL or has mime type image/jpeg, and in both cases, we'll set
|
2002-09-09 07:12:29 +00:00
|
|
|
* our own mime type back and it'll work. Other properties are to be set
|
|
|
|
* by the src, not by the opposite caps */
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
gst_structure_get_int (structure, "width", &w);
|
|
|
|
gst_structure_get_int (structure, "height", &h);
|
2003-05-10 14:36:34 +00:00
|
|
|
|
|
|
|
/* figure out decimation */
|
|
|
|
if (w >= max_w) {
|
|
|
|
hor_dec = 1;
|
2004-03-14 22:34:34 +00:00
|
|
|
} else if (w * 2 >= max_w) {
|
2003-05-10 14:36:34 +00:00
|
|
|
hor_dec = 2;
|
|
|
|
} else {
|
|
|
|
hor_dec = 4;
|
|
|
|
}
|
|
|
|
if (h >= max_h) {
|
|
|
|
ver_dec = 1;
|
2004-03-14 22:34:34 +00:00
|
|
|
} else if (h * 2 >= max_h) {
|
2003-05-10 14:36:34 +00:00
|
|
|
ver_dec = 2;
|
|
|
|
} else {
|
|
|
|
ver_dec = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate bufsize */
|
2004-03-14 22:34:34 +00:00
|
|
|
bufsize = calc_bufsize (hor_dec, ver_dec);
|
2003-05-10 14:36:34 +00:00
|
|
|
|
2002-09-09 07:12:29 +00:00
|
|
|
/* set buffer info */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lmjpegsrc_set_buffer (v4lmjpegsrc, v4lmjpegsrc->numbufs, bufsize)) {
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
2002-09-09 07:12:29 +00:00
|
|
|
|
|
|
|
/* set capture parameters and mmap the buffers */
|
2003-05-10 14:36:34 +00:00
|
|
|
if (hor_dec == ver_dec) {
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lmjpegsrc_set_capture (v4lmjpegsrc,
|
2004-03-15 19:32:28 +00:00
|
|
|
hor_dec, v4lmjpegsrc->quality)) {
|
2003-05-10 14:36:34 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
|
|
|
} else {
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lmjpegsrc_set_capture_m (v4lmjpegsrc,
|
2004-03-15 19:32:28 +00:00
|
|
|
0, 0, max_w, max_h, hor_dec, ver_dec, v4lmjpegsrc->quality)) {
|
2003-05-10 14:36:34 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if 0
|
2002-09-09 07:12:29 +00:00
|
|
|
if (!v4lmjpegsrc->frame_width && !v4lmjpegsrc->frame_height &&
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->x_offset < 0 && v4lmjpegsrc->y_offset < 0 &&
|
|
|
|
v4lmjpegsrc->horizontal_decimation == v4lmjpegsrc->vertical_decimation) {
|
|
|
|
if (!gst_v4lmjpegsrc_set_capture (v4lmjpegsrc,
|
2004-03-15 19:32:28 +00:00
|
|
|
v4lmjpegsrc->horizontal_decimation, v4lmjpegsrc->quality))
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
|
|
|
if (!gst_v4lmjpegsrc_set_capture_m (v4lmjpegsrc,
|
2004-03-15 19:32:28 +00:00
|
|
|
v4lmjpegsrc->x_offset, v4lmjpegsrc->y_offset,
|
|
|
|
v4lmjpegsrc->frame_width, v4lmjpegsrc->frame_height,
|
|
|
|
v4lmjpegsrc->horizontal_decimation,
|
|
|
|
v4lmjpegsrc->vertical_decimation, v4lmjpegsrc->quality))
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-09-09 07:12:29 +00:00
|
|
|
}
|
2003-05-10 14:36:34 +00:00
|
|
|
#endif
|
|
|
|
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
if (!gst_v4lmjpegsrc_capture_init (v4lmjpegsrc))
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
|
|
|
|
if (was_capturing || GST_STATE (v4lmjpegsrc) == GST_STATE_PLAYING)
|
|
|
|
if (!gst_v4lmjpegsrc_capture_start (v4lmjpegsrc))
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstData *
|
|
|
|
gst_v4lmjpegsrc_get (GstPad * pad)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc;
|
|
|
|
GstBuffer *buf;
|
|
|
|
gint num;
|
2005-11-22 23:39:12 +00:00
|
|
|
GValue fps = { 0 };
|
|
|
|
GstClockTime duration;
|
|
|
|
GstClockTime cur_frame_time;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (pad != NULL, NULL);
|
|
|
|
|
|
|
|
v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
if (v4lmjpegsrc->use_fixed_fps) {
|
|
|
|
g_value_init (&fps, GST_VALUE_FRACTION);
|
Updates for API changes
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_src_setcaps), (get_buffer),
(gst_visual_chain):
* ext/theora/theoraenc.c: (theora_enc_sink_setcaps):
* gst/videorate/gstvideorate.c: (gst_videorate_setcaps),
(gst_videorate_chain):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_fixate), (gst_videotestsrc_create):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_get_fps),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query),
(gst_v4lmjpegsrc_get), (gst_v4lmjpegsrc_getcaps):
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_get_fps),
(gst_v4lsrc_get_fps_list), (gst_v4lsrc_buffer_new):
Updates for API changes
2005-11-23 13:25:54 +00:00
|
|
|
duration = gst_util_uint64_scale_int (GST_SECOND,
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_value_get_fraction_denominator (&fps),
|
|
|
|
gst_value_get_fraction_numerator (&fps));
|
|
|
|
cur_frame_time =
|
Updates for API changes
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_src_setcaps), (get_buffer),
(gst_visual_chain):
* ext/theora/theoraenc.c: (theora_enc_sink_setcaps):
* gst/videorate/gstvideorate.c: (gst_videorate_setcaps),
(gst_videorate_chain):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_fixate), (gst_videotestsrc_create):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_get_fps),
(gst_v4lmjpegsrc_src_convert), (gst_v4lmjpegsrc_src_query),
(gst_v4lmjpegsrc_get), (gst_v4lmjpegsrc_getcaps):
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_get_fps),
(gst_v4lsrc_get_fps_list), (gst_v4lsrc_buffer_new):
Updates for API changes
2005-11-23 13:25:54 +00:00
|
|
|
gst_util_uint64_scale_int (v4lmjpegsrc->handled * GST_SECOND,
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_value_get_fraction_denominator (&fps),
|
|
|
|
gst_value_get_fraction_numerator (&fps));
|
|
|
|
|
|
|
|
|
|
|
|
if (!gst_v4lmjpegsrc_get_fps (v4lmjpegsrc, &fps)) {
|
|
|
|
g_value_unset (&fps);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
if (v4lmjpegsrc->need_writes > 0) {
|
|
|
|
/* use last frame */
|
|
|
|
num = v4lmjpegsrc->last_frame;
|
|
|
|
v4lmjpegsrc->need_writes--;
|
|
|
|
} else if (v4lmjpegsrc->clock && v4lmjpegsrc->use_fixed_fps) {
|
|
|
|
GstClockTime time;
|
|
|
|
gboolean have_frame = FALSE;
|
|
|
|
|
|
|
|
do {
|
|
|
|
/* by default, we use the frame once */
|
|
|
|
v4lmjpegsrc->need_writes = 1;
|
|
|
|
|
|
|
|
/* grab a frame from the device */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lmjpegsrc_grab_frame (v4lmjpegsrc, &num,
|
2004-03-15 19:32:28 +00:00
|
|
|
&v4lmjpegsrc->last_size))
|
|
|
|
return NULL;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
v4lmjpegsrc->last_frame = num;
|
2004-03-14 22:34:34 +00:00
|
|
|
time = GST_TIMEVAL_TO_TIME (v4lmjpegsrc->bsync.timestamp) -
|
2004-03-15 19:32:28 +00:00
|
|
|
v4lmjpegsrc->substract_time;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
/* first check whether we lost any frames according to the device */
|
|
|
|
if (v4lmjpegsrc->last_seq != 0) {
|
2004-03-15 19:32:28 +00:00
|
|
|
if (v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq > 1) {
|
|
|
|
v4lmjpegsrc->need_writes =
|
|
|
|
v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq;
|
|
|
|
g_signal_emit (G_OBJECT (v4lmjpegsrc),
|
|
|
|
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_LOST], 0,
|
|
|
|
v4lmjpegsrc->bsync.seq - v4lmjpegsrc->last_seq - 1);
|
|
|
|
}
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
v4lmjpegsrc->last_seq = v4lmjpegsrc->bsync.seq;
|
|
|
|
|
|
|
|
/* decide how often we're going to write the frame - set
|
|
|
|
* v4lmjpegsrc->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... */
|
2005-11-22 23:39:12 +00:00
|
|
|
if (cur_frame_time - time > 1.5 * duration) {
|
2004-03-15 19:32:28 +00:00
|
|
|
/* yo dude, we've got too many frames here! Drop! DROP! */
|
|
|
|
v4lmjpegsrc->need_writes--; /* -= (v4lmjpegsrc->handled - (time / fps)); */
|
|
|
|
g_signal_emit (G_OBJECT (v4lmjpegsrc),
|
|
|
|
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_DROP], 0);
|
2005-11-22 23:39:12 +00:00
|
|
|
} else if (cur_frame_time - time < -1.5 * duration) {
|
2004-03-15 19:32:28 +00:00
|
|
|
/* this means we're lagging far behind */
|
|
|
|
v4lmjpegsrc->need_writes++; /* += ((time / fps) - v4lmjpegsrc->handled); */
|
|
|
|
g_signal_emit (G_OBJECT (v4lmjpegsrc),
|
|
|
|
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_INSERT], 0);
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (v4lmjpegsrc->need_writes > 0) {
|
2004-03-15 19:32:28 +00:00
|
|
|
have_frame = TRUE;
|
|
|
|
v4lmjpegsrc->use_num_times[num] = v4lmjpegsrc->need_writes;
|
|
|
|
v4lmjpegsrc->need_writes--;
|
2003-05-02 21:16:55 +00:00
|
|
|
} else {
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_v4lmjpegsrc_requeue_frame (v4lmjpegsrc, 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_v4lmjpegsrc_grab_frame (v4lmjpegsrc, &num,
|
2004-03-15 19:32:28 +00:00
|
|
|
&v4lmjpegsrc->last_size))
|
2003-05-02 21:16:55 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
v4lmjpegsrc->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_v4lmjpegsrc_buffer_free;
|
2004-01-11 22:03:52 +00:00
|
|
|
GST_BUFFER_PRIVATE (buf) = v4lmjpegsrc;
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_BUFFER_DATA (buf) = gst_v4lmjpegsrc_get_buffer (v4lmjpegsrc, num);
|
|
|
|
GST_BUFFER_SIZE (buf) = v4lmjpegsrc->last_size;
|
|
|
|
GST_BUFFER_MAXSIZE (buf) = v4lmjpegsrc->breq.size;
|
2004-06-16 15:07:58 +00:00
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY);
|
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
2003-05-02 21:16:55 +00:00
|
|
|
if (v4lmjpegsrc->use_fixed_fps)
|
2005-11-22 23:39:12 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buf) = cur_frame_time;
|
2004-03-15 19:32:28 +00:00
|
|
|
else /* calculate time based on our own clock */
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buf) =
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_TIMEVAL_TO_TIME (v4lmjpegsrc->bsync.timestamp) -
|
|
|
|
v4lmjpegsrc->substract_time;
|
2003-05-02 21:16:55 +00:00
|
|
|
|
|
|
|
v4lmjpegsrc->handled++;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_signal_emit (G_OBJECT (v4lmjpegsrc),
|
|
|
|
gst_v4lmjpegsrc_signals[SIGNAL_FRAME_CAPTURE], 0);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-10-08 16:08:22 +00:00
|
|
|
return GST_DATA (buf);
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_v4lmjpegsrc_getcaps (GstPad * pad)
|
2003-05-10 14:36:34 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (gst_pad_get_parent (pad));
|
|
|
|
struct video_capability *vcap = &GST_V4LELEMENT (v4lmjpegsrc)->vcap;
|
2005-02-05 16:18:15 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *str;
|
|
|
|
gint i;
|
|
|
|
GValue w = { 0 }, h = {
|
|
|
|
0}, w1 = {
|
|
|
|
0}, h1 = {
|
2005-11-22 23:39:12 +00:00
|
|
|
0}, fps = {
|
2005-02-05 16:18:15 +00:00
|
|
|
0};
|
2003-05-10 14:36:34 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lmjpegsrc))) {
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
g_value_init (&fps, GST_TYPE_FRACTION);
|
|
|
|
gst_return_val_if_fail (gst_v4lmjpegsrc_get_fps (v4lmjpegsrc, &fps), NULL);
|
|
|
|
|
|
|
|
caps = gst_caps_new_simple ("image/jpeg", NULL);
|
2005-02-05 16:18:15 +00:00
|
|
|
str = gst_caps_get_structure (caps, 0);
|
2005-11-22 23:39:12 +00:00
|
|
|
gst_structure_set_value (str, "framerate", &fps);
|
|
|
|
g_value_unset (&fps);
|
|
|
|
|
2005-02-05 16:18:15 +00:00
|
|
|
g_value_init (&w, GST_TYPE_LIST);
|
|
|
|
g_value_init (&h, GST_TYPE_LIST);
|
|
|
|
g_value_init (&w1, G_TYPE_INT);
|
|
|
|
g_value_init (&h1, G_TYPE_INT);
|
|
|
|
for (i = 0; i <= 2; i++) {
|
|
|
|
g_value_set_int (&w1, vcap->maxwidth / (1 << i));
|
|
|
|
g_value_set_int (&h1, vcap->maxheight / (1 << i));
|
|
|
|
gst_value_list_append_value (&w, &w1);
|
|
|
|
gst_value_list_append_value (&h, &h1);
|
|
|
|
}
|
|
|
|
g_value_unset (&h1);
|
|
|
|
g_value_unset (&w1);
|
|
|
|
gst_structure_set_value (str, "width", &w);
|
|
|
|
gst_structure_set_value (str, "height", &h);
|
|
|
|
g_value_unset (&w);
|
|
|
|
g_value_unset (&h);
|
|
|
|
|
|
|
|
return caps;
|
2003-05-10 14:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_return_if_fail (GST_IS_V4LMJPEGSRC (object));
|
|
|
|
v4lmjpegsrc = GST_V4LMJPEGSRC (object);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2003-05-10 14:36:34 +00:00
|
|
|
#if 0
|
2001-12-23 15:31:15 +00:00
|
|
|
case ARG_X_OFFSET:
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->x_offset = g_value_get_int (value);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
|
|
|
case ARG_Y_OFFSET:
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->y_offset = g_value_get_int (value);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
|
|
|
case ARG_F_WIDTH:
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->frame_width = g_value_get_int (value);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
|
|
|
case ARG_F_HEIGHT:
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->frame_height = g_value_get_int (value);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
#endif
|
2001-12-23 15:31:15 +00:00
|
|
|
case ARG_QUALITY:
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->quality = g_value_get_int (value);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
|
|
|
case ARG_NUMBUFS:
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lmjpegsrc->numbufs = g_value_get_int (value);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
2003-05-02 21:16:55 +00:00
|
|
|
case ARG_USE_FIXED_FPS:
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc))) {
|
2004-03-15 19:32:28 +00:00
|
|
|
v4lmjpegsrc->use_fixed_fps = g_value_get_boolean (value);
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
default:
|
2002-01-15 15:52:09 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_return_if_fail (GST_IS_V4LMJPEGSRC (object));
|
|
|
|
v4lmjpegsrc = GST_V4LMJPEGSRC (object);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2003-05-10 14:36:34 +00:00
|
|
|
#if 0
|
2002-02-20 07:25:40 +00:00
|
|
|
case ARG_X_OFFSET:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->x_offset);
|
2002-02-20 07:25:40 +00:00
|
|
|
break;
|
|
|
|
case ARG_Y_OFFSET:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->y_offset);
|
2002-02-20 07:25:40 +00:00
|
|
|
break;
|
|
|
|
case ARG_F_WIDTH:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->frame_width);
|
2002-02-20 07:25:40 +00:00
|
|
|
break;
|
|
|
|
case ARG_F_HEIGHT:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->frame_height);
|
2002-02-20 07:25:40 +00:00
|
|
|
break;
|
2003-05-10 14:36:34 +00:00
|
|
|
#endif
|
2002-02-20 07:25:40 +00:00
|
|
|
case ARG_QUALITY:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->quality);
|
2002-02-20 07:25:40 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
case ARG_NUMBUFS:
|
2004-03-14 22:34:34 +00:00
|
|
|
if (GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc)))
|
2004-03-15 19:32:28 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->breq.count);
|
2003-11-09 20:04:08 +00:00
|
|
|
else
|
2004-03-15 19:32:28 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->numbufs);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
2003-05-21 06:33:18 +00:00
|
|
|
case ARG_BUFSIZE:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_int (value, v4lmjpegsrc->breq.size);
|
2003-05-21 06:33:18 +00:00
|
|
|
break;
|
2003-05-02 21:16:55 +00:00
|
|
|
case ARG_USE_FIXED_FPS:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_value_set_boolean (value, v4lmjpegsrc->use_fixed_fps);
|
2003-05-02 21:16:55 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
default:
|
2002-01-15 15:52:09 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_v4lmjpegsrc_change_state (GstElement * element, GstStateChange transition)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc;
|
2003-05-02 21:16:55 +00:00
|
|
|
GTimeVal time;
|
2002-01-04 23:58:11 +00:00
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
g_return_val_if_fail (GST_IS_V4LMJPEGSRC (element), GST_STATE_CHANGE_FAILURE);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
|
|
|
v4lmjpegsrc = GST_V4LMJPEGSRC (element);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2002-09-09 07:12:29 +00:00
|
|
|
/* actual buffer set-up used to be done here - but I moved
|
|
|
|
* it to capsnego itself */
|
2003-05-02 21:16:55 +00:00
|
|
|
v4lmjpegsrc->handled = 0;
|
|
|
|
v4lmjpegsrc->need_writes = 0;
|
|
|
|
v4lmjpegsrc->last_frame = 0;
|
|
|
|
v4lmjpegsrc->substract_time = 0;
|
2002-01-06 21:38:22 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
2001-12-23 15:31:15 +00:00
|
|
|
/* queue all buffer, start streaming capture */
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
if (GST_V4LELEMENT (v4lmjpegsrc)->buffer &&
|
|
|
|
!gst_v4lmjpegsrc_capture_start (v4lmjpegsrc))
|
2005-09-02 15:43:18 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_get_current_time (&time);
|
|
|
|
v4lmjpegsrc->substract_time = GST_TIMEVAL_TO_TIME (time) -
|
2004-03-15 19:32:28 +00:00
|
|
|
v4lmjpegsrc->substract_time;
|
2003-05-02 21:16:55 +00:00
|
|
|
v4lmjpegsrc->last_seq = 0;
|
2001-12-23 15:31:15 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2004-03-14 22:34:34 +00:00
|
|
|
g_get_current_time (&time);
|
|
|
|
v4lmjpegsrc->substract_time = GST_TIMEVAL_TO_TIME (time) -
|
2004-03-15 19:32:28 +00:00
|
|
|
v4lmjpegsrc->substract_time;
|
2001-12-28 19:54:23 +00:00
|
|
|
/* de-queue all queued buffers */
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
if (v4lmjpegsrc->is_capturing &&
|
|
|
|
!gst_v4lmjpegsrc_capture_stop (v4lmjpegsrc))
|
2005-09-02 15:43:18 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2001-12-28 19:54:23 +00:00
|
|
|
break;
|
2005-09-02 15:43:18 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2001-12-28 19:54:23 +00:00
|
|
|
/* stop capturing, unmap all buffers */
|
ext/ogg/gstoggmux.c: Basic pad template which accepts OGM tracks, speex, flac, vorbis and theora. Any is incorrect.
Original commit message from CVS:
* ext/ogg/gstoggmux.c:
Basic pad template which accepts OGM tracks, speex, flac, vorbis
and theora. Any is incorrect.
* gst/asfdemux/gstasfmux.c: (gst_asfmux_vidsink_link):
Fix caps.
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_base_init):
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_base_init),
(gst_v4lmjpegsrc_init), (gst_v4lmjpegsrc_srcconnect),
(gst_v4lmjpegsrc_getcaps), (gst_v4lmjpegsrc_change_state):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_getcaps),
(gst_v4lsrc_change_state):
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_capture_stop):
Fix caps. Keep track of internal state. Work.
2004-10-24 13:41:18 +00:00
|
|
|
if (GST_V4LELEMENT (v4lmjpegsrc)->buffer &&
|
|
|
|
!gst_v4lmjpegsrc_capture_deinit (v4lmjpegsrc))
|
2005-09-02 15:43:18 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2001-12-28 19:54:23 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
2002-01-04 23:58:11 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
2005-09-02 15:43:18 +00:00
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2002-01-04 23:58:11 +00:00
|
|
|
|
2005-09-02 15:43:18 +00:00
|
|
|
return GST_STATE_CHANGE_SUCCESS;
|
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_v4lmjpegsrc_set_clock (GstElement * element, GstClock * clock)
|
2003-05-02 21:16:55 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4LMJPEGSRC (element)->clock = clock;
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
#if 0
|
2004-03-14 22:34:34 +00:00
|
|
|
static GstBuffer *
|
|
|
|
gst_v4lmjpegsrc_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
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (user_data);
|
2002-09-20 09:28:46 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc)))
|
2002-09-20 09:28:46 +00:00
|
|
|
return NULL;
|
2001-12-23 15:31:15 +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;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* TODO: add interlacing info to buffer as metadata */
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_BUFFER_MAXSIZE (buffer) = v4lmjpegsrc->breq.size;
|
|
|
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
2003-12-22 01:47:09 +00:00
|
|
|
#endif
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lmjpegsrc_buffer_free (GstBuffer * buf)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-01-11 22:03:52 +00:00
|
|
|
GstV4lMjpegSrc *v4lmjpegsrc = GST_V4LMJPEGSRC (GST_BUFFER_PRIVATE (buf));
|
2001-12-23 15:31:15 +00:00
|
|
|
int n;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (gst_element_get_state (GST_ELEMENT (v4lmjpegsrc)) != 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-03-14 22:34:34 +00:00
|
|
|
for (n = 0; n < v4lmjpegsrc->breq.count; n++)
|
|
|
|
if (GST_BUFFER_DATA (buf) == gst_v4lmjpegsrc_get_buffer (v4lmjpegsrc, n)) {
|
2003-05-02 21:16:55 +00:00
|
|
|
v4lmjpegsrc->use_num_times[n]--;
|
|
|
|
if (v4lmjpegsrc->use_num_times[n] <= 0) {
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_v4lmjpegsrc_requeue_frame (v4lmjpegsrc, n);
|
2003-05-02 21:16:55 +00:00
|
|
|
}
|
2002-09-20 09:28:46 +00:00
|
|
|
break;
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
2002-09-20 09:28:46 +00:00
|
|
|
if (n == v4lmjpegsrc->breq.count)
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, TOO_LAZY, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Couldn't find the buffer"));
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|