Add new video interface for id of wl_surface
authorHyunil <hyunil46.park@samsung.com>
Thu, 4 Feb 2016 06:11:43 +0000 (15:11 +0900)
committerHyunil <hyunil46.park@samsung.com>
Thu, 4 Feb 2016 06:21:19 +0000 (15:21 +0900)
Change-Id: I1c02517b11c1c876acbaf8e8b6da8c29ea852105
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c
ext/wayland/wldisplay.c
ext/wayland/wldisplay.h
ext/wayland/wlwindow.c

index b9c112f..1cbdab8 100755 (executable)
@@ -191,6 +191,9 @@ static void gst_wayland_sink_videooverlay_init (GstVideoOverlayInterface *
     iface);
 static void gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay,
     guintptr handle);
+static void
+gst_wayland_sink_set_wl_window_wl_surface_id (GstVideoOverlay * overlay,
+    guintptr wl_surface_id);
 static void gst_wayland_sink_set_render_rectangle (GstVideoOverlay * overlay,
     gint x, gint y, gint w, gint h);
 static void gst_wayland_sink_expose (GstVideoOverlay * overlay);
@@ -1340,13 +1343,19 @@ gst_wayland_sink_videooverlay_init (GstVideoOverlayInterface * iface)
   iface->set_window_handle = gst_wayland_sink_set_window_handle;
   iface->set_render_rectangle = gst_wayland_sink_set_render_rectangle;
   iface->expose = gst_wayland_sink_expose;
+#ifdef GST_WLSINK_ENHANCEMENT   /* use  unique_id */
+  iface->set_wl_window_wl_surface_id =
+      gst_wayland_sink_set_wl_window_wl_surface_id;
+#endif
 }
 
+#ifdef GST_WLSINK_ENHANCEMENT   /* use  unique_id */
 static void
-gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
+gst_wayland_sink_set_wl_window_wl_surface_id (GstVideoOverlay * overlay,
+    guintptr wl_surface_id)
 {
   FUNCTION;
-#if GST_WLSINK_ENHANCEMENT      /* use  unique_id */
+
   GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
   g_return_if_fail (sink != NULL);
 
@@ -1357,15 +1366,13 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
   g_mutex_lock (&sink->render_lock);
   g_clear_object (&sink->window);
 
-  GST_INFO ("parent_id %d %p", (int) handle, handle);
+  GST_INFO ("wl_surface_id %d %p", (int) wl_surface_id, wl_surface_id);
 
-  if (handle) {
+  if (wl_surface_id) {
     if (G_LIKELY (gst_wayland_sink_find_display (sink))) {
       /* we cannot use our own display with an external window handle */
       if (G_UNLIKELY (sink->display->own_display)) {
-        sink->display->parent_id = (int) handle;
-        GST_INFO ("parent_id %d", sink->display->parent_id);
-        //GST_DEBUG_OBJECT (sink, "Setting parent id %d", handle);
+        sink->display->wl_surface_id = (int) wl_surface_id;
         sink->window = gst_wl_window_new_in_surface (sink->display, NULL);
       }
     } else {
@@ -1377,13 +1384,25 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
 
   g_mutex_unlock (&sink->render_lock);
 
+}
+#endif
+
+static void
+gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
+{
+  FUNCTION;
 
-#else
   GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
   struct wl_surface *surface = (struct wl_surface *) handle;
 
   g_return_if_fail (sink != NULL);
 
+#ifdef GST_WLSINK_ENHANCEMENT   /* use  unique_id */
+  if (sink->window != NULL) {
+    GST_WARNING_OBJECT (sink, "changing window handle is not supported");
+    return;
+  }
+#endif
   g_mutex_lock (&sink->render_lock);
 
   GST_DEBUG_OBJECT (sink, "Setting window handle %" GST_PTR_FORMAT,
@@ -1395,11 +1414,12 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
     if (G_LIKELY (gst_wayland_sink_find_display (sink))) {
       /* we cannot use our own display with an external window handle */
       if (G_UNLIKELY (sink->display->own_display)) {
-        GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ_WRITE,
-            ("waylandsink cannot use an externally-supplied surface without "
-                "an externally-supplied display handle. Consider providing a "
-                "display handle from your application with GstContext"));
       } else {
+        GST_ELEMENT_WARNING (sink, RESOURCE, OPEN_READ_WRITE,
+            ("Application did not provide a wayland display handle"),
+            ("Now waylandsink use internal display handle "
+                "which is created ourselves. Consider providing a "
+                "display handle from your application with GstContext"));
         sink->window = gst_wl_window_new_in_surface (sink->display, surface);
       }
     } else {
@@ -1409,7 +1429,6 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
   }
   g_mutex_unlock (&sink->render_lock);
 
-#endif /* use  unique_id */
 }
 
 static void
index a06da71..7d67706 100644 (file)
@@ -81,6 +81,7 @@ gst_wl_display_init (GstWlDisplay * self)
   g_mutex_init (&self->buffers_mutex);
 #ifdef GST_WLSINK_ENHANCEMENT
   self->tbm_bo_idx = 0;
+  self->wl_surface_id = -1;
 #endif
 }
 
index 83b4aea..1ee1626 100644 (file)
@@ -90,7 +90,7 @@ struct _GstWlDisplay
   int stride_width[NV_BUF_PLANE_NUM];
   int stride_height[NV_BUF_PLANE_NUM];
   int native_video_size;
-  unsigned int parent_id;
+  unsigned int wl_surface_id;
 #endif
 
 #if 1
index 14a6d08..bbf2f66 100644 (file)
@@ -108,7 +108,11 @@ gst_wl_window_finalize (GObject * gobject)
 }
 
 static GstWlWindow *
+#ifdef GST_WLSINK_ENHANCEMENT
 gst_wl_window_new_internal (GstWlDisplay * display, struct wl_surface *parent)
+#else
+gst_wl_window_new_internal (GstWlDisplay * display)
+#endif
 {
   FUNCTION;
   GstWlWindow *window;
@@ -137,11 +141,19 @@ gst_wl_window_new_internal (GstWlDisplay * display, struct wl_surface *parent)
   } else if (display->use_parent_wl_surface) {
 #ifdef GST_WLSINK_ENHANCEMENT
     GST_INFO ("call tizen_policy_get_subsurface");
-    window->area_subsurface =
-        tizen_policy_get_subsurface (display->tizen_policy,
-        window->area_surface, display->parent_id);
-    wl_subsurface_set_desync (window->area_subsurface);
-    wl_surface_commit (window->area_surface);
+    if (display->wl_surface_id && parent == NULL) {
+      window->area_subsurface =
+          tizen_policy_get_subsurface (display->tizen_policy,
+          window->area_surface, display->wl_surface_id);
+      wl_subsurface_set_desync (window->area_subsurface);
+      wl_surface_commit (window->area_surface);
+    } else {
+      GST_INFO (" wl_surface %p", parent);
+      window->area_subsurface =
+          wl_subcompositor_get_subsurface (display->subcompositor,
+          window->area_surface, parent);
+      wl_subsurface_set_desync (window->area_subsurface);
+    }
 #else
     window->area_subsurface =
         wl_subcompositor_get_subsurface (display->subcompositor,
@@ -215,6 +227,7 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info)
   gint width;
 
 /* not create shell_surface here for enlightenment */
+#ifdef GST_WLSINK_ENHANCEMENT
   display->need_shell_surface = TRUE;
 
   window = gst_wl_window_new_internal (display, NULL);
@@ -224,6 +237,7 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info)
   window->shell_surface = wl_shell_get_shell_surface (display->shell,
       window->area_surface);
 #endif
+#endif
   if (window->shell_surface) {
     wl_shell_surface_add_listener (window->shell_surface,
         &shell_surface_listener, window);
@@ -252,7 +266,11 @@ gst_wl_window_new_in_surface (GstWlDisplay * display,
 
   display->use_parent_wl_surface = TRUE;
 #ifdef GST_WLSINK_ENHANCEMENT
-  window = gst_wl_window_new_internal (display, NULL);
+  if (parent) {                 /*use wl_surface */
+    window = gst_wl_window_new_internal (display, parent);
+  } else {                      /* use wl_surface id */
+    window = gst_wl_window_new_internal (display, NULL);
+  }
 #else
   window = gst_wl_window_new_internal (display, parent);
 #endif