mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
waylandsink: handle the list of supported formats properly
enum wl_shm_format is not a flags enum, as it may have been in the past, so multiple formats cannot be stored in a bitfield. Use an array instead.
This commit is contained in:
parent
873671f2b6
commit
26ce7f2344
4 changed files with 26 additions and 11 deletions
|
@ -219,29 +219,37 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|||
GstWaylandSink *sink;
|
||||
GstBufferPool *newpool;
|
||||
GstVideoInfo info;
|
||||
enum wl_shm_format format;
|
||||
GArray *formats;
|
||||
gint i;
|
||||
GstStructure *structure;
|
||||
static GstAllocationParams params = { 0, 0, 0, 15, };
|
||||
guint size;
|
||||
|
||||
sink = GST_WAYLAND_SINK (bsink);
|
||||
|
||||
GST_LOG_OBJECT (sink, "set caps %" GST_PTR_FORMAT, caps);
|
||||
|
||||
/* extract info from caps */
|
||||
if (!gst_video_info_from_caps (&info, caps))
|
||||
goto invalid_format;
|
||||
|
||||
if (!gst_wayland_sink_format_from_caps (&sink->format, caps))
|
||||
format = gst_video_format_to_wayland_format (GST_VIDEO_INFO_FORMAT (&info));
|
||||
if (format == -1)
|
||||
goto invalid_format;
|
||||
|
||||
if (!(sink->display->formats & (1 << sink->format))) {
|
||||
GST_DEBUG_OBJECT (sink, "%s not available",
|
||||
gst_wayland_format_to_string (sink->format));
|
||||
return FALSE;
|
||||
/* verify we support the requested format */
|
||||
formats = sink->display->formats;
|
||||
for (i = 0; i < formats->len; i++) {
|
||||
if (g_array_index (formats, uint32_t, i) == format)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= formats->len)
|
||||
goto unsupported_format;
|
||||
|
||||
/* store the video size */
|
||||
sink->video_width = info.width;
|
||||
sink->video_height = info.height;
|
||||
size = info.size;
|
||||
|
||||
/* create a new pool for the new configuration */
|
||||
newpool = gst_wayland_buffer_pool_new (sink->display);
|
||||
|
@ -252,7 +260,7 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|||
}
|
||||
|
||||
structure = gst_buffer_pool_get_config (newpool);
|
||||
gst_buffer_pool_config_set_params (structure, caps, size, 2, 0);
|
||||
gst_buffer_pool_config_set_params (structure, caps, info.size, 2, 0);
|
||||
gst_buffer_pool_config_set_allocator (structure, NULL, ¶ms);
|
||||
if (!gst_buffer_pool_set_config (newpool, structure))
|
||||
goto config_failed;
|
||||
|
@ -268,6 +276,12 @@ invalid_format:
|
|||
"Could not locate image format from caps %" GST_PTR_FORMAT, caps);
|
||||
return FALSE;
|
||||
}
|
||||
unsupported_format:
|
||||
{
|
||||
GST_DEBUG_OBJECT (sink, "Format %s is not available on the display",
|
||||
gst_wayland_format_to_string (format));
|
||||
return FALSE;
|
||||
}
|
||||
config_failed:
|
||||
{
|
||||
GST_DEBUG_OBJECT (bsink, "failed setting config");
|
||||
|
|
|
@ -58,7 +58,6 @@ struct _GstWaylandSink
|
|||
|
||||
gint video_width;
|
||||
gint video_height;
|
||||
enum wl_shm_format format;
|
||||
|
||||
gchar *display_name;
|
||||
};
|
||||
|
|
|
@ -43,6 +43,7 @@ gst_wl_display_class_init (GstWlDisplayClass * klass)
|
|||
static void
|
||||
gst_wl_display_init (GstWlDisplay * self)
|
||||
{
|
||||
self->formats = g_array_new (FALSE, FALSE, sizeof (uint32_t));
|
||||
self->wl_fd_poll = gst_poll_new (TRUE);
|
||||
}
|
||||
|
||||
|
@ -56,6 +57,7 @@ gst_wl_display_finalize (GObject * gobject)
|
|||
if (self->thread)
|
||||
g_thread_join (self->thread);
|
||||
|
||||
g_array_unref (self->formats);
|
||||
gst_poll_free (self->wl_fd_poll);
|
||||
|
||||
if (self->shm)
|
||||
|
@ -117,7 +119,7 @@ shm_format (void *data, struct wl_shm *wl_shm, uint32_t format)
|
|||
{
|
||||
GstWlDisplay *self = data;
|
||||
|
||||
self->formats |= (1 << format);
|
||||
g_array_append_val (self->formats, format);
|
||||
}
|
||||
|
||||
static const struct wl_shm_listener shm_listener = {
|
||||
|
|
|
@ -47,7 +47,7 @@ struct _GstWlDisplay
|
|||
struct wl_compositor *compositor;
|
||||
struct wl_shell *shell;
|
||||
struct wl_shm *shm;
|
||||
guint32 formats;
|
||||
GArray *formats;
|
||||
|
||||
/* private */
|
||||
gboolean own_display;
|
||||
|
|
Loading…
Reference in a new issue