waylandsink : 1. modify dump api for native format 59/120359/3 accepted/tizen_common accepted/tizen_ivi accepted/tizen_mobile accepted/tizen_tv accepted/tizen_wearable accepted/tizen/common/20170404.142345 accepted/tizen/ivi/20170403.130032 accepted/tizen/mobile/20170403.125629 accepted/tizen/tv/20170403.125829 accepted/tizen/unified/20170403.130124 accepted/tizen/wearable/20170403.125919 submit/tizen/20170403.050513
authorHyunil <hyunil46.park@samsung.com>
Wed, 22 Mar 2017 11:26:40 +0000 (20:26 +0900)
committerHyunil <hyunil46.park@samsung.com>
Thu, 23 Mar 2017 08:01:37 +0000 (17:01 +0900)
              2. add SR32, S420 to sink_template

Change-Id: I6fe9157386c0567067dfe4ae18b7ecbf0079afb9
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c
ext/wayland/wlshmallocator.c

index dac33a6..c334780 100755 (executable)
@@ -187,7 +187,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
         ("{ BGRx, BGRA, RGBx, xBGR, xRGB, RGBA, ABGR, ARGB, RGB, BGR, "
             "RGB16, BGR16, YUY2, YVYU, UYVY, AYUV, NV12, NV21, NV16, "
 #ifdef TIZEN_FEATURE_WLSINK_ENHANCEMENT
-            "SN12, ST12, "
+            "SN12, ST12, SR32, S420,"
 #endif
             "YUV9, YVU9, Y41B, I420, YV12, Y42B, v308 }"))
     );
@@ -489,8 +489,10 @@ gst_wayland_sink_dump_raw_video (GstWaylandSink * sink, GstBuffer * buffer,
   g_return_if_fail (sink != NULL);
   g_return_if_fail (buffer != NULL);
 
-  if (dump_count > dump_total)
+  if (dump_count > dump_total) {
+    sink->dump_video = FALSE;
     return;
+  }
 
   size = GST_VIDEO_INFO_SIZE (&sink->video_info);
   mem = gst_buffer_peek_memory (buffer, 0);
@@ -685,6 +687,7 @@ gst_wayland_sink_make_flush_buffer (GstWlDisplay * display,
     if (mm_video_buf->handle.bo[i] != NULL) {
       tbm_bo_handle src;
       tbm_bo_handle dst;
+      gchar err_str[256];
 
       /* get bo size */
       bo_size = tbm_bo_size (mm_video_buf->handle.bo[i]);
@@ -692,8 +695,9 @@ gst_wayland_sink_make_flush_buffer (GstWlDisplay * display,
       /* alloc bo */
       bo = tbm_bo_alloc (display->flush_tbm_bufmgr, bo_size, TBM_DEVICE_CPU);
       if (G_UNLIKELY (!bo)) {
-        GST_ERROR ("alloc tbm bo(size:%d) failed: %s", bo_size,
-            strerror (errno));
+        strerror_r (errno, err_str, sizeof (err_str));
+        GST_ERROR ("alloc tbm bo(size:%d) failed: %s(%d)", bo_size, err_str,
+            errno);
         return FALSE;
       }
       GST_LOG ("flush buffer tbm_bo =(%p)", bo);
@@ -706,8 +710,9 @@ gst_wayland_sink_make_flush_buffer (GstWlDisplay * display,
           TBM_OPTION_READ);
       dst = tbm_bo_map (bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
       if (G_UNLIKELY ((!src.ptr || !dst.ptr))) {
-        GST_ERROR ("get tbm bo handle failed src(%p) dst(%p): %s", src.ptr,
-            dst.ptr, strerror (errno));
+        strerror_r (errno, err_str, sizeof (err_str));
+        GST_ERROR ("get tbm bo handle failed src(%p) dst(%p): %s(%d)", src.ptr,
+            dst.ptr, err_str, errno);
         if (src.ptr)
           tbm_bo_unmap (mm_video_buf->handle.bo[i]);
         if (dst.ptr)
index f5f7510..e6a8bd4 100644 (file)
@@ -55,7 +55,7 @@ gst_wl_fwrite_data (gchar * file, gpointer data, guint size)
 }
 
 static void
-gst_wl_tbm_dump_native_raw_video (gpointer bo, guint size, guint dump_count,
+gst_wl_tbm_dump_normal_raw_video (gpointer bo, guint size, guint dump_count,
     guint dump_total)
 {
   tbm_bo_handle virtual_addr;
@@ -64,13 +64,10 @@ gst_wl_tbm_dump_native_raw_video (gpointer bo, guint size, guint dump_count,
   gchar err_str[256];
   g_return_if_fail (bo != NULL);
 
-  if (dump_count > dump_total)
-    return;
-
   virtual_addr = tbm_bo_get_handle (bo, TBM_DEVICE_CPU);
   if (!virtual_addr.ptr) {
     strerror_r (errno, err_str, sizeof (err_str));
-    GST_ERROR ("get tbm bo handle failed: %s (%d)", err_str, (errno));
+    GST_ERROR ("get tbm bo handle failed: %s(%d)", err_str, errno);
     return;
   }
 
@@ -83,6 +80,68 @@ gst_wl_tbm_dump_native_raw_video (gpointer bo, guint size, guint dump_count,
 
 }
 
+static void
+gst_wl_tbm_dump_native_raw_video (GstWlDisplay * display, guint dump_count)
+{
+  gchar file_name[128];
+  gchar err_str[256];
+  FILE *fp;
+  tbm_bo_handle virtual_addr;
+  gchar *data;
+  int i;
+  g_return_if_fail (display != NULL);
+
+  if (dump_count > display->total_dump) {
+    display->dump_video = FALSE;
+    return;
+  }
+  /* get virtual addr with bo and TBM_DEVICD_CPU */
+  virtual_addr = tbm_bo_get_handle (display->bo[0], TBM_DEVICE_CPU);
+  if (!virtual_addr.ptr) {
+    strerror_r (errno, err_str, sizeof (err_str));
+    GST_ERROR ("get tbm bo handle failed: %s(%d)", err_str, errno);
+    return;
+  }
+
+  snprintf (file_name, sizeof (file_name), "/tmp/WLSINK_OUT_DUMP_%2.2d.dump",
+      dump_count);
+
+  fp = fopen (file_name, "wb");
+  if (fp == NULL)
+    return;
+  data = (gchar *) virtual_addr.ptr;
+
+  /* Y */
+  for (i = 0; i < display->height[0]; i++) {
+    fwrite (data, display->width[0], 1, fp);
+    data += display->stride_width[0];
+  }
+
+  if (display->bo[1] == NULL) {
+    /* sprd */
+    data = (gchar *) virtual_addr.ptr +
+        (display->stride_width[0] * display->stride_height[0]);
+    GST_LOG ("UV: virtual_addr.ptr(%p)", data);
+  } else {
+    /* omx */
+    virtual_addr = tbm_bo_get_handle (display->bo[1], TBM_DEVICE_CPU);
+    if (!virtual_addr.ptr) {
+      strerror_r (errno, err_str, sizeof (err_str));
+      GST_ERROR ("get tbm bo handle failed: %s(%d)", err_str, errno);
+      return;
+    }
+    data = (gchar *) virtual_addr.ptr;
+  }
+
+  /* UV */
+  for (i = 0; i < display->height[1]; i++) {
+    fwrite (data, display->width[1], 1, fp);
+    data += display->stride_width[1];
+  }
+
+  fclose (fp);
+}
+
 static GstMemory *
 gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size,
     GstAllocationParams * params)
@@ -94,6 +153,7 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size,
   int idx;
   gpointer data;
   GstWlShmMemory *mem;
+  gchar err_str[256];
   FUNCTION;
 
 #ifdef TIZEN_FEATURE_WLSINK_ENHANCEMENT
@@ -109,8 +169,9 @@ 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 (G_UNLIKELY (!self->display->tbm_bo[idx])) {
-      GST_ERROR_OBJECT (self, "alloc tbm bo(size:%d) failed: %s", size,
-          strerror (errno));
+      strerror_r (errno, err_str, sizeof (err_str));
+      GST_ERROR_OBJECT (self, "alloc tbm bo(size:%d) failed: %s(%d)", size,
+          err_str, errno);
       return FALSE;
     }
     GST_LOG ("display->tbm_bo[%d]=(%p)", idx, self->display->tbm_bo[idx]);
@@ -118,7 +179,9 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size,
     virtual_addr =
         tbm_bo_get_handle (self->display->tbm_bo[idx], TBM_DEVICE_CPU);
     if (G_UNLIKELY (!virtual_addr.ptr)) {
-      GST_ERROR_OBJECT (self, "get tbm bo handle failed: %s", strerror (errno));
+      strerror_r (errno, err_str, sizeof (err_str));
+      GST_ERROR_OBJECT (self, "get tbm bo handle failed: %s(%d)", err_str,
+          errno);
       tbm_bo_unref (self->display->tbm_bo[idx]);
       self->display->tbm_bo[idx] = NULL;
       self->display->tbm_bo_idx--;
@@ -298,10 +361,8 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display,
 
     if (display->is_native_format == TRUE) {
       /* In case of native format, use MMVideoBuffer data instead of GstVideoInfo */
-      size = display->native_video_size;
       if (display->dump_video)
-        gst_wl_tbm_dump_native_raw_video (display->bo[0], size,
-            display->dump_count++, display->total_dump);
+        gst_wl_tbm_dump_native_raw_video (display, display->dump_count++);
 
       width = display->width[0];
       height = display->height[0];
@@ -351,9 +412,12 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display,
       GST_DEBUG_OBJECT (mem->allocator, "Creating wl_buffer of size %"
           G_GSSIZE_FORMAT " (%d x %d, stride %d)", size, width, height, stride);
 
-      if (display->dump_video)
-        gst_wl_tbm_dump_native_raw_video (shm_mem->tbm_bo_ptr, size,
+      if (display->dump_video) {
+        gst_wl_tbm_dump_normal_raw_video (shm_mem->tbm_bo_ptr, size,
             display->dump_count++, display->total_dump);
+        if (display->dump_count > display->total_dump)
+          display->dump_video = FALSE;
+      }
 
       ts_info.width = width;
       ts_info.height = height;