v4l2: pool: Adjust pool behaviour when DMA_DRM is used
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 18 Dec 2024 20:13:17 +0000 (15:13 -0500)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 18 Dec 2024 23:34:08 +0000 (23:34 +0000)
We disable the copy threshold and always add GstVideoMeta.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7633>

subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c
subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.h

index 98c7dbe084431bd2e33e7fcb0a46e3526f127204..55ae3d86073dc15198ae92ef666c0872087bbb57 100644 (file)
@@ -526,15 +526,19 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
   gboolean updated = FALSE;
   gboolean ret;
 
-  pool->add_videometa =
-      gst_buffer_pool_config_has_option (config,
-      GST_BUFFER_POOL_OPTION_VIDEO_META);
-
   /* parse the config and keep around */
   if (!gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers,
           &max_buffers))
     goto wrong_config;
 
+  pool->add_videometa =
+      gst_buffer_pool_config_has_option (config,
+      GST_BUFFER_POOL_OPTION_VIDEO_META);
+
+  /* Always enable VideoMeta when we negotiate memory:DMABuf */
+  pool->have_dma_drm_caps = gst_video_is_dma_drm_caps (caps);
+  pool->add_videometa |= pool->have_dma_drm_caps;
+
   if (!gst_buffer_pool_config_get_allocator (config, &allocator, &params))
     goto wrong_config;
 
@@ -2258,7 +2262,8 @@ void
 gst_v4l2_buffer_pool_copy_at_threshold (GstV4l2BufferPool * pool, gboolean copy)
 {
   GST_OBJECT_LOCK (pool);
-  pool->enable_copy_threshold = copy;
+  /* Ignore copy threashold when memory:DMABuf caps features is in used */
+  pool->enable_copy_threshold = copy && !pool->have_dma_drm_caps;
   GST_OBJECT_UNLOCK (pool);
 }
 
index db8c554306995701b2f3fbee30d9ca760cc02ec7..517e45f821d3ff3475d842fa44a49996b515280a 100644 (file)
@@ -76,6 +76,7 @@ struct _GstV4l2BufferPool
   GstBufferPool *other_pool;
   guint size;
   GstVideoInfo caps_info;   /* Default video information */
+  gboolean have_dma_drm_caps; /* If the configured caps have memory:DMABuf */
 
   gboolean add_videometa;    /* set if video meta should be added */
   gboolean enable_copy_threshold; /* If copy_threshold should be set */