waylandsink : Apply get_time function to inform start and end for basesink buffer... 49/116749/2
authorHyunil <hyunil46.park@samsung.com>
Tue, 28 Feb 2017 05:48:06 +0000 (14:48 +0900)
committerHyunil <hyunil46.park@samsung.com>
Tue, 28 Feb 2017 07:02:42 +0000 (16:02 +0900)
Change-Id: I604b46e38ebb04ff5e0c93052809f27023ba950e
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c
ext/wayland/gstwaylandsink.h
ext/wayland/wlshmallocator.c

index dd33d64..ec3dff5 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 07060af..1864329 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 27e61a6..3dc1ba8 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;