Add skeleton code for ds_tizen_video 50/283250/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 13 Sep 2022 06:19:25 +0000 (15:19 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 21 Oct 2022 02:27:55 +0000 (11:27 +0900)
Change-Id: Id499c27336f7e4f774893444b9988d8367156148

include/libds-tizen/video.h [new file with mode: 0644]
packaging/libds-tizen.spec
src/meson.build
src/video/meson.build [new file with mode: 0644]
src/video/video.c [new file with mode: 0644]

diff --git a/include/libds-tizen/video.h b/include/libds-tizen/video.h
new file mode 100644 (file)
index 0000000..36115c5
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef LIBDS_TIZEN_VIDEO_H
+#define LIBDS_TIZEN_VIDEO_H
+
+#include <wayland-server.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ds_tizen_video;
+
+struct ds_tizen_video *ds_tizen_video_create(struct wl_display *display);
+
+void ds_tizen_video_add_destroy_listener(struct ds_tizen_video *video,
+        struct wl_listener *listener);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 777384b..27104b4 100644 (file)
@@ -359,6 +359,21 @@ Group:   Development/Libraries
 %description scaler-devel
 Development package for tizen scaler
 
+## libds-tizen-video
+%package video
+Summary: Library for tizen video
+Group:   Development/Libraries
+
+%description video
+Library for tizen video
+
+%package video-devel
+Summary: Development package for tizen video
+Group:   Development/Libraries
+
+%description video-devel
+Development package for tizen video
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -693,3 +708,17 @@ ninja -C builddir install
 %{_libdir}/pkgconfig/libds-tizen-scaler.pc
 %{_libdir}/libds-tizen-scaler.so
 %{_bindir}/libds-tizen-scaler-tests
+
+%files video
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license LICENSE
+%{_libdir}/libds-tizen-video.so.*
+
+%files video-devel
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license LICENSE
+%{_includedir}/libds-tizen/video.h
+%{_libdir}/pkgconfig/libds-tizen-video.pc
+%{_libdir}/libds-tizen-video.so
index b039f9d..f067865 100644 (file)
@@ -48,3 +48,4 @@ subdir('hwc')
 subdir('policy')
 subdir('screenshooter')
 subdir('scaler')
+subdir('video')
diff --git a/src/video/meson.build b/src/video/meson.build
new file mode 100644 (file)
index 0000000..7da8776
--- /dev/null
@@ -0,0 +1,29 @@
+libds_tizen_video_files = [
+  'video.c',
+]
+
+libds_tizen_video_deps = [
+  deps_libds_tizen,
+  dependency('tizen-extension-server', required: true),
+]
+
+lib_libds_tizen_video = shared_library('ds-tizen-video', libds_tizen_video_files,
+  dependencies: libds_tizen_video_deps,
+  include_directories: [ common_inc, include_directories('.'), include_directories('..') ],
+  version: meson.project_version(),
+  install: true
+)
+
+deps_libds_tizen_video = declare_dependency(
+  link_with: lib_libds_tizen_video,
+  dependencies: libds_tizen_video_deps,
+  include_directories: [ common_inc, include_directories('.') ],
+)
+
+pkgconfig = import('pkgconfig')
+pkgconfig.generate(lib_libds_tizen_video,
+  version: meson.project_version(),
+  filebase: 'libds-tizen-video',
+  name: 'libds-tizen-video',
+  description: 'tizen video extension of libds-tizen for tizen platform',
+)
diff --git a/src/video/video.c b/src/video/video.c
new file mode 100644 (file)
index 0000000..b9a0557
--- /dev/null
@@ -0,0 +1,113 @@
+#include <stdlib.h>
+#include <wayland-server.h>
+#include <tizen-extension-server-protocol.h>
+#include <libds/log.h>
+
+#define TIZEN_VIDEO_VERSION 1
+
+struct ds_tizen_video
+{
+    struct wl_global *global;
+
+    struct wl_listener display_destroy;
+
+    struct {
+        struct wl_signal destroy;
+    } events;
+};
+
+static void video_handle_display_destroy(struct wl_listener *listener,
+        void *data);
+static void video_bind(struct wl_client *client, void *data, uint32_t version,
+        uint32_t id);
+
+WL_EXPORT struct ds_tizen_video *
+ds_tizen_video_create(struct wl_display *display)
+{
+    struct ds_tizen_video *video;
+
+    video = calloc(1, sizeof *video);
+    if (!video)
+        return NULL;
+
+    video->global = wl_global_create(display, &tizen_video_interface,
+            TIZEN_VIDEO_VERSION, video, video_bind);
+    if (!video->global) {
+        ds_log_errno(DS_ERR, "Could not create tizen_video global");
+        free(video);
+        return NULL;
+    }
+
+    wl_signal_init(&video->events.destroy);
+
+    video->display_destroy.notify = video_handle_display_destroy;
+    wl_display_add_destroy_listener(display, &video->display_destroy);
+
+    ds_inf("Create ds_tizen_video(%p)", video);
+
+    return video;
+}
+
+WL_EXPORT void
+ds_tizen_video_add_destroy_listener(struct ds_tizen_video *video,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&video->events.destroy, listener);
+}
+
+static void
+video_handle_display_destroy(struct wl_listener *listener, void *data)
+{
+    struct ds_tizen_video *video;
+
+    video = wl_container_of(listener, video, display_destroy);
+
+    ds_inf("Destroy ds_tizen_video(%p)", video);
+
+    wl_signal_emit(&video->events.destroy, video);
+
+    wl_list_remove(&video->display_destroy.link);
+    wl_global_destroy(video->global);
+    free(video);
+}
+
+static void
+video_handle_get_object(struct wl_client *client, struct wl_resource *resource,
+        uint32_t id, struct wl_resource *surface_resource)
+{
+
+}
+
+static void
+video_handle_get_viewport(struct wl_client *client,
+        struct wl_resource *resource, uint32_t id,
+        struct wl_resource *surface_resource)
+{
+
+}
+
+static void
+video_handle_destroy(struct wl_client *client, struct wl_resource *resource)
+{
+    wl_resource_destroy(resource);
+}
+
+static const struct tizen_video_interface video_impl = {
+    .get_object = video_handle_get_object,
+    .get_viewport = video_handle_get_viewport,
+    .destroy = video_handle_destroy,
+};
+
+static void
+video_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+{
+    struct ds_tizen_video *video = data;
+    struct wl_resource *resource;
+
+    resource = wl_resource_create(client, &tizen_video_interface, version, id);
+    if (!resource) {
+        wl_client_post_no_memory(client);
+        return;
+    }
+    wl_resource_set_implementation(resource, &video_impl, video, NULL);
+}