Waylandsink : Add rotate, display_geometry_method, orientation and flip property 30/47130/4 accepted/tizen/mobile/20150902.101408 accepted/tizen/tv/20150902.101424 accepted/tizen/wearable/20150902.101437 submit/tizen/20150902.072927
authorHyunil <hyunil46.park@samsung.com>
Mon, 31 Aug 2015 05:40:40 +0000 (14:40 +0900)
committerHyunil <hyunil46.park@samsung.com>
Wed, 2 Sep 2015 07:25:55 +0000 (16:25 +0900)
Change-Id: I7478aca24d468ed2e14e8d7e31566c0748fb102f
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c
ext/wayland/gstwaylandsink.h
ext/wayland/waylandpool.c
ext/wayland/wldisplay.h
ext/wayland/wlwindow.c
ext/wayland/wlwindow.h

index c8d4a61..5d3eca6 100755 (executable)
 #include <gst/wayland/wayland.h>
 #include <gst/video/videooverlay.h>
 
+#ifdef GST_WLSINK_ENHANCEMENT
+#define GST_TYPE_WAYLANDSINK_DISPLAY_GEOMETRY_METHOD (gst_waylandsink_display_geometry_method_get_type())
+#define GST_TYPE_WAYLANDSINK_ROTATE_ANGLE (gst_waylandsink_rotate_angle_get_type())
+#define GST_TYPE_WAYLANDSINK_FLIP (gst_waylandsink_flip_get_type())
+
+static GType
+gst_waylandsink_rotate_angle_get_type (void)
+{
+  static GType waylandsink_rotate_angle_type = 0;
+  static const GEnumValue rotate_angle_type[] = {
+    {0, "No rotate", "DEGREE_0"},
+    {1, "Rotate 90 degree", "DEGREE_90"},
+    {2, "Rotate 180 degree", "DEGREE_180"},
+    {3, "Rotate 270 degree", "DEGREE_270"},
+    {4, NULL, NULL},
+  };
+
+  if (!waylandsink_rotate_angle_type) {
+    waylandsink_rotate_angle_type =
+        g_enum_register_static ("GstWaylandSinkRotateAngleType",
+        rotate_angle_type);
+  }
+
+  return waylandsink_rotate_angle_type;
+}
+
+
+static GType
+gst_waylandsink_display_geometry_method_get_type (void)
+{
+  static GType waylandsink_display_geometry_method_type = 0;
+  static const GEnumValue display_geometry_method_type[] = {
+    {0, "Letter box", "LETTER_BOX"},
+    {1, "Origin size", "ORIGIN_SIZE"},
+    {2, "Full-screen", "FULL_SCREEN"},
+    {3, "Cropped full-screen", "CROPPED_FULL_SCREEN"},
+    {4, "Origin size(if screen size is larger than video size(width/height)) or Letter box(if video size(width/height) is larger than screen size)", "ORIGIN_SIZE_OR_LETTER_BOX"},
+    {5, NULL, NULL},
+  };
+
+  if (!waylandsink_display_geometry_method_type) {
+    waylandsink_display_geometry_method_type =
+        g_enum_register_static ("GstWaylandSinkDisplayGeometryMethodType",
+        display_geometry_method_type);
+  }
+  return waylandsink_display_geometry_method_type;
+}
+
+static GType
+gst_waylandsink_flip_get_type (void)
+{
+  static GType waylandsink_flip_type = 0;
+  static const GEnumValue flip_type[] = {
+    {FLIP_NONE, "Flip NONE", "FLIP_NONE"},
+    {FLIP_HORIZONTAL, "Flip HORIZONTAL", "FLIP_HORIZONTAL"},
+    {FLIP_VERTICAL, "Flip VERTICAL", "FLIP_VERTICAL"},
+    {FLIP_BOTH, "Flip BOTH", "FLIP_BOTH"},
+    {FLIP_NUM, NULL, NULL},
+  };
+
+  if (!waylandsink_flip_type) {
+    waylandsink_flip_type =
+        g_enum_register_static ("GstWaylandSinkFlipType", flip_type);
+  }
+
+  return waylandsink_flip_type;
+}
+
+#endif
+
+
 /* signals */
 enum
 {
@@ -64,7 +135,13 @@ enum
 enum
 {
   PROP_0,
-  PROP_DISPLAY
+  PROP_DISPLAY,
+#ifdef GST_WLSINK_ENHANCEMENT
+  PROP_ROTATE_ANGLE,
+  PROP_DISPLAY_GEOMETRY_METHOD,
+  PROP_ORIENTATION,
+  PROP_FLIP
+#endif
 };
 
 GST_DEBUG_CATEGORY (gstwayland_debug);
@@ -117,6 +194,9 @@ static void gst_wayland_sink_waylandvideo_init (GstWaylandVideoInterface *
     iface);
 static void gst_wayland_sink_begin_geometry_change (GstWaylandVideo * video);
 static void gst_wayland_sink_end_geometry_change (GstWaylandVideo * video);
+#ifdef GST_WLSINK_ENHANCEMENT
+static void gst_wayland_sink_update_window_geometry (GstWaylandSink * sink);
+#endif
 
 #define gst_wayland_sink_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstWaylandSink, gst_wayland_sink, GST_TYPE_VIDEO_SINK,
@@ -166,12 +246,46 @@ gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
       g_param_spec_string ("display", "Wayland Display name", "Wayland "
           "display name to connect to, if not supplied via the GstContext",
           NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#ifdef GST_WLSINK_ENHANCEMENT
+  g_object_class_install_property (gobject_class, PROP_ROTATE_ANGLE,
+      g_param_spec_enum ("rotate", "Rotate angle",
+          "Rotate angle of display output",
+          GST_TYPE_WAYLANDSINK_ROTATE_ANGLE, DEGREE_0,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class, PROP_DISPLAY_GEOMETRY_METHOD,
+      g_param_spec_enum ("display-geometry-method", "Display geometry method",
+          "Geometrical method for display",
+          GST_TYPE_WAYLANDSINK_DISPLAY_GEOMETRY_METHOD,
+          DEF_DISPLAY_GEOMETRY_METHOD,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class, PROP_ORIENTATION,
+      g_param_spec_enum ("orientation",
+          "Orientation information used for ROI/ZOOM",
+          "Orientation information for display",
+          GST_TYPE_WAYLANDSINK_ROTATE_ANGLE, DEGREE_0,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class, PROP_FLIP,
+      g_param_spec_enum ("flip", "Display flip",
+          "Flip for display",
+          GST_TYPE_WAYLANDSINK_FLIP, DEF_DISPLAY_FLIP,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+#endif
 }
 
 static void
 gst_wayland_sink_init (GstWaylandSink * sink)
 {
   FUNCTION_ENTER ();
+
+  sink->display_geometry_method = DEF_DISPLAY_GEOMETRY_METHOD;
+  sink->flip = DEF_DISPLAY_FLIP;
+  sink->rotate_angle = DEGREE_0;
+  sink->orientation = DEGREE_0;
+
   g_mutex_init (&sink->display_lock);
   g_mutex_init (&sink->render_lock);
 }
@@ -189,6 +303,20 @@ gst_wayland_sink_get_property (GObject * object,
       g_value_set_string (value, sink->display_name);
       GST_OBJECT_UNLOCK (sink);
       break;
+#ifdef GST_WLSINK_ENHANCEMENT
+    case PROP_ROTATE_ANGLE:
+      g_value_set_enum (value, sink->rotate_angle);
+      break;
+    case PROP_DISPLAY_GEOMETRY_METHOD:
+      g_value_set_enum (value, sink->display_geometry_method);
+      break;
+    case PROP_ORIENTATION:
+      g_value_set_enum (value, sink->orientation);
+      break;
+    case PROP_FLIP:
+      g_value_set_enum (value, sink->flip);
+      break;
+#endif
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -208,6 +336,53 @@ gst_wayland_sink_set_property (GObject * object,
       sink->display_name = g_value_dup_string (value);
       GST_OBJECT_UNLOCK (sink);
       break;
+#ifdef GST_WLSINK_ENHANCEMENT
+    case PROP_ROTATE_ANGLE:
+      sink->rotate_angle = g_value_get_enum (value);
+      GST_INFO_OBJECT (sink, "Rotate angle is set (%d)", sink->rotate_angle);
+      if (sink->window) {
+        gst_wl_window_set_rotate_angle (sink->window, sink->rotate_angle);
+      }
+      sink->video_info_changed = TRUE;
+      if (GST_STATE (sink) == GST_STATE_PAUSED) {
+        /*need to render current buffer*/
+      }
+      break;
+    case PROP_DISPLAY_GEOMETRY_METHOD:
+      sink->display_geometry_method = g_value_get_enum (value);
+      GST_INFO_OBJECT (sink, "Display geometry method is set (%d)",
+          sink->display_geometry_method);
+      if (sink->window) {
+        gst_wl_window_set_disp_geo_method (sink->window, sink->display_geometry_method);
+      }
+      sink->video_info_changed = TRUE;
+      if (GST_STATE (sink) == GST_STATE_PAUSED) {
+        /*need to render current buffer*/
+      }
+      break;
+    case PROP_ORIENTATION:
+      sink->orientation = g_value_get_enum (value);
+      GST_INFO_OBJECT (sink, "Orientation is set (%d)", sink->orientation);
+      if (sink->window) {
+        gst_wl_window_set_orientation (sink->window, sink->orientation);
+      }
+      sink->video_info_changed = TRUE;
+      if (GST_STATE (sink) == GST_STATE_PAUSED) {
+        /*need to render current buffer*/
+      }
+      break;
+    case PROP_FLIP:
+      sink->flip = g_value_get_enum (value);
+      GST_INFO_OBJECT (sink, "flip is set (%d)", sink->flip);
+      if (sink->flip) {
+        gst_wl_window_set_flip (sink->window, sink->flip);
+      }
+      sink->video_info_changed = TRUE;
+      if (GST_STATE (sink) == GST_STATE_PAUSED) {
+        /*need to render current buffer*/
+      }
+      break;
+#endif
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -784,7 +959,12 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
       sink->window =
           gst_wl_window_new_toplevel (sink->display, &sink->video_info);
     }
+#ifdef GST_WLSINK_ENHANCEMENT
+    gst_wayland_sink_update_window_geometry (sink);
+    sink->video_info_changed = TRUE;
+#else
     sink->video_info_changed = FALSE;
+#endif
   }
 
   /* drop buffers until we get a frame callback */
@@ -931,7 +1111,7 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
   if (buffer != to_render) {
     GST_LOG_OBJECT (sink, "Decrease ref count of buffer");
     gst_buffer_unref (to_render);
- }
 }
   goto done;
 
 no_window_size:
@@ -1018,10 +1198,28 @@ 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);
 }
 
+#ifdef GST_WLSINK_ENHANCEMENT
+static void
+gst_wayland_sink_update_window_geometry (GstWaylandSink * sink)
+{
+  FUNCTION_ENTER ();
+
+  if (sink == NULL || sink->window == NULL)
+    return;
+
+  gst_wl_window_set_rotate_angle (sink->window, sink->rotate_angle);
+  gst_wl_window_set_disp_geo_method (sink->window, sink->display_geometry_method);
+  gst_wl_window_set_orientation (sink->window, sink->orientation);
+  gst_wl_window_set_flip (sink->window, sink->flip);
+}
+#endif
 static void
 gst_wayland_sink_set_render_rectangle (GstVideoOverlay * overlay,
     gint x, gint y, gint w, gint h)
index 2c37f0b..ee7eb0b 100755 (executable)
@@ -43,6 +43,42 @@ G_BEGIN_DECLS
            (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WAYLAND_SINK))
 #define GST_WAYLAND_SINK_GET_CLASS(inst) \
         (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_WAYLAND_SINK, GstWaylandSinkClass))
+#ifdef GST_WLSINK_ENHANCEMENT
+    enum
+{
+  DISP_GEO_METHOD_LETTER_BOX = 0,
+  DISP_GEO_METHOD_ORIGIN_SIZE,
+  DISP_GEO_METHOD_FULL_SCREEN,
+  DISP_GEO_METHOD_CROPPED_FULL_SCREEN,
+  DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX,
+  DISP_GEO_METHOD_NUM,
+};
+
+enum
+{
+  DEGREE_0,
+  DEGREE_90,
+  DEGREE_180,
+  DEGREE_270,
+  DEGREE_NUM,
+};
+
+enum
+{
+  FLIP_NONE = 0,
+  FLIP_HORIZONTAL,
+  FLIP_VERTICAL,
+  FLIP_BOTH,
+  FLIP_NUM,
+};
+
+#define DEF_DISPLAY_FLIP            FLIP_NONE
+#define DEF_DISPLAY_GEOMETRY_METHOD         DISP_GEO_METHOD_FULL_SCREEN
+
+#define WL_SCREEN_SIZE_WIDTH 4096
+#define WL_SCREEN_SIZE_HEIGHT 4096
+
+#endif
 #if 1
 #define FUNCTION_ENTER()       GST_INFO("<ENTER>")
 #else
@@ -63,8 +99,13 @@ struct _GstWaylandSink
   gboolean video_info_changed;
   GstVideoInfo video_info;
 
+  /*property */
   gchar *display_name;
 #ifdef GST_WLSINK_ENHANCEMENT
+  guint rotate_angle;
+  guint display_geometry_method;
+  guint orientation;
+  guint flip;
   GstCaps *caps;
 #endif
   gboolean redraw_pending;
index 9e2b73a..1d33332 100755 (executable)
@@ -205,7 +205,7 @@ gst_wayland_compositor_acquire_buffer (GstWaylandBufferPool * self,
   g_return_if_fail (meta->used_by_compositor == FALSE);
 
   meta->used_by_compositor = TRUE;
-  GST_LOG_OBJECT(self, "Increase ref count of buffer");
+  GST_LOG_OBJECT (self, "Increase ref count of buffer");
   gst_buffer_ref (buffer);
 }
 
@@ -562,13 +562,13 @@ gst_wayland_tizen_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
 #ifdef DUMP_BUFFER
     int ret;
     char file_name[128];
-       if (dump_cnt < 10) {
-         sprintf (file_name, "/root/WLSINK_OUT_DUMP_%2.2d.dump", dump_cnt++);
-      ret = _write_rawdata (file_name, vitual_addr.ptr,size);
+    if (dump_cnt < 10) {
+      sprintf (file_name, "/root/WLSINK_OUT_DUMP_%2.2d.dump", dump_cnt++);
+      ret = _write_rawdata (file_name, vitual_addr.ptr, size);
       if (ret) {
         GST_ERROR_OBJECT (pool, "_write_rawdata() failed");
       }
-       }
+    }
 #endif
     /* create buffer and its metadata object */
     *buffer = gst_buffer_new ();
@@ -590,9 +590,9 @@ gst_wayland_tizen_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
     }
 
     meta->wbuffer =
-        tizen_buffer_pool_create_planar_buffer (self->display->
-        tizen_buffer_pool, width, height, format, name[0], offset[0], stride[0],
-        name[1], offset[1], stride[1], 0, 0, 0);
+        tizen_buffer_pool_create_planar_buffer (self->
+        display->tizen_buffer_pool, width, height, format, name[0], offset[0],
+        stride[0], name[1], offset[1], stride[1], 0, 0, 0);
     meta->used_by_compositor = FALSE;
 
     GST_DEBUG ("tizen_buffer_pool_create_planar_buffer create wl_buffer %p",
@@ -664,8 +664,8 @@ gst_wayland_tizen_buffer_pool_finalize (GObject * object)
   if (pool->display->tizen_buffer_pool) {
     gst_wayland_tizen_buffer_pool_stop (GST_BUFFER_POOL (pool));
   } else {
-    /*already stop*/
-       return;
+    /*already stop */
+    return;
   }
   g_mutex_clear (&pool->buffers_map_mutex);
   g_hash_table_unref (pool->buffers_map);
index b3ca67c..587350a 100755 (executable)
@@ -80,7 +80,7 @@ struct _GstWlDisplay
   tbm_bufmgr tbm_bufmgr;
   tbm_bo tbm_bo;
 
-  gboolean is_native_format;   /*SN12, ST12 */
+  gboolean is_native_format;    /*SN12, ST12 */
   void *bo[NV_BUF_PLANE_NUM];
   int plane_size[NV_BUF_PLANE_NUM];
   int stride_width[NV_BUF_PLANE_NUM];
index 149e98a..8769335 100755 (executable)
 #endif
 
 #include "wlwindow.h"
+#ifdef GST_WLSINK_ENHANCEMENT
+#include "gstwaylandsink.h"
+#define SWAP(a, b) { (a) ^= (b) ^= (a) ^= (b); }
+#endif
 
 GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug);
 #define GST_CAT_DEFAULT gstwayland_debug
@@ -220,15 +224,181 @@ gst_wl_window_resize_internal (GstWlWindow * window, gboolean commit)
   FUNCTION_ENTER ();
 
   GstVideoRectangle src = { 0, };
-  GstVideoRectangle res;
+  GstVideoRectangle res;        //dst
 
   src.w = window->video_width;
   src.h = window->video_height;
-  gst_video_sink_center_rect (src, window->render_rectangle, &res, TRUE);
+#ifdef GST_WLSINK_ENHANCEMENT   // need to change ifndef to ifdef
+
+  GstVideoRectangle src_origin = { 0, 0, 0, 0 };
+  GstVideoRectangle src_input = { 0, 0, 0, 0 };
+  GstVideoRectangle dst = { 0, 0, 0, 0 };
+
+  gint rotate = 0;
+  gint transform = WL_OUTPUT_TRANSFORM_NORMAL;
+
+  src.x = src.y = 0;
+  src_input.w = src_origin.w = window->video_width;
+  src_input.h = src_origin.h = window->video_height;
+  GST_INFO ("video (%d x %d)", window->video_width, window->video_height);
+  GST_INFO ("src_input(%d, %d, %d x %d)", src_input.x, src_input.y, src_input.w,
+      src_input.h);
+  GST_INFO ("src_origin(%d, %d, %d x %d)", src_origin.x, src_origin.y,
+      src_origin.w, src_origin.h);
+
+  if (window->rotate_angle == DEGREE_0 || window->rotate_angle == DEGREE_180) {
+    src.w = window->video_width;        //video_width
+    src.h = window->video_height;       //video_height
+  } else {
+    src.w = window->video_height;
+    src.h = window->video_width;
+  }
+  GST_INFO ("src(%d, %d, %d x %d)", src.x, src.y, src.w, src.h);
+
+  /*default res.w and res.h */
+  dst.w = window->render_rectangle.w;
+  dst.h = window->render_rectangle.h;
+  GST_INFO ("dst(%d,%d,%d x %d)", dst.x, dst.y, dst.w, dst.h);
+  GST_INFO ("window->render_rectangle(%d,%d,%d x %d)",
+      window->render_rectangle.x, window->render_rectangle.y,
+      window->render_rectangle.w, window->render_rectangle.h);
+  switch (window->disp_geo_method) {
+    case DISP_GEO_METHOD_LETTER_BOX:
+      GST_INFO ("DISP_GEO_METHOD_LETTER_BOX");
+      gst_video_sink_center_rect (src, dst, &res, TRUE);
+      gst_video_sink_center_rect (dst, src, &src_input, FALSE);
+      res.x += window->render_rectangle.x;
+      res.y += window->render_rectangle.y;
+      break;
+    case DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX:
+      if (src.w > dst.w || src.h > dst.h) {
+        /*LETTER BOX */
+        GST_INFO
+            ("DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX -> set LETTER BOX");
+        gst_video_sink_center_rect (src, dst, &res, TRUE);
+        gst_video_sink_center_rect (dst, src, &src_input, FALSE);
+        res.x += window->render_rectangle.x;
+        res.y += window->render_rectangle.y;
+      } else {
+        /*ORIGIN SIZE */
+        GST_INFO ("DISP_GEO_METHOD_ORIGIN_SIZE");
+        gst_video_sink_center_rect (src, dst, &res, FALSE);
+        gst_video_sink_center_rect (dst, src, &src_input, FALSE);
+      }
+      break;
+    case DISP_GEO_METHOD_ORIGIN_SIZE:  //is working
+      GST_INFO ("DISP_GEO_METHOD_ORIGIN_SIZE");
+      gst_video_sink_center_rect (src, dst, &res, FALSE);
+      gst_video_sink_center_rect (dst, src, &src_input, FALSE);
+      break;
+    case DISP_GEO_METHOD_FULL_SCREEN:  //is working
+      GST_INFO ("DISP_GEO_METHOD_FULL_SCREEN");
+      res.x = res.y = 0;
+      res.w = window->render_rectangle.w;
+      res.h = window->render_rectangle.h;
+      break;
+    case DISP_GEO_METHOD_CROPPED_FULL_SCREEN:
+      GST_INFO ("DISP_GEO_METHOD_CROPPED_FULL_SCREEN");
+      gst_video_sink_center_rect (src, dst, &res, FALSE);
+      gst_video_sink_center_rect (dst, src, &src_input, FALSE);
+      res.x = res.y = 0;
+      res.w = dst.w;
+      res.h = dst.h;
+      break;
+    default:
+      break;
+  }
+
+  switch (window->rotate_angle) {
+    case DEGREE_0:
+      transform = WL_OUTPUT_TRANSFORM_NORMAL;
+      break;
+    case DEGREE_90:
+      transform = WL_OUTPUT_TRANSFORM_90;
+      break;
+    case DEGREE_180:
+      transform = WL_OUTPUT_TRANSFORM_180;
+      break;
+    case DEGREE_270:
+      transform = WL_OUTPUT_TRANSFORM_270;
+      break;
+
+    default:
+      GST_ERROR ("Unsupported rotation [%d]... set DEGREE 0.",
+          window->rotate_angle);
+      break;
+  }
+
+  switch (window->flip) {
+    case FLIP_NONE:
+      break;
+    case FLIP_VERTICAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED;
+      break;
+    case FLIP_HORIZONTAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
+      break;
+    case FLIP_BOTH:
+      transform = WL_OUTPUT_TRANSFORM_180;
+      break;
+    default:
+      GST_ERROR ("Unsupported flip [%d]... set FLIP_NONE.", window->flip);
+  }
+
+  GST_INFO
+      ("window[%d x %d] src[%d,%d,%d x %d],dst[%d,%d,%d x %d],input[%d,%d,%d x %d],result[%d,%d,%d x %d]",
+      window->render_rectangle.w, window->render_rectangle.h,
+      src.x, src.y, src.w, src.h,
+      dst.x, dst.y, dst.w, dst.h,
+      src_input.x, src_input.y, src_input.w, src_input.h,
+      res.x, res.y, res.w, res.h);
+
+  GST_INFO ("video (%d x %d)", window->video_width, window->video_height);
+  GST_INFO ("src_input(%d, %d, %d x %d)", src_input.x, src_input.y, src_input.w,
+      src_input.h);
+  GST_INFO ("src_origin(%d, %d, %d x %d)", src_origin.x, src_origin.y,
+      src_origin.w, src_origin.h);
+  GST_INFO ("src(%d, %d, %d x %d)", src.x, src.y, src.w, src.h);
+  GST_INFO ("dst(%d,%d,%d x %d)", dst.x, dst.y, dst.w, dst.h);
+  GST_INFO ("window->render_rectangle(%d,%d,%d x %d)",
+      window->render_rectangle.x, window->render_rectangle.y,
+      window->render_rectangle.w, window->render_rectangle.h);
+  GST_INFO ("res(%d, %d, %d x %d)", res.x, res.y, res.w, res.h);
+
+  if (window->subsurface) {
+    GST_INFO ("have window->subsurface");
+    wl_subsurface_set_position (window->subsurface,
+        window->render_rectangle.x + res.x, window->render_rectangle.y + res.y);
+    GST_INFO ("wl_subsurface_set_position(%d,%d)",
+        window->render_rectangle.x + res.x, window->render_rectangle.y + res.y);
+  }
+  wl_viewport_set_destination (window->viewport, res.w, res.h);
+  GST_INFO ("wl_viewport_set_destination(%d,%d)", res.w, res.h);
+
+  wl_viewport_set_source (window->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);
+
+  wl_surface_set_buffer_transform (window->surface, transform);
+  GST_INFO ("wl_surface_set_buffer_transform (%d)", transform);
+
+  if (commit) {
+    wl_surface_damage (window->surface, 0, 0, res.w, res.h);
+    wl_surface_commit (window->surface);
+  }
+
+  /* this is saved for use in wl_surface_damage */
+  window->surface_width = res.w;
+  window->surface_height = res.h;
 
+#else
+  gst_video_sink_center_rect (src, window->render_rectangle, &res, TRUE);
   if (window->subsurface)
     wl_subsurface_set_position (window->subsurface,
         window->render_rectangle.x + res.x, window->render_rectangle.y + res.y);
+
   wl_viewport_set_destination (window->viewport, res.w, res.h);
 
   if (commit) {
@@ -239,6 +409,7 @@ gst_wl_window_resize_internal (GstWlWindow * window, gboolean commit)
   /* this is saved for use in wl_surface_damage */
   window->surface_width = res.w;
   window->surface_height = res.h;
+#endif
 }
 
 void
@@ -272,3 +443,35 @@ gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
   if (window->video_width != 0)
     gst_wl_window_resize_internal (window, TRUE);
 }
+
+#ifdef GST_WLSINK_ENHANCEMENT
+void gst_wl_window_set_rotate_angle (GstWlWindow * window, guint rotate_angle)
+{
+  FUNCTION_ENTER ();
+  g_return_if_fail (window != NULL);
+  window->rotate_angle = rotate_angle;
+  GST_INFO ("rotate_angle value is (%d)", window->rotate_angle);
+
+}
+void gst_wl_window_set_disp_geo_method (GstWlWindow * window, guint disp_geo_method)
+{
+  FUNCTION_ENTER ();
+  g_return_if_fail (window != NULL);
+  window->disp_geo_method = disp_geo_method;
+  GST_INFO ("disp_geo_method value is (%d)", window->disp_geo_method);
+}
+void gst_wl_window_set_orientation (GstWlWindow * window, guint orientation)
+{
+  FUNCTION_ENTER ();
+  g_return_if_fail (window != NULL);
+  window->orientation = orientation;
+  GST_INFO ("orientation value is (%d)", window->orientation);
+}
+void gst_wl_window_set_flip (GstWlWindow * window, guint flip)
+{
+  FUNCTION_ENTER ();
+  g_return_if_fail (window != NULL);
+  window->flip = flip;
+  GST_INFO ("flip value is (%d)", window->flip);
+}
+#endif
index 6ba058a..38cdc47 100755 (executable)
@@ -55,6 +55,13 @@ struct _GstWlWindow
   gint video_width, video_height;
   /* the size of the (sub)surface */
   gint surface_width, surface_height;
+#ifdef GST_WLSINK_ENHANCEMENT
+  /*Display geometry method */
+  guint disp_geo_method;
+  guint rotate_angle;
+  guint orientation;
+  guint flip;
+#endif
 };
 
 struct _GstWlWindowClass
@@ -78,5 +85,13 @@ void gst_wl_window_set_video_info (GstWlWindow * window, GstVideoInfo * info);
 void gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
     gint w, gint h);
 
+#ifdef GST_WLSINK_ENHANCEMENT
+void gst_wl_window_set_rotate_angle (GstWlWindow * window, guint rotate_angle);
+void gst_wl_window_set_disp_geo_method (GstWlWindow * window, guint disp_geo_method);
+void gst_wl_window_set_orientation (GstWlWindow * window, guint orientation);
+void gst_wl_window_set_flip (GstWlWindow * window, guint flip);
+#endif
+
+
 G_END_DECLS
 #endif /* __GST_WL_WINDOW_H__ */