2012-08-08 14:10:28 +00:00
|
|
|
/* GStreamer Wayland video sink
|
2011-11-02 09:02:11 +00:00
|
|
|
*
|
2012-03-07 23:48:56 +00:00
|
|
|
* Copyright (C) 2011 Intel Corporation
|
|
|
|
* Copyright (C) 2011 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
|
2012-05-23 10:07:14 +00:00
|
|
|
* Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
|
2014-03-07 14:16:30 +00:00
|
|
|
* Copyright (C) 2014 Collabora Ltd.
|
2012-05-23 10:07:14 +00:00
|
|
|
*
|
2011-11-02 09:02:11 +00:00
|
|
|
* 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
|
2012-08-18 19:31:17 +00:00
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA.
|
2011-11-02 09:02:11 +00:00
|
|
|
*/
|
|
|
|
|
2012-03-07 23:48:56 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-waylandsink
|
|
|
|
*
|
|
|
|
* The waylandsink is creating its own window and render the decoded video frames to that.
|
|
|
|
* Setup the Wayland environment as described in
|
|
|
|
* <ulink url="http://wayland.freedesktop.org/building.html">Wayland</ulink> home page.
|
2012-05-23 10:07:14 +00:00
|
|
|
* The current implementaion is based on weston compositor.
|
2012-03-07 23:48:56 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Example pipelines</title>
|
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 -v videotestsrc ! waylandsink
|
2012-03-07 23:48:56 +00:00
|
|
|
* ]| test the video rendering in wayland
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
2011-11-02 09:02:11 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstwaylandsink.h"
|
2014-02-13 09:02:54 +00:00
|
|
|
#include "wlvideoformat.h"
|
2014-06-20 11:47:57 +00:00
|
|
|
#include "wlbuffer.h"
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
#include "wlshmallocator.h"
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-02-14 15:08:56 +00:00
|
|
|
#include <gst/wayland/wayland.h>
|
|
|
|
#include <gst/video/videooverlay.h>
|
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
/* signals */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SIGNAL_0,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Properties */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2014-02-26 12:56:21 +00:00
|
|
|
PROP_DISPLAY
|
2011-11-02 09:02:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY (gstwayland_debug);
|
|
|
|
#define GST_CAT_DEFAULT gstwayland_debug
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2014-03-12 12:13:49 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
|
|
|
|
("{ BGRx, BGRA, RGBx, xBGR, xRGB, RGBA, ABGR, ARGB, RGB, BGR, "
|
|
|
|
"RGB16, BGR16, YUY2, YVYU, UYVY, AYUV, NV12, NV21, NV16, "
|
|
|
|
"YUV9, YVU9, Y41B, I420, YV12, Y42B, v308 }"))
|
2013-06-18 11:47:54 +00:00
|
|
|
);
|
2012-03-07 23:48:56 +00:00
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
static void gst_wayland_sink_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_wayland_sink_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_wayland_sink_finalize (GObject * object);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
|
|
|
static GstStateChangeReturn gst_wayland_sink_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2014-05-21 15:27:28 +00:00
|
|
|
static void gst_wayland_sink_set_context (GstElement * element,
|
|
|
|
GstContext * context);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2012-05-23 10:07:14 +00:00
|
|
|
static GstCaps *gst_wayland_sink_get_caps (GstBaseSink * bsink,
|
|
|
|
GstCaps * filter);
|
2011-11-02 09:02:11 +00:00
|
|
|
static gboolean gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps);
|
2012-08-08 14:10:28 +00:00
|
|
|
static gboolean
|
|
|
|
gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query);
|
2016-09-16 19:41:11 +00:00
|
|
|
static gboolean gst_wayland_sink_show_frame (GstVideoSink * bsink,
|
2011-11-02 09:02:11 +00:00
|
|
|
GstBuffer * buffer);
|
|
|
|
|
2014-02-14 15:08:56 +00:00
|
|
|
/* VideoOverlay interface */
|
|
|
|
static void gst_wayland_sink_videooverlay_init (GstVideoOverlayInterface *
|
|
|
|
iface);
|
|
|
|
static void gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay,
|
|
|
|
guintptr handle);
|
2014-05-23 15:18:32 +00:00
|
|
|
static void gst_wayland_sink_set_render_rectangle (GstVideoOverlay * overlay,
|
|
|
|
gint x, gint y, gint w, gint h);
|
2014-02-14 15:08:56 +00:00
|
|
|
static void gst_wayland_sink_expose (GstVideoOverlay * overlay);
|
|
|
|
|
|
|
|
/* WaylandVideo interface */
|
|
|
|
static void gst_wayland_sink_waylandvideo_init (GstWaylandVideoInterface *
|
|
|
|
iface);
|
2014-06-06 10:49:56 +00:00
|
|
|
static void gst_wayland_sink_begin_geometry_change (GstWaylandVideo * video);
|
|
|
|
static void gst_wayland_sink_end_geometry_change (GstWaylandVideo * video);
|
2014-02-14 15:08:56 +00:00
|
|
|
|
|
|
|
#define gst_wayland_sink_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstWaylandSink, gst_wayland_sink, GST_TYPE_VIDEO_SINK,
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY,
|
|
|
|
gst_wayland_sink_videooverlay_init)
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_WAYLAND_VIDEO,
|
|
|
|
gst_wayland_sink_waylandvideo_init));
|
2011-11-02 09:02:11 +00:00
|
|
|
|
|
|
|
static void
|
2011-11-02 11:51:13 +00:00
|
|
|
gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
|
2011-11-02 09:02:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2012-05-23 10:07:14 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2011-11-02 09:02:11 +00:00
|
|
|
GstBaseSinkClass *gstbasesink_class;
|
2016-09-16 19:41:11 +00:00
|
|
|
GstVideoSinkClass *gstvideosink_class;
|
2011-11-02 09:02:11 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
2012-05-23 10:07:14 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2011-11-02 09:02:11 +00:00
|
|
|
gstbasesink_class = (GstBaseSinkClass *) klass;
|
2016-09-16 19:41:11 +00:00
|
|
|
gstvideosink_class = (GstVideoSinkClass *) klass;
|
2011-11-02 09:02:11 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_wayland_sink_set_property;
|
|
|
|
gobject_class->get_property = gst_wayland_sink_get_property;
|
|
|
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_wayland_sink_finalize);
|
|
|
|
|
2016-03-04 06:50:26 +00:00
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &sink_template);
|
2012-05-23 10:07:14 +00:00
|
|
|
|
2012-10-17 16:34:26 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class,
|
2012-05-23 10:07:14 +00:00
|
|
|
"wayland video sink", "Sink/Video",
|
|
|
|
"Output to wayland surface",
|
2014-03-12 17:25:06 +00:00
|
|
|
"Sreerenj Balachandran <sreerenj.balachandran@intel.com>, "
|
|
|
|
"George Kiagiadakis <george.kiagiadakis@collabora.com>");
|
2012-05-23 10:07:14 +00:00
|
|
|
|
2014-02-28 09:48:30 +00:00
|
|
|
gstelement_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wayland_sink_change_state);
|
2014-05-21 15:27:28 +00:00
|
|
|
gstelement_class->set_context =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wayland_sink_set_context);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_get_caps);
|
|
|
|
gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_set_caps);
|
2012-08-08 14:10:28 +00:00
|
|
|
gstbasesink_class->propose_allocation =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wayland_sink_propose_allocation);
|
2016-09-16 19:41:11 +00:00
|
|
|
|
|
|
|
gstvideosink_class->show_frame =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_wayland_sink_show_frame);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-02-26 12:56:21 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_DISPLAY,
|
|
|
|
g_param_spec_string ("display", "Wayland Display name", "Wayland "
|
2014-05-21 15:27:28 +00:00
|
|
|
"display name to connect to, if not supplied via the GstContext",
|
2014-02-26 12:56:21 +00:00
|
|
|
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2011-11-02 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-23 10:07:14 +00:00
|
|
|
gst_wayland_sink_init (GstWaylandSink * sink)
|
2011-11-02 09:02:11 +00:00
|
|
|
{
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_init (&sink->display_lock);
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_init (&sink->render_lock);
|
2011-11-02 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wayland_sink_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2011-11-02 11:51:13 +00:00
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (object);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2014-02-26 12:56:21 +00:00
|
|
|
case PROP_DISPLAY:
|
2014-06-06 10:10:24 +00:00
|
|
|
GST_OBJECT_LOCK (sink);
|
2014-02-26 12:56:21 +00:00
|
|
|
g_value_set_string (value, sink->display_name);
|
2014-06-06 10:10:24 +00:00
|
|
|
GST_OBJECT_UNLOCK (sink);
|
2011-11-02 09:02:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wayland_sink_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2011-11-02 11:51:13 +00:00
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (object);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2014-02-26 12:56:21 +00:00
|
|
|
case PROP_DISPLAY:
|
2014-06-06 10:10:24 +00:00
|
|
|
GST_OBJECT_LOCK (sink);
|
2014-02-26 12:56:21 +00:00
|
|
|
sink->display_name = g_value_dup_string (value);
|
2014-06-06 10:10:24 +00:00
|
|
|
GST_OBJECT_UNLOCK (sink);
|
2011-11-02 09:02:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wayland_sink_finalize (GObject * object)
|
|
|
|
{
|
2011-11-02 11:51:13 +00:00
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (object);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2011-11-02 11:51:13 +00:00
|
|
|
GST_DEBUG_OBJECT (sink, "Finalizing the sink..");
|
|
|
|
|
2014-03-11 15:45:05 +00:00
|
|
|
if (sink->last_buffer)
|
|
|
|
gst_buffer_unref (sink->last_buffer);
|
2014-06-23 14:27:01 +00:00
|
|
|
if (sink->display)
|
2014-03-07 14:16:30 +00:00
|
|
|
g_object_unref (sink->display);
|
2012-03-07 23:48:56 +00:00
|
|
|
if (sink->window)
|
2014-02-13 10:59:45 +00:00
|
|
|
g_object_unref (sink->window);
|
2014-02-26 14:20:41 +00:00
|
|
|
if (sink->pool)
|
|
|
|
gst_object_unref (sink->pool);
|
|
|
|
|
2015-11-17 23:23:17 +00:00
|
|
|
g_free (sink->display_name);
|
2011-11-02 11:51:13 +00:00
|
|
|
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_clear (&sink->display_lock);
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_clear (&sink->render_lock);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2014-06-06 10:04:44 +00:00
|
|
|
/* must be called with the display_lock */
|
|
|
|
static void
|
|
|
|
gst_wayland_sink_set_display_from_context (GstWaylandSink * sink,
|
|
|
|
GstContext * context)
|
|
|
|
{
|
|
|
|
struct wl_display *display;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
display = gst_wayland_display_handle_context_get_handle (context);
|
|
|
|
sink->display = gst_wl_display_new_existing (display, FALSE, &error);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
GST_ELEMENT_WARNING (sink, RESOURCE, OPEN_READ_WRITE,
|
|
|
|
("Could not set display handle"),
|
|
|
|
("Failed to use the external wayland display: '%s'", error->message));
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-21 15:27:28 +00:00
|
|
|
static gboolean
|
|
|
|
gst_wayland_sink_find_display (GstWaylandSink * sink)
|
2014-02-28 09:48:30 +00:00
|
|
|
{
|
2014-05-21 15:27:28 +00:00
|
|
|
GstQuery *query;
|
|
|
|
GstMessage *msg;
|
|
|
|
GstContext *context = NULL;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_lock (&sink->display_lock);
|
|
|
|
|
2014-05-21 15:27:28 +00:00
|
|
|
if (!sink->display) {
|
|
|
|
/* first query upstream for the needed display handle */
|
|
|
|
query = gst_query_new_context (GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE);
|
|
|
|
if (gst_pad_peer_query (GST_VIDEO_SINK_PAD (sink), query)) {
|
|
|
|
gst_query_parse_context (query, &context);
|
2014-06-06 10:04:44 +00:00
|
|
|
gst_wayland_sink_set_display_from_context (sink, context);
|
2014-05-21 15:27:28 +00:00
|
|
|
}
|
|
|
|
gst_query_unref (query);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2014-05-21 15:27:28 +00:00
|
|
|
if (G_LIKELY (!sink->display)) {
|
|
|
|
/* now ask the application to set the display handle */
|
|
|
|
msg = gst_message_new_need_context (GST_OBJECT_CAST (sink),
|
|
|
|
GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE);
|
2014-06-06 10:04:44 +00:00
|
|
|
|
|
|
|
g_mutex_unlock (&sink->display_lock);
|
2014-05-21 15:27:28 +00:00
|
|
|
gst_element_post_message (GST_ELEMENT_CAST (sink), msg);
|
|
|
|
/* at this point we expect gst_wayland_sink_set_context
|
|
|
|
* to get called and fill sink->display */
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_lock (&sink->display_lock);
|
2014-03-12 12:28:44 +00:00
|
|
|
|
|
|
|
if (!sink->display) {
|
2014-05-21 15:27:28 +00:00
|
|
|
/* if the application didn't set a display, let's create it ourselves */
|
2014-06-06 10:10:24 +00:00
|
|
|
GST_OBJECT_LOCK (sink);
|
2014-03-12 12:28:44 +00:00
|
|
|
sink->display = gst_wl_display_new (sink->display_name, &error);
|
2014-06-06 10:10:24 +00:00
|
|
|
GST_OBJECT_UNLOCK (sink);
|
|
|
|
|
2014-05-21 15:27:28 +00:00
|
|
|
if (error) {
|
2014-03-12 12:28:44 +00:00
|
|
|
GST_ELEMENT_WARNING (sink, RESOURCE, OPEN_READ_WRITE,
|
|
|
|
("Could not initialise Wayland output"),
|
|
|
|
("Failed to create GstWlDisplay: '%s'", error->message));
|
|
|
|
g_error_free (error);
|
2014-05-21 15:27:28 +00:00
|
|
|
ret = FALSE;
|
2014-03-12 12:28:44 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-21 15:27:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_unlock (&sink->display_lock);
|
|
|
|
|
2014-05-21 15:27:28 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_wayland_sink_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (element);
|
|
|
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
|
|
|
if (!gst_wayland_sink_find_display (sink))
|
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2014-02-28 09:48:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2014-06-16 16:03:51 +00:00
|
|
|
gst_buffer_replace (&sink->last_buffer, NULL);
|
|
|
|
if (sink->window) {
|
|
|
|
if (gst_wl_window_is_toplevel (sink->window)) {
|
|
|
|
g_clear_object (&sink->window);
|
|
|
|
} else {
|
|
|
|
/* remove buffer from surface, show nothing */
|
2014-07-01 08:43:20 +00:00
|
|
|
gst_wl_window_render (sink->window, NULL, NULL);
|
2014-06-16 16:03:51 +00:00
|
|
|
}
|
2014-03-12 12:28:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_lock (&sink->display_lock);
|
2014-06-16 16:03:51 +00:00
|
|
|
/* If we had a toplevel window, we most likely have our own connection
|
|
|
|
* to the display too, and it is a good idea to disconnect and allow
|
|
|
|
* potentially the application to embed us with GstVideoOverlay
|
|
|
|
* (which requires to re-use the same display connection as the parent
|
|
|
|
* surface). If we didn't have a toplevel window, then the display
|
|
|
|
* connection that we have is definitely shared with the application
|
|
|
|
* and it's better to keep it around (together with the window handle)
|
|
|
|
* to avoid requesting them again from the application if/when we are
|
|
|
|
* restarted (GstVideoOverlay behaves like that in other sinks)
|
|
|
|
*/
|
2014-03-12 12:28:44 +00:00
|
|
|
if (sink->display && !sink->window) { /* -> the window was toplevel */
|
2014-02-28 09:48:30 +00:00
|
|
|
g_clear_object (&sink->display);
|
|
|
|
}
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_unlock (&sink->display_lock);
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
g_clear_object (&sink->pool);
|
2014-02-28 09:48:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-05-21 15:27:28 +00:00
|
|
|
static void
|
|
|
|
gst_wayland_sink_set_context (GstElement * element, GstContext * context)
|
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (element);
|
|
|
|
|
|
|
|
if (gst_context_has_context_type (context,
|
|
|
|
GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE)) {
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_lock (&sink->display_lock);
|
2015-04-09 04:17:01 +00:00
|
|
|
if (G_LIKELY (!sink->display)) {
|
2014-06-06 10:04:44 +00:00
|
|
|
gst_wayland_sink_set_display_from_context (sink, context);
|
2015-04-09 04:17:01 +00:00
|
|
|
} else {
|
2014-06-06 10:04:44 +00:00
|
|
|
GST_WARNING_OBJECT (element, "changing display handle is not supported");
|
2015-04-09 04:17:01 +00:00
|
|
|
g_mutex_unlock (&sink->display_lock);
|
|
|
|
return;
|
|
|
|
}
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_unlock (&sink->display_lock);
|
2014-05-21 15:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->set_context)
|
|
|
|
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
|
|
|
|
}
|
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
static GstCaps *
|
2012-05-23 10:07:14 +00:00
|
|
|
gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
|
2011-11-02 09:02:11 +00:00
|
|
|
{
|
2012-08-08 14:10:28 +00:00
|
|
|
GstWaylandSink *sink;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
sink = GST_WAYLAND_SINK (bsink);
|
|
|
|
|
|
|
|
caps = gst_pad_get_pad_template_caps (GST_VIDEO_SINK_PAD (sink));
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_lock (&sink->display_lock);
|
|
|
|
|
2014-03-12 12:13:49 +00:00
|
|
|
if (sink->display) {
|
|
|
|
GValue list = G_VALUE_INIT;
|
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
GArray *formats;
|
|
|
|
gint i;
|
|
|
|
enum wl_shm_format fmt;
|
|
|
|
|
|
|
|
g_value_init (&list, GST_TYPE_LIST);
|
|
|
|
|
2015-08-30 12:55:11 +00:00
|
|
|
formats = sink->display->shm_formats;
|
2014-03-12 12:13:49 +00:00
|
|
|
for (i = 0; i < formats->len; i++) {
|
2016-09-23 19:49:21 +00:00
|
|
|
g_value_init (&value, G_TYPE_STRING);
|
2014-03-12 12:13:49 +00:00
|
|
|
fmt = g_array_index (formats, uint32_t, i);
|
2016-09-23 19:49:21 +00:00
|
|
|
g_value_set_static_string (&value, gst_wl_shm_format_to_string (fmt));
|
|
|
|
gst_value_list_append_and_take_value (&list, &value);
|
2014-03-12 12:13:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
caps = gst_caps_make_writable (caps);
|
2016-09-23 19:49:21 +00:00
|
|
|
gst_structure_take_value (gst_caps_get_structure (caps, 0), "format",
|
|
|
|
&list);
|
2014-03-12 12:13:49 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (sink, "display caps: %" GST_PTR_FORMAT, caps);
|
|
|
|
}
|
|
|
|
|
2014-06-06 10:04:44 +00:00
|
|
|
g_mutex_unlock (&sink->display_lock);
|
|
|
|
|
2012-08-08 14:10:28 +00:00
|
|
|
if (filter) {
|
|
|
|
GstCaps *intersection;
|
|
|
|
|
|
|
|
intersection =
|
|
|
|
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
caps = intersection;
|
|
|
|
}
|
2014-03-12 12:13:49 +00:00
|
|
|
|
2012-08-08 14:10:28 +00:00
|
|
|
return caps;
|
2011-11-02 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
2016-09-19 16:04:52 +00:00
|
|
|
static GstBufferPool *
|
|
|
|
gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
GstStructure *structure;
|
|
|
|
gsize size = sink->video_info.size;
|
|
|
|
|
|
|
|
pool = gst_video_buffer_pool_new ();
|
|
|
|
|
|
|
|
structure = gst_buffer_pool_get_config (pool);
|
2016-09-29 16:12:24 +00:00
|
|
|
gst_buffer_pool_config_set_params (structure, caps, size, 2, 0);
|
2016-09-19 16:04:52 +00:00
|
|
|
gst_buffer_pool_config_set_allocator (structure, gst_wl_shm_allocator_get (),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (!gst_buffer_pool_set_config (pool, structure)) {
|
|
|
|
g_object_unref (pool);
|
|
|
|
pool = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
}
|
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
static gboolean
|
|
|
|
gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|
|
|
{
|
2014-04-14 05:56:16 +00:00
|
|
|
GstWaylandSink *sink;
|
2014-02-14 16:20:42 +00:00
|
|
|
GstBufferPool *newpool;
|
2012-08-08 14:10:28 +00:00
|
|
|
GstVideoInfo info;
|
2014-02-26 16:35:29 +00:00
|
|
|
enum wl_shm_format format;
|
|
|
|
GArray *formats;
|
|
|
|
gint i;
|
2012-08-08 14:10:28 +00:00
|
|
|
|
|
|
|
sink = GST_WAYLAND_SINK (bsink);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-02-28 09:48:30 +00:00
|
|
|
GST_DEBUG_OBJECT (sink, "set caps %" GST_PTR_FORMAT, caps);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-02-26 16:35:29 +00:00
|
|
|
/* extract info from caps */
|
2012-08-08 14:10:28 +00:00
|
|
|
if (!gst_video_info_from_caps (&info, caps))
|
|
|
|
goto invalid_format;
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-06-20 13:24:36 +00:00
|
|
|
format = gst_video_format_to_wl_shm_format (GST_VIDEO_INFO_FORMAT (&info));
|
2014-06-21 14:57:18 +00:00
|
|
|
if ((gint) format == -1)
|
2013-06-18 11:47:54 +00:00
|
|
|
goto invalid_format;
|
|
|
|
|
2014-02-26 16:35:29 +00:00
|
|
|
/* verify we support the requested format */
|
2015-08-30 12:55:11 +00:00
|
|
|
formats = sink->display->shm_formats;
|
2014-02-26 16:35:29 +00:00
|
|
|
for (i = 0; i < formats->len; i++) {
|
|
|
|
if (g_array_index (formats, uint32_t, i) == format)
|
|
|
|
break;
|
2013-06-18 11:47:54 +00:00
|
|
|
}
|
|
|
|
|
2014-02-26 16:35:29 +00:00
|
|
|
if (i >= formats->len)
|
|
|
|
goto unsupported_format;
|
|
|
|
|
2016-09-19 16:04:52 +00:00
|
|
|
/* store the video info */
|
|
|
|
sink->video_info = info;
|
|
|
|
sink->video_info_changed = TRUE;
|
|
|
|
|
2012-08-08 14:10:28 +00:00
|
|
|
/* create a new pool for the new configuration */
|
2016-09-19 16:04:52 +00:00
|
|
|
newpool = gst_wayland_create_pool (sink, caps);
|
2014-02-28 09:48:30 +00:00
|
|
|
if (!newpool)
|
|
|
|
goto pool_failed;
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-06-13 13:58:08 +00:00
|
|
|
|
2014-02-14 16:20:42 +00:00
|
|
|
gst_object_replace ((GstObject **) & sink->pool, (GstObject *) newpool);
|
|
|
|
gst_object_unref (newpool);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2012-08-08 14:10:28 +00:00
|
|
|
return TRUE;
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2012-08-08 14:10:28 +00:00
|
|
|
invalid_format:
|
|
|
|
{
|
2016-09-19 16:06:17 +00:00
|
|
|
GST_ERROR_OBJECT (sink,
|
2012-08-08 14:10:28 +00:00
|
|
|
"Could not locate image format from caps %" GST_PTR_FORMAT, caps);
|
2014-06-06 08:35:20 +00:00
|
|
|
return FALSE;
|
2014-02-28 09:48:30 +00:00
|
|
|
}
|
2014-02-26 16:35:29 +00:00
|
|
|
unsupported_format:
|
|
|
|
{
|
2016-09-19 16:06:17 +00:00
|
|
|
GST_ERROR_OBJECT (sink, "Format %s is not available on the display",
|
2014-06-20 13:24:36 +00:00
|
|
|
gst_wl_shm_format_to_string (format));
|
2014-06-06 08:35:20 +00:00
|
|
|
return FALSE;
|
2014-02-28 09:48:30 +00:00
|
|
|
}
|
|
|
|
pool_failed:
|
|
|
|
{
|
2016-09-19 16:04:52 +00:00
|
|
|
GST_ERROR_OBJECT (sink, "Failed to create new pool");
|
2012-09-13 00:07:46 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-11-02 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2012-08-08 14:10:28 +00:00
|
|
|
gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (bsink);
|
2016-09-19 16:08:20 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
GstBufferPool *pool = NULL;
|
|
|
|
gboolean need_pool;
|
2012-08-08 14:10:28 +00:00
|
|
|
|
2016-09-19 16:08:20 +00:00
|
|
|
gst_query_parse_allocation (query, &caps, &need_pool);
|
2012-08-08 14:10:28 +00:00
|
|
|
|
2016-09-19 16:08:20 +00:00
|
|
|
if (need_pool)
|
|
|
|
pool = gst_wayland_create_pool (sink, caps);
|
|
|
|
|
|
|
|
if (pool) {
|
2016-09-22 19:37:41 +00:00
|
|
|
gst_query_add_allocation_pool (query, pool, sink->video_info.size, 2, 0);
|
2016-09-19 16:08:20 +00:00
|
|
|
g_object_unref (pool);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_query_add_allocation_param (query, gst_wl_shm_allocator_get (), NULL);
|
|
|
|
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
2015-01-23 11:44:22 +00:00
|
|
|
|
2012-08-08 14:10:28 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
frame_redraw_callback (void *data, struct wl_callback *callback, uint32_t time)
|
|
|
|
{
|
2014-03-07 15:25:00 +00:00
|
|
|
GstWaylandSink *sink = data;
|
|
|
|
|
2014-02-12 10:28:40 +00:00
|
|
|
GST_LOG ("frame_redraw_cb");
|
2014-03-07 15:25:00 +00:00
|
|
|
|
2016-09-22 22:53:22 +00:00
|
|
|
g_mutex_lock (&sink->render_lock);
|
|
|
|
sink->redraw_pending = FALSE;
|
|
|
|
g_mutex_unlock (&sink->render_lock);
|
|
|
|
|
2012-08-08 14:10:28 +00:00
|
|
|
wl_callback_destroy (callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_callback_listener frame_callback_listener = {
|
|
|
|
frame_redraw_callback
|
|
|
|
};
|
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
/* must be called with the render lock */
|
2014-03-11 15:45:05 +00:00
|
|
|
static void
|
|
|
|
render_last_buffer (GstWaylandSink * sink)
|
|
|
|
{
|
2014-06-20 11:47:57 +00:00
|
|
|
GstWlBuffer *wlbuffer;
|
2014-07-01 08:43:20 +00:00
|
|
|
const GstVideoInfo *info = NULL;
|
2014-03-11 15:45:05 +00:00
|
|
|
struct wl_surface *surface;
|
|
|
|
struct wl_callback *callback;
|
|
|
|
|
2014-06-20 11:47:57 +00:00
|
|
|
wlbuffer = gst_buffer_get_wl_buffer (sink->last_buffer);
|
2014-03-11 15:45:05 +00:00
|
|
|
surface = gst_wl_window_get_wl_surface (sink->window);
|
|
|
|
|
2016-09-22 22:53:22 +00:00
|
|
|
sink->redraw_pending = TRUE;
|
2014-03-11 15:45:05 +00:00
|
|
|
callback = wl_surface_frame (surface);
|
|
|
|
wl_callback_add_listener (callback, &frame_callback_listener, sink);
|
|
|
|
|
2014-07-01 08:43:20 +00:00
|
|
|
if (G_UNLIKELY (sink->video_info_changed)) {
|
|
|
|
info = &sink->video_info;
|
|
|
|
sink->video_info_changed = FALSE;
|
|
|
|
}
|
|
|
|
gst_wl_window_render (sink->window, wlbuffer, info);
|
2014-03-11 15:45:05 +00:00
|
|
|
}
|
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
static GstFlowReturn
|
2016-09-16 19:41:11 +00:00
|
|
|
gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
|
2011-11-02 09:02:11 +00:00
|
|
|
{
|
2016-09-16 19:41:11 +00:00
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (vsink);
|
2012-05-23 10:07:14 +00:00
|
|
|
GstBuffer *to_render;
|
2014-06-20 11:47:57 +00:00
|
|
|
GstWlBuffer *wlbuffer;
|
2014-02-28 09:48:30 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_lock (&sink->render_lock);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2012-07-15 11:27:12 +00:00
|
|
|
GST_LOG_OBJECT (sink, "render buffer %p", buffer);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2014-06-13 13:58:08 +00:00
|
|
|
if (G_UNLIKELY (!sink->window)) {
|
|
|
|
/* ask for window handle. Unlock render_lock while doing that because
|
|
|
|
* set_window_handle & friends will lock it in this context */
|
|
|
|
g_mutex_unlock (&sink->render_lock);
|
|
|
|
gst_video_overlay_prepare_window_handle (GST_VIDEO_OVERLAY (sink));
|
|
|
|
g_mutex_lock (&sink->render_lock);
|
|
|
|
|
2014-07-01 08:43:20 +00:00
|
|
|
if (!sink->window) {
|
2014-06-13 13:58:08 +00:00
|
|
|
/* if we were not provided a window, create one ourselves */
|
2016-09-22 22:55:23 +00:00
|
|
|
sink->window = gst_wl_window_new_toplevel (sink->display,
|
|
|
|
&sink->video_info, &sink->render_lock);
|
2014-06-13 13:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-07 15:25:00 +00:00
|
|
|
/* drop buffers until we get a frame callback */
|
2016-09-22 22:53:22 +00:00
|
|
|
if (sink->redraw_pending)
|
2014-03-07 15:25:00 +00:00
|
|
|
goto done;
|
|
|
|
|
2014-07-01 08:43:20 +00:00
|
|
|
/* make sure that the application has called set_render_rectangle() */
|
|
|
|
if (G_UNLIKELY (sink->window->render_rectangle.w == 0))
|
2014-06-13 13:58:08 +00:00
|
|
|
goto no_window_size;
|
|
|
|
|
2014-06-20 11:47:57 +00:00
|
|
|
wlbuffer = gst_buffer_get_wl_buffer (buffer);
|
2012-10-20 11:55:41 +00:00
|
|
|
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
if (G_LIKELY (wlbuffer && wlbuffer->display == sink->display)) {
|
|
|
|
GST_LOG_OBJECT (sink, "buffer %p has a wl_buffer from our display, "
|
|
|
|
"writing directly", buffer);
|
2012-05-23 10:07:14 +00:00
|
|
|
to_render = buffer;
|
|
|
|
} else {
|
2016-09-19 16:11:59 +00:00
|
|
|
GstVideoMeta *vmeta;
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
GstMemory *mem;
|
|
|
|
struct wl_buffer *wbuf = NULL;
|
|
|
|
|
2016-09-19 16:11:59 +00:00
|
|
|
/* update video info from video meta */
|
|
|
|
vmeta = gst_buffer_get_video_meta (buffer);
|
|
|
|
if (vmeta) {
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < vmeta->n_planes; i++) {
|
|
|
|
sink->video_info.offset[i] = vmeta->offset[i];
|
|
|
|
sink->video_info.stride[i] = vmeta->stride[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
GST_LOG_OBJECT (sink, "buffer %p does not have a wl_buffer from our "
|
|
|
|
"display, creating it", buffer);
|
2011-11-02 11:51:13 +00:00
|
|
|
|
2016-09-19 16:11:59 +00:00
|
|
|
/* FIXME check all memory when introducing DMA-Buf */
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
mem = gst_buffer_peek_memory (buffer, 0);
|
2012-08-08 14:10:28 +00:00
|
|
|
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
if (gst_is_wl_shm_memory (mem)) {
|
|
|
|
wbuf = gst_wl_shm_memory_construct_wl_buffer (mem, sink->display,
|
|
|
|
&sink->video_info);
|
|
|
|
}
|
2012-08-08 14:10:28 +00:00
|
|
|
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
if (wbuf) {
|
|
|
|
gst_buffer_add_wl_buffer (buffer, wbuf, sink->display);
|
|
|
|
to_render = buffer;
|
|
|
|
} else {
|
2016-09-19 16:11:59 +00:00
|
|
|
GstVideoFrame src, dst;
|
|
|
|
GstVideoInfo src_info = sink->video_info;
|
|
|
|
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
/* we don't know how to create a wl_buffer directly from the provided
|
|
|
|
* memory, so we have to copy the data to a memory that we know how
|
|
|
|
* to handle... */
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (sink, "buffer %p cannot have a wl_buffer, "
|
|
|
|
"copying to wl_shm memory", buffer);
|
|
|
|
|
|
|
|
/* sink->pool always exists (created in set_caps), but it may not
|
|
|
|
* be active if upstream is not using it */
|
2016-09-22 19:37:41 +00:00
|
|
|
if (!gst_buffer_pool_is_active (sink->pool)) {
|
|
|
|
GstStructure *config;
|
|
|
|
GstCaps *caps;
|
|
|
|
guint size = sink->video_info.size;
|
|
|
|
|
|
|
|
config = gst_buffer_pool_get_config (sink->pool);
|
|
|
|
gst_buffer_pool_config_get_params (config, &caps, &size, NULL, NULL);
|
2016-09-29 16:49:39 +00:00
|
|
|
gst_buffer_pool_config_set_params (config, caps, size, 2, 0);
|
2016-09-22 19:37:41 +00:00
|
|
|
|
|
|
|
/* This is a video pool, it should not fail with basic setings */
|
2016-09-29 16:12:24 +00:00
|
|
|
if (!gst_buffer_pool_set_config (sink->pool, config) ||
|
|
|
|
!gst_buffer_pool_set_active (sink->pool, TRUE))
|
2016-09-22 19:37:41 +00:00
|
|
|
goto activate_failed;
|
|
|
|
}
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
|
|
|
|
ret = gst_buffer_pool_acquire_buffer (sink->pool, &to_render, NULL);
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto no_buffer;
|
|
|
|
|
|
|
|
/* the first time we acquire a buffer,
|
|
|
|
* we need to attach a wl_buffer on it */
|
2015-08-30 12:56:57 +00:00
|
|
|
wlbuffer = gst_buffer_get_wl_buffer (to_render);
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
if (G_UNLIKELY (!wlbuffer)) {
|
|
|
|
mem = gst_buffer_peek_memory (to_render, 0);
|
|
|
|
wbuf = gst_wl_shm_memory_construct_wl_buffer (mem, sink->display,
|
|
|
|
&sink->video_info);
|
|
|
|
if (G_UNLIKELY (!wbuf))
|
|
|
|
goto no_wl_buffer;
|
|
|
|
|
2015-08-30 12:56:57 +00:00
|
|
|
gst_buffer_add_wl_buffer (to_render, wbuf, sink->display);
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
}
|
2011-11-02 11:51:13 +00:00
|
|
|
|
2016-09-19 16:11:59 +00:00
|
|
|
if (!gst_video_frame_map (&dst, &sink->video_info, to_render,
|
|
|
|
GST_MAP_WRITE))
|
|
|
|
goto dst_map_failed;
|
|
|
|
|
|
|
|
if (!gst_video_frame_map (&src, &src_info, buffer, GST_MAP_READ)) {
|
|
|
|
gst_video_frame_unmap (&dst);
|
|
|
|
goto src_map_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_video_frame_copy (&dst, &src);
|
|
|
|
|
|
|
|
gst_video_frame_unmap (&src);
|
|
|
|
gst_video_frame_unmap (&dst);
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
}
|
2012-05-23 10:07:14 +00:00
|
|
|
}
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2014-10-07 08:37:33 +00:00
|
|
|
/* drop double rendering */
|
|
|
|
if (G_UNLIKELY (to_render == sink->last_buffer)) {
|
|
|
|
GST_LOG_OBJECT (sink, "Buffer already being rendered");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2014-03-11 15:45:05 +00:00
|
|
|
gst_buffer_replace (&sink->last_buffer, to_render);
|
|
|
|
render_last_buffer (sink);
|
2011-11-02 09:02:11 +00:00
|
|
|
|
2012-05-23 10:07:14 +00:00
|
|
|
if (buffer != to_render)
|
|
|
|
gst_buffer_unref (to_render);
|
2014-02-28 09:48:30 +00:00
|
|
|
goto done;
|
2012-05-23 10:07:14 +00:00
|
|
|
|
2014-05-21 15:27:28 +00:00
|
|
|
no_window_size:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
|
|
|
|
("Window has no size set"),
|
|
|
|
("Make sure you set the size after calling set_window_handle"));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
2012-08-08 14:10:28 +00:00
|
|
|
no_buffer:
|
|
|
|
{
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
GST_WARNING_OBJECT (sink, "could not create buffer");
|
2014-02-28 09:48:30 +00:00
|
|
|
goto done;
|
2012-08-08 14:10:28 +00:00
|
|
|
}
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
no_wl_buffer:
|
2012-05-23 10:07:14 +00:00
|
|
|
{
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
GST_ERROR_OBJECT (sink, "could not create wl_buffer out of wl_shm memory");
|
2014-02-28 09:48:30 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
2012-08-08 14:10:28 +00:00
|
|
|
}
|
|
|
|
activate_failed:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (sink, "failed to activate bufferpool.");
|
|
|
|
ret = GST_FLOW_ERROR;
|
2014-02-28 09:48:30 +00:00
|
|
|
goto done;
|
|
|
|
}
|
2016-09-19 16:11:59 +00:00
|
|
|
src_map_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (sink, RESOURCE, READ,
|
|
|
|
("Video memory can not be read from userspace."), (NULL));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
dst_map_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
|
|
|
|
("Video memory can not be written from userspace."), (NULL));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
2014-02-28 09:48:30 +00:00
|
|
|
done:
|
|
|
|
{
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2012-08-08 14:10:28 +00:00
|
|
|
return ret;
|
2012-05-23 10:07:14 +00:00
|
|
|
}
|
2011-11-02 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 15:08:56 +00:00
|
|
|
static void
|
|
|
|
gst_wayland_sink_videooverlay_init (GstVideoOverlayInterface * iface)
|
|
|
|
{
|
|
|
|
iface->set_window_handle = gst_wayland_sink_set_window_handle;
|
2014-05-23 15:18:32 +00:00
|
|
|
iface->set_render_rectangle = gst_wayland_sink_set_render_rectangle;
|
2014-02-14 15:08:56 +00:00
|
|
|
iface->expose = gst_wayland_sink_expose;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
|
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
|
2014-05-21 15:27:28 +00:00
|
|
|
struct wl_surface *surface = (struct wl_surface *) handle;
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2014-02-14 15:08:56 +00:00
|
|
|
g_return_if_fail (sink != NULL);
|
2014-03-12 12:28:44 +00:00
|
|
|
|
2015-11-03 10:42:40 +00:00
|
|
|
if (sink->window != NULL) {
|
|
|
|
GST_WARNING_OBJECT (sink, "changing window handle is not supported");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_lock (&sink->render_lock);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (sink, "Setting window handle %" GST_PTR_FORMAT,
|
|
|
|
(void *) handle);
|
|
|
|
|
|
|
|
g_clear_object (&sink->window);
|
|
|
|
|
|
|
|
if (handle) {
|
2014-05-21 15:27:28 +00:00
|
|
|
if (G_LIKELY (gst_wayland_sink_find_display (sink))) {
|
|
|
|
/* we cannot use our own display with an external window handle */
|
|
|
|
if (G_UNLIKELY (sink->display->own_display)) {
|
|
|
|
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ_WRITE,
|
|
|
|
("Application did not provide a wayland display handle"),
|
|
|
|
("waylandsink cannot use an externally-supplied surface without "
|
|
|
|
"an externally-supplied display handle. Consider providing a "
|
|
|
|
"display handle from your application with GstContext"));
|
|
|
|
} else {
|
2016-09-22 22:55:23 +00:00
|
|
|
sink->window = gst_wl_window_new_in_surface (sink->display, surface,
|
|
|
|
&sink->render_lock);
|
2014-05-21 15:27:28 +00:00
|
|
|
}
|
2014-02-28 09:48:30 +00:00
|
|
|
} else {
|
2014-05-21 15:27:28 +00:00
|
|
|
GST_ERROR_OBJECT (sink, "Failed to find display handle, "
|
|
|
|
"ignoring window handle");
|
2014-02-28 09:48:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-02-14 15:08:56 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 15:18:32 +00:00
|
|
|
static void
|
|
|
|
gst_wayland_sink_set_render_rectangle (GstVideoOverlay * overlay,
|
|
|
|
gint x, gint y, gint w, gint h)
|
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
|
|
|
|
|
|
|
|
g_return_if_fail (sink != NULL);
|
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_lock (&sink->render_lock);
|
2014-05-23 15:18:32 +00:00
|
|
|
if (!sink->window) {
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-05-23 15:18:32 +00:00
|
|
|
GST_WARNING_OBJECT (sink,
|
|
|
|
"set_render_rectangle called without window, ignoring");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (sink, "window geometry changed to (%d, %d) %d x %d",
|
|
|
|
x, y, w, h);
|
2014-05-26 11:13:56 +00:00
|
|
|
gst_wl_window_set_render_rectangle (sink->window, x, y, w, h);
|
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-05-23 15:18:32 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 15:08:56 +00:00
|
|
|
static void
|
|
|
|
gst_wayland_sink_expose (GstVideoOverlay * overlay)
|
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
|
2014-03-11 15:45:05 +00:00
|
|
|
|
2014-02-14 15:08:56 +00:00
|
|
|
g_return_if_fail (sink != NULL);
|
2014-03-11 15:45:05 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (sink, "expose");
|
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_lock (&sink->render_lock);
|
2016-09-22 22:53:22 +00:00
|
|
|
if (sink->last_buffer && !sink->redraw_pending) {
|
2014-03-11 15:45:05 +00:00
|
|
|
GST_DEBUG_OBJECT (sink, "redrawing last buffer");
|
|
|
|
render_last_buffer (sink);
|
|
|
|
}
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-02-14 15:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_wayland_sink_waylandvideo_init (GstWaylandVideoInterface * iface)
|
|
|
|
{
|
2014-06-06 10:49:56 +00:00
|
|
|
iface->begin_geometry_change = gst_wayland_sink_begin_geometry_change;
|
|
|
|
iface->end_geometry_change = gst_wayland_sink_end_geometry_change;
|
2014-02-14 15:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-06 10:49:56 +00:00
|
|
|
gst_wayland_sink_begin_geometry_change (GstWaylandVideo * video)
|
2014-02-14 15:08:56 +00:00
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (video);
|
|
|
|
g_return_if_fail (sink != NULL);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_lock (&sink->render_lock);
|
2014-07-01 08:43:20 +00:00
|
|
|
if (!sink->window || !sink->window->area_subsurface) {
|
2014-05-29 09:27:46 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-06-06 10:49:56 +00:00
|
|
|
GST_INFO_OBJECT (sink,
|
|
|
|
"begin_geometry_change called without window, ignoring");
|
2014-05-29 09:27:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-01 08:43:20 +00:00
|
|
|
wl_subsurface_set_sync (sink->window->area_subsurface);
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-02-14 15:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-06 10:49:56 +00:00
|
|
|
gst_wayland_sink_end_geometry_change (GstWaylandVideo * video)
|
2014-02-14 15:08:56 +00:00
|
|
|
{
|
|
|
|
GstWaylandSink *sink = GST_WAYLAND_SINK (video);
|
|
|
|
g_return_if_fail (sink != NULL);
|
2014-02-28 09:48:30 +00:00
|
|
|
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_lock (&sink->render_lock);
|
2014-07-01 08:43:20 +00:00
|
|
|
if (!sink->window || !sink->window->area_subsurface) {
|
2014-05-29 09:27:46 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-06-06 10:49:56 +00:00
|
|
|
GST_INFO_OBJECT (sink,
|
|
|
|
"end_geometry_change called without window, ignoring");
|
2014-05-29 09:27:46 +00:00
|
|
|
return;
|
2014-03-11 15:48:46 +00:00
|
|
|
}
|
2014-03-11 15:45:05 +00:00
|
|
|
|
2014-07-01 08:43:20 +00:00
|
|
|
wl_subsurface_set_desync (sink->window->area_subsurface);
|
2014-05-28 10:10:43 +00:00
|
|
|
g_mutex_unlock (&sink->render_lock);
|
2014-02-14 15:08:56 +00:00
|
|
|
}
|
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gstwayland_debug, "waylandsink", 0,
|
|
|
|
" wayland video sink");
|
|
|
|
|
waylandsink: replace the custom buffer pool with an allocator
This reduces the complexity of having a custom buffer pool, as
we don't really need it. We only need the custom allocation part.
And since the wl_buffer is no longer saved in a GstMeta, we can
create it and add it on the buffers in the sink's render()
function, which removes the reference cycle caused by the pool
holding a reference to the display and also allows more generic
scenarios (the allocator being used in another pool, or buffers
being allocated without a pool [if anything stupid does that]).
This commit also simplifies the propose_allocation() function,
which doesn't really need to do all these complicated checks,
since there is always a correct buffer pool available, created
in set_caps().
The other side effect of this commit is that a new wl_shm_pool
is now created for every GstMemory, which means that we use
as much shm memory as we actually need and no more. Previously,
the created wl_shm_pool would allocate space for 15 buffers, no
matter if they were being used or not.
2014-06-23 13:40:02 +00:00
|
|
|
gst_wl_shm_allocator_register ();
|
|
|
|
|
2011-11-02 09:02:11 +00:00
|
|
|
return gst_element_register (plugin, "waylandsink", GST_RANK_MARGINAL,
|
|
|
|
GST_TYPE_WAYLAND_SINK);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2012-04-05 16:02:56 +00:00
|
|
|
waylandsink,
|
2012-03-07 23:48:56 +00:00
|
|
|
"Wayland Video Sink", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
|
|
|
|
GST_PACKAGE_ORIGIN)
|