Title: [294152] trunk/Source/WebCore
Revision
294152
Author
z...@falconsigh.net
Date
2022-05-13 02:14:07 -0700 (Fri, 13 May 2022)

Log Message

[GStreamer] Properly handle DMABuf-containing GstBuffers with missing DMABuf GstCaps feature
https://bugs.webkit.org/show_bug.cgi?id=240374

Reviewed by Chris Lord.

To detect DMABuf-backed GstBuffers, for now we relied on the appropriate
feature being present on the related GstCaps object. This doesn't cover
every decoder which for one reason or another isn't specifying their
caps like this.

For those cases, we have to do a weaker but sufficient check on the
base GstMemory object contained in the GstBuffer, namely test that it
comes from a DMABuf-capable allocator, through using the
gst_is_dmabuf_memory() function. When true, we can proceed on handling
the buffer and its contained DMABuf object.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::pushDMABufToCompositor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (294151 => 294152)


--- trunk/Source/WebCore/ChangeLog	2022-05-13 09:07:17 UTC (rev 294151)
+++ trunk/Source/WebCore/ChangeLog	2022-05-13 09:14:07 UTC (rev 294152)
@@ -1,5 +1,26 @@
 2022-05-13  Zan Dobersek  <zdober...@igalia.com>
 
+        [GStreamer] Properly handle DMABuf-containing GstBuffers with missing DMABuf GstCaps feature
+        https://bugs.webkit.org/show_bug.cgi?id=240374
+
+        Reviewed by Chris Lord.
+
+        To detect DMABuf-backed GstBuffers, for now we relied on the appropriate
+        feature being present on the related GstCaps object. This doesn't cover
+        every decoder which for one reason or another isn't specifying their
+        caps like this.
+
+        For those cases, we have to do a weaker but sufficient check on the
+        base GstMemory object contained in the GstBuffer, namely test that it
+        comes from a DMABuf-capable allocator, through using the
+        gst_is_dmabuf_memory() function. When true, we can proceed on handling
+        the buffer and its contained DMABuf object.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::pushDMABufToCompositor):
+
+2022-05-13  Zan Dobersek  <zdober...@igalia.com>
+
         [Linux][GBM] Provide utility function for construction of eglCreateImage attributes data
         https://bugs.webkit.org/show_bug.cgi?id=240373
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (294151 => 294152)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-05-13 09:07:17 UTC (rev 294151)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-05-13 09:14:07 UTC (rev 294152)
@@ -3081,8 +3081,13 @@
     auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy();
     ASSERT(is<TextureMapperPlatformLayerProxyDMABuf>(proxy));
 
-    auto* features = gst_caps_get_features(caps, 0);
-    if (gst_caps_features_contains(features, GST_CAPS_FEATURE_MEMORY_DMABUF)) {
+    // Currently we have to cover two ways of detecting a DMABuf memory. The most reliable is by detecting
+    // the memory:DMABuf feature on the GstCaps object. All sensible decoders yielding DMABufs specify this.
+    // For all other decoders, another option is peeking the zero-index GstMemory and testing whether it's
+    // a DMABuf memory, i.e. allocated by a DMABuf-capable allocator. If it is, we can proceed the same way.
+    bool isDMABufMemory = gst_caps_features_contains(gst_caps_get_features(caps, 0), GST_CAPS_FEATURE_MEMORY_DMABUF)
+        || gst_is_dmabuf_memory(gst_buffer_peek_memory(buffer, 0));
+    if (isDMABufMemory) {
         // In case of a hardware decoder that's yielding dmabuf memory, we can take the relevant data and
         // push it into the composition process.
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to