Apply using parent_id of wl_window 08/57708/3
authorHyunil <hyunil46.park@samsung.com>
Fri, 22 Jan 2016 02:29:18 +0000 (11:29 +0900)
committerHyunil <hyunil46.park@samsung.com>
Thu, 28 Jan 2016 09:27:23 +0000 (18:27 +0900)
waylandsink can get unique_id of wl_window through video overlay handle.
Now, waylandsink can create sub surface by unique_id

Change-Id: I158a729dcb8e44fdc353bec7e2ac88e70b71faf4
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 cab4c33..b9c112f 100755 (executable)
@@ -383,7 +383,7 @@ gst_wayland_sink_set_property (GObject * object,
       if (GST_STATE (sink) == GST_STATE_PAUSED) {
         /*need to render last buffer */
         g_mutex_lock (&sink->render_lock);
-        render_last_buffer(sink);
+        render_last_buffer (sink);
         g_mutex_unlock (&sink->render_lock);
       }
       break;
@@ -399,7 +399,7 @@ gst_wayland_sink_set_property (GObject * object,
       if (GST_STATE (sink) == GST_STATE_PAUSED) {
         /*need to render last buffer */
         g_mutex_lock (&sink->render_lock);
-        render_last_buffer(sink);
+        render_last_buffer (sink);
         g_mutex_unlock (&sink->render_lock);
       }
       break;
@@ -413,7 +413,7 @@ gst_wayland_sink_set_property (GObject * object,
       if (GST_STATE (sink) == GST_STATE_PAUSED) {
         /*need to render last buffer */
         g_mutex_lock (&sink->render_lock);
-        render_last_buffer(sink);
+        render_last_buffer (sink);
         g_mutex_unlock (&sink->render_lock);
       }
       break;
@@ -427,7 +427,7 @@ gst_wayland_sink_set_property (GObject * object,
       if (GST_STATE (sink) == GST_STATE_PAUSED) {
         /*need to render last buffer */
         g_mutex_lock (&sink->render_lock);
-        render_last_buffer(sink);
+        render_last_buffer (sink);
         g_mutex_unlock (&sink->render_lock);
       }
       break;
@@ -986,7 +986,7 @@ render_last_buffer (GstWaylandSink * sink)
     sink->video_info_changed = FALSE;
   }
 #ifdef GST_WLSINK_ENHANCEMENT
-  if(sink->last_buffer)
+  if (sink->last_buffer)
     gst_wl_window_render (sink->window, wlbuffer, info);
   else {
     if (G_UNLIKELY (info)) {
@@ -1346,16 +1346,44 @@ static void
 gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
 {
   FUNCTION;
+#if GST_WLSINK_ENHANCEMENT      /* use  unique_id */
   GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
-  struct wl_surface *surface = (struct wl_surface *) handle;
-
   g_return_if_fail (sink != NULL);
-#ifdef GST_WLSINK_ENHANCEMENT
+
   if (sink->window != NULL) {
     GST_WARNING_OBJECT (sink, "changing window handle is not supported");
     return;
   }
-#endif
+  g_mutex_lock (&sink->render_lock);
+  g_clear_object (&sink->window);
+
+  GST_INFO ("parent_id %d %p", (int) handle, handle);
+
+  if (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)) {
+        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->window = gst_wl_window_new_in_surface (sink->display, NULL);
+      }
+    } else {
+      GST_ERROR_OBJECT (sink, "Failed to find display handle, "
+          "ignoring window handle");
+    }
+  }
+  gst_wayland_sink_update_window_geometry (sink);
+
+  g_mutex_unlock (&sink->render_lock);
+
+
+#else
+  GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
+  struct wl_surface *surface = (struct wl_surface *) handle;
+
+  g_return_if_fail (sink != NULL);
+
   g_mutex_lock (&sink->render_lock);
 
   GST_DEBUG_OBJECT (sink, "Setting window handle %" GST_PTR_FORMAT,
@@ -1367,18 +1395,10 @@ 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)) {
-#ifdef GST_WLSINK_ENHANCEMENT
-        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"));
-#else
         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"));
-#endif
       } else {
         sink->window = gst_wl_window_new_in_surface (sink->display, surface);
       }
@@ -1387,10 +1407,9 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
           "ignoring window handle");
     }
   }
-#ifdef GST_WLSINK_ENHANCEMENT
-  gst_wayland_sink_update_window_geometry (sink);
-#endif
   g_mutex_unlock (&sink->render_lock);
+
+#endif /* use  unique_id */
 }
 
 static void
index 6187329..a06da71 100644 (file)
@@ -122,12 +122,12 @@ gst_wl_display_finalize (GObject * gobject)
         self->tbm_bo[i] = NULL;
       }
     }
-    if (self->tbm_client) {
-      wayland_tbm_client_deinit (self->tbm_client);
-      self->tbm_client = NULL;
-    }
     self->tbm_bufmgr = NULL;
   }
+  if (self->tbm_client) {
+    wayland_tbm_client_deinit (self->tbm_client);
+    self->tbm_client = NULL;
+  }
 #endif
   if (self->shm)
     wl_shm_destroy (self->shm);
