mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
query v4lsrc device for fps (which works for webcams)
Original commit message from CVS: query v4lsrc device for fps (which works for webcams)
This commit is contained in:
parent
36fef2e569
commit
7da21bd2e8
6 changed files with 50 additions and 10 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2004-05-03 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* sys/v4l/gstv4lelement.h:
|
||||||
|
* sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_class_init):
|
||||||
|
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_fps), (gst_v4lsrc_getcaps),
|
||||||
|
(gst_v4lsrc_buffer_free):
|
||||||
|
* sys/v4l/v4l_calls.c: (gst_v4l_get_capabilities):
|
||||||
|
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_queue_frame),
|
||||||
|
(gst_v4lsrc_sync_frame), (gst_v4lsrc_grab_frame),
|
||||||
|
(gst_v4lsrc_requeue_frame):
|
||||||
|
move some debugging categories around
|
||||||
|
query for fps index and set accordingly if found
|
||||||
|
|
||||||
2004-05-03 Stephane Loeuillet <stephane.loeuillet@tiscali.fr>
|
2004-05-03 Stephane Loeuillet <stephane.loeuillet@tiscali.fr>
|
||||||
|
|
||||||
* ext/lame/gstlame.c:
|
* ext/lame/gstlame.c:
|
||||||
|
|
|
@ -70,9 +70,12 @@ struct _GstV4lElement {
|
||||||
/* the video buffer (mmap()'ed) */
|
/* the video buffer (mmap()'ed) */
|
||||||
guint8 *buffer;
|
guint8 *buffer;
|
||||||
|
|
||||||
/* the video-device's capabilities */
|
/* the video device's capabilities */
|
||||||
struct video_capability vcap;
|
struct video_capability vcap;
|
||||||
|
|
||||||
|
/* the video device's window properties */
|
||||||
|
struct video_window vwin;
|
||||||
|
|
||||||
/* some more info about the current input's capabilities */
|
/* some more info about the current input's capabilities */
|
||||||
struct video_channel vchan;
|
struct video_channel vchan;
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ gst_v4lmjpegsrc_class_init (GstV4lMjpegSrcClass * klass)
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_FIXED_FPS,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_USE_FIXED_FPS,
|
||||||
g_param_spec_boolean ("use_fixed_fps", "Use Fixed FPS",
|
g_param_spec_boolean ("use_fixed_fps", "Use Fixed FPS",
|
||||||
"Drop/Insert frames to reach a certain FPS (TRUE) "
|
"Drop/Insert frames to reach a certain FPS (TRUE) "
|
||||||
"or adapt FPS to suit the number of frabbed frames",
|
"or adapt FPS to suit the number of grabbed frames",
|
||||||
TRUE, G_PARAM_READWRITE));
|
TRUE, G_PARAM_READWRITE));
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
|
|
|
@ -277,7 +277,18 @@ static gfloat
|
||||||
gst_v4lsrc_get_fps (GstV4lSrc * v4lsrc)
|
gst_v4lsrc_get_fps (GstV4lSrc * v4lsrc)
|
||||||
{
|
{
|
||||||
gint norm;
|
gint norm;
|
||||||
|
gint fps_index;
|
||||||
gfloat fps;
|
gfloat fps;
|
||||||
|
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 */
|
||||||
|
if (fps_index != 0)
|
||||||
|
/* index of 16 corresponds to 15 fps */
|
||||||
|
return fps_index * 15.0 / 16;
|
||||||
|
|
||||||
if (!v4lsrc->use_fixed_fps && v4lsrc->clock != NULL && v4lsrc->handled > 0) {
|
if (!v4lsrc->use_fixed_fps && v4lsrc->clock != NULL && v4lsrc->handled > 0) {
|
||||||
/* try to get time from clock master and calculate fps */
|
/* try to get time from clock master and calculate fps */
|
||||||
|
@ -622,6 +633,8 @@ gst_v4lsrc_getcaps (GstPad * pad)
|
||||||
return gst_caps_new_any ();
|
return gst_caps_new_any ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fps = gst_v4lsrc_get_fps (v4lsrc);
|
||||||
|
|
||||||
list = gst_caps_new_empty ();
|
list = gst_caps_new_empty ();
|
||||||
for (item = v4lsrc->colourspaces; item != NULL; item = item->next) {
|
for (item = v4lsrc->colourspaces; item != NULL; item = item->next) {
|
||||||
GstCaps *one;
|
GstCaps *one;
|
||||||
|
@ -629,7 +642,6 @@ gst_v4lsrc_getcaps (GstPad * pad)
|
||||||
one = gst_v4lsrc_palette_to_caps (GPOINTER_TO_INT (item->data));
|
one = gst_v4lsrc_palette_to_caps (GPOINTER_TO_INT (item->data));
|
||||||
if (!one)
|
if (!one)
|
||||||
g_print ("Palette %d gave no caps\n", GPOINTER_TO_INT (item->data));
|
g_print ("Palette %d gave no caps\n", GPOINTER_TO_INT (item->data));
|
||||||
fps = gst_v4lsrc_get_fps (v4lsrc);
|
|
||||||
GST_DEBUG_OBJECT (v4lsrc,
|
GST_DEBUG_OBJECT (v4lsrc,
|
||||||
"Device reports w: %d-%d, h: %d-%d, fps: %f for palette %d",
|
"Device reports w: %d-%d, h: %d-%d, fps: %f for palette %d",
|
||||||
vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight, fps,
|
vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight, fps,
|
||||||
|
@ -895,14 +907,14 @@ gst_v4lsrc_buffer_free (GstBuffer * buf)
|
||||||
g_free (v4lsrc_private);
|
g_free (v4lsrc_private);
|
||||||
GST_BUFFER_PRIVATE (buf) = 0;
|
GST_BUFFER_PRIVATE (buf) = 0;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (v4lsrc, "freeing buffer %p with refcount %d for frame %d",
|
GST_LOG_OBJECT (v4lsrc, "freeing buffer %p with refcount %d for frame %d",
|
||||||
buf, GST_BUFFER_REFCOUNT_VALUE (buf), num);
|
buf, GST_BUFFER_REFCOUNT_VALUE (buf), num);
|
||||||
if (gst_element_get_state (GST_ELEMENT (v4lsrc)) != GST_STATE_PLAYING)
|
if (gst_element_get_state (GST_ELEMENT (v4lsrc)) != GST_STATE_PLAYING)
|
||||||
return; /* we've already cleaned up ourselves */
|
return; /* we've already cleaned up ourselves */
|
||||||
|
|
||||||
v4lsrc->use_num_times[num]--;
|
v4lsrc->use_num_times[num]--;
|
||||||
if (v4lsrc->use_num_times[num] <= 0) {
|
if (v4lsrc->use_num_times[num] <= 0) {
|
||||||
GST_DEBUG_OBJECT (v4lsrc, "requeueing frame %d", num);
|
GST_LOG_OBJECT (v4lsrc, "requeueing frame %d", num);
|
||||||
gst_v4lsrc_requeue_frame (v4lsrc, num);
|
gst_v4lsrc_requeue_frame (v4lsrc, num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,13 @@ gst_v4l_get_capabilities (GstV4lElement * v4lelement)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ioctl (v4lelement->video_fd, VIDIOCGWIN, &(v4lelement->vwin)) < 0) {
|
||||||
|
GST_ELEMENT_ERROR (v4lelement, RESOURCE, SETTINGS, (NULL),
|
||||||
|
("error getting window properties %s of from device %s",
|
||||||
|
g_strerror (errno), v4lelement->videodev));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,11 @@ GST_DEBUG_CATEGORY_EXTERN (v4l_debug);
|
||||||
GST_DEBUG_OBJECT (\
|
GST_DEBUG_OBJECT (\
|
||||||
GST_ELEMENT(v4lsrc), \
|
GST_ELEMENT(v4lsrc), \
|
||||||
"V4LSRC: " format, ##args)
|
"V4LSRC: " format, ##args)
|
||||||
|
#define LOG(format, args...) \
|
||||||
|
GST_LOG_OBJECT (\
|
||||||
|
GST_ELEMENT(v4lsrc), \
|
||||||
|
"V4LSRC: " format, ##args)
|
||||||
|
|
||||||
|
|
||||||
/* palette names */
|
/* palette names */
|
||||||
static const char *palette_name[] = {
|
static const char *palette_name[] = {
|
||||||
|
@ -80,7 +85,7 @@ static const char *palette_name[] = {
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_v4lsrc_queue_frame (GstV4lSrc * v4lsrc, gint num)
|
gst_v4lsrc_queue_frame (GstV4lSrc * v4lsrc, gint num)
|
||||||
{
|
{
|
||||||
DEBUG ("queueing frame %d", num);
|
LOG ("queueing frame %d", num);
|
||||||
|
|
||||||
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_READY_FOR_QUEUE) {
|
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_READY_FOR_QUEUE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -110,7 +115,7 @@ gst_v4lsrc_queue_frame (GstV4lSrc * v4lsrc, gint num)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_v4lsrc_sync_frame (GstV4lSrc * v4lsrc, gint num)
|
gst_v4lsrc_sync_frame (GstV4lSrc * v4lsrc, gint num)
|
||||||
{
|
{
|
||||||
DEBUG ("Syncing on frame %d", num);
|
LOG ("Syncing on frame %d", num);
|
||||||
|
|
||||||
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_QUEUED) {
|
if (v4lsrc->frame_queue_state[num] != QUEUE_STATE_QUEUED) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -271,7 +276,7 @@ gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc)
|
||||||
gboolean
|
gboolean
|
||||||
gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
|
gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
|
||||||
{
|
{
|
||||||
DEBUG ("grabbing frame");
|
LOG ("grabbing frame");
|
||||||
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
||||||
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
||||||
|
|
||||||
|
@ -306,7 +311,7 @@ gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
|
||||||
}
|
}
|
||||||
v4lsrc->sync_frame = (v4lsrc->sync_frame + 1) % v4lsrc->mbuf.frames;
|
v4lsrc->sync_frame = (v4lsrc->sync_frame + 1) % v4lsrc->mbuf.frames;
|
||||||
|
|
||||||
GST_DEBUG ("grabbed frame %d", *num);
|
GST_LOG ("grabbed frame %d", *num);
|
||||||
|
|
||||||
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
g_mutex_unlock (v4lsrc->mutex_queue_state);
|
||||||
|
|
||||||
|
@ -343,7 +348,7 @@ gst_v4lsrc_get_buffer (GstV4lSrc * v4lsrc, gint num)
|
||||||
gboolean
|
gboolean
|
||||||
gst_v4lsrc_requeue_frame (GstV4lSrc * v4lsrc, gint num)
|
gst_v4lsrc_requeue_frame (GstV4lSrc * v4lsrc, gint num)
|
||||||
{
|
{
|
||||||
DEBUG ("requeueing frame %d", num);
|
LOG ("requeueing frame %d", num);
|
||||||
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
||||||
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue