v4l2object: Copy timestamp when importing buffers
authorTodor Tomov <todor.tomov@linaro.org>
Mon, 10 Apr 2017 08:56:00 +0000 (08:56 +0000)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Mon, 10 Apr 2017 16:49:39 +0000 (12:49 -0400)
This is needed for V4L2_OUTPUT interface, and is harmless of
V4L2_CAPTURE interfaces. This will fix timestamp in cases like:

  v4l2src io-mode=dmabuf ! v4l2videoNenc output-io-mode=dmabuf-import !  ...

Same apply for userptr.

https://bugzilla.gnome.org/show_bug.cgi?id=781119

sys/v4l2/gstv4l2bufferpool.c

index b795e4a..48cda0f 100644 (file)
@@ -292,6 +292,9 @@ gst_v4l2_buffer_pool_import_userptr (GstV4l2BufferPool * pool,
   gst_mini_object_set_qdata (GST_MINI_OBJECT (dest), GST_V4L2_IMPORT_QUARK,
       data, (GDestroyNotify) _unmap_userptr_frame);
 
+  gst_buffer_copy_into (dest, src,
+      GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
+
   return ret;
 
 not_our_buffer:
@@ -346,6 +349,9 @@ gst_v4l2_buffer_pool_import_dmabuf (GstV4l2BufferPool * pool,
   gst_mini_object_set_qdata (GST_MINI_OBJECT (dest), GST_V4L2_IMPORT_QUARK,
       gst_buffer_ref (src), (GDestroyNotify) gst_buffer_unref);
 
+  gst_buffer_copy_into (dest, src,
+      GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
+
   return GST_FLOW_OK;
 
 not_our_buffer: