pipewiresrc: Always advertise support for DmaBuf

Quoting https://docs.pipewire.org/page_dma_buf.html section "v4l2":
```
It's the the responsibility of the producer while the add_buffer event
to choose DMA-BUF as the used buffer type even though no modifier is
present, if it can guarantee, that the used buffer is mmapable.
```

As Gstreamer internally can mmap dmabufs just fine, support this case.
This enables dmabuf support with V4L2 and libcamera.

This was also tested against Gnome-Shell, which correctly handles this
case and only chooses DmaBuf if the negotiated format has a modifier,
i.e. if the Gstreamer peer supports the format with
`GST_CAPS_FEATURE_MEMORY_DMABUF`.

Fixes 602aa7d541
This commit is contained in:
Robert Mader 2023-01-11 22:48:36 +01:00 committed by Wim Taymans
parent 17c53577e8
commit 6bf47e0bfa

View file

@ -964,14 +964,14 @@ on_param_changed (void *data, uint32_t id,
uint32_t buffers = CLAMP (16, pwsrc->min_buffers, pwsrc->max_buffers); uint32_t buffers = CLAMP (16, pwsrc->min_buffers, pwsrc->max_buffers);
int buffertypes; int buffertypes;
if (spa_pod_find_prop (param, NULL, SPA_FORMAT_VIDEO_modifier)) {
buffertypes = (1<<SPA_DATA_DmaBuf); buffertypes = (1<<SPA_DATA_DmaBuf);
if (spa_pod_find_prop (param, NULL, SPA_FORMAT_VIDEO_modifier)) {
gst_caps_features_remove (gst_caps_get_features (pwsrc->caps, 0), gst_caps_features_remove (gst_caps_get_features (pwsrc->caps, 0),
GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY); GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
gst_caps_features_add (gst_caps_get_features (pwsrc->caps, 0), gst_caps_features_add (gst_caps_get_features (pwsrc->caps, 0),
GST_CAPS_FEATURE_MEMORY_DMABUF); GST_CAPS_FEATURE_MEMORY_DMABUF);
} else { } else {
buffertypes = ((1<<SPA_DATA_MemFd) | (1<<SPA_DATA_MemPtr)); buffertypes |= ((1<<SPA_DATA_MemFd) | (1<<SPA_DATA_MemPtr));
} }
GST_DEBUG_OBJECT (pwsrc, "we got format %" GST_PTR_FORMAT, pwsrc->caps); GST_DEBUG_OBJECT (pwsrc, "we got format %" GST_PTR_FORMAT, pwsrc->caps);