[mutter/gbsneto/dmabuf-screencast: 8/8] screen-cast-stream-src: Allow recording DMABuf frames



commit 2e3d637e38ef42ecdd9ecd5ba0a73bb24b98356b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Feb 24 13:40:21 2020 -0300

    screen-cast-stream-src: Allow recording DMABuf frames
    
    Handle the various places where DMABuf sharing and memfd differ.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1086

 src/backends/meta-screen-cast-stream-src.c | 34 ++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
index f49106e53..665c55445 100644
--- a/src/backends/meta-screen-cast-stream-src.c
+++ b/src/backends/meta-screen-cast-stream-src.c
@@ -419,6 +419,33 @@ maybe_record_cursor (MetaScreenCastStreamSrc *src,
   g_assert_not_reached ();
 }
 
+static gboolean
+do_record_frame (MetaScreenCastStreamSrc *src,
+                 struct spa_buffer       *spa_buffer,
+                 uint8_t                 *data)
+{
+  MetaScreenCastStreamSrcPrivate *priv =
+    meta_screen_cast_stream_src_get_instance_private (src);
+
+  if (spa_buffer->datas[0].data ||
+      spa_buffer->datas[0].type == SPA_DATA_MemFd)
+    {
+      return meta_screen_cast_stream_src_record_frame (src, data);
+    }
+  else if (spa_buffer->datas[0].type == SPA_DATA_DmaBuf)
+    {
+      CoglOnscreenDmabufHandle *dmabuf_handle =
+        g_hash_table_lookup (priv->dmabuf_handles,
+                             GINT_TO_POINTER (spa_buffer->datas[0].fd));
+      CoglFramebuffer *dmabuf_fbo =
+        cogl_onscreen_dmabuf_handle_get_framebuffer (dmabuf_handle);
+
+      return meta_screen_cast_stream_src_blit_to_framebuffer (src, dmabuf_fbo);
+    }
+
+  return FALSE;
+}
+
 void
 meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
 {
@@ -468,14 +495,17 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
 
       data = SPA_MEMBER (map, spa_buffer->datas[0].mapoffset, uint8_t);
     }
+  else if (spa_buffer->datas[0].type == SPA_DATA_DmaBuf)
+    {
+      /* Do nothing */
+    }
   else
     {
       g_warning ("Unhandled spa buffer type: %d", spa_buffer->datas[0].type);
       return;
     }
 
-  if (spa_buffer->datas[0].type != SPA_DATA_DmaBuf &&
-      meta_screen_cast_stream_src_record_frame (src, data))
+  if (do_record_frame (src, spa_buffer, data))
     {
       struct spa_meta_region *spa_meta_video_crop;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]