stm-st-stm32mp: add support to gstreamer1.0 recipes for STM32 paltforms
https://onedigi.atlassian.net/browse/DEL-7981 Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
parent
bdb42db0f1
commit
ee2a28f3cc
|
|
@ -0,0 +1,35 @@
|
|||
From a01f2526663eee1d98f2e133d076a5dcb556d1ea Mon Sep 17 00:00:00 2001
|
||||
From: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
|
||||
Date: Tue, 26 Apr 2022 11:30:31 +0200
|
||||
Subject: [PATCH] gstreamer1.0-libav: disable decoder direct rendering by
|
||||
default
|
||||
|
||||
DMA-buf 0-copy path and direct-rendering mode are not yet compatible
|
||||
because of stride and offset issues.
|
||||
Nevertheless performances are better than with direct-rendering enabled
|
||||
and virtual memory path.
|
||||
|
||||
This fix is required to reach 30fps on display driver side
|
||||
with 30fps VGA video content.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/libav/gstavviddec.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c
|
||||
index f5197fb..fde599b 100644
|
||||
--- a/ext/libav/gstavviddec.c
|
||||
+++ b/ext/libav/gstavviddec.c
|
||||
@@ -41,7 +41,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
|
||||
|
||||
#define DEFAULT_LOWRES 0
|
||||
#define DEFAULT_SKIPFRAME 0
|
||||
-#define DEFAULT_DIRECT_RENDERING TRUE
|
||||
+#define DEFAULT_DIRECT_RENDERING FALSE
|
||||
#define DEFAULT_MAX_THREADS 0
|
||||
#define DEFAULT_OUTPUT_CORRUPT TRUE
|
||||
#define REQUIRED_POOL_MAX_BUFFERS 32
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
|
||||
|
||||
SRC_URI:append = " file://0001-gstreamer1.0-libav-disable-decoder-direct-rendering-.patch "
|
||||
|
|
@ -0,0 +1,999 @@
|
|||
From ddeb2fe4af5c62235c31bba257354258ad14d7a1 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
|
||||
Date: Thu, 5 Sep 2019 16:19:22 +0200
|
||||
Subject: [PATCH 01/14] waylandsink: add dmabuf bufferpool
|
||||
|
||||
Add support of DMA-buf allocated buffers through use of
|
||||
drm/kms kernel driver ioctl DRM_IOCTL_MODE_CREATE_DUMB.
|
||||
This pool is selected if video/x-raw(memory:DMABuf)
|
||||
is set in caps.
|
||||
|
||||
Change-Id: I0507752a1a64ee2c657b73d8c802c44fd707f49f
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/gstwaylandsink.c | 108 +++++-
|
||||
ext/wayland/waylandpool.c | 640 +++++++++++++++++++++++++++++++++++
|
||||
ext/wayland/waylandpool.h | 105 ++++++
|
||||
ext/wayland/wldisplay.c | 3 +
|
||||
ext/wayland/wldisplay.h | 9 +-
|
||||
5 files changed, 853 insertions(+), 12 deletions(-)
|
||||
create mode 100644 ext/wayland/waylandpool.c
|
||||
create mode 100644 ext/wayland/waylandpool.h
|
||||
|
||||
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
||||
index 0761304..20df1bf 100644
|
||||
--- a/ext/wayland/gstwaylandsink.c
|
||||
+++ b/ext/wayland/gstwaylandsink.c
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "wlbuffer.h"
|
||||
#include "wlshmallocator.h"
|
||||
#include "wllinuxdmabuf.h"
|
||||
+#include "waylandpool.h"
|
||||
|
||||
#include <gst/wayland/wayland.h>
|
||||
#include <gst/video/videooverlay.h>
|
||||
@@ -557,6 +558,36 @@ gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps)
|
||||
return pool;
|
||||
}
|
||||
|
||||
+static GstBufferPool *
|
||||
+gst_wayland_create_dmabuf_pool (GstWaylandSink * sink, GstCaps * caps)
|
||||
+{
|
||||
+ GstBufferPool *pool = NULL;
|
||||
+ GstStructure *structure;
|
||||
+ gsize size = sink->video_info.size;
|
||||
+ GstAllocator *alloc;
|
||||
+
|
||||
+ /* create a new DMABuf pool */
|
||||
+ pool = gst_wayland_buffer_pool_new (sink->display);
|
||||
+ if (!pool) {
|
||||
+ GST_DEBUG_OBJECT (sink, "Failed to create new pool");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ structure = gst_buffer_pool_get_config (pool);
|
||||
+ gst_buffer_pool_config_set_params (structure, caps, info.size, 2, 0);
|
||||
+ gst_buffer_pool_config_set_allocator (structure, NULL, ¶ms);
|
||||
+ alloc = gst_dmabuf_allocator_new ();
|
||||
+ gst_buffer_pool_config_set_allocator (structure, alloc, NULL);
|
||||
+ if (!gst_buffer_pool_set_config (pool, structure)) {
|
||||
+ GST_DEBUG_OBJECT (sink, "failed setting config");
|
||||
+ gst_object_unref (pool);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ g_object_unref (alloc);
|
||||
+
|
||||
+ return pool;
|
||||
+}
|
||||
+
|
||||
static gboolean
|
||||
gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
||||
{
|
||||
@@ -575,15 +606,9 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
||||
format = GST_VIDEO_INFO_FORMAT (&sink->video_info);
|
||||
sink->video_info_changed = TRUE;
|
||||
|
||||
- /* create a new pool for the new caps */
|
||||
- if (sink->pool)
|
||||
- gst_object_unref (sink->pool);
|
||||
- sink->pool = gst_wayland_create_pool (sink, caps);
|
||||
-
|
||||
use_dmabuf = gst_caps_features_contains (gst_caps_get_features (caps, 0),
|
||||
GST_CAPS_FEATURE_MEMORY_DMABUF);
|
||||
|
||||
- /* validate the format base on the memory type. */
|
||||
if (use_dmabuf) {
|
||||
if (!gst_wl_display_check_format_for_dmabuf (sink->display, format))
|
||||
goto unsupported_format;
|
||||
@@ -591,6 +616,14 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
||||
goto unsupported_format;
|
||||
}
|
||||
|
||||
+ /* create a new pool for the new caps */
|
||||
+ if (sink->pool)
|
||||
+ gst_object_unref (sink->pool);
|
||||
+ if (use_dmabuf)
|
||||
+ sink->pool = gst_wayland_create_dmabuf_pool (sink, caps);
|
||||
+ else
|
||||
+ sink->pool = gst_wayland_create_pool (sink, caps);
|
||||
+
|
||||
sink->use_dmabuf = use_dmabuf;
|
||||
|
||||
return TRUE;
|
||||
@@ -610,7 +643,7 @@ unsupported_format:
|
||||
}
|
||||
|
||||
static gboolean
|
||||
-gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
||||
+gst_wayland_sink_propose_shm_allocation (GstBaseSink * bsink, GstQuery * query)
|
||||
{
|
||||
GstWaylandSink *sink = GST_WAYLAND_SINK (bsink);
|
||||
GstCaps *caps;
|
||||
@@ -635,6 +668,67 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+static gboolean
|
||||
+gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
||||
+{
|
||||
+ GstWaylandSink *sink = GST_WAYLAND_SINK (bsink);
|
||||
+ GstCaps *caps;
|
||||
+ GstBufferPool *pool = NULL;
|
||||
+ GstStructure *config;
|
||||
+ guint size;
|
||||
+ gboolean need_pool;
|
||||
+ GstAllocator *alloc;
|
||||
+ GstCaps *pcaps;
|
||||
+ guint config_min_buf, config_max_buf;
|
||||
+
|
||||
+ if (!sink->use_dmabuf)
|
||||
+ return gst_wayland_sink_propose_shm_allocation(bsink, query);
|
||||
+
|
||||
+ /*
|
||||
+ * propose DMA-buf allocator...
|
||||
+ */
|
||||
+ gst_query_parse_allocation (query, &caps, &need_pool);
|
||||
+
|
||||
+ if (need_pool) {
|
||||
+ /* Fill query with DMABuf pool characteristics,
|
||||
+ * to do so create a pool, get its characteristics
|
||||
+ * to fill query and free it...
|
||||
+ */
|
||||
+ pool = gst_wayland_create_dmabuf_pool (sink, caps);
|
||||
+ if (!pool)
|
||||
+ goto no_pool;
|
||||
+
|
||||
+ config = gst_buffer_pool_get_config (pool);
|
||||
+ gst_buffer_pool_config_get_params (config, &pcaps, &size,
|
||||
+ &config_min_buf, &config_max_buf);
|
||||
+ gst_query_add_allocation_pool (query, pool, size,
|
||||
+ config_min_buf, config_max_buf);
|
||||
+ g_object_unref (pool);
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * FIXME is there a case where !need_pool and we fill query with an
|
||||
+ * allocator and alignment ?
|
||||
+ */
|
||||
+ alloc = gst_dmabuf_allocator_new ();
|
||||
+ gst_query_add_allocation_param (query, alloc, NULL);
|
||||
+ gst_object_unref (alloc);
|
||||
+
|
||||
+ /* we also support video metadata (alignment) */
|
||||
+ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
||||
+
|
||||
+ GST_WARNING_OBJECT (bsink, "Add dmabuf allocator");
|
||||
+
|
||||
+ return TRUE;
|
||||
+
|
||||
+ /* ERRORS */
|
||||
+no_pool:
|
||||
+ {
|
||||
+ GST_DEBUG_OBJECT (bsink, "failed to propose the needed pool");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void
|
||||
frame_redraw_callback (void *data, struct wl_callback *callback, uint32_t time)
|
||||
{
|
||||
diff --git a/ext/wayland/waylandpool.c b/ext/wayland/waylandpool.c
|
||||
new file mode 100644
|
||||
index 0000000..70e40b4
|
||||
--- /dev/null
|
||||
+++ b/ext/wayland/waylandpool.c
|
||||
@@ -0,0 +1,640 @@
|
||||
+/* GStreamer
|
||||
+ * Copyright (C) 2012 Intel Corporation
|
||||
+ * Copyright (C) 2012 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
+ * Copyright (C) 2014 Collabora Ltd.
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Library General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Library General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Library General Public
|
||||
+ * License along with this library; if not, write to the
|
||||
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
+ * Boston, MA 02110-1301, USA.
|
||||
+ */
|
||||
+
|
||||
+#ifdef HAVE_CONFIG_H
|
||||
+#include "config.h"
|
||||
+#endif
|
||||
+
|
||||
+#include "waylandpool.h"
|
||||
+#include "wldisplay.h"
|
||||
+#include "wlvideoformat.h"
|
||||
+
|
||||
+#include <errno.h>
|
||||
+#include <fcntl.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <unistd.h>
|
||||
+#include <sys/mman.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <sys/types.h>
|
||||
+
|
||||
+#include <libdrm/drm.h>
|
||||
+#include <xf86drm.h>
|
||||
+#include <drm/drm_fourcc.h>
|
||||
+
|
||||
+GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug);
|
||||
+#define GST_CAT_DEFAULT gstwayland_debug
|
||||
+
|
||||
+/* wl metadata */
|
||||
+GType
|
||||
+gst_wl_meta_api_get_type (void)
|
||||
+{
|
||||
+ static volatile GType type;
|
||||
+ static const gchar *tags[] =
|
||||
+ { "memory", "size", "colorspace", "orientation", NULL };
|
||||
+ if (g_once_init_enter (&type)) {
|
||||
+ GType _type = gst_meta_api_type_register ("GstWlMetaAPI", tags);
|
||||
+ g_once_init_leave (&type, _type);
|
||||
+ }
|
||||
+ return type;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gst_wl_meta_free (GstWlMeta * meta, GstBuffer * buffer)
|
||||
+{
|
||||
+ GstMemory *gmem;
|
||||
+ GST_DEBUG ("destroying wl_buffer %p", meta->wbuffer);
|
||||
+
|
||||
+ gmem = gst_buffer_get_memory (buffer, 0);
|
||||
+
|
||||
+ if ((gmem != NULL) && gst_is_dmabuf_memory (gmem)) {
|
||||
+ struct drm_mode_destroy_dumb destroy_arg;
|
||||
+ int prime_fd = gst_dmabuf_memory_get_fd (gmem);
|
||||
+
|
||||
+ memset (&destroy_arg, 0, sizeof destroy_arg);
|
||||
+ drmPrimeFDToHandle (meta->drm_fd, prime_fd, &destroy_arg.handle);
|
||||
+ drmIoctl (meta->drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg);
|
||||
+ close (prime_fd);
|
||||
+ } else {
|
||||
+ if (meta->data)
|
||||
+ munmap (meta->data, meta->size);
|
||||
+ }
|
||||
+ gst_memory_unref (gmem);
|
||||
+
|
||||
+ if (meta->wbuffer)
|
||||
+ wl_buffer_destroy (meta->wbuffer);
|
||||
+}
|
||||
+
|
||||
+static gboolean gst_wl_meta_init(GstMeta *meta, G_GNUC_UNUSED gpointer params, G_GNUC_UNUSED GstBuffer *buffer)
|
||||
+{
|
||||
+ /* Just to avoid a warning */
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+const GstMetaInfo *
|
||||
+gst_wl_meta_get_info (void)
|
||||
+{
|
||||
+ static const GstMetaInfo *wl_meta_info = NULL;
|
||||
+ if (g_once_init_enter (&wl_meta_info)) {
|
||||
+ const GstMetaInfo *meta =
|
||||
+ gst_meta_register (GST_WL_META_API_TYPE, "GstWlMeta",
|
||||
+ sizeof (GstWlMeta), (GstMetaInitFunction) gst_wl_meta_init,
|
||||
+ (GstMetaFreeFunction) gst_wl_meta_free,
|
||||
+ (GstMetaTransformFunction) NULL);
|
||||
+ g_once_init_leave (&wl_meta_info, meta);
|
||||
+ }
|
||||
+ return wl_meta_info;
|
||||
+}
|
||||
+
|
||||
+/* bufferpool */
|
||||
+static void gst_wayland_buffer_pool_finalize (GObject * object);
|
||||
+static gboolean gst_wayland_buffer_pool_set_config (GstBufferPool * pool,
|
||||
+ GstStructure * config);
|
||||
+static gboolean gst_wayland_buffer_pool_start (GstBufferPool * pool);
|
||||
+static gboolean gst_wayland_buffer_pool_stop (GstBufferPool * pool);
|
||||
+static GstFlowReturn gst_wayland_buffer_pool_alloc (GstBufferPool * pool,
|
||||
+ GstBuffer ** buffer, GstBufferPoolAcquireParams * params);
|
||||
+
|
||||
+#define gst_wayland_buffer_pool_parent_class parent_class
|
||||
+G_DEFINE_TYPE (GstWaylandBufferPool, gst_wayland_buffer_pool,
|
||||
+ GST_TYPE_BUFFER_POOL);
|
||||
+
|
||||
+static const gchar **
|
||||
+gst_wayland_buffer_pool_get_options (GstBufferPool * pool)
|
||||
+{
|
||||
+ static const gchar *options[] = {
|
||||
+ GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT, NULL
|
||||
+ };
|
||||
+ return options;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+gst_wayland_buffer_pool_class_init (GstWaylandBufferPoolClass * klass)
|
||||
+{
|
||||
+ GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
+ GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
|
||||
+ gobject_class->finalize = gst_wayland_buffer_pool_finalize;
|
||||
+
|
||||
+ gstbufferpool_class->set_config = gst_wayland_buffer_pool_set_config;
|
||||
+ gstbufferpool_class->start = gst_wayland_buffer_pool_start;
|
||||
+ gstbufferpool_class->stop = gst_wayland_buffer_pool_stop;
|
||||
+ gstbufferpool_class->alloc_buffer = gst_wayland_buffer_pool_alloc;
|
||||
+ gstbufferpool_class->get_options = gst_wayland_buffer_pool_get_options;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gst_wayland_buffer_pool_init (GstWaylandBufferPool * self)
|
||||
+{
|
||||
+ gst_video_info_init (&self->info);
|
||||
+ g_mutex_init (&self->buffers_map_mutex);
|
||||
+ self->buffers_map = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gst_wayland_buffer_pool_finalize (GObject * object)
|
||||
+{
|
||||
+ GstWaylandBufferPool *pool = GST_WAYLAND_BUFFER_POOL_CAST (object);
|
||||
+ if (pool->allocator)
|
||||
+ gst_object_unref (pool->allocator);
|
||||
+ pool->allocator = NULL;
|
||||
+
|
||||
+ if (pool->wl_pool)
|
||||
+ gst_wayland_buffer_pool_stop (GST_BUFFER_POOL (pool));
|
||||
+
|
||||
+ if (pool->fd != -1)
|
||||
+ close (pool->fd);
|
||||
+
|
||||
+ g_mutex_clear (&pool->buffers_map_mutex);
|
||||
+ g_hash_table_unref (pool->buffers_map);
|
||||
+
|
||||
+ g_object_unref (pool->display);
|
||||
+
|
||||
+ G_OBJECT_CLASS (gst_wayland_buffer_pool_parent_class)->finalize (object);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+buffer_release (void *data, struct wl_buffer *wl_buffer)
|
||||
+{
|
||||
+ GstWaylandBufferPool *self = data;
|
||||
+ GstBuffer *buffer;
|
||||
+ GstWlMeta *meta;
|
||||
+ g_mutex_lock (&self->buffers_map_mutex);
|
||||
+ buffer = g_hash_table_lookup (self->buffers_map, wl_buffer);
|
||||
+
|
||||
+ GST_LOG_OBJECT (self, "wl_buffer::release (GstBuffer: %p)", buffer);
|
||||
+
|
||||
+ if (buffer) {
|
||||
+ meta = gst_buffer_get_wl_meta (buffer);
|
||||
+ if (meta->used_by_compositor) {
|
||||
+ meta->used_by_compositor = FALSE;
|
||||
+ /* unlock before unref because stop() may be called from here */
|
||||
+ g_mutex_unlock (&self->buffers_map_mutex);
|
||||
+ gst_buffer_unref (buffer);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ g_mutex_unlock (&self->buffers_map_mutex);
|
||||
+}
|
||||
+
|
||||
+static const struct wl_buffer_listener buffer_listener = {
|
||||
+ buffer_release
|
||||
+};
|
||||
+
|
||||
+void
|
||||
+gst_wayland_compositor_acquire_buffer (GstWaylandBufferPool * self,
|
||||
+ GstBuffer * buffer)
|
||||
+{
|
||||
+ GstWlMeta *meta;
|
||||
+
|
||||
+ meta = gst_buffer_get_wl_meta (buffer);
|
||||
+ g_return_if_fail (meta != NULL);
|
||||
+ g_return_if_fail (meta->pool == self);
|
||||
+ g_return_if_fail (meta->used_by_compositor == FALSE);
|
||||
+
|
||||
+ meta->used_by_compositor = TRUE;
|
||||
+ gst_buffer_ref (buffer);
|
||||
+
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+unref_used_buffers (gpointer key, gpointer value, gpointer data)
|
||||
+{
|
||||
+ GstBuffer *buffer = value;
|
||||
+ GstWlMeta *meta = gst_buffer_get_wl_meta (buffer);
|
||||
+ GList **to_unref = data;
|
||||
+
|
||||
+ if (meta->used_by_compositor) {
|
||||
+ meta->used_by_compositor = FALSE;
|
||||
+ *to_unref = g_list_prepend (*to_unref, buffer);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+gst_wayland_compositor_release_all_buffers (GstWaylandBufferPool * self)
|
||||
+{
|
||||
+ GList *to_unref = NULL;
|
||||
+
|
||||
+ g_mutex_lock (&self->buffers_map_mutex);
|
||||
+ g_hash_table_foreach (self->buffers_map, unref_used_buffers, &to_unref);
|
||||
+ g_mutex_unlock (&self->buffers_map_mutex);
|
||||
+
|
||||
+ /* unref without the lock because stop() may be called from here */
|
||||
+ if (to_unref) {
|
||||
+ g_list_free_full (to_unref, (GDestroyNotify) gst_buffer_unref);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+gst_wayland_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||
+{
|
||||
+
|
||||
+ GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL_CAST (pool);
|
||||
+ GstWlDisplay *display = self->display;
|
||||
+ GstAllocationParams params;
|
||||
+ GstVideoInfo info;
|
||||
+ GstCaps *caps;
|
||||
+ guint config_min_buf, config_max_buf;
|
||||
+ gboolean has_alignment = FALSE;
|
||||
+ GstVideoAlignment video_align;
|
||||
+
|
||||
+ if (self->allocator)
|
||||
+ gst_object_unref (self->allocator);
|
||||
+ self->allocator = NULL;
|
||||
+
|
||||
+ if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &config_min_buf,
|
||||
+ &config_max_buf))
|
||||
+ goto wrong_config;
|
||||
+
|
||||
+ if (caps == NULL)
|
||||
+ goto no_caps;
|
||||
+
|
||||
+ /* now parse the caps from the config */
|
||||
+ if (!gst_video_info_from_caps (&info, caps))
|
||||
+ goto wrong_caps;
|
||||
+
|
||||
+ /* parse extra alignment info */
|
||||
+ has_alignment = gst_buffer_pool_config_has_option (config,
|
||||
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||
+ if (has_alignment) {
|
||||
+ /* get and apply the alignment to info */
|
||||
+ if (gst_buffer_pool_config_get_video_alignment (config, &video_align)) {
|
||||
+ gst_video_info_align (&info, &video_align);
|
||||
+
|
||||
+ GST_LOG_OBJECT (self, "padding %u-%ux%u-%u",
|
||||
+ video_align.padding_top,
|
||||
+ video_align.padding_left,
|
||||
+ video_align.padding_right, video_align.padding_bottom);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!gst_buffer_pool_config_get_allocator (config, &self->allocator, ¶ms))
|
||||
+ goto wrong_allocator;
|
||||
+
|
||||
+ if (self->allocator)
|
||||
+ gst_object_ref (self->allocator);
|
||||
+
|
||||
+ GST_LOG_OBJECT (self, "%dx%d, caps %" GST_PTR_FORMAT,
|
||||
+ info.width, info.height, caps);
|
||||
+
|
||||
+ /* FIXME: Enable metadata checking handling based on the config of pool */
|
||||
+ self->caps = gst_caps_ref (caps);
|
||||
+ self->info = info;
|
||||
+ self->width = info.width;
|
||||
+ self->height = info.height;
|
||||
+ self->size = GST_VIDEO_INFO_SIZE (&info);
|
||||
+ /* Update size in the config to be inline with buffer pool setup */
|
||||
+ gst_buffer_pool_config_set_params (config, caps, self->size, config_min_buf,
|
||||
+ config_max_buf);
|
||||
+
|
||||
+ self->use_linux_dmabuf = (self->allocator
|
||||
+ && g_strcmp0 (self->allocator->mem_type, GST_ALLOCATOR_DMABUF) == 0);
|
||||
+
|
||||
+ GST_LOG_OBJECT (self, "pool will use %s",
|
||||
+ self->use_linux_dmabuf ? "linux_dmabuf" : "wl_shm");
|
||||
+
|
||||
+ if (self->use_linux_dmabuf && display->device_name) {
|
||||
+ self->fd = open (display->device_name, O_RDWR, 0);
|
||||
+
|
||||
+ if (self->fd == -1) {
|
||||
+ GST_ERROR_OBJECT (self, "can't open %s", display->device_name);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config);
|
||||
+ /* ERRORS */
|
||||
+wrong_allocator:
|
||||
+ {
|
||||
+ GST_WARNING_OBJECT (pool, "no allocator");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+wrong_config:
|
||||
+ {
|
||||
+ GST_WARNING_OBJECT (pool, "invalid config");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+no_caps:
|
||||
+ {
|
||||
+ GST_WARNING_OBJECT (pool, "no caps in config");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+wrong_caps:
|
||||
+ {
|
||||
+ GST_WARNING_OBJECT (pool,
|
||||
+ "failed getting geometry from caps %" GST_PTR_FORMAT, caps);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+gst_wayland_buffer_pool_start (GstBufferPool * pool)
|
||||
+{
|
||||
+ GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL (pool);
|
||||
+ guint size = 0;
|
||||
+ int fd;
|
||||
+ char filename[1024];
|
||||
+ static int init = 0;
|
||||
+
|
||||
+ GST_DEBUG_OBJECT (self, "Initializing wayland buffer pool");
|
||||
+
|
||||
+ /* configure */
|
||||
+ size = GST_VIDEO_INFO_SIZE (&self->info) * 15;
|
||||
+
|
||||
+ /* allocate shm pool */
|
||||
+ snprintf (filename, 1024, "%s/%s-%d-%s", g_get_user_runtime_dir (),
|
||||
+ "wayland-shm", init++, "XXXXXX");
|
||||
+
|
||||
+ fd = mkstemp (filename);
|
||||
+ if (fd < 0) {
|
||||
+ GST_ERROR_OBJECT (pool, "opening temp file %s failed: %s", filename,
|
||||
+ strerror (errno));
|
||||
+
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ if (ftruncate (fd, size) < 0) {
|
||||
+ GST_ERROR_OBJECT (pool, "ftruncate failed: %s", strerror (errno));
|
||||
+ close (fd);
|
||||
+
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ self->data = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
+ if (self->data == MAP_FAILED) {
|
||||
+ GST_ERROR_OBJECT (pool, "mmap failed: %s", strerror (errno));
|
||||
+ close (fd);
|
||||
+
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ GST_DEBUG_OBJECT (self, "wl_shm_create_pool");
|
||||
+ self->wl_pool = wl_shm_create_pool (self->display->shm, fd, size);
|
||||
+ unlink (filename);
|
||||
+ close (fd);
|
||||
+
|
||||
+ self->size = size;
|
||||
+ self->used = 0;
|
||||
+
|
||||
+
|
||||
+ return GST_BUFFER_POOL_CLASS (parent_class)->start (pool);
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+gst_wayland_buffer_pool_stop (GstBufferPool * pool)
|
||||
+{
|
||||
+ GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL (pool);
|
||||
+
|
||||
+ GST_DEBUG_OBJECT (self, "Stopping wayland buffer pool");
|
||||
+
|
||||
+ munmap (self->data, self->size);
|
||||
+ wl_shm_pool_destroy (self->wl_pool);
|
||||
+
|
||||
+ self->wl_pool = NULL;
|
||||
+ self->size = 0;
|
||||
+ self->used = 0;
|
||||
+
|
||||
+ /* all buffers are about to be destroyed;
|
||||
+ * we should no longer do anything with them */
|
||||
+ g_mutex_lock (&self->buffers_map_mutex);
|
||||
+ g_hash_table_remove_all (self->buffers_map);
|
||||
+ g_mutex_unlock (&self->buffers_map_mutex);
|
||||
+
|
||||
+
|
||||
+ return GST_BUFFER_POOL_CLASS (parent_class)->stop (pool);
|
||||
+}
|
||||
+
|
||||
+/* DMABUF buffer functions */
|
||||
+static int
|
||||
+get_format_bpp (int format)
|
||||
+{
|
||||
+ switch (format) {
|
||||
+ case DRM_FORMAT_YUV420:
|
||||
+ case DRM_FORMAT_NV12:
|
||||
+ return 12;
|
||||
+ case WL_SHM_FORMAT_XRGB8888:
|
||||
+ case DRM_FORMAT_XRGB8888:
|
||||
+ case WL_SHM_FORMAT_ARGB8888:
|
||||
+ case DRM_FORMAT_ARGB8888:
|
||||
+ return 32;
|
||||
+ default:
|
||||
+ GST_WARNING ("Unknown format: %d", format);
|
||||
+ return 32;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+create_dumb (int drm_fd, uint32_t width, uint32_t height, int format,
|
||||
+ int *prime_fd, guint * stride)
|
||||
+{
|
||||
+ struct drm_mode_create_dumb create_arg;
|
||||
+ gint ret;
|
||||
+
|
||||
+ *prime_fd = -1;
|
||||
+ *stride = 0;
|
||||
+
|
||||
+
|
||||
+ memset (&create_arg, 0, sizeof (create_arg));
|
||||
+ create_arg.bpp = get_format_bpp (format);
|
||||
+ create_arg.width = width;
|
||||
+ create_arg.height = height;
|
||||
+
|
||||
+ ret = drmIoctl (drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg);
|
||||
+
|
||||
+ if (ret) {
|
||||
+ GST_ERROR ("DRM_IOCTL_MODE_CREATE_DUMB failed %s ret =%d on fd %d",
|
||||
+ strerror (errno), ret, drm_fd);
|
||||
+
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ *stride = create_arg.pitch;
|
||||
+
|
||||
+ ret = drmPrimeHandleToFD (drm_fd, create_arg.handle, DRM_CLOEXEC, prime_fd);
|
||||
+ if (ret) {
|
||||
+ struct drm_mode_destroy_dumb destroy_arg;
|
||||
+
|
||||
+ GST_WARNING ("Can't get fd from handle");
|
||||
+
|
||||
+ memset (&destroy_arg, 0, sizeof destroy_arg);
|
||||
+ destroy_arg.handle = create_arg.handle;
|
||||
+ drmIoctl (drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static GstWlMeta *
|
||||
+gst_buffer_add_wayland_meta (GstBuffer * buffer, GstWaylandBufferPool * self)
|
||||
+{
|
||||
+ GstWlMeta *meta;
|
||||
+ gint offset;
|
||||
+ void *data;
|
||||
+ guint width, height, stride, dumb_stride;
|
||||
+ gsize size;
|
||||
+ int format;
|
||||
+
|
||||
+ width = GST_VIDEO_INFO_WIDTH (&self->info);
|
||||
+ height = GST_VIDEO_INFO_HEIGHT (&self->info);
|
||||
+ stride = GST_VIDEO_INFO_PLANE_STRIDE (&self->info, 0);
|
||||
+ size = GST_VIDEO_INFO_SIZE (&self->info);
|
||||
+
|
||||
+ if (self->display->dmabuf && self->use_linux_dmabuf) {
|
||||
+ format =
|
||||
+ gst_video_format_to_wl_dmabuf_format (GST_VIDEO_INFO_FORMAT
|
||||
+ (&self->info));
|
||||
+ GST_DEBUG_OBJECT (self,
|
||||
+ "Allocating buffer of size %" G_GSSIZE_FORMAT
|
||||
+ " (%d x %d, stride %d), format : %s", size, width, height, stride,
|
||||
+ gst_wl_dmabuf_format_to_string (format));
|
||||
+ } else {
|
||||
+ format =
|
||||
+ gst_video_format_to_wl_shm_format (GST_VIDEO_INFO_FORMAT (&self->info));
|
||||
+ GST_DEBUG_OBJECT (self,
|
||||
+ "Allocating buffer of size %" G_GSSIZE_FORMAT
|
||||
+ " (%d x %d, stride %d), format : %s", size, width, height, stride,
|
||||
+ gst_wl_shm_format_to_string (format));
|
||||
+ }
|
||||
+
|
||||
+ meta = (GstWlMeta *) gst_buffer_add_meta (buffer, GST_WL_META_INFO, NULL);
|
||||
+ meta->pool = self;
|
||||
+ meta->size = size;
|
||||
+ meta->drm_fd = -1;
|
||||
+ meta->used_by_compositor = FALSE;
|
||||
+
|
||||
+ gst_buffer_add_video_meta_full (buffer, GST_VIDEO_FRAME_FLAG_NONE,
|
||||
+ GST_VIDEO_INFO_FORMAT (&self->info),
|
||||
+ GST_VIDEO_INFO_WIDTH (&self->info),
|
||||
+ GST_VIDEO_INFO_HEIGHT (&self->info),
|
||||
+ GST_VIDEO_INFO_N_PLANES (&self->info), self->info.offset,
|
||||
+ self->info.stride);
|
||||
+
|
||||
+ if (self->display->dmabuf && self->use_linux_dmabuf) {
|
||||
+ int prime_fd, ret, buf_width, buf_height;
|
||||
+
|
||||
+ buf_width = (stride / (get_format_bpp (format) / 8));
|
||||
+ buf_height = (size / buf_width) * 8 / get_format_bpp (format);
|
||||
+ if ((buf_width * buf_height * get_format_bpp (format)) / 8 < size)
|
||||
+ GST_ERROR_OBJECT (self, "Not allocating enough memory");
|
||||
+
|
||||
+ ret =
|
||||
+ create_dumb (self->fd, width, buf_height, format, &prime_fd,
|
||||
+ &dumb_stride);
|
||||
+ if (ret || prime_fd == -1) {
|
||||
+
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ GST_LOG_OBJECT (self, "drm buffer prime fd %d", prime_fd);
|
||||
+
|
||||
+ /* The wl_buffer will be created at the first render */
|
||||
+ meta->wbuffer = NULL;
|
||||
+
|
||||
+ gst_buffer_append_memory (buffer,
|
||||
+ gst_dmabuf_allocator_alloc (self->allocator, prime_fd, meta->size));
|
||||
+
|
||||
+ meta->drm_fd = self->fd;
|
||||
+ } else {
|
||||
+ /* try to reserve another memory block from the shm pool */
|
||||
+ if (self->used + size > self->size) {
|
||||
+
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ offset = self->used;
|
||||
+ self->used += size;
|
||||
+ data = ((gchar *) self->data) + offset;
|
||||
+
|
||||
+ meta->wbuffer = wl_shm_pool_create_buffer (self->wl_pool, offset,
|
||||
+ width, height, stride, format);
|
||||
+
|
||||
+ meta->data = data;
|
||||
+
|
||||
+ /* add the allocated memory on the GstBuffer */
|
||||
+ gst_buffer_append_memory (buffer,
|
||||
+ gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, data,
|
||||
+ size, 0, size, NULL, NULL));
|
||||
+
|
||||
+ /* configure listening to wl_buffer.release */
|
||||
+ g_mutex_lock (&self->buffers_map_mutex);
|
||||
+ g_hash_table_insert (self->buffers_map, meta->wbuffer, buffer);
|
||||
+ g_mutex_unlock (&self->buffers_map_mutex);
|
||||
+
|
||||
+ wl_buffer_add_listener (meta->wbuffer, &buffer_listener, self);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ return meta;
|
||||
+}
|
||||
+
|
||||
+static GstFlowReturn
|
||||
+gst_wayland_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||
+ GstBufferPoolAcquireParams * params)
|
||||
+{
|
||||
+ GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL_CAST (pool);
|
||||
+ GstWlMeta *meta;
|
||||
+
|
||||
+ /* create buffer and its metadata object */
|
||||
+ *buffer = gst_buffer_new ();
|
||||
+
|
||||
+ meta = gst_buffer_add_wayland_meta (*buffer, self);
|
||||
+
|
||||
+ if (meta == NULL) {
|
||||
+ gst_buffer_unref (*buffer);
|
||||
+ goto no_buffer;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ return GST_FLOW_OK;
|
||||
+
|
||||
+ /* ERROR */
|
||||
+no_buffer:
|
||||
+ {
|
||||
+ GST_WARNING_OBJECT (pool, "can't create buffer");
|
||||
+
|
||||
+ return GST_FLOW_ERROR;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+GstBufferPool *
|
||||
+gst_wayland_buffer_pool_new (GstWlDisplay * display)
|
||||
+{
|
||||
+ GstWaylandBufferPool *pool;
|
||||
+ GstStructure *s;
|
||||
+ GstVideoAlignment align;
|
||||
+
|
||||
+ g_return_val_if_fail (GST_IS_WL_DISPLAY (display), NULL);
|
||||
+ pool = g_object_new (GST_TYPE_WAYLAND_BUFFER_POOL, NULL);
|
||||
+ pool->display = g_object_ref (display);
|
||||
+
|
||||
+ pool->fd = -1;
|
||||
+
|
||||
+ s = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
|
||||
+ gst_buffer_pool_config_add_option (s, GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||
+ gst_buffer_pool_config_add_option (s, GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||
+ /* reset alignment */
|
||||
+ gst_video_alignment_reset (&align);
|
||||
+ gst_buffer_pool_config_set_video_alignment (s, &align);
|
||||
+ gst_buffer_pool_set_config (GST_BUFFER_POOL_CAST (pool), s);
|
||||
+
|
||||
+ return GST_BUFFER_POOL_CAST (pool);
|
||||
+}
|
||||
diff --git a/ext/wayland/waylandpool.h b/ext/wayland/waylandpool.h
|
||||
new file mode 100644
|
||||
index 0000000..4afd683
|
||||
--- /dev/null
|
||||
+++ b/ext/wayland/waylandpool.h
|
||||
@@ -0,0 +1,105 @@
|
||||
+/* GStreamer Wayland buffer pool
|
||||
+ * Copyright (C) 2012 Intel Corporation
|
||||
+ * Copyright (C) 2012 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
||||
+ * Copyright (C) 2014 Collabora Ltd.
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Library General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Library General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Library General Public
|
||||
+ * License along with this library; if not, write to the
|
||||
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
+ * Boston, MA 02110-1301, USA.
|
||||
+ */
|
||||
+
|
||||
+#ifndef __GST_WAYLAND_BUFFER_POOL_H__
|
||||
+#define __GST_WAYLAND_BUFFER_POOL_H__
|
||||
+
|
||||
+#include <gst/video/video.h>
|
||||
+#include <gst/video/gstvideometa.h>
|
||||
+
|
||||
+#include "wldisplay.h"
|
||||
+#include "gstwaylandsink.h"
|
||||
+
|
||||
+G_BEGIN_DECLS
|
||||
+#define GST_TYPE_WAYLAND_BUFFER_POOL (gst_wayland_buffer_pool_get_type())
|
||||
+#define GST_IS_WAYLAND_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WAYLAND_BUFFER_POOL))
|
||||
+#define GST_WAYLAND_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WAYLAND_BUFFER_POOL, GstWaylandBufferPool))
|
||||
+#define GST_WAYLAND_BUFFER_POOL_CAST(obj) ((GstWaylandBufferPool*)(obj))
|
||||
+typedef struct _GstWaylandBufferPool GstWaylandBufferPool;
|
||||
+typedef struct _GstWaylandBufferPoolClass GstWaylandBufferPoolClass;
|
||||
+
|
||||
+/* buffer meta */
|
||||
+typedef struct _GstWlMeta GstWlMeta;
|
||||
+
|
||||
+GType gst_wl_meta_api_get_type (void);
|
||||
+#define GST_WL_META_API_TYPE (gst_wl_meta_api_get_type())
|
||||
+
|
||||
+const GstMetaInfo *gst_wl_meta_get_info (void);
|
||||
+#define GST_WL_META_INFO (gst_wl_meta_get_info())
|
||||
+
|
||||
+#define gst_buffer_get_wl_meta(b) ((GstWlMeta*)gst_buffer_get_meta((b),GST_WL_META_API_TYPE))
|
||||
+
|
||||
+struct _GstWlMeta
|
||||
+{
|
||||
+ GstMeta meta;
|
||||
+
|
||||
+ GstWaylandBufferPool *pool;
|
||||
+ struct wl_buffer *wbuffer;
|
||||
+ gboolean used_by_compositor;
|
||||
+
|
||||
+ void *data;
|
||||
+ size_t size;
|
||||
+ int drm_fd;
|
||||
+};
|
||||
+
|
||||
+/* buffer pool */
|
||||
+struct _GstWaylandBufferPool
|
||||
+{
|
||||
+ GstBufferPool bufferpool;
|
||||
+ GstWlDisplay *display;
|
||||
+
|
||||
+ GstAllocator *allocator;
|
||||
+
|
||||
+ /* external configuration */
|
||||
+ GstVideoInfo info;
|
||||
+
|
||||
+ /* allocation data */
|
||||
+ struct wl_shm_pool *wl_pool;
|
||||
+ size_t size;
|
||||
+ size_t used;
|
||||
+ void *data;
|
||||
+
|
||||
+ gboolean use_linux_dmabuf;
|
||||
+ gint fd;
|
||||
+ GstCaps *caps;
|
||||
+ guint width;
|
||||
+ guint height;
|
||||
+
|
||||
+ GMutex buffers_map_mutex;
|
||||
+ GHashTable *buffers_map;
|
||||
+};
|
||||
+
|
||||
+struct _GstWaylandBufferPoolClass
|
||||
+{
|
||||
+ GstBufferPoolClass parent_class;
|
||||
+};
|
||||
+
|
||||
+GType gst_wayland_buffer_pool_get_type (void);
|
||||
+
|
||||
+GstBufferPool *gst_wayland_buffer_pool_new (GstWlDisplay * display);
|
||||
+
|
||||
+void gst_wayland_compositor_acquire_buffer (GstWaylandBufferPool * self,
|
||||
+ GstBuffer * buffer);
|
||||
+void gst_wayland_compositor_release_all_buffers (GstWaylandBufferPool * self);
|
||||
+
|
||||
+gboolean gst_buffer_set_wl_buffer (GstBuffer * buf, GstBufferPool * bpool);
|
||||
+G_END_DECLS
|
||||
+#endif /*__GST_WAYLAND_BUFFER_POOL_H__*/
|
||||
diff --git a/ext/wayland/wldisplay.c b/ext/wayland/wldisplay.c
|
||||
index f326091..b2e1359 100644
|
||||
--- a/ext/wayland/wldisplay.c
|
||||
+++ b/ext/wayland/wldisplay.c
|
||||
@@ -50,6 +50,9 @@ gst_wl_display_init (GstWlDisplay * self)
|
||||
self->wl_fd_poll = gst_poll_new (TRUE);
|
||||
self->buffers = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
g_mutex_init (&self->buffers_mutex);
|
||||
+ /* Default DRM */
|
||||
+ /* TODO : device name is hardcoded. It should come from protocol */
|
||||
+ self->device_name = g_strdup ("/dev/dri/card0");
|
||||
}
|
||||
|
||||
static void
|
||||
diff --git a/ext/wayland/wldisplay.h b/ext/wayland/wldisplay.h
|
||||
index f2025a6..65c754a 100644
|
||||
--- a/ext/wayland/wldisplay.h
|
||||
+++ b/ext/wayland/wldisplay.h
|
||||
@@ -29,15 +29,15 @@
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
#include "fullscreen-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
-G_BEGIN_DECLS
|
||||
+#include "gst/allocators/gstdmabuf.h"
|
||||
|
||||
+G_BEGIN_DECLS
|
||||
#define GST_TYPE_WL_DISPLAY (gst_wl_display_get_type ())
|
||||
#define GST_WL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WL_DISPLAY, GstWlDisplay))
|
||||
#define GST_IS_WL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WL_DISPLAY))
|
||||
#define GST_WL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_WL_DISPLAY, GstWlDisplayClass))
|
||||
#define GST_IS_WL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_WL_DISPLAY))
|
||||
#define GST_WL_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_WL_DISPLAY, GstWlDisplayClass))
|
||||
-
|
||||
typedef struct _GstWlDisplay GstWlDisplay;
|
||||
typedef struct _GstWlDisplayClass GstWlDisplayClass;
|
||||
|
||||
@@ -67,7 +67,7 @@ struct _GstWlDisplay
|
||||
gboolean own_display;
|
||||
GThread *thread;
|
||||
GstPoll *wl_fd_poll;
|
||||
-
|
||||
+ char *device_name;
|
||||
GMutex buffers_mutex;
|
||||
GHashTable *buffers;
|
||||
gboolean shutting_down;
|
||||
@@ -81,7 +81,7 @@ struct _GstWlDisplayClass
|
||||
GType gst_wl_display_get_type (void);
|
||||
|
||||
GstWlDisplay *gst_wl_display_new (const gchar * name, GError ** error);
|
||||
-GstWlDisplay *gst_wl_display_new_existing (struct wl_display * display,
|
||||
+GstWlDisplay *gst_wl_display_new_existing (struct wl_display *display,
|
||||
gboolean take_ownership, GError ** error);
|
||||
|
||||
/* see wlbuffer.c for explanation */
|
||||
@@ -96,5 +96,4 @@ gboolean gst_wl_display_check_format_for_dmabuf (GstWlDisplay * display,
|
||||
GstVideoFormat format);
|
||||
|
||||
G_END_DECLS
|
||||
-
|
||||
#endif /* __GST_WL_DISPLAY_H__ */
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
From a69cd4d027f3b86fd19a87d8139e08614587885c Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Mon, 26 Nov 2018 17:38:13 +0100
|
||||
Subject: [PATCH 02/14] waylandsink: fix error when mmapping dmabuf buffers
|
||||
|
||||
Linux Kernel 4.10 DRM/KMS requires DRM_RDWR rights
|
||||
in addition to DRM_CLOEXEC (see drmPrimeHandleToFD())
|
||||
in order to mmap in RD/WR.
|
||||
|
||||
Change-Id: I9c26642a47e6f71b56c0a4ad4714a5b85d814e5f
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/waylandpool.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ext/wayland/waylandpool.c b/ext/wayland/waylandpool.c
|
||||
index 70e40b4..9b20884 100644
|
||||
--- a/ext/wayland/waylandpool.c
|
||||
+++ b/ext/wayland/waylandpool.c
|
||||
@@ -470,7 +470,7 @@ create_dumb (int drm_fd, uint32_t width, uint32_t height, int format,
|
||||
|
||||
*stride = create_arg.pitch;
|
||||
|
||||
- ret = drmPrimeHandleToFD (drm_fd, create_arg.handle, DRM_CLOEXEC, prime_fd);
|
||||
+ ret = drmPrimeHandleToFD (drm_fd, create_arg.handle, DRM_CLOEXEC | DRM_RDWR, prime_fd);
|
||||
if (ret) {
|
||||
struct drm_mode_destroy_dumb destroy_arg;
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
From 754625fd6a60fbc529416ba88ff06f542523937a Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Thu, 6 Dec 2018 18:08:15 +0100
|
||||
Subject: [PATCH 03/14] waylandsink: fix wrong width when creating dmabuf dumb
|
||||
buffers
|
||||
|
||||
Unaligned width is given in argument of create_dumb(), fix this.
|
||||
|
||||
Change-Id: Ifc57aa24331f58f588aae480baa2099a47d5f31b
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/waylandpool.c | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/ext/wayland/waylandpool.c b/ext/wayland/waylandpool.c
|
||||
index 9b20884..6e98143 100644
|
||||
--- a/ext/wayland/waylandpool.c
|
||||
+++ b/ext/wayland/waylandpool.c
|
||||
@@ -537,10 +537,9 @@ gst_buffer_add_wayland_meta (GstBuffer * buffer, GstWaylandBufferPool * self)
|
||||
buf_height = (size / buf_width) * 8 / get_format_bpp (format);
|
||||
if ((buf_width * buf_height * get_format_bpp (format)) / 8 < size)
|
||||
GST_ERROR_OBJECT (self, "Not allocating enough memory");
|
||||
-
|
||||
ret =
|
||||
- create_dumb (self->fd, width, buf_height, format, &prime_fd,
|
||||
- &dumb_stride);
|
||||
+ create_dumb (self->fd, buf_width, buf_height, format, &prime_fd,
|
||||
+ &dumb_stride);
|
||||
if (ret || prime_fd == -1) {
|
||||
|
||||
return NULL;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
From f1e46e02aeac410a4bf1faae5a7dac62c0dfbe1d Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Wed, 12 Dec 2018 11:39:33 +0100
|
||||
Subject: [PATCH 04/14] waylandsink: do not hardcode dmabuf bufferpool info
|
||||
size
|
||||
|
||||
Read pool config to get the maximum number of buffers
|
||||
for info size pool allocation.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/waylandpool.c | 12 +++++++++++-
|
||||
1 file changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ext/wayland/waylandpool.c b/ext/wayland/waylandpool.c
|
||||
index 6e98143..1ba1f85 100644
|
||||
--- a/ext/wayland/waylandpool.c
|
||||
+++ b/ext/wayland/waylandpool.c
|
||||
@@ -357,11 +357,21 @@ gst_wayland_buffer_pool_start (GstBufferPool * pool)
|
||||
int fd;
|
||||
char filename[1024];
|
||||
static int init = 0;
|
||||
+ GstStructure *config;
|
||||
+ guint config_max_buf;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Initializing wayland buffer pool");
|
||||
|
||||
+ /* get max size of pool */
|
||||
+ config = gst_buffer_pool_get_config (pool);
|
||||
+ gst_buffer_pool_config_get_params (config, NULL, NULL,
|
||||
+ NULL, &config_max_buf);
|
||||
+
|
||||
+ if (config_max_buf == 0)
|
||||
+ config_max_buf = 32;
|
||||
+
|
||||
/* configure */
|
||||
- size = GST_VIDEO_INFO_SIZE (&self->info) * 15;
|
||||
+ size = GST_VIDEO_INFO_SIZE (&self->info) * config_max_buf;
|
||||
|
||||
/* allocate shm pool */
|
||||
snprintf (filename, 1024, "%s/%s-%d-%s", g_get_user_runtime_dir (),
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
From 837247993dd5399c0faa95950ab62bd1a1f7d6cb Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Thu, 6 Dec 2018 18:08:59 +0100
|
||||
Subject: [PATCH 05/14] waylandsink: increase max buffers to 32 to enable
|
||||
dmabuf with libav decoders
|
||||
|
||||
libav software decoders requires max buffers in pool config to be
|
||||
at least 32, otherwise this pool is rejected.
|
||||
|
||||
Change-Id: If1a54ee8c1a9f320fd91537e8e2082c4a7a78700
|
||||
---
|
||||
ext/wayland/gstwaylandsink.c | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
||||
index 20df1bf..8b807da 100644
|
||||
--- a/ext/wayland/gstwaylandsink.c
|
||||
+++ b/ext/wayland/gstwaylandsink.c
|
||||
@@ -52,6 +52,9 @@
|
||||
#include <gst/wayland/wayland.h>
|
||||
#include <gst/video/videooverlay.h>
|
||||
|
||||
+#define CONFIG_DMABUF_MIN_BUFFERS 2
|
||||
+#define CONFIG_DMABUF_MAX_BUFFERS 32
|
||||
+
|
||||
/* signals */
|
||||
enum
|
||||
{
|
||||
@@ -574,8 +577,9 @@ gst_wayland_create_dmabuf_pool (GstWaylandSink * sink, GstCaps * caps)
|
||||
}
|
||||
|
||||
structure = gst_buffer_pool_get_config (pool);
|
||||
- gst_buffer_pool_config_set_params (structure, caps, info.size, 2, 0);
|
||||
- gst_buffer_pool_config_set_allocator (structure, NULL, ¶ms);
|
||||
+ gst_buffer_pool_config_set_params (structure, caps, size,
|
||||
+ CONFIG_DMABUF_MIN_BUFFERS, CONFIG_DMABUF_MAX_BUFFERS);
|
||||
+
|
||||
alloc = gst_dmabuf_allocator_new ();
|
||||
gst_buffer_pool_config_set_allocator (structure, alloc, NULL);
|
||||
if (!gst_buffer_pool_set_config (pool, structure)) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
From 36a3da1477d9dd5c23b0c47fd45e61a8c0316600 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Thu, 6 Dec 2018 18:09:20 +0100
|
||||
Subject: [PATCH 06/14] waylandsink: always select dmabuf buffer pool
|
||||
|
||||
Force usage of dmabuf buffer pool by default, ie
|
||||
even if video/x-raw(memory:DMABuf) is not set in caps.
|
||||
This allows 0-copy path with software downstream elements
|
||||
(use of dmabuf buffers mmapped memory directly instead
|
||||
of copying).
|
||||
|
||||
Change-Id: Icb6e8ff272c562e829bb3ff91150e7d77b25dfd1
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/gstwaylandsink.c | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
||||
index 8b807da..40edff7 100644
|
||||
--- a/ext/wayland/gstwaylandsink.c
|
||||
+++ b/ext/wayland/gstwaylandsink.c
|
||||
@@ -610,9 +610,17 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
||||
format = GST_VIDEO_INFO_FORMAT (&sink->video_info);
|
||||
sink->video_info_changed = TRUE;
|
||||
|
||||
- use_dmabuf = gst_caps_features_contains (gst_caps_get_features (caps, 0),
|
||||
- GST_CAPS_FEATURE_MEMORY_DMABUF);
|
||||
+ /* Force usage of dmabuf buffer pool by default, ie
|
||||
+ * even if video/x-raw(memory:DMABuf) is not set in caps.
|
||||
+ * This allows 0-copy path with software downstream elements
|
||||
+ * (use of dmabuf buffers mmapped memory directly instead
|
||||
+ * of copying)
|
||||
+ */
|
||||
+ /* use_dmabuf = gst_caps_features_contains (gst_caps_get_features (caps, 0),
|
||||
+ GST_CAPS_FEATURE_MEMORY_DMABUF); */
|
||||
+ use_dmabuf = TRUE;
|
||||
|
||||
+ /* validate the format base on the memory type */
|
||||
if (use_dmabuf) {
|
||||
if (!gst_wl_display_check_format_for_dmabuf (sink->display, format))
|
||||
goto unsupported_format;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
From 15464502cf5851e29fa5da9c6e1547655865de21 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Mon, 10 Dec 2018 17:36:27 +0100
|
||||
Subject: [PATCH 07/14] waylandsink: do not destroy pool twice
|
||||
|
||||
Fix segfault in wayland client due to pool
|
||||
destroy being called with null pool...
|
||||
This problem was encountered with GStreamer-1.14.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/waylandpool.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/ext/wayland/waylandpool.c b/ext/wayland/waylandpool.c
|
||||
index 1ba1f85..17a94f1 100644
|
||||
--- a/ext/wayland/waylandpool.c
|
||||
+++ b/ext/wayland/waylandpool.c
|
||||
@@ -417,7 +417,12 @@ gst_wayland_buffer_pool_stop (GstBufferPool * pool)
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Stopping wayland buffer pool");
|
||||
|
||||
+ /* already stopped... */
|
||||
+ if (!self->wl_pool)
|
||||
+ return FALSE;
|
||||
+
|
||||
munmap (self->data, self->size);
|
||||
+
|
||||
wl_shm_pool_destroy (self->wl_pool);
|
||||
|
||||
self->wl_pool = NULL;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
From 5cf87e34ad0aa98ceb004f68ea72498f490e6858 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Wed, 12 Dec 2018 12:04:03 +0100
|
||||
Subject: [PATCH 08/14] waylandsink: HACK: disable frame dropping while redraw
|
||||
is pending
|
||||
|
||||
This workaround is needed to reach 30fps video playback.
|
||||
|
||||
Redraw callback is received late, leading to many frames
|
||||
being dropped and so low framerate on display driver stage.
|
||||
The fact that redraw callback is received late is not yet understood
|
||||
but display subsystem is able to sustain a higher framerate
|
||||
than the one reached with redraw callback mechanism.
|
||||
This workaround consists to ignore redraw callback allowing to
|
||||
get back to the expected framerate performances.
|
||||
|
||||
Even if not observed yet, there is a risk of visible decoding artefacts
|
||||
due to the fact that downstream elements could rewrite in a frame
|
||||
being currently rendered by display subsystem...
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/gstwaylandsink.c | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
||||
index 40edff7..b97570e 100644
|
||||
--- a/ext/wayland/gstwaylandsink.c
|
||||
+++ b/ext/wayland/gstwaylandsink.c
|
||||
@@ -774,10 +774,29 @@ render_last_buffer (GstWaylandSink * sink, gboolean redraw)
|
||||
wlbuffer = gst_buffer_get_wl_buffer (sink->display, sink->last_buffer);
|
||||
surface = gst_wl_window_get_wl_surface (sink->window);
|
||||
|
||||
+ /*
|
||||
+ * HACK: disable frame dropping while redraw is pending
|
||||
+ *
|
||||
+ * This workaround is needed to reach 30fps video playback.
|
||||
+ *
|
||||
+ * Redraw callback is received late, leading to many frames
|
||||
+ * being dropped and so low framerate on display driver stage.
|
||||
+ * The fact that redraw callback is received late is not yet understood
|
||||
+ * but display subsystem is able to sustain a higher framerate
|
||||
+ * than the one reached with redraw callback mechanism.
|
||||
+ * This workaround consists to ignore redraw callback allowing to
|
||||
+ * get back to the expected framerate performances.
|
||||
+ *
|
||||
+ * Why not observed yet, there is a risk of visible decoding artefacts
|
||||
+ * due to the fact that downstream elements could rewrite in a frame
|
||||
+ * being currently rendered by display subsystem...
|
||||
+ */
|
||||
+#if 0
|
||||
sink->redraw_pending = TRUE;
|
||||
callback = wl_surface_frame (surface);
|
||||
sink->callback = callback;
|
||||
wl_callback_add_listener (callback, &frame_callback_listener, sink);
|
||||
+#endif
|
||||
|
||||
if (G_UNLIKELY (sink->video_info_changed && !redraw)) {
|
||||
info = &sink->video_info;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
From cf2dfe7a376d10a3d7815d29ffc1c9efb4d4f19e Mon Sep 17 00:00:00 2001
|
||||
From: Christophe Priouzeau <christophe.priouzeau@st.com>
|
||||
Date: Mon, 21 May 2018 14:26:47 +0200
|
||||
Subject: [PATCH 09/14] waylandsink: Uprank to secondary
|
||||
|
||||
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
|
||||
---
|
||||
ext/wayland/gstwaylandsink.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
||||
index b97570e..0dc1f0d 100644
|
||||
--- a/ext/wayland/gstwaylandsink.c
|
||||
+++ b/ext/wayland/gstwaylandsink.c
|
||||
@@ -126,7 +126,7 @@ G_DEFINE_TYPE_WITH_CODE (GstWaylandSink, gst_wayland_sink, GST_TYPE_VIDEO_SINK,
|
||||
gst_wayland_sink_videooverlay_init)
|
||||
G_IMPLEMENT_INTERFACE (GST_TYPE_WAYLAND_VIDEO,
|
||||
gst_wayland_sink_waylandvideo_init));
|
||||
-GST_ELEMENT_REGISTER_DEFINE (waylandsink, "waylandsink", GST_RANK_MARGINAL,
|
||||
+GST_ELEMENT_REGISTER_DEFINE (waylandsink, "waylandsink", GST_RANK_SECONDARY+1,
|
||||
GST_TYPE_WAYLAND_SINK);
|
||||
|
||||
/* A tiny GstVideoBufferPool subclass that modify the options to remove
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 9eb8fcc53467a575dc3fba3bbeae26ed8752e639 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Mon, 11 Feb 2019 16:00:02 +0100
|
||||
Subject: [PATCH 10/14] waylandsink: set video alignment to 32 bytes
|
||||
|
||||
Display subsystem requires at least 32 bytes alignment.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/waylandpool.c | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ext/wayland/waylandpool.c b/ext/wayland/waylandpool.c
|
||||
index 17a94f1..e04a459 100644
|
||||
--- a/ext/wayland/waylandpool.c
|
||||
+++ b/ext/wayland/waylandpool.c
|
||||
@@ -635,6 +635,7 @@ gst_wayland_buffer_pool_new (GstWlDisplay * display)
|
||||
GstWaylandBufferPool *pool;
|
||||
GstStructure *s;
|
||||
GstVideoAlignment align;
|
||||
+ guint i;
|
||||
|
||||
g_return_val_if_fail (GST_IS_WL_DISPLAY (display), NULL);
|
||||
pool = g_object_new (GST_TYPE_WAYLAND_BUFFER_POOL, NULL);
|
||||
@@ -645,8 +646,12 @@ gst_wayland_buffer_pool_new (GstWlDisplay * display)
|
||||
s = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
|
||||
gst_buffer_pool_config_add_option (s, GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||
gst_buffer_pool_config_add_option (s, GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||
- /* reset alignment */
|
||||
+
|
||||
+ /* display subsystem requires at least 32 bytes alignment */
|
||||
gst_video_alignment_reset (&align);
|
||||
+ for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
|
||||
+ align.stride_align[i] = 31;
|
||||
+
|
||||
gst_buffer_pool_config_set_video_alignment (s, &align);
|
||||
gst_buffer_pool_set_config (GST_BUFFER_POOL_CAST (pool), s);
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
From e46e02a4745e20b139a5834d235fe2eeb992be14 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Fri, 22 Mar 2019 15:40:03 +0100
|
||||
Subject: [PATCH 11/14] waylandsink: fallback to shm if display does not
|
||||
support dmabuf
|
||||
|
||||
Fallback to shm if display does not support dmabuf.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/gstwaylandsink.c | 10 +++-------
|
||||
1 file changed, 3 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
||||
index 0dc1f0d..e4952cb 100644
|
||||
--- a/ext/wayland/gstwaylandsink.c
|
||||
+++ b/ext/wayland/gstwaylandsink.c
|
||||
@@ -618,15 +618,11 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
||||
*/
|
||||
/* use_dmabuf = gst_caps_features_contains (gst_caps_get_features (caps, 0),
|
||||
GST_CAPS_FEATURE_MEMORY_DMABUF); */
|
||||
- use_dmabuf = TRUE;
|
||||
+ use_dmabuf = gst_wl_display_check_format_for_dmabuf (sink->display, format);
|
||||
|
||||
- /* validate the format base on the memory type */
|
||||
- if (use_dmabuf) {
|
||||
- if (!gst_wl_display_check_format_for_dmabuf (sink->display, format))
|
||||
+ if (!use_dmabuf)
|
||||
+ if (!gst_wl_display_check_format_for_shm (sink->display, format))
|
||||
goto unsupported_format;
|
||||
- } else if (!gst_wl_display_check_format_for_shm (sink->display, format)) {
|
||||
- goto unsupported_format;
|
||||
- }
|
||||
|
||||
/* create a new pool for the new caps */
|
||||
if (sink->pool)
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
From 105576bd522f3a751fda51ea35da2147b1adcfe7 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
|
||||
Date: Fri, 4 Oct 2019 09:47:43 +0200
|
||||
Subject: [PATCH 12/14] waylandsink: XDG protocol does not work in fullscreen
|
||||
|
||||
Using new XDG protocol, it turns out to be not working when enabling
|
||||
fullscreen support.
|
||||
This patch avoids to over commit surface during configuration and takes
|
||||
into account render region when provided within wayland callback.
|
||||
|
||||
Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
|
||||
---
|
||||
ext/wayland/wlwindow.c | 19 +++++++++++++++----
|
||||
1 file changed, 15 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/ext/wayland/wlwindow.c b/ext/wayland/wlwindow.c
|
||||
index 66df0fc..cc5de26 100644
|
||||
--- a/ext/wayland/wlwindow.c
|
||||
+++ b/ext/wayland/wlwindow.c
|
||||
@@ -325,10 +325,18 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
|
||||
/* render_rectangle is already set via toplevel_configure in
|
||||
* xdg_shell fullscreen mode */
|
||||
if (!(display->xdg_wm_base && fullscreen)) {
|
||||
+ gint width, height;
|
||||
+
|
||||
/* set the initial size to be the same as the reported video size */
|
||||
- gint width =
|
||||
- gst_util_uint64_scale_int_round (info->width, info->par_n, info->par_d);
|
||||
- gst_wl_window_set_render_rectangle (window, 0, 0, width, info->height);
|
||||
+ if ( window->render_rectangle.w == 0 || window->render_rectangle.h == 0) {
|
||||
+ width =
|
||||
+ gst_util_uint64_scale_int_round (info->width, info->par_n, info->par_d);
|
||||
+ height = info->height;
|
||||
+ } else {
|
||||
+ width = window->render_rectangle.w;
|
||||
+ height = window->render_rectangle.h;
|
||||
+ }
|
||||
+ gst_wl_window_set_render_rectangle (window, 0, 0, width, height);
|
||||
}
|
||||
|
||||
return window;
|
||||
@@ -567,7 +575,10 @@ gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
|
||||
gst_wl_window_resize_video_surface (window, TRUE);
|
||||
}
|
||||
|
||||
- wl_surface_commit (window->area_surface_wrapper);
|
||||
+ if (window->xdg_surface && window->configured) {
|
||||
+ wl_surface_damage (window->area_surface_wrapper, 0, 0, w, h);
|
||||
+ wl_surface_commit (window->area_surface_wrapper);
|
||||
+ }
|
||||
|
||||
if (window->video_width != 0)
|
||||
wl_subsurface_set_desync (window->video_subsurface);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
From e14996eb9c0332aeda6390db207380dd0267e7c2 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Wed, 25 Sep 2019 16:01:49 +0200
|
||||
Subject: [PATCH 13/14] waylandsink: silently drop erroneous frame
|
||||
|
||||
Do not stop playback when erroneous frame is received at show_frame():
|
||||
- test file descriptors validity, to not let throw erroneous
|
||||
file descriptor to wayland backend (which may crash on fatal error)
|
||||
- if file descriptors are not valid, do not fall into general
|
||||
"GST_ELEMENT_ERROR" nor return FLOW_ERROR.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
ext/wayland/gstwaylandsink.c | 6 +++---
|
||||
ext/wayland/wllinuxdmabuf.c | 14 ++++++++++++++
|
||||
ext/wayland/wlshmallocator.c | 10 ++++++++++
|
||||
3 files changed, 27 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
||||
index e4952cb..cf355d3 100644
|
||||
--- a/ext/wayland/gstwaylandsink.c
|
||||
+++ b/ext/wayland/gstwaylandsink.c
|
||||
@@ -1025,9 +1025,9 @@ activate_failed:
|
||||
}
|
||||
src_map_failed:
|
||||
{
|
||||
- GST_ELEMENT_ERROR (sink, RESOURCE, READ,
|
||||
- ("Video memory can not be read from userspace."), (NULL));
|
||||
- ret = GST_FLOW_ERROR;
|
||||
+ /* Silently drop in case of erroneous buffer */
|
||||
+ GST_ERROR_OBJECT (sink, "Video memory can not be read from userspace,"
|
||||
+ "dropping buffer %p", buffer);
|
||||
goto done;
|
||||
}
|
||||
dst_map_failed:
|
||||
diff --git a/ext/wayland/wllinuxdmabuf.c b/ext/wayland/wllinuxdmabuf.c
|
||||
index 96487d1..36815b5 100644
|
||||
--- a/ext/wayland/wllinuxdmabuf.c
|
||||
+++ b/ext/wayland/wllinuxdmabuf.c
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "wllinuxdmabuf.h"
|
||||
#include "wlvideoformat.h"
|
||||
|
||||
+#include <unistd.h>
|
||||
+
|
||||
GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug);
|
||||
#define GST_CAT_DEFAULT gstwayland_debug
|
||||
|
||||
@@ -110,6 +112,18 @@ gst_wl_linux_dmabuf_construct_wl_buffer (GstBuffer * buf,
|
||||
if (gst_buffer_find_memory (buf, offset, 1, &mem_idx, &length, &skip)) {
|
||||
GstMemory *m = gst_buffer_peek_memory (buf, mem_idx);
|
||||
gint fd = gst_dmabuf_memory_get_fd (m);
|
||||
+ gint dup_fd = dup (fd);
|
||||
+
|
||||
+ /* Test if file descriptor is valid */
|
||||
+ if (dup_fd < 0) {
|
||||
+ GST_ERROR_OBJECT (display, "zwp_linux_dmabuf: dup failed for fd=%d (err=%d) buffer=%p",
|
||||
+ fd, dup_fd, buf);
|
||||
+ zwp_linux_buffer_params_v1_destroy (params);
|
||||
+ data.wbuf = NULL;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ close(dup_fd);
|
||||
+
|
||||
zwp_linux_buffer_params_v1_add (params, fd, i, m->offset + skip,
|
||||
stride, 0, 0);
|
||||
} else {
|
||||
diff --git a/ext/wayland/wlshmallocator.c b/ext/wayland/wlshmallocator.c
|
||||
index 0a82a35..8659c2f 100644
|
||||
--- a/ext/wayland/wlshmallocator.c
|
||||
+++ b/ext/wayland/wlshmallocator.c
|
||||
@@ -212,12 +212,22 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display,
|
||||
enum wl_shm_format format;
|
||||
struct wl_shm_pool *wl_pool;
|
||||
struct wl_buffer *wbuffer;
|
||||
+ gint fd = gst_fd_memory_get_fd (mem);
|
||||
+ gint dup_fd = dup(fd);
|
||||
|
||||
if (!gst_wl_shm_validate_video_info (info)) {
|
||||
GST_DEBUG_OBJECT (display, "Unsupported strides and offsets.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ /* Test if file descriptor is valid */
|
||||
+ if (dup_fd < 0) {
|
||||
+ GST_ERROR_OBJECT (display, "wl_shm_memory: dup failed for fd=%d (err=%d) mem=%p",
|
||||
+ fd, dup_fd, mem);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ close(dup_fd);
|
||||
+
|
||||
width = GST_VIDEO_INFO_WIDTH (info);
|
||||
height = GST_VIDEO_INFO_HEIGHT (info);
|
||||
stride = GST_VIDEO_INFO_PLANE_STRIDE (info, 0);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
From 678d91a743bb35e202211abc6db495fbf8d75601 Mon Sep 17 00:00:00 2001
|
||||
From: Christophe Priouzeau <christophe.priouzeau@st.com>
|
||||
Date: Tue, 18 Feb 2020 13:33:21 +0100
|
||||
Subject: [PATCH 14/14] waylandsink add waylandpool on meson build
|
||||
|
||||
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
|
||||
---
|
||||
ext/wayland/meson.build | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ext/wayland/meson.build b/ext/wayland/meson.build
|
||||
index a3ffb70..66dd148 100644
|
||||
--- a/ext/wayland/meson.build
|
||||
+++ b/ext/wayland/meson.build
|
||||
@@ -5,7 +5,8 @@ wl_sources = [
|
||||
'wldisplay.c',
|
||||
'wlwindow.c',
|
||||
'wlvideoformat.c',
|
||||
- 'wllinuxdmabuf.c'
|
||||
+ 'wllinuxdmabuf.c',
|
||||
+ 'waylandpool.c'
|
||||
]
|
||||
|
||||
libdrm_dep = dependency('libdrm', version: '>= 2.4.55', required:get_option('wayland'))
|
||||
--
|
||||
2.25.1
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,39 @@
|
|||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
|
||||
|
||||
SRC_URI:append = " \
|
||||
file://0001-waylandsink-add-dmabuf-bufferpool.patch \
|
||||
file://0002-waylandsink-fix-error-when-mmapping-dmabuf-buffers.patch \
|
||||
file://0003-waylandsink-fix-wrong-width-when-creating-dmabuf-dum.patch \
|
||||
file://0004-waylandsink-do-not-hardcode-dmabuf-bufferpool-info-s.patch \
|
||||
file://0005-waylandsink-increase-max-buffers-to-32-to-enable-dma.patch \
|
||||
file://0006-waylandsink-always-select-dmabuf-buffer-pool.patch \
|
||||
file://0007-waylandsink-do-not-destroy-pool-twice.patch \
|
||||
file://0008-waylandsink-HACK-disable-frame-dropping-while-redraw.patch \
|
||||
file://0009-waylandsink-Uprank-to-secondary.patch \
|
||||
file://0010-waylandsink-set-video-alignment-to-32-bytes.patch \
|
||||
file://0011-waylandsink-fallback-to-shm-if-display-does-not-supp.patch \
|
||||
file://0012-waylandsink-XDG-protocol-does-not-work-in-fullscreen.patch \
|
||||
file://0013-waylandsink-silently-drop-erroneous-frame.patch \
|
||||
file://0014-waylandsink-add-waylandpool-on-meson-build.patch \
|
||||
\
|
||||
file://0016-Add-new-gtkwaylandsink-element.patch \
|
||||
"
|
||||
|
||||
PACKAGECONFIG_GL ?= "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gles2 egl', '', d)}"
|
||||
PACKAGECONFIG[gtk3] = "-Dgtk3=enabled,-Dgtk3=disabled,gtk+3"
|
||||
|
||||
PACKAGECONFIG ?= " \
|
||||
${GSTREAMER_ORC} \
|
||||
${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \
|
||||
${@bb.utils.filter('DISTRO_FEATURES', 'directfb vulkan', d)} \
|
||||
${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland gtk3', '', d)} \
|
||||
${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gl', '', d)} \
|
||||
bz2 closedcaption curl dash dtls hls rsvg sbc smoothstreaming sndfile \
|
||||
ttml uvch264 webp \
|
||||
kms \
|
||||
"
|
||||
|
||||
do_install:append() {
|
||||
install -d ${D}${includedir}/gstreamer-1.0/wayland
|
||||
install -m 644 ${S}/gst-libs/gst/wayland/wayland.h ${D}${includedir}/gstreamer-1.0/wayland
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
From a698ef5806e50b614f49decb4eb2a2b4404f56e5 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Wed, 23 Jan 2019 14:18:28 +0100
|
||||
Subject: [PATCH 1/2] playbin2: disable any default video processing
|
||||
|
||||
Do not enable by default software video processing
|
||||
to not degrade performances.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
gst/playback/gstplaybin2.c | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c
|
||||
index a2e9ed4..4c0163e 100644
|
||||
--- a/gst/playback/gstplaybin2.c
|
||||
+++ b/gst/playback/gstplaybin2.c
|
||||
@@ -499,9 +499,8 @@ struct _GstPlayBinClass
|
||||
#define DEFAULT_URI NULL
|
||||
#define DEFAULT_SUBURI NULL
|
||||
#define DEFAULT_SOURCE NULL
|
||||
-#define DEFAULT_FLAGS GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_TEXT | \
|
||||
- GST_PLAY_FLAG_SOFT_VOLUME | GST_PLAY_FLAG_DEINTERLACE | \
|
||||
- GST_PLAY_FLAG_SOFT_COLORBALANCE
|
||||
+#define DEFAULT_FLAGS GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_SOFT_VOLUME
|
||||
+
|
||||
#define DEFAULT_N_VIDEO 0
|
||||
#define DEFAULT_CURRENT_VIDEO -1
|
||||
#define DEFAULT_N_AUDIO 0
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
From 17a847850f31be11c0c98d31cdd4d62856bfa313 Mon Sep 17 00:00:00 2001
|
||||
From: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
Date: Wed, 23 Jan 2019 14:16:36 +0100
|
||||
Subject: [PATCH 2/2] playbin3: disable any default video processing
|
||||
|
||||
Do not enable by default software video processing
|
||||
to not degrade performances.
|
||||
|
||||
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
|
||||
---
|
||||
gst/playback/gstplaybin3.c | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gst/playback/gstplaybin3.c b/gst/playback/gstplaybin3.c
|
||||
index 027766b..9103cb1 100644
|
||||
--- a/gst/playback/gstplaybin3.c
|
||||
+++ b/gst/playback/gstplaybin3.c
|
||||
@@ -520,9 +520,8 @@ struct _GstPlayBin3Class
|
||||
/* props */
|
||||
#define DEFAULT_URI NULL
|
||||
#define DEFAULT_SUBURI NULL
|
||||
-#define DEFAULT_FLAGS GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_TEXT | \
|
||||
- GST_PLAY_FLAG_SOFT_VOLUME | GST_PLAY_FLAG_DEINTERLACE | \
|
||||
- GST_PLAY_FLAG_SOFT_COLORBALANCE | GST_PLAY_FLAG_BUFFERING
|
||||
+#define DEFAULT_FLAGS GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | \
|
||||
+ GST_PLAY_FLAG_SOFT_VOLUME | GST_PLAY_FLAG_BUFFERING
|
||||
#define DEFAULT_CURRENT_VIDEO -1
|
||||
#define DEFAULT_CURRENT_AUDIO -1
|
||||
#define DEFAULT_CURRENT_TEXT -1
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}/:"
|
||||
|
||||
SRC_URI:append = " file://0001-playbin2-disable-any-default-video-processing.patch "
|
||||
SRC_URI:append = " file://0002-playbin3-disable-any-default-video-processing.patch "
|
||||
|
||||
PACKAGECONFIG ?= " \
|
||||
${GSTREAMER_ORC} \
|
||||
${PACKAGECONFIG_GL} \
|
||||
${@bb.utils.filter('DISTRO_FEATURES', 'alsa x11', d)} \
|
||||
jpeg ogg pango png theora vorbis \
|
||||
${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland egl', '', d)} \
|
||||
encoding \
|
||||
"
|
||||
|
||||
PACKAGECONFIG[encoding] = "-Dencoding=enabled,-Dencoding=disabled,"
|
||||
|
||||
#enable hardware convert/scale in playbin (gstsubtitleoverlay.c, gstplaysinkvideoconvert.c, gstplaysink.c) & gstencodebin (gstencodebin.c)
|
||||
#disable software convert/scale/rate in gstencodebin (gstencodebin.c)
|
||||
#HW_TRANSFORM_CONFIG = 'CFLAGS="-DCOLORSPACE=\\\\\\"autovideoconvert\\\\\\" \
|
||||
# -DCOLORSPACE_SUBT=\\\\\\"videoconvert\\\\\\" \
|
||||
# -DGST_PLAYBIN_DEFAULT_FLAGS=0x00000017 \
|
||||
# -DCOLORSPACE2=\\\\\\"identity\\\\\\" \
|
||||
# -DVIDEOSCALE=\\\\\\"identity\\\\\\" \
|
||||
# -DVIDEORATE=\\\\\\"identity\\\\\\" "'
|
||||
|
||||
#CACHED_CONFIGUREVARS += "${@bb.utils.contains('DISTRO_FEATURES', 'hwdecode', '${HW_TRANSFORM_CONFIG}', '', d)}"
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}/:"
|
||||
|
||||
PACKAGECONFIG ?= " \
|
||||
${GSTREAMER_ORC} \
|
||||
${@bb.utils.filter('DISTRO_FEATURES', 'pulseaudio x11', d)} \
|
||||
bz2 cairo flac gdk-pixbuf gudev jpeg lame libpng mpg123 soup speex taglib v4l2 \
|
||||
libv4l2 \
|
||||
${@bb.utils.contains_any('DISTRO_FEATURES', '${GTK3DISTROFEATURES}', 'gtk', '', d)} \
|
||||
"
|
||||
|
||||
EXTRA_OEMESON += " \
|
||||
-Dv4l2-probe=enabled \
|
||||
-Dv4l2-libv4l2=enabled \
|
||||
"
|
||||
|
||||
# remove qt5 for the moment
|
||||
PACKAGECONFIG:remove = " qt5"
|
||||
|
||||
RDEPENDS:${PN}-soup += "libsoup-2.4"
|
||||
Loading…
Reference in New Issue