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
{
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
}
}
+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)
{
return 0;
}
+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)
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);
}
}
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);
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) {
}
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);
{
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);
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;
}
if (!sink->display)
sink->display = create_display ();
- if (!sink->window)
- sink->window = create_window (sink, sink->display, 1280, 720);
return result;
}
"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;
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;
}