[Waylandsink] 1. Apply tizen_buffer_pool 80/40480/4 accepted/tizen/common/20150605.124505 accepted/tizen/mobile/20150606.053042 accepted/tizen/tv/20150606.053747 accepted/tizen/wearable/20150606.054601 submit/tizen/20150605.043418
authorHyunil Park <hyunil46.park@samsung.com>
Thu, 4 Jun 2015 07:47:02 +0000 (16:47 +0900)
committerHyunil Park <hyunil46.park@samsung.com>
Fri, 5 Jun 2015 02:21:03 +0000 (11:21 +0900)
              2. S/W Codec can acquire wl_buffer from tizen_buffer_pool.

Change-Id: I38d765ae8a11da11137d73dda97c0b5f0db72bf5
Signed-off-by: Hyunil Park <hyunil46.park@samsung.com>
20 files changed:
configure.ac
ext/wayland/Makefile.am
ext/wayland/gstwaylandsink.c
ext/wayland/gstwaylandsink.h
ext/wayland/protocol/tizen-buffer-pool.xml [new file with mode: 0755]
ext/wayland/protocol/tizen-bufferpoolprotocol.c [new file with mode: 0755]
ext/wayland/protocol/tizen-bufferpoolprotocol.h [new file with mode: 0755]
ext/wayland/protocol/tizen-subsurfaceprotocol.c [moved from ext/wayland/tizen-subsurfaceprotocol.c with 100% similarity]
ext/wayland/protocol/tizen-subsurfaceprotocol.h [moved from ext/wayland/tizen-subsurfaceprotocol.h with 100% similarity]
ext/wayland/tizen-wlvideoformat.c [new file with mode: 0755]
ext/wayland/tizen-wlvideoformat.h [new file with mode: 0755]
ext/wayland/waylandpool.c [changed mode: 0644->0755]
ext/wayland/waylandpool.h [changed mode: 0644->0755]
ext/wayland/wldisplay.c
ext/wayland/wldisplay.h
ext/wayland/wlvideoformat.c [changed mode: 0644->0755]
ext/wayland/wlvideoformat.h [changed mode: 0644->0755]
ext/wayland/wlwindow.c
ext/wayland/wlwindow.h
packaging/gst-plugins-bad.spec

index acc8d82..c275479 100644 (file)
@@ -2000,6 +2000,15 @@ AG_GST_CHECK_FEATURE(WAYLAND, [wayland sink], wayland , [
 ])
 
 AC_PATH_PROG([wayland_scanner], [wayland-scanner])
+if test "x$HAVE_WAYLAND" = "xyes"; then
+PKG_CHECK_MODULES(DRM, libdrm)
+AC_SUBST(DRM_CFLAGS)
+AC_SUBST(DRM_LIBS)
+
+PKG_CHECK_MODULES(TBM, libtbm)
+AC_SUBST(TBM_CFLAGS)
+AC_SUBST(TBM_LIBS)
+fi
 
 dnl **** WebP ****
 translit(dnm, m, l) AM_CONDITIONAL(USE_WEBP, true)
index 6116fff..268f0bd 100644 (file)
@@ -7,14 +7,16 @@ libgstwaylandsink_la_SOURCES =  \
        wlwindow.c \
        wlvideoformat.c \
        scaler-protocol.c \
-       tizen-subsurfaceprotocol.c
+       tizen-wlvideoformat.c \
+       protocol/tizen-subsurfaceprotocol.c \
+       protocol/tizen-bufferpoolprotocol.c
 
 libgstwaylandsink_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
-                               $(WAYLAND_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS)
+                               $(WAYLAND_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(DRM_CFLAGS) $(TBM_CFLAGS)
 libgstwaylandsink_la_LIBADD = \
        $(GST_PLUGINS_BASE_LIBS) \
        -lgstvideo-$(GST_API_VERSION) \
-       $(WAYLAND_LIBS) \
+       $(WAYLAND_LIBS) $(DRM_LIBS) $(TBM_LIBS)\
        $(top_builddir)/gst-libs/gst/wayland/libgstwayland-$(GST_API_VERSION).la
 libgstwaylandsink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstwaylandsink_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
@@ -26,7 +28,9 @@ noinst_HEADERS = \
        wlwindow.h \
        wlvideoformat.h \
        scaler-client-protocol.h \
-       tizen-subsurfaceprotocol.h
+       tizen-wlvideoformat.h \
+       protocol/tizen-subsurfaceprotocol.h \
+       protocol/tizen-bufferpoolprotocol.h
 
 EXTRA_DIST = scaler.xml
 CLEANFILES = scaler-protocol.c scaler-client-protocol.h
index a572eca..36c66ff 100755 (executable)
 #endif
 
 #include "gstwaylandsink.h"
+#ifdef GST_WLSINK_ENHANCEMENT
+#include "tizen-wlvideoformat.h"
+#else
 #include "wlvideoformat.h"
+#endif
 #include "waylandpool.h"
 
 #include <gst/wayland/wayland.h>
@@ -441,7 +445,11 @@ gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
     GValue value = G_VALUE_INIT;
     GArray *formats;
     gint i;
+#ifdef GST_WLSINK_ENHANCEMENT
+    enum tizen_buffer_pool_format fmt;
+#else
     enum wl_shm_format fmt;
+#endif
 
     g_value_init (&list, GST_TYPE_LIST);
     g_value_init (&value, G_TYPE_STRING);
@@ -481,7 +489,11 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
   GstWaylandSink *sink;
   GstBufferPool *newpool;
   GstVideoInfo info;
+#ifdef GST_WLSINK_ENHANCEMENT
+  enum tizen_buffer_pool_format format;
+#else
   enum wl_shm_format format;
+#endif
   GArray *formats;
   gint i;
   GstStructure *structure;
index 5eb56e9..6604a38 100755 (executable)
@@ -43,7 +43,7 @@ G_BEGIN_DECLS
            (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WAYLAND_SINK))
 #define GST_WAYLAND_SINK_GET_CLASS(inst) \
         (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_WAYLAND_SINK, GstWaylandSinkClass))
-#if 0
+#if 1
 #define FUNCTION_ENTER()       GST_INFO("<ENTER>")
 #else
 #define FUNCTION_ENTER()
