[MMFMWK-7883]Update for gplay not set video-sink by default

- Combine gstimxcommon.c into gstimxcommon.h
- Move gstimxcommon.h into gst-plugins-base
- Add gstimx.h for not common function header
- Update overlaysink, using "video-direction" property for master display
- Update imxv4l2sink, using "video-direction" property instead of "rotate"
- in gplay not set default video-sink

 Signed-off-by: Lyon Wang <lyon.wang@nxp.com>
diff --git a/libs/Makefile.am b/libs/Makefile.am
index 3e46aeb..aaf0a94 100755
--- a/libs/Makefile.am
+++ b/libs/Makefile.am
@@ -1,7 +1,6 @@
 lib_LTLIBRARIES = libgstfsl-@GST_API_VERSION@.la
 
 libgstfsl_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/imx-mm/
-libgstfsl_@GST_API_VERSION@include_HEADERS = gstimxcommon.h
 
 if USE_V4L2_CORE
 V4L2_CORE_SOURCE = v4l2_core/gstimxv4l2.c
diff --git a/libs/device-2d/imx_2d_device.h b/libs/device-2d/imx_2d_device.h
index cbea3fd..ba030d9 100755
--- a/libs/device-2d/imx_2d_device.h
+++ b/libs/device-2d/imx_2d_device.h
@@ -22,6 +22,7 @@
 
 #include <gst/video/video.h>
 #include "gstimxcommon.h"
+#include "gstimx.h"
 #include "imx_2d_device_allocator.h"
 
 #define ALIGNMENT (16)
diff --git a/libs/gstimx.h b/libs/gstimx.h
new file mode 100644
index 0000000..de318a0
--- /dev/null
+++ b/libs/gstimx.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2018 NXP
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __IMX_H__
+#define __IMX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+unsigned long phy_addr_from_fd(int dmafd);
+unsigned long phy_addr_from_vaddr(void *vaddr, int size);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __IMX_H__ */
diff --git a/libs/gstimxcommon.c b/libs/gstimxcommon.c
old mode 100755
new mode 100644
index 9f891ba..e1a81c7
--- a/libs/gstimxcommon.c
+++ b/libs/gstimxcommon.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016, Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2017 NXP
+ * Copyright 2017,2018 NXP
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -19,259 +19,13 @@
  */
 
 #include "gstimxcommon.h"
+#include "gstimx.h"
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #ifdef USE_ION
 #include <linux/ion.h>
 #endif
-
-/* define rotate and flip glib enum for overlaysink and imxv4l2sink */
-static const GEnumValue rotate_methods[] = {
-  {GST_IMX_ROTATION_0, "no rotation", "none"},
-  {GST_IMX_ROTATION_90, "Rotate clockwise 90 degrees", "rotate-90"},
-  {GST_IMX_ROTATION_180, "Rotate clockwise 180 degrees", "rotate-180"},
-  {GST_IMX_ROTATION_270, "Rotate clockwise 270 degrees", "rotate-270"},
-  {GST_IMX_ROTATION_HFLIP, "Flip horizontally", "horizontal-flip"},
-  {GST_IMX_ROTATION_VFLIP, "Flip vertically", "vertically-flip"},
-  {0, NULL, NULL}
-};
-
-GType
-gst_imx_rotate_method_get_type()
-{
-  static GType rotate_method_type = 0;
-  static volatile gsize once = 0;
-
-  if (g_once_init_enter (&once)) {
-    rotate_method_type = g_enum_register_static ("GstImxRotateMethod",
-        rotate_methods);
-    g_once_init_leave (&once, rotate_method_type);
-  }
-
-  return rotate_method_type;
-}
-
-/*=============================================================================
-FUNCTION:               get_chipname
-
-DESCRIPTION:            To get chipname from /proc/cpuinfo
-
-ARGUMENTS PASSED: STR of chipname
-
-RETURN VALUE:            chip code
-=============================================================================*/
-//*
-
-static CPU_INFO cpu_info[] = {
-  {CC_MX23, 0x23},
-  {CC_MX25, 0x25},
-  {CC_MX27, 0x27},
-  {CC_MX28, 0x28},
-  {CC_MX31, 0x31},
-  {CC_MX35, 0x35},
-  {CC_MX37, 0x37},
-  {CC_MX50, 0x50},
-  {CC_MX51, 0x51},
-  {CC_MX53, 0x53},
-  {CC_MX6Q, 0x61},
-  {CC_MX6Q, 0x63},
-  {CC_MX60, 0x60}
-};
-
-CHIP_CODE getChipCodeFromCpuinfo (void)
-{
-  FILE *fp = NULL;
-  char buf[100], *p, *rev;
-  char chip_name[3];
-  int len = 0, i;
-  int chip_num = -1;
-  CHIP_CODE cc = CC_UNKN;
-  fp = fopen ("/proc/cpuinfo", "r");
-  if (fp == NULL) {
-    return cc;
-  }
-  while (!feof (fp)) {
-    p = fgets (buf, 100, fp);
-    p = strstr (buf, "Revision");
-    if (p != NULL) {
-      rev = index (p, ':');
-      if (rev != NULL) {
-        rev++;
-        chip_num = strtoul (rev, NULL, 16);
-        chip_num >>= 12;
-        break;
-      }
-    }
-  }
-
-  fclose (fp);
-
-  if (chip_num < 0) {
-    return cc;
-  }
-
-  int num = sizeof(cpu_info) / sizeof(CPU_INFO);
-  for(i=0; i<num; i++) {
-    if(chip_num == cpu_info[i].chip_num) {
-      cc = cpu_info[i].code;
-      break;
-    }
-  }
-
-  return cc;
-}
-
-static SOC_INFO soc_info[] = {
-  {CC_MX23, "i.MX23"},
-  {CC_MX25, "i.MX25"},
-  {CC_MX27, "i.MX27"},
-  {CC_MX28, "i.MX28"},
-  {CC_MX31, "i.MX31"},
-  {CC_MX35, "i.MX35"},
-  {CC_MX37, "i.MX37"},
-  {CC_MX50, "i.MX50"},
-  {CC_MX51, "i.MX51"},
-  {CC_MX53, "i.MX53"},
-  {CC_MX6Q, "i.MX6DL"},
-  {CC_MX6Q, "i.MX6Q"},
-  {CC_MX6Q, "i.MX6QP"},
-  {CC_MX6SL, "i.MX6SL"},
-  {CC_MX6SLL, "i.MX6SLL"},
-  {CC_MX6SX, "i.MX6SX"},
-  {CC_MX6UL, "i.MX6UL"},
-  {CC_MX6UL, "i.MX6ULL"},
-  {CC_MX7D, "i.MX7D"},
-  {CC_MX7ULP, "i.MX7ULP"},
-  {CC_MX8, "i.MX8DV"},
-  {CC_MX8QM, "i.MX8QM"},
-  {CC_MX8QXP, "i.MX8QXP"},
-  {CC_MX8M, "i.MX8MQ"},
-};
-
-CHIP_CODE getChipCodeFromSocid (void)
-{
-  FILE *fp = NULL;
-  char soc_name[100];
-  CHIP_CODE code = CC_UNKN;
-
-  fp = fopen("/sys/devices/soc0/soc_id", "r");
-  if (fp == NULL) {
-    g_print("open /sys/devices/soc0/soc_id failed.\n");
-    return  CC_UNKN;
-  }
-
-  if (fscanf(fp, "%100s", soc_name) != 1) {
-    g_print("fscanf soc_id failed.\n");
-    fclose(fp);
-    return CC_UNKN;
-  }
-  fclose(fp);
-
-  //GST_INFO("SOC is %s\n", soc_name);
-
-  int num = sizeof(soc_info) / sizeof(SOC_INFO);
-  int i;
-  for(i=0; i<num; i++) {
-    if(!strcmp(soc_name, soc_info[i].name)) {
-      code = soc_info[i].code;
-      break;
-    }
-  }
-
-  return code;
-}
-
-
-#define KERN_VER(a, b, c) (((a) << 16) + ((b) << 8) + (c))
-
-static CHIP_CODE gimx_chip_code = CC_UNKN;
-
-CHIP_CODE imx_chip_code (void)
-{
-  struct utsname sys_name;
-  int kv, kv_major, kv_minor, kv_rel;
-  char soc_name[255];
-  int rev_major, rev_minor;
-  int idx, num;
-
-  if (gimx_chip_code != CC_UNKN)
-    return gimx_chip_code;
-
-  if (uname(&sys_name) < 0) {
-    g_print("get kernel version via uname failed.\n");
-    return CC_UNKN;
-  }
-
-  if (sscanf(sys_name.release, "%d.%d.%d", &kv_major, &kv_minor, &kv_rel) != 3) {
-    g_print("sscanf kernel version failed.\n");
-    return CC_UNKN;
-  }
-
-  kv = ((kv_major << 16) + (kv_minor << 8) + kv_rel);
-  //GST_INFO("kernel:%s, %d.%d.%d\n", sys_name.release, kv_major, kv_minor, kv_rel);
-
-  if (kv < KERN_VER(3, 10, 0))
-    gimx_chip_code = getChipCodeFromCpuinfo();
-  else
-    gimx_chip_code = getChipCodeFromSocid();
-
-  return gimx_chip_code;
-}
-
-static IMXV4l2FeatureMap g_imxv4l2feature_maps[] = {
-  /* chip_name, g3d, g2d, ipu, pxp, vpu, dpu, dcss*/
-  {CC_MX6Q, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE},
-  {CC_MX6SL, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE},
-  {CC_MX6SLL, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE},
-  {CC_MX6SX, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE},
-  {CC_MX6UL, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE},
-  {CC_MX7D, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE},
-  {CC_MX7ULP, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
-  {CC_MX8, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE},
-  {CC_MX8QM, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE},
-  {CC_MX8QXP, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE},
-  {CC_MX8M, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE},
-};
-
-
-gboolean check_feature(CHIP_CODE chip_name, CHIP_FEATURE feature)
-{
-  int i;
-  gboolean ret = FALSE;
-  for (i=0; i<sizeof(g_imxv4l2feature_maps)/sizeof(IMXV4l2FeatureMap); i++) {
-    if ( chip_name== g_imxv4l2feature_maps[i].chip_name) {
-      switch (feature) {
-        case G3D:
-          ret = g_imxv4l2feature_maps[i].g3d;
-          break;
-        case G2D:
-          ret = g_imxv4l2feature_maps[i].g2d;
-          break;
-        case IPU:
-          ret = g_imxv4l2feature_maps[i].ipu;
-          break;
-        case PXP:
-          ret = g_imxv4l2feature_maps[i].pxp;
-          break;
-        case VPU:
-          ret = g_imxv4l2feature_maps[i].vpu;
-          break;
-        case DPU:
-          ret = g_imxv4l2feature_maps[i].dpu;
-          break;
-        case DCSS:
-          ret = g_imxv4l2feature_maps[i].dcss;
-          break;
-        default:
-          break;
-      }
-      break;
-    }
-  }
-  return ret;
-}
-
 const char *dev_ion = "/dev/ion";
 
 unsigned long phy_addr_from_fd(int dmafd)
diff --git a/libs/gstimxcommon.h b/libs/gstimxcommon.h
deleted file mode 100755
index 828acb1..0000000
--- a/libs/gstimxcommon.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2013-2016, Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2017 NXP
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __IMX_COMMON_H__
-#define __IMX_COMMON_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/utsname.h>
-#include <gst/gst.h>
-#include <string.h>
-
-#define IMX_GST_PLUGIN_AUTHOR "Multimedia Team <shmmmw@freescale.com>"
-#define IMX_GST_PLUGIN_PACKAGE_NAME "Freescle Gstreamer Multimedia Plugins"
-#define IMX_GST_PLUGIN_PACKAGE_ORIG "http://www.freescale.com"
-#define IMX_GST_PLUGIN_LICENSE "LGPL"
-
-#define IMX_GST_PLUGIN_RANK (GST_RANK_PRIMARY+1)
-
-#define IMX_GST_PLUGIN_DEFINE(name, description, initfunc)\
-  GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,\
-      GST_VERSION_MINOR,\
-      name.imx,\
-      description,\
-      initfunc,\
-      VERSION,\
-      IMX_GST_PLUGIN_LICENSE,\
-      IMX_GST_PLUGIN_PACKAGE_NAME, IMX_GST_PLUGIN_PACKAGE_ORIG)
-
-#define CHIPCODE(a,b,c,d)( (((unsigned int)((a)))<<24) | (((unsigned int)((b)))<<16)|(((unsigned int)((c)))<<8)|(((unsigned int)((d)))))
-typedef enum
-{
-  CC_MX23 = CHIPCODE ('M', 'X', '2', '3'),
-  CC_MX25 = CHIPCODE ('M', 'X', '2', '5'),
-  CC_MX27 = CHIPCODE ('M', 'X', '2', '7'),
-  CC_MX28 = CHIPCODE ('M', 'X', '2', '8'),
-  CC_MX31 = CHIPCODE ('M', 'X', '3', '1'),
-  CC_MX35 = CHIPCODE ('M', 'X', '3', '5'),
-  CC_MX37 = CHIPCODE ('M', 'X', '3', '7'),
-  CC_MX50 = CHIPCODE ('M', 'X', '5', '0'),
-  CC_MX51 = CHIPCODE ('M', 'X', '5', '1'),
-  CC_MX53 = CHIPCODE ('M', 'X', '5', '3'),
-  CC_MX6Q = CHIPCODE ('M', 'X', '6', 'Q'),
-  CC_MX60 = CHIPCODE ('M', 'X', '6', '0'),
-  CC_MX6SL = CHIPCODE ('M', 'X', '6', '1'),
-  CC_MX6SX = CHIPCODE ('M', 'X', '6', '2'),
-  CC_MX6UL = CHIPCODE ('M', 'X', '6', '3'),
-  CC_MX6SLL = CHIPCODE ('M', 'X', '6', '4'),
-  CC_MX7D = CHIPCODE ('M', 'X', '7', 'D'),
-  CC_MX7ULP = CHIPCODE ('M', 'X', '7', 'U'),
-  CC_MX8 = CHIPCODE ('M', 'X', '8', '0'),
-  CC_MX8QM = CHIPCODE ('M', 'X', '8', '1'),
-  CC_MX8QXP = CHIPCODE ('M', 'X', '8', '3'),
-  CC_MX8M = CHIPCODE ('M', 'X', '8', '2'),
-  CC_UNKN = CHIPCODE ('U', 'N', 'K', 'N')
-
-} CHIP_CODE;
-
-typedef struct {
-  CHIP_CODE code;
-  int chip_num;
-} CPU_INFO;
-
-typedef struct {
-  CHIP_CODE code;
-  char *name;
-} SOC_INFO;
-
-typedef struct {
-  CHIP_CODE chip_name;
-  gboolean g3d;
-  gboolean g2d;
-  gboolean ipu;
-  gboolean pxp;
-  gboolean vpu;
-  gboolean dpu;
-  gboolean dcss;
-} IMXV4l2FeatureMap;
-
-typedef enum {
-  G3D = 1,
-  G2D,
-  IPU,
-  PXP,
-  VPU,
-  DPU,
-  DCSS
-} CHIP_FEATURE;
-
-CHIP_CODE getChipCodeFromCpuinfo (void);
-CHIP_CODE getChipCodeFromSocid (void);
-CHIP_CODE imx_chip_code (void);
-gboolean check_feature(CHIP_CODE chip_name, CHIP_FEATURE feature);
-
-#define HAS_G3D() check_feature(imx_chip_code(), G3D)
-#define HAS_G2D() check_feature(imx_chip_code(), G2D)
-#define HAS_IPU() check_feature(imx_chip_code(), IPU)
-#define HAS_PXP() check_feature(imx_chip_code(), PXP)
-#define HAS_VPU() check_feature(imx_chip_code(), VPU)
-#define HAS_DPU() check_feature(imx_chip_code(), DPU)
-#define HAS_DCSS() check_feature(imx_chip_code(), DCSS)
-
-#define IS_HANTRO() (CC_MX8M == imx_chip_code())
-#define IS_AMPHION() (CC_MX8QXP == imx_chip_code())
-
-/* define rotate and flip glib enum for overlaysink and imxv4l2sink */
-typedef enum
-{
-  GST_IMX_ROTATION_0 = 0,
-  GST_IMX_ROTATION_90,
-  GST_IMX_ROTATION_180,
-  GST_IMX_ROTATION_270,
-  GST_IMX_ROTATION_HFLIP,
-  GST_IMX_ROTATION_VFLIP
-}GstImxRotateMethod;
-
-GType gst_imx_rotate_method_get_type();
-
-#define DEFAULT_IMX_ROTATE_METHOD GST_IMX_ROTATION_0
-#define GST_TYPE_IMX_ROTATE_METHOD (gst_imx_rotate_method_get_type())
-
-unsigned long phy_addr_from_fd(int dmafd);
-unsigned long phy_addr_from_vaddr(void *vaddr, int size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __IMX_COMMON_H__ */ 
diff --git a/plugins/fbdevsink/gstimxfbdevsink.c b/plugins/fbdevsink/gstimxfbdevsink.c
index 956d56b..60482aa 100644
--- a/plugins/fbdevsink/gstimxfbdevsink.c
+++ b/plugins/fbdevsink/gstimxfbdevsink.c
@@ -41,6 +41,7 @@
 
 #include "gstimxfbdevsink.h"
 #include "gstimxcommon.h"
+#include "gstimx.h"
 #include "gstimxvideooverlay.h"
 
 GST_DEBUG_CATEGORY (imx_fbdevsink_debug);
diff --git a/plugins/overlay_sink/gstosink.c b/plugins/overlay_sink/gstosink.c
index af7f704..f14b4ae 100755
--- a/plugins/overlay_sink/gstosink.c
+++ b/plugins/overlay_sink/gstosink.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. All rights reserved.
+ * Copyright 2018 NXP
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -44,6 +45,7 @@
 {
   OVERLAY_SINK_PROP_0,
   OVERLAY_SINK_PROP_COMPOSITION_META_ENABLE,
+  OVERLAY_SINK_PROP_VIDEO_DIRECTION,
   OVERLAY_SINK_PROP_DISP_ON_0,
   OVERLAY_SINK_PROP_DISPWIN_X_0,
   OVERLAY_SINK_PROP_DISPWIN_Y_0,
@@ -59,6 +61,35 @@
 #define OVERLAY_SINK_PROP_DISP_LENGTH (OVERLAY_SINK_PROP_DISP_MAX_0-OVERLAY_SINK_PROP_DISP_ON_0)
 #define OVERLAY_SINK_COMPOMETA_DEFAULT     TRUE
 
+#define DEFAULT_IMX_ROTATE_METHOD GST_IMX_ROTATION_0
+#define GST_TYPE_IMX_ROTATE_METHOD (gst_imx_rotate_method_get_type())
+
+static const GEnumValue rotate_methods[] = {
+  {GST_IMX_ROTATION_0, "no rotation", "none"},
+  {GST_IMX_ROTATION_90, "Rotate clockwise 90 degrees", "rotate-90"},
+  {GST_IMX_ROTATION_180, "Rotate clockwise 180 degrees", "rotate-180"},
+  {GST_IMX_ROTATION_270, "Rotate clockwise 270 degrees", "rotate-270"},
+  {GST_IMX_ROTATION_HFLIP, "Flip horizontally", "horizontal-flip"},
+  {GST_IMX_ROTATION_VFLIP, "Flip vertically", "vertically-flip"},
+  {0, NULL, NULL}
+};
+
+GType
+gst_imx_rotate_method_get_type()
+{
+  static GType rotate_method_type = 0;
+  static volatile gsize once = 0;
+
+  if (g_once_init_enter (&once)) {
+    rotate_method_type = g_enum_register_static ("GstImxRotateMethod",
+        rotate_methods);
+    g_once_init_leave (&once, rotate_method_type);
+  }
+
+  return rotate_method_type;
+}
+
+
 static GstFlowReturn
 gst_overlay_sink_show_frame (GstBaseSink * bsink, GstBuffer * buffer);
 
@@ -97,10 +128,20 @@
     osink_object_set_color_key(osink->osink_obj, 0, enable, color_key);
 }
 
+static void
+gst_overlay_sink_video_direction_interface_init (GstVideoDirectionInterface *
+    iface)
+{
+  /* We implement the video-direction property */
+}
+
 #define gst_overlay_sink_parent_class parent_class
+
 G_DEFINE_TYPE_WITH_CODE (GstOverlaySink, gst_overlay_sink, GST_TYPE_VIDEO_SINK,
     G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY,
-        gst_overlay_sink_video_overlay_interface_init));
+        gst_overlay_sink_video_overlay_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_DIRECTION,
+        gst_overlay_sink_video_direction_interface_init));
 
 //G_DEFINE_TYPE (GstOverlaySink, gst_overlay_sink, GST_TYPE_VIDEO_SINK);
 
