paranoia cleanups and a sync fix

Original commit message from CVS:
paranoia cleanups and a sync fix
This commit is contained in:
Thomas Vander Stichele 2004-06-15 09:11:06 +00:00
parent 0eb2ab91f0
commit 5e9b6aab3b
25 changed files with 267 additions and 135 deletions

View file

@ -1,3 +1,53 @@
2004-06-15 Thomas Vander Stichele <thomas at apestaart dot org>
* sys/v4l/gstv4l.c: (plugin_init):
* sys/v4l/gstv4lcolorbalance.c:
* sys/v4l/gstv4lcolorbalance.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lelement.h:
* sys/v4l/gstv4lmjpegsink.c: (gst_v4lmjpegsink_class_init):
* sys/v4l/gstv4lmjpegsink.h:
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_class_init):
* sys/v4l/gstv4lmjpegsrc.h:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_fps_list),
(gst_v4lsrc_get_fps), (gst_v4lsrc_srcconnect),
(gst_v4lsrc_getcaps), (gst_v4lsrc_get):
* sys/v4l/gstv4lsrc.h:
* sys/v4l/gstv4ltuner.c:
* sys/v4l/gstv4ltuner.h:
* sys/v4l/gstv4lxoverlay.c:
* sys/v4l/gstv4lxoverlay.h:
* sys/v4l/v4l-overlay_calls.c: (gst_v4l_set_overlay),
(gst_v4l_set_window), (gst_v4l_enable_overlay):
* sys/v4l/v4l_calls.c: (gst_v4l_set_window_properties),
(gst_v4l_open), (gst_v4l_get_picture), (gst_v4l_get_audio),
(gst_v4l_set_audio):
* sys/v4l/v4l_calls.h:
* sys/v4l/v4lmjpegsink_calls.c: (gst_v4lmjpegsink_sync_thread),
(gst_v4lmjpegsink_queue_frame), (gst_v4lmjpegsink_sync_frame),
(gst_v4lmjpegsink_set_buffer), (gst_v4lmjpegsink_set_playback),
(gst_v4lmjpegsink_playback_init),
(gst_v4lmjpegsink_playback_start), (gst_v4lmjpegsink_get_buffer),
(gst_v4lmjpegsink_play_frame), (gst_v4lmjpegsink_wait_frame),
(gst_v4lmjpegsink_playback_stop),
(gst_v4lmjpegsink_playback_deinit):
* sys/v4l/v4lmjpegsink_calls.h:
* sys/v4l/v4lmjpegsrc_calls.c: (gst_v4lmjpegsrc_queue_frame),
(gst_v4lmjpegsrc_sync_next_frame), (gst_v4lmjpegsrc_set_buffer),
(gst_v4lmjpegsrc_set_capture), (gst_v4lmjpegsrc_set_capture_m),
(gst_v4lmjpegsrc_capture_init), (gst_v4lmjpegsrc_capture_start),
(gst_v4lmjpegsrc_grab_frame), (gst_v4lmjpegsrc_requeue_frame),
(gst_v4lmjpegsrc_capture_stop), (gst_v4lmjpegsrc_capture_deinit):
* sys/v4l/v4lmjpegsrc_calls.h:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_queue_frame),
(gst_v4lsrc_sync_frame), (gst_v4lsrc_set_capture),
(gst_v4lsrc_capture_init), (gst_v4lsrc_capture_start),
(gst_v4lsrc_grab_frame), (gst_v4lsrc_requeue_frame),
(gst_v4lsrc_capture_stop), (gst_v4lsrc_capture_deinit),
(gst_v4lsrc_try_palette):
* sys/v4l/v4lsrc_calls.h:
bunch of paranoia cleanups
2004-06-14 David Schleef <ds@schleef.org>
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_init),
@ -10,7 +60,7 @@
* ext/alsa/gstalsa.c: Use snd_pcm_hw_params_set_rate _near instead of
snd_pcm_hw_params_set_rate since the latter fails for no good
reason on some setups.<
reason on some setups.
2004-06-14 David Schleef <ds@schleef.org>
@ -21,7 +71,7 @@
* gst/ffmpegcolorspace/imgconvert.c: (img_convert):
Patch 1.3 broke the ordering of the colorspace info and
made the plugin basically work by coincidence, reodered
made the plugin basically work by coincidence, reordered
the info.
2004-06-14 Thomas Vander Stichele <thomas at apestaart dot org>

View file

@ -1,4 +1,7 @@
/* G-Streamer video4linux plugins
/* GStreamer
*
* gstv4l.c: plugin for v4l elements
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -31,11 +34,14 @@
#include "gstv4lmjpegsink.h"
GST_DEBUG_CATEGORY (v4l_debug); /* used in v4l_calls.c and v4lsrc_calls.c */
GST_DEBUG_CATEGORY_EXTERN (v4loverlay_debug);
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (v4l_debug, "v4l", 0, "V4L API calls");
GST_DEBUG_CATEGORY_INIT (v4loverlay_debug, "v4loverlay", 0,
"V4L overlay calls");
/* actually, we can survive without it, but I'll create
* that handling later on. */

View file

@ -1,8 +1,9 @@
/* GStreamer Color Balance interface implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
/* GStreamer
*
* gstv4lcolorbalance.c: color balance interface implementation for V4L
*
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* 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

View file

@ -1,8 +1,9 @@
/* G-Streamer generic V4L element - Color Balance interface implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
/* GStreamer
*
* gstv4lcolorbalance.h: color balance interface implementation for V4L
*
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* 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

View file

@ -1,4 +1,7 @@
/* G-Streamer generic V4L element - generic V4L calls handling
/* GStreamer
*
* gstv4lelement.c: base class for V4L elements
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or

View file

@ -1,4 +1,7 @@
/* G-Streamer generic V4L element - generic V4L calls handling
/* GStreamer
*
* gstv4lelement.h: base class for V4L elements
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video sink plugin
/* GStreamer
*
* gstv4lmjpegsink.c: hardware MJPEG video sink plugin
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -24,6 +27,9 @@
#include <string.h>
#include "v4lmjpegsink_calls.h"
GST_DEBUG_CATEGORY (v4lmjpegsink_debug);
#define GST_CAT_DEFAULT v4lmjpegsink_debug
/* elementfactory information */
static GstElementDetails gst_v4lmjpegsink_details = {
"Video (video4linux/MJPEG) sink",
@ -129,26 +135,28 @@ gst_v4lmjpegsink_class_init (GstV4lMjpegSinkClass * klass)
parent_class = g_type_class_ref (GST_TYPE_V4LELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUMBUFS,
g_param_spec_int ("num_buffers", "num_buffers", "num_buffers",
g_param_spec_int ("num-buffers", "num-buffers", "num-buffers",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
g_param_spec_int ("buffer_size", "buffer_size", "buffer_size",
g_param_spec_int ("buffer-size", "buffer-size", "buffer-size",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_X_OFFSET,
g_param_spec_int ("x_offset", "x_offset", "x_offset",
g_param_spec_int ("x-offset", "x-offset", "x-offset",
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_Y_OFFSET,
g_param_spec_int ("y_offset", "y_offset", "y_offset",
g_param_spec_int ("y-offset", "y-offset", "y-offset",
G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAMES_DISPLAYED,
g_param_spec_int ("frames_displayed", "frames_displayed",
"frames_displayed", G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
g_param_spec_int ("frames-displayed", "frames-displayed",
"frames-displayed", G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAME_TIME,
g_param_spec_int ("frame_time", "frame_time", "frame_time", G_MININT,
g_param_spec_int ("frame-time", "frame-time", "frame-time", G_MININT,
G_MAXINT, 0, G_PARAM_READABLE));
GST_DEBUG_CATEGORY_INIT (v4lmjpegsink_debug, "v4lmjpegsink", 0,
"V4L MJPEG sink element");
gobject_class->set_property = gst_v4lmjpegsink_set_property;
gobject_class->get_property = gst_v4lmjpegsink_get_property;

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video sink plugin
/* GStreamer
*
* gstv4lmjpegsink.h: hardware MJPEG video sink element
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video source plugin
/* GStreamer
*
* gstv4lmjpegsrc.c: hardware MJPEG video source plugin
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -24,6 +27,9 @@
#include <string.h>
#include "v4lmjpegsrc_calls.h"
GST_DEBUG_CATEGORY (v4lmjpegsrc_debug);
#define GST_CAT_DEFAULT v4lmjpegsrc_debug
/* elementfactory information */
static GstElementDetails gst_v4lmjpegsrc_details = {
"Video (video4linux/MJPEG) Source",
@ -208,6 +214,8 @@ gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass * klass)
G_STRUCT_OFFSET (GstV4lMjpegSrcClass, frame_lost), NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
GST_DEBUG_CATEGORY_INIT (v4lmjpegsrc_debug, "v4lmjpegsrc", 0,
"V4L MJPEG source element");
gobject_class->set_property = gst_v4lmjpegsrc_set_property;
gobject_class->get_property = gst_v4lmjpegsrc_get_property;

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video source plugin
/* GStreamer
*
* gstv4lmjpegsrc.h: hardware MJPEG video source element
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or

View file

@ -1,4 +1,7 @@
/* G-Streamer BT8x8/V4L frame grabber plugin
/* GStreamer
*
* gstv4lsrc.c: BT8x8/V4L source element
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -316,7 +319,7 @@ gst_v4lsrc_get_fps_list (GstV4lSrc * v4lsrc)
/* index of 16 corresponds to 15 fps */
current_fps = fps_index * 15.0 / 16;
GST_DEBUG_OBJECT (v4lsrc, "device reports fps of %.4f", current_fps);
for (i = 1; i < 63; ++i) {
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 */
@ -359,7 +362,7 @@ gst_v4lsrc_get_fps (GstV4lSrc * v4lsrc)
/* index of 16 corresponds to 15 fps */
current_fps = fps_index * 15.0 / 16;
GST_LOG_OBJECT (v4lsrc, "device reports fps of %.3f", current_fps);
GST_LOG_OBJECT (v4lsrc, "device reports fps of %.4f", current_fps);
return current_fps;
}
@ -774,8 +777,9 @@ gst_v4lsrc_get (GstPad * pad)
g_return_val_if_fail (pad != NULL, NULL);
v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
fps = gst_v4lsrc_get_fps (v4lsrc);
if (v4lsrc->use_fixed_fps && (fps = gst_v4lsrc_get_fps (v4lsrc)) == 0)
if (v4lsrc->use_fixed_fps && fps == 0.0)
return NULL;
if (v4lsrc->need_writes > 0) {
@ -868,8 +872,10 @@ gst_v4lsrc_get (GstPad * pad)
g_signal_emit (G_OBJECT (v4lsrc),
gst_v4lsrc_signals[SIGNAL_FRAME_CAPTURE], 0);
/* this is the current timestamp */
now = gst_element_get_time (GST_ELEMENT (v4lsrc));
until = GST_BUFFER_TIMESTAMP (buf) + v4lsrc->last_discont;
until = GST_BUFFER_TIMESTAMP (buf);
GST_LOG_OBJECT (v4lsrc, "Current time %" GST_TIME_FORMAT
", buffer timestamp %" GST_TIME_FORMAT,
@ -878,7 +884,10 @@ gst_v4lsrc_get (GstPad * pad)
GST_LOG_OBJECT (v4lsrc, "waiting until %" GST_TIME_FORMAT,
GST_TIME_ARGS (until));
if (!gst_element_wait (GST_ELEMENT (v4lsrc), until))
g_warning ("gst_element_wait failed");
g_warning ("waiting from now %" GST_TIME_FORMAT
" until %" GST_TIME_FORMAT " failed",
GST_TIME_ARGS (now), GST_TIME_ARGS (until));
GST_LOG_OBJECT (v4lsrc, "wait done.");
}
/* check for discont; we do it after grabbing so that we drop the
* first frame grabbed, but get an accurate discont event */

View file

@ -1,4 +1,7 @@
/* G-Streamer BT8x8/V4L frame grabber plugin
/* GStreamer
*
* gstv4lsrc.h: BT8x8/V4L video source element
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -39,9 +42,9 @@ typedef struct _GstV4lSrcClass GstV4lSrcClass;
enum
{
QUEUE_STATE_ERROR = -1,
QUEUE_STATE_READY_FOR_QUEUE,
QUEUE_STATE_QUEUED,
QUEUE_STATE_SYNCED
QUEUE_STATE_READY_FOR_QUEUE, /* the frame is ready to be queued for capture */
QUEUE_STATE_QUEUED, /* the frame is queued for capture */
QUEUE_STATE_SYNCED /* the frame is captured */
};
struct _GstV4lSrc

View file

@ -1,8 +1,9 @@
/* GStreamer Tuner interface implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
/* GStreamer
*
* gstv4ltuner.c: tuner interface implementation for V4L
*
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* 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

View file

@ -1,8 +1,9 @@
/* G-Streamer generic V4L element - Tuner interface implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
/* GStreamer
*
* gstv4ltuner.h: tuner interface implementation for V4L
*
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* 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

View file

@ -1,8 +1,9 @@
/* GStreamer X-based overlay interface implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
/* GStreamer
*
* gstv4lxoverlay.c: X-based overlay interface implementation for V4L
*
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* 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

View file

@ -1,8 +1,9 @@
/* G-Streamer generic V4L element - X overlay interface implementation
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
/* GStreamer
*
* gstv4lxoverlay.h: tv mixer interface implementation for V4L
*
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* 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

View file

@ -1,4 +1,7 @@
/* G-Streamer generic V4L element - generic V4L overlay handling
/* GStreamer
*
* v4l-overlay_calls.c: calls for generic V4L overlay handling
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -31,11 +34,8 @@
#include <errno.h>
#include "v4l_calls.h"
#define DEBUG(format, args...) \
GST_DEBUG_OBJECT (\
GST_ELEMENT(v4lelement), \
"V4L-overlay: " format, ##args)
GST_DEBUG_CATEGORY (v4loverlay_debug);
#define GST_CAT_DEFAULT v4loverlay_debug
/******************************************************
* gst_v4l_set_overlay():
@ -53,7 +53,7 @@ gst_v4l_set_overlay (GstV4lElement * v4lelement)
g_free (v4lelement->display);
v4lelement->display = g_strdup (g_getenv ("DISPLAY"));
DEBUG ("setting display to '%s'", v4lelement->display);
GST_DEBUG_OBJECT (v4lelement, "setting display to '%s'", v4lelement->display);
GST_V4L_CHECK_NOT_OPEN (v4lelement);
if (!v4lelement->display || v4lelement->display[0] != ':')
@ -105,8 +105,8 @@ gst_v4l_set_window (GstElement * element,
GstV4lElement *v4lelement = GST_V4LELEMENT (element);
struct video_window vwin;
DEBUG ("setting video window to position (x,y/wxh) = %d,%d/%dx%d",
x, y, w, h);
GST_DEBUG_OBJECT (v4lelement,
"setting video window to position (x,y/wxh) = %d,%d/%dx%d", x, y, w, h);
GST_V4L_CHECK_OPEN (v4lelement);
GST_V4L_CHECK_OVERLAY (v4lelement);
@ -117,7 +117,7 @@ gst_v4l_set_window (GstElement * element,
vwin.flags = 0;
if (clips && !(v4lelement->vcap.type & VID_TYPE_CLIPPING)) {
DEBUG ("Device \'%s\' doesn't do clipping",
GST_DEBUG_OBJECT (v4lelement, "Device \'%s\' doesn't do clipping",
v4lelement->videodev ? v4lelement->videodev : "/dev/video");
vwin.clips = 0;
} else {
@ -146,7 +146,8 @@ gst_v4l_enable_overlay (GstV4lElement * v4lelement, gboolean enable)
{
gint doit = enable ? 1 : 0;
DEBUG ("%s overlay", enable ? "enabling" : "disabling");
GST_DEBUG_OBJECT (v4lelement, "%s overlay",
enable ? "enabling" : "disabling");
GST_V4L_CHECK_OPEN (v4lelement);
GST_V4L_CHECK_OVERLAY (v4lelement);

View file

@ -1,4 +1,7 @@
/* G-Streamer generic V4L element - generic V4L calls handling
/* GStreamer
*
* v4l_calls.c: generic V4L calls
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -43,7 +46,6 @@
#include "gstv4lmjpegsink.h"
GST_DEBUG_CATEGORY_EXTERN (v4l_debug);
#define GST_CAT_DEFAULT v4l_debug
static const char *picture_name[] = {
@ -160,6 +162,11 @@ gst_v4l_open (GstV4lElement * v4lelement)
/* open the device */
v4lelement->video_fd = open (v4lelement->videodev, O_RDWR);
if (!GST_V4L_IS_OPEN (v4lelement)) {
if (errno == ENODEV || errno == ENOENT) {
GST_ELEMENT_ERROR (v4lelement, RESOURCE, NOT_FOUND,
(_("Device \"%s\" does not exist."), v4lelement->videodev), (NULL));
return FALSE;
}
GST_ELEMENT_ERROR (v4lelement, RESOURCE, OPEN_READ_WRITE,
(_("Could not open device \"%s\" for reading and writing."),
v4lelement->videodev), GST_ERROR_SYSTEM);
@ -187,7 +194,7 @@ gst_v4l_open (GstV4lElement * v4lelement)
return FALSE;
}
GST_INFO ("Opened device \'%s\' (\'%s\') successfully\n",
GST_INFO_OBJECT (v4lelement, "Opened device \'%s\' (\'%s\') successfully\n",
v4lelement->vcap.name, v4lelement->videodev);
/* norms + inputs, for the tuner interface */
@ -256,7 +263,7 @@ gst_v4l_close (GstV4lElement * v4lelement)
/******************************************************
* gst_v4l_get_num_chans()
* return value: the numver of video input channels
* return value: the number of video input channels
******************************************************/
gint

View file

@ -1,4 +1,7 @@
/* G-Streamer generic V4L element - generic V4L calls handling
/* GStreamer
*
* v4l_calls.h: header for generic V4L calls
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -127,7 +130,7 @@ gboolean gst_v4l_set_frequency (GstV4lElement *v4lelement,
gboolean gst_v4l_get_picture (GstV4lElement *v4lelement,
GstV4lPictureType type,
gint *value);
gboolean gst_v4l_set_picture (GstV4lElement *v4lelement,
gboolean gst_v4l_set_picture (GstV4lElement *v4lelement,
GstV4lPictureType type,
gint value);

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video sink plugin
/* GStreamer
*
* v4lmjpegsink_calls.c: functions for hardware MJPEG video sink
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -36,11 +39,8 @@
#define MAP_FAILED ( (caddr_t) -1 )
#endif
#define DEBUG(format, args...) \
GST_DEBUG_OBJECT (\
GST_ELEMENT(v4lmjpegsink), \
"V4LMJPEGSINK: " format, ##args)
GST_DEBUG_CATEGORY_EXTERN (v4lmjpegsink_debug);
#define GST_CAT_DEFAULT v4lmjpegsink_debug
/******************************************************
* gst_v4lmjpegsink_sync_thread()
@ -53,7 +53,7 @@ gst_v4lmjpegsink_sync_thread (void *arg)
GstV4lMjpegSink *v4lmjpegsink = GST_V4LMJPEGSINK (arg);
gint frame = 0; /* frame that we're currently syncing on */
DEBUG ("starting sync thread");
GST_DEBUG_OBJECT (v4lmjpegsink, "starting sync thread");
#if 0
/* Allow easy shutting down by other processes... */
@ -73,7 +73,7 @@ gst_v4lmjpegsink_sync_thread (void *arg)
}
g_mutex_unlock (v4lmjpegsink->mutex_queued_frames);
DEBUG ("thread-syncing on next frame");
GST_DEBUG_OBJECT (v4lmjpegsink, "thread-syncing on next frame");
if (ioctl (GST_V4LELEMENT (v4lmjpegsink)->video_fd, MJPIOC_SYNC,
&(v4lmjpegsink->bsync)) < 0) {
GST_ELEMENT_ERROR (v4lmjpegsink, RESOURCE, SYNC, (NULL),
@ -100,7 +100,7 @@ gst_v4lmjpegsink_sync_thread (void *arg)
}
end:
DEBUG ("Sync thread got signalled to exit");
GST_DEBUG_OBJECT (v4lmjpegsink, "Sync thread got signalled to exit");
g_thread_exit (NULL);
return NULL;
}
@ -115,7 +115,7 @@ end:
static gboolean
gst_v4lmjpegsink_queue_frame (GstV4lMjpegSink * v4lmjpegsink, gint num)
{
DEBUG ("queueing frame %d", num);
GST_DEBUG_OBJECT (v4lmjpegsink, "queueing frame %d", num);
/* queue on this frame */
if (ioctl (GST_V4LELEMENT (v4lmjpegsink)->video_fd, MJPIOC_QBUF_PLAY,
@ -143,7 +143,7 @@ gst_v4lmjpegsink_queue_frame (GstV4lMjpegSink * v4lmjpegsink, gint num)
static gboolean
gst_v4lmjpegsink_sync_frame (GstV4lMjpegSink * v4lmjpegsink, gint * num)
{
DEBUG ("syncing on next frame");
GST_DEBUG_OBJECT (v4lmjpegsink, "syncing on next frame");
/* calculate next frame */
v4lmjpegsink->current_frame =
@ -175,8 +175,8 @@ gboolean
gst_v4lmjpegsink_set_buffer (GstV4lMjpegSink * v4lmjpegsink,
gint numbufs, gint bufsize)
{
DEBUG ("setting buffer info to numbufs = %d, bufsize = %d KB",
numbufs, bufsize);
GST_DEBUG_OBJECT (v4lmjpegsink,
"setting buffer info to numbufs = %d, bufsize = %d KB", numbufs, bufsize);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
@ -201,8 +201,8 @@ gst_v4lmjpegsink_set_playback (GstV4lMjpegSink * v4lmjpegsink,
gint mw, mh;
struct mjpeg_params bparm;
DEBUG
("setting size = %dx%d, X/Y-offsets = %d/%d, norm = %d, interlacing = %d\n",
GST_DEBUG_OBJECT (v4lmjpegsink,
"setting size=%dx%d, X/Y offsets=%d/%d, norm=%d, interlacing=%d\n",
width, height, x_offset, y_offset, norm, interlacing);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
/*GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lmjpegsink)); */
@ -317,7 +317,7 @@ gst_v4lmjpegsink_playback_init (GstV4lMjpegSink * v4lmjpegsink)
{
gint n;
DEBUG ("initting playback subsystem");
GST_DEBUG_OBJECT (v4lmjpegsink, "initting playback subsystem");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
@ -328,7 +328,7 @@ gst_v4lmjpegsink_playback_init (GstV4lMjpegSink * v4lmjpegsink)
return FALSE;
}
GST_INFO ("Got %ld buffers of size %ld KB",
GST_INFO_OBJECT (v4lmjpegsink, "Got %ld buffers of size %ld KB",
v4lmjpegsink->breq.count, v4lmjpegsink->breq.size / 1024);
/* Map the buffers */
@ -378,7 +378,7 @@ gst_v4lmjpegsink_playback_start (GstV4lMjpegSink * v4lmjpegsink)
GError *error;
gint n;
DEBUG ("starting playback");
GST_DEBUG_OBJECT (v4lmjpegsink, "starting playback");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
@ -411,7 +411,7 @@ gst_v4lmjpegsink_playback_start (GstV4lMjpegSink * v4lmjpegsink)
guint8 *
gst_v4lmjpegsink_get_buffer (GstV4lMjpegSink * v4lmjpegsink, gint num)
{
/*DEBUG("gst_v4lmjpegsink_get_buffer(), num = %d", num); */
/*GST_DEBUG_OBJECT (v4lmjpegsink, gst_v4lmjpegsink_get_buffer(), num = %d", num); */
if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsink)) ||
!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lmjpegsink)))
@ -434,7 +434,7 @@ gst_v4lmjpegsink_get_buffer (GstV4lMjpegSink * v4lmjpegsink, gint num)
gboolean
gst_v4lmjpegsink_play_frame (GstV4lMjpegSink * v4lmjpegsink, gint num)
{
DEBUG ("playing frame %d", num);
GST_DEBUG_OBJECT (v4lmjpegsink, "playing frame %d", num);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
@ -454,7 +454,8 @@ gst_v4lmjpegsink_play_frame (GstV4lMjpegSink * v4lmjpegsink, gint num)
gboolean
gst_v4lmjpegsink_wait_frame (GstV4lMjpegSink * v4lmjpegsink, gint * num)
{
DEBUG ("waiting for next frame to be finished playing");
GST_DEBUG_OBJECT (v4lmjpegsink,
"waiting for next frame to be finished playing");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
@ -476,7 +477,7 @@ gst_v4lmjpegsink_playback_stop (GstV4lMjpegSink * v4lmjpegsink)
{
gint num;
DEBUG ("stopping playback");
GST_DEBUG_OBJECT (v4lmjpegsink, "stopping playback");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));
@ -504,7 +505,7 @@ gst_v4lmjpegsink_playback_deinit (GstV4lMjpegSink * v4lmjpegsink)
{
int n;
DEBUG ("quitting playback subsystem");
GST_DEBUG_OBJECT (v4lmjpegsink, "quitting playback subsystem");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsink));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsink));

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video sink plugin
/* GStreamer
*
* v4lmjpegsink_calls.c: functions for hardware MJPEG video sink
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video source plugin
/* GStreamer
*
* v4lmjpegsrc_calls.c: functions for hardware MJPEG video source
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -37,10 +40,8 @@
#define MIN_BUFFERS_QUEUED 2
#define DEBUG(format, args...) \
GST_DEBUG_OBJECT (\
GST_ELEMENT(v4lmjpegsrc), \
"V4LMJPEGSRC: " format, ##args)
GST_DEBUG_CATEGORY_EXTERN (v4lmjpegsrc_debug);
#define GST_CAT_DEFAULT v4lmjpegsrc_debug
enum
{
@ -59,7 +60,7 @@ enum
static gboolean
gst_v4lmjpegsrc_queue_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint num)
{
DEBUG ("queueing frame %d", num);
GST_DEBUG_OBJECT (v4lmjpegsrc, "queueing frame %d", num);
if (v4lmjpegsrc->frame_queue_state[num] != QUEUE_STATE_READY_FOR_QUEUE) {
return FALSE;
@ -88,7 +89,7 @@ gst_v4lmjpegsrc_queue_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint num)
static gboolean
gst_v4lmjpegsrc_sync_next_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint * num)
{
DEBUG ("syncing on next frame");
GST_DEBUG_OBJECT (v4lmjpegsrc, "syncing on next frame");
if (v4lmjpegsrc->num_queued <= 0) {
return FALSE;
@ -100,7 +101,7 @@ gst_v4lmjpegsrc_sync_next_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint * num)
GST_ELEMENT_ERROR (v4lmjpegsrc, RESOURCE, SYNC, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
DEBUG ("Sync got interrupted");
GST_DEBUG_OBJECT (v4lmjpegsrc, "Sync got interrupted");
}
*num = v4lmjpegsrc->bsync.frame;
@ -122,8 +123,8 @@ gboolean
gst_v4lmjpegsrc_set_buffer (GstV4lMjpegSrc * v4lmjpegsrc,
gint numbufs, gint bufsize)
{
DEBUG ("setting buffer info to numbufs = %d, bufsize = %d KB",
numbufs, bufsize);
GST_DEBUG_OBJECT (v4lmjpegsrc,
"setting buffer info to numbufs = %d, bufsize = %d KB", numbufs, bufsize);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
@ -147,7 +148,8 @@ gst_v4lmjpegsrc_set_capture (GstV4lMjpegSrc * v4lmjpegsrc,
int norm, input, mw;
struct mjpeg_params bparm;
DEBUG ("setting decimation = %d, quality = %d", decimation, quality);
GST_DEBUG_OBJECT (v4lmjpegsrc, "setting decimation = %d, quality = %d",
decimation, quality);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
@ -207,7 +209,7 @@ gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc * v4lmjpegsrc,
gint maxwidth;
struct mjpeg_params bparm;
DEBUG ("setting x_offset = %d, y_offset = %d, "
GST_DEBUG_OBJECT (v4lmjpegsrc, "setting x_offset = %d, y_offset = %d, "
"width = %d, height = %d, h_decimation = %d, v_decimation = %d, quality = %d\n",
x_offset, y_offset, width, height, h_decimation, v_decimation, quality);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
@ -318,7 +320,7 @@ gst_v4lmjpegsrc_set_capture_m (GstV4lMjpegSrc * v4lmjpegsrc,
gboolean
gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc * v4lmjpegsrc)
{
DEBUG ("initting capture subsystem");
GST_DEBUG_OBJECT (v4lmjpegsrc, "initting capture subsystem");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
@ -336,7 +338,7 @@ gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc * v4lmjpegsrc)
return FALSE;
}
GST_INFO ("Got %ld buffers of size %ld KB",
GST_INFO_OBJECT (v4lmjpegsrc, "Got %ld buffers of size %ld KB",
v4lmjpegsrc->breq.count, v4lmjpegsrc->breq.size / 1024);
/* keep track of queued buffers */
@ -378,7 +380,7 @@ gst_v4lmjpegsrc_capture_start (GstV4lMjpegSrc * v4lmjpegsrc)
{
int n;
DEBUG ("starting capture");
GST_DEBUG_OBJECT (v4lmjpegsrc, "starting capture");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
@ -414,7 +416,7 @@ gboolean
gst_v4lmjpegsrc_grab_frame (GstV4lMjpegSrc * v4lmjpegsrc,
gint * num, gint * size)
{
DEBUG ("grabbing frame");
GST_DEBUG_OBJECT (v4lmjpegsrc, "grabbing frame");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
@ -426,7 +428,8 @@ gst_v4lmjpegsrc_grab_frame (GstV4lMjpegSrc * v4lmjpegsrc,
QUEUE_STATE_READY_FOR_QUEUE) {
while (v4lmjpegsrc->frame_queue_state[v4lmjpegsrc->queue_frame] !=
QUEUE_STATE_READY_FOR_QUEUE && !v4lmjpegsrc->quit) {
GST_DEBUG ("Waiting for frames to become available (%d < %d)",
GST_DEBUG_OBJECT (v4lmjpegsrc,
"Waiting for frames to become available (%d < %d)",
v4lmjpegsrc->num_queued, MIN_BUFFERS_QUEUED);
g_cond_wait (v4lmjpegsrc->cond_queue_state,
v4lmjpegsrc->mutex_queue_state);
@ -487,7 +490,7 @@ gst_v4lmjpegsrc_get_buffer (GstV4lMjpegSrc * v4lmjpegsrc, gint num)
gboolean
gst_v4lmjpegsrc_requeue_frame (GstV4lMjpegSrc * v4lmjpegsrc, gint num)
{
DEBUG ("requeueing frame %d", num);
GST_DEBUG_OBJECT (v4lmjpegsrc, "requeueing frame %d", num);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
@ -523,7 +526,7 @@ gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc * v4lmjpegsrc)
{
int n;
DEBUG ("stopping capture");
GST_DEBUG_OBJECT (v4lmjpegsrc, "stopping capture");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));
@ -553,7 +556,7 @@ gst_v4lmjpegsrc_capture_stop (GstV4lMjpegSrc * v4lmjpegsrc)
gboolean
gst_v4lmjpegsrc_capture_deinit (GstV4lMjpegSrc * v4lmjpegsrc)
{
DEBUG ("quitting capture subsystem");
GST_DEBUG_OBJECT (v4lmjpegsrc, "quitting capture subsystem");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lmjpegsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lmjpegsrc));

View file

@ -1,4 +1,7 @@
/* G-Streamer hardware MJPEG video source plugin
/* GStreamer
*
* v4lmjpegsrc_calls.h: functions for hardware MJPEG video source
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or

View file

@ -1,4 +1,7 @@
/* G-Streamer BT8x8/V4L frame grabber plugin
/* GStreamer
*
* v4lsrc_calls.c: generic V4L source functions
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
@ -44,16 +47,6 @@ GST_DEBUG_CATEGORY_EXTERN (v4l_debug);
#define GST_CAT_DEFAULT v4l_debug
#define DEBUG(format, args...) \
GST_DEBUG_OBJECT (\
GST_ELEMENT(v4lsrc), \
"V4LSRC: " format, ##args)
#define LOG(format, args...) \
GST_LOG_OBJECT (\
GST_ELEMENT(v4lsrc), \
"V4LSRC: " format, ##args)
/* palette names */
static const char *palette_name[] = {
"", /* 0 */
@ -78,6 +71,7 @@ static const char *palette_name[] = {
/******************************************************
* gst_v4lsrc_queue_frame():
* queue a frame for capturing
* (ie. instruct the hardware to start capture)
* Requires queue_state lock to be held!
* return value: TRUE on success, FALSE on error
******************************************************/
@ -85,14 +79,14 @@ static const char *palette_name[] = {
static gboolean
gst_v4lsrc_queue_frame (GstV4lSrc * v4lsrc, gint num)
{
LOG ("queueing frame %d", num);
GST_LOG_OBJECT (v4lsrc, "queueing frame %d", num);
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_READY_FOR_QUEUE) {
return FALSE;
}
/* instruct the driver to prepare capture using buffer frame num */
v4lsrc->mmap.frame = num;
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd,
VIDIOCMCAPTURE, &(v4lsrc->mmap)) < 0) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, WRITE, (NULL),
@ -115,7 +109,7 @@ gst_v4lsrc_queue_frame (GstV4lSrc * v4lsrc, gint num)
static gboolean
gst_v4lsrc_sync_frame (GstV4lSrc * v4lsrc, gint num)
{
LOG ("Syncing on frame %d", num);
GST_LOG_OBJECT (v4lsrc, "VIOIOCSYNC on frame %d", num);
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_QUEUED) {
return FALSE;
@ -128,8 +122,9 @@ gst_v4lsrc_sync_frame (GstV4lSrc * v4lsrc, gint num)
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SYNC, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
DEBUG ("Sync got interrupted");
GST_DEBUG_OBJECT (v4lsrc, "Sync got interrupted");
}
GST_LOG_OBJECT (v4lsrc, "VIOIOCSYNC on frame %d done", num);
if (v4lsrc->clock) {
v4lsrc->timestamp_sync = gst_clock_get_time (v4lsrc->clock);
@ -156,7 +151,8 @@ gboolean
gst_v4lsrc_set_capture (GstV4lSrc * v4lsrc,
gint width, gint height, gint palette)
{
DEBUG ("capture properties set to width = %d, height = %d, palette = %d",
GST_DEBUG_OBJECT (v4lsrc,
"capture properties set to width = %d, height = %d, palette = %d",
width, height, palette);
/*GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); */
@ -179,11 +175,12 @@ gst_v4lsrc_set_capture (GstV4lSrc * v4lsrc,
gboolean
gst_v4lsrc_capture_init (GstV4lSrc * v4lsrc)
{
DEBUG ("initting capture subsystem");
GST_DEBUG_OBJECT (v4lsrc, "initting capture subsystem");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lsrc));
/* request buffer info */
/* request the mmap buffer info:
* total size of mmap buffer, number of frames, offsets of frames */
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCGMBUF,
&(v4lsrc->mbuf)) < 0) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, READ, (NULL),
@ -198,7 +195,7 @@ gst_v4lsrc_capture_init (GstV4lSrc * v4lsrc)
return FALSE;
}
GST_INFO ("Got %d buffers (\'%s\') of size %d KB",
GST_INFO_OBJECT (v4lsrc, "Got %d buffers (\'%s\') with total size %d KB",
v4lsrc->mbuf.frames, palette_name[v4lsrc->mmap.format],
v4lsrc->mbuf.size / (v4lsrc->mbuf.frames * 1024));
@ -218,7 +215,7 @@ gst_v4lsrc_capture_init (GstV4lSrc * v4lsrc)
GST_V4LELEMENT (v4lsrc)->buffer = mmap (0, v4lsrc->mbuf.size,
PROT_READ | PROT_WRITE, MAP_SHARED, GST_V4LELEMENT (v4lsrc)->video_fd, 0);
if (GST_V4LELEMENT (v4lsrc)->buffer == MAP_FAILED) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, OPEN_READ_WRITE, (NULL),
("Error mapping video buffers: %s", g_strerror (errno)));
GST_V4LELEMENT (v4lsrc)->buffer = NULL;
return FALSE;
@ -239,7 +236,7 @@ gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc)
{
int n;
DEBUG ("starting capture");
GST_DEBUG_OBJECT (v4lsrc, "starting capture");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
@ -250,7 +247,8 @@ gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc)
v4lsrc->sync_frame = 0;
v4lsrc->queue_frame = 0;
/* set all buffers ready to queue , this starts streaming capture */
/* set all buffers ready to queue, and queue captures to the device.
* This starts streaming capture */
for (n = 0; n < v4lsrc->mbuf.frames; n++) {
v4lsrc->frame_queue_state[n] = QUEUE_STATE_READY_FOR_QUEUE;
if (!gst_v4lsrc_queue_frame (v4lsrc, n)) {
@ -276,8 +274,7 @@ gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc)
gboolean
gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
{
LOG ("(%" GST_TIME_FORMAT ") grabbing frame",
GST_TIME_ARGS (gst_clock_get_time (v4lsrc->clock)));
GST_LOG_OBJECT (v4lsrc, "grabbing frame");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
@ -289,7 +286,8 @@ gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
QUEUE_STATE_READY_FOR_QUEUE) {
while (v4lsrc->frame_queue_state[v4lsrc->queue_frame] !=
QUEUE_STATE_READY_FOR_QUEUE && !v4lsrc->quit) {
GST_DEBUG ("Waiting for frames to become available (%d < %d)",
GST_DEBUG_OBJECT (v4lsrc,
"Waiting for frames to become available (%d < %d)",
v4lsrc->num_queued, MIN_BUFFERS_QUEUED);
g_cond_wait (v4lsrc->cond_queue_state, v4lsrc->mutex_queue_state);
}
@ -312,7 +310,7 @@ gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
}
v4lsrc->sync_frame = (v4lsrc->sync_frame + 1) % v4lsrc->mbuf.frames;
LOG ("(%" GST_TIME_FORMAT ") grabbed frame %d",
GST_LOG_OBJECT (v4lsrc, "(%" GST_TIME_FORMAT ") grabbed frame %d",
GST_TIME_ARGS (gst_clock_get_time (v4lsrc->clock)), *num);
g_mutex_unlock (v4lsrc->mutex_queue_state);
@ -323,7 +321,7 @@ gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
/******************************************************
* gst_v4lsrc_get_buffer():
* get the address of the just-capture buffer
* get the address of the given frame number in the mmap'd buffer
* return value: the buffer's address or NULL
******************************************************/
@ -350,7 +348,7 @@ gst_v4lsrc_get_buffer (GstV4lSrc * v4lsrc, gint num)
gboolean
gst_v4lsrc_requeue_frame (GstV4lSrc * v4lsrc, gint num)
{
LOG ("requeueing frame %d", num);
GST_LOG_OBJECT (v4lsrc, "requeueing frame %d", num);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
@ -384,7 +382,7 @@ gst_v4lsrc_requeue_frame (GstV4lSrc * v4lsrc, gint num)
gboolean
gst_v4lsrc_capture_stop (GstV4lSrc * v4lsrc)
{
DEBUG ("stopping capture");
GST_DEBUG_OBJECT (v4lsrc, "stopping capture");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
@ -420,18 +418,26 @@ gst_v4lsrc_capture_stop (GstV4lSrc * v4lsrc)
gboolean
gst_v4lsrc_capture_deinit (GstV4lSrc * v4lsrc)
{
DEBUG ("quitting capture subsystem");
GST_DEBUG_OBJECT (v4lsrc, "quitting capture subsystem");
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
/* free buffer tracker */
g_mutex_free (v4lsrc->mutex_queue_state);
v4lsrc->mutex_queue_state = NULL;
g_cond_free (v4lsrc->cond_queue_state);
v4lsrc->cond_queue_state = NULL;
g_free (v4lsrc->frame_queue_state);
v4lsrc->frame_queue_state = NULL;
g_free (v4lsrc->use_num_times);
v4lsrc->use_num_times = NULL;
/* unmap the buffer */
munmap (GST_V4LELEMENT (v4lsrc)->buffer, v4lsrc->mbuf.size);
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;
}
GST_V4LELEMENT (v4lsrc)->buffer = NULL;
return TRUE;
@ -463,7 +469,7 @@ gst_v4lsrc_try_palette (GstV4lSrc * v4lsrc, gint palette)
struct video_mbuf vmbuf;
struct video_mmap vmmap;
DEBUG ("gonna try out palette format %d (%s)",
GST_DEBUG_OBJECT (v4lsrc, "gonna try out palette format %d (%s)",
palette, palette_name[palette]);
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
GST_V4L_CHECK_NOT_ACTIVE (GST_V4LELEMENT (v4lsrc));
@ -478,7 +484,7 @@ gst_v4lsrc_try_palette (GstV4lSrc * v4lsrc, gint palette)
buffer = mmap (0, vmbuf.size, PROT_READ | PROT_WRITE,
MAP_SHARED, GST_V4LELEMENT (v4lsrc)->video_fd, 0);
if (buffer == MAP_FAILED) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, OPEN_READ_WRITE, (NULL),
("Error mapping our try-out buffer: %s", g_strerror (errno)));
return FALSE;
}
@ -490,7 +496,7 @@ gst_v4lsrc_try_palette (GstV4lSrc * v4lsrc, gint palette)
vmmap.frame = frame;
if (ioctl (GST_V4LELEMENT (v4lsrc)->video_fd, VIDIOCMCAPTURE, &vmmap) < 0) {
if (errno != EINVAL) /* our format failed! */
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, TOO_LAZY, (NULL),
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, OPEN_READ_WRITE, (NULL),
("Error queueing our try-out buffer: %s", g_strerror (errno)));
munmap (buffer, vmbuf.size);
return FALSE;

View file

@ -1,4 +1,7 @@
/* G-Streamer BT8x8/V4L frame grabber plugin
/* GStreamer
*
* v4lsrc_calls.h: functions for V4L video source
*
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or