diff --git a/ext/wayland/protocol/tizen-buffer-pool.xml b/ext/wayland/protocol/tizen-buffer-pool.xml
new file mode 100755 (executable)
index 0000000..aa0ab84
--- /dev/null
@@ -0,0 +1,123 @@
+<protocol name="tizen_buffer_pool">
+    <interface name="tizen_buffer_pool" version="1">
+        <request name="authenticate">
+            <arg name="id" type="uint"/>
+        </request>
+
+        <request name="create_buffer">
+            <arg name="id" type="new_id" interface="wl_buffer"/>
+            <arg name="name" type="uint"/>
+            <arg name="width" type="int"/>
+            <arg name="height" type="int"/>
+            <arg name="stride" type="uint"/>
+            <arg name="format" type="uint"/>
+        </request>
+
+        <request name="create_planar_buffer">
+            <arg name="id" type="new_id" interface="wl_buffer"/>
+            <arg name="width" type="int"/>
+            <arg name="height" type="int"/>
+            <arg name="format" type="uint"/>
+            <arg name="name0" type="uint"/>
+            <arg name="offset0" type="int"/>
+            <arg name="stride0" type="int"/>
+            <arg name="name1" type="uint"/>
+            <arg name="offset1" type="int"/>
+            <arg name="stride1" type="int"/>
+            <arg name="name2" type="uint"/>
+            <arg name="offset2" type="int"/>
+            <arg name="stride2" type="int"/>
+        </request>
+
+        <event name="device">
+            <arg name="name" type="string"/>
+        </event>
+
+        <event name="authenticated"/>
+
+        <event name="capabilities">
+            <arg name="value" type="uint"/>
+        </event>
+
+        <event name="format">
+            <arg name="format" type="uint"/>
+        </event>
+
+        <enum name="error">
+            <entry name="invalid_format" value="0"/>
+            <entry name="invalid_name" value="1"/>
+        </enum>
+
+        <enum name="capability">
+            <entry name="default" value="0"/>
+            <entry name="video" value="0x1"/>
+            <entry name="screenmirror" value="0x2"/>
+        </enum>
+
+        <enum name="format">
+            <entry name="c8" value="0x20203843"/>
+            <entry name="rgb332" value="0x38424752"/>
+            <entry name="bgr233" value="0x38524742"/>
+            <entry name="xrgb4444" value="0x32315258"/>
+            <entry name="xbgr4444" value="0x32314258"/>
+            <entry name="rgbx4444" value="0x32315852"/>
+            <entry name="bgrx4444" value="0x32315842"/>
+            <entry name="argb4444" value="0x32315241"/>
+            <entry name="abgr4444" value="0x32314241"/>
+            <entry name="rgba4444" value="0x32314152"/>
+            <entry name="bgra4444" value="0x32314142"/>
+            <entry name="xrgb1555" value="0x35315258"/>
+            <entry name="xbgr1555" value="0x35314258"/>
+            <entry name="rgbx5551" value="0x35315852"/>
+            <entry name="bgrx5551" value="0x35315842"/>
+            <entry name="argb1555" value="0x35315241"/>
+            <entry name="abgr1555" value="0x35314241"/>
+            <entry name="rgba5551" value="0x35314152"/>
+            <entry name="bgra5551" value="0x35314142"/>
+            <entry name="rgb565" value="0x36314752"/>
+            <entry name="bgr565" value="0x36314742"/>
+            <entry name="rgb888" value="0x34324752"/>
+            <entry name="bgr888" value="0x34324742"/>
+            <entry name="xrgb8888" value="0x34325258"/>
+            <entry name="xbgr8888" value="0x34324258"/>
+            <entry name="rgbx8888" value="0x34325852"/>
+            <entry name="bgrx8888" value="0x34325842"/>
+            <entry name="argb8888" value="0x34325241"/>
+            <entry name="abgr8888" value="0x34324241"/>
+            <entry name="rgba8888" value="0x34324152"/>
+            <entry name="bgra8888" value="0x34324142"/>
+            <entry name="xrgb2101010" value="0x30335258"/>
+            <entry name="xbgr2101010" value="0x30334258"/>
+            <entry name="rgbx1010102" value="0x30335852"/>
+            <entry name="bgrx1010102" value="0x30335842"/>
+            <entry name="argb2101010" value="0x30335241"/>
+            <entry name="abgr2101010" value="0x30334241"/>
+            <entry name="rgba1010102" value="0x30334152"/>
+            <entry name="bgra1010102" value="0x30334142"/>
+            <entry name="yuyv" value="0x56595559"/>
+            <entry name="yvyu" value="0x55595659"/>
+            <entry name="uyvy" value="0x59565955"/>
+            <entry name="vyuy" value="0x59555956"/>
+            <entry name="ayuv" value="0x56555941"/>
+            <entry name="nv12" value="0x3231564e"/>
+            <entry name="nv21" value="0x3132564e"/>
+            <entry name="nv16" value="0x3631564e"/>
+            <entry name="nv61" value="0x3136564e"/>
+            <entry name="yuv410" value="0x39565559"/>
+            <entry name="yvu410" value="0x39555659"/>
+            <entry name="yuv411" value="0x31315559"/>
+            <entry name="yvu411" value="0x31315659"/>
+            <entry name="yuv420" value="0x32315559"/>
+            <entry name="yvu420" value="0x32315659"/>
+            <entry name="yuv422" value="0x36315559"/>
+            <entry name="yvu422" value="0x36315659"/>
+            <entry name="yuv444" value="0x34325559"/>
+            <entry name="yvu444" value="0x34325659"/>
+
+            <!-- specail format for samsung exynos(nv12t) -->
+            <entry name="st12" value="0x32315453"/>
+            <entry name="sn12" value="0x32314e53"/>
+        </enum>
+
+    </interface>
+</protocol>
diff --git a/ext/wayland/protocol/tizen-bufferpoolprotocol.c b/ext/wayland/protocol/tizen-bufferpoolprotocol.c
new file mode 100755 (executable)
index 0000000..560fe8d
--- /dev/null
@@ -0,0 +1,48 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface wl_buffer_interface;
+
+static const struct wl_interface *types[] = {
+       NULL,
+       &wl_buffer_interface,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       &wl_buffer_interface,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+};
+
+static const struct wl_message tizen_buffer_pool_requests[] = {
+       { "authenticate", "u", types + 0 },
+       { "create_buffer", "nuiiuu", types + 1 },
+       { "create_planar_buffer", "niiuuiiuiiuii", types + 7 },
+};
+
+static const struct wl_message tizen_buffer_pool_events[] = {
+       { "device", "s", types + 0 },
+       { "authenticated", "", types + 0 },
+       { "capabilities", "u", types + 0 },
+       { "format", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface tizen_buffer_pool_interface = {
+       "tizen_buffer_pool", 1,
+       3, tizen_buffer_pool_requests,
+       4, tizen_buffer_pool_events,
+};
+
diff --git a/ext/wayland/protocol/tizen-bufferpoolprotocol.h b/ext/wayland/protocol/tizen-bufferpoolprotocol.h
new file mode 100755 (executable)
index 0000000..781d0a8
--- /dev/null
@@ -0,0 +1,194 @@
+#ifndef TIZEN_BUFFER_POOL_CLIENT_PROTOCOL_H
+#define TIZEN_BUFFER_POOL_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct tizen_buffer_pool;
+
+extern const struct wl_interface tizen_buffer_pool_interface;
+
+#ifndef TIZEN_BUFFER_POOL_ERROR_ENUM
+#define TIZEN_BUFFER_POOL_ERROR_ENUM
+enum tizen_buffer_pool_error {
+       TIZEN_BUFFER_POOL_ERROR_INVALID_FORMAT = 0,
+       TIZEN_BUFFER_POOL_ERROR_INVALID_NAME = 1,
+};
+#endif /* TIZEN_BUFFER_POOL_ERROR_ENUM */
+
+#ifndef TIZEN_BUFFER_POOL_CAPABILITY_ENUM
+#define TIZEN_BUFFER_POOL_CAPABILITY_ENUM
+enum tizen_buffer_pool_capability {
+       TIZEN_BUFFER_POOL_CAPABILITY_DEFAULT = 0,
+       TIZEN_BUFFER_POOL_CAPABILITY_VIDEO = 0x1,
+       TIZEN_BUFFER_POOL_CAPABILITY_SCREENMIRROR = 0x2,
+};
+#endif /* TIZEN_BUFFER_POOL_CAPABILITY_ENUM */
+
+#ifndef TIZEN_BUFFER_POOL_FORMAT_ENUM
+#define TIZEN_BUFFER_POOL_FORMAT_ENUM
+enum tizen_buffer_pool_format {
+       TIZEN_BUFFER_POOL_FORMAT_C8 = 0x20203843,
+       TIZEN_BUFFER_POOL_FORMAT_RGB332 = 0x38424752,
+       TIZEN_BUFFER_POOL_FORMAT_BGR233 = 0x38524742,
+       TIZEN_BUFFER_POOL_FORMAT_XRGB4444 = 0x32315258,
+       TIZEN_BUFFER_POOL_FORMAT_XBGR4444 = 0x32314258,
+       TIZEN_BUFFER_POOL_FORMAT_RGBX4444 = 0x32315852,
+       TIZEN_BUFFER_POOL_FORMAT_BGRX4444 = 0x32315842,
+       TIZEN_BUFFER_POOL_FORMAT_ARGB4444 = 0x32315241,
+       TIZEN_BUFFER_POOL_FORMAT_ABGR4444 = 0x32314241,
+       TIZEN_BUFFER_POOL_FORMAT_RGBA4444 = 0x32314152,
+       TIZEN_BUFFER_POOL_FORMAT_BGRA4444 = 0x32314142,
+       TIZEN_BUFFER_POOL_FORMAT_XRGB1555 = 0x35315258,
+       TIZEN_BUFFER_POOL_FORMAT_XBGR1555 = 0x35314258,
+       TIZEN_BUFFER_POOL_FORMAT_RGBX5551 = 0x35315852,
+       TIZEN_BUFFER_POOL_FORMAT_BGRX5551 = 0x35315842,
+       TIZEN_BUFFER_POOL_FORMAT_ARGB1555 = 0x35315241,
+       TIZEN_BUFFER_POOL_FORMAT_ABGR1555 = 0x35314241,
+       TIZEN_BUFFER_POOL_FORMAT_RGBA5551 = 0x35314152,
+       TIZEN_BUFFER_POOL_FORMAT_BGRA5551 = 0x35314142,
+       TIZEN_BUFFER_POOL_FORMAT_RGB565 = 0x36314752,
+       TIZEN_BUFFER_POOL_FORMAT_BGR565 = 0x36314742,
+       TIZEN_BUFFER_POOL_FORMAT_RGB888 = 0x34324752,
+       TIZEN_BUFFER_POOL_FORMAT_BGR888 = 0x34324742,
+       TIZEN_BUFFER_POOL_FORMAT_XRGB8888 = 0x34325258,
+       TIZEN_BUFFER_POOL_FORMAT_XBGR8888 = 0x34324258,
+       TIZEN_BUFFER_POOL_FORMAT_RGBX8888 = 0x34325852,
+       TIZEN_BUFFER_POOL_FORMAT_BGRX8888 = 0x34325842,
+       TIZEN_BUFFER_POOL_FORMAT_ARGB8888 = 0x34325241,
+       TIZEN_BUFFER_POOL_FORMAT_ABGR8888 = 0x34324241,
+       TIZEN_BUFFER_POOL_FORMAT_RGBA8888 = 0x34324152,
+       TIZEN_BUFFER_POOL_FORMAT_BGRA8888 = 0x34324142,
+       TIZEN_BUFFER_POOL_FORMAT_XRGB2101010 = 0x30335258,
+       TIZEN_BUFFER_POOL_FORMAT_XBGR2101010 = 0x30334258,
+       TIZEN_BUFFER_POOL_FORMAT_RGBX1010102 = 0x30335852,
+       TIZEN_BUFFER_POOL_FORMAT_BGRX1010102 = 0x30335842,
+       TIZEN_BUFFER_POOL_FORMAT_ARGB2101010 = 0x30335241,
+       TIZEN_BUFFER_POOL_FORMAT_ABGR2101010 = 0x30334241,
+       TIZEN_BUFFER_POOL_FORMAT_RGBA1010102 = 0x30334152,
+       TIZEN_BUFFER_POOL_FORMAT_BGRA1010102 = 0x30334142,
+       TIZEN_BUFFER_POOL_FORMAT_YUYV = 0x56595559,
+       TIZEN_BUFFER_POOL_FORMAT_YVYU = 0x55595659,
+       TIZEN_BUFFER_POOL_FORMAT_UYVY = 0x59565955,
+       TIZEN_BUFFER_POOL_FORMAT_VYUY = 0x59555956,
+       TIZEN_BUFFER_POOL_FORMAT_AYUV = 0x56555941,
+       TIZEN_BUFFER_POOL_FORMAT_NV12 = 0x3231564e,
+       TIZEN_BUFFER_POOL_FORMAT_NV21 = 0x3132564e,
+       TIZEN_BUFFER_POOL_FORMAT_NV16 = 0x3631564e,
+       TIZEN_BUFFER_POOL_FORMAT_NV61 = 0x3136564e,
+       TIZEN_BUFFER_POOL_FORMAT_YUV410 = 0x39565559,
+       TIZEN_BUFFER_POOL_FORMAT_YVU410 = 0x39555659,
+       TIZEN_BUFFER_POOL_FORMAT_YUV411 = 0x31315559,
+       TIZEN_BUFFER_POOL_FORMAT_YVU411 = 0x31315659,
+       TIZEN_BUFFER_POOL_FORMAT_YUV420 = 0x32315559,
+       TIZEN_BUFFER_POOL_FORMAT_YVU420 = 0x32315659,
+       TIZEN_BUFFER_POOL_FORMAT_YUV422 = 0x36315559,
+       TIZEN_BUFFER_POOL_FORMAT_YVU422 = 0x36315659,
+       TIZEN_BUFFER_POOL_FORMAT_YUV444 = 0x34325559,
+       TIZEN_BUFFER_POOL_FORMAT_YVU444 = 0x34325659,
+       TIZEN_BUFFER_POOL_FORMAT_ST12 = 0x32315453,
+       TIZEN_BUFFER_POOL_FORMAT_SN12 = 0x32314e53,
+};
+#endif /* TIZEN_BUFFER_POOL_FORMAT_ENUM */
+
+struct tizen_buffer_pool_listener {
+       /**
+        * device - (none)
+        * @name: (none)
+        */
+       void (*device)(void *data,
+                      struct tizen_buffer_pool *tizen_buffer_pool,
+                      const char *name);
+       /**
+        * authenticated - (none)
+        */
+       void (*authenticated)(void *data,
+                             struct tizen_buffer_pool *tizen_buffer_pool);
+       /**
+        * capabilities - (none)
+        * @value: (none)
+        */
+       void (*capabilities)(void *data,
+                            struct tizen_buffer_pool *tizen_buffer_pool,
+                            uint32_t value);
+       /**
+        * format - (none)
+        * @format: (none)
+        */
+       void (*format)(void *data,
+                      struct tizen_buffer_pool *tizen_buffer_pool,
+                      uint32_t format);
+};
+
+static inline int
+tizen_buffer_pool_add_listener(struct tizen_buffer_pool *tizen_buffer_pool,
+                              const struct tizen_buffer_pool_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) tizen_buffer_pool,
+                                    (void (**)(void)) listener, data);
+}
+
+#define TIZEN_BUFFER_POOL_AUTHENTICATE 0
+#define TIZEN_BUFFER_POOL_CREATE_BUFFER        1
+#define TIZEN_BUFFER_POOL_CREATE_PLANAR_BUFFER 2
+
+static inline void
+tizen_buffer_pool_set_user_data(struct tizen_buffer_pool *tizen_buffer_pool, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) tizen_buffer_pool, user_data);
+}
+
+static inline void *
+tizen_buffer_pool_get_user_data(struct tizen_buffer_pool *tizen_buffer_pool)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) tizen_buffer_pool);
+}
+
+static inline void
+tizen_buffer_pool_destroy(struct tizen_buffer_pool *tizen_buffer_pool)
+{
+       wl_proxy_destroy((struct wl_proxy *) tizen_buffer_pool);
+}
+
+static inline void
+tizen_buffer_pool_authenticate(struct tizen_buffer_pool *tizen_buffer_pool, uint32_t id)
+{
+       wl_proxy_marshal((struct wl_proxy *) tizen_buffer_pool,
+                        TIZEN_BUFFER_POOL_AUTHENTICATE, id);
+}
+
+static inline struct wl_buffer *
+tizen_buffer_pool_create_buffer(struct tizen_buffer_pool *tizen_buffer_pool, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) tizen_buffer_pool,
+                        TIZEN_BUFFER_POOL_CREATE_BUFFER, &wl_buffer_interface, NULL, name, width, height, stride, format);
+
+       return (struct wl_buffer *) id;
+}
+
+static inline struct wl_buffer *
+tizen_buffer_pool_create_planar_buffer(struct tizen_buffer_pool *tizen_buffer_pool, int32_t width, int32_t height, uint32_t format, uint32_t name0, int32_t offset0, int32_t stride0, uint32_t name1, int32_t offset1, int32_t stride1, uint32_t name2, int32_t offset2, int32_t stride2)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) tizen_buffer_pool,
+                        TIZEN_BUFFER_POOL_CREATE_PLANAR_BUFFER, &wl_buffer_interface, NULL, width, height, format, name0, offset0, stride0, name1, offset1, stride1, name2, offset2, stride2);
+
+       return (struct wl_buffer *) id;
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/ext/wayland/tizen-wlvideoformat.c b/ext/wayland/tizen-wlvideoformat.c
new file mode 100755 (executable)
index 0000000..23cde48
--- /dev/null
@@ -0,0 +1,113 @@
+/* GStreamer Wayland video sink
+ *
+ * Copyright (C) 2011 Intel Corporation
+ * Copyright (C) 2011 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
+ * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "tizen-wlvideoformat.h"
+#ifdef GST_WLSINK_ENHANCEMENT
+
+GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug);
+#define GST_CAT_DEFAULT gstwayland_debug
+
+typedef struct
+{
+  enum tizen_buffer_pool_format wl_format;
+  GstVideoFormat gst_format;
+} wl_VideoFormat;
+
+static const wl_VideoFormat formats[] = {
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+  {TIZEN_BUFFER_POOL_FORMAT_XRGB8888, GST_VIDEO_FORMAT_xRGB},
+  {TIZEN_BUFFER_POOL_FORMAT_XBGR8888, GST_VIDEO_FORMAT_xBGR},
+  {TIZEN_BUFFER_POOL_FORMAT_RGBX8888, GST_VIDEO_FORMAT_RGBx},
+  {TIZEN_BUFFER_POOL_FORMAT_BGRX8888, GST_VIDEO_FORMAT_BGRx},
+  {TIZEN_BUFFER_POOL_FORMAT_ARGB8888, GST_VIDEO_FORMAT_ARGB},
+  {TIZEN_BUFFER_POOL_FORMAT_ABGR8888, GST_VIDEO_FORMAT_RGBA},
+  {TIZEN_BUFFER_POOL_FORMAT_RGBA8888, GST_VIDEO_FORMAT_RGBA},
+  {TIZEN_BUFFER_POOL_FORMAT_BGRA8888, GST_VIDEO_FORMAT_BGRA},
+#else
+  {TIZEN_BUFFER_POOL_FORMAT_XRGB8888, GST_VIDEO_FORMAT_BGRx},
+  {TIZEN_BUFFER_POOL_FORMAT_XBGR8888, GST_VIDEO_FORMAT_RGBx},
+  {TIZEN_BUFFER_POOL_FORMAT_RGBX8888, GST_VIDEO_FORMAT_xBGR},
+  {TIZEN_BUFFER_POOL_FORMAT_BGRX8888, GST_VIDEO_FORMAT_xRGB},
+  {TIZEN_BUFFER_POOL_FORMAT_ARGB8888, GST_VIDEO_FORMAT_BGRA},
+  {TIZEN_BUFFER_POOL_FORMAT_ABGR8888, GST_VIDEO_FORMAT_RGBA},
+  {TIZEN_BUFFER_POOL_FORMAT_RGBA8888, GST_VIDEO_FORMAT_ABGR},
+  {TIZEN_BUFFER_POOL_FORMAT_BGRA8888, GST_VIDEO_FORMAT_ARGB},
+#endif
+  {TIZEN_BUFFER_POOL_FORMAT_RGB565, GST_VIDEO_FORMAT_RGB16},
+  {TIZEN_BUFFER_POOL_FORMAT_BGR565, GST_VIDEO_FORMAT_BGR16},
+  {TIZEN_BUFFER_POOL_FORMAT_RGB888, GST_VIDEO_FORMAT_RGB},
+  {TIZEN_BUFFER_POOL_FORMAT_BGR888, GST_VIDEO_FORMAT_BGR},
+  {TIZEN_BUFFER_POOL_FORMAT_YUYV, GST_VIDEO_FORMAT_YUY2},
+  {TIZEN_BUFFER_POOL_FORMAT_YVYU, GST_VIDEO_FORMAT_YVYU},
+  {TIZEN_BUFFER_POOL_FORMAT_UYVY, GST_VIDEO_FORMAT_UYVY},
+  {TIZEN_BUFFER_POOL_FORMAT_AYUV, GST_VIDEO_FORMAT_AYUV},
+  {TIZEN_BUFFER_POOL_FORMAT_NV12, GST_VIDEO_FORMAT_NV12},
+  {TIZEN_BUFFER_POOL_FORMAT_NV21, GST_VIDEO_FORMAT_NV21},
+  {TIZEN_BUFFER_POOL_FORMAT_NV16, GST_VIDEO_FORMAT_NV16},
+  {TIZEN_BUFFER_POOL_FORMAT_YUV410, GST_VIDEO_FORMAT_YUV9},
+  {TIZEN_BUFFER_POOL_FORMAT_YVU410, GST_VIDEO_FORMAT_YVU9},
+  {TIZEN_BUFFER_POOL_FORMAT_YUV411, GST_VIDEO_FORMAT_Y41B},
+  {TIZEN_BUFFER_POOL_FORMAT_YUV420, GST_VIDEO_FORMAT_I420},
+  {TIZEN_BUFFER_POOL_FORMAT_YVU420, GST_VIDEO_FORMAT_YV12},
+  {TIZEN_BUFFER_POOL_FORMAT_YUV422, GST_VIDEO_FORMAT_Y42B},
+  {TIZEN_BUFFER_POOL_FORMAT_YUV444, GST_VIDEO_FORMAT_v308},
+  {TIZEN_BUFFER_POOL_FORMAT_ST12, GST_VIDEO_FORMAT_ST12},
+  {TIZEN_BUFFER_POOL_FORMAT_SN12, GST_VIDEO_FORMAT_SN12}
+};
+
+enum tizen_buffer_pool_format
+gst_video_format_to_wayland_format (GstVideoFormat format)
+{
+  guint i;
+
+  for (i = 0; i < G_N_ELEMENTS (formats); i++)
+    if (formats[i].gst_format == format)
+      return formats[i].wl_format;
+
+  GST_WARNING ("wayland video format not found");
+  return -1;
+}
+
+GstVideoFormat
+gst_wayland_format_to_video_format (enum tizen_buffer_pool_format wl_format)
+{
+  guint i;
+
+  for (i = 0; i < G_N_ELEMENTS (formats); i++)
+    if (formats[i].wl_format == wl_format)
+      return formats[i].gst_format;
+
+  GST_WARNING ("gst video format not found");
+  return GST_VIDEO_FORMAT_UNKNOWN;
+}
+
+const gchar *
+gst_wayland_format_to_string (enum tizen_buffer_pool_format wl_format)
+{
+  return gst_video_format_to_string
+      (gst_wayland_format_to_video_format (wl_format));
+}
+#endif
diff --git a/ext/wayland/tizen-wlvideoformat.h b/ext/wayland/tizen-wlvideoformat.h
new file mode 100755 (executable)
index 0000000..ab259e1
--- /dev/null
@@ -0,0 +1,42 @@
+/* GStreamer Wayland video sink
+ *
+ * Copyright (C) 2011 Intel Corporation
+ * Copyright (C) 2011 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
+ * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GST_TIZEN_WL_VIDEO_FORMAT_H__
+#define __GST_TIZEN_WL_VIDEO_FORMAT_H__
+
+#include <wayland-client.h>
+#include <gst/video/video.h>
+
+#ifdef GST_WLSINK_ENHANCEMENT
+#include "protocol/tizen-bufferpoolprotocol.h"
+
+G_BEGIN_DECLS
+
+enum tizen_buffer_pool_format gst_video_format_to_wayland_format (GstVideoFormat format);
+GstVideoFormat gst_wayland_format_to_video_format (enum tizen_buffer_pool_format wl_format);
+
+const gchar *gst_wayland_format_to_string (enum tizen_buffer_pool_format wl_format);
+
+G_END_DECLS
+#endif
+#endif
old mode 100644 (file)
new mode 100755 (executable)
index de20602..b89551c
@@ -85,6 +85,15 @@ static gboolean gst_wayland_buffer_pool_stop (GstBufferPool * pool);
 static GstFlowReturn gst_wayland_buffer_pool_alloc (GstBufferPool * pool,
     GstBuffer ** buffer, GstBufferPoolAcquireParams * params);
 
+#ifdef GST_WLSINK_ENHANCEMENT
+/*tizen buffer pool*/
+static gboolean gst_wayland_tizen_buffer_pool_start (GstBufferPool * pool);
+static gboolean gst_wayland_tizen_buffer_pool_stop (GstBufferPool * pool);
+static GstFlowReturn gst_wayland_tizen_buffer_pool_alloc (GstBufferPool * pool,
+    GstBuffer ** buffer, GstBufferPoolAcquireParams * params);
+static void tizen_buffer_release (void *data, struct wl_buffer *wl_buffer);
+#endif
+
 #define gst_wayland_buffer_pool_parent_class parent_class
 G_DEFINE_TYPE (GstWaylandBufferPool, gst_wayland_buffer_pool,
     GST_TYPE_BUFFER_POOL);
@@ -92,20 +101,30 @@ G_DEFINE_TYPE (GstWaylandBufferPool, gst_wayland_buffer_pool,
 static void
 gst_wayland_buffer_pool_class_init (GstWaylandBufferPoolClass * klass)
 {
+  FUNCTION_ENTER ();
+
   GObjectClass *gobject_class = (GObjectClass *) klass;
   GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
 
   gobject_class->finalize = gst_wayland_buffer_pool_finalize;
 
   gstbufferpool_class->set_config = gst_wayland_buffer_pool_set_config;
+#ifdef GST_WLSINK_ENHANCEMENT
+  gstbufferpool_class->start = gst_wayland_tizen_buffer_pool_start;
+  gstbufferpool_class->stop = gst_wayland_tizen_buffer_pool_stop;
+  gstbufferpool_class->alloc_buffer = gst_wayland_tizen_buffer_pool_alloc;
+#else
   gstbufferpool_class->start = gst_wayland_buffer_pool_start;
   gstbufferpool_class->stop = gst_wayland_buffer_pool_stop;
   gstbufferpool_class->alloc_buffer = gst_wayland_buffer_pool_alloc;
+#endif
 }
 
 static void
 gst_wayland_buffer_pool_init (GstWaylandBufferPool * self)
 {
+  FUNCTION_ENTER ();
+
   gst_video_info_init (&self->info);
   g_mutex_init (&self->buffers_map_mutex);
   self->buffers_map = g_hash_table_new (g_direct_hash, g_direct_equal);
@@ -114,6 +133,8 @@ gst_wayland_buffer_pool_init (GstWaylandBufferPool * self)
 static void
 gst_wayland_buffer_pool_finalize (GObject * object)
 {
+  FUNCTION_ENTER ();
+
   GstWaylandBufferPool *pool = GST_WAYLAND_BUFFER_POOL_CAST (object);
 
   if (pool->wl_pool)
@@ -130,6 +151,8 @@ gst_wayland_buffer_pool_finalize (GObject * object)
 static void
 buffer_release (void *data, struct wl_buffer *wl_buffer)
 {
+  FUNCTION_ENTER ();
+
   GstWaylandBufferPool *self = data;
   GstBuffer *buffer;
   GstWlMeta *meta;
@@ -160,6 +183,8 @@ void
 gst_wayland_compositor_acquire_buffer (GstWaylandBufferPool * self,
     GstBuffer * buffer)
 {
+  FUNCTION_ENTER ();
+
   GstWlMeta *meta;
 
   meta = gst_buffer_get_wl_meta (buffer);
@@ -174,6 +199,8 @@ gst_wayland_compositor_acquire_buffer (GstWaylandBufferPool * self,
 static void
 unref_used_buffers (gpointer key, gpointer value, gpointer data)
 {
+  FUNCTION_ENTER ();
+
   GstBuffer *buffer = value;
   GstWlMeta *meta = gst_buffer_get_wl_meta (buffer);
   GList **to_unref = data;
@@ -187,6 +214,8 @@ unref_used_buffers (gpointer key, gpointer value, gpointer data)
 void
 gst_wayland_compositor_release_all_buffers (GstWaylandBufferPool * self)
 {
+  FUNCTION_ENTER ();
+
   GList *to_unref = NULL;
 
   g_mutex_lock (&self->buffers_map_mutex);
@@ -202,6 +231,8 @@ gst_wayland_compositor_release_all_buffers (GstWaylandBufferPool * self)
 static gboolean
 gst_wayland_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
 {
+  FUNCTION_ENTER ();
+
   GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL_CAST (pool);
   GstCaps *caps;
 
@@ -244,7 +275,12 @@ wrong_caps:
 static gboolean
 gst_wayland_buffer_pool_start (GstBufferPool * pool)
 {
+  FUNCTION_ENTER ();
+
   GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL (pool);
+
+  GST_DEBUG_OBJECT (self, "Initializing wayland buffer pool");
+
   guint size = 0;
   int fd;
   char filename[1024];
@@ -285,12 +321,15 @@ gst_wayland_buffer_pool_start (GstBufferPool * pool)
   self->size = size;
   self->used = 0;
 
+
   return GST_BUFFER_POOL_CLASS (parent_class)->start (pool);
 }
 
 static gboolean
 gst_wayland_buffer_pool_stop (GstBufferPool * pool)
 {
+  FUNCTION_ENTER ();
+
   GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL (pool);
 
   GST_DEBUG_OBJECT (self, "Stopping wayland buffer pool");
@@ -315,7 +354,10 @@ static GstFlowReturn
 gst_wayland_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
     GstBufferPoolAcquireParams * params)
 {
+  FUNCTION_ENTER ();
+
   GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL_CAST (pool);
+
   gint width, height, stride;
   gsize size;
   enum wl_shm_format format;
@@ -333,19 +375,20 @@ gst_wayland_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
   GST_DEBUG_OBJECT (self, "Allocating buffer of size %" G_GSSIZE_FORMAT
       " (%d x %d, stride %d), format %s", size, width, height, stride,
       gst_wayland_format_to_string (format));
-
   /* try to reserve another memory block from the shm pool */
   if (self->used + size > self->size)
     goto no_buffer;
 
   offset = self->used;
   self->used += size;
+
   data = ((gchar *) self->data) + offset;
 
   /* create buffer and its metadata object */
   *buffer = gst_buffer_new ();
   meta = (GstWlMeta *) gst_buffer_add_meta (*buffer, GST_WL_META_INFO, NULL);
   meta->pool = self;
+
   meta->wbuffer = wl_shm_pool_create_buffer (self->wl_pool, offset,
       width, height, stride, format);
   meta->used_by_compositor = FALSE;
@@ -375,6 +418,8 @@ no_buffer:
 GstBufferPool *
 gst_wayland_buffer_pool_new (GstWlDisplay * display)
 {
+  FUNCTION_ENTER ();
+
   GstWaylandBufferPool *pool;
 
   g_return_val_if_fail (GST_IS_WL_DISPLAY (display), NULL);
@@ -383,3 +428,179 @@ gst_wayland_buffer_pool_new (GstWlDisplay * display)
 
   return GST_BUFFER_POOL_CAST (pool);
 }
+
+#ifdef GST_WLSINK_ENHANCEMENT
+static void
+tizen_buffer_release (void *data, struct wl_buffer *wl_buffer)
+{
+  FUNCTION_ENTER ();
+
+  GstWaylandBufferPool *self = data;
+  GstBuffer *buffer;
+  GstWlMeta *meta;
+
+  g_mutex_lock (&self->buffers_map_mutex);
+  buffer = g_hash_table_lookup (self->buffers_map, wl_buffer);
+
+  GST_LOG_OBJECT (self, "wl_buffer::release (GstBuffer: %p)", buffer);
+
+  if (buffer) {
+    meta = gst_buffer_get_wl_meta (buffer);
+    if (meta->used_by_compositor) {
+      meta->used_by_compositor = FALSE;
+      /* unlock before unref because stop() may be called from here */
+      g_mutex_unlock (&self->buffers_map_mutex);
+      gst_buffer_unref (buffer);
+      return;
+    }
+  }
+  g_mutex_unlock (&self->buffers_map_mutex);
+}
+
+static const struct wl_buffer_listener tizen_buffer_listener = {
+  tizen_buffer_release
+};
+
+
+gboolean
+gst_wayland_tizen_buffer_pool_start (GstBufferPool * pool)
+{
+  FUNCTION_ENTER ();
+
+  GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL (pool);
+
+  GST_DEBUG_OBJECT (self, "Initializing wayland buffer pool");
+
+  tbm_bo_handle vitual_addr;
+  guint size = 0;
+
+  size = GST_VIDEO_INFO_SIZE (&self->info) * 15;
+
+  self->display->tbm_bufmgr = tbm_bufmgr_init (self->display->drm_fd);
+  g_return_if_fail (self->display->tbm_bufmgr != NULL);
+
+  self->display->tbm_bo =
+      tbm_bo_alloc (self->display->tbm_bufmgr, size, TBM_BO_DEFAULT);
+  if (!self->display->tbm_bo) {
+    GST_ERROR_OBJECT (pool, "alloc tbm bo(size:%d) failed: %s", size,
+        strerror (errno));
+    tbm_bufmgr_deinit (self->display->tbm_bufmgr);
+    self->display->tbm_bufmgr = NULL;
+    return FALSE;
+  }
+
+  vitual_addr = tbm_bo_get_handle (self->display->tbm_bo, TBM_DEVICE_CPU);
+  if (!vitual_addr.ptr) {
+    GST_ERROR_OBJECT (pool, "get tbm bo handle failed: %s", strerror (errno));
+    tbm_bo_unref (self->display->tbm_bo);
+    tbm_bufmgr_deinit (self->display->tbm_bufmgr);
+    self->display->tbm_bo = NULL;
+    self->display->tbm_bufmgr = NULL;
+    return FALSE;
+  }
+
+  if (vitual_addr.ptr)
+    memset (vitual_addr.ptr, 0x0, size);
+
+  self->data = vitual_addr.ptr;
+  self->size = size;
+  self->used = 0;
+
+  return GST_BUFFER_POOL_CLASS (parent_class)->start (pool);
+}
+
+gboolean
+gst_wayland_tizen_buffer_pool_stop (GstBufferPool * pool)
+{
+  FUNCTION_ENTER ();
+
+  GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL (pool);
+
+  GST_DEBUG_OBJECT (self, "Stopping wayland buffer pool");
+
+  if (self->display->tbm_bo)
+    tbm_bo_unref (self->display->tbm_bo);
+  if (self->display->tbm_bufmgr)
+    tbm_bufmgr_deinit (self->display->tbm_bufmgr);
+  self->display->tbm_bo = NULL;
+  self->display->tbm_bufmgr = NULL;
+
+  self->wl_pool = NULL;
+  self->size = 0;
+  self->used = 0;
+
+  /* all buffers are about to be destroyed;
+   * we should no longer do anything with them */
+  g_mutex_lock (&self->buffers_map_mutex);
+  g_hash_table_remove_all (self->buffers_map);
+  g_mutex_unlock (&self->buffers_map_mutex);
+
+  return GST_BUFFER_POOL_CLASS (parent_class)->stop (pool);
+}
+
+GstFlowReturn
+gst_wayland_tizen_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
+    GstBufferPoolAcquireParams * params)
+{
+  FUNCTION_ENTER ();
+
+  GstWaylandBufferPool *self = GST_WAYLAND_BUFFER_POOL_CAST (pool);
+
+  gint width, height, stride;
+  gsize size;
+  enum tizen_buffer_pool_format format;
+  gint offset;
+  void *data;
+  GstWlMeta *meta;
+
+  width = GST_VIDEO_INFO_WIDTH (&self->info);
+  height = GST_VIDEO_INFO_HEIGHT (&self->info);
+  stride = GST_VIDEO_INFO_PLANE_STRIDE (&self->info, 0);
+  size = GST_VIDEO_INFO_SIZE (&self->info);
+  format =
+      gst_video_format_to_wayland_format (GST_VIDEO_INFO_FORMAT (&self->info));
+
+  GST_DEBUG_OBJECT (self, "Allocating buffer of size %" G_GSSIZE_FORMAT
+      " (%d x %d, stride %d), format %s", size, width, height, stride,
+      gst_wayland_format_to_string (format));
+  /* try to reserve another memory block from the shm pool */
+  if (self->used + size > self->size)
+    goto no_buffer;
+
+  offset = self->used;
+  self->used += size;
+
+  data = ((gchar *) self->data) + offset;
+
+  /* create buffer and its metadata object */
+  *buffer = gst_buffer_new ();
+  meta = (GstWlMeta *) gst_buffer_add_meta (*buffer, GST_WL_META_INFO, NULL);
+  meta->pool = self;
+
+  meta->wbuffer =
+      tizen_buffer_pool_create_buffer (self->display->tizen_buffer_pool,
+      tbm_bo_export (self->display->tbm_bo), width, height, stride, format);
+  meta->used_by_compositor = FALSE;
+
+  /* configure listening to wl_buffer.release */
+  g_mutex_lock (&self->buffers_map_mutex);
+  g_hash_table_insert (self->buffers_map, meta->wbuffer, *buffer);
+  g_mutex_unlock (&self->buffers_map_mutex);
+
+  wl_buffer_add_listener (meta->wbuffer, &tizen_buffer_listener, self);
+
+  /* add the allocated memory on the GstBuffer */
+  gst_buffer_append_memory (*buffer,
+      gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE, data,
+          size, 0, size, NULL, NULL));
+
+  return GST_FLOW_OK;
+
+  /* ERROR */
+no_buffer:
+  {
+    GST_WARNING_OBJECT (pool, "can't create buffer");
+    return GST_FLOW_ERROR;
+  }
+}
+#endif
old mode 100644 (file)
new mode 100755 (executable)
index ad5020b..acd06f8
@@ -26,6 +26,9 @@
 #include <gst/video/gstvideometa.h>
 
 #include "wldisplay.h"
+#ifdef GST_WLSINK_ENHANCEMENT
+#include <tbm_bufmgr.h>
+#endif
 
 G_BEGIN_DECLS
 
@@ -34,6 +37,12 @@ G_BEGIN_DECLS
 #define GST_WAYLAND_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WAYLAND_BUFFER_POOL, GstWaylandBufferPool))
 #define GST_WAYLAND_BUFFER_POOL_CAST(obj) ((GstWaylandBufferPool*)(obj))
 
+#if 1
+#define FUNCTION_ENTER()       GST_INFO("<ENTER>")
+#else
+#define FUNCTION_ENTER()
+#endif
+
 typedef struct _GstWaylandBufferPool GstWaylandBufferPool;
 typedef struct _GstWaylandBufferPoolClass GstWaylandBufferPoolClass;
 
index c812b86..a3057c9 100755 (executable)
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-
 #include "wldisplay.h"
-
 #include <errno.h>
 
+#ifdef GST_WLSINK_ENHANCEMENT
+#include <fcntl.h>
+#include <unistd.h>
+#include <xf86drm.h>
+
+static void
+handle_tizen_buffer_pool_device (void *data,
+    struct tizen_buffer_pool *tizen_buffer_pool, const char *device_name)
+{
+  FUNCTION_ENTER ();
+  GstWlDisplay *self = data;
+
+  g_return_if_fail (self != NULL);
+  g_return_if_fail (device_name != NULL);
+
+  self->device_name = strdup (device_name);
+}
+
+static void
+handle_tizen_buffer_pool_authenticated (void *data,
+    struct tizen_buffer_pool *tizen_buffer_pool)
+{
+  FUNCTION_ENTER ();
+
+  GstWlDisplay *self = data;
+  g_return_if_fail (self != NULL);
+
+  /* authenticated */
+  self->authenticated = 1;
+}
+
+static void
+handle_tizen_buffer_pool_capabilities (void *data,
+    struct tizen_buffer_pool *tizen_buffer_pool, uint32_t value)
+{
+  FUNCTION_ENTER ();
+  GstWlDisplay *self = data;
+  g_return_if_fail (self != NULL);
+
+  drm_magic_t magic;
+
+  /* check if buffer_pool has video capability */
+  if (!(value & TIZEN_BUFFER_POOL_CAPABILITY_VIDEO))
+    return;
+
+  self->has_capability = 1;
+
+  /* do authenticate only if a pool has the video capability */
+#ifdef O_CLOEXEC
+  self->drm_fd = open (self->device_name, O_RDWR | O_CLOEXEC);
+  if (self->drm_fd == -1 && errno == EINVAL)
+#endif
+  {
+    self->drm_fd = open (self->device_name, O_RDWR);
+    if (self->drm_fd != -1)
+      fcntl (self->drm_fd, F_SETFD, fcntl (self->drm_fd, F_GETFD) | FD_CLOEXEC);
+  }
+
+  g_return_if_fail (self->drm_fd >= 0);
+
+  if (drmGetMagic (self->drm_fd, &magic) != 0) {
+    close (self->drm_fd);
+    self->drm_fd = -1;
+    return;
+  }
+
+  tizen_buffer_pool_authenticate (tizen_buffer_pool, magic);
+  wl_display_roundtrip (self->display);
+}
+
+static void
+handle_tizen_buffer_pool_format (void *data,
+    struct tizen_buffer_pool *tizen_buffer_pool, uint32_t format)
+{
+  FUNCTION_ENTER ();
+  GstWlDisplay *self = data;
+  g_return_if_fail (self != NULL);
+
+  GST_INFO ("format is %d", format);
+  g_array_append_val (self->formats, format);
+}
+
+static const struct tizen_buffer_pool_listener tz_buffer_pool_listener = {
+  handle_tizen_buffer_pool_device,
+  handle_tizen_buffer_pool_authenticated,
+  handle_tizen_buffer_pool_capabilities,
+  handle_tizen_buffer_pool_format
+};
+#endif
+
 GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug);
 #define GST_CAT_DEFAULT gstwayland_debug
 
@@ -64,10 +152,6 @@ gst_wl_display_finalize (GObject * gobject)
 
   g_array_unref (self->formats);
   gst_poll_free (self->wl_fd_poll);
-#ifdef GST_ENHANCEMENT
-  if (self->tz_subsurface)
-    tizen_subsurface_destroy (self->tz_subsurface);
-#endif
   if (self->shm)
     wl_shm_destroy (self->shm);
 
@@ -90,6 +174,16 @@ gst_wl_display_finalize (GObject * gobject)
     wl_display_flush (self->display);
     wl_display_disconnect (self->display);
   }
+#ifdef GST_WLSINK_ENHANCEMENT
+  if (self->tizen_subsurface)
+    tizen_subsurface_destroy (self->tizen_subsurface);
+  if (self->tizen_buffer_pool)
+    tizen_buffer_pool_destroy (self->tizen_buffer_pool);
+  if (self->device_name)
+    free (self->device_name);
+  if (self->drm_fd >= 0)
+    close (self->drm_fd);
+#endif
 
   G_OBJECT_CLASS (gst_wl_display_parent_class)->finalize (gobject);
 }
@@ -159,14 +253,31 @@ registry_handle_global (void *data, struct wl_registry *registry,
         wl_registry_bind (registry, id, &wl_subcompositor_interface, 1);
   } else if (g_strcmp0 (interface, "wl_shell") == 0) {
     self->shell = wl_registry_bind (registry, id, &wl_shell_interface, 1);
+#ifndef GST_WLSINK_ENHANCEMENT
   } else if (g_strcmp0 (interface, "wl_shm") == 0) {
     self->shm = wl_registry_bind (registry, id, &wl_shm_interface, 1);
     wl_shm_add_listener (self->shm, &shm_listener, self);
+#endif
   } else if (g_strcmp0 (interface, "wl_scaler") == 0) {
     self->scaler = wl_registry_bind (registry, id, &wl_scaler_interface, 2);
-#ifdef GST_ENHANCEMENT
+#ifdef GST_WLSINK_ENHANCEMENT
   } else if (g_strcmp0 (interface, "tizen_subsurface") == 0) {
-    self->tz_subsurface = wl_registry_bind (registry, id, &tizen_subsurface_interface, 1);
+    self->tizen_subsurface =
+        wl_registry_bind (registry, id, &tizen_subsurface_interface, 1);
+  } else if (g_strcmp0 (interface, "tizen_buffer_pool") == 0) {
+
+    self->tizen_buffer_pool =
+        wl_registry_bind (registry, id, &tizen_buffer_pool_interface, 1);
+    g_return_if_fail (self->tizen_buffer_pool != NULL);
+
+    GST_INFO ("id(%d)", id);
+    self->name = id;
+    self->drm_fd = -1;
+
+    tizen_buffer_pool_add_listener (self->tizen_buffer_pool, &tz_buffer_pool_listener, self);
+
+    /* make sure all tizen_buffer_pool's events are handled */
+    wl_display_roundtrip (self->display);
   }
 #endif
 }
@@ -276,7 +387,11 @@ gst_wl_display_new_existing (struct wl_display * display,
   VERIFY_INTERFACE_EXISTS (compositor, "wl_compositor");
   VERIFY_INTERFACE_EXISTS (subcompositor, "wl_subcompositor");
   VERIFY_INTERFACE_EXISTS (shell, "wl_shell");
+#ifdef GST_WLSINK_ENHANCEMENT
+  VERIFY_INTERFACE_EXISTS (tizen_buffer_pool, "tizen_buffer_pool");
+#else
   VERIFY_INTERFACE_EXISTS (shm, "wl_shm");
+#endif
   VERIFY_INTERFACE_EXISTS (scaler, "wl_scaler");
 
 #undef VERIFY_INTERFACE_EXISTS
index c98c801..9b8d669 100755 (executable)
 #include <gst/gst.h>
 #include <wayland-client.h>
 #include "scaler-client-protocol.h"
-#ifdef GST_ENHANCEMENT
-#include "tizen-subsurfaceprotocol.h"
+#ifdef GST_WLSINK_ENHANCEMENT
+#include <tbm_bufmgr.h>
+#include "protocol/tizen-subsurfaceprotocol.h"
+#include "protocol/tizen-bufferpoolprotocol.h"
 #endif
 G_BEGIN_DECLS
 #define GST_TYPE_WL_DISPLAY                  (gst_wl_display_get_type ())
@@ -34,7 +36,7 @@ G_BEGIN_DECLS
 #define GST_WL_DISPLAY_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_WL_DISPLAY, GstWlDisplayClass))
 #define GST_IS_WL_DISPLAY_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_WL_DISPLAY))
 #define GST_WL_DISPLAY_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_WL_DISPLAY, GstWlDisplayClass))
-#if 0
+#if 1
 #define FUNCTION_ENTER()       GST_INFO("<ENTER>")
 #else
 #define FUNCTION_ENTER()
@@ -57,15 +59,30 @@ struct _GstWlDisplay
   struct wl_shell *shell;
   struct wl_shm *shm;
   struct wl_scaler *scaler;
-#ifdef GST_ENHANCEMENT
-  struct tizen_subsurface *tz_subsurface;
-#endif
   GArray *formats;
 
   /* private */
   gboolean own_display;
   GThread *thread;
   GstPoll *wl_fd_poll;
+
+#ifdef GST_WLSINK_ENHANCEMENT
+  /*video output layer*/
+  struct tizen_subsurface *tizen_subsurface;
+
+  /*zero copy*/
+  struct tizen_buffer_pool *tizen_buffer_pool;
+  uint32_t name;
+  int has_capability;
+
+  /* drm for zero copy */
+  char *device_name;
+  int drm_fd;
+  int authenticated;
+  /* tbm for zero copy*/
+  tbm_bufmgr tbm_bufmgr;
+  tbm_bo tbm_bo;
+#endif
 };
 
 struct _GstWlDisplayClass
old mode 100644 (file)
new mode 100755 (executable)
index f2166f9..5309c34
@@ -30,6 +30,8 @@
 GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug);
 #define GST_CAT_DEFAULT gstwayland_debug
 
+#ifndef GST_WLSINK_ENHANCEMENT
+
 typedef struct
 {
   enum wl_shm_format wl_format;
@@ -109,3 +111,4 @@ gst_wayland_format_to_string (enum wl_shm_format wl_format)
   return gst_video_format_to_string
       (gst_wayland_format_to_video_format (wl_format));
 }
+#endif
old mode 100644 (file)
new mode 100755 (executable)
index 72efc81..b0aba5b
@@ -27,6 +27,8 @@
 #include <wayland-client.h>
 #include <gst/video/video.h>
 
+#ifndef GST_WLSINK_ENHANCEMENT
+
 G_BEGIN_DECLS
 
 enum wl_shm_format gst_video_format_to_wayland_format (GstVideoFormat format);
@@ -37,3 +39,4 @@ const gchar *gst_wayland_format_to_string (enum wl_shm_format wl_format);
 G_END_DECLS
 
 #endif
+#endif
index 5c1822f..dab8786 100755 (executable)
@@ -174,9 +174,9 @@ gst_wl_window_new_in_surface (GstWlDisplay * display,
   window->subsurface = wl_subcompositor_get_subsurface (display->subcompositor,
       window->surface, parent);
   wl_subsurface_set_desync (window->subsurface);
-#ifdef GST_ENHANCEMENT
-  if (display->tz_subsurface)
-    tizen_subsurface_place_below_parent (display->tz_subsurface, window->subsurface);
+#ifdef GST_WLSINK_ENHANCEMENT
+  if (display->tizen_subsurface)
+    tizen_subsurface_place_below_parent (display->tizen_subsurface, window->subsurface);
 
   wl_surface_commit (parent);
 #endif
index 9ea99e3..6ba058a 100755 (executable)
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
 #define GST_WL_WINDOW_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_WL_WINDOW, GstWlWindowClass))
 #define GST_IS_WL_WINDOW_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_WL_WINDOW))
 #define GST_WL_WINDOW_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_WL_WINDOW, GstWlWindowClass))
-#if 0
+#if 1
 #define FUNCTION_ENTER()       GST_INFO("<ENTER>")
 #else
 #define FUNCTION_ENTER()
index a0947ad..cc7481b 100644 (file)
@@ -33,12 +33,14 @@ BuildRequires:  pkgconfig(openssl) >= 0.9.5
 BuildRequires:  pkgconfig(sndfile) >= 1.0.16
 %if %{with wayland}
 BuildRequires:  pkgconfig(wayland-client) >= 1.0.0
+BuildRequires:  pkgconfig(libdrm)
+BuildRequires:  pkgconfig(libtbm)
 %endif
 %if %{with x}
 BuildRequires:  pkgconfig(x11)
 %endif
 Requires:       gstreamer >= 1.0.2
-Enhances:       gstreamer
+#Enhances:       gstreamer
 
 %description
 GStreamer is a streaming media framework based on graphs of filters
@@ -68,7 +70,7 @@ processing capabilities can be added simply by installing new plug-ins.
 %build
 export V=1
 NOCONFIGURE=1 ./autogen.sh
-export CFLAGS="-DGST_ENHANCEMENT"
+export CFLAGS="-DGST_WLSINK_ENHANCEMENT"
 %configure\
     --disable-static\
     --disable-examples\