@@ -143,7 +184,10 @@
     sink->composition_meta_enable = g_value_get_boolean(value);
     return;
   }
-
+  if (prop_id == OVERLAY_SINK_PROP_VIDEO_DIRECTION) {
+    sink->overlay[0].rot = g_value_get_enum (value);
+    return;
+  }
   idx = (prop_id - OVERLAY_SINK_PROP_DISP_ON_0) / OVERLAY_SINK_PROP_DISP_LENGTH;
   prop = prop_id - idx * OVERLAY_SINK_PROP_DISP_LENGTH;
   switch (prop) {
@@ -199,7 +243,10 @@
     g_value_set_boolean(value, sink->composition_meta_enable);
     return;
   }
-
+  if (prop_id == OVERLAY_SINK_PROP_VIDEO_DIRECTION) {
+     g_value_set_enum (value, sink->overlay[0].rot);
+     return;
+  }
   idx = (prop_id - OVERLAY_SINK_PROP_DISP_ON_0) / OVERLAY_SINK_PROP_DISP_LENGTH;
   prop = prop_id - idx * OVERLAY_SINK_PROP_DISP_LENGTH;
   switch (prop) {
@@ -986,15 +1033,20 @@
     g_free (prop_name);
     prop++;
 
-    if (i == 0)
-      prop_name = g_strdup_printf ("rotate");
-    else
+
+    if (i == 0) {
+      prop_name = g_strdup_printf("video-direction");
+      g_object_class_override_property (gobject_class, OVERLAY_SINK_PROP_VIDEO_DIRECTION, "video-direction");
+
+    }
+    else {
       prop_name = g_strdup_printf ("rotate-%d", i);
-    g_object_class_install_property (gobject_class, prop,
+      g_object_class_install_property (gobject_class, prop,
         g_param_spec_enum (prop_name,
           prop_name,
           "get/set the rotation of the video", GST_TYPE_IMX_ROTATE_METHOD, DEFAULT_IMX_ROTATE_METHOD,
           G_PARAM_READWRITE));
+    }
     g_free (prop_name);
     prop++;
 
diff --git a/plugins/v4l2/gstimxv4l2sink.c b/plugins/v4l2/gstimxv4l2sink.c
index b34d6b1..df43b89 100755
--- a/plugins/v4l2/gstimxv4l2sink.c
+++ b/plugins/v4l2/gstimxv4l2sink.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2013-2015, Freescale Semiconductor, Inc. All rights reserved.
+ * Copyright 2018 NXP
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -47,12 +48,12 @@
   PROP_CROP_LEFT,
   PROP_CROP_WIDTH,
   PROP_CROP_HEIGHT,
-  PROP_ROTATE,
   PROP_KEEP_VIDEO_RATIO,
   PROP_DEINTERLACE_ENABLE,
   PROP_DEINTERLACE_MOTION,
   PROP_CONFIG,
-  PROP_COMPOSITION_META_ENABLE
+  PROP_COMPOSITION_META_ENABLE,
+  PROP_VIDEO_DIRECTION,
 };
 
 enum {
@@ -92,10 +93,19 @@
     gst_imx_v4l2out_config_color_key(v4l2sink->v4l2handle, enable, color_key);
 }
 
+static void
+gst_imx_v4l2sink_video_direction_interface_init (GstVideoDirectionInterface *
+    iface)
+{
+  /* We implement the video-direction property */
+}
+
 #define gst_imx_v4l2sink_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstImxV4l2Sink, gst_imx_v4l2sink, GST_TYPE_VIDEO_SINK,
     G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY,
-                       gst_imx_v4l2sink_video_overlay_interface_init));
+                       gst_imx_v4l2sink_video_overlay_interface_init);
+    G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_DIRECTION,
+        gst_imx_v4l2sink_video_direction_interface_init));
 
 //G_DEFINE_TYPE (GstImxV4l2Sink, gst_imx_v4l2sink, GST_TYPE_VIDEO_SINK);
 
