d3d11videosink: Ensure upload staging texture to fallback render texture
authorSeungha Yang <seungha.yang@navercorp.com>
Sun, 16 Feb 2020 08:11:29 +0000 (17:11 +0900)
committerSeungha Yang <seungha.yang@navercorp.com>
Sun, 16 Feb 2020 12:29:08 +0000 (21:29 +0900)
gst_video_frame_copy will copy input frame to stating texture
of fallback frame. Then, we need to map fallback texture with GST_MAP_D3D11
flag to upload the staging texture to render texture. Otherwise
the render texture wouldn't be updated.

sys/d3d11/gstd3d11videosink.c

index 3eb9e35..84297fa 100644 (file)
@@ -735,6 +735,7 @@ gst_d3d11_video_sink_upload_frame (GstD3D11VideoSink * self, GstBuffer * inbuf,
 {
   GstVideoFrame in_frame, out_frame;
   gboolean ret;
+  gint i;
 
   if (!gst_video_frame_map (&in_frame, &self->info, inbuf,
           GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))
@@ -751,6 +752,22 @@ gst_d3d11_video_sink_upload_frame (GstD3D11VideoSink * self, GstBuffer * inbuf,
   gst_video_frame_unmap (&in_frame);
   gst_video_frame_unmap (&out_frame);
 
+  if (ret) {
+    /* map to upload staging texture to render texture */
+    for (i = 0; i < gst_buffer_n_memory (outbuf); i++) {
+      GstMemory *mem;
+      GstMapInfo map;
+
+      mem = gst_buffer_peek_memory (outbuf, i);
+      if (!gst_memory_map (mem, &map, (GST_MAP_READ | GST_MAP_D3D11))) {
+        GST_ERROR_OBJECT (self, "cannot upload staging texture");
+        ret = FALSE;
+        break;
+      }
+      gst_memory_unmap (mem, &map);
+    }
+  }
+
   return ret;
 
   /* ERRORS */