wayland: add public API for creating & using the display handle GstContext

This commit is contained in:
George Kiagiadakis 2014-05-23 13:09:27 +03:00
parent c62ec6f815
commit b806313396
3 changed files with 50 additions and 6 deletions

View file

@ -265,9 +265,7 @@ gst_wayland_sink_find_display (GstWaylandSink * sink)
} else {
/* inform the world about the new display */
context =
gst_context_new (GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE, FALSE);
gst_structure_set (gst_context_writable_structure (context),
"handle", G_TYPE_POINTER, sink->display->display, NULL);
gst_wayland_display_handle_context_new (sink->display->display);
msg = gst_message_new_have_context (GST_OBJECT_CAST (sink), context);
gst_element_post_message (GST_ELEMENT_CAST (sink), msg);
}
@ -345,13 +343,13 @@ gst_wayland_sink_set_context (GstElement * element, GstContext * context)
if (gst_context_has_context_type (context,
GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE)) {
const GstStructure *s;
struct wl_display *display;
GError *error = NULL;
s = gst_context_get_structure (context);
gst_structure_get (s, "handle", G_TYPE_POINTER, &display, NULL);
g_clear_object (&sink->display);
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"),

View file

@ -25,6 +25,45 @@
#include <gst/wayland/wayland.h>
#include <gst/video/videooverlay.h>
gboolean
gst_is_wayland_display_handle_need_context_message (GstMessage * msg)
{
const gchar *type = NULL;
g_return_val_if_fail (GST_IS_MESSAGE (msg), FALSE);
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_NEED_CONTEXT &&
gst_message_parse_context_type (msg, &type)) {
return !g_strcmp0 (type, GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE);
}
return FALSE;
}
GstContext *
gst_wayland_display_handle_context_new (struct wl_display * display)
{
GstContext *context =
gst_context_new (GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE, TRUE);
gst_structure_set (gst_context_writable_structure (context),
"handle", G_TYPE_POINTER, display, NULL);
return context;
}
struct wl_display *
gst_wayland_display_handle_context_get_handle (GstContext * context)
{
const GstStructure *s;
struct wl_display *display;
g_return_val_if_fail (GST_IS_CONTEXT (context), NULL);
s = gst_context_get_structure (context);
gst_structure_get (s, "handle", G_TYPE_POINTER, &display, NULL);
return display;
}
G_DEFINE_INTERFACE (GstWaylandVideo, gst_wayland_video, GST_TYPE_VIDEO_OVERLAY);
static void

View file

@ -30,6 +30,13 @@ G_BEGIN_DECLS
* from the application to the sink */
#define GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE "GstWaylandDisplayHandleContextType"
gboolean gst_is_wayland_display_handle_need_context_message (GstMessage * msg);
GstContext *
gst_wayland_display_handle_context_new (struct wl_display * display);
struct wl_display *
gst_wayland_display_handle_context_get_handle (GstContext * context);
#define GST_TYPE_WAYLAND_VIDEO \
(gst_wayland_video_get_type ())
#define GST_WAYLAND_VIDEO(obj) \