@@ -344,6 +344,7 @@ gst_wl_display_new_existing (struct wl_display * display,
   VERIFY_INTERFACE_EXISTS (shell, "wl_shell");
 #ifdef GST_WLSINK_ENHANCEMENT
   VERIFY_INTERFACE_EXISTS (tizen_video, "tizen_video");
+
   self->tbm_client = wayland_tbm_client_init (self->display);
   if (!self->tbm_client) {
     *error = g_error_new (g_quark_from_static_string ("GstWlDisplay"), 0,
index 363d714..83b4aea 100644 (file)
@@ -90,6 +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;
 #endif
 
 #if 1
index fd9a53e..e8b3706 100644 (file)
@@ -132,12 +132,20 @@ gst_wl_window_new_internal (GstWlDisplay * display, struct wl_surface *parent)
   if (display->need_shell_surface) {
     window->shell_surface = wl_shell_get_shell_surface (display->shell,
         window->area_surface);
-  }
-  if (display->use_parent_wl_surface && parent != NULL) {
+  } else if (display->use_parent_wl_surface) {
+#ifdef GST_WLSINK_ENHANCEMENT
+       GST_INFO("call tizen_policy_get_subsurface");
     window->area_subsurface =
-        wl_subcompositor_get_subsurface (display->subcompositor,
-        window->area_surface, parent);
+        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);
+#else
+    window->area_subsurface =
+           wl_subcompositor_get_subsurface (display->subcompositor,
+           window->area_surface, parent);
+    wl_subsurface_set_desync (window->area_subsurface);
+#endif
   }
 #endif
 
@@ -146,6 +154,7 @@ gst_wl_window_new_internal (GstWlDisplay * display, struct wl_surface *parent)
       wl_subcompositor_get_subsurface (display->subcompositor,
       window->video_surface, window->area_surface);
   wl_subsurface_set_desync (window->video_subsurface);
+  wl_surface_commit (window->video_surface);
 
   window->area_viewport = wl_scaler_get_viewport (display->scaler,
       window->area_surface);
@@ -240,9 +249,13 @@ gst_wl_window_new_in_surface (GstWlDisplay * display,
   GstWlWindow *window;
 
   display->use_parent_wl_surface = TRUE;
+#ifdef GST_WLSINK_ENHANCEMENT
+  window = gst_wl_window_new_internal (display, NULL);
+#else
   window = gst_wl_window_new_internal (display, parent);
+#endif
 
-#if 0
+#if 0                           /*for enlightment */
   /* embed in parent */
   window->area_subsurface =
       wl_subcompositor_get_subsurface (display->subcompositor,
@@ -253,11 +266,13 @@ gst_wl_window_new_in_surface (GstWlDisplay * display,
 #ifdef GST_WLSINK_ENHANCEMENT
   /*Area surface from App need to be under parent surface */
   if (display->tizen_policy) {
+       GST_INFO(" call tizen_policy_place_subsurface_below_parent ");
     tizen_policy_place_subsurface_below_parent (display->tizen_policy,
         window->area_subsurface);
     tizen_policy_place_subsurface_below_parent (display->tizen_policy,
         window->video_subsurface);
   }
+#else
   wl_surface_commit (parent);
 #endif
   return window;
@@ -445,9 +460,9 @@ gst_wl_window_resize_video_surface (GstWlWindow * window, gboolean commit)
   wl_viewport_set_destination (window->video_viewport, res.w, res.h);
   GST_INFO ("wl_viewport_set_destination(%d,%d)", res.w, res.h);
 
-  wl_viewport_set_source (window->video_viewport, wl_fixed_from_int (src_input.x),
-      wl_fixed_from_int (src_input.y), wl_fixed_from_int (src_input.w),
-      wl_fixed_from_int (src_input.h));
+  wl_viewport_set_source (window->video_viewport,
+      wl_fixed_from_int (src_input.x), wl_fixed_from_int (src_input.y),
+      wl_fixed_from_int (src_input.w), wl_fixed_from_int (src_input.h));
   GST_INFO ("wl_viewport_set_source(%d,%d, %d x %d)", src_input.x, src_input.y,
       src_input.w, src_input.h);
 
@@ -502,7 +517,8 @@ gst_wl_window_render (GstWlWindow * window, GstWlBuffer * buffer,
   wl_surface_damage (window->video_surface, 0, 0, window->surface_width,
       window->surface_height);
 #ifdef GST_WLSINK_ENHANCEMENT
-  GST_LOG("update area width %d, height %d", window->surface_width, window->surface_height);
+  GST_LOG ("update area width %d, height %d", window->surface_width,
+      window->surface_height);
 #endif
   /* wl_surface_commit change surface state, if wl_buffer is not attached newly,  then surface is not changed */
   wl_surface_commit (window->video_surface);
@@ -511,7 +527,8 @@ gst_wl_window_render (GstWlWindow * window, GstWlBuffer * buffer,
     /* commit also the parent (area_surface) in order to change
      * the position of the video_subsurface */
 #ifdef GST_WLSINK_ENHANCEMENT
-    GST_DEBUG("render_rectangle %d*%d", window->render_rectangle.w, window->render_rectangle.h);
+    GST_DEBUG ("render_rectangle %d*%d", window->render_rectangle.w,
+        window->render_rectangle.h);
 #endif
     wl_surface_damage (window->area_surface, 0, 0, window->render_rectangle.w,
         window->render_rectangle.h);
@@ -558,6 +575,7 @@ gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
   if (window->video_width != 0)
     wl_subsurface_set_desync (window->video_subsurface);
 }
+
 #ifdef GST_WLSINK_ENHANCEMENT
 void
 gst_wl_window_set_video_info (GstWlWindow * window, GstVideoInfo * info)
@@ -572,6 +590,7 @@ gst_wl_window_set_video_info (GstWlWindow * window, GstVideoInfo * info)
   if (window->render_rectangle.w != 0)
     gst_wl_window_resize_video_surface (window, FALSE);
 }
+
 void
 gst_wl_window_set_rotate_angle (GstWlWindow * window, guint rotate_angle)
 {
@@ -608,4 +627,3 @@ gst_wl_window_set_flip (GstWlWindow * window, guint flip)
   GST_INFO ("flip value is (%d)", window->flip);
 }
 #endif
-