mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
sys/v4l/: Probe less and cache it. Fixes #159187.
Original commit message from CVS: * sys/v4l/gstv4lsrc.c: * sys/v4l/gstv4lsrc.h: * sys/v4l/v4lsrc_calls.c: Probe less and cache it. Fixes #159187.
This commit is contained in:
parent
4735c6ad5f
commit
d680329e06
4 changed files with 51 additions and 23 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-11-23 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* sys/v4l/gstv4lsrc.c:
|
||||
* sys/v4l/gstv4lsrc.h:
|
||||
* sys/v4l/v4lsrc_calls.c:
|
||||
Probe less and cache it. Fixes #159187.
|
||||
|
||||
2004-11-23 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/videorate/gstvideorate.c:
|
||||
|
|
|
@ -287,6 +287,8 @@ gst_v4lsrc_init (GstV4lSrc * v4lsrc)
|
|||
v4lsrc->autoprobe_fps = TRUE;
|
||||
|
||||
v4lsrc->latency_offset = 0;
|
||||
|
||||
v4lsrc->fps_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -634,6 +636,7 @@ gst_v4lsrc_src_link (GstPad * pad, const GstCaps * vscapslist)
|
|||
return GST_PAD_LINK_DELAYED;
|
||||
}
|
||||
|
||||
/* FIXME: setting the first one is just stupid. We should loop */
|
||||
structure = gst_caps_get_structure (vscapslist, 0);
|
||||
|
||||
if (!strcmp (gst_structure_get_name (structure), "video/x-raw-yuv"))
|
||||
|
@ -644,6 +647,7 @@ gst_v4lsrc_src_link (GstPad * pad, const GstCaps * vscapslist)
|
|||
gst_structure_get_int (structure, "width", &w);
|
||||
gst_structure_get_int (structure, "height", &h);
|
||||
gst_structure_get_double (structure, "framerate", &fps);
|
||||
GST_DEBUG_OBJECT (v4lsrc, "linking with %dx%d at %f fps", w, h, fps);
|
||||
|
||||
/* set framerate if it's not already correct */
|
||||
if (fps != gst_v4lsrc_get_fps (v4lsrc)) {
|
||||
|
@ -812,7 +816,6 @@ gst_v4lsrc_getcaps (GstPad * pad)
|
|||
struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
|
||||
gfloat fps = 0.0;
|
||||
GList *item;
|
||||
GValue *fps_list = NULL;
|
||||
|
||||
if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
|
||||
return gst_caps_new_any ();
|
||||
|
@ -822,12 +825,12 @@ gst_v4lsrc_getcaps (GstPad * pad)
|
|||
return gst_caps_new_any ();
|
||||
}
|
||||
|
||||
/* FIXME: cache this on gst_v4l_open() */
|
||||
if (v4lsrc->autoprobe_fps) {
|
||||
fps_list = gst_v4lsrc_get_fps_list (v4lsrc);
|
||||
}
|
||||
if (!fps_list)
|
||||
fps = gst_v4lsrc_get_fps (v4lsrc);
|
||||
/*
|
||||
FIXME: if we choose a fixed one because we didn't probe, fixated caps don't
|
||||
work. So comment this out for now.
|
||||
if (!v4lsrc->fps_list)
|
||||
fps = gst_v4lsrc_get_fps (v4lsrc);
|
||||
*/
|
||||
|
||||
list = gst_caps_new_empty ();
|
||||
for (item = v4lsrc->colourspaces; item != NULL; item = item->next) {
|
||||
|
@ -855,15 +858,18 @@ gst_v4lsrc_getcaps (GstPad * pad)
|
|||
gst_caps_set_simple (one, "height", G_TYPE_INT, vcap->minheight, NULL);
|
||||
}
|
||||
|
||||
if (fps_list) {
|
||||
if (v4lsrc->fps_list) {
|
||||
GstStructure *structure = gst_caps_get_structure (one, 0);
|
||||
|
||||
gst_structure_set_value (structure, "framerate", fps_list);
|
||||
} else {
|
||||
gst_structure_set_value (structure, "framerate", v4lsrc->fps_list);
|
||||
}
|
||||
/* see higher up why we comment this
|
||||
else {
|
||||
GstStructure *structure = gst_caps_get_structure (one, 0);
|
||||
|
||||
gst_structure_set (structure, "framerate", G_TYPE_DOUBLE, fps, NULL);
|
||||
}
|
||||
*/
|
||||
GST_DEBUG_OBJECT (v4lsrc, "caps: %" GST_PTR_FORMAT, one);
|
||||
gst_caps_append (list, one);
|
||||
}
|
||||
|
@ -1163,14 +1169,14 @@ gst_v4lsrc_change_state (GstElement * element)
|
|||
GstV4lSrc *v4lsrc;
|
||||
GTimeVal time;
|
||||
gint transition = GST_STATE_TRANSITION (element);
|
||||
GstElementStateReturn parent_ret = GST_STATE_SUCCESS;
|
||||
|
||||
g_return_val_if_fail (GST_IS_V4LSRC (element), GST_STATE_FAILURE);
|
||||
|
||||
v4lsrc = GST_V4LSRC (element);
|
||||
|
||||
/* pre-parent state change */
|
||||
switch (transition) {
|
||||
case GST_STATE_NULL_TO_READY:
|
||||
break;
|
||||
case GST_STATE_READY_TO_PAUSED:
|
||||
v4lsrc->handled = 0;
|
||||
v4lsrc->need_discont = TRUE;
|
||||
|
@ -1210,9 +1216,22 @@ gst_v4lsrc_change_state (GstElement * element)
|
|||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
parent_ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
/* post-parent change_state */
|
||||
switch (transition) {
|
||||
case GST_STATE_NULL_TO_READY:
|
||||
GST_DEBUG_OBJECT (v4lsrc,
|
||||
"Doing post-parent NULL_TO_READY, checking probes");
|
||||
if (v4lsrc->autoprobe_fps) {
|
||||
GST_DEBUG_OBJECT (v4lsrc, "autoprobing framerates");
|
||||
v4lsrc->fps_list = gst_v4lsrc_get_fps_list (v4lsrc);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return parent_ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ typedef struct _GstV4lSrcClass GstV4lSrcClass;
|
|||
enum
|
||||
{
|
||||
QUEUE_STATE_ERROR = -1,
|
||||
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 */
|
||||
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 */
|
||||
};
|
||||
|
||||
typedef enum
|
||||
|
@ -101,11 +101,13 @@ struct _GstV4lSrc
|
|||
GList *colourspaces;
|
||||
|
||||
/* how are we going to timestamp buffers? */
|
||||
GstV4lSrcSyncMode syncmode;
|
||||
GstV4lSrcSyncMode syncmode;
|
||||
|
||||
gboolean copy_mode;
|
||||
gboolean autoprobe; /* probe features on startup ? */
|
||||
gboolean autoprobe_fps; /* probe fps on startup ? */
|
||||
gboolean copy_mode;
|
||||
gboolean autoprobe; /* probe features on startup ? */
|
||||
gboolean autoprobe_fps; /* probe fps on startup ? */
|
||||
|
||||
GValue *fps_list; /* list of fps probed */
|
||||
};
|
||||
|
||||
struct _GstV4lSrcClass
|
||||
|
|
|
@ -272,7 +272,7 @@ gst_v4lsrc_capture_start (GstV4lSrc * v4lsrc)
|
|||
gboolean
|
||||
gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
|
||||
{
|
||||
GST_LOG_OBJECT (v4lsrc, "grabbing frame %d", num);
|
||||
GST_LOG_OBJECT (v4lsrc, "grabbing frame %d", *num);
|
||||
GST_V4L_CHECK_OPEN (GST_V4LELEMENT (v4lsrc));
|
||||
GST_V4L_CHECK_ACTIVE (GST_V4LELEMENT (v4lsrc));
|
||||
|
||||
|
@ -285,7 +285,7 @@ gst_v4lsrc_grab_frame (GstV4lSrc * v4lsrc, gint * num)
|
|||
while (v4lsrc->frame_queue_state[v4lsrc->queue_frame] !=
|
||||
QUEUE_STATE_READY_FOR_QUEUE && !v4lsrc->quit) {
|
||||
GST_DEBUG_OBJECT (v4lsrc,
|
||||
"Waiting for frames to become available (%d < %d)",
|
||||
"Waiting for frames to become available (queued %d < minimum %d)",
|
||||
v4lsrc->num_queued, MIN_BUFFERS_QUEUED);
|
||||
g_cond_wait (v4lsrc->cond_queue_state, v4lsrc->mutex_queue_state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue