mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
Update with new APIs in wayland-client.
This commit is contained in:
parent
b5a7780122
commit
775643d60e
2 changed files with 18 additions and 48 deletions
|
@ -103,13 +103,10 @@ static void
|
||||||
gst_wayland_buffer_destroy (GstWaylandSink * sink, GstWlBuffer * buffer);
|
gst_wayland_buffer_destroy (GstWaylandSink * sink, GstWlBuffer * buffer);
|
||||||
|
|
||||||
static int event_mask_update (uint32_t mask, void *data);
|
static int event_mask_update (uint32_t mask, void *data);
|
||||||
static void sync_callback (void *data);
|
|
||||||
static struct display *create_display (void);
|
static struct display *create_display (void);
|
||||||
static void display_handle_global (struct wl_display *display, uint32_t id,
|
static void display_handle_global (struct wl_display *display, uint32_t id,
|
||||||
const char *interface, uint32_t version, void *data);
|
const char *interface, uint32_t version, void *data);
|
||||||
static void compositor_handle_visual (void *data,
|
static void redraw (void *data, struct wl_callback *callback, uint32_t time);
|
||||||
struct wl_compositor *compositor, uint32_t id, uint32_t token);
|
|
||||||
static void redraw (struct wl_surface *surface, void *data, uint32_t time);
|
|
||||||
static struct window *create_window (GstWaylandSink * sink,
|
static struct window *create_window (GstWaylandSink * sink,
|
||||||
struct display *display, int width, int height);
|
struct display *display, int width, int height);
|
||||||
|
|
||||||
|
@ -199,11 +196,9 @@ static void
|
||||||
gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
|
gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
|
||||||
GstBaseSinkClass *gstbasesink_class;
|
GstBaseSinkClass *gstbasesink_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
gstelement_class = (GstElementClass *) klass;
|
|
||||||
gstbasesink_class = (GstBaseSinkClass *) klass;
|
gstbasesink_class = (GstBaseSinkClass *) klass;
|
||||||
|
|
||||||
gobject_class->set_property = gst_wayland_sink_set_property;
|
gobject_class->set_property = gst_wayland_sink_set_property;
|
||||||
|
@ -322,18 +317,6 @@ event_mask_update (uint32_t mask, void *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
sync_callback (void *data)
|
|
||||||
{
|
|
||||||
int *done = data;
|
|
||||||
|
|
||||||
*done = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct wl_compositor_listener compositor_listener = {
|
|
||||||
compositor_handle_visual,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_handle_global (struct wl_display *display, uint32_t id,
|
display_handle_global (struct wl_display *display, uint32_t id,
|
||||||
const char *interface, uint32_t version, void *data)
|
const char *interface, uint32_t version, void *data)
|
||||||
|
@ -341,12 +324,11 @@ display_handle_global (struct wl_display *display, uint32_t id,
|
||||||
struct display *d = data;
|
struct display *d = data;
|
||||||
|
|
||||||
if (strcmp (interface, "wl_compositor") == 0) {
|
if (strcmp (interface, "wl_compositor") == 0) {
|
||||||
d->compositor = wl_compositor_create (display, id, 1);
|
d->compositor = wl_display_bind (display, id, &wl_compositor_interface);
|
||||||
wl_compositor_add_listener (d->compositor, &compositor_listener, d);
|
|
||||||
} else if (strcmp (interface, "wl_shell") == 0) {
|
} else if (strcmp (interface, "wl_shell") == 0) {
|
||||||
d->shell = wl_shell_create (display, id, 1);
|
d->shell = wl_display_bind (display, id, &wl_shell_interface);
|
||||||
} else if (strcmp (interface, "wl_shm") == 0) {
|
} else if (strcmp (interface, "wl_shm") == 0) {
|
||||||
d->shm = wl_shm_create (display, id, 1);
|
d->shm = wl_display_bind (display, id, &wl_shm_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -355,10 +337,10 @@ static struct display *
|
||||||
create_display (void)
|
create_display (void)
|
||||||
{
|
{
|
||||||
struct display *display;
|
struct display *display;
|
||||||
int done;
|
|
||||||
|
|
||||||
display = malloc (sizeof *display);
|
display = malloc (sizeof *display);
|
||||||
display->display = wl_display_connect (NULL);
|
display->display = wl_display_connect (NULL);
|
||||||
|
assert (display->display);
|
||||||
|
|
||||||
wl_display_add_global_listener (display->display,
|
wl_display_add_global_listener (display->display,
|
||||||
display_handle_global, display);
|
display_handle_global, display);
|
||||||
|
@ -367,12 +349,6 @@ create_display (void)
|
||||||
|
|
||||||
wl_display_get_fd (display->display, event_mask_update, display);
|
wl_display_get_fd (display->display, event_mask_update, display);
|
||||||
|
|
||||||
wl_display_sync_callback (display->display, sync_callback, &done);
|
|
||||||
|
|
||||||
while (!display->xrgb_visual) {
|
|
||||||
wl_display_iterate (display->display, display->mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,8 +397,7 @@ wayland_buffer_create (GstWaylandSink * sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
wbuffer->wbuffer = wl_shm_create_buffer (sink->display->shm, fd,
|
wbuffer->wbuffer = wl_shm_create_buffer (sink->display->shm, fd,
|
||||||
sink->video_width, sink->video_height, stride,
|
sink->video_width, sink->video_height, stride, WL_SHM_FORMAT_XRGB32);
|
||||||
sink->display->xrgb_visual);
|
|
||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
|
@ -547,21 +522,10 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static const struct wl_callback_listener frame_listener;
|
||||||
compositor_handle_visual (void *data,
|
|
||||||
struct wl_compositor *compositor, uint32_t id, uint32_t token)
|
|
||||||
{
|
|
||||||
struct display *d = data;
|
|
||||||
|
|
||||||
switch (token) {
|
|
||||||
case WL_COMPOSITOR_VISUAL_XRGB32:
|
|
||||||
d->xrgb_visual = wl_visual_create (d->display, id, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
redraw (struct wl_surface *surface, void *data, uint32_t time)
|
redraw (void *data, struct wl_callback *callback, uint32_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
GstWaylandSink *sink = (GstWaylandSink *) data;
|
GstWaylandSink *sink = (GstWaylandSink *) data;
|
||||||
|
@ -627,6 +591,7 @@ gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer)
|
||||||
return gst_wayland_sink_render (bsink, buffer);
|
return gst_wayland_sink_render (bsink, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
|
@ -692,20 +657,25 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
||||||
|
|
||||||
wl_surface_damage (sink->window->surface, 0, 0, res.w, res.h);
|
wl_surface_damage (sink->window->surface, 0, 0, res.w, res.h);
|
||||||
|
|
||||||
wl_display_frame_callback (sink->display->display,
|
if (sink->callback)
|
||||||
sink->window->surface, redraw, sink);
|
wl_callback_destroy (sink->callback);
|
||||||
|
|
||||||
|
sink->callback = wl_surface_frame (sink->window->surface);
|
||||||
|
wl_callback_add_listener (sink->callback, &frame_listener, sink);
|
||||||
wl_display_iterate (sink->display->display, sink->display->mask);
|
wl_display_iterate (sink->display->display, sink->display->mask);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GST_LOG_OBJECT (sink,
|
GST_LOG_OBJECT (sink,
|
||||||
"Waiting to get the signal from compositor to render the next frame..");
|
"Waiting to get the signal from compositor to render the next frame..");
|
||||||
g_usleep (50000);
|
|
||||||
sink->render_finish = TRUE;
|
sink->render_finish = TRUE;
|
||||||
}
|
}
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct wl_callback_listener frame_listener = {
|
||||||
|
redraw
|
||||||
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
struct display
|
struct display
|
||||||
{
|
{
|
||||||
struct wl_display *display;
|
struct wl_display *display;
|
||||||
struct wl_visual *xrgb_visual;
|
|
||||||
struct wl_compositor *compositor;
|
struct wl_compositor *compositor;
|
||||||
struct wl_shell *shell;
|
struct wl_shell *shell;
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
|
@ -84,6 +83,7 @@ struct _GstWaylandSink
|
||||||
|
|
||||||
struct display *display;
|
struct display *display;
|
||||||
struct window *window;
|
struct window *window;
|
||||||
|
struct wl_callback *callback;
|
||||||
|
|
||||||
GMutex *pool_lock;
|
GMutex *pool_lock;
|
||||||
GSList *buffer_pool;
|
GSList *buffer_pool;
|
||||||
|
|
Loading…
Reference in a new issue