waylandsink : update last_sample in paused state when signal_handoffs is set to zero 52/138352/4 accepted/tizen_3.0_ivi accepted/tizen/3.0/common/20170719.081517 accepted/tizen/3.0/ivi/20170719.003547 accepted/tizen/3.0/mobile/20170719.003444 accepted/tizen/3.0/tv/20170719.003513 accepted/tizen/3.0/wearable/20170719.003530 submit/tizen_3.0/20170713.103716 submit/tizen_3.0/20170714.024109
authorHyunil <hyunil46.park@samsung.com>
Wed, 12 Jul 2017 02:08:26 +0000 (11:08 +0900)
committerHyunil <hyunil46.park@samsung.com>
Wed, 12 Jul 2017 07:29:30 +0000 (16:29 +0900)
Change-Id: I6f86fac995e079095f2e852c1baaf7c93bdd23a4
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c

index c334780f03ab7fdeaa4a77ab32fca448fc98d32b..d6fd75b31a11b18fbae2417a536f1b1230b1ddeb 100755 (executable)
@@ -886,6 +886,29 @@ gst_wayland_sink_render_flush_buffer (GstBaseSink * bsink)
   gst_wayland_sink_render (bsink, sink->last_buffer);
 }
 
+static void
+gst_wayland_sink_render_last_sample (GstWaylandSink * sink)
+{
+  GstSample *last_sample = NULL;
+  GstBuffer *last_buffer = NULL;
+  FUNCTION;
+  g_return_if_fail (sink != NULL);
+
+  g_object_get (G_OBJECT (sink), "last-sample", &last_sample, NULL);
+  if (last_sample) {
+    last_buffer = gst_sample_get_buffer (last_sample);
+    if (last_buffer) {
+      GST_LOG ("PAUSED state : last buffer %p", last_buffer);
+      gst_buffer_ref (last_buffer);
+      gst_wayland_sink_render (GST_BASE_SINK (sink), last_buffer);
+      gst_buffer_unref (last_buffer);
+      last_buffer = NULL;
+    }
+    gst_sample_unref (last_sample);
+    last_sample = NULL;
+  }
+}
+
 #endif
 
 static void
@@ -1026,9 +1049,28 @@ gst_wayland_sink_set_property (GObject * object,
     case PROP_SIGNAL_HANDOFFS:
       sink->signal_handoffs = g_value_get_boolean (value);
       GST_LOG ("set signal_handoffs(%d)", sink->signal_handoffs);
-      if (sink->signal_handoffs && sink->window) {
-        /* overlay -> hand-off */
-        gst_wayland_sink_stop_video (sink);
+      if (sink->window) {
+        if (sink->signal_handoffs) {
+          /* overlay -> hand-off */
+          if (GST_STATE (sink) == GST_STATE_PAUSED) {
+            /* check if the prerolled buffer has been rendered in GST_STATE_PAUSED */
+            if (sink->last_buffer) {
+              GST_LOG ("g_signal_emit: preroll-handoff");
+              g_signal_emit (sink,
+                  gst_waylandsink_signals[SIGNAL_PREROLL_HANDOFF], 0,
+                  sink->last_buffer, GST_BASE_SINK (object)->sinkpad);
+            }
+          }
+          gst_wayland_sink_stop_video (sink);
+        } else {
+          if (GST_STATE (sink) == GST_STATE_PAUSED) {
+            g_mutex_unlock (&sink->render_lock);
+            /* scenario: inline video mode->paused->fullscreen mode->signal_handoffs(0)
+               we need to update preroll buffer on wayland surface */
+            gst_wayland_sink_render_last_sample (sink);
+            g_mutex_lock (&sink->render_lock);
+          }
+        }
       }
       break;
     case PROP_KEEP_CAMERA_PREVIEW: