summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Seiderer <ps.report@gmx.net>2015-03-27 21:09:44 +0100
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2015-04-02 17:40:20 -0400
commitf160625ea674538be81d41c9286c7dd437c7a034 (patch)
treefa1aa52f849089e7338247aab277aa6788154fef
parent866d97fa2c9fe3b2de70d1b04454baa83edea92c (diff)
v4l2src: device sequence/offset correction in case of renegotiation
The v4l2 device restarts the sequence counter in case of streamoff/streamon, the GST offset values are supposed to increment strictly monotonic, so adjust the sequence counter/offset values in case of caps renegotiation. https://bugzilla.gnome.org/show_bug.cgi?id=745441
-rw-r--r--sys/v4l2/gstv4l2src.c10
-rw-r--r--sys/v4l2/gstv4l2src.h3
2 files changed, 11 insertions, 2 deletions
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index ab36a5820..633e46fb6 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -459,9 +459,10 @@ gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps)
* Basesrc will do an allocation query that
* should indirectly reclaim buffers, after that we can
* set the format and then configure our pool */
- if (gst_v4l2_object_try_format (obj, caps))
+ if (gst_v4l2_object_try_format (obj, caps)) {
+ v4l2src->renegotiation_adjust = v4l2src->offset + 1;
v4l2src->pending_set_fmt = TRUE;
- else
+ } else
return FALSE;
} else {
/* make sure we stop capturing and dealloc buffers */
@@ -588,6 +589,7 @@ gst_v4l2src_start (GstBaseSrc * src)
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
v4l2src->offset = 0;
+ v4l2src->renegotiation_adjust = 0;
/* activate settings for first frame */
v4l2src->ctrl_time = 0;
@@ -813,6 +815,10 @@ retry:
GST_BUFFER_OFFSET (*buf) = v4l2src->offset++;
GST_BUFFER_OFFSET_END (*buf) = v4l2src->offset;
} else {
+ /* adjust raw v4l2 device sequence, will restart at null in case of renegotiation
+ * (streamoff/streamon) */
+ GST_BUFFER_OFFSET (*buf) += v4l2src->renegotiation_adjust;
+ GST_BUFFER_OFFSET_END (*buf) += v4l2src->renegotiation_adjust;
/* check for frame loss with given (from v4l2 device) buffer offset */
if ((v4l2src->offset != 0) && (GST_BUFFER_OFFSET (*buf) != (v4l2src->offset + 1))) {
guint64 lost_frame_count = GST_BUFFER_OFFSET (*buf) - v4l2src->offset - 1;
diff --git a/sys/v4l2/gstv4l2src.h b/sys/v4l2/gstv4l2src.h
index 79dec17e0..90a0dd6ec 100644
--- a/sys/v4l2/gstv4l2src.h
+++ b/sys/v4l2/gstv4l2src.h
@@ -59,6 +59,9 @@ struct _GstV4l2Src
guint64 offset;
+ /* offset adjust after renegotiation */
+ guint64 renegotiation_adjust;
+
GstClockTime ctrl_time;
gboolean pending_set_fmt;