mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
gst: Sanitize caps before translating
DMABuf caps without concrete formats and modifiers don't map well to the Pipewire negotiation process. Introduce a new gst_caps_sanitize() helper function, where such cases can be handled.
This commit is contained in:
parent
f1b75fc6f8
commit
8a271a87b7
3 changed files with 47 additions and 1 deletions
|
|
@ -1176,3 +1176,43 @@ gst_caps_from_format (const struct spa_pod *format)
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
filter_dmabuf_caps (GstCapsFeatures *features,
|
||||
GstStructure *structure,
|
||||
gpointer user_data)
|
||||
{
|
||||
const GValue *value;
|
||||
const char *v;
|
||||
|
||||
if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_DMABUF))
|
||||
return TRUE;
|
||||
|
||||
if (!(value = gst_structure_get_value (structure, "format")) ||
|
||||
!(v = get_nth_string (value, 0)))
|
||||
return FALSE;
|
||||
|
||||
#ifdef HAVE_GSTREAMER_DMA_DRM
|
||||
{
|
||||
int idx;
|
||||
|
||||
idx = gst_video_format_from_string (v);
|
||||
if (idx == GST_VIDEO_FORMAT_UNKNOWN)
|
||||
return FALSE;
|
||||
|
||||
if (idx == GST_VIDEO_FORMAT_DMA_DRM &&
|
||||
!gst_structure_get_value (structure, "drm-format"))
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstCaps *
|
||||
gst_caps_sanitize (GstCaps *caps)
|
||||
{
|
||||
caps = gst_caps_make_writable (caps);
|
||||
gst_caps_filter_and_map_in_place (caps, filter_dmabuf_caps, NULL);
|
||||
return caps;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue