mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-13 07:02:53 +00:00
wayland: De-dupe filling caps format fields
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8268>
This commit is contained in:
parent
d327b576fd
commit
e0e7a11089
4 changed files with 77 additions and 66 deletions
|
@ -780,46 +780,21 @@ gst_gtk_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
|
|||
g_mutex_lock (&priv->display_lock);
|
||||
|
||||
if (priv->display) {
|
||||
GValue shm_list = G_VALUE_INIT, dmabuf_list = G_VALUE_INIT;
|
||||
GValue value = G_VALUE_INIT;
|
||||
GArray *formats, *modifiers;
|
||||
gint i;
|
||||
guint fmt;
|
||||
GstVideoFormat gfmt;
|
||||
guint64 mod;
|
||||
GValue format_list = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&shm_list, GST_TYPE_LIST);
|
||||
g_value_init (&dmabuf_list, GST_TYPE_LIST);
|
||||
g_value_init (&format_list, GST_TYPE_LIST);
|
||||
|
||||
/* Add corresponding shm formats */
|
||||
formats = gst_wl_display_get_shm_formats (priv->display);
|
||||
for (i = 0; i < formats->len; i++) {
|
||||
fmt = g_array_index (formats, uint32_t, i);
|
||||
gfmt = gst_wl_shm_format_to_video_format (fmt);
|
||||
if (gfmt != GST_VIDEO_FORMAT_UNKNOWN) {
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_set_static_string (&value, gst_video_format_to_string (gfmt));
|
||||
gst_value_list_append_and_take_value (&shm_list, &value);
|
||||
}
|
||||
}
|
||||
|
||||
gst_wl_display_fill_shm_format_list (priv->display, &format_list);
|
||||
gst_structure_take_value (gst_caps_get_structure (caps, 0), "format",
|
||||
&shm_list);
|
||||
&format_list);
|
||||
|
||||
g_value_init (&format_list, GST_TYPE_LIST);
|
||||
|
||||
/* Add corresponding dmabuf formats */
|
||||
formats = gst_wl_display_get_dmabuf_formats (priv->display);
|
||||
modifiers = gst_wl_display_get_dmabuf_modifiers (priv->display);
|
||||
for (i = 0; i < formats->len; i++) {
|
||||
fmt = g_array_index (formats, uint32_t, i);
|
||||
mod = g_array_index (modifiers, guint64, i);
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_take_string (&value, gst_video_dma_drm_fourcc_to_string (fmt,
|
||||
mod));
|
||||
gst_value_list_append_and_take_value (&dmabuf_list, &value);
|
||||
}
|
||||
|
||||
gst_wl_display_fill_dmabuf_format_list (priv->display, &format_list);
|
||||
gst_structure_take_value (gst_caps_get_structure (caps, 1), "drm-format",
|
||||
&dmabuf_list);
|
||||
&format_list);
|
||||
|
||||
GST_DEBUG_OBJECT (self, "display caps: %" GST_PTR_FORMAT, caps);
|
||||
}
|
||||
|
|
|
@ -565,46 +565,21 @@ gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
|
|||
g_mutex_lock (&self->display_lock);
|
||||
|
||||
if (self->display) {
|
||||
GValue shm_list = G_VALUE_INIT, dmabuf_list = G_VALUE_INIT;
|
||||
GValue value = G_VALUE_INIT;
|
||||
GArray *formats, *modifiers;
|
||||
gint i;
|
||||
guint fmt;
|
||||
GstVideoFormat gfmt;
|
||||
guint64 mod;
|
||||
GValue format_list = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&shm_list, GST_TYPE_LIST);
|
||||
g_value_init (&dmabuf_list, GST_TYPE_LIST);
|
||||
g_value_init (&format_list, GST_TYPE_LIST);
|
||||
|
||||
/* Add corresponding shm formats */
|
||||
formats = gst_wl_display_get_shm_formats (self->display);
|
||||
for (i = 0; i < formats->len; i++) {
|
||||
fmt = g_array_index (formats, uint32_t, i);
|
||||
gfmt = gst_wl_shm_format_to_video_format (fmt);
|
||||
if (gfmt != GST_VIDEO_FORMAT_UNKNOWN) {
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_set_static_string (&value, gst_video_format_to_string (gfmt));
|
||||
gst_value_list_append_and_take_value (&shm_list, &value);
|
||||
}
|
||||
}
|
||||
|
||||
gst_wl_display_fill_shm_format_list (self->display, &format_list);
|
||||
gst_structure_take_value (gst_caps_get_structure (caps, 0), "format",
|
||||
&shm_list);
|
||||
&format_list);
|
||||
|
||||
g_value_init (&format_list, GST_TYPE_LIST);
|
||||
|
||||
/* Add corresponding dmabuf formats */
|
||||
formats = gst_wl_display_get_dmabuf_formats (self->display);
|
||||
modifiers = gst_wl_display_get_dmabuf_modifiers (self->display);
|
||||
for (i = 0; i < formats->len; i++) {
|
||||
fmt = g_array_index (formats, uint32_t, i);
|
||||
mod = g_array_index (modifiers, guint64, i);
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_take_string (&value, gst_video_dma_drm_fourcc_to_string (fmt,
|
||||
mod));
|
||||
gst_value_list_append_and_take_value (&dmabuf_list, &value);
|
||||
}
|
||||
|
||||
gst_wl_display_fill_dmabuf_format_list (self->display, &format_list);
|
||||
gst_structure_take_value (gst_caps_get_structure (caps, 1), "drm-format",
|
||||
&dmabuf_list);
|
||||
&format_list);
|
||||
|
||||
GST_DEBUG_OBJECT (self, "display caps: %" GST_PTR_FORMAT, caps);
|
||||
}
|
||||
|
|
|
@ -676,6 +676,61 @@ gst_wl_display_get_dmabuf_formats (GstWlDisplay * self)
|
|||
return priv->dmabuf_formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_wl_display_fill_shm_format_list:
|
||||
* @self: A #GstWlDisplay
|
||||
* @format_list: A #GValue of type #GST_TYPE_LIST
|
||||
*
|
||||
* Append supported SHM formats to a given list, suitable for use with the "format" caps value.
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
void
|
||||
gst_wl_display_fill_shm_format_list (GstWlDisplay * self, GValue * format_list)
|
||||
{
|
||||
GstWlDisplayPrivate *priv = gst_wl_display_get_instance_private (self);
|
||||
GValue value = G_VALUE_INIT;
|
||||
guint fmt;
|
||||
GstVideoFormat gfmt;
|
||||
|
||||
for (gint i = 0; i < priv->shm_formats->len; i++) {
|
||||
fmt = g_array_index (priv->shm_formats, uint32_t, i);
|
||||
gfmt = gst_wl_shm_format_to_video_format (fmt);
|
||||
if (gfmt != GST_VIDEO_FORMAT_UNKNOWN) {
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_set_static_string (&value, gst_video_format_to_string (gfmt));
|
||||
gst_value_list_append_and_take_value (format_list, &value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_wl_display_fill_drm_format_list:
|
||||
* @self: A #GstWlDisplay
|
||||
* @format_list: A #GValue of type #GST_TYPE_LIST
|
||||
*
|
||||
* Append supported DRM formats to a given list, suitable for use with the "drm-format" caps value.
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
void
|
||||
gst_wl_display_fill_dmabuf_format_list (GstWlDisplay * self,
|
||||
GValue * format_list)
|
||||
{
|
||||
GstWlDisplayPrivate *priv = gst_wl_display_get_instance_private (self);
|
||||
GValue value = G_VALUE_INIT;
|
||||
guint fmt;
|
||||
guint64 mod;
|
||||
|
||||
for (gint i = 0; i < priv->dmabuf_formats->len; i++) {
|
||||
fmt = g_array_index (priv->dmabuf_formats, uint32_t, i);
|
||||
mod = g_array_index (priv->dmabuf_formats, guint64, i);
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_take_string (&value, gst_video_dma_drm_fourcc_to_string (fmt, mod));
|
||||
gst_value_list_append_and_take_value (format_list, &value);
|
||||
}
|
||||
}
|
||||
|
||||
struct wp_single_pixel_buffer_manager_v1 *
|
||||
gst_wl_display_get_single_pixel_buffer_manager_v1 (GstWlDisplay * self)
|
||||
{
|
||||
|
|
|
@ -103,6 +103,12 @@ GArray *gst_wl_display_get_dmabuf_formats (GstWlDisplay * self);
|
|||
GST_WL_API
|
||||
GArray *gst_wl_display_get_dmabuf_modifiers (GstWlDisplay * self);
|
||||
|
||||
GST_WL_API
|
||||
void gst_wl_display_fill_shm_format_list (GstWlDisplay *self, GValue *format_list);
|
||||
|
||||
GST_WL_API
|
||||
void gst_wl_display_fill_dmabuf_format_list (GstWlDisplay *self, GValue *format_list);
|
||||
|
||||
GST_WL_API
|
||||
struct zwp_linux_dmabuf_v1 *gst_wl_display_get_dmabuf_v1 (GstWlDisplay * self);
|
||||
|
||||
|
|
Loading…
Reference in a new issue