@@ -144,7 +154,7 @@
       v4l2sink->crop.height = g_value_get_uint (value);
       v4l2sink->config_flag |= CONFIG_CROP;
       break;
-    case PROP_ROTATE:
+    case PROP_VIDEO_DIRECTION:
       v4l2sink->rotate = g_value_get_enum (value);
       v4l2sink->config_flag |= CONFIG_ROTATE;
       break;
@@ -204,7 +214,7 @@
     case PROP_CROP_HEIGHT:
       g_value_set_uint (value, v4l2sink->crop.height);
       break;
-    case PROP_ROTATE:
+    case PROP_VIDEO_DIRECTION:
       g_value_set_enum (value, v4l2sink->rotate);
       break;
     case PROP_KEEP_VIDEO_RATIO:
@@ -1010,11 +1020,6 @@
         "The height of the video crop; default is equal to negotiated image height",
         0, G_MAXINT, 0, G_PARAM_READWRITE));
 
-  g_object_class_install_property (gobject_class, PROP_ROTATE,
-      g_param_spec_enum ("rotate", "Rotate",
-        "The orientation degree of the video; default is 0 degree",
-        GST_TYPE_IMX_ROTATE_METHOD, DEFAULT_IMX_ROTATE_METHOD, G_PARAM_READWRITE));
-
   g_object_class_install_property (gobject_class, PROP_KEEP_VIDEO_RATIO,
       g_param_spec_boolean ("force-aspect-ratio", "Force aspect ratio",
         "When enabled, scaling will respect original aspect ratio",
@@ -1044,6 +1049,9 @@
         TRUE,
         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+    g_object_class_override_property (gobject_class, PROP_VIDEO_DIRECTION,
+      "video-direction");
+
   return;
 }
 
diff --git a/tools/gplay2/gplay2.c b/tools/gplay2/gplay2.c
index 5b5363c..1c0e930 100755
--- a/tools/gplay2/gplay2.c
+++ b/tools/gplay2/gplay2.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 2014-2016 Freescale Semiconductor, Inc.
- * Copyright 2017 NXP
+ * Copyright 2017, 2018 NXP
  *
  */
 
@@ -35,11 +35,11 @@
 #include <signal.h>
 #include <unistd.h>
 #include <errno.h>
+#include <gstimxcommon.h>
 
 #include <gst/player/player.h>
 
 #include "playlist.h"
-#include "../../libs/gstimxcommon.h"
 
 #include <fcntl.h>
 #include <linux/fb.h>
@@ -1512,26 +1512,18 @@
     options.timeout = DEFAULT_TIME_OUT;
   }
 
-  if (!options.video_sink_name)
-    if (gplay_checkfeature (G2D)) {
-      options.video_sink_name = "overlaysink";
-      if (gplay_checkfeature (DPU)) {
-        if (gplay_checkfeature (VPU)) 
-          options.video_sink_name = "kmssink";
-        else
-          options.video_sink_name = "glimagesink";
-      }
-    } else {
-      options.video_sink_name = "imxv4l2sink";
-      if (gplay_checkfeature (DCSS))
-        options.video_sink_name = "kmssink";
-    }
-  g_print ("Set VideoSink %s \n", options.video_sink_name);
-  video_sink =
-      gst_parse_bin_from_description (options.video_sink_name, TRUE, NULL);
 
-  VideoRender =
-      gst_player_video_overlay_video_renderer_new_with_sink (NULL, video_sink);
+    if (!options.video_sink_name) {
+      VideoRender =
+        gst_player_video_overlay_video_renderer_new (NULL);
+    } else {
+      g_print ("Set VideoSink %s \n", options.video_sink_name);
+      video_sink =
+          gst_parse_bin_from_description (options.video_sink_name, TRUE, NULL);
+      VideoRender =
+        gst_player_video_overlay_video_renderer_new_with_sink (NULL, video_sink);
+    }
+
   VideoOverlayVideoRenderer =
       GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (VideoRender);