2004-06-15 09:11:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* v4lsrc_calls.c: generic V4L source functions
|
|
|
|
*
|
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 <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "v4lsrc_calls.h"
|
2002-01-04 23:58:11 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
/* number of buffers to be queued *at least* before syncing */
|
|
|
|
#define MIN_BUFFERS_QUEUED 2
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* On some systems MAP_FAILED seems to be missing */
|
|
|
|
#ifndef MAP_FAILED
|
|
|
|
#define MAP_FAILED ( (caddr_t) -1 )
|
|
|
|
#endif
|
|
|
|
|
2004-04-27 11:33:52 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (v4l_debug);
|
|
|
|
|
|
|
|
#define GST_CAT_DEFAULT v4l_debug
|
|
|
|
|
compile fixes for --disable-gst-debug, G_DISABLE_ASSERT and friends
Original commit message from CVS:
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_get_volume),
(gst_alsa_mixer_set_volume), (gst_alsa_mixer_set_mute),
(gst_alsa_mixer_set_record), (gst_alsa_mixer_set_option),
(gst_alsa_mixer_get_option):
* ext/dvdnav/dvdnavsrc.c: (dvdnav_get_event_name),
(dvdnavsrc_print_event):
* ext/ogg/gstoggdemux.c: (_find_chain_process), (gst_ogg_print):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_pad_link),
(gst_ogg_mux_pad_unlink):
* gst/multipart/multipartmux.c: (gst_multipart_mux_pad_link),
(gst_multipart_mux_pad_unlink):
* gst/videofilter/gstvideobalance.c:
(gst_videobalance_colorbalance_set_value):
* gst/videomixer/videomixer.c: (gst_videomixer_pad_link),
(gst_videomixer_pad_unlink):
* po/uk.po:
* sys/oss/gstossmixer.c:
* sys/v4l/gstv4lcolorbalance.c:
* sys/v4l/gstv4ltuner.c:
* sys/v4l/v4lsrc_calls.c:
* sys/v4l2/gstv4l2colorbalance.c:
* sys/v4l2/gstv4l2tuner.c:
compile fixes for --disable-gst-debug, G_DISABLE_ASSERT and friends
2004-08-03 16:06:08 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2002-01-07 09:31:34 +00:00
|
|
|
/* palette names */
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static const char *v4l_palette_name[] = {
|
2004-03-15 19:32:28 +00:00
|
|
|
"", /* 0 */
|
|
|
|
"grayscale", /* VIDEO_PALETTE_GREY */
|
|
|
|
"Hi-420", /* VIDEO_PALETTE_HI420 */
|
|
|
|
"16-bit RGB (RGB-565)", /* VIDEO_PALETTE_RB565 */
|
|
|
|
"24-bit RGB", /* VIDEO_PALETTE_RGB24 */
|
|
|
|
"32-bit RGB", /* VIDEO_PALETTE_RGB32 */
|
|
|
|
"15-bit RGB (RGB-555)", /* VIDEO_PALETTE_RGB555 */
|
|
|
|
"YUV-4:2:2 (packed)", /* VIDEO_PALETTE_YUV422 */
|
|
|
|
"YUYV", /* VIDEO_PALETTE_YUYV */
|
|
|
|
"UYVY", /* VIDEO_PALETTE_UYVY */
|
|
|
|
"YUV-4:2:0 (packed)", /* VIDEO_PALETTE_YUV420 */
|
|
|
|
"YUV-4:1:1 (packed)", /* VIDEO_PALETTE_YUV411 */
|
|
|
|
"Raw", /* VIDEO_PALETTE_RAW */
|
|
|
|
"YUV-4:2:2 (planar)", /* VIDEO_PALETTE_YUV422P */
|
|
|
|
"YUV-4:1:1 (planar)", /* VIDEO_PALETTE_YUV411P */
|
2004-11-09 18:27:32 +00:00
|
|
|
"YUV-4:2:0 (planar)/I420", /* VIDEO_PALETTE_YUV420P */
|
2004-03-15 19:32:28 +00:00
|
|
|
"YUV-4:1:0 (planar)" /* VIDEO_PALETTE_YUV410P */
|
2002-01-07 09:31:34 +00:00
|
|
|
};
|
compile fixes for --disable-gst-debug, G_DISABLE_ASSERT and friends
Original commit message from CVS:
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_get_volume),
(gst_alsa_mixer_set_volume), (gst_alsa_mixer_set_mute),
(gst_alsa_mixer_set_record), (gst_alsa_mixer_set_option),
(gst_alsa_mixer_get_option):
* ext/dvdnav/dvdnavsrc.c: (dvdnav_get_event_name),
(dvdnavsrc_print_event):
* ext/ogg/gstoggdemux.c: (_find_chain_process), (gst_ogg_print):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_pad_link),
(gst_ogg_mux_pad_unlink):
* gst/multipart/multipartmux.c: (gst_multipart_mux_pad_link),
(gst_multipart_mux_pad_unlink):
* gst/videofilter/gstvideobalance.c:
(gst_videobalance_colorbalance_set_value):
* gst/videomixer/videomixer.c: (gst_videomixer_pad_link),
(gst_videomixer_pad_unlink):
* po/uk.po:
* sys/oss/gstossmixer.c:
* sys/v4l/gstv4lcolorbalance.c:
* sys/v4l/gstv4ltuner.c:
* sys/v4l/v4lsrc_calls.c:
* sys/v4l2/gstv4l2colorbalance.c:
* sys/v4l2/gstv4l2tuner.c:
compile fixes for --disable-gst-debug, G_DISABLE_ASSERT and friends
2004-08-03 16:06:08 +00:00
|
|
|
#endif
|
2002-01-07 09:31:34 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_queue_frame():
|
|
|
|
* queue a frame for capturing
|
2004-06-15 09:11:06 +00:00
|
|
|
* (ie. instruct the hardware to start capture)
|
2003-05-21 06:33:18 +00:00
|
|
|
* Requires queue_state lock to be held!
|
2001-12-23 15:31:15 +00:00
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_queue_frame (GstV4lSrc * v4lsrc, gint num)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "queueing frame %d", num);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-05-21 06:33:18 +00:00
|
|
|
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_READY_FOR_QUEUE) {
|
|
|
|
return FALSE;
|
2002-01-31 22:22:42 +00:00
|
|
|
}
|
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
/* instruct the driver to prepare capture using buffer frame num */
|
2003-05-21 06:33:18 +00:00
|
|
|
v4lsrc->mmap.frame = num;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd,
|
2004-03-15 19:32:28 +00:00
|
|
|
VIDIOCMCAPTURE, &(v4lsrc->mmap)) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, WRITE, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error queueing a buffer (%d): %s", num, g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-21 06:33:18 +00:00
|
|
|
v4lsrc->frame_queue_state[num] = QUEUE_STATE_QUEUED;
|
|
|
|
v4lsrc->num_queued++;
|
2001-12-23 19:14:18 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2003-05-21 06:33:18 +00:00
|
|
|
|
2003-03-01 14:35:17 +00:00
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_hard_sync_frame(GstV4lSrc *v4lsrc,gint num)
|
|
|
|
* sync a frame and set the timestamp correctly
|
2003-05-21 06:33:18 +00:00
|
|
|
* Requires queue_state lock to be held
|
2003-03-01 14:35:17 +00:00
|
|
|
*****************************************************/
|
2001-12-23 19:14:18 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static gboolean
|
|
|
|
gst_v4lsrc_sync_frame (GstV4lSrc * v4lsrc, gint num)
|
2001-12-23 19:14:18 +00:00
|
|
|
{
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "VIOIOCSYNC on frame %d", num);
|
2002-09-09 07:12:29 +00:00
|
|
|
|
2003-05-21 06:33:18 +00:00
|
|
|
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_QUEUED) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-23 19:14:18 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCSYNC, &num) < 0) {
|
2003-05-21 06:33:18 +00:00
|
|
|
/* if the sync() got interrupted, we can retry */
|
|
|
|
if (errno != EINTR) {
|
|
|
|
v4lsrc->frame_queue_state[num] = QUEUE_STATE_ERROR;
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SYNC, (NULL), GST_ERROR_SYSTEM);
|
2003-05-21 06:33:18 +00:00
|
|
|
return FALSE;
|
2001-12-23 19:14:18 +00:00
|
|
|
}
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "Sync got interrupted");
|
2001-12-23 19:14:18 +00:00
|
|
|
}
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "VIOIOCSYNC on frame %d done", num);
|
2001-12-23 19:14:18 +00:00
|
|
|
|
2003-05-21 06:33:18 +00:00
|
|
|
v4lsrc->frame_queue_state[num] = QUEUE_STATE_SYNCED;
|
|
|
|
v4lsrc->num_queued--;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_set_capture():
|
|
|
|
* set capture parameters, palette = VIDEO_PALETTE_*
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_set_capture (GstV4lSrc * v4lsrc,
|
|
|
|
gint width, gint height, gint palette)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc,
|
2004-08-12 15:58:52 +00:00
|
|
|
"capture properties set to %dx%d, palette %d", width, height, palette);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
v4lsrc->mmap.width = width;
|
|
|
|
v4lsrc->mmap.height = height;
|
|
|
|
v4lsrc->mmap.format = palette;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_capture_init():
|
|
|
|
* initialize the capture system
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_capture_init (GstV4lSrc * v4lsrc)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "initting capture subsystem");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
|
|
|
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
/* request the mmap buffer info:
|
|
|
|
* total size of mmap buffer, number of frames, offsets of frames */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCGMBUF,
|
2004-03-15 19:32:28 +00:00
|
|
|
&(v4lsrc->mbuf)) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, READ, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting buffer information: %s", g_strerror (errno)));
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (v4lsrc->mbuf.frames < MIN_BUFFERS_QUEUED) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, READ, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Not enough buffers. We got %d, we want at least %d",
|
|
|
|
v4lsrc->mbuf.frames, MIN_BUFFERS_QUEUED));
|
2002-01-04 23:58:11 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_INFO_OBJECT (v4lsrc, "Got %d buffers (\'%s\') with total size %d KB",
|
2004-11-09 20:29:44 +00:00
|
|
|
v4lsrc->mbuf.frames, v4l_palette_name[v4lsrc->mmap.format],
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->mbuf.size / (v4lsrc->mbuf.frames * 1024));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-05-02 21:16:55 +00:00
|
|
|
/* keep track of queued buffers */
|
2003-05-21 06:33:18 +00:00
|
|
|
v4lsrc->frame_queue_state = (gint8 *)
|
2004-03-14 22:34:34 +00:00
|
|
|
g_malloc (sizeof (gint8) * v4lsrc->mbuf.frames);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-05-21 06:33:18 +00:00
|
|
|
/* lock for the frame_state */
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->mutex_queue_state = g_mutex_new ();
|
|
|
|
v4lsrc->cond_queue_state = g_cond_new ();
|
2001-12-23 19:14:18 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* Map the buffers */
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
GST_V4LELEMENT (v4lsrc)->buffer = mmap (NULL, v4lsrc->mbuf.size,
|
2004-03-14 22:34:34 +00:00
|
|
|
PROT_READ | PROT_WRITE, MAP_SHARED, GST_V4LELEMENT (v4lsrc)->video_fd, 0);
|
|
|
|
if (GST_V4LELEMENT (v4lsrc)->buffer == MAP_FAILED) {
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, OPEN_READ_WRITE, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error mapping video buffers: %s", g_strerror (errno)));
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4LELEMENT (v4lsrc)->buffer = NULL;
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_capture_start():
|
|
|
|
* start streaming capture
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
|
|
|
int n;
|
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "starting capture");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
|
|
|
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_lock (v4lsrc->mutex_queue_state);
|
2003-05-21 06:33:18 +00:00
|
|
|
|
2003-03-01 14:35:17 +00:00
|
|
|
v4lsrc->quit = FALSE;
|
2003-05-21 06:33:18 +00:00
|
|
|
v4lsrc->num_queued = 0;
|
|
|
|
v4lsrc->sync_frame = 0;
|
|
|
|
v4lsrc->queue_frame = 0;
|
|
|
|
|
2004-06-15 09:11:06 +00:00
|
|
|
/* set all buffers ready to queue, and queue captures to the device.
|
|
|
|
* This starts streaming capture */
|
2004-03-14 22:34:34 +00:00
|
|
|
for (n = 0; n < v4lsrc->mbuf.frames; n++) {
|
2003-05-21 06:33:18 +00:00
|
|
|
v4lsrc->frame_queue_state[n] = QUEUE_STATE_READY_FOR_QUEUE;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_queue_frame (v4lsrc, n)) {
|
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
|
|
|
gst_v4lsrc_capture_stop (v4lsrc);
|
2003-05-21 06:33:18 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2003-03-01 14:35:17 +00:00
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-01-28 21:16:01 +00:00
|
|
|
v4lsrc->is_capturing = TRUE;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
2001-12-23 19:14:18 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_grab_frame():
|
|
|
|
* capture one frame during streaming capture
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
|
|
|
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2009-09-01 13:30:41 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "grabbing frame");
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_lock (v4lsrc->mutex_queue_state);
|
2003-05-21 06:33:18 +00:00
|
|
|
|
|
|
|
/* do we have enough frames? */
|
|
|
|
while (v4lsrc->num_queued < MIN_BUFFERS_QUEUED ||
|
2004-03-14 22:34:34 +00:00
|
|
|
v4lsrc->frame_queue_state[v4lsrc->queue_frame] ==
|
|
|
|
QUEUE_STATE_READY_FOR_QUEUE) {
|
2003-05-21 06:33:18 +00:00
|
|
|
while (v4lsrc->frame_queue_state[v4lsrc->queue_frame] !=
|
2004-03-15 19:32:28 +00:00
|
|
|
QUEUE_STATE_READY_FOR_QUEUE && !v4lsrc->quit) {
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc,
|
2004-11-23 12:42:21 +00:00
|
|
|
"Waiting for frames to become available (queued %d < minimum %d)",
|
2004-03-15 19:32:28 +00:00
|
|
|
v4lsrc->num_queued, MIN_BUFFERS_QUEUED);
|
2004-03-14 22:34:34 +00:00
|
|
|
g_cond_wait (v4lsrc->cond_queue_state, v4lsrc->mutex_queue_state);
|
2003-05-21 06:33:18 +00:00
|
|
|
}
|
|
|
|
if (v4lsrc->quit) {
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
2005-01-11 00:26:13 +00:00
|
|
|
return FALSE;
|
2003-05-21 06:33:18 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_queue_frame (v4lsrc, v4lsrc->queue_frame)) {
|
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
2003-05-21 06:33:18 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
v4lsrc->queue_frame = (v4lsrc->queue_frame + 1) % v4lsrc->mbuf.frames;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
/* syncing on the buffer grabs it */
|
2003-05-21 06:33:18 +00:00
|
|
|
*num = v4lsrc->sync_frame;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!gst_v4lsrc_sync_frame (v4lsrc, *num)) {
|
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
2001-12-23 15:31:15 +00:00
|
|
|
return FALSE;
|
2003-05-21 06:33:18 +00:00
|
|
|
}
|
|
|
|
v4lsrc->sync_frame = (v4lsrc->sync_frame + 1) % v4lsrc->mbuf.frames;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2009-09-01 13:30:41 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "grabbed frame %d", *num);
|
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_get_buffer():
|
2004-06-15 09:11:06 +00:00
|
|
|
* get the address of the given frame number in the mmap'd buffer
|
2001-12-23 19:14:18 +00:00
|
|
|
* return value: the buffer's address or NULL
|
2001-12-23 15:31:15 +00:00
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
guint8 *
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_get_buffer (GstV4lSrc * v4lsrc, gint num)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lsrc)) ||
|
|
|
|
!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc)))
|
2001-12-24 21:43:31 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (num < 0 || num >= v4lsrc->mbuf.frames)
|
2001-12-23 15:31:15 +00:00
|
|
|
return NULL;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
return GST_V4LELEMENT (v4lsrc)->buffer + v4lsrc->mbuf.offsets[num];
|
2001-12-23 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_requeue_frame():
|
|
|
|
* re-queue a frame after we're done with the buffer
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_requeue_frame (GstV4lSrc * v4lsrc, gint num)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "requeueing frame %d", num);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
|
|
|
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2003-02-06 18:45:35 +00:00
|
|
|
/* mark frame as 'ready to requeue' */
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_lock (v4lsrc->mutex_queue_state);
|
2003-05-21 06:33:18 +00:00
|
|
|
|
|
|
|
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_SYNCED) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Invalid state %d (expected %d), can't requeue",
|
|
|
|
v4lsrc->frame_queue_state[num], QUEUE_STATE_SYNCED));
|
2003-05-21 06:33:18 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
v4lsrc->frame_queue_state[num] = QUEUE_STATE_READY_FOR_QUEUE;
|
2003-03-01 14:35:17 +00:00
|
|
|
|
2003-05-21 06:33:18 +00:00
|
|
|
/* let an optional wait know */
|
2004-03-14 22:34:34 +00:00
|
|
|
g_cond_broadcast (v4lsrc->cond_queue_state);
|
2003-03-01 14:35:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_capture_stop():
|
|
|
|
* stop streaming capture
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_capture_stop (GstV4lSrc * v4lsrc)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "stopping capture");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
|
|
|
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_lock (v4lsrc->mutex_queue_state);
|
2004-01-28 21:16:01 +00:00
|
|
|
v4lsrc->is_capturing = FALSE;
|
2003-05-21 06:33:18 +00:00
|
|
|
|
|
|
|
/* make an optional pending wait stop */
|
2003-03-01 14:35:17 +00:00
|
|
|
v4lsrc->quit = TRUE;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_cond_broadcast (v4lsrc->cond_queue_state);
|
|
|
|
|
2003-05-21 06:33:18 +00:00
|
|
|
/* sync on remaining frames */
|
|
|
|
while (1) {
|
|
|
|
if (v4lsrc->frame_queue_state[v4lsrc->sync_frame] == QUEUE_STATE_QUEUED) {
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_sync_frame (v4lsrc, v4lsrc->sync_frame);
|
2003-05-21 06:33:18 +00:00
|
|
|
v4lsrc->sync_frame = (v4lsrc->sync_frame + 1) % v4lsrc->mbuf.frames;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-12-23 15:31:15 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
2001-12-23 19:14:18 +00:00
|
|
|
|
2001-12-23 15:31:15 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* gst_v4lsrc_capture_deinit():
|
|
|
|
* deinitialize the capture system
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_v4lsrc_capture_deinit (GstV4lSrc * v4lsrc)
|
2001-12-23 15:31:15 +00:00
|
|
|
{
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "quitting capture subsystem");
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
|
|
|
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* free buffer tracker */
|
2004-03-14 22:34:34 +00:00
|
|
|
g_mutex_free (v4lsrc->mutex_queue_state);
|
2004-06-15 09:11:06 +00:00
|
|
|
v4lsrc->mutex_queue_state = NULL;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_cond_free (v4lsrc->cond_queue_state);
|
2004-06-15 09:11:06 +00:00
|
|
|
v4lsrc->cond_queue_state = NULL;
|
2004-03-14 22:34:34 +00:00
|
|
|
g_free (v4lsrc->frame_queue_state);
|
2004-06-15 09:11:06 +00:00
|
|
|
v4lsrc->frame_queue_state = NULL;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
/* unmap the buffer */
|
2004-06-15 09:11:06 +00:00
|
|
|
if (munmap (GST_V4LELEMENT (v4lsrc)->buffer, v4lsrc->mbuf.size) == -1) {
|
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, CLOSE, (NULL),
|
|
|
|
("error munmap'ing capture buffer: %s", g_strerror (errno)));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4LELEMENT (v4lsrc)->buffer = NULL;
|
2001-12-23 15:31:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-09-20 09:28:46 +00:00
|
|
|
|
|
|
|
/******************************************************
|
2004-06-17 17:06:24 +00:00
|
|
|
* gst_v4lsrc_try_capture():
|
|
|
|
* try out a capture on the device
|
2002-09-20 09:28:46 +00:00
|
|
|
* This has to be done before initializing the
|
|
|
|
* actual capture system, to make sure we don't
|
|
|
|
* mess up anything. So we need to mini-mmap()
|
|
|
|
* a buffer here, queue and sync on one buffer,
|
|
|
|
* and unmap it.
|
|
|
|
* This is ugly, yes, I know - but it's a major
|
|
|
|
* design flaw of v4l1 that you don't know in
|
|
|
|
* advance which formats will be supported...
|
|
|
|
* This is better than "just assuming that it'll
|
|
|
|
* work"...
|
|
|
|
* return value: TRUE on success, FALSE on error
|
|
|
|
******************************************************/
|
|
|
|
|
|
|
|
gboolean
|
2004-06-17 17:06:24 +00:00
|
|
|
gst_v4lsrc_try_capture (GstV4lSrc * v4lsrc, gint width, gint height,
|
|
|
|
gint palette)
|
2002-09-20 09:28:46 +00:00
|
|
|
{
|
|
|
|
/* so, we need a buffer and some more stuff */
|
|
|
|
int frame = 0;
|
|
|
|
guint8 *buffer;
|
|
|
|
struct video_mbuf vmbuf;
|
|
|
|
struct video_mmap vmmap;
|
|
|
|
|
2004-06-17 17:06:24 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "try out %dx%d, palette format %d (%s)",
|
2004-11-09 20:29:44 +00:00
|
|
|
width, height, palette, v4l_palette_name[palette]);
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
|
|
|
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
2002-09-20 09:28:46 +00:00
|
|
|
|
|
|
|
/* let's start by requesting a buffer and mmap()'ing it */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCGMBUF, &vmbuf) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, READ, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error getting buffer information: %s", g_strerror (errno)));
|
2002-09-20 09:28:46 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* Map the buffers */
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
buffer = mmap (NULL, vmbuf.size, PROT_READ | PROT_WRITE,
|
2004-03-14 22:34:34 +00:00
|
|
|
MAP_SHARED, GST_V4LELEMENT (v4lsrc)->video_fd, 0);
|
|
|
|
if (buffer == MAP_FAILED) {
|
2004-06-15 09:11:06 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, OPEN_READ_WRITE, (NULL),
|
2004-03-15 19:32:28 +00:00
|
|
|
("Error mapping our try-out buffer: %s", g_strerror (errno)));
|
2002-09-20 09:28:46 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now that we have a buffer, let's try out our format */
|
2004-06-17 17:06:24 +00:00
|
|
|
vmmap.width = width;
|
|
|
|
vmmap.height = height;
|
2002-09-20 09:28:46 +00:00
|
|
|
vmmap.format = palette;
|
|
|
|
vmmap.frame = frame;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCMCAPTURE, &vmmap) < 0) {
|
2004-03-15 19:32:28 +00:00
|
|
|
if (errno != EINVAL) /* our format failed! */
|
2004-10-01 10:02:42 +00:00
|
|
|
GST_ERROR_OBJECT (v4lsrc,
|
|
|
|
"Error queueing our try-out buffer: %s", g_strerror (errno));
|
2004-03-14 22:34:34 +00:00
|
|
|
munmap (buffer, vmbuf.size);
|
2002-09-20 09:28:46 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCSYNC, &frame) < 0) {
|
2004-02-27 23:36:43 +00:00
|
|
|
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SYNC, (NULL), GST_ERROR_SYSTEM);
|
2004-03-14 22:34:34 +00:00
|
|
|
munmap (buffer, vmbuf.size);
|
2002-09-20 09:28:46 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
munmap (buffer, vmbuf.size);
|
2002-09-20 09:28:46 +00:00
|
|
|
|
|
|
|
/* if we got here, it worked! woohoo, the format is supported! */
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-02-03 18:23:17 +00:00
|
|
|
|
2006-02-03 17:45:44 +00:00
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2005-02-03 18:23:17 +00:00
|
|
|
const char *
|
|
|
|
gst_v4lsrc_palette_name (int i)
|
|
|
|
{
|
|
|
|
return v4l_palette_name[i];
|
|
|
|
}
|
2006-02-03 17:45:44 +00:00
|
|
|
#endif
|
2005-02-03 18:23:17 +00:00
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
gboolean
|
2005-11-23 10:40:42 +00:00
|
|
|
gst_v4lsrc_get_fps (GstV4lSrc * v4lsrc, gint * fps_n, gint * fps_d)
|
2005-02-03 18:23:17 +00:00
|
|
|
{
|
|
|
|
gint norm;
|
|
|
|
gint fps_index;
|
|
|
|
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 */
|
|
|
|
|
|
|
|
/* webcams have a non-zero fps_index */
|
|
|
|
if (fps_index != 0) {
|
|
|
|
/* index of 16 corresponds to 15 fps */
|
2005-11-22 23:39:12 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "device reports fps of %d/%d (%.4f)",
|
|
|
|
fps_index * 15, 16, fps_index * 15.0 / 16);
|
|
|
|
|
2005-11-23 10:40:42 +00:00
|
|
|
if (fps_n)
|
|
|
|
*fps_n = fps_index * 15;
|
|
|
|
if (fps_d)
|
|
|
|
*fps_d = 16;
|
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
return TRUE;
|
2005-02-03 18:23:17 +00:00
|
|
|
}
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
/* removed fps estimation code here */
|
2005-02-03 18:23:17 +00:00
|
|
|
|
|
|
|
/* if that failed ... */
|
|
|
|
|
|
|
|
if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc)))
|
2005-11-22 23:39:12 +00:00
|
|
|
return FALSE;
|
2005-02-03 18:23:17 +00:00
|
|
|
|
|
|
|
if (!gst_v4l_get_chan_norm (GST_V4LELEMENT (v4lsrc), NULL, &norm))
|
2005-11-22 23:39:12 +00:00
|
|
|
return FALSE;
|
2005-02-03 18:23:17 +00:00
|
|
|
|
2005-11-23 10:40:42 +00:00
|
|
|
if (norm == VIDEO_MODE_NTSC) {
|
|
|
|
if (fps_n)
|
|
|
|
*fps_n = 30000;
|
|
|
|
if (fps_d)
|
|
|
|
*fps_d = 1001;
|
|
|
|
} else {
|
|
|
|
if (fps_n)
|
|
|
|
*fps_n = 25;
|
|
|
|
if (fps_d)
|
|
|
|
*fps_d = 1;
|
|
|
|
}
|
2005-02-03 18:23:17 +00:00
|
|
|
|
2005-11-22 23:39:12 +00:00
|
|
|
return TRUE;
|
2005-02-03 18:23:17 +00:00
|
|
|
}
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
/* get a list of possible framerates
|
|
|
|
* this is only done for webcams;
|
|
|
|
* other devices return NULL here.
|
|
|
|
* this function takes a LONG time to execute.
|
|
|
|
*/
|
|
|
|
GValue *
|
|
|
|
gst_v4lsrc_get_fps_list (GstV4lSrc * v4lsrc)
|
|
|
|
{
|
|
|
|
gint fps_index;
|
|
|
|
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);
|
|
|
|
|
|
|
|
{
|
|
|
|
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 */
|
2005-11-22 23:39:12 +00:00
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "device reports fps of %d/%d (%.4f)",
|
|
|
|
fps_index * 15, 16, fps_index * 15.0 / 16);
|
2005-07-07 11:29:29 +00:00
|
|
|
for (i = 0; i < 63; ++i) {
|
|
|
|
/* 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. */
|
2005-11-22 23:39:12 +00:00
|
|
|
g_value_init (&value, GST_TYPE_FRACTION);
|
|
|
|
gst_value_set_fraction (&value, i * 15, 16);
|
2005-07-07 11:29:29 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-25 14:49:33 +00:00
|
|
|
typedef struct _GstMetaV4lSrc
|
2005-07-07 11:29:29 +00:00
|
|
|
{
|
2011-02-25 14:49:33 +00:00
|
|
|
GstMeta meta;
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
GstV4lSrc *v4lsrc;
|
|
|
|
gint num;
|
2011-02-25 14:49:33 +00:00
|
|
|
} GstMetaV4lSrc;
|
|
|
|
|
2011-02-27 18:42:31 +00:00
|
|
|
#define GST_META_V4LSRC_GET(buf) ((GstMetaV4lSrc *)gst_buffer_get_meta(buf,gst_meta_v4lsrc_get_info()))
|
|
|
|
#define GST_META_V4LSRC_ADD(buf) ((GstMetaV4lSrc *)gst_buffer_add_meta(buf,gst_meta_v4lsrc_get_info(), NULL))
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
static void
|
2011-02-25 14:49:33 +00:00
|
|
|
meta_v4lsrc_free (GstMetaV4lSrc * meta, GstBuffer * buffer)
|
2005-07-07 11:29:29 +00:00
|
|
|
{
|
|
|
|
GstV4lSrc *v4lsrc;
|
|
|
|
gint num;
|
|
|
|
|
2011-02-25 14:49:33 +00:00
|
|
|
v4lsrc = meta->v4lsrc;
|
|
|
|
num = meta->num;
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2011-02-24 11:18:43 +00:00
|
|
|
GST_LOG_OBJECT (v4lsrc, "freeing buffer %p for frame %d", buffer, num);
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
/* only requeue if we still have an mmap buffer */
|
|
|
|
if (GST_V4LELEMENT (v4lsrc)->buffer) {
|
|
|
|
GST_LOG_OBJECT (v4lsrc, "requeueing frame %d", num);
|
|
|
|
gst_v4lsrc_requeue_frame (v4lsrc, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (v4lsrc);
|
|
|
|
}
|
|
|
|
|
2011-02-25 14:49:33 +00:00
|
|
|
static const GstMetaInfo *
|
|
|
|
gst_meta_v4lsrc_get_info (void)
|
|
|
|
{
|
|
|
|
static const GstMetaInfo *meta_v4lsrc_info = NULL;
|
|
|
|
|
|
|
|
if (meta_v4lsrc_info == NULL) {
|
|
|
|
meta_v4lsrc_info = gst_meta_register ("GstMetaV4lSrc", "GstMetaV4lSrc",
|
|
|
|
sizeof (GstMetaV4lSrc),
|
|
|
|
(GstMetaInitFunction) NULL,
|
|
|
|
(GstMetaFreeFunction) meta_v4lsrc_free,
|
2011-03-27 15:16:10 +00:00
|
|
|
(GstMetaCopyFunction) NULL,
|
2011-03-08 17:01:41 +00:00
|
|
|
(GstMetaTransformFunction) NULL,
|
2011-02-25 14:49:33 +00:00
|
|
|
(GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
|
|
|
|
}
|
|
|
|
return meta_v4lsrc_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
/* Create a V4lSrc buffer from our mmap'd data area */
|
|
|
|
GstBuffer *
|
|
|
|
gst_v4lsrc_buffer_new (GstV4lSrc * v4lsrc, gint num)
|
|
|
|
{
|
2011-02-25 14:49:33 +00:00
|
|
|
GstMetaV4lSrc *meta;
|
2009-09-01 14:02:37 +00:00
|
|
|
GstClockTime duration, timestamp, latency;
|
2005-07-07 11:29:29 +00:00
|
|
|
GstBuffer *buf;
|
2009-09-01 14:02:37 +00:00
|
|
|
GstClock *clock;
|
2005-11-23 10:40:42 +00:00
|
|
|
gint fps_n, fps_d;
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (v4lsrc, "creating buffer for frame %d", num);
|
|
|
|
|
2009-04-04 14:28:14 +00:00
|
|
|
if (!(gst_v4lsrc_get_fps (v4lsrc, &fps_n, &fps_d)))
|
|
|
|
return NULL;
|
2005-11-22 23:39:12 +00:00
|
|
|
|
2011-02-24 11:18:43 +00:00
|
|
|
buf = gst_buffer_new ();
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2011-02-25 14:49:33 +00:00
|
|
|
/* attach private metadata with the frame num and v4lsrc element */
|
2011-02-27 18:42:31 +00:00
|
|
|
meta = GST_META_V4LSRC_ADD (buf);
|
2011-02-25 14:49:33 +00:00
|
|
|
meta->num = num;
|
|
|
|
meta->v4lsrc = gst_object_ref (v4lsrc);
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2011-03-27 15:16:10 +00:00
|
|
|
gst_buffer_take_memory (buf,
|
|
|
|
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
|
|
|
|
gst_v4lsrc_get_buffer (v4lsrc, num), NULL, v4lsrc->buffer_size,
|
|
|
|
0, v4lsrc->buffer_size));
|
|
|
|
|
2005-07-07 11:29:29 +00:00
|
|
|
GST_BUFFER_OFFSET (buf) = v4lsrc->offset++;
|
2009-09-01 14:02:37 +00:00
|
|
|
GST_BUFFER_OFFSET_END (buf) = v4lsrc->offset;
|
|
|
|
|
|
|
|
/* timestamps, LOCK to get clock and base time. */
|
|
|
|
GST_OBJECT_LOCK (v4lsrc);
|
|
|
|
if ((clock = GST_ELEMENT_CLOCK (v4lsrc))) {
|
|
|
|
/* we have a clock, get base time and ref clock */
|
|
|
|
timestamp = GST_ELEMENT_CAST (v4lsrc)->base_time;
|
|
|
|
gst_object_ref (clock);
|
|
|
|
} else {
|
|
|
|
/* no clock, can't set timestamps */
|
|
|
|
timestamp = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (v4lsrc);
|
2005-07-07 11:29:29 +00:00
|
|
|
|
2009-09-01 14:02:37 +00:00
|
|
|
duration =
|
|
|
|
gst_util_uint64_scale_int (GST_SECOND, fps_d * v4lsrc->offset, fps_n) -
|
|
|
|
gst_util_uint64_scale_int (GST_SECOND, fps_d * (v4lsrc->offset - 1),
|
|
|
|
fps_n);
|
2007-02-28 15:05:03 +00:00
|
|
|
|
2009-09-01 14:02:37 +00:00
|
|
|
latency = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);
|
|
|
|
|
|
|
|
if (clock) {
|
|
|
|
/* the time now is the time of the clock minus the base time */
|
|
|
|
timestamp = gst_clock_get_time (clock) - timestamp;
|
|
|
|
gst_object_unref (clock);
|
|
|
|
|
|
|
|
/* adjust timestamp for frame latency (we assume we have a framerate) */
|
|
|
|
if (timestamp > latency)
|
|
|
|
timestamp -= latency;
|
|
|
|
else
|
|
|
|
timestamp = 0;
|
|
|
|
}
|
2007-02-28 15:05:03 +00:00
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = timestamp;
|
|
|
|
GST_BUFFER_DURATION (buf) = duration;
|
2005-07-07 11:29:29 +00:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|