summaryrefslogtreecommitdiff
path: root/ext/wayland
diff options
context:
space:
mode:
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>2012-02-16 22:27:23 +0200
committerStefan Sauer <ensonic@users.sf.net>2012-03-04 20:21:37 +0100
commit2747aefaf7607fe2dbac0c858077405b533ca7c8 (patch)
tree9ca0c8662f9d48194fb8836495e718cbaa8d2daa /ext/wayland
parent775643d60ea67c43895ca778bd1dbb8506d30722 (diff)
downloadgstreamer-plugins-bad-2747aefaf7607fe2dbac0c858077405b533ca7c8.tar.gz
waylandsink: More fixes -- update to Wayland 0.85 protocol -- Added shell surface -- Added format query for shm format -- Create the window based on width and height of video extracted from upstream caps.
Diffstat (limited to 'ext/wayland')
-rw-r--r--[-rwxr-xr-x]ext/wayland/gstwaylandsink.c85
-rw-r--r--[-rwxr-xr-x]ext/wayland/gstwaylandsink.h2
2 files changed, 67 insertions, 20 deletions
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
index 6a7218ae4..a073bf035 100755..100644
--- a/ext/wayland/gstwaylandsink.c
+++ b/ext/wayland/gstwaylandsink.c
@@ -107,7 +107,7 @@ static struct display *create_display (void);
static void display_handle_global (struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data);
static void redraw (void *data, struct wl_callback *callback, uint32_t time);
-static struct window *create_window (GstWaylandSink * sink,
+static void create_window (GstWaylandSink * sink,
struct display *display, int width, int height);
static void
@@ -229,12 +229,14 @@ gst_wayland_sink_init (GstWaylandSink * sink,
{
sink->caps = NULL;
+ sink->render_finish = TRUE;
+ sink->display = NULL;
+ sink->window = NULL;
sink->pool_lock = g_mutex_new ();
sink->buffer_pool = NULL;
sink->wayland_lock = g_mutex_new ();
-
}
static void
@@ -270,6 +272,31 @@ gst_wayland_sink_set_property (GObject * object,
}
static void
+destroy_display (struct display *display)
+{
+ if (display->shm)
+ wl_shm_destroy (display->shm);
+
+ if (display->shell)
+ wl_shell_destroy (display->shell);
+
+ if (display->compositor)
+ wl_compositor_destroy (display->compositor);
+
+ wl_display_flush (display->display);
+ wl_display_destroy (display->display);
+ free (display);
+}
+
+static void
+destroy_window (struct window *window)
+{
+ wl_shell_surface_destroy (window->shell_surface);
+ wl_surface_destroy (window->surface);
+ free (window);
+}
+
+static void
gst_wayland_sink_dispose (GObject * object)
{
G_OBJECT_CLASS (parent_class)->dispose (object);
@@ -318,6 +345,18 @@ event_mask_update (uint32_t mask, void *data)
}
static void
+shm_format (void *data, struct wl_shm *wl_shm, uint32_t format)
+{
+ struct display *d = data;
+
+ d->formats |= (1 << format);
+}
+
+struct wl_shm_listener shm_listenter = {
+ shm_format
+};
+
+static void
display_handle_global (struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
@@ -329,6 +368,7 @@ display_handle_global (struct wl_display *display, uint32_t id,
d->shell = wl_display_bind (display, id, &wl_shell_interface);
} else if (strcmp (interface, "wl_shm") == 0) {
d->shm = wl_display_bind (display, id, &wl_shm_interface);
+ wl_shm_add_listener (d->shm, &shm_listenter, d);
}
}
@@ -346,6 +386,12 @@ create_display (void)
display_handle_global, display);
wl_display_iterate (display->display, WL_DISPLAY_READABLE);
+ wl_display_roundtrip (display->display);
+
+ if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB8888))) {
+ GST_ERROR ("WL_SHM_FORMAT_XRGB32 not available");
+ return NULL;
+ }
wl_display_get_fd (display->display, event_mask_update, display);
@@ -366,12 +412,7 @@ wayland_buffer_create (GstWaylandSink * sink)
wbuffer = (GstWlBuffer *) gst_mini_object_new (GST_TYPE_WLBUFFER);
wbuffer->wlsink = gst_object_ref (sink);
- if (!init) {
- wl_display_iterate (sink->display->display, sink->display->mask);
- init++;
- }
-
- snprintf (filename, 256, "%s-%d-%s", "/tmp/wayland-shm", init, "XXXXXX");
+ snprintf (filename, 256, "%s-%d-%s", "/tmp/wayland-shm", init++, "XXXXXX");
fd = mkstemp (filename);
if (fd < 0) {
@@ -397,7 +438,7 @@ wayland_buffer_create (GstWaylandSink * sink)
}
wbuffer->wbuffer = wl_shm_create_buffer (sink->display->shm, fd,
- sink->video_width, sink->video_height, stride, WL_SHM_FORMAT_XRGB32);
+ sink->video_width, sink->video_height, stride, WL_SHM_FORMAT_XRGB8888);
close (fd);
@@ -529,19 +570,19 @@ redraw (void *data, struct wl_callback *callback, uint32_t time)
{
GstWaylandSink *sink = (GstWaylandSink *) data;
- g_mutex_lock (sink->wayland_lock);
sink->render_finish = TRUE;
-
- g_mutex_unlock (sink->wayland_lock);
}
-static struct window *
+static void
create_window (GstWaylandSink * sink, struct display *display, int width,
int height)
{
struct window *window;
+ if (sink->window)
+ return;
+
g_mutex_lock (sink->wayland_lock);
window = malloc (sizeof *window);
@@ -550,10 +591,14 @@ create_window (GstWaylandSink * sink, struct display *display, int width,
window->height = height;
window->surface = wl_compositor_create_surface (display->compositor);
- //wl_shell_set_toplevel (display->shell, window->surface);
+ window->shell_surface = wl_shell_get_shell_surface (display->shell,
+ window->surface);
+// wl_shell_surface_set_toplevel (window->shell_surface);
+ wl_shell_surface_set_fullscreen (window->shell_surface);
+
+ sink->window = window;
g_mutex_unlock (sink->wayland_lock);
- return window;
}
@@ -567,8 +612,6 @@ gst_wayland_sink_start (GstBaseSink * bsink)
if (!sink->display)
sink->display = create_display ();
- if (!sink->window)
- sink->window = create_window (sink, sink->display, 1280, 720);
return result;
}
@@ -603,6 +646,9 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
"render buffer %p, data = %p, timestamp = %" GST_TIME_FORMAT, buffer,
GST_BUFFER_DATA (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+ if (!sink->window)
+ create_window (sink, sink->display, sink->video_width, sink->video_height);
+
if (sink->render_finish) {
if (GST_IS_WLBUFFER (buffer)) {
GstWlBuffer *tmp_buffer = (GstWlBuffer *) buffer;
@@ -664,11 +710,10 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
wl_callback_add_listener (sink->callback, &frame_listener, sink);
wl_display_iterate (sink->display->display, sink->display->mask);
- } else {
+ } else
GST_LOG_OBJECT (sink,
"Waiting to get the signal from compositor to render the next frame..");
- sink->render_finish = TRUE;
- }
+
return GST_FLOW_OK;
}
diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h
index 678b8cfa2..56fffd823 100755..100644
--- a/ext/wayland/gstwaylandsink.h
+++ b/ext/wayland/gstwaylandsink.h
@@ -46,6 +46,7 @@ struct display
struct wl_compositor *compositor;
struct wl_shell *shell;
struct wl_shm *shm;
+ uint32_t formats;
uint32_t mask;
};
@@ -54,6 +55,7 @@ struct window
struct display *display;
int width, height;
struct wl_surface *surface;
+ struct wl_shell_surface *shell_surface;
struct wl_buffer *buffer;
};