#include <stdlib.h>
+#include <tbm_type.h>
#include <wayland-server.h>
#include <tizen-extension-server-protocol.h>
#include <libds/log.h>
+#include "shared/pixel_format.h"
+
#define TIZEN_VIDEO_VERSION 1
struct ds_tizen_video
{
struct wl_global *global;
+ struct wl_list resources;
+ struct wl_array formats;
struct wl_listener display_destroy;
void *data);
static void video_bind(struct wl_client *client, void *data, uint32_t version,
uint32_t id);
+static void video_send_format(struct ds_tizen_video *video,
+ tbm_format format);
+static void video_resource_send_formats(struct wl_resource *resource,
+ struct wl_array *formats);
WL_EXPORT struct ds_tizen_video *
ds_tizen_video_create(struct wl_display *display)
return NULL;
}
+ wl_list_init(&video->resources);
+ wl_array_init(&video->formats);
+
wl_signal_init(&video->events.destroy);
video->display_destroy.notify = video_handle_display_destroy;
}
WL_EXPORT void
+ds_tizen_video_add_format(struct ds_tizen_video *video, uint32_t format)
+{
+ tbm_format *p;
+
+ p = wl_array_add(&video->formats, sizeof *p);
+ if (!p) {
+ ds_err("Failed wl_array_add()");
+ return;
+ }
+
+ *p = convert_drm_format_to_tbm(format);
+
+ video_send_format(video, *p);
+}
+
+WL_EXPORT void
ds_tizen_video_add_destroy_listener(struct ds_tizen_video *video,
struct wl_listener *listener)
{
wl_signal_emit(&video->events.destroy, video);
+ wl_array_release(&video->formats);
+
wl_list_remove(&video->display_destroy.link);
wl_global_destroy(video->global);
free(video);
};
static void
+video_handle_resource_destroy(struct wl_resource *resource)
+{
+ wl_list_remove(wl_resource_get_link(resource));
+}
+
+static void
video_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
{
struct ds_tizen_video *video = data;
wl_client_post_no_memory(client);
return;
}
- wl_resource_set_implementation(resource, &video_impl, video, NULL);
+ wl_resource_set_implementation(resource, &video_impl, video,
+ video_handle_resource_destroy);
+
+ video_resource_send_formats(resource, &video->formats);
+
+ wl_list_insert(&video->resources, wl_resource_get_link(resource));
+}
+
+static void
+video_send_format(struct ds_tizen_video *video, tbm_format format)
+{
+ struct wl_resource *resource;
+
+ wl_resource_for_each(resource, &video->resources)
+ tizen_video_send_format(resource, format);
+}
+
+static void
+video_resource_send_formats(struct wl_resource *resource,
+ struct wl_array *formats)
+{
+ tbm_format *p;
+
+ wl_array_for_each(p, formats)
+ tizen_video_send_format(resource, *p);
}