waylandsink : Apply get_time function to inform start and end for basesink buffer... 84/116784/4 accepted/tizen/3.0/common/20170302.075727 accepted/tizen/3.0/ivi/20170302.034441 accepted/tizen/3.0/mobile/20170302.034058 accepted/tizen/3.0/tv/20170302.034224 accepted/tizen/3.0/wearable/20170302.034346 submit/tizen_3.0/20170228.102611
authorHyunil <hyunil46.park@samsung.com>
Tue, 28 Feb 2017 05:48:06 +0000 (14:48 +0900)
committerHyunil Park <hyunil46.park@samsung.com>
Tue, 28 Feb 2017 08:32:32 +0000 (00:32 -0800)
Change-Id: I604b46e38ebb04ff5e0c93052809f27023ba950e
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
(cherry picked from commit 625dcb6a50ef365d40de16ec0c22a02708e77521)

ext/wayland/gstwaylandsink.c
ext/wayland/gstwaylandsink.h
ext/wayland/wlshmallocator.c

index dd33d64e3b8849a92d9c48a9fc23b0ec27aec832..ec3dff5b8c11bd128bce2d20a16d3e810590d58e 100755 (executable)
@@ -232,6 +232,8 @@ static void gst_wayland_sink_begin_geometry_change (GstWaylandVideo * video);
 static void gst_wayland_sink_end_geometry_change (GstWaylandVideo * video);
 #ifdef TIZEN_FEATURE_WLSINK_ENHANCEMENT
 static gboolean gst_wayland_sink_event (GstBaseSink * bsink, GstEvent * event);
+static void gst_wayland_sink_get_times (GstBaseSink * bsink, GstBuffer * buf,
+    GstClockTime * start, GstClockTime * end);
 static void gst_wayland_sink_update_window_geometry (GstWaylandSink * sink);
 static void render_last_buffer (GstWaylandSink * sink);
 
@@ -283,6 +285,7 @@ gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
   gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_wayland_sink_render);
 #ifdef TIZEN_FEATURE_WLSINK_ENHANCEMENT
   gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_wayland_sink_event);
+  gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_wayland_sink_get_times);
 #endif
 
   g_object_class_install_property (gobject_class, PROP_DISPLAY,
@@ -1284,6 +1287,29 @@ gst_wayland_sink_event (GstBaseSink * bsink, GstEvent * event)
   }
   return GST_BASE_SINK_CLASS (parent_class)->event (bsink, event);
 }
+
+static void
+gst_wayland_sink_get_times (GstBaseSink * bsink, GstBuffer * buf,
+    GstClockTime * start, GstClockTime * end)
+{
+  /* If basesink need to drop buffer, basesink ask waylandsink to start and end */
+  GstWaylandSink *sink;
+
+  sink = GST_WAYLAND_SINK (bsink);
+
+  if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
+    *start = GST_BUFFER_TIMESTAMP (buf);
+    if (GST_BUFFER_DURATION_IS_VALID (buf)) {
+      *end = *start + GST_BUFFER_DURATION (buf);
+    } else {
+      if (sink->fps_n > 0) {
+        *end =
+            *start + gst_util_uint64_scale_int (GST_SECOND, sink->fps_d,
+            sink->fps_n);
+      }
+    }
+  }
+}
 #endif
 
 /* must be called with the display_lock */
@@ -1637,7 +1663,6 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
     }
   }
 #else /* open source */
-
   formats = sink->display->formats;
   for (i = 0; i < formats->len; i++) {
     if (g_array_index (formats, uint32_t, i) == format)
@@ -1648,6 +1673,10 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
     goto unsupported_format;
 
 #ifdef TIZEN_FEATURE_WLSINK_ENHANCEMENT
+  /* init frame rate for baseink */
+  sink->fps_n = info.fps_n;
+  sink->fps_d = info.fps_d;
+
   /* init value for set source */
   sink->crop_x = sink->crop_y = sink->crop_w = sink->crop_h = 0;
 
@@ -1708,12 +1737,12 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
     gst_object_replace ((GstObject **) & sink->pool, (GstObject *) newpool);
     gst_object_unref (newpool);
   }
-#ifdef TIZEN_FEATURE_WLSINK_ENHANCEMENT
+
   sink->is_native_format = sink->display->is_native_format;
 
   if (sink->window)
     gst_wayland_sink_update_window_geometry (sink);
-#endif
+
 
 #else /*open source */
   /* create a new pool for the new configuration */
index 07060af7d7c4c4d009b17ac1deab123ff50f2519..1864329a8e926ded0bc46268573cb8c89416b67c 100644 (file)
@@ -82,6 +82,10 @@ struct _GstWaylandSink
   GstBuffer *last_buffer;
 
 #ifdef TIZEN_FEATURE_WLSINK_ENHANCEMENT
+  /* Framerate numerator and denominator */
+  gint fps_n;
+  gint fps_d;
+
   gboolean dump_video;
   gboolean signal_handoffs;
   gboolean request_camera_flush_buf;
index 27e61a6df7a261abd7200cf1c6572532dcb4b82b..3dc1ba8a9326dc51ec7804e6cc47924fc440cf3d 100644 (file)
@@ -108,7 +108,7 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size,
 
     self->display->tbm_bo[idx] =
         tbm_bo_alloc (self->display->tbm_bufmgr, size, TBM_BO_DEFAULT);
-    if (!self->display->tbm_bo[idx]) {
+    if (G_UNLIKELY (!self->display->tbm_bo[idx])) {
       GST_ERROR_OBJECT (self, "alloc tbm bo(size:%d) failed: %s", size,
           strerror (errno));
       return FALSE;
@@ -117,7 +117,7 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size,
     virtual_addr.ptr = NULL;
     virtual_addr =
         tbm_bo_get_handle (self->display->tbm_bo[idx], TBM_DEVICE_CPU);
-    if (!virtual_addr.ptr) {
+    if (G_UNLIKELY (!virtual_addr.ptr)) {
       GST_ERROR_OBJECT (self, "get tbm bo handle failed: %s", strerror (errno));
       tbm_bo_unref (self->display->tbm_bo[idx]);
       self->display->tbm_bo[idx] = NULL;