1. Use wfdtsdemux instead of tsdemux. 78/41478/1 accepted/tizen/mobile/20150617.044428 accepted/tizen/tv/20150617.044439 accepted/tizen/wearable/20150617.044456 submit/tizen/20150617.013118
authorSangkyu Park <sk1122.park@samsung.com>
Tue, 16 Jun 2015 06:58:46 +0000 (15:58 +0900)
committerSangkyu Park <sk1122.park@samsung.com>
Tue, 16 Jun 2015 06:58:50 +0000 (15:58 +0900)
2. Implement pause/resume functions.
3. Fix a prevent defect.
4. Update code by Tizen coding convention.
5. Remove useless comment.
6. Remove unused kernel-headers dependency.

Change-Id: If7dfe71c06c679f76e4fafbaf03e22a5c52adfe2
Signed-off-by: Sangkyu Park <sk1122.park@samsung.com>
15 files changed:
common/include/mm_wfd_attrs.h
common/include/mm_wfd_sink_dlog.h
common/include/mm_wfd_sink_ini.h
common/mm_wfd_attrs.c
common/mm_wfd_sink_ini.c
config/mmfw_wfd_sink.ini
packaging/libmm-wfd.spec [changed mode: 0644->0755]
sink/include/mm_wfd_sink.h
sink/include/mm_wfd_sink_manager.h
sink/include/mm_wfd_sink_priv.h
sink/include/mm_wfd_sink_util.h
sink/mm_wfd_sink.c
sink/mm_wfd_sink_manager.c
sink/mm_wfd_sink_priv.c
sink/mm_wfd_sink_util.c

index 6bbab6e..1c6fc48 100755 (executable)
  * Enumeration for attribute values types.
  */
 typedef enum {
- MM_WFD_ATTRS_TYPE_INVALID = -1,        /**< Type is invalid */
- MM_WFD_ATTRS_TYPE_INT,                 /**< Integer type */
- MM_WFD_ATTRS_TYPE_DOUBLE,              /**< Double type */
- MM_WFD_ATTRS_TYPE_STRING,              /**< UTF-8 String type */
- MM_WFD_ATTRS_TYPE_DATA,                /**< Pointer type */
- MM_WFD_ATTRS_TYPE_ARRAY,               /**< Array type */
- MM_WFD_ATTRS_TYPE_RANGE,               /**< Range type */
- MM_WFD_ATTRS_TYPE_NUM,                 /**< Number of attribute type */
      MM_WFD_ATTRS_TYPE_INVALID = -1,        /**< Type is invalid */
      MM_WFD_ATTRS_TYPE_INT,                 /**< Integer type */
      MM_WFD_ATTRS_TYPE_DOUBLE,              /**< Double type */
      MM_WFD_ATTRS_TYPE_STRING,              /**< UTF-8 String type */
      MM_WFD_ATTRS_TYPE_DATA,                /**< Pointer type */
      MM_WFD_ATTRS_TYPE_ARRAY,               /**< Array type */
      MM_WFD_ATTRS_TYPE_RANGE,               /**< Range type */
      MM_WFD_ATTRS_TYPE_NUM,                 /**< Number of attribute type */
 } MMWfdAttrsType;
 
 /**
  * Enumeration for attribute validation type.
  */
 typedef enum {
- MM_WFD_ATTRS_VALID_TYPE_INVALID = -1,       /**< Invalid validation type */
- MM_WFD_ATTRS_VALID_TYPE_NONE,               /**< Do not check validity */
- MM_WFD_ATTRS_VALID_TYPE_INT_ARRAY,          /**< validity checking type of integer array */
- MM_WFD_ATTRS_VALID_TYPE_INT_RANGE,          /**< validity checking type of integer range */
- MM_WFD_ATTRS_VALID_TYPE_DOUBLE_ARRAY,       /**< validity checking type of double array */
- MM_WFD_ATTRS_VALID_TYPE_DOUBLE_RANGE,       /**< validity checking type of double range */
      MM_WFD_ATTRS_VALID_TYPE_INVALID = -1,       /**< Invalid validation type */
      MM_WFD_ATTRS_VALID_TYPE_NONE,               /**< Do not check validity */
      MM_WFD_ATTRS_VALID_TYPE_INT_ARRAY,          /**< validity checking type of integer array */
      MM_WFD_ATTRS_VALID_TYPE_INT_RANGE,          /**< validity checking type of integer range */
      MM_WFD_ATTRS_VALID_TYPE_DOUBLE_ARRAY,       /**< validity checking type of double array */
      MM_WFD_ATTRS_VALID_TYPE_DOUBLE_RANGE,       /**< validity checking type of double range */
 } MMWfdAttrsValidType;
 
 /**
  * Enumeration for attribute access flag.
  */
 typedef enum {
- MM_WFD_ATTRS_FLAG_NONE = 0,              /**< None flag is set */
- MM_WFD_ATTRS_FLAG_READABLE = 1 << 0,     /**< Readable */
- MM_WFD_ATTRS_FLAG_WRITABLE = 1 << 1,     /**< Writable */
- MM_WFD_ATTRS_FLAG_MODIFIED = 1 << 2,     /**< Modified */
      MM_WFD_ATTRS_FLAG_NONE = 0,              /**< None flag is set */
      MM_WFD_ATTRS_FLAG_READABLE = 1 << 0,     /**< Readable */
      MM_WFD_ATTRS_FLAG_WRITABLE = 1 << 1,     /**< Writable */
      MM_WFD_ATTRS_FLAG_MODIFIED = 1 << 2,     /**< Modified */
 
- MM_WFD_ATTRS_FLAG_RW = MM_WFD_ATTRS_FLAG_READABLE | MM_WFD_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
      MM_WFD_ATTRS_FLAG_RW = MM_WFD_ATTRS_FLAG_READABLE | MM_WFD_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
 } MMWfdAttrsFlag;
 
 /**
  * Attribute validity structure
  */
 typedef struct {
-   MMWfdAttrsType type;
-   MMWfdAttrsValidType validity_type;
-   MMWfdAttrsFlag flag;
-  /**
-    * a union that describes validity of the attribute.
-    * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
-    * the attribute can have validity.
-   */
-   union {
-    /**
-       * Validity structure for integer array.
-     */
-    struct {
-      int *array;  /**< a pointer of array */
-      int count;   /**< size of array */
-      int d_val;
-    } int_array;
-    /**
-       * Validity structure for integer range.
-     */
-    struct {
-      int min;   /**< minimum range */
-      int max;   /**< maximum range */
-      int d_val;
-    } int_range;
-    /**
-    * Validity structure for double array.
-    */
-    struct {
-      double   * array;  /**< a pointer of array */
-      int    count;   /**< size of array */
-      double d_val;
-    } double_array;
-    /**
-    * Validity structure for double range.
-    */
-    struct {
-      double   min;   /**< minimum range */
-      double   max;   /**< maximum range */
-      double d_val;
-    } double_range;
-  };
+       MMWfdAttrsType type;
+       MMWfdAttrsValidType validity_type;
+       MMWfdAttrsFlag flag;
+       /**
+         * a union that describes validity of the attribute.
+         * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
+         * the attribute can have validity.
+        */
+       union {
+               /**
+                  * Validity structure for integer array.
+                */
+               struct {
+                       int *array;  /**< a pointer of array */
+                       int count;   /**< size of array */
+                       int d_val;
+               } int_array;
+               /**
+                  * Validity structure for integer range.
+                */
+               struct {
+                       int min;   /**< minimum range */
+                       int max;   /**< maximum range */
+                       int d_val;
+               } int_range;
+               /**
+               * Validity structure for double array.
+               */
+               struct {
+                       double    *array;  /**< a pointer of array */
+                       int    count;   /**< size of array */
+                       double d_val;
+               } double_array;
+               /**
+               * Validity structure for double range.
+               */
+               struct {
+                       double   min;   /**< minimum range */
+                       double   max;   /**< maximum range */
+                       double d_val;
+               } double_range;
+       };
 } MMWfdAttrsInfo;
 
 MMHandleType _mmwfd_construct_attribute(MMHandleType hwfd);
-void  _mmwfd_deconstruct_attribute( MMHandleType hwfd);
+void  _mmwfd_deconstruct_attribute(MMHandleType hwfd);
 int _mmwfd_set_attribute(MMHandleType hwfd,  char **err_atr_name, const char *attribute_name, va_list args_list);
 int _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMWfdAttrsInfo *dst_info);
 int _mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list);
index 54d7d01..d2880d0 100755 (executable)
@@ -38,52 +38,52 @@ extern "C" {
 #define FONT_COLOR_GRAY     "\033[37m"
 
 #define wfd_sink_debug(fmt, arg...) do { \
-                       LOGD(FONT_COLOR_RESET""fmt"", ##arg);     \
-               } while (0)
+               LOGD(FONT_COLOR_RESET""fmt"", ##arg);     \
+       } while (0)
 
 #define wfd_sink_info(fmt, arg...) do { \
-                       LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg);     \
-               } while (0)
+               LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg);     \
+       } while (0)
 
 #define wfd_sink_error(fmt, arg...) do { \
-                       LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg);     \
-               } while (0)
+               LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg);     \
+       } while (0)
 
 #define wfd_sink_warning(fmt, arg...) do { \
-                       LOGW(FONT_COLOR_YELLOW""fmt""FONT_COLOR_RESET, ##arg);     \
-               } while (0)
+               LOGW(FONT_COLOR_YELLOW""fmt""FONT_COLOR_RESET, ##arg);     \
+       } while (0)
 
 #define wfd_sink_debug_fenter() do { \
-                       LOGD(FONT_COLOR_RESET"<Enter>");     \
-               } while (0)
+               LOGD(FONT_COLOR_RESET"<Enter>");     \
+       } while (0)
 
 #define wfd_sink_debug_fleave() do { \
-                       LOGD(FONT_COLOR_RESET"<Leave>");     \
-               } while (0)
+               LOGD(FONT_COLOR_RESET"<Leave>");     \
+       } while (0)
 
 #define wfd_sink_error_fenter() do { \
-                       LOGE(FONT_COLOR_RESET"NO-ERROR : <Enter>");     \
-               } while (0)
+               LOGE(FONT_COLOR_RESET"NO-ERROR : <Enter>");     \
+       } while (0)
 
 #define wfd_sink_error_fleave() do { \
-                       LOGE(FONT_COLOR_RESET"NO-ERROR : <Leave>");     \
-               } while (0)
+               LOGE(FONT_COLOR_RESET"NO-ERROR : <Leave>");     \
+       } while (0)
 
 #define wfd_sink_sucure_info(fmt, arg...) do { \
-                       SECURE_LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg);     \
-               } while (0)
+               SECURE_LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg);     \
+       } while (0)
 
 #define wfd_sink_return_if_fail(expr)  \
-               if(!(expr)) {   \
-                       wfd_sink_error(FONT_COLOR_RED"failed [%s]\n"FONT_COLOR_RESET, #expr);   \
-                       return; \
-               }
+       if(!(expr)) {   \
+               wfd_sink_error(FONT_COLOR_RED"failed [%s]\n"FONT_COLOR_RESET, #expr);   \
+               return; \
+       }
 
 #define wfd_sink_return_val_if_fail(expr, val) \
-               if (!(expr)) {  \
-                       wfd_sink_error(FONT_COLOR_RED"failed [%s]\n"FONT_COLOR_RESET, #expr);   \
-                       return val; \
-               }
+       if (!(expr)) {  \
+               wfd_sink_error(FONT_COLOR_RED"failed [%s]\n"FONT_COLOR_RESET, #expr);   \
+               return val; \
+       }
 
 #define wfd_sink_assert_not_reached() \
        { \
index 66c6ce8..9115949 100755 (executable)
@@ -27,7 +27,7 @@
 #include <mmf/wfdconfigmessage.h>
 
 #ifdef __cplusplus
-  extern "C" {
+extern "C" {
 #endif
 
 
@@ -52,8 +52,7 @@ enum WFDSinkINIProbeFlags
  * before that time, we should be careful with size limitation
  * of each string item.
  */
-typedef struct __mm_wfd_sink_ini
-{
+typedef struct __mm_wfd_sink_ini {
        /* general */
        gchar gst_param[5][WFD_SINK_INI_MAX_STRLEN];
        gboolean generate_dot;
@@ -113,7 +112,7 @@ typedef struct __mm_wfd_sink_ini
        /* hdcp parameter for reponse of M3 request */
        gint hdcp_content_protection;
        gint hdcp_port_no;
-}mm_wfd_sink_ini_t;
+} mm_wfd_sink_ini_t;
 
 
 /*Default sink ini values*/
@@ -188,8 +187,8 @@ typedef struct __mm_wfd_sink_ini
 " \
 [general]\n\
 ; parameters for initializing gstreamer\n\
-; DEFAULT SET (--gst-debug=2,*wfd*:5)\n\
-gstparam1 = --gst-debug=2,*wfd*:5,*wfdtsdemux:1,*wfdrtpbuffer:1\n\
+; DEFAULT SET(--gst-debug=2, *wfd*:5)\n\
+gstparam1 = --gst-debug=2, *wfd*:5, *wfdtsdemux:1, *wfdrtpbuffer:1\n\
 gstparam2 =\n\
 gstparam3 =\n\
 gstparam4 =\n\
@@ -205,7 +204,7 @@ enable pad probe = no\n\
 ; enable wfdrtspsrc inner pad probe\n\
 enable wfdrtspsrc pad probe = no\n\
 \n\
-; enable ts data dump (/var/tmp/*.ts)\n\
+; enable ts data dump(/var/tmp/*.ts)\n\
 enable ts data dump = no\n\
 \n\
 ; allowed timeout for changing pipeline state\n\
@@ -226,7 +225,7 @@ enable retransmission = yes\n\
 ; for reset basetime, enable = yes, disable = no\n\
 enable reset basetime = yes\n\
 \n\
-; Maximum number of nanoseconds that a buffer can be late before it is dropped by videosink (-1 unlimited)\n\
+; Maximum number of nanoseconds that a buffer can be late before it is dropped by videosink(-1 unlimited)\n\
 video sink max lateness=20000000\n\
 \n\
 ; nanoseconds to be added to buffertimestamp by sink elements\n\
@@ -241,33 +240,29 @@ video sink async=no\n\
 \n\
 \n\
 [pipeline]\n\
-tsdemux element = ffdemux_mpegts\n\
-\n\
-audio hdcp element = drm_hdcp\n\
+tsdemux element = wfdtsdemux\n\
 \n\
-aac parser element =\n\
+aac parser element = aacparse\n\
 \n\
-aac decoder element = omx_tz_aacdec\n\
+aac decoder element = avdec_aac\n\
 \n\
-ac3 parser element = \n\
+ac3 parser element = ac3parse\n\
 \n\
-ac3 decoder element = ;omx_tz_ac3dec\n\
+ac3 decoder element =\n\
 \n\
-lpcm converter element = omx_tz_lpcmdec\n\
+lpcm converter element = audioconvert\n\
 \n\
-lpcm filter element = ;capsfilter\n\
+lpcm filter element = capsfilter\n\
 \n\
-audio resampler element =\n\
+audio resampler element = audioconvert\n\
 \n\
 audio volume element =\n\
 \n\
-audio sink element = alsasink\n\
-\n\
-video hdcp element = drm_hdcp\n\
+audio sink element = pulsesink\n\
 \n\
-video parser element =\n\
+video parser element = h264parse\n\
 \n\
-video decoder element = omx_tz_h264dec\n\
+video decoder element = omxh264dec\n\
 \n\
 video sink element = xvimagesink\n\
 \n\
@@ -335,7 +330,7 @@ int
 mm_wfd_sink_ini_unload(mm_wfd_sink_ini_t *ini);
 
 #ifdef __cplusplus
-  }
+}
 #endif
 
 #endif
index 2fa3215..142bc7a 100755 (executable)
 
 #include "mm_wfd_attrs.h"
 
-typedef struct{
-  char *name;
-  int value_type;
-  int flags;           // r, w
-  void *default_value;
-  int valid_type;      // validity type
-  int value_min;       //<- set validity value range
-  int value_max;       //->
-}MMWfdAttrsSpec;
-
-//static gboolean __mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name);
+typedef struct {
+       char *name;
+       int value_type;
+       int flags;           /* r, w */
+       void *default_value;
+       int valid_type;
+       int value_min;
+       int value_max;
+} MMWfdAttrsSpec;
+
+/*static gboolean __mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name); */
 
 MMHandleType
 _mmwfd_construct_attribute(MMHandleType handle)
 {
-  int idx = 0;
-  MMHandleType attrs = 0;
-  int num_of_attrs = 0;
-  mmf_attrs_construct_info_t *base = NULL;
-
-  debug_fenter();
-
-  return_val_if_fail(handle, (MMHandleType) NULL);
-
-  MMWfdAttrsSpec wfd_attrs[] =
-  {
-    {
-      "server_ip",
-      MM_ATTRS_TYPE_STRING,
-      MM_ATTRS_FLAG_RW,
-      (void *)"127.0.0.1",
-      MM_ATTRS_VALID_TYPE_NONE,
-      0,
-      0
-    },
-
-    {
-      "server_port",
-      MM_ATTRS_TYPE_STRING,
-      MM_ATTRS_FLAG_RW,
-      (void *)"8554",
-      MM_ATTRS_VALID_TYPE_NONE,
-      0,
-      0
-    },
-
-    {
-      "max_client_count",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *)1,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      10
-    },
-    /* Initialized with invalid native type, if a valid value is set then only this atribute will be considered */
-    {
-      "native_resolution",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *)0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      3
-    },
-    /* Initialized with invalid resolution, if a valid value is set then only this atribute will be considered */
-    {
-      "prefered_resolutions",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *)2147483647,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      2147483647
-    },
-    /* Initialized with invalid uibc option, if a valid value is set then only this atribute will be considered */
-    {
-      "set_hdcp",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *)2,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      2
-    },
-    {
-      "display_rotate",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *)0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      3
-    },
-    {
-      "display_src_crop_x",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_src_crop_y",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_src_crop_width",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_src_crop_height",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_roi_x",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_roi_y",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_roi_width",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 480,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_roi_height",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 800,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_roi_mode",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
-      MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
-    },
-    {
-      "display_rotation",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) MM_DISPLAY_ROTATION_NONE,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      MM_DISPLAY_ROTATION_NONE,
-      MM_DISPLAY_ROTATION_270
-    },
-    {
-      "display_visible",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) TRUE,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      1
-    },
-    {
-      "display_method",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) MM_DISPLAY_METHOD_LETTER_BOX,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      MM_DISPLAY_METHOD_LETTER_BOX,
-      MM_DISPLAY_METHOD_CUSTOM_ROI
-    },
-    {
-      "display_overlay",
-      MM_ATTRS_TYPE_DATA,
-      MM_ATTRS_FLAG_RW,
-      (void *) NULL,
-      MM_ATTRS_VALID_TYPE_NONE,
-      0,
-      0
-    },
-    {
-      "display_overlay_user_data",
-      MM_ATTRS_TYPE_DATA,
-      MM_ATTRS_FLAG_RW,
-      (void *) NULL,
-      MM_ATTRS_VALID_TYPE_NONE,
-      0,
-      0
-    },
-    {
-      "display_zoom",
-      MM_ATTRS_TYPE_DOUBLE,
-      MM_ATTRS_FLAG_RW,
-      (void *) 1,
-      MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
-      1.0,
-      9.0
-    },
-    {
-      "display_surface_type",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) MM_DISPLAY_SURFACE_NULL,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      MM_DISPLAY_SURFACE_X,
-      MM_DISPLAY_SURFACE_X_EXT
-    },
-    {
-      "display_width",   // dest width of fimcconvert ouput
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_height",   // dest height of fimcconvert ouput
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_evas_do_scaling",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) TRUE,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      FALSE,
-      TRUE
-    },
-    {
-      "display_x",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "display_y",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      4096
-    },
-    {
-      "hdcp_handle",
-      MM_ATTRS_TYPE_DATA,
-      MM_ATTRS_FLAG_RW,
-      (void *) NULL,
-      MM_ATTRS_VALID_TYPE_NONE,
-      0,
-      0
-    },
-    {
-      "hdcp_version",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      2
-    },
-    {
-      "hdcp_port",
-      MM_ATTRS_TYPE_INT,
-      MM_ATTRS_FLAG_RW,
-      (void *) 0,
-      MM_ATTRS_VALID_TYPE_INT_RANGE,
-      0,
-      2147483647
-    },
-  };
-
-  num_of_attrs = ARRAY_SIZE(wfd_attrs);
-
-  base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
-
-  if ( !base )
-  {
-    debug_error("Cannot create mmwfd attribute\n");
-    goto ERROR;
-  }
-
-  /* initialize values of attributes */
-  for ( idx = 0; idx < num_of_attrs; idx++ )
-  {
-    base[idx].name = wfd_attrs[idx].name;
-    base[idx].value_type = wfd_attrs[idx].value_type;
-    base[idx].flags = wfd_attrs[idx].flags;
-    base[idx].default_value = wfd_attrs[idx].default_value;
-  }
-
-  attrs = mmf_attrs_new_from_data(
-          "mmwfd_attrs",
-          base,
-          num_of_attrs,
-          NULL,
-          NULL);
-
-  if(base)
-  {
-    g_free( base );
-    base = NULL;
-  }
-
-  if ( !attrs )
-  {
-    debug_error("Cannot create mmwfd attribute\n");
-    goto ERROR;
-  }
-
-  /* set validity type and range */
-  for ( idx = 0; idx < num_of_attrs; idx++ )
-  {
-    switch ( wfd_attrs[idx].valid_type)
-    {
-      case MM_ATTRS_VALID_TYPE_INT_RANGE:
-      {
-        mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
-        mmf_attrs_set_valid_range (attrs, idx,
-            wfd_attrs[idx].value_min,
-            wfd_attrs[idx].value_max,
-            (int)wfd_attrs[idx].default_value);
-      }
-      break;
-
-      case MM_ATTRS_VALID_TYPE_INT_ARRAY:
-      case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
-      case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
-      default:
-      break;
-    }
-  }
-
-  debug_fleave();
-
-  return attrs;
+       int idx = 0;
+       MMHandleType attrs = 0;
+       int num_of_attrs = 0;
+       mmf_attrs_construct_info_t *base = NULL;
+
+       debug_fenter();
+
+       return_val_if_fail(handle, (MMHandleType) NULL);
+
+       MMWfdAttrsSpec wfd_attrs[] = {
+               {
+                       "server_ip",
+                       MM_ATTRS_TYPE_STRING,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)"127.0.0.1",
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       0,
+                       0
+               },
+
+               {
+                       "server_port",
+                       MM_ATTRS_TYPE_STRING,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)"8554",
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       0,
+                       0
+               },
+
+               {
+                       "max_client_count",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)1,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       10
+               },
+               /* Initialized with invalid native type, if a valid value is set then only this atribute will be considered */
+               {
+                       "native_resolution",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       3
+               },
+               /* Initialized with invalid resolution, if a valid value is set then only this atribute will be considered */
+               {
+                       "prefered_resolutions",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)2147483647,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       2147483647
+               },
+               /* Initialized with invalid uibc option, if a valid value is set then only this atribute will be considered */
+               {
+                       "set_hdcp",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)2,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       2
+               },
+               {
+                       "display_rotate",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *)0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       3
+               },
+               {
+                       "display_src_crop_x",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_src_crop_y",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_src_crop_width",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_src_crop_height",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_roi_x",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_roi_y",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_roi_width",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 480,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_roi_height",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 800,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_roi_mode",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
+                       MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
+               },
+               {
+                       "display_rotation",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) MM_DISPLAY_ROTATION_NONE,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       MM_DISPLAY_ROTATION_NONE,
+                       MM_DISPLAY_ROTATION_270
+               },
+               {
+                       "display_visible",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) TRUE,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       1
+               },
+               {
+                       "display_method",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) MM_DISPLAY_METHOD_LETTER_BOX,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       MM_DISPLAY_METHOD_LETTER_BOX,
+                       MM_DISPLAY_METHOD_CUSTOM_ROI
+               },
+               {
+                       "display_overlay",
+                       MM_ATTRS_TYPE_DATA,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) NULL,
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       0,
+                       0
+               },
+               {
+                       "display_overlay_user_data",
+                       MM_ATTRS_TYPE_DATA,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) NULL,
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       0,
+                       0
+               },
+               {
+                       "display_zoom",
+                       MM_ATTRS_TYPE_DOUBLE,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 1,
+                       MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
+                       1.0,
+                       9.0
+               },
+               {
+                       "display_surface_type",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) MM_DISPLAY_SURFACE_NULL,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       MM_DISPLAY_SURFACE_X,
+                       MM_DISPLAY_SURFACE_X_EXT
+               },
+               {
+                       "display_width",   /* dest width of fimcconvert ouput */
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_height",   /* dest height of fimcconvert ouput */
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_evas_do_scaling",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) TRUE,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       FALSE,
+                       TRUE
+               },
+               {
+                       "display_x",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "display_y",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       4096
+               },
+               {
+                       "hdcp_handle",
+                       MM_ATTRS_TYPE_DATA,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) NULL,
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       0,
+                       0
+               },
+               {
+                       "hdcp_version",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       2
+               },
+               {
+                       "hdcp_port",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) 0,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       0,
+                       2147483647
+               },
+       };
+
+       num_of_attrs = ARRAY_SIZE(wfd_attrs);
+
+       base = (mmf_attrs_construct_info_t *)malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
+
+       if (!base) {
+               debug_error("Cannot create mmwfd attribute\n");
+               goto ERROR;
+       }
+
+       /* initialize values of attributes */
+       for (idx = 0; idx < num_of_attrs; idx++) {
+               base[idx].name = wfd_attrs[idx].name;
+               base[idx].value_type = wfd_attrs[idx].value_type;
+               base[idx].flags = wfd_attrs[idx].flags;
+               base[idx].default_value = wfd_attrs[idx].default_value;
+       }
+
+       attrs = mmf_attrs_new_from_data(
+                   "mmwfd_attrs",
+                   base,
+                   num_of_attrs,
+                   NULL,
+                   NULL);
+
+       if (base) {
+               g_free(base);
+               base = NULL;
+       }
+
+       if (!attrs) {
+               debug_error("Cannot create mmwfd attribute\n");
+               goto ERROR;
+       }
+
+       /* set validity type and range */
+       for (idx = 0; idx < num_of_attrs; idx++) {
+               switch (wfd_attrs[idx].valid_type) {
+                       case MM_ATTRS_VALID_TYPE_INT_RANGE: {
+                                       mmf_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
+                                       mmf_attrs_set_valid_range(attrs, idx,
+                                                                 wfd_attrs[idx].value_min,
+                                                                 wfd_attrs[idx].value_max,
+                                                                 (int)wfd_attrs[idx].default_value);
+                               }
+                               break;
+
+                       case MM_ATTRS_VALID_TYPE_INT_ARRAY:
+                       case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
+                       case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
+                       default:
+                               break;
+               }
+       }
+
+       debug_fleave();
+
+       return attrs;
 
 ERROR:
-  _mmwfd_deconstruct_attribute(attrs);
+       _mmwfd_deconstruct_attribute(attrs);
 
-  return (MMHandleType)NULL;
+       return (MMHandleType)NULL;
 }
 
 void
-_mmwfd_deconstruct_attribute(MMHandleType handle) // @
+_mmwfd_deconstruct_attribute(MMHandleType handle)
 {
-  debug_fenter();
+       debug_fenter();
 
-  return_if_fail( handle );
+       return_if_fail(handle);
 
-  if (handle)
-  {
-    mmf_attrs_free (handle);
-  }
+       if (handle)
+               mmf_attrs_free(handle);
 
-  debug_fleave();
+       debug_fleave();
 }
 
-
 int
 _mmwfd_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
 {
-  int result = MM_ERROR_NONE;
-  MMHandleType attrs = 0;
+       int result = MM_ERROR_NONE;
+       MMHandleType attrs = 0;
 
-  debug_fenter();
+       debug_fenter();
 
-  /* NOTE : Don't need to check err_attr_name because it can be set NULL */
-  /* if it's not want to know it. */
-  return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-  return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       /* NOTE : Don't need to check err_attr_name because it can be set NULL */
+       /* if it's not want to know it. */
+       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-  attrs = handle;
+       attrs = handle;
 
-  return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-  result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
+       result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
 
-  if ( result != MM_ERROR_NONE)
-    debug_error("failed to get %s attribute\n", attribute_name);
+       if (result != MM_ERROR_NONE)
+               debug_error("failed to get %s attribute\n", attribute_name);
 
-  debug_fleave();
+       debug_fleave();
 
-  return result;
+       return result;
 }
 
 int
 _mmwfd_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
 {
-  int result = MM_ERROR_NONE;
-  MMHandleType attrs = 0;
+       int result = MM_ERROR_NONE;
+       MMHandleType attrs = 0;
 
-  debug_fenter();
+       debug_fenter();
 
-  /* NOTE : Don't need to check err_attr_name because it can be set NULL */
-  /* if it's not want to know it. */
-  return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-  return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       /* NOTE : Don't need to check err_attr_name because it can be set NULL */
+       /* if it's not want to know it. */
+       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-  attrs = handle;
+       attrs = handle;
 
-  return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-  /* set attributes and commit them */
-  result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
+       /* set attributes and commit them */
+       result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
 
-  if ( result != MM_ERROR_NONE)
-  {
-    debug_error("failed to set %s attribute\n", attribute_name);
-    return result;
-  }
+       if (result != MM_ERROR_NONE) {
+               debug_error("failed to set %s attribute\n", attribute_name);
+               return result;
+       }
 
-  //__mmwfd_apply_attribute(handle, attribute_name);
+       /*__mmwfd_apply_attribute(handle, attribute_name); */
 
-  debug_fleave();
+       debug_fleave();
 
-  return result;
+       return result;
 }
 
-// Currently not used.
+/* Currently not used. */
 /*static gboolean
 __mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name)
 {
@@ -509,67 +497,65 @@ __mmwfd_apply_attribute(MMHandleType handle, const char *attribute_name)
 int
 _mmwfd_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMWfdAttrsInfo *dst_info)
 {
-  int result = MM_ERROR_NONE;
-  MMHandleType attrs = 0;
-  MMAttrsInfo src_info = {0, };
+       int result = MM_ERROR_NONE;
+       MMHandleType attrs = 0;
+       MMAttrsInfo src_info = {0, };
 
-  debug_fenter();
+       debug_fenter();
 
-  return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
-  return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
-  return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-  attrs = handle;
+       attrs = handle;
 
-  return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-  result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
-
-  if ( result != MM_ERROR_NONE)
-  {
-    debug_error("failed to get attribute info\n");
-    return result;
-  }
-
-  memset(dst_info, 0x00, sizeof(MMWfdAttrsInfo));
-
-  dst_info->type = src_info.type;
-  dst_info->flag = src_info.flag;
-  dst_info->validity_type= src_info.validity_type;
-
-  switch(src_info.validity_type)
-  {
-    case MM_ATTRS_VALID_TYPE_INT_ARRAY:
-      dst_info->int_array.array = src_info.int_array.array;
-      dst_info->int_array.count = src_info.int_array.count;
-      dst_info->int_array.d_val = src_info.int_array.dval;
-    break;
-
-    case MM_ATTRS_VALID_TYPE_INT_RANGE:
-      dst_info->int_range.min = src_info.int_range.min;
-      dst_info->int_range.max = src_info.int_range.max;
-      dst_info->int_range.d_val = src_info.int_range.dval;
-    break;
-
-    case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
-      dst_info->double_array.array = src_info.double_array.array;
-      dst_info->double_array.count = src_info.double_array.count;
-      dst_info->double_array.d_val = src_info.double_array.dval;
-    break;
-
-    case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
-      dst_info->double_range.min = src_info.double_range.min;
-      dst_info->double_range.max = src_info.double_range.max;
-      dst_info->double_range.d_val = src_info.double_range.dval;
-    break;
-
-    default:
-    break;
-  }
+       result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
 
-  debug_fleave();
+       if (result != MM_ERROR_NONE) {
+               debug_error("failed to get attribute info\n");
+               return result;
+       }
+
+       memset(dst_info, 0x00, sizeof(MMWfdAttrsInfo));
+
+       dst_info->type = src_info.type;
+       dst_info->flag = src_info.flag;
+       dst_info->validity_type = src_info.validity_type;
+
+       switch (src_info.validity_type) {
+               case MM_ATTRS_VALID_TYPE_INT_ARRAY:
+                       dst_info->int_array.array = src_info.int_array.array;
+                       dst_info->int_array.count = src_info.int_array.count;
+                       dst_info->int_array.d_val = src_info.int_array.dval;
+                       break;
+
+               case MM_ATTRS_VALID_TYPE_INT_RANGE:
+                       dst_info->int_range.min = src_info.int_range.min;
+                       dst_info->int_range.max = src_info.int_range.max;
+                       dst_info->int_range.d_val = src_info.int_range.dval;
+                       break;
+
+               case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
+                       dst_info->double_array.array = src_info.double_array.array;
+                       dst_info->double_array.count = src_info.double_array.count;
+                       dst_info->double_array.d_val = src_info.double_array.dval;
+                       break;
+
+               case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
+                       dst_info->double_range.min = src_info.double_range.min;
+                       dst_info->double_range.max = src_info.double_range.max;
+                       dst_info->double_range.d_val = src_info.double_range.dval;
+                       break;
+
+               default:
+                       break;
+       }
+
+       debug_fleave();
 
-  return result;
+       return result;
 }
 
 
index 63d68d4..6fc8acb 100755 (executable)
@@ -38,46 +38,40 @@ static gboolean     __generate_sink_default_ini(void);
 static void __mm_wfd_sink_ini_check_status(void);
 
 /* macro */
-#define MM_WFD_SINK_INI_GET_STRING( x_dict, x_item, x_ini, x_default ) \
-do \
-{ \
-       gchar* str = NULL; \
-       gint length = 0; \
- \
-       str = iniparser_getstring(x_dict, x_ini, x_default); \
-       if ( str ) \
-       { \
-               length = strlen (str); \
-               if ( ( length > 1 ) && ( length < WFD_SINK_INI_MAX_STRLEN ) ) \
-                       strncpy ( x_item, str, length+1 ); \
-               else \
-                       strncpy ( x_item, x_default, WFD_SINK_INI_MAX_STRLEN-1 ); \
-       } \
-       else \
-       { \
-               strncpy ( x_item, x_default, WFD_SINK_INI_MAX_STRLEN-1 ); \
-       } \
-}while(0)
+#define MM_WFD_SINK_INI_GET_STRING(x_dict, x_item, x_ini, x_default) \
+       do { \
+               gchar *str = NULL; \
+               gint length = 0; \
+               \
+               str = iniparser_getstring(x_dict, x_ini, x_default); \
+               if (str) { \
+                       length = strlen(str); \
+                       if ((length > 1) && (length < WFD_SINK_INI_MAX_STRLEN)) \
+                               strncpy(x_item, str, length+1); \
+                       else \
+                               strncpy(x_item, x_default, WFD_SINK_INI_MAX_STRLEN-1); \
+               } else { \
+                       strncpy(x_item, x_default, WFD_SINK_INI_MAX_STRLEN-1); \
+               } \
+       } while (0);
 
 #ifdef MM_WFD_SINK_DEFAULT_INI
 static
-gboolean __generate_sink_default_ini (void)
+gboolean __generate_sink_default_ini(void)
 {
-       FILEfp = NULL;
-       gchardefault_ini = MM_WFD_SINK_DEFAULT_INI;
+       FILE *fp = NULL;
+       gchar *default_ini = MM_WFD_SINK_DEFAULT_INI;
 
 
        /* create new file */
-       fp = fopen (MM_WFD_SINK_INI_DEFAULT_PATH, "wt");
+       fp = fopen(MM_WFD_SINK_INI_DEFAULT_PATH, "wt");
 
-       if ( !fp )
-       {
+       if (!fp) {
                return FALSE;
        }
 
        /* writing default ini file */
-       if ( strlen(default_ini) != fwrite(default_ini, 1, strlen(default_ini), fp) )
-       {
+       if (strlen(default_ini) != fwrite(default_ini, 1, strlen(default_ini), fp)) {
                fclose(fp);
                return FALSE;
        }
@@ -88,9 +82,9 @@ gboolean __generate_sink_default_ini (void)
 #endif
 
 int
-mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
+mm_wfd_sink_ini_load(mm_wfd_sink_ini_t *ini)
 {
-       dictionary * dict = NULL;
+       dictionary *dict = NULL;
 
        wfd_sink_debug_fenter();
 
@@ -98,21 +92,17 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
        __mm_wfd_sink_ini_check_status();
 
        /* first, try to load existing ini file */
-       dict = iniparser_load (MM_WFD_SINK_INI_DEFAULT_PATH);
+       dict = iniparser_load(MM_WFD_SINK_INI_DEFAULT_PATH);
 
        /* if no file exists. create one with set of default values */
-       if ( !dict )
-       {
+       if (!dict) {
 #ifdef MM_WFD_SINK_DEFAULT_INI
                wfd_sink_debug("No inifile found. create default ini file.\n");
-               if ( FALSE == __generate_sink_default_ini() )
-               {
+               if (FALSE == __generate_sink_default_ini()) {
                        wfd_sink_error("Creating default ini file failed. Use default values.\n");
-               }
-               else
-               {
+               } else {
                        /* load default ini */
-                       dict = iniparser_load (MM_WFD_SINK_INI_DEFAULT_PATH);
+                       dict = iniparser_load(MM_WFD_SINK_INI_DEFAULT_PATH);
                }
 #else
                wfd_sink_error("No ini file found. \n");
@@ -122,16 +112,15 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
        }
 
        /* get ini values */
-       memset (ini, 0, sizeof(mm_wfd_sink_ini_t) );
+       memset(ini, 0, sizeof(mm_wfd_sink_ini_t));
 
-       if ( dict ) /* if dict is available */
-       {
+       if (dict) { /* if dict is available */
                /* general */
-               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM );
-               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM );
-               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM );
-               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM );
-               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM );
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM);
                ini->generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
                ini->enable_pad_probe = iniparser_getboolean(dict, "general:enable pad probe", DEFAULT_ENABLE_PAD_PROBE);
                ini->state_change_timeout = iniparser_getint(dict, "general:state change timeout", DEFAULT_STATE_CHANGE_TIMEOUT);
@@ -149,21 +138,21 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
 
 
                /* pipeline */
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_tsdemux, "pipeline:tsdemux element", DEFAULT_NAME_OF_TSDEMUX );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_audio_hdcp, "pipeline:audio hdcp element", DEFAULT_NAME_OF_AUDIO_HDCP );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_aac_parser, "pipeline:aac parser element", DEFAULT_NAME_OF_AAC_PARSER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_aac_decoder, "pipeline:aac decoder element", DEFAULT_NAME_OF_AAC_DECODER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_ac3_parser, "pipeline:ac3 parser element", DEFAULT_NAME_OF_AC3_PARSER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_ac3_decoder, "pipeline:ac3 decoder element", DEFAULT_NAME_OF_AC3_DECODER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_lpcm_converter, "pipeline:lpcm converter element", DEFAULT_NAME_OF_LPCM_CONVERTER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_lpcm_filter, "pipeline:lpcm filter element", DEFAULT_NAME_OF_LPCM_FILTER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_audio_resampler, "pipeline:audio resampler element", DEFAULT_NAME_OF_AUDIO_RESAMPLER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_audio_volume, "pipeline:audio volume element", DEFAULT_NAME_OF_AUDIO_VOLUME );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_audio_sink, "pipeline:audio sink element", DEFAULT_NAME_OF_AUDIO_SINK );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_video_hdcp, "pipeline:video hdcp element", DEFAULT_NAME_OF_VIDEO_HDCP );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_video_parser, "pipeline:video parser element", DEFAULT_NAME_OF_VIDEO_PARSER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_video_decoder, "pipeline:video decoder element", DEFAULT_NAME_OF_VIDEO_DECODER );
-               MM_WFD_SINK_INI_GET_STRING( dict, ini->name_of_video_sink, "pipeline:video sink element", DEFAULT_NAME_OF_VIDEO_SINK );
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_tsdemux, "pipeline:tsdemux element", DEFAULT_NAME_OF_TSDEMUX);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_audio_hdcp, "pipeline:audio hdcp element", DEFAULT_NAME_OF_AUDIO_HDCP);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_aac_parser, "pipeline:aac parser element", DEFAULT_NAME_OF_AAC_PARSER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_aac_decoder, "pipeline:aac decoder element", DEFAULT_NAME_OF_AAC_DECODER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_ac3_parser, "pipeline:ac3 parser element", DEFAULT_NAME_OF_AC3_PARSER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_ac3_decoder, "pipeline:ac3 decoder element", DEFAULT_NAME_OF_AC3_DECODER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_lpcm_converter, "pipeline:lpcm converter element", DEFAULT_NAME_OF_LPCM_CONVERTER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_lpcm_filter, "pipeline:lpcm filter element", DEFAULT_NAME_OF_LPCM_FILTER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_audio_resampler, "pipeline:audio resampler element", DEFAULT_NAME_OF_AUDIO_RESAMPLER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_audio_volume, "pipeline:audio volume element", DEFAULT_NAME_OF_AUDIO_VOLUME);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_audio_sink, "pipeline:audio sink element", DEFAULT_NAME_OF_AUDIO_SINK);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_video_hdcp, "pipeline:video hdcp element", DEFAULT_NAME_OF_VIDEO_HDCP);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_video_parser, "pipeline:video parser element", DEFAULT_NAME_OF_VIDEO_PARSER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_video_decoder, "pipeline:video decoder element", DEFAULT_NAME_OF_VIDEO_DECODER);
+               MM_WFD_SINK_INI_GET_STRING(dict, ini->name_of_video_sink, "pipeline:video sink element", DEFAULT_NAME_OF_VIDEO_SINK);
 
                /* audio parameter*/
                ini->audio_codec = iniparser_getint(dict, "audio param:audio codec", DEFAULT_AUDIO_CODEC);
@@ -189,17 +178,15 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
                /* hdcp parameter*/
                ini->hdcp_content_protection = iniparser_getint(dict, "hdcp param:hdcp content protection", DEFAULT_HDCP_CONTENT_PROTECTION);
                ini->hdcp_port_no = iniparser_getint(dict, "hdcp param:hdcp port no", DEFAULT_HDCP_PORT_NO);
-       }
-       else /* if dict is not available just fill the structure with default value */
-       {
+       } else { /* if dict is not available just fill the structure with default value */
                wfd_sink_error("failed to load ini. using hardcoded default\n");
 
                /* general */
-               strncpy( ini->gst_param[0], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->gst_param[1], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->gst_param[2], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->gst_param[3], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->gst_param[4], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1 );
+               strncpy(ini->gst_param[0], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->gst_param[1], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->gst_param[2], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->gst_param[3], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->gst_param[4], DEFAULT_GST_PARAM, WFD_SINK_INI_MAX_STRLEN - 1);
                ini->generate_dot =  DEFAULT_GENERATE_DOT;
                ini->enable_pad_probe = DEFAULT_ENABLE_PAD_PROBE;
                ini->state_change_timeout = DEFAULT_STATE_CHANGE_TIMEOUT;
@@ -214,21 +201,21 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
                ini->enable_wfdrtspsrc_pad_probe = DEFAULT_ENABLE_WFDRTSPSRC_PAD_PROBE;
 
                /* pipeline */
-               strncpy( ini->name_of_tsdemux, DEFAULT_NAME_OF_TSDEMUX, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_audio_hdcp, DEFAULT_NAME_OF_AUDIO_HDCP, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_aac_parser, DEFAULT_NAME_OF_AAC_PARSER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_aac_decoder, DEFAULT_NAME_OF_AAC_DECODER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_ac3_parser, DEFAULT_NAME_OF_AC3_PARSER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_ac3_decoder, DEFAULT_NAME_OF_AC3_DECODER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_lpcm_converter, DEFAULT_NAME_OF_LPCM_CONVERTER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_lpcm_filter, DEFAULT_NAME_OF_LPCM_FILTER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_audio_resampler, DEFAULT_NAME_OF_AUDIO_RESAMPLER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_audio_volume, DEFAULT_NAME_OF_AUDIO_VOLUME, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_audio_sink, DEFAULT_NAME_OF_AUDIO_SINK, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_video_hdcp, DEFAULT_NAME_OF_VIDEO_HDCP, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_video_parser, DEFAULT_NAME_OF_VIDEO_PARSER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_video_decoder, DEFAULT_NAME_OF_VIDEO_DECODER, WFD_SINK_INI_MAX_STRLEN - 1 );
-               strncpy( ini->name_of_video_sink, DEFAULT_NAME_OF_VIDEO_SINK, WFD_SINK_INI_MAX_STRLEN - 1 );
+               strncpy(ini->name_of_tsdemux, DEFAULT_NAME_OF_TSDEMUX, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_audio_hdcp, DEFAULT_NAME_OF_AUDIO_HDCP, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_aac_parser, DEFAULT_NAME_OF_AAC_PARSER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_aac_decoder, DEFAULT_NAME_OF_AAC_DECODER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_ac3_parser, DEFAULT_NAME_OF_AC3_PARSER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_ac3_decoder, DEFAULT_NAME_OF_AC3_DECODER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_lpcm_converter, DEFAULT_NAME_OF_LPCM_CONVERTER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_lpcm_filter, DEFAULT_NAME_OF_LPCM_FILTER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_audio_resampler, DEFAULT_NAME_OF_AUDIO_RESAMPLER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_audio_volume, DEFAULT_NAME_OF_AUDIO_VOLUME, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_audio_sink, DEFAULT_NAME_OF_AUDIO_SINK, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_video_hdcp, DEFAULT_NAME_OF_VIDEO_HDCP, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_video_parser, DEFAULT_NAME_OF_VIDEO_PARSER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_video_decoder, DEFAULT_NAME_OF_VIDEO_DECODER, WFD_SINK_INI_MAX_STRLEN - 1);
+               strncpy(ini->name_of_video_sink, DEFAULT_NAME_OF_VIDEO_SINK, WFD_SINK_INI_MAX_STRLEN - 1);
 
                /* audio parameter*/
                ini->audio_codec = DEFAULT_AUDIO_CODEC;
@@ -257,11 +244,11 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
        }
 
        /* free dict as we got our own structure */
-       iniparser_freedict (dict);
+       iniparser_freedict(dict);
 
 
        /* dump structure */
-       wfd_sink_debug("W-Fi Display Sink Initial Settings -----------------------------------\n");
+       wfd_sink_debug("W-Fi Display Sink Initial Settings-----------------------------------\n");
 
        /* general */
        wfd_sink_debug("gst_param1 : %s\n", ini->gst_param[0]);
@@ -270,10 +257,9 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
        wfd_sink_debug("gst_param4 : %s\n", ini->gst_param[3]);
        wfd_sink_debug("gst_param5 : %s\n", ini->gst_param[4]);
        wfd_sink_debug("generate_dot : %d\n", ini->generate_dot);
-       if (ini->generate_dot == TRUE)
-       {
+       if (ini->generate_dot == TRUE) {
                wfd_sink_debug("generate_dot is TRUE, dot file will be stored into /tmp/\n");
-               g_setenv ("GST_DEBUG_DUMP_DOT_DIR", "/tmp/", FALSE);
+               g_setenv("GST_DEBUG_DUMP_DOT_DIR", "/tmp/", FALSE);
        }
        wfd_sink_debug("enable_pad_probe : %d\n", ini->enable_pad_probe);
        wfd_sink_debug("state_change_timeout(sec) : %d\n", ini->state_change_timeout);
@@ -345,22 +331,18 @@ mm_wfd_sink_ini_load (mm_wfd_sink_ini_t* ini)
 
 
 static
-void __mm_wfd_sink_ini_check_status (void)
+void __mm_wfd_sink_ini_check_status(void)
 {
        struct stat ini_buff;
 
        wfd_sink_debug_fenter();
 
-       if ( g_stat(MM_WFD_SINK_INI_DEFAULT_PATH, &ini_buff) < 0 )
-       {
+       if (g_stat(MM_WFD_SINK_INI_DEFAULT_PATH, &ini_buff) < 0) {
                wfd_sink_error("failed to get mmfw_wfd_sink ini status\n");
-       }
-       else
-       {
-               if ( ini_buff.st_size < 5 )
-               {
+       } else {
+               if (ini_buff.st_size < 5) {
                        wfd_sink_error("mmfw_wfd_sink.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
-                       g_remove( MM_WFD_SINK_INI_DEFAULT_PATH );
+                       g_remove(MM_WFD_SINK_INI_DEFAULT_PATH);
                }
        }
 
@@ -368,7 +350,7 @@ void __mm_wfd_sink_ini_check_status (void)
 }
 
 int
-mm_wfd_sink_ini_unload (mm_wfd_sink_ini_t* ini)
+mm_wfd_sink_ini_unload(mm_wfd_sink_ini_t *ini)
 {
        wfd_sink_debug_fenter();
 
index ab60b02..c1102ad 100755 (executable)
@@ -52,7 +52,7 @@ video sink async=no
 
 
 [pipeline]
-tsdemux element = tsdemux
+tsdemux element = wfdtsdemux
 
 aac parser element = aacparse
 
old mode 100644 (file)
new mode 100755 (executable)
index 63a2d9b..1e53f04
@@ -1,6 +1,6 @@
 Name:       libmm-wfd
 Summary:    Multimedia Framework Wifi-Display Library
-Version:    0.2.165
+Version:    0.2.171
 Release:    0
 Group:      System/Libraries
 License:    Apache License 2.0
@@ -15,7 +15,6 @@ BuildRequires: pkgconfig(gstreamer-app-1.0)
 BuildRequires: pkgconfig(iniparser)
 BuildRequires: pkgconfig(capi-network-wifi-direct)
 BuildRequires: pkgconfig(mm-scmirroring-common)
-BuildRequires: kernel-headers
 BuildRequires: pkgconfig(dlog)
 
 BuildRoot:  %{_tmppath}/%{name}-%{version}-build
index 9e1ee59..c94122d 100755 (executable)
@@ -43,7 +43,7 @@ typedef enum {
        MM_WFD_SINK_STATE_NUM,                          /**< Number of wifi-display states */
 } MMWFDSinkStateType;
 
-typedef void (*MMWFDMessageCallback)(int error_type, MMWFDSinkStateType state_type, void *user_data);
+typedef void(*MMWFDMessageCallback)(int error_type, MMWFDSinkStateType state_type, void *user_data);
 
 /**
  * This function creates a wi-fi display sink object. \n
@@ -83,7 +83,7 @@ int mm_wfd_sink_create(MMHandleType *wfd_sink);
  * @return     This function returns zero on success, or negative value with error code. \n
  *                     Please refer 'mm_error.h' to know it in detail.
  * @pre                MM_WFD_SINK_STATE_NULL
- * @post               MM_WFD_SINK_STATE_READY
+ * @post               MM_WFD_SINK_STATE_PREPARED
  * @see                mm_wfd_sink_unprepare
  * @remark     None
  * @par Example
@@ -105,8 +105,8 @@ int mm_wfd_sink_prepare(MMHandleType wfd_sink);
  *
  * @return     This function returns zero on success, or negative value with error code.
  *
- * @pre                wi-fi display sink state should be MM_WFD_SINK_STATE_READY
- * @post               wi-fi display sink state will be MM_WFD_SINK_STATE_PAUSED with no preroll.
+ * @pre                wi-fi display sink state should be MM_WFD_SINK_STATE_PREPARED
+ * @post               wi-fi display sink state will be MM_WFD_SINK_STATE_CONNECTED with no preroll.
  * @remark     None
  * @par Example
  * @code
@@ -127,7 +127,7 @@ int mm_wfd_sink_connect(MMHandleType wfd_sink, const char *uri);
  * @return     This function returns zero on success, or negative value with error code.
  * @remark
  *
- * @pre                wi-fi display sink state may be MM_WFD_SINK_STATE_PAUSED.
+ * @pre                wi-fi display sink state may be MM_WFD_SINK_STATE_CONNECTED.
  * @post               wi-fi display sink state will be MM_WFD_SINK_STATE_PLAYING.
  * @see                mm_wfd_sink_disconnect
  * @remark     None
@@ -142,6 +142,52 @@ if (mm_wfd_sink_start(g_wfd_sink) != MM_ERROR_NONE)
 int mm_wfd_sink_start(MMHandleType wfd_sink);
 
 /**
+ * This function is to pause playing. \n
+ * The wi-fi display sink pause the current stream being received form wi-fi display source. \n
+ *
+ * @param      wfd_sink                [in]    Handle of wi-fi display sink
+ *
+ * @return     This function returns zero on success, or negative value with error code.
+ * @remark
+ *
+ * @pre                wi-fi display sink state should be MM_WFD_SINK_STATE_PLAYING.
+ * @post               wi-fi display sink state will be MM_WFD_SINK_STATE_PAUSED.
+ * @see                mm_wfd_sink_pause
+ * @remark     None
+ * @par Example
+ * @code
+if (mm_wfd_sink_pause(g_wfd_sink) != MM_ERROR_NONE)
+{
+       wfd_sink_error("failed to pause wi-fi display sink\n");
+}
+ * @endcode
+ */
+int mm_wfd_sink_pause(MMHandleType wfd_sink);
+
+/**
+ * This function is to resume playing. \n
+ * Data from wi-fi display source will be received. \n
+ *
+ * @param      wfd_sink                [in]    Handle of wi-fi display sink
+ *
+ * @return     This function returns zero  on success, or negative value with error code.
+ * @remark
+ *
+ * @pre                wi-fi display sink state may be MM_WFD_SINK_STATE_PAUSED.
+ * @post               wi-fi display sink state will be MM_WFD_SINK_STATE_PLAYING.
+ * @see                mm_wfd_sink_disconnect
+ * @remark     None
+ * @par Example
+ * @code
+if (mm_wfd_sink_start(g_wfd_sink) != MM_ERROR_NONE)
+{
+       wfd_sink_error("failed to resume wi-fi display sink\n");
+}
+ * @endcode
+ */
+int mm_wfd_sink_resume(MMHandleType wfd_sink);
+
+/**
  * This function is to stop playing wi-fi display. \n
  *
  * @param      wfd_sink                [in]    Handle of wi-fi display sink
@@ -149,7 +195,7 @@ int mm_wfd_sink_start(MMHandleType wfd_sink);
  * @return     This function returns zero on success, or negative value with error code.
  *
  * @pre                wi-fi display sink state may be MM_WFD_SINK_STATE_PLAYING.
- * @post               wi-fi display sink state will be MM_WFD_SINK_STATE_READY.
+ * @post               wi-fi display sink state will be MM_WFD_SINK_STATE_DISCONNECTED.
  * @see                mm_wfd_sink_start
  * @remark     None
  * @par Example
@@ -169,7 +215,7 @@ int mm_wfd_sink_disconnect(MMHandleType wfd_sink);
  *
  * @return     This function returns zero on success, or negative value with error code. \n
  *                     Please refer 'mm_error.h' to know it in detail.
- * @pre                wi-fi display sink state may be MM_WFD_SINK_STATE_READY.
+ * @pre                wi-fi display sink state may be MM_WFD_SINK_STATE_PREPARED or MM_WFD_SINK_STATE_DISCONNECTED.
  *                     But, it can be called in any state.
  * @post               MM_WFD_SINK_STATE_NULL
  * @see                mm_wfd_sink_prepare
@@ -178,7 +224,7 @@ int mm_wfd_sink_disconnect(MMHandleType wfd_sink);
  * @code
 if (mm_wfd_sink_unprepare(&g_wfd_sink) != MM_ERROR_NONE)
 {
-       wfd_sink_error("failed to unrealize wi-fi display sink\n");
+       wfd_sink_error("failed to unprepare wi-fi display sink\n");
 }
  * @endcode
  */
@@ -230,11 +276,11 @@ int msg_callback(int error_type, MMWFDSinkStateType state_type, void *user_data)
                        //do something
                        break;
 
-               case MM_WFD_SINK_STATE_READY:
+               case MM_WFD_SINK_STATE_PREPARED:
                        //do something
                        break;
 
-               case MM_WFD_SINK_STATE_PAUSED:
+               case MM_WFD_SINK_STATE_CONNECTED:
                        //do something
                        break;
 
@@ -242,7 +288,11 @@ int msg_callback(int error_type, MMWFDSinkStateType state_type, void *user_data)
                        //do something
                        break;
 
-               case MM_WFD_SINK_STATE_TEARDOWN:
+               case MM_WFD_SINK_STATE_PAUSED:
+                       //do something
+                       break;
+
+               case MM_WFD_SINK_DISCONNECTED:
                        //do something
                        break;
 
@@ -265,7 +315,7 @@ int mm_wfd_sink_set_attribute(MMHandleType wfd_sink,  char **err_attr_name, cons
  * @param      wfd_sink                [in]    Handle of wi-fi display sink
  *
  * @return     This function returns zero on success, or negative value with error code.
- * @pre                wi-fi display state should be MM_WFD_SINK_STATE_READY or MM_WFD_SINK_STATE_PAUSED. \n
+ * @pre                wi-fi display state should be MM_WFD_SINK_STATE_READY or MM_WFD_SINK_STATE_PREPARED. \n
  * @post               N/A
  * @remark     resources are released when mm_wfd_sink_destory is called
  *
@@ -363,7 +413,7 @@ int mm_wfd_sink_set_display_visible(MMHandleType wfd_sink, gint display_visible)
  * @param      height          [in]    Height of video
  *
  * @return     This function returns zero on success, or negative value with error code.
- * @pre                wi-fi display state should be MM_WFD_SINK_STATE_PAUSED. \n
+ * @pre                wi-fi display state should be MM_WFD_SINK_STATE_CONNECTED or MM_WFD_SINK_STATE_PLAYING. \n
  *
  * @par Example
  * @code
@@ -375,7 +425,7 @@ if (mm_wfd_sink_get_video_resolution(g_wfd_sink, &g_width, &g_height) != MM_ERRO
 }
  * @endcode
  */
-int mm_wfd_sink_get_video_resolution(MMHandleType wfd_sink, gint *width, gint *height );
+int mm_wfd_sink_get_video_resolution(MMHandleType wfd_sink, gint *width, gint *height);
 
 /**
  * This function gets the width and height of video which is played by wi-fi display sink\n
@@ -384,7 +434,7 @@ int mm_wfd_sink_get_video_resolution(MMHandleType wfd_sink, gint *width, gint *h
  * @param      framerate               [in]    Framerate of video
  *
  * @return     This function returns zero on success, or negative value with error code.
- * @pre                wi-fi display state should be MM_WFD_SINK_STATE_PAUSED. \n
+ * @pre                wi-fi display state should be MM_WFD_SINK_STATE_CONNECTED or MM_WFD_SINK_STATE_PLAYING. \n
  *
  * @par Example
  * @code
@@ -398,4 +448,16 @@ if (mm_wfd_sink_get_video_framerate(g_wfd_sink, &g_framerate) != MM_ERROR_NONE)
  */
 int mm_wfd_sink_get_video_framerate(MMHandleType wfd_sink,  gint *framerate);
 
+/**
+ * This function sets the resolutions for wi-fi display sink\n
+ *
+ * @param      wfd_sink                [in]    Handle of wi-fi display sink
+ * @param      resolution              [in]    Resolutions for wi-fi display sink
+ *
+ * @return     This function returns zero on success, or negative value with error code.
+ * @pre                wi-fi display state should be MM_WFD_SINK_STATE_NULL. \n
+ *
+ */
+int mm_wfd_sink_set_resolution(MMHandleType wfd_sink,  gint resolution);
+
 #endif
index b6eb9d0..77489a3 100755 (executable)
 #include "mm_wfd_sink_util.h"
 
 #ifdef __cplusplus
-       extern "C" {
+extern "C" {
 #endif
 
 #define WFD_SINK_MANAGER_LOCK(wfd_sink) \
-do{\
-       if (wfd_sink)\
-       {\
-               g_mutex_lock (&((wfd_sink)->manager_thread_mutex));\
-       }\
-} while(0);
+       do {\
+               if (wfd_sink) {\
+                       g_mutex_lock(&((wfd_sink)->manager_thread_mutex));\
+               }\
+       } while (0);
 
 #define WFD_SINK_MANAGER_UNLOCK(wfd_sink) \
-do{\
-       if (wfd_sink)\
-       {\
-               g_mutex_unlock (&((wfd_sink)->manager_thread_mutex));\
-       }\
-} while(0);
+       do {\
+               if (wfd_sink) {\
+                       g_mutex_unlock(&((wfd_sink)->manager_thread_mutex));\
+               }\
+       } while (0);
 
 #define WFD_SINK_MANAGER_WAIT_CMD(wfd_sink) \
-do{\
-       wfd_sink_debug ("manager thread is waiting for command signal\n");\
-       wfd_sink->waiting_cmd = TRUE; \
-       g_cond_wait (&((wfd_sink)->manager_thread_cond), &((wfd_sink)->manager_thread_mutex)); \
-       wfd_sink->waiting_cmd = FALSE; \
-} while(0);
+       do {\
+               wfd_sink_debug("manager thread is waiting for command signal\n");\
+               wfd_sink->waiting_cmd = TRUE; \
+               g_cond_wait(&((wfd_sink)->manager_thread_cond), &((wfd_sink)->manager_thread_mutex)); \
+               wfd_sink->waiting_cmd = FALSE; \
+       } while (0);
 
 #define WFD_SINK_MANAGER_SIGNAL_CMD(wfd_sink, cmd) \
-do{\
-       if (wfd_sink->manager_thread_cmd != WFD_SINK_MANAGER_CMD_EXIT)\
-       {\
-               wfd_sink->manager_thread_cmd |= cmd;\
-               if (wfd_sink->waiting_cmd)\
-               {\
-                       wfd_sink_debug ("send command signal to manager thread with %x command\n", &(wfd_sink->manager_thread_cmd));\
-                       g_cond_signal (&((wfd_sink)->manager_thread_cond));\
+       do {\
+               if (wfd_sink->manager_thread_cmd != WFD_SINK_MANAGER_CMD_EXIT) {\
+                       wfd_sink->manager_thread_cmd |= cmd;\
+                       if (wfd_sink->waiting_cmd) {\
+                               wfd_sink_debug("send command signal to manager thread with %x command\n", &(wfd_sink->manager_thread_cmd));\
+                               g_cond_signal(&((wfd_sink)->manager_thread_cond));\
+                       }\
                }\
-       }\
-} while(0);
+       } while (0);
 
 /**
  * This function is to initialize manager
@@ -89,11 +85,11 @@ int _mm_wfd_sink_init_manager(mm_wfd_sink_t *wfd_sink);
  * @see
  *
  */
-int _mm_wfd_sink_release_manager(mm_wfd_sink_twfd_sink);
+int _mm_wfd_sink_release_manager(mm_wfd_sink_t *wfd_sink);
 
 
 #ifdef __cplusplus
-       }
+}
 #endif
 
 #endif
index 7962af7..fb16fbc 100755 (executable)
@@ -38,8 +38,7 @@
 #include "mm_wfd_sink.h"
 
 /* main pipeline's element id */
-enum WFDSinkMainElementID
-{
+enum WFDSinkMainElementID {
        WFD_SINK_M_PIPE = 0, /* NOTE : WFD_SINK_M_PIPE should be zero */
        WFD_SINK_M_SRC,
        WFD_SINK_M_DEPAY,
@@ -48,8 +47,7 @@ enum WFDSinkMainElementID
 };
 
 /* audio pipeline's element id */
-enum WFDSinkAudioElementID
-{
+enum WFDSinkAudioElementID {
        WFD_SINK_A_BIN = 0, /* NOTE : WFD_SINK_A_BIN should be zero */
        WFD_SINK_A_QUEUE,
        WFD_SINK_A_HDCP,
@@ -67,8 +65,7 @@ enum WFDSinkAudioElementID
 };
 
 /* video pipeline's element id */
-enum WFDSinkVideoElementID
-{
+enum WFDSinkVideoElementID {
        WFD_SINK_V_BIN = 0, /* NOTE : WFD_SINK_V_BIN should be zero */
        WFD_SINK_V_QUEUE,
        WFD_SINK_V_HDCP,
@@ -80,8 +77,7 @@ enum WFDSinkVideoElementID
 };
 
 /* audio codec : AAC, AC3, LPCM  */
-enum WFDSinkAudioCodec
-{
+enum WFDSinkAudioCodec {
        WFD_SINK_AUDIO_CODEC_NONE,
        WFD_SINK_AUDIO_CODEC_AAC = 0x0F,
        WFD_SINK_AUDIO_CODEC_AC3 = 0x81,
@@ -89,8 +85,7 @@ enum WFDSinkAudioCodec
 };
 
 /* video codec : H264  */
-enum WFDSinkVideoCodec
-{
+enum WFDSinkVideoCodec {
        WFD_SINK_VIDEO_CODEC_NONE,
        WFD_SINK_VIDEO_CODEC_H264 = 0x1b
 };
@@ -104,6 +99,8 @@ typedef enum {
        MM_WFD_SINK_COMMAND_PREPARE,            /**< command for preparing wifi-display sink */
        MM_WFD_SINK_COMMAND_CONNECT,    /**< command for connecting wifi-display sink  */
        MM_WFD_SINK_COMMAND_START,       /**< command for starting wifi-display sink  */
+       MM_WFD_SINK_COMMAND_PAUSE,       /**< command for pausing wifi-display sink  */
+       MM_WFD_SINK_COMMAND_RESUME,      /**< command for resuming wifi-display sink  */
        MM_WFD_SINK_COMMAND_DISCONNECT, /**< command for disconnecting wifi-display sink  */
        MM_WFD_SINK_COMMAND_UNPREPARE,          /**< command for unpreparing wifi-display sink  */
        MM_WFD_SINK_COMMAND_DESTROY,            /**< command for destroting wifi-display sink  */
@@ -122,47 +119,56 @@ typedef enum {
        WFD_SINK_MANAGER_CMD_EXIT = (1 << 8)
 } WFDSinkManagerCMDType;
 
-typedef struct
-{
+/**
+ *  * Enumerations of resolution.
+ *   */
+typedef enum {
+       MM_WFD_SINK_RESOLUTION_UNKNOWN = 0,
+       MM_WFD_SINK_RESOLUTION_1920x1080_P30 = (1 << 0),  /**< W-1920, H-1080, 30 fps*/
+       MM_WFD_SINK_RESOLUTION_1280x720_P30 = (1 << 1),   /**< W-1280, H-720, 30 fps*/
+       MM_WFD_SINK_RESOLUTION_960x540_P30 = (1 << 2),    /**< W-960, H-540, 30 fps*/
+       MM_WFD_SINK_RESOLUTION_864x480_P30 = (1 << 3),    /**< W-864, H-480, 30 fps*/
+       MM_WFD_SINK_RESOLUTION_720x480_P60 = (1 << 4),    /**< W-720, H-480, 30 fps*/
+       MM_WFD_SINK_RESOLUTION_640x480_P60 = (1 << 5),    /**< W-640, H-480, 60 fps*/
+       MM_WFD_SINK_RESOLUTION_640x360_P30 = (1 << 6),    /**< W-640, H-360, 30 fps*/
+       MM_WFD_SINK_RESOLUTION_MAX = 128,
+} MMWFDSinkResolution;
+
+typedef struct {
        gint codec;
        gint width;
        gint height;
        gint frame_rate;
-}MMWFDSinkVideoStreamInfo;
+} MMWFDSinkVideoStreamInfo;
 
-typedef struct
-{
+typedef struct {
        gint codec;
        gint channels;
        gint sample_rate;
        gint bitwidth;
-}MMWFDSinkAudioStreamInfo;
+} MMWFDSinkAudioStreamInfo;
 
-typedef struct
-{
+typedef struct {
        MMWFDSinkAudioStreamInfo audio_stream_info;
        MMWFDSinkVideoStreamInfo video_stream_info;
-}MMWFDSinkStreamInfo;
+} MMWFDSinkStreamInfo;
 
 
-typedef struct
-{
+typedef struct {
        gint id;
        GstElement *gst;
 } MMWFDSinkGstElement;
 
-typedef struct
-{
+typedef struct {
        MMWFDSinkGstElement     *mainbin;
        MMWFDSinkGstElement     *audiobin;
        MMWFDSinkGstElement     *videobin;
 } MMWFDSinkGstPipelineInfo;
 
-typedef struct
-{
-       MMWFDSinkStateType state;         // wfd current state
-       MMWFDSinkStateType prev_state;    // wfd  previous state
-       MMWFDSinkStateType pending_state; // wfd  state which is going to now
+typedef struct {
+       MMWFDSinkStateType state;         /* wfd current state */
+       MMWFDSinkStateType prev_state;    /* wfd  previous state */
+       MMWFDSinkStateType pending_state; /* wfd  state which is going to now */
 } MMWFDSinkState;
 
 #define MMWFDSINK_GET_ATTRS(x_wfd) ((x_wfd)? ((mm_wfd_sink_t*)x_wfd)->attrs : (MMHandleType)NULL)
@@ -173,8 +179,8 @@ typedef struct {
        gint added_av_pad_num;
        gboolean audio_bin_is_linked;
        gboolean video_bin_is_linked;
-       GstPad * prev_audio_dec_src_pad;
-       GstPad * next_audio_dec_sink_pad;
+       GstPad *prev_audio_dec_src_pad;
+       GstPad *next_audio_dec_sink_pad;
 
        /* timestamp compensation */
        gboolean need_to_reset_basetime;
@@ -189,9 +195,9 @@ typedef struct {
        GstClockTime last_buffer_timestamp;
 
        /* attributes */
-       MMHandleType attrs;
+       MMHandleType attrs;
 
-       /* state */
+       /* state */
        MMWFDSinkState state;
 
        /* initialize values */
@@ -199,7 +205,7 @@ typedef struct {
 
        /* command */
        MMWFDSinkCommandType cmd;
-       GMutex cmd_lock;
+       GMutex cmd_lock;
        gboolean waiting_cmd;
 
        /* stream information */
@@ -212,6 +218,9 @@ typedef struct {
        /* audio session manager related variables */
        GList *resource_list;
 
+       /* video resolution for negotiation */
+       MMWFDSinkResolution supportive_resolution;
+
        GThread         *manager_thread;
        GMutex manager_thread_mutex;
        GCond manager_thread_cond;
@@ -226,12 +235,15 @@ int _mm_wfd_sink_unprepare(mm_wfd_sink_t *wfd_sink);
 int _mm_wfd_sink_connect(mm_wfd_sink_t *wfd_sink, const char *uri);
 int _mm_wfd_sink_disconnect(mm_wfd_sink_t *wfd_sink);
 int _mm_wfd_sink_start(mm_wfd_sink_t *wfd_sink);
+int _mm_wfd_sink_pause(mm_wfd_sink_t *wfd_sink);
+int _mm_wfd_sink_resume(mm_wfd_sink_t *wfd_sink);
 int _mm_wfd_set_message_callback(mm_wfd_sink_t *wfd_sink, MMWFDMessageCallback callback, void *user_data);
-int _mm_wfd_sink_get_resource(mm_wfd_sink_t* wfd_sink);
+int _mm_wfd_sink_get_resource(mm_wfd_sink_t *wfd_sink);
+int _mm_wfd_sink_set_resolution(mm_wfd_sink_t *wfd_sink, MMWFDSinkResolution resolution);
 
 int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink);
-int __mm_wfd_sink_prepare_videobin (mm_wfd_sink_t *wfd_sink);
-int __mm_wfd_sink_prepare_audiobin(mm_wfd_sink_t * wfd_sink);
+int __mm_wfd_sink_prepare_videobin(mm_wfd_sink_t *wfd_sink);
+int __mm_wfd_sink_prepare_audiobin(mm_wfd_sink_t *wfd_sink);
 
 #endif
 
index c021363..20e46ad 100755 (executable)
 #include "mm_wfd_sink_dlog.h"
 
 #define MMWFDSINK_FREEIF(x) \
-do\
-{\
-       if ( (x) ) \
-               g_free( (gpointer)(x) ); \
-       (x) = NULL;\
-} while(0);
+       do      {\
+               if ((x)) \
+                       g_free((gpointer)(x)); \
+               (x) = NULL;\
+       } while (0);
 
 /* lock for commnad */
 #define MMWFDSINK_CMD_LOCK(x_wfd) \
-if(x_wfd) \
-  g_mutex_lock(&(((mm_wfd_sink_t*)x_wfd)->cmd_lock));
+       if (x_wfd) \
+               g_mutex_lock(&(((mm_wfd_sink_t *)x_wfd)->cmd_lock));
 
 #define MMWFDSINK_CMD_UNLOCK(x_wfd) \
-if(x_wfd) \
-  g_mutex_unlock(&(((mm_wfd_sink_t*)x_wfd)->cmd_lock));
+       if (x_wfd) \
+               g_mutex_unlock(&(((mm_wfd_sink_t *)x_wfd)->cmd_lock));
 
 /* create element  */
 #define MMWFDSINK_CREATE_ELEMENT(x_bin, x_id, x_factory, x_name, x_add_bucket) \
-do \
-\
-       if ( x_name &&\
-               ( strlen( x_factory ) > 1 )) \
-       {\
-               x_bin[x_id].id = x_id;\
-               x_bin[x_id].gst = gst_element_factory_make(x_factory, x_name);\
-               if ( ! x_bin[x_id].gst )\
-               {\
-                       wfd_sink_error("failed to create %s \n", x_factory);\
-                       goto CREATE_ERROR;\
+       do      { \
+               if (x_name && (strlen(x_factory) > 1)) {\
+                       x_bin[x_id].id = x_id;\
+                       x_bin[x_id].gst = gst_element_factory_make(x_factory, x_name);\
+                       if (! x_bin[x_id].gst)  {\
+                               wfd_sink_error("failed to create %s \n", x_factory);\
+                               goto CREATE_ERROR;\
+                       }\
+                       wfd_sink_debug("%s is created \n", x_factory);\
+                       if (x_add_bucket)\
+                               element_bucket = g_list_append(element_bucket, &x_bin[x_id]);\
                }\
-               wfd_sink_debug("%s is created \n", x_factory);\
-               if ( x_add_bucket )\
-                       element_bucket = g_list_append(element_bucket, &x_bin[x_id]);\
-       }\
-} while(0);
+       } while (0);
 
 /* generating dot */
-#define MMWFDSINK_GENERATE_DOT_IF_ENABLED( x_wfd_sink, x_name ) \
-if ( x_wfd_sink->ini.generate_dot ) \
-{ \
-       wfd_sink_debug ("create dot file : %s.dot", x_name);\
-       GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (x_wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst), \
-               GST_DEBUG_GRAPH_SHOW_ALL, x_name); \
-}
+#define MMWFDSINK_GENERATE_DOT_IF_ENABLED(x_wfd_sink, x_name) \
+       if (x_wfd_sink->ini.generate_dot) { \
+               wfd_sink_debug("create dot file : %s.dot", x_name);\
+               GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(x_wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst), \
+                                          GST_DEBUG_GRAPH_SHOW_ALL, x_name); \
+       }
 
 /* postint message */
-#define MMWFDSINK_POST_MESSAGE( x_wfd_sink, x_error_type, x_state_type ) \
-if (x_wfd_sink->msg_cb) \
-{ \
-       wfd_sink_debug("Message (error : %d, state : %d) will be posted using user callback\n", x_error_type, x_state_type); \
-       x_wfd_sink->msg_cb(x_error_type, x_state_type, x_wfd_sink->msg_user_data); \
-}
+#define MMWFDSINK_POST_MESSAGE(x_wfd_sink, x_error_type, x_state_type) \
+       if (x_wfd_sink->msg_cb) { \
+               wfd_sink_debug("Message(error : %d, state : %d) will be posted using user callback\n", x_error_type, x_state_type); \
+               x_wfd_sink->msg_cb(x_error_type, x_state_type, x_wfd_sink->msg_user_data); \
+       }
 
 
 /* state */
-#define MMWFDSINK_CURRENT_STATE( x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.state
-#define MMWFDSINK_PREVIOUS_STATE( x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.prev_state
-#define MMWFDSINK_PENDING_STATE( x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.pending_state
+#define MMWFDSINK_CURRENT_STATE(x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.state
+#define MMWFDSINK_PREVIOUS_STATE(x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.prev_state
+#define MMWFDSINK_PENDING_STATE(x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.pending_state
 #define MMWFDSINK_STATE_GET_NAME(x_state) __mm_wfds_sink_get_state_name(x_state)
 
 #define MMWFDSINK_PRINT_STATE(x_wfd_sink) \
-wfd_sink_debug("-- prev %s, current %s, pending %s --\n", \
-       MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PREVIOUS_STATE(x_wfd_sink)), \
-       MMWFDSINK_STATE_GET_NAME(MMWFDSINK_CURRENT_STATE(x_wfd_sink)), \
-       MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PENDING_STATE(x_wfd_sink)));
-
-#define MMWFDSINK_CHECK_STATE( x_wfd_sink, x_cmd) \
-switch ( __mm_wfd_sink_check_state((mm_wfd_sink_t *)x_wfd_sink, x_cmd) ) \
-{ \
+       wfd_sink_debug("--prev %s, current %s, pending %s--\n", \
+                      MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PREVIOUS_STATE(x_wfd_sink)), \
+                      MMWFDSINK_STATE_GET_NAME(MMWFDSINK_CURRENT_STATE(x_wfd_sink)), \
+                      MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PENDING_STATE(x_wfd_sink)));
+
+#define MMWFDSINK_CHECK_STATE(x_wfd_sink, x_cmd) \
+       switch (__mm_wfd_sink_check_state((mm_wfd_sink_t *)x_wfd_sink, x_cmd)) \
+       { \
        case MM_ERROR_NONE: \
                break;\
        case MM_ERROR_WFD_NO_OP: \
@@ -108,7 +101,7 @@ switch ( __mm_wfd_sink_check_state((mm_wfd_sink_t *)x_wfd_sink, x_cmd) ) \
        default: \
                return MM_ERROR_WFD_INVALID_STATE; \
                break; \
-}
+       }
 
 
 /* pad probe */
@@ -117,26 +110,21 @@ mm_wfd_sink_util_add_pad_probe(GstPad *pad, GstElement *element, const gchar *pa
 void
 mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer(GstPad *pad, GstElement *element, const gchar *pad_name);
 
-#define MMWFDSINK_PAD_PROBE( x_wfd_sink, x_pad, x_element, x_pad_name ) \
-if ( x_wfd_sink ) \
-{  \
-       if (x_wfd_sink->ini.enable_pad_probe ) \
-       { \
-               mm_wfd_sink_util_add_pad_probe (x_pad, x_element, (const gchar*)x_pad_name); \
-       } \
-       else \
-       {\
-               mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer (x_pad, x_element, (const gchar*)x_pad_name); \
-       }\
-}
+#define MMWFDSINK_PAD_PROBE(x_wfd_sink, x_pad, x_element, x_pad_name) \
+       if (x_wfd_sink) {  \
+               if (x_wfd_sink->ini.enable_pad_probe) { \
+                       mm_wfd_sink_util_add_pad_probe(x_pad, x_element, (const gchar*)x_pad_name); \
+               } else {\
+                       mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer (x_pad, x_element, (const gchar*)x_pad_name); \
+               }\
+       }
 
 void
 mm_wfd_sink_util_add_pad_probe_for_data_dump(GstElement *element, const gchar *pad_name);
 
-#define MMWFDSINK_TS_DATA_DUMP( x_wfd_sink, x_element, x_pad_name ) \
-if ( x_wfd_sink && x_wfd_sink->ini.enable_ts_data_dump ) \
-{ \
-       mm_wfd_sink_util_add_pad_probe_for_data_dump (x_element, (const gchar*)x_pad_name); \
-}
+#define MMWFDSINK_TS_DATA_DUMP(x_wfd_sink, x_element, x_pad_name) \
+       if (x_wfd_sink && x_wfd_sink->ini.enable_ts_data_dump) { \
+               mm_wfd_sink_util_add_pad_probe_for_data_dump (x_element, (const gchar*)x_pad_name); \
+       }
 
 #endif
index d9872c8..c7f6131 100755 (executable)
@@ -37,8 +37,7 @@ int mm_wfd_sink_create(MMHandleType *wfd_sink)
        wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        result = _mm_wfd_sink_create(&new_wfd_sink);
-       if (result != MM_ERROR_NONE)
-       {
+       if (result != MM_ERROR_NONE) {
                wfd_sink_error("fail to create wi-fi display sink handle. ret[%d]", result);
                *wfd_sink = (MMHandleType)NULL;
                return result;
@@ -59,7 +58,7 @@ int mm_wfd_sink_prepare(MMHandleType wfd_sink)
 {
        int result = MM_ERROR_NONE;
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        MMWFDSINK_CMD_LOCK(wfd_sink);
        result = _mm_wfd_sink_prepare((mm_wfd_sink_t *)wfd_sink);
@@ -72,8 +71,8 @@ int mm_wfd_sink_connect(MMHandleType wfd_sink, const char *uri)
 {
        int result = MM_ERROR_NONE;
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
-       wfd_sink_return_val_if_fail (uri, MM_ERROR_WFD_INVALID_ARGUMENT);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(uri, MM_ERROR_WFD_INVALID_ARGUMENT);
 
        MMWFDSINK_CMD_LOCK(wfd_sink);
        result = _mm_wfd_sink_connect((mm_wfd_sink_t *)wfd_sink, uri);
@@ -95,6 +94,32 @@ int mm_wfd_sink_start(MMHandleType wfd_sink)
        return result;
 }
 
+int mm_wfd_sink_pause(MMHandleType wfd_sink)
+{
+       int result = MM_ERROR_NONE;
+
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+
+       MMWFDSINK_CMD_LOCK(wfd_sink);
+       result = _mm_wfd_sink_pause((mm_wfd_sink_t *)wfd_sink);
+       MMWFDSINK_CMD_UNLOCK(wfd_sink);
+
+       return result;
+}
+
+int mm_wfd_sink_resume(MMHandleType wfd_sink)
+{
+       int result = MM_ERROR_NONE;
+
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+
+       MMWFDSINK_CMD_LOCK(wfd_sink);
+       result = _mm_wfd_sink_resume((mm_wfd_sink_t *)wfd_sink);
+       MMWFDSINK_CMD_UNLOCK(wfd_sink);
+
+       return result;
+}
+
 int mm_wfd_sink_disconnect(MMHandleType wfd_sink)
 {
        int result = MM_ERROR_NONE;
@@ -112,7 +137,7 @@ int mm_wfd_sink_unprepare(MMHandleType wfd_sink)
 {
        int result = MM_ERROR_NONE;
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        MMWFDSINK_CMD_LOCK(wfd_sink);
        result = _mm_wfd_sink_unprepare((mm_wfd_sink_t *)wfd_sink);
@@ -124,7 +149,7 @@ int mm_wfd_sink_unprepare(MMHandleType wfd_sink)
 int mm_wfd_sink_destroy(MMHandleType wfd_sink)
 {
        int result = MM_ERROR_NONE;
-       mm_wfd_sink_t * sink_handle = NULL;
+       mm_wfd_sink_t *sink_handle = NULL;
 
        wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
@@ -162,9 +187,9 @@ int mm_wfd_sink_set_attribute(MMHandleType wfd_sink,  char **err_attr_name, cons
        wfd_sink_return_val_if_fail(first_attribute_name, MM_ERROR_WFD_INVALID_ARGUMENT);
 
        MMWFDSINK_CMD_LOCK(wfd_sink);
-       va_start (var_args, first_attribute_name);
+       va_start(var_args, first_attribute_name);
        result = _mmwfd_set_attribute(MMWFDSINK_GET_ATTRS(wfd_sink), err_attr_name, first_attribute_name, var_args);
-       va_end (var_args);
+       va_end(var_args);
        MMWFDSINK_CMD_UNLOCK(wfd_sink);
 
        return result;
@@ -179,7 +204,7 @@ int mm_wfd_sink_get_video_resolution(MMHandleType wfd_sink, gint *width, gint *h
        wfd_sink_return_val_if_fail(height, MM_ERROR_WFD_INVALID_ARGUMENT);
 
        *width = wfd->stream_info.video_stream_info.width;
-       *height =wfd->stream_info.video_stream_info.height;
+       *height = wfd->stream_info.video_stream_info.height;
 
        return MM_ERROR_NONE;
 }
@@ -196,3 +221,16 @@ int mm_wfd_sink_get_video_framerate(MMHandleType wfd_sink, gint *frame_rate)
        return MM_ERROR_NONE;
 }
 
+int mm_wfd_sink_set_resolution(MMHandleType wfd_sink,  gint resolution)
+{
+       int result = MM_ERROR_NONE;
+
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       MMWFDSINK_CMD_LOCK(wfd_sink);
+       result = _mm_wfd_sink_set_resolution((mm_wfd_sink_t *)wfd_sink, resolution);
+       MMWFDSINK_CMD_UNLOCK(wfd_sink);
+
+       return result;
+}
+
+
index 719778c..034944f 100755 (executable)
@@ -30,7 +30,7 @@ int _mm_wfd_sink_init_manager(mm_wfd_sink_t *wfd_sink)
 {
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* create capture mutex */
        g_mutex_init(&(wfd_sink->manager_thread_mutex));
@@ -42,10 +42,9 @@ int _mm_wfd_sink_init_manager(mm_wfd_sink_t *wfd_sink)
 
        /* create video capture thread */
        wfd_sink->manager_thread =
-               g_thread_new ("__mm_wfd_sink_manager_thread", __mm_wfd_sink_manager_thread, (gpointer)wfd_sink);
-       if (wfd_sink->manager_thread == NULL)
-       {
-               wfd_sink_error ("failed to create manager thread\n");
+           g_thread_new("__mm_wfd_sink_manager_thread", __mm_wfd_sink_manager_thread, (gpointer)wfd_sink);
+       if (wfd_sink->manager_thread == NULL) {
+               wfd_sink_error("failed to create manager thread\n");
                goto failed_to_init;
        }
 
@@ -54,29 +53,28 @@ int _mm_wfd_sink_init_manager(mm_wfd_sink_t *wfd_sink)
        return MM_ERROR_NONE;
 
 failed_to_init:
-       g_mutex_clear (&(wfd_sink->manager_thread_mutex));
-       g_cond_clear (&(wfd_sink->manager_thread_cond));
+       g_mutex_clear(&(wfd_sink->manager_thread_mutex));
+       g_cond_clear(&(wfd_sink->manager_thread_cond));
 
        return MM_ERROR_WFD_INTERNAL;
 }
 
-int _mm_wfd_sink_release_manager(mm_wfd_sink_twfd_sink)
+int _mm_wfd_sink_release_manager(mm_wfd_sink_t *wfd_sink)
 {
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* release capture thread */
-       if ( wfd_sink->manager_thread )
-       {
+       if (wfd_sink->manager_thread) {
                WFD_SINK_MANAGER_LOCK(wfd_sink);
                WFD_SINK_MANAGER_SIGNAL_CMD(wfd_sink, WFD_SINK_MANAGER_CMD_EXIT);
                WFD_SINK_MANAGER_UNLOCK(wfd_sink);
 
                wfd_sink_debug("waitting for manager thread exit");
-               g_thread_join (wfd_sink->manager_thread);
-               g_mutex_clear (&(wfd_sink->manager_thread_mutex));
-               g_cond_clear (&(wfd_sink->manager_thread_cond));
+               g_thread_join(wfd_sink->manager_thread);
+               g_mutex_clear(&(wfd_sink->manager_thread_mutex));
+               g_cond_clear(&(wfd_sink->manager_thread_cond));
                wfd_sink_debug("manager thread released");
        }
 
@@ -88,7 +86,7 @@ int _mm_wfd_sink_release_manager(mm_wfd_sink_t* wfd_sink)
 static gpointer
 __mm_wfd_sink_manager_thread(gpointer data)
 {
-       mm_wfd_sink_t* wfd_sink = (mm_wfd_sink_t*) data;
+       mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *) data;
        gboolean link_auido_bin = FALSE;
        gboolean link_video_bin = FALSE;
        gboolean set_ready_audio_bin = FALSE;
@@ -97,25 +95,22 @@ __mm_wfd_sink_manager_thread(gpointer data)
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, NULL);
+       wfd_sink_return_val_if_fail(wfd_sink, NULL);
 
-       if (wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_EXIT)
-       {
+       if (wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_EXIT) {
                wfd_sink->manager_thread_cmd = WFD_SINK_MANAGER_CMD_EXIT;
                return NULL;
        }
 
        wfd_sink_debug("manager thread started. waiting for signal");
 
-       while (TRUE)
-       {
+       while (TRUE) {
                WFD_SINK_MANAGER_LOCK(wfd_sink);
                WFD_SINK_MANAGER_WAIT_CMD(wfd_sink);
 
                wfd_sink_debug("got command %x", wfd_sink->manager_thread_cmd);
 
-               if (wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_EXIT)
-               {
+               if (wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_EXIT) {
                        wfd_sink_debug("exiting manager thread");
                        goto EXIT;
                }
@@ -124,53 +119,44 @@ __mm_wfd_sink_manager_thread(gpointer data)
                link_auido_bin = wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_LINK_A_BIN;
                link_video_bin = wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_LINK_V_BIN;
                set_ready_audio_bin = wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_PREPARE_A_BIN;
-               if (set_ready_audio_bin && !link_auido_bin && !wfd_sink->audio_bin_is_linked)
-               {
+               if (set_ready_audio_bin && !link_auido_bin && !wfd_sink->audio_bin_is_linked) {
                        wfd_sink_error("audio bin is not linked... wait for command for linking audiobin");
                        WFD_SINK_MANAGER_UNLOCK(wfd_sink);
                        continue;
                }
                set_ready_video_bin = wfd_sink->manager_thread_cmd & WFD_SINK_MANAGER_CMD_PREPARE_V_BIN;
-               if (set_ready_video_bin && !link_video_bin && !wfd_sink->video_bin_is_linked)
-               {
+               if (set_ready_video_bin && !link_video_bin && !wfd_sink->video_bin_is_linked) {
                        wfd_sink_error("video bin is not linked... wait for command for linking videobin.");
                        WFD_SINK_MANAGER_UNLOCK(wfd_sink);
                        continue;
                }
 
                /* link audio bin*/
-               if (link_auido_bin)
-               {
+               if (link_auido_bin) {
                        wfd_sink_debug("try to link audiobin.");
-                       if (MM_ERROR_NONE !=__mm_wfd_sink_link_audiobin(wfd_sink))
-                       {
-                               wfd_sink_error ("failed to link audiobin.....\n");
+                       if (MM_ERROR_NONE != __mm_wfd_sink_link_audiobin(wfd_sink)) {
+                               wfd_sink_error("failed to link audiobin.....\n");
                                goto EXIT;
                        }
                }
 
                /* link video bin*/
-               if (link_video_bin)
-               {
+               if (link_video_bin) {
                        wfd_sink_debug("try to link videobin.");
                }
 
-               if (set_ready_audio_bin)
-               {
+               if (set_ready_audio_bin) {
                        wfd_sink_debug("try to prepare audiobin.");
-                       if (MM_ERROR_NONE !=__mm_wfd_sink_prepare_audiobin(wfd_sink))
-                       {
-                               wfd_sink_error ("failed to prepare audiobin.....\n");
+                       if (MM_ERROR_NONE != __mm_wfd_sink_prepare_audiobin(wfd_sink)) {
+                               wfd_sink_error("failed to prepare audiobin.....\n");
                                goto EXIT;
                        }
                }
 
-               if (set_ready_video_bin)
-               {
+               if (set_ready_video_bin) {
                        wfd_sink_debug("try to prepare videobin.");
-                       if (MM_ERROR_NONE !=__mm_wfd_sink_prepare_videobin(wfd_sink))
-                       {
-                               wfd_sink_error ("failed to prepare videobin.....\n");
+                       if (MM_ERROR_NONE != __mm_wfd_sink_prepare_videobin(wfd_sink)) {
+                               wfd_sink_error("failed to prepare videobin.....\n");
                                goto EXIT;
                        }
                }
index d925374..fa16e76 100755 (executable)
@@ -27,6 +27,7 @@
 #include "mm_wfd_sink_priv.h"
 #include "mm_wfd_sink_manager.h"
 #include "mm_wfd_sink_dlog.h"
+#include <wfdconfigmessage.h>
 
 
 /* gstreamer */
@@ -34,16 +35,18 @@ static int __mm_wfd_sink_init_gstreamer(mm_wfd_sink_t *wfd_sink);
 static int __mm_wfd_sink_create_pipeline(mm_wfd_sink_t *wfd_sink);
 static int __mm_wfd_sink_create_videobin(mm_wfd_sink_t *wfd_sink);
 static int __mm_wfd_sink_create_audiobin(mm_wfd_sink_t *wfd_sink);
- static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t* wfd_sink);
-static int __mm_wfd_sink_set_pipeline_state(mm_wfd_sink_twfd_sink, GstState state, gboolean async);
+static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink);
+static int __mm_wfd_sink_set_pipeline_state(mm_wfd_sink_t *wfd_sink, GstState state, gboolean async);
 
 /* state */
-static int __mm_wfd_sink_check_state(mm_wfd_sink_twfd_sink, MMWFDSinkCommandType cmd);
-static int __mm_wfd_sink_set_state(mm_wfd_sink_twfd_sink, MMWFDSinkStateType state);
+static int __mm_wfd_sink_check_state(mm_wfd_sink_t *wfd_sink, MMWFDSinkCommandType cmd);
+static int __mm_wfd_sink_set_state(mm_wfd_sink_t *wfd_sink, MMWFDSinkStateType state);
 
 /* util */
 static void __mm_wfd_sink_dump_pipeline_state(mm_wfd_sink_t *wfd_sink);
-const gchar * __mm_wfds_sink_get_state_name ( MMWFDSinkStateType state );
+const gchar *__mm_wfds_sink_get_state_name(MMWFDSinkStateType state);
+static void __mm_wfd_sink_prepare_video_resolution(gint resolution, guint *CEA_resolution,
+                                                   guint *VESA_resolution, guint *HH_resolution);
 
 int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink)
 {
@@ -57,8 +60,7 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink)
 
        /* create handle */
        new_wfd_sink = g_malloc0(sizeof(mm_wfd_sink_t));
-       if (!new_wfd_sink)
-       {
+       if (!new_wfd_sink) {
                wfd_sink_error("failed to allocate memory for wi-fi display sink\n");
                return MM_ERROR_WFD_NO_FREE_SPACE;
        }
@@ -85,9 +87,9 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink)
        new_wfd_sink->last_buffer_timestamp = GST_CLOCK_TIME_NONE;
 
        /* Initialize all states */
-       MMWFDSINK_CURRENT_STATE (new_wfd_sink) = MM_WFD_SINK_STATE_NONE;
-       MMWFDSINK_PREVIOUS_STATE (new_wfd_sink) =  MM_WFD_SINK_STATE_NONE;
-       MMWFDSINK_PENDING_STATE (new_wfd_sink) =  MM_WFD_SINK_STATE_NONE;
+       MMWFDSINK_CURRENT_STATE(new_wfd_sink) = MM_WFD_SINK_STATE_NONE;
+       MMWFDSINK_PREVIOUS_STATE(new_wfd_sink) =  MM_WFD_SINK_STATE_NONE;
+       MMWFDSINK_PENDING_STATE(new_wfd_sink) =  MM_WFD_SINK_STATE_NONE;
 
        /* initialize audio/video information */
        new_wfd_sink->stream_info.audio_stream_info.codec = WFD_SINK_AUDIO_CODEC_NONE;
@@ -110,19 +112,20 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink)
        new_wfd_sink->manager_thread = NULL;
        new_wfd_sink->manager_thread_cmd = WFD_SINK_MANAGER_CMD_NONE;
 
+       /* Initialize video resolution */
+       new_wfd_sink->supportive_resolution = MM_WFD_SINK_RESOLUTION_UNKNOWN;
+
        /* construct attributes */
        new_wfd_sink->attrs = _mmwfd_construct_attribute((MMHandleType)new_wfd_sink);
-       if (!new_wfd_sink->attrs)
-       {
-               MMWFDSINK_FREEIF (new_wfd_sink);
+       if (!new_wfd_sink->attrs) {
+               MMWFDSINK_FREEIF(new_wfd_sink);
                wfd_sink_error("failed to set attribute\n");
                return MM_ERROR_WFD_INTERNAL;
        }
 
        /* load ini for initialize */
        result = mm_wfd_sink_ini_load(&new_wfd_sink->ini);
-       if (result != MM_ERROR_NONE)
-       {
+       if (result != MM_ERROR_NONE) {
                wfd_sink_error("failed to load ini file\n");
                goto fail_to_load_ini;
        }
@@ -130,16 +133,14 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink)
 
        /* initialize manager */
        result = _mm_wfd_sink_init_manager(new_wfd_sink);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("failed to init manager : %d\n", result);
                goto fail_to_init;
        }
 
        /* initialize gstreamer */
        result = __mm_wfd_sink_init_gstreamer(new_wfd_sink);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("failed to init gstreamer : %d\n", result);
                goto fail_to_init;
        }
@@ -154,58 +155,54 @@ int _mm_wfd_sink_create(mm_wfd_sink_t **wfd_sink)
 
        return result;
 
-/* ERRORS */
+       /* ERRORS */
 fail_to_init:
        mm_wfd_sink_ini_unload(&new_wfd_sink->ini);
 fail_to_load_ini:
        _mmwfd_deconstruct_attribute(new_wfd_sink->attrs);
-       MMWFDSINK_FREEIF (new_wfd_sink);
+       MMWFDSINK_FREEIF(new_wfd_sink);
 
        *wfd_sink = NULL;
 
        return result;
 }
 
-int _mm_wfd_sink_prepare (mm_wfd_sink_t *wfd_sink)
+int _mm_wfd_sink_prepare(mm_wfd_sink_t *wfd_sink)
 {
        int result = MM_ERROR_NONE;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* check current wi-fi display sink state */
-       MMWFDSINK_CHECK_STATE (wfd_sink, MM_WFD_SINK_COMMAND_PREPARE);
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_PREPARE);
 
        /* construct pipeline */
        /* create main pipeline */
        result = __mm_wfd_sink_create_pipeline(wfd_sink);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("failed to create pipeline : %d\n", result);
                goto fail_to_create;
        }
 
        /* create videobin */
        result = __mm_wfd_sink_create_videobin(wfd_sink);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("failed to create videobin : %d\n", result);
                goto fail_to_create;
        }
 
        /* create audiobin */
        result = __mm_wfd_sink_create_audiobin(wfd_sink);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("fail to create audiobin : %d\n", result);
                goto fail_to_create;
        }
 
        /* set pipeline READY state */
        result = __mm_wfd_sink_set_pipeline_state(wfd_sink, GST_STATE_READY, TRUE);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("failed to set state : %d\n", result);
                goto fail_to_create;
        }
@@ -217,42 +214,41 @@ int _mm_wfd_sink_prepare (mm_wfd_sink_t *wfd_sink)
 
        return result;
 
-  /* ERRORS */
+       /* ERRORS */
 fail_to_create:
        /* need to destroy pipeline already created */
        __mm_wfd_sink_destroy_pipeline(wfd_sink);
        return result;
 }
 
-int _mm_wfd_sink_connect (mm_wfd_sink_t *wfd_sink, const char *uri)
+int _mm_wfd_sink_connect(mm_wfd_sink_t *wfd_sink, const char *uri)
 {
        int result = MM_ERROR_NONE;
 
        wfd_sink_debug_fenter();
 
        wfd_sink_return_val_if_fail(uri && strlen(uri) > strlen("rtsp://"),
-               MM_ERROR_WFD_INVALID_ARGUMENT);
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->mainbin &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_DEPAY].gst &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_DEMUX].gst,
-               MM_ERROR_WFD_NOT_INITIALIZED);
+                                   MM_ERROR_WFD_INVALID_ARGUMENT);
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline &&
+                                   wfd_sink->pipeline->mainbin &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_DEPAY].gst &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_DEMUX].gst,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* check current wi-fi display sink state */
-       MMWFDSINK_CHECK_STATE (wfd_sink, MM_WFD_SINK_COMMAND_CONNECT);
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_CONNECT);
 
-       wfd_sink_debug ("try to connect to %s.....\n", GST_STR_NULL(uri));
+       wfd_sink_debug("try to connect to %s.....\n", GST_STR_NULL(uri));
 
        /* set uri to wfdrtspsrc */
-       g_object_set (G_OBJECT(wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst), "location", uri, NULL);
+       g_object_set(G_OBJECT(wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst), "location", uri, NULL);
 
        /* set pipeline PAUSED state */
        result = __mm_wfd_sink_set_pipeline_state(wfd_sink, GST_STATE_PAUSED, TRUE);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("failed to set state : %d\n", result);
                return result;
        }
@@ -268,18 +264,17 @@ int _mm_wfd_sink_start(mm_wfd_sink_t *wfd_sink)
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* check current wi-fi display sink state */
-       MMWFDSINK_CHECK_STATE (wfd_sink, MM_WFD_SINK_COMMAND_START);
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_START);
 
        WFD_SINK_MANAGER_LOCK(wfd_sink) ;
        wfd_sink_debug("check pipeline is ready to start");
        WFD_SINK_MANAGER_UNLOCK(wfd_sink);
 
        result = __mm_wfd_sink_set_pipeline_state(wfd_sink, GST_STATE_PLAYING, TRUE);
-       if (result < MM_ERROR_NONE)
-       {
+       if (result < MM_ERROR_NONE) {
                wfd_sink_error("failed to set state : %d\n", result);
                return result;
        }
@@ -289,30 +284,64 @@ int _mm_wfd_sink_start(mm_wfd_sink_t *wfd_sink)
        return result;
 }
 
+int _mm_wfd_sink_pause(mm_wfd_sink_t *wfd_sink)
+{
+       int result = MM_ERROR_NONE;
+
+       wfd_sink_debug_fenter();
+
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline &&
+                                   wfd_sink->pipeline->mainbin &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
+
+       /* check current wi-fi display sink state */
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_PAUSE);
+
+       g_signal_emit_by_name(wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst, "pause", NULL);
+
+       wfd_sink_debug_fleave();
+
+       return result;
+}
+
+int _mm_wfd_sink_resume(mm_wfd_sink_t *wfd_sink)
+{
+       int result = MM_ERROR_NONE;
+
+       wfd_sink_debug_fenter();
+
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+
+       /* check current wi-fi display sink state */
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_RESUME);
+
+       g_signal_emit_by_name(wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst, "resume", NULL);
+
+       wfd_sink_debug_fleave();
+
+       return result;
+}
+
 int _mm_wfd_sink_disconnect(mm_wfd_sink_t *wfd_sink)
 {
        int result = MM_ERROR_NONE;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* check current wi-fi display sink state */
-       MMWFDSINK_CHECK_STATE (wfd_sink, MM_WFD_SINK_COMMAND_DISCONNECT);
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_DISCONNECT);
 
        WFD_SINK_MANAGER_LOCK(wfd_sink) ;
        WFD_SINK_MANAGER_SIGNAL_CMD(wfd_sink, WFD_SINK_MANAGER_CMD_EXIT);
        WFD_SINK_MANAGER_UNLOCK(wfd_sink);
 
-       result = __mm_wfd_sink_set_pipeline_state (wfd_sink, GST_STATE_READY, FALSE);
-       if (result < MM_ERROR_NONE)
-       {
-               wfd_sink_error("fail to set state : %d\n", result);
-               return result;
-       }
+       g_signal_emit_by_name(wfd_sink->pipeline->mainbin[WFD_SINK_M_SRC].gst, "close", NULL);
 
-       /* set state */
-       __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_DISCONNECTED);
 
        wfd_sink_debug_fleave();
 
@@ -328,21 +357,18 @@ int _mm_wfd_sink_unprepare(mm_wfd_sink_t *wfd_sink)
        wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* check current wi-fi display sink state */
-       MMWFDSINK_CHECK_STATE (wfd_sink, MM_WFD_SINK_COMMAND_UNPREPARE);
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_UNPREPARE);
 
        WFD_SINK_MANAGER_LOCK(wfd_sink) ;
        WFD_SINK_MANAGER_SIGNAL_CMD(wfd_sink, WFD_SINK_MANAGER_CMD_EXIT);
        WFD_SINK_MANAGER_UNLOCK(wfd_sink);
 
        /* release pipeline */
-       result =  __mm_wfd_sink_destroy_pipeline (wfd_sink);
-       if ( result != MM_ERROR_NONE)
-       {
+       result =  __mm_wfd_sink_destroy_pipeline(wfd_sink);
+       if (result != MM_ERROR_NONE) {
                wfd_sink_error("failed to destory pipeline\n");
                return MM_ERROR_WFD_INTERNAL;
-       }
-       else
-       {
+       } else {
                wfd_sink_debug("success to destory pipeline\n");
        }
 
@@ -363,7 +389,7 @@ int _mm_wfd_sink_destroy(mm_wfd_sink_t *wfd_sink)
        wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* check current wi-fi display sink state */
-       MMWFDSINK_CHECK_STATE (wfd_sink, MM_WFD_SINK_COMMAND_DESTROY);
+       MMWFDSINK_CHECK_STATE(wfd_sink, MM_WFD_SINK_COMMAND_DESTROY);
 
        /* unload ini */
        mm_wfd_sink_ini_unload(&wfd_sink->ini);
@@ -371,8 +397,7 @@ int _mm_wfd_sink_destroy(mm_wfd_sink_t *wfd_sink)
        /* release attributes */
        _mmwfd_deconstruct_attribute(wfd_sink->attrs);
 
-       if (MM_ERROR_NONE != _mm_wfd_sink_release_manager(wfd_sink))
-       {
+       if (MM_ERROR_NONE != _mm_wfd_sink_release_manager(wfd_sink)) {
                wfd_sink_error("failed to release manager\n");
                return MM_ERROR_WFD_INTERNAL;
        }
@@ -392,7 +417,7 @@ int _mm_wfd_set_message_callback(mm_wfd_sink_t *wfd_sink, MMWFDMessageCallback c
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        wfd_sink->msg_cb = callback;
        wfd_sink->msg_user_data = user_data;
@@ -405,8 +430,8 @@ int _mm_wfd_set_message_callback(mm_wfd_sink_t *wfd_sink, MMWFDMessageCallback c
 static int __mm_wfd_sink_init_gstreamer(mm_wfd_sink_t *wfd_sink)
 {
        int result = MM_ERROR_NONE;
-       gintargc = NULL;
-       gchar** argv = NULL;
+       gint *argc = NULL;
+       gchar **argv = NULL;
        static const int max_argc = 50;
        GError *err = NULL;
        gint i = 0;
@@ -414,10 +439,9 @@ static int __mm_wfd_sink_init_gstreamer(mm_wfd_sink_t *wfd_sink)
        wfd_sink_debug_fenter();
 
        /* alloc */
-       argc = calloc(1, sizeof(gint) );
-       argv = calloc(max_argc, sizeof(gchar*));
-       if (!argc || !argv)
-       {
+       argc = calloc(1, sizeof(gint));
+       argv = calloc(max_argc, sizeof(gchar *));
+       if (!argc || !argv) {
                wfd_sink_error("failed to allocate memory for wfdsink\n");
 
                MMWFDSINK_FREEIF(argv);
@@ -439,10 +463,8 @@ static int __mm_wfd_sink_init_gstreamer(mm_wfd_sink_t *wfd_sink)
        (*argc)++;
 
        /* check ini */
-       for (i=0; i<5; i++)
-       {
-               if (strlen( wfd_sink->ini.gst_param[i] ) > 2)
-               {
+       for (i = 0; i < 5; i++) {
+               if (strlen(wfd_sink->ini.gst_param[i]) > 2) {
                        wfd_sink_debug("set %s\n", wfd_sink->ini.gst_param[i]);
                        argv[*argc] = g_strdup(wfd_sink->ini.gst_param[i]);
                        (*argc)++;
@@ -452,26 +474,23 @@ static int __mm_wfd_sink_init_gstreamer(mm_wfd_sink_t *wfd_sink)
        wfd_sink_debug("initializing gstreamer with following parameter\n");
        wfd_sink_debug("argc : %d\n", *argc);
 
-       for ( i = 0; i < *argc; i++ )
-       {
+       for (i = 0; i < *argc; i++) {
                wfd_sink_debug("argv[%d] : %s\n", i, argv[i]);
        }
 
        /* initializing gstreamer */
-       if ( ! gst_init_check (argc, &argv, &err))
-       {
+       if (!gst_init_check(argc, &argv, &err)) {
                wfd_sink_error("failed to initialize gstreamer: %s\n",
-                       err ? err->message : "unknown error occurred");
+                              err ? err->message : "unknown error occurred");
                if (err)
-                       g_error_free (err);
+                       g_error_free(err);
 
                result = MM_ERROR_WFD_INTERNAL;
        }
 
        /* release */
-       for ( i = 0; i < *argc; i++ )
-       {
-               MMWFDSINK_FREEIF( argv[i] );
+       for (i = 0; i < *argc; i++) {
+               MMWFDSINK_FREEIF(argv[i]);
        }
        MMWFDSINK_FREEIF(argv);
        MMWFDSINK_FREEIF(argc);
@@ -482,50 +501,47 @@ static int __mm_wfd_sink_init_gstreamer(mm_wfd_sink_t *wfd_sink)
 }
 
 static void
-_mm_wfd_sink_correct_pipeline_latency (mm_wfd_sink_t *wfd_sink)
+_mm_wfd_sink_correct_pipeline_latency(mm_wfd_sink_t *wfd_sink)
 {
        GstQuery *qlatency;
        GstClockTime min_latency;
 
        qlatency = gst_query_new_latency();
-       gst_element_query (wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst, qlatency);
-       gst_query_parse_latency (qlatency, NULL, &min_latency, NULL);
+       gst_element_query(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst, qlatency);
+       gst_query_parse_latency(qlatency, NULL, &min_latency, NULL);
 
-       debug_msg ("Correct manually pipeline latency: current=%"GST_TIME_FORMAT, GST_TIME_ARGS (min_latency));
-       g_object_set (wfd_sink->pipeline->videobin[WFD_SINK_V_SINK].gst, "ts-offset", -(gint64)(min_latency*9/10), NULL);
-       g_object_set (wfd_sink->pipeline->audiobin[WFD_SINK_A_SINK].gst, "ts-offset", -(gint64)(min_latency*9/10), NULL);
+       debug_msg("Correct manually pipeline latency: current=%"GST_TIME_FORMAT, GST_TIME_ARGS(min_latency));
+       g_object_set(wfd_sink->pipeline->videobin[WFD_SINK_V_SINK].gst, "ts-offset", -(gint64)(min_latency * 9 / 10), NULL);
+       g_object_set(wfd_sink->pipeline->audiobin[WFD_SINK_A_SINK].gst, "ts-offset", -(gint64)(min_latency * 9 / 10), NULL);
        gst_query_unref(qlatency);
 }
 
 static GstBusSyncReply
-_mm_wfd_bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data)
+_mm_wfd_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
 {
        GstBusSyncReply ret = GST_BUS_PASS;
 
-       wfd_sink_return_val_if_fail (message &&
-               GST_IS_MESSAGE(message) &&
-               GST_MESSAGE_SRC(message),
-               GST_BUS_DROP);
+       wfd_sink_return_val_if_fail(message &&
+                                   GST_IS_MESSAGE(message) &&
+                                   GST_MESSAGE_SRC(message),
+                                   GST_BUS_DROP);
 
-       switch (GST_MESSAGE_TYPE (message))
-       {
+       switch (GST_MESSAGE_TYPE(message)) {
                case GST_MESSAGE_TAG:
-               break;
+                       break;
                case GST_MESSAGE_DURATION:
-               break;
-               case GST_MESSAGE_STATE_CHANGED:
-               {
-                       /* we only handle state change messages from pipeline */
-                       if (!GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
-                               ret = GST_BUS_DROP;
-               }
-               break;
-               case GST_MESSAGE_ASYNC_DONE:
-               {
-                       if (!GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
-                               ret = GST_BUS_DROP;
-               }
-               break;
+                       break;
+               case GST_MESSAGE_STATE_CHANGED: {
+                               /* we only handle state change messages from pipeline */
+                               if (!GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
+                                       ret = GST_BUS_DROP;
+                       }
+                       break;
+               case GST_MESSAGE_ASYNC_DONE: {
+                               if (!GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
+                                       ret = GST_BUS_DROP;
+                       }
+                       break;
                default:
                        break;
        }
@@ -534,242 +550,217 @@ _mm_wfd_bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data)
 }
 
 static gboolean
-_mm_wfd_sink_msg_callback (GstBus *bus, GstMessage *msg, gpointer data)
+_mm_wfd_sink_msg_callback(GstBus *bus, GstMessage *msg, gpointer data)
 {
-       mm_wfd_sink_t* wfd_sink = (mm_wfd_sink_t*) data;
-       const GstStructuremessage_structure = gst_message_get_structure(msg);
+       mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *) data;
+       const GstStructure *message_structure = gst_message_get_structure(msg);
        gboolean ret = TRUE;
 
-       wfd_sink_return_val_if_fail (wfd_sink, FALSE);
-       wfd_sink_return_val_if_fail (msg && GST_IS_MESSAGE(msg), FALSE);
+       wfd_sink_return_val_if_fail(wfd_sink, FALSE);
+       wfd_sink_return_val_if_fail(msg && GST_IS_MESSAGE(msg), FALSE);
 
        wfd_sink_debug("got %s from %s \n",
-               GST_STR_NULL(GST_MESSAGE_TYPE_NAME(msg)),
-               GST_STR_NULL(GST_OBJECT_NAME(GST_MESSAGE_SRC(msg))));
+                      GST_STR_NULL(GST_MESSAGE_TYPE_NAME(msg)),
+                      GST_STR_NULL(GST_OBJECT_NAME(GST_MESSAGE_SRC(msg))));
 
-       switch (GST_MESSAGE_TYPE (msg))
-       {
-               case GST_MESSAGE_ERROR:
-               {
-                       GError *error = NULL;
-                       gchar* debug = NULL;
+       switch (GST_MESSAGE_TYPE(msg)) {
+               case GST_MESSAGE_ERROR: {
+                               GError *error = NULL;
+                               gchar *debug = NULL;
 
-                       /* get error code */
-                       gst_message_parse_error( msg, &error, &debug );
+                               /* get error code */
+                               gst_message_parse_error(msg, &error, &debug);
 
-                       wfd_sink_error("error : %s\n", error->message);
-                       wfd_sink_error("debug : %s\n", debug);
+                               wfd_sink_error("error : %s\n", error->message);
+                               wfd_sink_error("debug : %s\n", debug);
 
-                       MMWFDSINK_FREEIF( debug );
-                       g_error_free( error );
-               }
-               break;
+                               MMWFDSINK_FREEIF(debug);
+                               g_error_free(error);
+                       }
+                       break;
 
-               case GST_MESSAGE_WARNING:
-               {
-                       char* debug = NULL;
-                       GError* error = NULL;
+               case GST_MESSAGE_WARNING: {
+                               char *debug = NULL;
+                               GError *error = NULL;
 
-                       gst_message_parse_warning(msg, &error, &debug);
+                               gst_message_parse_warning(msg, &error, &debug);
 
-                       wfd_sink_error("warning : %s\n", error->message);
-                       wfd_sink_error("debug : %s\n", debug);
+                               wfd_sink_error("warning : %s\n", error->message);
+                               wfd_sink_error("debug : %s\n", debug);
 
-                       MMWFDSINK_FREEIF (debug);
-                       g_error_free (error);
-               }
-               break;
-
-               case GST_MESSAGE_STATE_CHANGED:
-               {
-                       const GValue *voldstate, *vnewstate, *vpending;
-                       GstState oldstate, newstate, pending;
-                       const GstStructure *structure;
-
-                       /* we only handle messages from pipeline */
-                       if (msg->src != (GstObject *)wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst )
-                               break;
-
-                       /* get state info from msg */
-                       structure = gst_message_get_structure(msg);
-                       voldstate = gst_structure_get_value (structure, "old-state");
-                       vnewstate = gst_structure_get_value (structure, "new-state");
-                       vpending = gst_structure_get_value (structure, "pending-state");
-
-                       oldstate = (GstState)voldstate->data[0].v_int;
-                       newstate = (GstState)vnewstate->data[0].v_int;
-                       pending = (GstState)vpending->data[0].v_int;
-
-                       wfd_sink_debug("state changed [%s] : %s ---> %s final : %s\n",
-                               GST_OBJECT_NAME(GST_MESSAGE_SRC(msg)),
-                               gst_element_state_get_name( (GstState)oldstate ),
-                               gst_element_state_get_name( (GstState)newstate ),
-                               gst_element_state_get_name( (GstState)pending ) );
-
-                       if (oldstate == newstate)
-                       {
-                               wfd_sink_error("pipeline reports state transition to old state\n");
-                               break;
+                               MMWFDSINK_FREEIF(debug);
+                               g_error_free(error);
                        }
+                       break;
 
-                       switch(newstate)
-                       {
-                               case GST_STATE_VOID_PENDING:
-                               case GST_STATE_NULL:
-                               case GST_STATE_READY:
-                               case GST_STATE_PAUSED:
-                               case GST_STATE_PLAYING:
-                               default:
-                               break;
-                       }
-               }
-               break;
-
-               case GST_MESSAGE_CLOCK_LOST:
-               {
-                       GstClock *clock = NULL;
-                       gst_message_parse_clock_lost (msg, &clock);
-                       wfd_sink_debug("The current clock[%s] as selected by the pipeline became unusable.",
-                               (clock ? GST_OBJECT_NAME (clock) : "NULL"));
-               }
-               break;
-
-               case GST_MESSAGE_NEW_CLOCK:
-               {
-                       GstClock *clock = NULL;
-                       gst_message_parse_new_clock (msg, &clock);
-                       if (!clock)
-                               break;
-
-                       if (wfd_sink->clock)
-                       {
-                               if (wfd_sink->clock != clock)
-                                       wfd_sink_debug("clock is changed! [%s] --> [%s]\n",
-                                               GST_STR_NULL(GST_OBJECT_NAME (wfd_sink->clock)),
-                                               GST_STR_NULL(GST_OBJECT_NAME (clock)));
-                               else
-                                       wfd_sink_debug("same clock is selected again! [%s] \n",
-                                               GST_STR_NULL(GST_OBJECT_NAME (clock)));
-                       }
-                       else
-                       {
-                               wfd_sink_debug("new clock [%s] was selected in the pipeline\n",
-                                       (GST_STR_NULL(GST_OBJECT_NAME (clock))));
-                       }
+               case GST_MESSAGE_STATE_CHANGED: {
+                               const GValue *voldstate, *vnewstate, *vpending;
+                               GstState oldstate, newstate, pending;
+                               const GstStructure *structure;
 
-                       wfd_sink->clock = clock;
-               }
-               break;
+                               /* we only handle messages from pipeline */
+                               if (msg->src != (GstObject *)wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst)
+                                       break;
 
-               case GST_MESSAGE_APPLICATION:
-               {
-                       const gchar* message_structure_name;
+                               /* get state info from msg */
+                               structure = gst_message_get_structure(msg);
+                               if (structure == NULL)
+                                       break;
 
-                       message_structure_name = gst_structure_get_name(message_structure);
-                       if (!message_structure_name)
-                               break;
+                               voldstate = gst_structure_get_value(structure, "old-state");
+                               vnewstate = gst_structure_get_value(structure, "new-state");
+                               vpending = gst_structure_get_value(structure, "pending-state");
 
-                       wfd_sink_debug ("message name : %s", GST_STR_NULL(message_structure_name));
-               }
-               break;
-
-               case GST_MESSAGE_ELEMENT:
-               {
-                       const gchar *structure_name = NULL;
-                       const GstStructure* message_structure = NULL;
-
-                       message_structure = gst_message_get_structure(msg);
-                       structure_name = gst_structure_get_name(message_structure);
-                       if (structure_name)
-                       {
-                               wfd_sink_debug("got element specific message[%s]\n", GST_STR_NULL(structure_name));
-                               if(g_strrstr(structure_name, "GstUDPSrcTimeout"))
-                               {
-                                       wfd_sink_error("Got %s, post error message\n", GST_STR_NULL(structure_name));
-                                       MMWFDSINK_POST_MESSAGE(wfd_sink,
-                                               MM_ERROR_WFD_INTERNAL,
-                                               MMWFDSINK_CURRENT_STATE(wfd_sink));
+                               oldstate = (GstState)voldstate->data[0].v_int;
+                               newstate = (GstState)vnewstate->data[0].v_int;
+                               pending = (GstState)vpending->data[0].v_int;
+
+                               wfd_sink_debug("state changed [%s] : %s--->%s final : %s\n",
+                                              GST_OBJECT_NAME(GST_MESSAGE_SRC(msg)),
+                                              gst_element_state_get_name((GstState)oldstate),
+                                              gst_element_state_get_name((GstState)newstate),
+                                              gst_element_state_get_name((GstState)pending));
+
+                               if (oldstate == newstate) {
+                                       wfd_sink_error("pipeline reports state transition to old state\n");
+                                       break;
                                }
-                       }
-               }
-               break;
 
-               case GST_MESSAGE_PROGRESS:
-               {
-                       GstProgressType type = GST_PROGRESS_TYPE_ERROR;
-                       gchar *category=NULL, *text=NULL;
+                               switch (newstate) {
+                                       case GST_STATE_VOID_PENDING:
+                                       case GST_STATE_NULL:
+                                       case GST_STATE_READY:
+                                       case GST_STATE_PAUSED:
+                                       case GST_STATE_PLAYING:
+                                       default:
+                                               break;
+                               }
+                       }
+                       break;
 
-                       gst_message_parse_progress (msg, &type, &category, &text);
-                       wfd_sink_debug("%s : %s \n", GST_STR_NULL(category), GST_STR_NULL(text));
+               case GST_MESSAGE_CLOCK_LOST: {
+                               GstClock *clock = NULL;
+                               gst_message_parse_clock_lost(msg, &clock);
+                               wfd_sink_debug("The current clock[%s] as selected by the pipeline became unusable.",
+                                              (clock ? GST_OBJECT_NAME(clock) : "NULL"));
+                       }
+                       break;
 
-                       switch (type)
-                       {
-                               case GST_PROGRESS_TYPE_START:
+               case GST_MESSAGE_NEW_CLOCK: {
+                               GstClock *clock = NULL;
+                               gst_message_parse_new_clock(msg, &clock);
+                               if (!clock)
                                        break;
-                               case GST_PROGRESS_TYPE_COMPLETE:
-                                       if (category && !strcmp (category, "open"))
-                                               __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_CONNECTED);
-                                       else if (category && !strcmp (category, "play"))
-                                       {
-                                               __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_PLAYING);
-                                               //_mm_wfd_sink_correct_pipeline_latency (wfd_sink);
-                                       }
-                                       else if (category && !strcmp (category, "pause"))
-                                               __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_PAUSED);
-                                       else if (category && !strcmp (category, "close"))
-                                               __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_DISCONNECTED);
 
+                               if (wfd_sink->clock) {
+                                       if (wfd_sink->clock != clock)
+                                               wfd_sink_debug("clock is changed! [%s] -->[%s]\n",
+                                                              GST_STR_NULL(GST_OBJECT_NAME(wfd_sink->clock)),
+                                                              GST_STR_NULL(GST_OBJECT_NAME(clock)));
+                                       else
+                                               wfd_sink_debug("same clock is selected again! [%s] \n",
+                                                              GST_STR_NULL(GST_OBJECT_NAME(clock)));
+                               } else {
+                                       wfd_sink_debug("new clock [%s] was selected in the pipeline\n",
+                                                      (GST_STR_NULL(GST_OBJECT_NAME(clock))));
+                               }
 
+                               wfd_sink->clock = clock;
+                       }
+                       break;
+
+               case GST_MESSAGE_APPLICATION: {
+                               const gchar *message_structure_name;
+
+                               message_structure_name = gst_structure_get_name(message_structure);
+                               if (!message_structure_name)
                                        break;
-                               case GST_PROGRESS_TYPE_CANCELED:
-                                       break;
-                               case GST_PROGRESS_TYPE_ERROR:
-                                       if (category && !strcmp (category, "open"))
-                                       {
-                                               wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
-                                               //_mm_wfd_sink_disconnect (wfd_sink);
-                                               MMWFDSINK_POST_MESSAGE(wfd_sink,
-                                                       MM_ERROR_WFD_INTERNAL,
-                                                       MMWFDSINK_CURRENT_STATE(wfd_sink));
-                                       }
-                                       else if (category && !strcmp (category, "play"))
-                                       {
-                                               wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
-                                               //_mm_wfd_sink_disconnect (wfd_sink);
-                                               MMWFDSINK_POST_MESSAGE(wfd_sink,
-                                                       MM_ERROR_WFD_INTERNAL,
-                                                       MMWFDSINK_CURRENT_STATE(wfd_sink));
-                                       }
-                                       else if (category && !strcmp (category, "pause"))
-                                       {
-                                               wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
-                                               //_mm_wfd_sink_disconnect (wfd_sink);
-                                               MMWFDSINK_POST_MESSAGE(wfd_sink,
-                                                       MM_ERROR_WFD_INTERNAL,
-                                                       MMWFDSINK_CURRENT_STATE(wfd_sink));
-                                       }
-                                       else if (category && !strcmp (category, "close"))
-                                       {
-                                               wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
-                                               //_mm_wfd_sink_disconnect (wfd_sink);
+
+                               wfd_sink_debug("message name : %s", GST_STR_NULL(message_structure_name));
+                       }
+                       break;
+
+               case GST_MESSAGE_ELEMENT: {
+                               const gchar *structure_name = NULL;
+                               const GstStructure *message_structure = NULL;
+
+                               message_structure = gst_message_get_structure(msg);
+                               structure_name = gst_structure_get_name(message_structure);
+                               if (structure_name) {
+                                       wfd_sink_debug("got element specific message[%s]\n", GST_STR_NULL(structure_name));
+                                       if (g_strrstr(structure_name, "GstUDPSrcTimeout")) {
+                                               wfd_sink_error("Got %s, post error message\n", GST_STR_NULL(structure_name));
                                                MMWFDSINK_POST_MESSAGE(wfd_sink,
-                                                       MM_ERROR_WFD_INTERNAL,
-                                                       MMWFDSINK_CURRENT_STATE(wfd_sink));
-                                       }
-                                       else
-                                       {
-                                               wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
+                                                                      MM_ERROR_WFD_INTERNAL,
+                                                                      MMWFDSINK_CURRENT_STATE(wfd_sink));
                                        }
-                                       break;
-                               default :
-                                       wfd_sink_error("progress message has no type\n");
-                                       return ret;
+                               }
                        }
+                       break;
 
-                       MMWFDSINK_FREEIF (category);
-                       MMWFDSINK_FREEIF (text);
-               }
-               break;
+               case GST_MESSAGE_PROGRESS: {
+                               GstProgressType type = GST_PROGRESS_TYPE_ERROR;
+                               gchar *category = NULL, *text = NULL;
+
+                               gst_message_parse_progress(msg, &type, &category, &text);
+                               wfd_sink_debug("%s : %s \n", GST_STR_NULL(category), GST_STR_NULL(text));
+
+                               switch (type) {
+                                       case GST_PROGRESS_TYPE_START:
+                                               break;
+                                       case GST_PROGRESS_TYPE_COMPLETE:
+                                               if (category && !strcmp(category, "open"))
+                                                       __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_CONNECTED);
+                                               else if (category && !strcmp(category, "play")) {
+                                                       __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_PLAYING);
+                                                       /*_mm_wfd_sink_correct_pipeline_latency (wfd_sink); */
+                                               } else if (category && !strcmp(category, "pause"))
+                                                       __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_PAUSED);
+                                               else if (category && !strcmp(category, "close"))
+                                                       __mm_wfd_sink_set_state(wfd_sink,  MM_WFD_SINK_STATE_DISCONNECTED);
+
+
+                                               break;
+                                       case GST_PROGRESS_TYPE_CANCELED:
+                                               break;
+                                       case GST_PROGRESS_TYPE_ERROR:
+                                               if (category && !strcmp(category, "open")) {
+                                                       wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
+                                                       /*_mm_wfd_sink_disconnect (wfd_sink); */
+                                                       MMWFDSINK_POST_MESSAGE(wfd_sink,
+                                                                              MM_ERROR_WFD_INTERNAL,
+                                                                              MMWFDSINK_CURRENT_STATE(wfd_sink));
+                                               } else if (category && !strcmp(category, "play")) {
+                                                       wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
+                                                       /*_mm_wfd_sink_disconnect (wfd_sink); */
+                                                       MMWFDSINK_POST_MESSAGE(wfd_sink,
+                                                                              MM_ERROR_WFD_INTERNAL,
+                                                                              MMWFDSINK_CURRENT_STATE(wfd_sink));
+                                               } else if (category && !strcmp(category, "pause")) {
+                                                       wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
+                                                       /*_mm_wfd_sink_disconnect (wfd_sink); */
+                                                       MMWFDSINK_POST_MESSAGE(wfd_sink,
+                                                                              MM_ERROR_WFD_INTERNAL,
+                                                                              MMWFDSINK_CURRENT_STATE(wfd_sink));
+                                               } else if (category && !strcmp(category, "close")) {
+                                                       wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
+                                                       /*_mm_wfd_sink_disconnect (wfd_sink); */
+                                                       MMWFDSINK_POST_MESSAGE(wfd_sink,
+                                                                              MM_ERROR_WFD_INTERNAL,
+                                                                              MMWFDSINK_CURRENT_STATE(wfd_sink));
+                                               } else {
+                                                       wfd_sink_error("got error : %s\n", GST_STR_NULL(text));
+                                               }
+                                               break;
+                                       default:
+                                               wfd_sink_error("progress message has no type\n");
+                                               return ret;
+                               }
+
+                               MMWFDSINK_FREEIF(category);
+                               MMWFDSINK_FREEIF(text);
+                       }
+                       break;
                case GST_MESSAGE_ASYNC_START:
                        wfd_sink_debug("GST_MESSAGE_ASYNC_START : %s\n", gst_element_get_name(GST_MESSAGE_SRC(msg)));
                        break;
@@ -795,48 +786,45 @@ _mm_wfd_sink_msg_callback (GstBus *bus, GstMessage *msg, gpointer data)
                case GST_MESSAGE_QOS:
                case GST_MESSAGE_ANY:
                        break;
-               default:
+               default:
                        wfd_sink_debug("unhandled message\n");
-               break;
+                       break;
        }
 
        return ret;
 }
 
 static int
-__mm_wfd_sink_gst_element_add_bucket_to_bin (GstBin* bin, GList* element_bucket, gboolean need_prepare)
+__mm_wfd_sink_gst_element_add_bucket_to_bin(GstBin *bin, GList *element_bucket, gboolean need_prepare)
 {
-       GListbucket = element_bucket;
-       MMWFDSinkGstElementelement = NULL;
+       GList *bucket = element_bucket;
+       MMWFDSinkGstElement *element = NULL;
        int successful_add_count = 0;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (element_bucket, 0);
-       wfd_sink_return_val_if_fail (bin, 0);
+       wfd_sink_return_val_if_fail(element_bucket, 0);
+       wfd_sink_return_val_if_fail(bin, 0);
 
-       for (; bucket; bucket = bucket->next)
-       {
-               element = (MMWFDSinkGstElement*)bucket->data;
+       for (; bucket; bucket = bucket->next) {
+               element = (MMWFDSinkGstElement *)bucket->data;
 
-               if (element && element->gst)
-               {
+               if (element && element->gst) {
                        if (need_prepare)
-                               gst_element_set_state (GST_ELEMENT(element->gst), GST_STATE_READY);
+                               gst_element_set_state(GST_ELEMENT(element->gst), GST_STATE_READY);
 
-                       if (!gst_bin_add (bin, GST_ELEMENT(element->gst)))
-                       {
+                       if (!gst_bin_add(bin, GST_ELEMENT(element->gst))) {
                                wfd_sink_error("failed to add element [%s] to bin [%s]\n",
-                                       GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))),
-                                       GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT_CAST(bin) )));
+                                              GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))),
+                                              GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT_CAST(bin))));
                                return 0;
                        }
 
                        wfd_sink_debug("add element [%s] to bin [%s]\n",
-                               GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))),
-                               GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT_CAST(bin) )));
+                                      GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))),
+                                      GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT_CAST(bin))));
 
-                       successful_add_count ++;
+                       successful_add_count++;
                }
        }
 
@@ -846,38 +834,33 @@ __mm_wfd_sink_gst_element_add_bucket_to_bin (GstBin* bin, GList* element_bucket,
 }
 
 static int
-__mm_wfd_sink_gst_element_link_bucket (GList* element_bucket)
+__mm_wfd_sink_gst_element_link_bucket(GList *element_bucket)
 {
-       GListbucket = element_bucket;
-       MMWFDSinkGstElementelement = NULL;
-       MMWFDSinkGstElementprv_element = NULL;
+       GList *bucket = element_bucket;
+       MMWFDSinkGstElement *element = NULL;
+       MMWFDSinkGstElement *prv_element = NULL;
        gint successful_link_count = 0;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (element_bucket, -1);
+       wfd_sink_return_val_if_fail(element_bucket, -1);
 
-       prv_element = (MMWFDSinkGstElement*)bucket->data;
+       prv_element = (MMWFDSinkGstElement *)bucket->data;
        bucket = bucket->next;
 
-       for ( ; bucket; bucket = bucket->next )
-       {
-               element = (MMWFDSinkGstElement*)bucket->data;
+       for (; bucket; bucket = bucket->next) {
+               element = (MMWFDSinkGstElement *)bucket->data;
 
-               if (element && element->gst)
-               {
-                       if ( gst_element_link (GST_ELEMENT(prv_element->gst), GST_ELEMENT(element->gst)) )
-                       {
+               if (element && element->gst) {
+                       if (gst_element_link(GST_ELEMENT(prv_element->gst), GST_ELEMENT(element->gst))) {
                                wfd_sink_debug("linking [%s] to [%s] success\n",
-                                       GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst))),
-                                       GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))));
-                               successful_link_count ++;
-                       }
-                       else
-                       {
+                                              GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst))),
+                                              GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))));
+                               successful_link_count++;
+                       } else {
                                wfd_sink_error("linking [%s] to [%s] failed\n",
-                                       GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst))),
-                                       GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))));
+                                              GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst))),
+                                              GST_STR_NULL(GST_ELEMENT_NAME(GST_ELEMENT(element->gst))));
                                return -1;
                        }
                }
@@ -891,96 +874,108 @@ __mm_wfd_sink_gst_element_link_bucket (GList* element_bucket)
 }
 
 static int
-__mm_wfd_sink_check_state(mm_wfd_sink_twfd_sink, MMWFDSinkCommandType cmd)
+__mm_wfd_sink_check_state(mm_wfd_sink_t *wfd_sink, MMWFDSinkCommandType cmd)
 {
        MMWFDSinkStateType cur_state = MM_WFD_SINK_STATE_NONE;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        MMWFDSINK_PRINT_STATE(wfd_sink);
 
        cur_state = MMWFDSINK_CURRENT_STATE(wfd_sink);
 
-       switch (cmd)
-       {
-               case MM_WFD_SINK_COMMAND_CREATE:
-               {
-                       if (cur_state != MM_WFD_SINK_STATE_NONE)
-                               goto invalid_state;
+       switch (cmd) {
+               case MM_WFD_SINK_COMMAND_CREATE: {
+                               if (cur_state != MM_WFD_SINK_STATE_NONE)
+                                       goto invalid_state;
 
-                       MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NULL;
-               }
-               break;
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NULL;
+                       }
+                       break;
 
-               case MM_WFD_SINK_COMMAND_PREPARE:
-               {
-                       if (cur_state == MM_WFD_SINK_STATE_PREPARED)
-                               goto no_operation;
-                       else if (cur_state != MM_WFD_SINK_STATE_NULL)
-                               goto invalid_state;
+               case MM_WFD_SINK_COMMAND_PREPARE: {
+                               if (cur_state == MM_WFD_SINK_STATE_PREPARED)
+                                       goto no_operation;
+                               else if (cur_state != MM_WFD_SINK_STATE_NULL)
+                                       goto invalid_state;
 
-                       MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_PREPARED;
-               }
-               break;
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_PREPARED;
+                       }
+                       break;
 
-               case MM_WFD_SINK_COMMAND_CONNECT:
-               {
-                       if (cur_state == MM_WFD_SINK_STATE_CONNECTED)
-                               goto no_operation;
-                       else if (cur_state != MM_WFD_SINK_STATE_PREPARED)
-                               goto invalid_state;
+               case MM_WFD_SINK_COMMAND_CONNECT: {
+                               if (cur_state == MM_WFD_SINK_STATE_CONNECTED)
+                                       goto no_operation;
+                               else if (cur_state != MM_WFD_SINK_STATE_PREPARED)
+                                       goto invalid_state;
 
-                       MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_CONNECTED;
-               }
-               break;
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_CONNECTED;
+                       }
+                       break;
 
-               case MM_WFD_SINK_COMMAND_START:
-               {
-                       if (cur_state == MM_WFD_SINK_STATE_PLAYING)
-                               goto no_operation;
-                       else if (cur_state != MM_WFD_SINK_STATE_CONNECTED)
-                               goto invalid_state;
+               case MM_WFD_SINK_COMMAND_START: {
+                               if (cur_state == MM_WFD_SINK_STATE_PLAYING)
+                                       goto no_operation;
+                               else if (cur_state != MM_WFD_SINK_STATE_CONNECTED)
+                                       goto invalid_state;
 
-                       MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_PLAYING;
-               }
-               break;
-
-               case MM_WFD_SINK_COMMAND_DISCONNECT:
-               {
-                       if (cur_state == MM_WFD_SINK_STATE_NONE ||
-                               cur_state == MM_WFD_SINK_STATE_NULL ||
-                               cur_state == MM_WFD_SINK_STATE_PREPARED ||
-                               cur_state == MM_WFD_SINK_STATE_DISCONNECTED)
-                               goto no_operation;
-                       else if (cur_state != MM_WFD_SINK_STATE_PLAYING &&
-                               cur_state != MM_WFD_SINK_STATE_CONNECTED &&
-                               cur_state != MM_WFD_SINK_STATE_PAUSED)
-                               goto invalid_state;
-
-                       MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_DISCONNECTED;
-               }
-               break;
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_PLAYING;
+                       }
+                       break;
 
-               case MM_WFD_SINK_COMMAND_UNPREPARE:
-               {
-                       if (cur_state == MM_WFD_SINK_STATE_NONE ||
-                               cur_state == MM_WFD_SINK_STATE_NULL)
-                               goto no_operation;
+               case MM_WFD_SINK_COMMAND_PAUSE: {
+                               if (cur_state == MM_WFD_SINK_STATE_PAUSED)
+                                       goto no_operation;
+                               else if (cur_state != MM_WFD_SINK_STATE_PLAYING)
+                                       goto invalid_state;
 
-                       MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NULL;
-               }
-               break;
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_PAUSED;
+                       }
+                       break;
 
-               case MM_WFD_SINK_COMMAND_DESTROY:
-               {
-                       if (cur_state == MM_WFD_SINK_STATE_NONE)
-                               goto no_operation;
+               case MM_WFD_SINK_COMMAND_RESUME: {
+                               if (cur_state == MM_WFD_SINK_STATE_PLAYING)
+                                       goto no_operation;
+                               else if (cur_state != MM_WFD_SINK_STATE_PAUSED)
+                                       goto invalid_state;
 
-                       MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NONE;
-               }
-               break;
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_PLAYING;
+                       }
+                       break;
+
+               case MM_WFD_SINK_COMMAND_DISCONNECT: {
+                               if (cur_state == MM_WFD_SINK_STATE_NONE ||
+                                   cur_state == MM_WFD_SINK_STATE_NULL ||
+                                   cur_state == MM_WFD_SINK_STATE_PREPARED ||
+                                   cur_state == MM_WFD_SINK_STATE_DISCONNECTED)
+                                       goto no_operation;
+                               else if (cur_state != MM_WFD_SINK_STATE_PLAYING &&
+                                        cur_state != MM_WFD_SINK_STATE_CONNECTED &&
+                                        cur_state != MM_WFD_SINK_STATE_PAUSED)
+                                       goto invalid_state;
+
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_DISCONNECTED;
+                       }
+                       break;
+
+               case MM_WFD_SINK_COMMAND_UNPREPARE: {
+                               if (cur_state == MM_WFD_SINK_STATE_NONE ||
+                                   cur_state == MM_WFD_SINK_STATE_NULL)
+                                       goto no_operation;
+
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NULL;
+                       }
+                       break;
+
+               case MM_WFD_SINK_COMMAND_DESTROY: {
+                               if (cur_state == MM_WFD_SINK_STATE_NONE)
+                                       goto no_operation;
+
+                               MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NONE;
+                       }
+                       break;
 
                default:
                        break;
@@ -993,23 +988,22 @@ __mm_wfd_sink_check_state(mm_wfd_sink_t* wfd_sink, MMWFDSinkCommandType cmd)
        return MM_ERROR_NONE;
 
 no_operation:
-       wfd_sink_debug ("already %s state, nothing to do.\n", MMWFDSINK_STATE_GET_NAME(cur_state));
+       wfd_sink_debug("already %s state, nothing to do.\n", MMWFDSINK_STATE_GET_NAME(cur_state));
        return MM_ERROR_WFD_NO_OP;
 
-/* ERRORS */
+       /* ERRORS */
 invalid_state:
-       wfd_sink_error ("current state is invalid.\n", MMWFDSINK_STATE_GET_NAME(cur_state));
+       wfd_sink_error("current state is invalid.\n", MMWFDSINK_STATE_GET_NAME(cur_state));
        return MM_ERROR_WFD_INVALID_STATE;
 }
 
-static int __mm_wfd_sink_set_state(mm_wfd_sink_twfd_sink, MMWFDSinkStateType state)
+static int __mm_wfd_sink_set_state(mm_wfd_sink_t *wfd_sink, MMWFDSinkStateType state)
 {
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
-       if (MMWFDSINK_CURRENT_STATE(wfd_sink) == state )
-       {
+       if (MMWFDSINK_CURRENT_STATE(wfd_sink) == state) {
                wfd_sink_error("already state(%s)\n", MMWFDSINK_STATE_GET_NAME(state));
                MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NONE;
                return MM_ERROR_NONE;
@@ -1019,13 +1013,13 @@ static int __mm_wfd_sink_set_state(mm_wfd_sink_t* wfd_sink, MMWFDSinkStateType s
        MMWFDSINK_PREVIOUS_STATE(wfd_sink) = MMWFDSINK_CURRENT_STATE(wfd_sink);
        MMWFDSINK_CURRENT_STATE(wfd_sink) = state;
 
-       if ( MMWFDSINK_CURRENT_STATE(wfd_sink) == MMWFDSINK_PENDING_STATE(wfd_sink) )
+       if (MMWFDSINK_CURRENT_STATE(wfd_sink) == MMWFDSINK_PENDING_STATE(wfd_sink))
                MMWFDSINK_PENDING_STATE(wfd_sink) = MM_WFD_SINK_STATE_NONE;
 
        /* poset state message to application */
        MMWFDSINK_POST_MESSAGE(wfd_sink,
-               MM_ERROR_NONE,
-               MMWFDSINK_CURRENT_STATE(wfd_sink));
+                              MM_ERROR_NONE,
+                              MMWFDSINK_CURRENT_STATE(wfd_sink));
 
        /* print state */
        MMWFDSINK_PRINT_STATE(wfd_sink);
@@ -1036,7 +1030,7 @@ static int __mm_wfd_sink_set_state(mm_wfd_sink_t* wfd_sink, MMWFDSinkStateType s
 }
 
 static int
-__mm_wfd_sink_set_pipeline_state(mm_wfd_sink_twfd_sink, GstState state, gboolean async)
+__mm_wfd_sink_set_pipeline_state(mm_wfd_sink_t *wfd_sink, GstState state, gboolean async)
 {
        GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE;
        GstState cur_state = GST_STATE_VOID_PENDING;
@@ -1044,46 +1038,41 @@ __mm_wfd_sink_set_pipeline_state(mm_wfd_sink_t* wfd_sink, GstState state, gboole
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->mainbin &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst,
-               MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline &&
+                                   wfd_sink->pipeline->mainbin &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
 
-       wfd_sink_return_val_if_fail (state > GST_STATE_VOID_PENDING,
-               MM_ERROR_WFD_INVALID_ARGUMENT);
+       wfd_sink_return_val_if_fail(state > GST_STATE_VOID_PENDING,
+                                   MM_ERROR_WFD_INVALID_ARGUMENT);
 
-       wfd_sink_debug ("try to set %s state \n", gst_element_state_get_name(state));
+       wfd_sink_debug("try to set %s state \n", gst_element_state_get_name(state));
 
-       result = gst_element_set_state (wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst, state);
-       if (result == GST_STATE_CHANGE_FAILURE)
-       {
-               wfd_sink_error ("fail to set %s state....\n", gst_element_state_get_name(state));
+       result = gst_element_set_state(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst, state);
+       if (result == GST_STATE_CHANGE_FAILURE) {
+               wfd_sink_error("fail to set %s state....\n", gst_element_state_get_name(state));
                return MM_ERROR_WFD_INTERNAL;
        }
 
-       if (!async)
-       {
-               wfd_sink_debug ("wait for changing state is completed \n");
+       if (!async) {
+               wfd_sink_debug("wait for changing state is completed \n");
 
-               result = gst_element_get_state (wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst,
-                               &cur_state, &pending_state, wfd_sink->ini.state_change_timeout * GST_SECOND);
-               if (result == GST_STATE_CHANGE_FAILURE)
-               {
-                       wfd_sink_error ("fail to get state within %d seconds....\n", wfd_sink->ini.state_change_timeout);
+               result = gst_element_get_state(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst,
+                                              &cur_state, &pending_state, wfd_sink->ini.state_change_timeout * GST_SECOND);
+               if (result == GST_STATE_CHANGE_FAILURE) {
+                       wfd_sink_error("fail to get state within %d seconds....\n", wfd_sink->ini.state_change_timeout);
 
                        __mm_wfd_sink_dump_pipeline_state(wfd_sink);
 
                        return MM_ERROR_WFD_INTERNAL;
-               }
-               else if (result == GST_STATE_CHANGE_NO_PREROLL)
-               {
-                       wfd_sink_debug ("successfully changed state but is not able to provide data yet\n");
+               } else if (result == GST_STATE_CHANGE_NO_PREROLL) {
+                       wfd_sink_debug("successfully changed state but is not able to provide data yet\n");
                }
 
                wfd_sink_debug("cur state is %s, pending state is %s\n",
-                       gst_element_state_get_name(cur_state),
-                       gst_element_state_get_name(pending_state));
+                              gst_element_state_get_name(cur_state),
+                              gst_element_state_get_name(pending_state));
        }
 
 
@@ -1100,42 +1089,36 @@ _mm_wfd_sink_reset_basetime(mm_wfd_sink_t *wfd_sink)
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_if_fail (wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->mainbin &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst);
-       wfd_sink_return_if_fail (wfd_sink->need_to_reset_basetime);
+       wfd_sink_return_if_fail(wfd_sink &&
+                               wfd_sink->pipeline &&
+                               wfd_sink->pipeline->mainbin &&
+                               wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst);
+       wfd_sink_return_if_fail(wfd_sink->need_to_reset_basetime);
 
 
        if (wfd_sink->clock)
-               base_time = gst_clock_get_time (wfd_sink->clock);
+               base_time = gst_clock_get_time(wfd_sink->clock);
 
-       if (GST_CLOCK_TIME_IS_VALID(base_time))
-       {
+       if (GST_CLOCK_TIME_IS_VALID(base_time)) {
 
-               wfd_sink_debug ("set pipeline base_time as now [%"GST_TIME_FORMAT"]\n",GST_TIME_ARGS(base_time));
+               wfd_sink_debug("set pipeline base_time as now [%"GST_TIME_FORMAT"]\n", GST_TIME_ARGS(base_time));
 
-               for (i=0; i<WFD_SINK_M_NUM; i++)
-               {
+               for (i = 0; i < WFD_SINK_M_NUM; i++) {
                        if (wfd_sink->pipeline->mainbin[i].gst)
-                               gst_element_set_base_time(GST_ELEMENT_CAST (wfd_sink->pipeline->mainbin[i].gst), base_time);
+                               gst_element_set_base_time(GST_ELEMENT_CAST(wfd_sink->pipeline->mainbin[i].gst), base_time);
                }
 
-               if (wfd_sink->pipeline->videobin)
-               {
-                       for (i=0; i<WFD_SINK_V_NUM; i++)
-                       {
+               if (wfd_sink->pipeline->videobin) {
+                       for (i = 0; i < WFD_SINK_V_NUM; i++) {
                                if (wfd_sink->pipeline->videobin[i].gst)
-                                       gst_element_set_base_time(GST_ELEMENT_CAST (wfd_sink->pipeline->videobin[i].gst), base_time);
+                                       gst_element_set_base_time(GST_ELEMENT_CAST(wfd_sink->pipeline->videobin[i].gst), base_time);
                        }
                }
 
-               if (wfd_sink->pipeline->audiobin)
-               {
-                       for (i=0; i<WFD_SINK_A_NUM; i++)
-                       {
+               if (wfd_sink->pipeline->audiobin) {
+                       for (i = 0; i < WFD_SINK_A_NUM; i++) {
                                if (wfd_sink->pipeline->audiobin[i].gst)
-                                       gst_element_set_base_time(GST_ELEMENT_CAST (wfd_sink->pipeline->audiobin[i].gst), base_time);
+                                       gst_element_set_base_time(GST_ELEMENT_CAST(wfd_sink->pipeline->audiobin[i].gst), base_time);
                        }
                }
                wfd_sink->need_to_reset_basetime = FALSE;
@@ -1147,35 +1130,29 @@ _mm_wfd_sink_reset_basetime(mm_wfd_sink_t *wfd_sink)
 }
 
 int
-__mm_wfd_sink_prepare_videobin (mm_wfd_sink_t *wfd_sink)
+__mm_wfd_sink_prepare_videobin(mm_wfd_sink_t *wfd_sink)
 {
-       GstElementvideobin = NULL;
+       GstElement *videobin = NULL;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline,
-               MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
 
-       if (wfd_sink->pipeline->videobin == NULL)
-       {
-               if (MM_ERROR_NONE !=__mm_wfd_sink_create_videobin (wfd_sink))
-               {
-                       wfd_sink_error ("failed to create videobin....\n");
+       if (wfd_sink->pipeline->videobin == NULL) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_create_videobin(wfd_sink)) {
+                       wfd_sink_error("failed to create videobin....\n");
                        goto ERROR;
                }
-       }
-       else
-       {
-               wfd_sink_debug ("videobin is already created.\n");
+       } else {
+               wfd_sink_debug("videobin is already created.\n");
        }
 
        videobin = wfd_sink->pipeline->videobin[WFD_SINK_V_BIN].gst;
 
-       if (GST_STATE(videobin) <= GST_STATE_NULL)
-       {
-               if (GST_STATE_CHANGE_FAILURE == gst_element_set_state (videobin, GST_STATE_READY))
-               {
+       if (GST_STATE(videobin) <= GST_STATE_NULL) {
+               if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(videobin, GST_STATE_READY)) {
                        wfd_sink_error("failed to set state(READY) to %s\n", GST_STR_NULL(GST_ELEMENT_NAME(videobin)));
                        goto ERROR;
                }
@@ -1185,53 +1162,47 @@ __mm_wfd_sink_prepare_videobin (mm_wfd_sink_t *wfd_sink)
 
        return MM_ERROR_NONE;
 
-/* ERRORS */
+       /* ERRORS */
 ERROR:
        /* need to notify to app */
        MMWFDSINK_POST_MESSAGE(wfd_sink,
-               MM_ERROR_WFD_INTERNAL,
-               MMWFDSINK_CURRENT_STATE(wfd_sink));
+                              MM_ERROR_WFD_INTERNAL,
+                              MMWFDSINK_CURRENT_STATE(wfd_sink));
 
        return MM_ERROR_WFD_INTERNAL;
 }
 
 int
-__mm_wfd_sink_prepare_audiobin (mm_wfd_sink_t *wfd_sink)
+__mm_wfd_sink_prepare_audiobin(mm_wfd_sink_t *wfd_sink)
 {
-       MMWFDSinkGstElementaudiobin = NULL;
+       MMWFDSinkGstElement *audiobin = NULL;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline,
-               MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
 
-       if (wfd_sink->pipeline->audiobin == NULL)
-       {
-               if (MM_ERROR_NONE !=__mm_wfd_sink_create_audiobin (wfd_sink))
-               {
-                       wfd_sink_error ("failed to create audiobin....\n");
+       if (wfd_sink->pipeline->audiobin == NULL) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_create_audiobin(wfd_sink)) {
+                       wfd_sink_error("failed to create audiobin....\n");
                        goto ERROR;
                }
        }
 
-       if (!wfd_sink->audio_bin_is_linked)
-       {
-               if (MM_ERROR_NONE !=__mm_wfd_sink_link_audiobin(wfd_sink))
-               {
-                       wfd_sink_error ("failed to link audio decoder.....\n");
+       if (!wfd_sink->audio_bin_is_linked) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_link_audiobin(wfd_sink)) {
+                       wfd_sink_error("failed to link audio decoder.....\n");
                        goto ERROR;
                }
        }
 
        audiobin = wfd_sink->pipeline->audiobin;
 
-       if (GST_STATE(audiobin) <= GST_STATE_NULL)
-       {
-               if (GST_STATE_CHANGE_FAILURE ==gst_element_set_state (audiobin[WFD_SINK_A_BIN].gst, GST_STATE_READY))
-               {
+       if (GST_STATE(audiobin) <= GST_STATE_NULL) {
+               if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(audiobin[WFD_SINK_A_BIN].gst, GST_STATE_READY)) {
                        wfd_sink_error("failed to set state(READY) to %s\n",
-                               GST_STR_NULL(GST_ELEMENT_NAME(audiobin)));
+                                      GST_STR_NULL(GST_ELEMENT_NAME(audiobin)));
                        goto ERROR;
                }
        }
@@ -1240,21 +1211,21 @@ __mm_wfd_sink_prepare_audiobin (mm_wfd_sink_t *wfd_sink)
 
        return MM_ERROR_NONE;
 
-/* ERRORS */
+       /* ERRORS */
 ERROR:
        /* need to notify to app */
        MMWFDSINK_POST_MESSAGE(wfd_sink,
-               MM_ERROR_WFD_INTERNAL,
-               MMWFDSINK_CURRENT_STATE(wfd_sink));
+                              MM_ERROR_WFD_INTERNAL,
+                              MMWFDSINK_CURRENT_STATE(wfd_sink));
 
        return MM_ERROR_WFD_INTERNAL;
 }
 
-#define COMPENSATION_CRETERIA_VALUE 1000000 // 1 msec
-#define COMPENSATION_CHECK_PERIOD 30*GST_SECOND  // 30 sec
+#define COMPENSATION_CRETERIA_VALUE 1000000 /* 1 msec */
+#define COMPENSATION_CHECK_PERIOD (30*GST_SECOND)  /* 30 sec */
 
 static GstPadProbeReturn
-_mm_wfd_sink_check_running_time(GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
+_mm_wfd_sink_check_running_time(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
 {
        mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *)u_data;
        GstClockTime current_time = GST_CLOCK_TIME_NONE;
@@ -1263,19 +1234,18 @@ _mm_wfd_sink_check_running_time(GstPad * pad, GstPadProbeInfo * info, gpointer u
        GstClockTime base_time = GST_CLOCK_TIME_NONE;
        GstClockTime render_time = GST_CLOCK_TIME_NONE;
        GstClockTimeDiff diff = GST_CLOCK_TIME_NONE;
-       GstBuffer * buffer = NULL;
+       GstBuffer *buffer = NULL;
        gint64 ts_offset = 0LL;
 
-       wfd_sink_return_val_if_fail (info, FALSE);
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->mainbin &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst,
-               GST_PAD_PROBE_DROP);
+       wfd_sink_return_val_if_fail(info, FALSE);
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline &&
+                                   wfd_sink->pipeline->mainbin &&
+                                   wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst,
+                                   GST_PAD_PROBE_DROP);
 
-       if (!wfd_sink->clock)
-       {
-               wfd_sink_warning ("pipeline did not select clock, yet\n");
+       if (!wfd_sink->clock) {
+               wfd_sink_warning("pipeline did not select clock, yet\n");
                return GST_PAD_PROBE_OK;
        }
 
@@ -1290,34 +1260,27 @@ _mm_wfd_sink_check_running_time(GstPad * pad, GstPadProbeInfo * info, gpointer u
                base_time = gst_element_get_base_time(wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst);
        start_time = gst_element_get_start_time(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst);
        if (GST_CLOCK_TIME_IS_VALID(current_time) &&
-               GST_CLOCK_TIME_IS_VALID(start_time) &&
-               GST_CLOCK_TIME_IS_VALID(base_time))
-       {
+           GST_CLOCK_TIME_IS_VALID(start_time) &&
+           GST_CLOCK_TIME_IS_VALID(base_time)) {
                running_time = current_time - (start_time + base_time);
-       }
-       else
-       {
-               wfd_sink_debug ("current time %"GST_TIME_FORMAT", start time %"GST_TIME_FORMAT
-                       "  base time %"GST_TIME_FORMAT"\n", GST_TIME_ARGS(current_time),
-                       GST_TIME_ARGS(start_time), GST_TIME_ARGS(base_time));
+       } else {
+               wfd_sink_debug("current time %"GST_TIME_FORMAT", start time %"GST_TIME_FORMAT
+                              "  base time %"GST_TIME_FORMAT"\n", GST_TIME_ARGS(current_time),
+                              GST_TIME_ARGS(start_time), GST_TIME_ARGS(base_time));
                return GST_PAD_PROBE_OK;
        }
 
        /* calculate this buffer rendering time */
-       buffer = gst_pad_probe_info_get_buffer (info);
-       if (!GST_BUFFER_TIMESTAMP_IS_VALID(buffer))
-       {
-               wfd_sink_error ("buffer timestamp is invalid.\n");
+       buffer = gst_pad_probe_info_get_buffer(info);
+       if (!GST_BUFFER_TIMESTAMP_IS_VALID(buffer)) {
+               wfd_sink_error("buffer timestamp is invalid.\n");
                return GST_PAD_PROBE_OK;
        }
 
-       if (g_strrstr(GST_OBJECT_NAME(pad), "audio"))
-       {
+       if (g_strrstr(GST_OBJECT_NAME(pad), "audio")) {
                if (wfd_sink->pipeline && wfd_sink->pipeline->audiobin && wfd_sink->pipeline->audiobin[WFD_SINK_A_SINK].gst)
                        g_object_get(G_OBJECT(wfd_sink->pipeline->audiobin[WFD_SINK_A_SINK].gst), "ts-offset", &ts_offset, NULL);
-       }
-       else if (g_strrstr(GST_OBJECT_NAME(pad), "video"))
-       {
+       } else if (g_strrstr(GST_OBJECT_NAME(pad), "video")) {
                if (wfd_sink->pipeline && wfd_sink->pipeline->videobin && wfd_sink->pipeline->videobin[WFD_SINK_V_SINK].gst)
                        g_object_get(G_OBJECT(wfd_sink->pipeline->videobin[WFD_SINK_V_SINK].gst), "ts-offset", &ts_offset, NULL);
        }
@@ -1326,52 +1289,41 @@ _mm_wfd_sink_check_running_time(GstPad * pad, GstPadProbeInfo * info, gpointer u
        render_time += ts_offset;
 
        /* chekc this buffer could be rendered or not */
-       if (GST_CLOCK_TIME_IS_VALID(running_time) && GST_CLOCK_TIME_IS_VALID(render_time))
-       {
-               diff=GST_CLOCK_DIFF(running_time, render_time);
-               if (diff < 0)
-               {
+       if (GST_CLOCK_TIME_IS_VALID(running_time) && GST_CLOCK_TIME_IS_VALID(render_time)) {
+               diff = GST_CLOCK_DIFF(running_time, render_time);
+               if (diff < 0) {
                        /* this buffer could be NOT rendered */
-                       wfd_sink_debug ("%s : diff time : -%" GST_TIME_FORMAT "\n",
-                               GST_STR_NULL((GST_OBJECT_NAME(pad))),
-                               GST_TIME_ARGS(GST_CLOCK_DIFF(render_time, running_time)));
-               }
-               else
-               {
+                       wfd_sink_debug("%s : diff time : -%" GST_TIME_FORMAT "\n",
+                                      GST_STR_NULL((GST_OBJECT_NAME(pad))),
+                                      GST_TIME_ARGS(GST_CLOCK_DIFF(render_time, running_time)));
+               } else {
                        /* this buffer could be rendered */
-                       //wfd_sink_debug ("%s :diff time : %" GST_TIME_FORMAT "\n",
-                       //      GST_STR_NULL((GST_OBJECT_NAME(pad))),
-                       //      GST_TIME_ARGS(diff));
+                       /*wfd_sink_debug ("%s :diff time : %" GST_TIME_FORMAT "\n", */
+                       /*      GST_STR_NULL((GST_OBJECT_NAME(pad))), */
+                       /*      GST_TIME_ARGS(diff)); */
                }
        }
 
        /* update buffer count and gap */
-       if (g_strrstr(GST_OBJECT_NAME(pad), "video"))
-       {
-               wfd_sink->video_buffer_count ++;
+       if (g_strrstr(GST_OBJECT_NAME(pad), "video")) {
+               wfd_sink->video_buffer_count++;
                wfd_sink->video_accumulated_gap += diff;
-       }
-       else if (g_strrstr(GST_OBJECT_NAME(pad), "audio"))
-       {
-               wfd_sink->audio_buffer_count ++;
+       } else if (g_strrstr(GST_OBJECT_NAME(pad), "audio")) {
+               wfd_sink->audio_buffer_count++;
                wfd_sink->audio_accumulated_gap += diff;
-       }
-       else
-       {
+       } else {
                wfd_sink_warning("invalid buffer type.. \n");
                return GST_PAD_PROBE_DROP;
        }
 
-       if (GST_CLOCK_TIME_IS_VALID(wfd_sink->last_buffer_timestamp))
-       {
+       if (GST_CLOCK_TIME_IS_VALID(wfd_sink->last_buffer_timestamp)) {
                /* fisrt 60sec, just calculate the gap between source device and sink device */
-               if (GST_BUFFER_TIMESTAMP(buffer) < 60*GST_SECOND)
+               if (GST_BUFFER_TIMESTAMP(buffer) < 60 * GST_SECOND)
                        return GST_PAD_PROBE_OK;
 
                /* every 10sec, calculate the gap between source device and sink device */
                if (GST_CLOCK_DIFF(wfd_sink->last_buffer_timestamp, GST_BUFFER_TIMESTAMP(buffer))
-                       > COMPENSATION_CHECK_PERIOD)
-               {
+                   > COMPENSATION_CHECK_PERIOD) {
                        gint64 audio_avgrage_gap = 0LL;
                        gint64 video_avgrage_gap = 0LL;
                        gint64 audio_avgrage_gap_diff = 0LL;
@@ -1382,136 +1334,105 @@ _mm_wfd_sink_check_running_time(GstPad * pad, GstPadProbeInfo * info, gpointer u
                        gboolean minus_compensation = FALSE;
 
                        /* check video */
-                       if (wfd_sink->video_buffer_count > 0)
-                       {
-                               video_avgrage_gap = wfd_sink->video_accumulated_gap /wfd_sink->video_buffer_count;
-
-                               if (wfd_sink->video_average_gap !=0)
-                               {
-                                       if (video_avgrage_gap > wfd_sink->video_average_gap)
-                                       {
+                       if (wfd_sink->video_buffer_count > 0) {
+                               video_avgrage_gap = wfd_sink->video_accumulated_gap / wfd_sink->video_buffer_count;
+
+                               if (wfd_sink->video_average_gap != 0) {
+                                       if (video_avgrage_gap > wfd_sink->video_average_gap) {
                                                video_avgrage_gap_diff = video_avgrage_gap - wfd_sink->video_average_gap;
                                                video_minus_compensation = TRUE;
-                                       }
-                                       else
-                                       {
+                                       } else {
                                                video_avgrage_gap_diff = wfd_sink->video_average_gap - video_avgrage_gap;
                                                video_minus_compensation = FALSE;
                                        }
-                               }
-                               else
-                               {
-                                       wfd_sink_debug ("first update video average gap (%lld) \n", video_avgrage_gap);
+                               } else {
+                                       wfd_sink_debug("first update video average gap(%lld) \n", video_avgrage_gap);
                                        wfd_sink->video_average_gap = video_avgrage_gap;
                                }
-                       }
-                       else
-                       {
-                               wfd_sink_debug ("there is no video buffer flow during %"GST_TIME_FORMAT
-                                       " ~ %" GST_TIME_FORMAT"\n",
-                                       GST_TIME_ARGS(wfd_sink->last_buffer_timestamp),
-                                       GST_TIME_ARGS( GST_BUFFER_TIMESTAMP(buffer)));
+                       } else {
+                               wfd_sink_debug("there is no video buffer flow during %"GST_TIME_FORMAT
+                                              " ~ %" GST_TIME_FORMAT"\n",
+                                              GST_TIME_ARGS(wfd_sink->last_buffer_timestamp),
+                                              GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)));
                        }
 
                        /* check audio */
-                       if (wfd_sink->audio_buffer_count > 0)
-                       {
-                               audio_avgrage_gap = wfd_sink->audio_accumulated_gap /wfd_sink->audio_buffer_count;
-
-                               if (wfd_sink->audio_average_gap !=0)
-                               {
-                                       if (audio_avgrage_gap > wfd_sink->audio_average_gap)
-                                       {
+                       if (wfd_sink->audio_buffer_count > 0) {
+                               audio_avgrage_gap = wfd_sink->audio_accumulated_gap / wfd_sink->audio_buffer_count;
+
+                               if (wfd_sink->audio_average_gap != 0) {
+                                       if (audio_avgrage_gap > wfd_sink->audio_average_gap) {
                                                audio_avgrage_gap_diff = audio_avgrage_gap - wfd_sink->audio_average_gap;
                                                audio_minus_compensation = TRUE;
-                                       }
-                                       else
-                                       {
+                                       } else {
                                                audio_avgrage_gap_diff = wfd_sink->audio_average_gap - audio_avgrage_gap;
                                                audio_minus_compensation = FALSE;
                                        }
-                               }
-                               else
-                               {
-                                       wfd_sink_debug ("first update audio average gap (%lld) \n", audio_avgrage_gap);
+                               } else {
+                                       wfd_sink_debug("first update audio average gap(%lld) \n", audio_avgrage_gap);
                                        wfd_sink->audio_average_gap = audio_avgrage_gap;
                                }
-                       }
-                       else
-                       {
-                               wfd_sink_debug ("there is no audio buffer flow during %"GST_TIME_FORMAT
-                                       " ~ %" GST_TIME_FORMAT"\n",
-                                       GST_TIME_ARGS(wfd_sink->last_buffer_timestamp),
-                                       GST_TIME_ARGS( GST_BUFFER_TIMESTAMP(buffer)));
+                       } else {
+                               wfd_sink_debug("there is no audio buffer flow during %"GST_TIME_FORMAT
+                                              " ~ %" GST_TIME_FORMAT"\n",
+                                              GST_TIME_ARGS(wfd_sink->last_buffer_timestamp),
+                                              GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)));
                        }
 
                        /* selecet average_gap_diff between video and audio */
                        /*  which makes no buffer drop in the sink elements */
-                       if (video_avgrage_gap_diff && audio_avgrage_gap_diff)
-                       {
-                               if (!video_minus_compensation && !audio_minus_compensation)
-                               {
+                       if (video_avgrage_gap_diff && audio_avgrage_gap_diff) {
+                               if (!video_minus_compensation && !audio_minus_compensation) {
                                        minus_compensation = FALSE;
                                        if (video_avgrage_gap_diff > audio_avgrage_gap_diff)
                                                avgrage_gap_diff = video_avgrage_gap_diff;
                                        else
                                                avgrage_gap_diff = audio_avgrage_gap_diff;
-                               }
-                               else if (video_minus_compensation && audio_minus_compensation)
-                               {
+                               } else if (video_minus_compensation && audio_minus_compensation) {
                                        minus_compensation = TRUE;
                                        if (video_avgrage_gap_diff > audio_avgrage_gap_diff)
                                                avgrage_gap_diff = audio_avgrage_gap_diff;
                                        else
                                                avgrage_gap_diff = video_avgrage_gap_diff;
-                               }
-                               else
-                               {
+                               } else {
                                        minus_compensation = FALSE;
                                        if (!video_minus_compensation)
                                                avgrage_gap_diff = video_avgrage_gap_diff;
                                        else
                                                avgrage_gap_diff = audio_avgrage_gap_diff;
                                }
-                       }
-                       else if (video_avgrage_gap_diff)
-                       {
+                       } else if (video_avgrage_gap_diff) {
                                minus_compensation = video_minus_compensation;
                                avgrage_gap_diff = video_avgrage_gap_diff;
-                       }
-                       else if (audio_avgrage_gap_diff)
-                       {
+                       } else if (audio_avgrage_gap_diff) {
                                minus_compensation = audio_minus_compensation;
                                avgrage_gap_diff = audio_avgrage_gap_diff;
                        }
 
-                       wfd_sink_debug ("average diff gap difference beween audio:%s%lld and video:%s%lld \n",
-                               audio_minus_compensation ? "-" : "", audio_avgrage_gap_diff,
-                               video_minus_compensation ? "-" : "", video_avgrage_gap_diff);
+                       wfd_sink_debug("average diff gap difference beween audio:%s%lld and video:%s%lld \n",
+                                      audio_minus_compensation ? "-" : "", audio_avgrage_gap_diff,
+                                      video_minus_compensation ? "-" : "", video_avgrage_gap_diff);
 
 
                        /* if calculated gap diff is larger than 1ms. need to compensate buffer timestamp */
-                       if (avgrage_gap_diff >= COMPENSATION_CRETERIA_VALUE)
-                       {
+                       if (avgrage_gap_diff >= COMPENSATION_CRETERIA_VALUE) {
                                if (minus_compensation)
                                        ts_offset -= avgrage_gap_diff;
                                else
                                        ts_offset += avgrage_gap_diff;
 
-                               wfd_sink_debug ("do timestamp compensation : %s%lld (ts-offset : %"
-                                       GST_TIME_FORMAT") at (%" GST_TIME_FORMAT")\n",
-                                       minus_compensation? "-" : "", avgrage_gap_diff,
-                                       GST_TIME_ARGS(ts_offset), GST_TIME_ARGS(running_time));
+                               wfd_sink_debug("do timestamp compensation : %s%lld (ts-offset : %"
+                                              GST_TIME_FORMAT") at(%" GST_TIME_FORMAT")\n",
+                                              minus_compensation ? "-" : "", avgrage_gap_diff,
+                                              GST_TIME_ARGS(ts_offset), GST_TIME_ARGS(running_time));
 
                                if (wfd_sink->pipeline && wfd_sink->pipeline->audiobin && wfd_sink->pipeline->audiobin[WFD_SINK_A_SINK].gst)
                                        g_object_set(G_OBJECT(wfd_sink->pipeline->audiobin[WFD_SINK_A_SINK].gst), "ts-offset", (gint64)ts_offset, NULL);
                                if (wfd_sink->pipeline && wfd_sink->pipeline->videobin && wfd_sink->pipeline->videobin[WFD_SINK_V_SINK].gst)
                                        g_object_set(G_OBJECT(wfd_sink->pipeline->videobin[WFD_SINK_V_SINK].gst), "ts-offset", (gint64)ts_offset, NULL);
-                       }
-                       else
-                       {
-                               wfd_sink_debug ("don't need to do timestamp compensation : %s%lld (ts-offset : %"GST_TIME_FORMAT ")\n",
-                                       minus_compensation? "-" : "", avgrage_gap_diff, GST_TIME_ARGS(ts_offset));
+                       } else {
+                               wfd_sink_debug("don't need to do timestamp compensation : %s%lld (ts-offset : %"GST_TIME_FORMAT ")\n",
+                                              minus_compensation ? "-" : "", avgrage_gap_diff, GST_TIME_ARGS(ts_offset));
                        }
 
                        /* reset values*/
@@ -1521,11 +1442,9 @@ _mm_wfd_sink_check_running_time(GstPad * pad, GstPadProbeInfo * info, gpointer u
                        wfd_sink->audio_accumulated_gap = 0LL;
                        wfd_sink->last_buffer_timestamp = GST_BUFFER_TIMESTAMP(buffer);
                }
-       }
-       else
-       {
-               wfd_sink_debug ("first update last buffer timestamp :%" GST_TIME_FORMAT" \n",
-                        GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)));
+       } else {
+               wfd_sink_debug("first update last buffer timestamp :%" GST_TIME_FORMAT" \n",
+                              GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)));
                wfd_sink->last_buffer_timestamp = GST_BUFFER_TIMESTAMP(buffer);
        }
 
@@ -1534,35 +1453,32 @@ _mm_wfd_sink_check_running_time(GstPad * pad, GstPadProbeInfo * info, gpointer u
 
 
 static void
-__mm_wfd_sink_demux_pad_added (GstElement* ele, GstPad* pad, gpointer data)
+__mm_wfd_sink_demux_pad_added(GstElement *ele, GstPad *pad, gpointer data)
 {
        mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *)data;
-       gchar* name = gst_pad_get_name (pad);
-       GstElementsinkbin = NULL;
-       GstPadsinkpad = NULL;
+       gchar *name = gst_pad_get_name(pad);
+       GstElement *sinkbin = NULL;
+       GstPad *sinkpad = NULL;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_if_fail (wfd_sink && wfd_sink->pipeline);
+       wfd_sink_return_if_fail(wfd_sink && wfd_sink->pipeline);
 
-       if (name[0] == 'v')
-       {
+       if (name[0] == 'v') {
                wfd_sink_debug("=========== >>>>>>>>>> Received VIDEO pad...\n");
 
-               MMWFDSINK_PAD_PROBE( wfd_sink, pad, NULL,  NULL );
+               MMWFDSINK_PAD_PROBE(wfd_sink, pad, NULL,  NULL);
 
                gst_pad_add_probe(pad,
-                       GST_PAD_PROBE_TYPE_BUFFER,
-                       _mm_wfd_sink_check_running_time,
-                       (gpointer)wfd_sink,
-                       NULL);
-
-               if (GST_STATE(wfd_sink->pipeline->videobin[WFD_SINK_V_BIN].gst) <= GST_STATE_NULL)
-               {
-                       wfd_sink_debug ("need to prepare videobin" );
-                       if (MM_ERROR_NONE !=__mm_wfd_sink_prepare_videobin (wfd_sink))
-                       {
-                               wfd_sink_error ("failed to prepare videobin....\n");
+                                 GST_PAD_PROBE_TYPE_BUFFER,
+                                 _mm_wfd_sink_check_running_time,
+                                 (gpointer)wfd_sink,
+                                 NULL);
+
+               if (GST_STATE(wfd_sink->pipeline->videobin[WFD_SINK_V_BIN].gst) <= GST_STATE_NULL) {
+                       wfd_sink_debug("need to prepare videobin");
+                       if (MM_ERROR_NONE != __mm_wfd_sink_prepare_videobin(wfd_sink)) {
+                               wfd_sink_error("failed to prepare videobin....\n");
                                goto ERROR;
                        }
                }
@@ -1570,25 +1486,21 @@ __mm_wfd_sink_demux_pad_added (GstElement* ele, GstPad* pad, gpointer data)
                sinkbin = wfd_sink->pipeline->videobin[WFD_SINK_V_BIN].gst;
 
                wfd_sink->added_av_pad_num++;
-       }
-       else if (name[0] == 'a')
-       {
+       } else if (name[0] == 'a') {
                wfd_sink_debug("=========== >>>>>>>>>> Received AUDIO pad...\n");
 
-               MMWFDSINK_PAD_PROBE( wfd_sink, pad, NULL,  NULL );
+               MMWFDSINK_PAD_PROBE(wfd_sink, pad, NULL,  NULL);
 
                gst_pad_add_probe(pad,
-                       GST_PAD_PROBE_TYPE_BUFFER,
-                       _mm_wfd_sink_check_running_time,
-                       (gpointer)wfd_sink,
-                       NULL);
-
-               if (GST_STATE(wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst) <= GST_STATE_NULL)
-               {
-                       wfd_sink_debug ("need to prepare audiobin" );
-                       if (MM_ERROR_NONE !=__mm_wfd_sink_prepare_audiobin (wfd_sink))
-                       {
-                               wfd_sink_error ("failed to prepare audiobin....\n");
+                                 GST_PAD_PROBE_TYPE_BUFFER,
+                                 _mm_wfd_sink_check_running_time,
+                                 (gpointer)wfd_sink,
+                                 NULL);
+
+               if (GST_STATE(wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst) <= GST_STATE_NULL) {
+                       wfd_sink_debug("need to prepare audiobin");
+                       if (MM_ERROR_NONE != __mm_wfd_sink_prepare_audiobin(wfd_sink)) {
+                               wfd_sink_error("failed to prepare audiobin....\n");
                                goto ERROR;
                        }
                }
@@ -1596,21 +1508,17 @@ __mm_wfd_sink_demux_pad_added (GstElement* ele, GstPad* pad, gpointer data)
                sinkbin = wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst;
 
                wfd_sink->added_av_pad_num++;
-       }
-       else
-       {
+       } else {
                wfd_sink_error("not handling.....\n\n\n");
        }
 
 
-       if (sinkbin)
-       {
+       if (sinkbin) {
                wfd_sink_debug("add %s to pipeline.\n",
-                       GST_STR_NULL(GST_ELEMENT_NAME(sinkbin)));
+                              GST_STR_NULL(GST_ELEMENT_NAME(sinkbin)));
 
                /* add */
-               if(!gst_bin_add (GST_BIN(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst), sinkbin))
-               {
+               if (!gst_bin_add(GST_BIN(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst), sinkbin)) {
                        wfd_sink_error("failed to add sinkbin to pipeline\n");
                        goto ERROR;
                }
@@ -1618,26 +1526,23 @@ __mm_wfd_sink_demux_pad_added (GstElement* ele, GstPad* pad, gpointer data)
                wfd_sink_debug("link %s .\n", GST_STR_NULL(GST_ELEMENT_NAME(sinkbin)));
 
                /* link */
-               sinkpad = gst_element_get_static_pad (GST_ELEMENT_CAST(sinkbin), "sink");
-               if (!sinkpad)
-               {
+               sinkpad = gst_element_get_static_pad(GST_ELEMENT_CAST(sinkbin), "sink");
+               if (!sinkpad) {
                        wfd_sink_error("failed to get pad from sinkbin\n");
                        goto ERROR;
                }
 
-               if (GST_PAD_LINK_OK != gst_pad_link_full (pad, sinkpad, GST_PAD_LINK_CHECK_NOTHING))
-               {
+               if (GST_PAD_LINK_OK != gst_pad_link_full(pad, sinkpad, GST_PAD_LINK_CHECK_NOTHING)) {
                        wfd_sink_error("failed to link sinkbin\n");
                        goto ERROR;
                }
 
                wfd_sink_debug("sync state %s with pipeline .\n",
-                       GST_STR_NULL(GST_ELEMENT_NAME(sinkbin)));
+                              GST_STR_NULL(GST_ELEMENT_NAME(sinkbin)));
 
                /* run */
-               if (!gst_element_sync_state_with_parent (GST_ELEMENT_CAST(sinkbin)))
-               {
-                       wfd_sink_error ("failed to sync sinkbin state with parent \n");
+               if (!gst_element_sync_state_with_parent(GST_ELEMENT_CAST(sinkbin))) {
+                       wfd_sink_error("failed to sync sinkbin state with parent \n");
                        goto ERROR;
                }
 
@@ -1646,12 +1551,11 @@ __mm_wfd_sink_demux_pad_added (GstElement* ele, GstPad* pad, gpointer data)
        }
 
 
-       if (wfd_sink->added_av_pad_num == 2)
-       {
+       if (wfd_sink->added_av_pad_num == 2) {
                wfd_sink_debug("whole pipeline is constructed. \n");
 
                /* generate dot file of the constructed pipeline of wifi display sink */
-               MMWFDSINK_GENERATE_DOT_IF_ENABLED( wfd_sink, "constructed-pipeline" );
+               MMWFDSINK_GENERATE_DOT_IF_ENABLED(wfd_sink, "constructed-pipeline");
        }
 
        MMWFDSINK_FREEIF(name);
@@ -1660,7 +1564,7 @@ __mm_wfd_sink_demux_pad_added (GstElement* ele, GstPad* pad, gpointer data)
 
        return;
 
-/* ERRORS */
+       /* ERRORS */
 ERROR:
        MMWFDSINK_FREEIF(name);
 
@@ -1669,30 +1573,27 @@ ERROR:
        sinkpad = NULL;
 
        /* need to notify to app */
-       MMWFDSINK_POST_MESSAGE (wfd_sink,
-               MM_ERROR_WFD_INTERNAL,
-               MMWFDSINK_CURRENT_STATE(wfd_sink));
+       MMWFDSINK_POST_MESSAGE(wfd_sink,
+                              MM_ERROR_WFD_INTERNAL,
+                              MMWFDSINK_CURRENT_STATE(wfd_sink));
 
        return;
 }
 
 static void
-__mm_wfd_sink_change_av_format (GstElement* wfdrtspsrc, gpointer* need_to_flush, gpointer data)
+__mm_wfd_sink_change_av_format(GstElement *wfdrtspsrc, gpointer *need_to_flush, gpointer data)
 {
        mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *)data;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_if_fail (wfd_sink);
-       wfd_sink_return_if_fail (need_to_flush);
+       wfd_sink_return_if_fail(wfd_sink);
+       wfd_sink_return_if_fail(need_to_flush);
 
-       if (MMWFDSINK_CURRENT_STATE(wfd_sink)==MM_WFD_SINK_STATE_PLAYING)
-       {
+       if (MMWFDSINK_CURRENT_STATE(wfd_sink) == MM_WFD_SINK_STATE_PLAYING) {
                wfd_sink_debug("need to flush pipeline");
                *need_to_flush = (gpointer) TRUE;
-       }
-       else
-       {
+       } else {
                wfd_sink_debug("don't need to flush pipeline");
                *need_to_flush = (gpointer) FALSE;
        }
@@ -1703,91 +1604,84 @@ __mm_wfd_sink_change_av_format (GstElement* wfdrtspsrc, gpointer* need_to_flush,
 
 
 static void
-__mm_wfd_sink_update_stream_info (GstElement* wfdrtspsrc, GstStructure* str, gpointer data)
+__mm_wfd_sink_update_stream_info(GstElement *wfdrtspsrc, GstStructure *str, gpointer data)
 {
        mm_wfd_sink_t *wfd_sink = (mm_wfd_sink_t *)data;
        WFDSinkManagerCMDType cmd = WFD_SINK_MANAGER_CMD_NONE;
-       MMWFDSinkStreamInfo * stream_info = NULL;
+       MMWFDSinkStreamInfo *stream_info = NULL;
        gint is_valid_audio_format = FALSE;
        gint is_valid_video_format = FALSE;
-       gchar * audio_format;
-       gchar * video_format;
+       gchar *audio_format;
+       gchar *video_format;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_if_fail (str && GST_IS_STRUCTURE(str));
-       wfd_sink_return_if_fail (wfd_sink);
+       wfd_sink_return_if_fail(str && GST_IS_STRUCTURE(str));
+       wfd_sink_return_if_fail(wfd_sink);
 
        stream_info = &wfd_sink->stream_info;
 
-       if (gst_structure_has_field (str, "audio_format"))
-       {
+       if (gst_structure_has_field(str, "audio_format")) {
                is_valid_audio_format = TRUE;
                audio_format = g_strdup(gst_structure_get_string(str, "audio_format"));
-               if (g_strrstr(audio_format,"AAC"))
+               if (g_strrstr(audio_format, "AAC"))
                        stream_info->audio_stream_info.codec = WFD_SINK_AUDIO_CODEC_AAC;
-               else if (g_strrstr(audio_format,"AC3"))
+               else if (g_strrstr(audio_format, "AC3"))
                        stream_info->audio_stream_info.codec = WFD_SINK_AUDIO_CODEC_AC3;
-               else if (g_strrstr(audio_format,"LPCM"))
+               else if (g_strrstr(audio_format, "LPCM"))
                        stream_info->audio_stream_info.codec = WFD_SINK_AUDIO_CODEC_LPCM;
-               else
-               {
-                       wfd_sink_error ("invalid audio format(%s)...\n", audio_format);
+               else {
+                       wfd_sink_error("invalid audio format(%s)...\n", audio_format);
                        is_valid_audio_format = FALSE;
                }
 
-               if (is_valid_audio_format == TRUE)
-               {
-                       if (gst_structure_has_field (str, "audio_rate"))
-                               gst_structure_get_int (str, "audio_rate", &stream_info->audio_stream_info.sample_rate);
-                       if (gst_structure_has_field (str, "audio_channels"))
-                               gst_structure_get_int (str, "audio_channels", &stream_info->audio_stream_info.channels);
-                       if (gst_structure_has_field (str, "audio_bitwidth"))
-                               gst_structure_get_int (str, "audio_bitwidth", &stream_info->audio_stream_info.bitwidth);
+               if (is_valid_audio_format == TRUE) {
+                       if (gst_structure_has_field(str, "audio_rate"))
+                               gst_structure_get_int(str, "audio_rate", &stream_info->audio_stream_info.sample_rate);
+                       if (gst_structure_has_field(str, "audio_channels"))
+                               gst_structure_get_int(str, "audio_channels", &stream_info->audio_stream_info.channels);
+                       if (gst_structure_has_field(str, "audio_bitwidth"))
+                               gst_structure_get_int(str, "audio_bitwidth", &stream_info->audio_stream_info.bitwidth);
 
                        cmd = cmd | WFD_SINK_MANAGER_CMD_LINK_A_BIN;
 
-                       wfd_sink_debug ("audio_format : %s \n \t rate : %d \n \t channels :  %d \n \t bitwidth :  %d \n \t      \n",
-                               audio_format,
-                               stream_info->audio_stream_info.sample_rate,
-                               stream_info->audio_stream_info.channels,
-                               stream_info->audio_stream_info.bitwidth);
+                       wfd_sink_debug("audio_format : %s \n \t rate :  %d \n \t channels :  %d \n \t bitwidth :  %d \n \t      \n",
+                                      audio_format,
+                                      stream_info->audio_stream_info.sample_rate,
+                                      stream_info->audio_stream_info.channels,
+                                      stream_info->audio_stream_info.bitwidth);
                }
        }
 
-       if (gst_structure_has_field (str, "video_format"))
-       {
+       if (gst_structure_has_field(str, "video_format")) {
                is_valid_video_format = TRUE;
                video_format = g_strdup(gst_structure_get_string(str, "video_format"));
-               if (!g_strrstr(video_format,"H264"))
-               {
-                       wfd_sink_error ("invalid video format(%s)...\n", video_format);
+               if (!g_strrstr(video_format, "H264")) {
+                       wfd_sink_error("invalid video format(%s)...\n", video_format);
                        is_valid_video_format = FALSE;
                }
 
-               if(is_valid_video_format == TRUE)
-               {
+               if (is_valid_video_format == TRUE) {
                        stream_info->video_stream_info.codec = WFD_SINK_VIDEO_CODEC_H264;
 
-                       if (gst_structure_has_field (str, "video_width"))
-                               gst_structure_get_int (str, "video_width", &stream_info->video_stream_info.width);
-                       if (gst_structure_has_field (str, "video_height"))
-                               gst_structure_get_int (str, "video_height", &stream_info->video_stream_info.height);
-                       if (gst_structure_has_field (str, "video_framerate"))
-                               gst_structure_get_int (str, "video_framerate", &stream_info->video_stream_info.frame_rate);
+                       if (gst_structure_has_field(str, "video_width"))
+                               gst_structure_get_int(str, "video_width", &stream_info->video_stream_info.width);
+                       if (gst_structure_has_field(str, "video_height"))
+                               gst_structure_get_int(str, "video_height", &stream_info->video_stream_info.height);
+                       if (gst_structure_has_field(str, "video_framerate"))
+                               gst_structure_get_int(str, "video_framerate", &stream_info->video_stream_info.frame_rate);
 
                        cmd = cmd | WFD_SINK_MANAGER_CMD_LINK_V_BIN;
 
                        wfd_sink_debug("video_format : %s \n \t width :  %d \n \t height :  %d \n \t frame_rate :  %d \n \t  \n",
-                               video_format,
-                               stream_info->video_stream_info.width,
-                               stream_info->video_stream_info.height,
-                               stream_info->video_stream_info.frame_rate);
+                                      video_format,
+                                      stream_info->video_stream_info.width,
+                                      stream_info->video_stream_info.height,
+                                      stream_info->video_stream_info.frame_rate);
                }
        }
 
-       if (cmd != WFD_SINK_MANAGER_CMD_NONE)
-       {
+       if (cmd != WFD_SINK_MANAGER_CMD_NONE) {
                WFD_SINK_MANAGER_LOCK(wfd_sink);
                WFD_SINK_MANAGER_SIGNAL_CMD(wfd_sink, cmd);
                WFD_SINK_MANAGER_UNLOCK(wfd_sink);
@@ -1804,63 +1698,75 @@ static int __mm_wfd_sink_prepare_wfdrtspsrc(mm_wfd_sink_t *wfd_sink, GstElement
        void *hdcp_handle = NULL;
        gint hdcp_version = 0;
        gint hdcp_port = 0;
+       guint CEA_resolution = 0;
+       guint VESA_resolution = 0;
+       guint HH_resolution = 0;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
-       wfd_sink_return_val_if_fail (wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
-       wfd_sink_return_val_if_fail (wfdrtspsrc, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfdrtspsrc, MM_ERROR_WFD_NOT_INITIALIZED);
 
-       g_object_set (G_OBJECT(wfdrtspsrc), "debug", wfd_sink->ini.set_debug_property, NULL);
-       g_object_set (G_OBJECT(wfdrtspsrc), "latency", wfd_sink->ini.jitter_buffer_latency, NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "debug", wfd_sink->ini.set_debug_property, NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "latency", wfd_sink->ini.jitter_buffer_latency, NULL);
 #if 0
-       g_object_set (G_OBJECT(wfdrtspsrc), "do-request", wfd_sink->ini.enable_retransmission, NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "do-request", wfd_sink->ini.enable_retransmission, NULL);
 #endif
-       g_object_set (G_OBJECT(wfdrtspsrc), "udp-buffer-size", 2097152, NULL);
-       g_object_set (G_OBJECT(wfdrtspsrc), "enable-pad-probe", wfd_sink->ini.enable_wfdrtspsrc_pad_probe, NULL);
-
-       audio_param = gst_structure_new ("audio_param",
-               "audio_codec", G_TYPE_UINT, wfd_sink->ini.audio_codec,
-               "audio_latency", G_TYPE_UINT, wfd_sink->ini.audio_latency,
-               "audio_channels", G_TYPE_UINT, wfd_sink->ini.audio_channel,
-               "audio_sampling_frequency", G_TYPE_UINT, wfd_sink->ini.audio_sampling_frequency,
-               NULL);
-
-       video_param = gst_structure_new ("video_param",
-               "video_codec", G_TYPE_UINT, wfd_sink->ini.video_codec,
-               "video_native_resolution", G_TYPE_UINT, wfd_sink->ini.video_native_resolution,
-               "video_cea_support", G_TYPE_UINT, wfd_sink->ini.video_cea_support,
-               "video_vesa_support", G_TYPE_UINT, wfd_sink->ini.video_vesa_support,
-               "video_hh_support", G_TYPE_UINT, wfd_sink->ini.video_hh_support,
-               "video_profile", G_TYPE_UINT, wfd_sink->ini.video_profile,
-               "video_level", G_TYPE_UINT, wfd_sink->ini.video_level,
-               "video_latency", G_TYPE_UINT, wfd_sink->ini.video_latency,
-               "video_vertical_resolution", G_TYPE_INT, wfd_sink->ini.video_vertical_resolution,
-               "video_horizontal_resolution", G_TYPE_INT, wfd_sink->ini.video_horizontal_resolution,
-               "video_minimum_slicing", G_TYPE_INT, wfd_sink->ini.video_minimum_slicing,
-               "video_slice_enc_param", G_TYPE_INT, wfd_sink->ini.video_slice_enc_param,
-               "video_framerate_control_support", G_TYPE_INT, wfd_sink->ini.video_framerate_control_support,
-               NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "udp-buffer-size", 2097152, NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "enable-pad-probe", wfd_sink->ini.enable_wfdrtspsrc_pad_probe, NULL);
+
+       audio_param = gst_structure_new("audio_param",
+                                       "audio_codec", G_TYPE_UINT, wfd_sink->ini.audio_codec,
+                                       "audio_latency", G_TYPE_UINT, wfd_sink->ini.audio_latency,
+                                       "audio_channels", G_TYPE_UINT, wfd_sink->ini.audio_channel,
+                                       "audio_sampling_frequency", G_TYPE_UINT, wfd_sink->ini.audio_sampling_frequency,
+                                       NULL);
+
+       CEA_resolution = wfd_sink->ini.video_cea_support;
+       VESA_resolution = wfd_sink->ini.video_vesa_support;
+       HH_resolution =  wfd_sink->ini.video_hh_support;
+
+       __mm_wfd_sink_prepare_video_resolution(wfd_sink->supportive_resolution,
+                                              &CEA_resolution, &VESA_resolution, &HH_resolution);
+
+       wfd_sink_debug("set video resolution CEA[%x] VESA[%x] HH[%x]", CEA_resolution, VESA_resolution, HH_resolution);
+
+       video_param = gst_structure_new("video_param",
+                                       "video_codec", G_TYPE_UINT, wfd_sink->ini.video_codec,
+                                       "video_native_resolution", G_TYPE_UINT, wfd_sink->ini.video_native_resolution,
+                                       "video_cea_support", G_TYPE_UINT, CEA_resolution,
+                                       "video_vesa_support", G_TYPE_UINT, VESA_resolution,
+                                       "video_hh_support", G_TYPE_UINT, HH_resolution,
+                                       "video_profile", G_TYPE_UINT, wfd_sink->ini.video_profile,
+                                       "video_level", G_TYPE_UINT, wfd_sink->ini.video_level,
+                                       "video_latency", G_TYPE_UINT, wfd_sink->ini.video_latency,
+                                       "video_vertical_resolution", G_TYPE_INT, wfd_sink->ini.video_vertical_resolution,
+                                       "video_horizontal_resolution", G_TYPE_INT, wfd_sink->ini.video_horizontal_resolution,
+                                       "video_minimum_slicing", G_TYPE_INT, wfd_sink->ini.video_minimum_slicing,
+                                       "video_slice_enc_param", G_TYPE_INT, wfd_sink->ini.video_slice_enc_param,
+                                       "video_framerate_control_support", G_TYPE_INT, wfd_sink->ini.video_framerate_control_support,
+                                       NULL);
 
        mm_attrs_get_data_by_name(wfd_sink->attrs, "hdcp_handle", &hdcp_handle);
        mm_attrs_get_int_by_name(wfd_sink->attrs, "hdcp_version", &hdcp_version);
        mm_attrs_get_int_by_name(wfd_sink->attrs, "hdcp_port", &hdcp_port);
        wfd_sink_debug("set hdcp version %d with %d port\n", hdcp_version, hdcp_port);
 
-       hdcp_param = gst_structure_new ("hdcp_param",
-                       "hdcp_version", G_TYPE_INT, hdcp_version,
-                       "hdcp_port_no", G_TYPE_INT, hdcp_port,
-                       NULL);
+       hdcp_param = gst_structure_new("hdcp_param",
+                                      "hdcp_version", G_TYPE_INT, hdcp_version,
+                                      "hdcp_port_no", G_TYPE_INT, hdcp_port,
+                                      NULL);
 
-       g_object_set (G_OBJECT(wfdrtspsrc), "audio-param", audio_param, NULL);
-       g_object_set (G_OBJECT(wfdrtspsrc), "video-param", video_param, NULL);
-       g_object_set (G_OBJECT(wfdrtspsrc), "hdcp-param", hdcp_param, NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "audio-param", audio_param, NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "video-param", video_param, NULL);
+       g_object_set(G_OBJECT(wfdrtspsrc), "hdcp-param", hdcp_param, NULL);
 
-       g_signal_connect (wfdrtspsrc, "update-media-info",
-               G_CALLBACK(__mm_wfd_sink_update_stream_info), wfd_sink);
+       g_signal_connect(wfdrtspsrc, "update-media-info",
+                        G_CALLBACK(__mm_wfd_sink_update_stream_info), wfd_sink);
 
-       g_signal_connect (wfdrtspsrc, "change-av-format",
-               G_CALLBACK(__mm_wfd_sink_change_av_format), wfd_sink);
+       g_signal_connect(wfdrtspsrc, "change-av-format",
+                        G_CALLBACK(__mm_wfd_sink_change_av_format), wfd_sink);
 
        wfd_sink_debug_fleave();
 
@@ -1871,11 +1777,11 @@ static int __mm_wfd_sink_prepare_demux(mm_wfd_sink_t *wfd_sink, GstElement *demu
 {
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
-       wfd_sink_return_val_if_fail (demux, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(demux, MM_ERROR_WFD_NOT_INITIALIZED);
 
-       g_signal_connect (demux, "pad-added",
-               G_CALLBACK(__mm_wfd_sink_demux_pad_added),      wfd_sink);
+       g_signal_connect(demux, "pad-added",
+                        G_CALLBACK(__mm_wfd_sink_demux_pad_added),     wfd_sink);
 
        wfd_sink_debug_fleave();
 
@@ -1885,88 +1791,80 @@ static int __mm_wfd_sink_prepare_demux(mm_wfd_sink_t *wfd_sink, GstElement *demu
 static int __mm_wfd_sink_create_pipeline(mm_wfd_sink_t *wfd_sink)
 {
        MMWFDSinkGstElement *mainbin = NULL;
-       GListelement_bucket = NULL;
+       GList *element_bucket = NULL;
        GstBus  *bus = NULL;
        int i;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
-       wfd_sink_return_val_if_fail (wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* Create pipeline */
-       wfd_sink->pipeline = (MMWFDSinkGstPipelineInfo*) g_malloc0 (sizeof(MMWFDSinkGstPipelineInfo));
+       wfd_sink->pipeline = (MMWFDSinkGstPipelineInfo *) g_malloc0(sizeof(MMWFDSinkGstPipelineInfo));
        if (wfd_sink->pipeline == NULL)
                goto CREATE_ERROR;
 
-       memset (wfd_sink->pipeline, 0, sizeof(MMWFDSinkGstPipelineInfo));
+       memset(wfd_sink->pipeline, 0, sizeof(MMWFDSinkGstPipelineInfo));
 
        /* create mainbin */
-       mainbin = (MMWFDSinkGstElement*) g_malloc0 (sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
+       mainbin = (MMWFDSinkGstElement *) g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
        if (mainbin == NULL)
                goto CREATE_ERROR;
 
-       memset (mainbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
+       memset(mainbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
 
        /* create pipeline */
        mainbin[WFD_SINK_M_PIPE].id = WFD_SINK_M_PIPE;
-       mainbin[WFD_SINK_M_PIPE].gst = gst_pipeline_new ("wfdsink");
-       if (!mainbin[WFD_SINK_M_PIPE].gst)
-       {
-               wfd_sink_error ("failed to create pipeline\n");
+       mainbin[WFD_SINK_M_PIPE].gst = gst_pipeline_new("wfdsink");
+       if (!mainbin[WFD_SINK_M_PIPE].gst) {
+               wfd_sink_error("failed to create pipeline\n");
                goto CREATE_ERROR;
        }
 
        /* create wfdrtspsrc */
        MMWFDSINK_CREATE_ELEMENT(mainbin, WFD_SINK_M_SRC, "wfdrtspsrc", "wfdsink_source", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, mainbin[WFD_SINK_M_SRC].gst,  "src" );
-       if (mainbin[WFD_SINK_M_SRC].gst)
-       {
-               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_wfdrtspsrc (wfd_sink, mainbin[WFD_SINK_M_SRC].gst))
-               {
-                       wfd_sink_error ("failed to prepare wfdrtspsrc...\n");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, mainbin[WFD_SINK_M_SRC].gst,  "src");
+       if (mainbin[WFD_SINK_M_SRC].gst) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_wfdrtspsrc(wfd_sink, mainbin[WFD_SINK_M_SRC].gst)) {
+                       wfd_sink_error("failed to prepare wfdrtspsrc...\n");
                        goto CREATE_ERROR;
                }
        }
 
        /* create rtpmp2tdepay */
-       MMWFDSINK_CREATE_ELEMENT (mainbin, WFD_SINK_M_DEPAY, "rtpmp2tdepay", "wfdsink_depay", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, mainbin[WFD_SINK_M_DEPAY].gst, "src" );
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, mainbin[WFD_SINK_M_DEPAY].gst, "sink" );
+       MMWFDSINK_CREATE_ELEMENT(mainbin, WFD_SINK_M_DEPAY, "rtpmp2tdepay", "wfdsink_depay", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, mainbin[WFD_SINK_M_DEPAY].gst, "src");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, mainbin[WFD_SINK_M_DEPAY].gst, "sink");
 
-       MMWFDSINK_TS_DATA_DUMP( wfd_sink, mainbin[WFD_SINK_M_DEPAY].gst, "src" );
+       MMWFDSINK_TS_DATA_DUMP(wfd_sink, mainbin[WFD_SINK_M_DEPAY].gst, "src");
 
        /* create tsdemuxer*/
-       MMWFDSINK_CREATE_ELEMENT (mainbin, WFD_SINK_M_DEMUX, wfd_sink->ini.name_of_tsdemux, "wfdsink_demux", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, mainbin[WFD_SINK_M_DEMUX].gst, "sink" );
-       if (mainbin[WFD_SINK_M_DEMUX].gst)
-       {
-               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_demux (wfd_sink, mainbin[WFD_SINK_M_DEMUX].gst))
-               {
-                       wfd_sink_error ("failed to prepare demux...\n");
+       MMWFDSINK_CREATE_ELEMENT(mainbin, WFD_SINK_M_DEMUX, wfd_sink->ini.name_of_tsdemux, "wfdsink_demux", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, mainbin[WFD_SINK_M_DEMUX].gst, "sink");
+       if (mainbin[WFD_SINK_M_DEMUX].gst) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_demux(wfd_sink, mainbin[WFD_SINK_M_DEMUX].gst)) {
+                       wfd_sink_error("failed to prepare demux...\n");
                        goto CREATE_ERROR;
                }
        }
 
        /* adding created elements to pipeline */
-       if( !__mm_wfd_sink_gst_element_add_bucket_to_bin (GST_BIN_CAST(mainbin[WFD_SINK_M_PIPE].gst), element_bucket, FALSE))
-       {
-               wfd_sink_error ("failed to add elements\n");
+       if (!__mm_wfd_sink_gst_element_add_bucket_to_bin(GST_BIN_CAST(mainbin[WFD_SINK_M_PIPE].gst), element_bucket, FALSE)) {
+               wfd_sink_error("failed to add elements\n");
                goto CREATE_ERROR;
        }
 
        /* linking elements in the bucket by added order. */
-       if ( __mm_wfd_sink_gst_element_link_bucket (element_bucket) == -1 )
-       {
+       if (__mm_wfd_sink_gst_element_link_bucket(element_bucket) == -1) {
                wfd_sink_error("failed to link elements\n");
                goto CREATE_ERROR;
        }
 
        /* connect bus callback */
-       bus = gst_pipeline_get_bus (GST_PIPELINE(mainbin[WFD_SINK_M_PIPE].gst));
-       if (!bus)
-       {
-               wfd_sink_error ("cannot get bus from pipeline.\n");
+       bus = gst_pipeline_get_bus(GST_PIPELINE(mainbin[WFD_SINK_M_PIPE].gst));
+       if (!bus) {
+               wfd_sink_error("cannot get bus from pipeline.\n");
                goto CREATE_ERROR;
        }
 
@@ -1986,12 +1884,12 @@ static int __mm_wfd_sink_create_pipeline(mm_wfd_sink_t *wfd_sink)
 
        return MM_ERROR_NONE;
 
-/* ERRORS */
+       /* ERRORS */
 CREATE_ERROR:
        wfd_sink_error("ERROR : releasing pipeline\n");
 
        if (element_bucket)
-               g_list_free (element_bucket);
+               g_list_free(element_bucket);
        element_bucket = NULL;
 
        /* finished */
@@ -2000,34 +1898,27 @@ CREATE_ERROR:
        bus = NULL;
 
        /* release element which are not added to bin */
-       for (i = 1; i < WFD_SINK_M_NUM; i++)    /* NOTE : skip pipeline */
-       {
-               if (mainbin != NULL && mainbin[i].gst)
-               {
-                       GstObject* parent = NULL;
-                       parent = gst_element_get_parent (mainbin[i].gst);
-
-                       if (!parent)
-                       {
+       for (i = 1; i < WFD_SINK_M_NUM; i++) {  /* NOTE : skip pipeline */
+               if (mainbin != NULL && mainbin[i].gst) {
+                       GstObject *parent = NULL;
+                       parent = gst_element_get_parent(mainbin[i].gst);
+
+                       if (!parent) {
                                gst_object_unref(GST_OBJECT(mainbin[i].gst));
                                mainbin[i].gst = NULL;
-                       }
-                       else
-                       {
+                       } else {
                                gst_object_unref(GST_OBJECT(parent));
                        }
                }
        }
 
        /* release audiobin with it's childs */
-       if (mainbin != NULL && mainbin[WFD_SINK_M_PIPE].gst )
-       {
-               gst_object_unref (GST_OBJECT(mainbin[WFD_SINK_M_PIPE].gst));
-       }
+       if (mainbin != NULL && mainbin[WFD_SINK_M_PIPE].gst)
+               gst_object_unref(GST_OBJECT(mainbin[WFD_SINK_M_PIPE].gst));
 
-       MMWFDSINK_FREEIF (mainbin);
+       MMWFDSINK_FREEIF(mainbin);
 
-       MMWFDSINK_FREEIF (wfd_sink->pipeline);
+       MMWFDSINK_FREEIF(wfd_sink->pipeline);
 
        return MM_ERROR_WFD_INTERNAL;
 }
@@ -2038,24 +1929,23 @@ int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink)
        MMWFDSinkGstElement *first_element = NULL;
        MMWFDSinkGstElement *last_element = NULL;
        gint audio_codec = WFD_SINK_AUDIO_CODEC_NONE;
-       GListelement_bucket = NULL;
+       GList *element_bucket = NULL;
        GstPad *sinkpad = NULL;
        GstPad *srcpad = NULL;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->audiobin &&
-               wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst,
-               MM_ERROR_WFD_NOT_INITIALIZED );
-       wfd_sink_return_val_if_fail (wfd_sink->prev_audio_dec_src_pad &&
-               wfd_sink->next_audio_dec_sink_pad,
-               MM_ERROR_WFD_INTERNAL);
-
-       if (wfd_sink->audio_bin_is_linked)
-       {
-               wfd_sink_debug ("audiobin is already linked... nothing to do\n");
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline &&
+                                   wfd_sink->pipeline->audiobin &&
+                                   wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink->prev_audio_dec_src_pad &&
+                                   wfd_sink->next_audio_dec_sink_pad,
+                                   MM_ERROR_WFD_INTERNAL);
+
+       if (wfd_sink->audio_bin_is_linked) {
+               wfd_sink_debug("audiobin is already linked... nothing to do\n");
                return MM_ERROR_NONE;
        }
 
@@ -2064,8 +1954,7 @@ int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink)
 
        /* check audio codec */
        audio_codec = wfd_sink->stream_info.audio_stream_info.codec;
-       switch (audio_codec)
-       {
+       switch (audio_codec) {
                case WFD_SINK_AUDIO_CODEC_LPCM:
                        if (audiobin[WFD_SINK_A_LPCM_CONVERTER].gst)
                                element_bucket = g_list_append(element_bucket, &audiobin[WFD_SINK_A_LPCM_CONVERTER]);
@@ -2093,11 +1982,9 @@ int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink)
                        break;
        }
 
-       if (!element_bucket)
-       {
-               wfd_sink_debug ("there is no additional elements to be linked... just link audiobin.\n");
-               if (GST_PAD_LINK_OK != gst_pad_link_full(wfd_sink->prev_audio_dec_src_pad, wfd_sink->next_audio_dec_sink_pad, GST_PAD_LINK_CHECK_NOTHING))
-               {
+       if (!element_bucket) {
+               wfd_sink_debug("there is no additional elements to be linked... just link audiobin.\n");
+               if (GST_PAD_LINK_OK != gst_pad_link_full(wfd_sink->prev_audio_dec_src_pad, wfd_sink->next_audio_dec_sink_pad, GST_PAD_LINK_CHECK_NOTHING)) {
                        wfd_sink_error("failed to link audiobin....\n");
                        goto fail_to_link;
                }
@@ -2105,36 +1992,31 @@ int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink)
        }
 
        /* adding elements to audiobin */
-       if( !__mm_wfd_sink_gst_element_add_bucket_to_bin (GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), element_bucket, FALSE))
-       {
-               wfd_sink_error ("failed to add elements to audiobin\n");
+       if (!__mm_wfd_sink_gst_element_add_bucket_to_bin(GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), element_bucket, FALSE)) {
+               wfd_sink_error("failed to add elements to audiobin\n");
                goto fail_to_link;
        }
 
        /* linking elements in the bucket by added order. */
-       if ( __mm_wfd_sink_gst_element_link_bucket (element_bucket) == -1 )
-       {
+       if (__mm_wfd_sink_gst_element_link_bucket(element_bucket) == -1) {
                wfd_sink_error("failed to link elements\n");
                goto fail_to_link;
        }
 
        /* get src pad */
        first_element = (MMWFDSinkGstElement *)g_list_nth_data(element_bucket, 0);
-       if (!first_element)
-       {
+       if (!first_element) {
                wfd_sink_error("failed to get first element to be linked....\n");
                goto fail_to_link;
        }
 
        sinkpad = gst_element_get_static_pad(GST_ELEMENT(first_element->gst), "sink");
-       if (!sinkpad)
-       {
+       if (!sinkpad) {
                wfd_sink_error("failed to get sink pad from element(%s)\n", GST_ELEMENT_NAME(first_element->gst));
                goto fail_to_link;
        }
 
-       if (GST_PAD_LINK_OK != gst_pad_link_full(wfd_sink->prev_audio_dec_src_pad, sinkpad, GST_PAD_LINK_CHECK_NOTHING))
-       {
+       if (GST_PAD_LINK_OK != gst_pad_link_full(wfd_sink->prev_audio_dec_src_pad, sinkpad, GST_PAD_LINK_CHECK_NOTHING)) {
                wfd_sink_error("failed to link audiobin....\n");
                goto fail_to_link;
        }
@@ -2144,22 +2026,19 @@ int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink)
 
 
        /* get sink pad */
-       last_element = (MMWFDSinkGstElement *)g_list_nth_data(element_bucket, g_list_length(element_bucket)-1);
-       if (!last_element)
-       {
+       last_element = (MMWFDSinkGstElement *)g_list_nth_data(element_bucket, g_list_length(element_bucket) - 1);
+       if (!last_element) {
                wfd_sink_error("failed to get last element to be linked....\n");
                goto fail_to_link;
        }
 
        srcpad = gst_element_get_static_pad(GST_ELEMENT(last_element->gst), "src");
-       if (!srcpad)
-       {
+       if (!srcpad) {
                wfd_sink_error("failed to get src pad from element(%s)\n", GST_ELEMENT_NAME(last_element->gst));
                goto fail_to_link;
        }
 
-       if (GST_PAD_LINK_OK != gst_pad_link_full(srcpad, wfd_sink->next_audio_dec_sink_pad, GST_PAD_LINK_CHECK_NOTHING))
-       {
+       if (GST_PAD_LINK_OK != gst_pad_link_full(srcpad, wfd_sink->next_audio_dec_sink_pad, GST_PAD_LINK_CHECK_NOTHING)) {
                wfd_sink_error("failed to link audiobin....\n");
                goto fail_to_link;
        }
@@ -2167,7 +2046,7 @@ int __mm_wfd_sink_link_audiobin(mm_wfd_sink_t *wfd_sink)
        gst_object_unref(GST_OBJECT(srcpad));
        srcpad = NULL;
 
-       g_list_free (element_bucket);
+       g_list_free(element_bucket);
 
 done:
        wfd_sink->audio_bin_is_linked = TRUE;
@@ -2176,7 +2055,7 @@ done:
 
        return MM_ERROR_NONE;
 
-/* ERRORS*/
+       /* ERRORS*/
 fail_to_link:
        if (srcpad)
                gst_object_unref(GST_OBJECT(srcpad));
@@ -2186,7 +2065,7 @@ fail_to_link:
                gst_object_unref(GST_OBJECT(sinkpad));
        sinkpad = NULL;
 
-       g_list_free (element_bucket);
+       g_list_free(element_bucket);
 
        return MM_ERROR_WFD_INTERNAL;
 }
@@ -2196,15 +2075,15 @@ static int __mm_wfd_sink_prepare_audiosink(mm_wfd_sink_t *wfd_sink, GstElement *
        wfd_sink_debug_fenter();
 
        /* check audiosink is created */
-       wfd_sink_return_val_if_fail (audio_sink, MM_ERROR_WFD_INVALID_ARGUMENT);
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(audio_sink, MM_ERROR_WFD_INVALID_ARGUMENT);
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
-       g_object_set (G_OBJECT(audio_sink), "provide-clock", FALSE,  NULL);
-       g_object_set (G_OBJECT(audio_sink), "buffer-time", 100000LL, NULL);
-       g_object_set (G_OBJECT(audio_sink), "query-position-support", FALSE,  NULL);
-       g_object_set (G_OBJECT(audio_sink), "slave-method", 2,  NULL);
-       g_object_set (G_OBJECT(audio_sink), "async", wfd_sink->ini.audio_sink_async,  NULL);
-       g_object_set (G_OBJECT(audio_sink), "ts-offset", (gint64)wfd_sink->ini.sink_ts_offset, NULL );
+       g_object_set(G_OBJECT(audio_sink), "provide-clock", FALSE,  NULL);
+       g_object_set(G_OBJECT(audio_sink), "buffer-time", 100000LL, NULL);
+       g_object_set(G_OBJECT(audio_sink), "query-position-support", FALSE,  NULL);
+       g_object_set(G_OBJECT(audio_sink), "slave-method", 2,  NULL);
+       g_object_set(G_OBJECT(audio_sink), "async", wfd_sink->ini.audio_sink_async,  NULL);
+       g_object_set(G_OBJECT(audio_sink), "ts-offset", (gint64)wfd_sink->ini.sink_ts_offset, NULL);
 
        wfd_sink_debug_fleave();
 
@@ -2212,97 +2091,83 @@ static int __mm_wfd_sink_prepare_audiosink(mm_wfd_sink_t *wfd_sink, GstElement *
 }
 
 static void
-__mm_wfd_sink_queue_overrun (GstElement* element, gpointer u_data)
+__mm_wfd_sink_queue_overrun(GstElement *element, gpointer u_data)
 {
-        debug_fenter();
+       debug_fenter();
 
-        return_if_fail(element);
+       return_if_fail(element);
 
-        wfd_sink_warning ("%s is overrun\n",
-                       GST_STR_NULL(GST_ELEMENT_NAME(element)));
+       wfd_sink_warning("%s is overrun\n",
+                        GST_STR_NULL(GST_ELEMENT_NAME(element)));
 
-        debug_fleave();
+       debug_fleave();
 
-        return;
+       return;
 }
 
-static int  __mm_wfd_sink_destroy_audiobin(mm_wfd_sink_twfd_sink)
+static int  __mm_wfd_sink_destroy_audiobin(mm_wfd_sink_t *wfd_sink)
 {
        GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-       MMWFDSinkGstElementaudiobin = NULL;
-       GstObjectparent = NULL;
+       MMWFDSinkGstElement *audiobin = NULL;
+       GstObject *parent = NULL;
        int i;
 
-       wfd_sink_debug_fenter ();
+       wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink,
-               MM_ERROR_WFD_NOT_INITIALIZED);
+       wfd_sink_return_val_if_fail(wfd_sink,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
 
        if (wfd_sink->pipeline &&
-               wfd_sink->pipeline->audiobin &&
-               wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst)
-       {
+           wfd_sink->pipeline->audiobin &&
+           wfd_sink->pipeline->audiobin[WFD_SINK_A_BIN].gst) {
                audiobin = wfd_sink->pipeline->audiobin;
-       }
-       else
-       {
+       } else {
                wfd_sink_debug("audiobin is not created, nothing to destroy\n");
                return MM_ERROR_NONE;
        }
 
 
-       parent = gst_element_get_parent (audiobin[WFD_SINK_A_BIN].gst);
-       if (!parent)
-       {
+       parent = gst_element_get_parent(audiobin[WFD_SINK_A_BIN].gst);
+       if (!parent) {
                wfd_sink_debug("audiobin has no parent.. need to relase by itself\n");
 
-               if (GST_STATE(audiobin[WFD_SINK_A_BIN].gst)>=GST_STATE_READY)
-               {
+               if (GST_STATE(audiobin[WFD_SINK_A_BIN].gst) >= GST_STATE_READY) {
                        wfd_sink_debug("try to change state of audiobin to NULL\n");
-                       ret = gst_element_set_state (audiobin[WFD_SINK_A_BIN].gst, GST_STATE_NULL);
-                       if ( ret != GST_STATE_CHANGE_SUCCESS )
-                       {
+                       ret = gst_element_set_state(audiobin[WFD_SINK_A_BIN].gst, GST_STATE_NULL);
+                       if (ret != GST_STATE_CHANGE_SUCCESS) {
                                wfd_sink_error("failed to change state of audiobin to NULL\n");
                                return MM_ERROR_WFD_INTERNAL;
                        }
                }
 
                /* release element which are not added to bin */
-               for (i = 1; i < WFD_SINK_A_NUM; i++)    /* NOTE : skip bin */
-               {
-                       if (audiobin[i].gst)
-                       {
-                               parent = gst_element_get_parent (audiobin[i].gst);
-                               if (!parent)
-                               {
+               for (i = 1; i < WFD_SINK_A_NUM; i++) {  /* NOTE : skip bin */
+                       if (audiobin[i].gst) {
+                               parent = gst_element_get_parent(audiobin[i].gst);
+                               if (!parent) {
                                        wfd_sink_debug("unref %s(current ref %d)\n",
-                                               GST_STR_NULL(GST_ELEMENT_NAME(audiobin[i].gst)),
-                                               ((GObject *) audiobin[i].gst)->ref_count);
+                                                      GST_STR_NULL(GST_ELEMENT_NAME(audiobin[i].gst)),
+                                                      ((GObject *) audiobin[i].gst)->ref_count);
                                        gst_object_unref(GST_OBJECT(audiobin[i].gst));
                                        audiobin[i].gst = NULL;
-                               }
-                               else
-                               {
+                               } else {
                                        wfd_sink_debug("unref %s(current ref %d)\n",
-                                               GST_STR_NULL(GST_ELEMENT_NAME(audiobin[i].gst)),
-                                               ((GObject *) audiobin[i].gst)->ref_count);
+                                                      GST_STR_NULL(GST_ELEMENT_NAME(audiobin[i].gst)),
+                                                      ((GObject *) audiobin[i].gst)->ref_count);
                                        gst_object_unref(GST_OBJECT(parent));
                                }
                        }
                }
 
                /* release audiobin with it's childs */
-               if (audiobin[WFD_SINK_A_BIN].gst )
-               {
-                       gst_object_unref (GST_OBJECT(audiobin[WFD_SINK_A_BIN].gst));
-               }
-       }
-       else
-       {
-               wfd_sink_debug("audiobin has parent (%s), unref it \n",
-                       GST_STR_NULL(GST_OBJECT_NAME(GST_OBJECT(parent))));
+               if (audiobin[WFD_SINK_A_BIN].gst)
+                       gst_object_unref(GST_OBJECT(audiobin[WFD_SINK_A_BIN].gst));
+
+       } else {
+               wfd_sink_debug("audiobin has parent(%s), unref it \n",
+                              GST_STR_NULL(GST_OBJECT_NAME(GST_OBJECT(parent))));
 
-               gst_object_unref (GST_OBJECT(parent));
+               gst_object_unref(GST_OBJECT(parent));
        }
 
        wfd_sink_debug_fleave();
@@ -2312,41 +2177,38 @@ static int  __mm_wfd_sink_destroy_audiobin(mm_wfd_sink_t* wfd_sink)
 
 static int __mm_wfd_sink_create_audiobin(mm_wfd_sink_t *wfd_sink)
 {
-       MMWFDSinkGstElementaudiobin = NULL;
+       MMWFDSinkGstElement *audiobin = NULL;
        gint audio_codec = WFD_SINK_AUDIO_CODEC_NONE;
        gboolean link_audio_dec = TRUE;
-       GListelement_bucket = NULL;
+       GList *element_bucket = NULL;
        GstPad *pad = NULL;
        GstPad *ghostpad = NULL;
        GstCaps *caps = NULL;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->mainbin,
-               MM_ERROR_WFD_NOT_INITIALIZED );
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline &&
+                                   wfd_sink->pipeline->mainbin,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* alloc handles */
-       audiobin = (MMWFDSinkGstElement*)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_A_NUM);
-       if (!audiobin)
-       {
-               wfd_sink_error ("failed to allocate memory for audiobin\n");
+       audiobin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_A_NUM);
+       if (!audiobin) {
+               wfd_sink_error("failed to allocate memory for audiobin\n");
                return MM_ERROR_WFD_NO_FREE_SPACE;
        }
 
        /* create audiobin */
        audiobin[WFD_SINK_A_BIN].id = WFD_SINK_A_BIN;
        audiobin[WFD_SINK_A_BIN].gst = gst_bin_new("audiobin");
-       if ( !audiobin[WFD_SINK_A_BIN].gst )
-       {
-               wfd_sink_error ("failed to create audiobin\n");
+       if (!audiobin[WFD_SINK_A_BIN].gst) {
+               wfd_sink_error("failed to create audiobin\n");
                goto CREATE_ERROR;
        }
 
        /* check audio decoder could be linked or not */
-       switch (wfd_sink->stream_info.audio_stream_info.codec)
-       {
+       switch (wfd_sink->stream_info.audio_stream_info.codec) {
                case WFD_SINK_AUDIO_CODEC_AAC:
                        audio_codec = WFD_AUDIO_AAC;
                        break;
@@ -2358,7 +2220,7 @@ static int __mm_wfd_sink_create_audiobin(mm_wfd_sink_t *wfd_sink)
                        break;
                case WFD_SINK_AUDIO_CODEC_NONE:
                default:
-                       wfd_sink_debug ("audio decoder could NOT be linked now, just prepare.\n");
+                       wfd_sink_debug("audio decoder could NOT be linked now, just prepare.\n");
                        audio_codec = wfd_sink->ini.audio_codec;
                        link_audio_dec = FALSE;
                        break;
@@ -2369,191 +2231,167 @@ static int __mm_wfd_sink_create_audiobin(mm_wfd_sink_t *wfd_sink)
 
        /* queue - drm - parse - dec/capsfilter -  audioconvert- volume - sink */
        /* create queue */
-       MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_QUEUE, "queue", "audio_queue", link_audio_dec);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_QUEUE].gst,  "sink" );
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_QUEUE].gst,  "src" );
-       if (audiobin[WFD_SINK_A_QUEUE].gst)
-       {
-               g_object_set(G_OBJECT (audiobin[WFD_SINK_A_QUEUE].gst), "max-size-bytes", 0, NULL);
-               g_object_set(G_OBJECT (audiobin[WFD_SINK_A_QUEUE].gst), "max-size-buffers", 0, NULL);
-               g_object_set(G_OBJECT (audiobin[WFD_SINK_A_QUEUE].gst), "max-size-time", (guint64)3000000000ULL, NULL);
-               g_signal_connect (audiobin[WFD_SINK_A_QUEUE].gst, "overrun",
-                       G_CALLBACK(__mm_wfd_sink_queue_overrun), wfd_sink);
-       }
-       if (!link_audio_dec)
-       {
-               if (!gst_bin_add (GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), audiobin[WFD_SINK_A_QUEUE].gst))
-               {
+       MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_QUEUE, "queue", "audio_queue", link_audio_dec);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_QUEUE].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_QUEUE].gst,  "src");
+       if (audiobin[WFD_SINK_A_QUEUE].gst) {
+               g_object_set(G_OBJECT(audiobin[WFD_SINK_A_QUEUE].gst), "max-size-bytes", 0, NULL);
+               g_object_set(G_OBJECT(audiobin[WFD_SINK_A_QUEUE].gst), "max-size-buffers", 0, NULL);
+               g_object_set(G_OBJECT(audiobin[WFD_SINK_A_QUEUE].gst), "max-size-time", (guint64)3000000000ULL, NULL);
+               g_signal_connect(audiobin[WFD_SINK_A_QUEUE].gst, "overrun",
+                                G_CALLBACK(__mm_wfd_sink_queue_overrun), wfd_sink);
+       }
+       if (!link_audio_dec) {
+               if (!gst_bin_add(GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), audiobin[WFD_SINK_A_QUEUE].gst)) {
                        wfd_sink_error("failed to add %s to audiobin\n",
-                               GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_QUEUE].gst)));
+                                      GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_QUEUE].gst)));
                        goto CREATE_ERROR;
                }
 
-               if (audiobin[WFD_SINK_A_HDCP].gst)
-               {
-                       if (!gst_bin_add (GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), audiobin[WFD_SINK_A_HDCP].gst))
-                       {
+               if (audiobin[WFD_SINK_A_HDCP].gst) {
+                       if (!gst_bin_add(GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), audiobin[WFD_SINK_A_HDCP].gst)) {
                                wfd_sink_error("failed to add %s to audiobin\n",
-                                       GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_HDCP].gst)));
+                                              GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_HDCP].gst)));
                                goto CREATE_ERROR;
                        }
 
-                       if (!gst_element_link (audiobin[WFD_SINK_A_QUEUE].gst, audiobin[WFD_SINK_A_HDCP].gst) )
-                       {
+                       if (!gst_element_link(audiobin[WFD_SINK_A_QUEUE].gst, audiobin[WFD_SINK_A_HDCP].gst)) {
                                wfd_sink_error("failed to link [%s] to [%s] success\n",
-                                       GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_QUEUE].gst)),
-                                       GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_HDCP].gst)));
+                                              GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_QUEUE].gst)),
+                                              GST_STR_NULL(GST_ELEMENT_NAME(audiobin[WFD_SINK_A_HDCP].gst)));
                                goto CREATE_ERROR;
                        }
 
                        wfd_sink->prev_audio_dec_src_pad = gst_element_get_static_pad(audiobin[WFD_SINK_A_HDCP].gst, "src");
-               }
-               else
-               {
+               } else {
                        wfd_sink->prev_audio_dec_src_pad = gst_element_get_static_pad(audiobin[WFD_SINK_A_QUEUE].gst, "src");
                }
 
-               if (!wfd_sink->prev_audio_dec_src_pad)
-               {
-                       wfd_sink_error ("failed to get src pad from previous element of audio decoder\n");
+               if (!wfd_sink->prev_audio_dec_src_pad) {
+                       wfd_sink_error("failed to get src pad from previous element of audio decoder\n");
                        goto CREATE_ERROR;
                }
 
-               wfd_sink_debug ("take src pad from previous element of audio decoder for linking\n");
+               wfd_sink_debug("take src pad from previous element of audio decoder for linking\n");
        }
 
-       if (audio_codec & WFD_AUDIO_LPCM)
-       {
+       if (audio_codec & WFD_AUDIO_LPCM) {
                /* create LPCM converter */
-               MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_LPCM_CONVERTER, wfd_sink->ini.name_of_lpcm_converter, "audio_lpcm_convert", link_audio_dec);
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_CONVERTER].gst,  "sink" );
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_CONVERTER].gst,  "src" );
+               MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_LPCM_CONVERTER, wfd_sink->ini.name_of_lpcm_converter, "audio_lpcm_convert", link_audio_dec);
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_CONVERTER].gst,  "sink");
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_CONVERTER].gst,  "src");
 
                /* create LPCM filter */
-               MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_LPCM_FILTER, wfd_sink->ini.name_of_lpcm_filter, "audio_lpcm_filter", link_audio_dec);
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_FILTER].gst,  "sink" );
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_FILTER].gst,  "src" );
-               if (audiobin[WFD_SINK_A_LPCM_FILTER].gst)
-               {
+               MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_LPCM_FILTER, wfd_sink->ini.name_of_lpcm_filter, "audio_lpcm_filter", link_audio_dec);
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_FILTER].gst,  "sink");
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_LPCM_FILTER].gst,  "src");
+               if (audiobin[WFD_SINK_A_LPCM_FILTER].gst) {
                        caps = gst_caps_new_simple("audio/x-raw",
-                                       "rate", G_TYPE_INT, 48000,
-                                       "channels", G_TYPE_INT, 2,
-                                       "format", G_TYPE_STRING, "S16LE", NULL);
+                                                  "rate", G_TYPE_INT, 48000,
+                                                  "channels", G_TYPE_INT, 2,
+                                                  "format", G_TYPE_STRING, "S16LE", NULL);
 
-                       g_object_set (G_OBJECT(audiobin[WFD_SINK_A_LPCM_FILTER].gst), "caps", caps, NULL);
-                       gst_object_unref (GST_OBJECT(caps));
+                       g_object_set(G_OBJECT(audiobin[WFD_SINK_A_LPCM_FILTER].gst), "caps", caps, NULL);
+                       gst_object_unref(GST_OBJECT(caps));
                }
        }
 
-       if (audio_codec & WFD_AUDIO_AAC )
-       {
+       if (audio_codec & WFD_AUDIO_AAC) {
                /* create AAC parse  */
-               MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_AAC_PARSE, wfd_sink->ini.name_of_aac_parser, "audio_aac_parser", link_audio_dec);
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_PARSE].gst,  "sink" );
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_PARSE].gst,  "src" );
+               MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_AAC_PARSE, wfd_sink->ini.name_of_aac_parser, "audio_aac_parser", link_audio_dec);
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_PARSE].gst,  "sink");
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_PARSE].gst,  "src");
 
                /* create AAC decoder  */
-               MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_AAC_DEC, wfd_sink->ini.name_of_aac_decoder, "audio_aac_dec", link_audio_dec);
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_DEC].gst,  "sink" );
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_DEC].gst,  "src" );
+               MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_AAC_DEC, wfd_sink->ini.name_of_aac_decoder, "audio_aac_dec", link_audio_dec);
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_DEC].gst,  "sink");
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AAC_DEC].gst,  "src");
        }
 
-       if (audio_codec & WFD_AUDIO_AC3)
-       {
+       if (audio_codec & WFD_AUDIO_AC3) {
                /* create AC3 parser  */
-               MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_AC3_PARSE, wfd_sink->ini.name_of_ac3_parser, "audio_ac3_parser", link_audio_dec);
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_PARSE].gst,  "sink" );
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_PARSE].gst,  "src" );
+               MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_AC3_PARSE, wfd_sink->ini.name_of_ac3_parser, "audio_ac3_parser", link_audio_dec);
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_PARSE].gst,  "sink");
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_PARSE].gst,  "src");
 
                /* create AC3 decoder  */
-               MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_AC3_DEC, wfd_sink->ini.name_of_ac3_decoder, "audio_ac3_dec", link_audio_dec);
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_DEC].gst,  "sink" );
-               MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_DEC].gst,  "src" );
+               MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_AC3_DEC, wfd_sink->ini.name_of_ac3_decoder, "audio_ac3_dec", link_audio_dec);
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_DEC].gst,  "sink");
+               MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_AC3_DEC].gst,  "src");
        }
 
        /* create resampler */
-       MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_RESAMPLER, wfd_sink->ini.name_of_audio_resampler, "audio_resampler", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_RESAMPLER].gst,  "sink" );
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_RESAMPLER].gst,  "src" );
+       MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_RESAMPLER, wfd_sink->ini.name_of_audio_resampler, "audio_resampler", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_RESAMPLER].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_RESAMPLER].gst,  "src");
 
        /* create volume */
-       MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_VOLUME, wfd_sink->ini.name_of_audio_volume, "audio_volume", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_VOLUME].gst,  "sink" );
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_VOLUME].gst,  "src" );
-
-       //TODO gstreamer-1.0 alsasink does not want process not S16LE format.
-       MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_CAPSFILTER, "capsfilter", "audio_capsfilter", TRUE);
-       if (audiobin[WFD_SINK_A_CAPSFILTER].gst)
-       {
+       MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_VOLUME, wfd_sink->ini.name_of_audio_volume, "audio_volume", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_VOLUME].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_VOLUME].gst,  "src");
+
+       /*TODO gstreamer-1.0 alsasink does not want process not S16LE format. */
+       MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_CAPSFILTER, "capsfilter", "audio_capsfilter", TRUE);
+       if (audiobin[WFD_SINK_A_CAPSFILTER].gst) {
                caps = gst_caps_from_string("audio/x-raw, format=(string)S16LE");
-               g_object_set (G_OBJECT(audiobin[WFD_SINK_A_CAPSFILTER].gst), "caps", caps, NULL);
-               gst_caps_unref (caps);
+               g_object_set(G_OBJECT(audiobin[WFD_SINK_A_CAPSFILTER].gst), "caps", caps, NULL);
+               gst_caps_unref(caps);
        }
 
        /* create sink */
-       MMWFDSINK_CREATE_ELEMENT (audiobin, WFD_SINK_A_SINK, wfd_sink->ini.name_of_audio_sink, "audio_sink", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, audiobin[WFD_SINK_A_SINK].gst,  "sink" );
-       if (audiobin[WFD_SINK_A_SINK].gst)
-       {
-               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_audiosink(wfd_sink, audiobin[WFD_SINK_A_SINK].gst))
-               {
-                       wfd_sink_error ("failed to set audio sink property....\n");
+       MMWFDSINK_CREATE_ELEMENT(audiobin, WFD_SINK_A_SINK, wfd_sink->ini.name_of_audio_sink, "audio_sink", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, audiobin[WFD_SINK_A_SINK].gst,  "sink");
+       if (audiobin[WFD_SINK_A_SINK].gst) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_audiosink(wfd_sink, audiobin[WFD_SINK_A_SINK].gst)) {
+                       wfd_sink_error("failed to set audio sink property....\n");
                        goto CREATE_ERROR;
                }
        }
 
-       if (!link_audio_dec)
-       {
-               MMWFDSinkGstElement* first_element = NULL;
+       if (!link_audio_dec) {
+               MMWFDSinkGstElement *first_element = NULL;
 
                first_element = (MMWFDSinkGstElement *)g_list_nth_data(element_bucket, 0);
-               if (!first_element)
-               {
+               if (!first_element) {
                        wfd_sink_error("failed to get first element\n");
                        goto CREATE_ERROR;
                }
 
                wfd_sink->next_audio_dec_sink_pad = gst_element_get_static_pad(GST_ELEMENT(first_element->gst), "sink");
-               if (!wfd_sink->next_audio_dec_sink_pad)
-               {
+               if (!wfd_sink->next_audio_dec_sink_pad) {
                        wfd_sink_error("failed to get sink pad from next element of audio decoder\n");
                        goto CREATE_ERROR;
                }
 
-               wfd_sink_debug ("take sink pad from next element of audio decoder for linking\n");
+               wfd_sink_debug("take sink pad from next element of audio decoder for linking\n");
        }
 
        /* adding created elements to audiobin */
-       if( !__mm_wfd_sink_gst_element_add_bucket_to_bin (GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), element_bucket, FALSE))
-       {
-               wfd_sink_error ("failed to add elements\n");
+       if (!__mm_wfd_sink_gst_element_add_bucket_to_bin(GST_BIN_CAST(audiobin[WFD_SINK_A_BIN].gst), element_bucket, FALSE)) {
+               wfd_sink_error("failed to add elements\n");
                goto CREATE_ERROR;
        }
 
        /* linking elements in the bucket by added order. */
-       if ( __mm_wfd_sink_gst_element_link_bucket (element_bucket) == -1 )
-       {
+       if (__mm_wfd_sink_gst_element_link_bucket(element_bucket) == -1) {
                wfd_sink_error("failed to link elements\n");
                goto CREATE_ERROR;
        }
 
        /* get queue's sinkpad for creating ghostpad */
        pad = gst_element_get_static_pad(audiobin[WFD_SINK_A_QUEUE].gst, "sink");
-       if (!pad)
-       {
+       if (!pad) {
                wfd_sink_error("failed to get pad from queue of audiobin\n");
                goto CREATE_ERROR;
        }
 
-       ghostpad = gst_ghost_pad_new ("sink", pad);
-       if (!ghostpad)
-       {
+       ghostpad = gst_ghost_pad_new("sink", pad);
+       if (!ghostpad) {
                wfd_sink_error("failed to create ghostpad\n");
                goto CREATE_ERROR;
        }
 
-       if (FALSE == gst_element_add_pad (audiobin[WFD_SINK_A_BIN].gst, ghostpad) )
-       {
+       if (FALSE == gst_element_add_pad(audiobin[WFD_SINK_A_BIN].gst, ghostpad)) {
                wfd_sink_error("failed to add ghostpad to audiobin\n");
                goto CREATE_ERROR;
        }
@@ -2573,29 +2411,29 @@ CREATE_ERROR:
        wfd_sink_error("failed to create audiobin, releasing all\n");
 
        if (wfd_sink->next_audio_dec_sink_pad)
-               gst_object_unref (GST_OBJECT(wfd_sink->next_audio_dec_sink_pad));
+               gst_object_unref(GST_OBJECT(wfd_sink->next_audio_dec_sink_pad));
        wfd_sink->next_audio_dec_sink_pad = NULL;
 
        if (wfd_sink->prev_audio_dec_src_pad)
-               gst_object_unref (GST_OBJECT(wfd_sink->prev_audio_dec_src_pad));
+               gst_object_unref(GST_OBJECT(wfd_sink->prev_audio_dec_src_pad));
        wfd_sink->prev_audio_dec_src_pad = NULL;
 
        if (pad)
-               gst_object_unref (GST_OBJECT(pad));
+               gst_object_unref(GST_OBJECT(pad));
        pad = NULL;
 
        if (ghostpad)
-               gst_object_unref (GST_OBJECT(ghostpad));
+               gst_object_unref(GST_OBJECT(ghostpad));
        ghostpad = NULL;
 
        if (element_bucket)
-               g_list_free (element_bucket);
+               g_list_free(element_bucket);
        element_bucket = NULL;
 
        /* release element which are not added to bin */
        __mm_wfd_sink_destroy_audiobin(wfd_sink);
 
-       MMWFDSINK_FREEIF (audiobin);
+       MMWFDSINK_FREEIF(audiobin);
 
        return MM_ERROR_WFD_INTERNAL;
 }
@@ -2605,10 +2443,10 @@ static int __mm_wfd_sink_prepare_videodec(mm_wfd_sink_t *wfd_sink, GstElement *v
        wfd_sink_debug_fenter();
 
        /* check video decoder is created */
-       wfd_sink_return_val_if_fail ( video_dec, MM_ERROR_WFD_INVALID_ARGUMENT );
-       wfd_sink_return_val_if_fail ( wfd_sink && wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED );
+       wfd_sink_return_val_if_fail(video_dec, MM_ERROR_WFD_INVALID_ARGUMENT);
+       wfd_sink_return_val_if_fail(wfd_sink && wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
 
-       g_object_set (G_OBJECT(video_dec), "error-concealment", TRUE, NULL );
+       g_object_set(G_OBJECT(video_dec), "error-concealment", TRUE, NULL);
 
        wfd_sink_debug_fleave();
 
@@ -2624,153 +2462,129 @@ static int __mm_wfd_sink_prepare_videosink(mm_wfd_sink_t *wfd_sink, GstElement *
        wfd_sink_debug_fenter();
 
        /* check videosink is created */
-       wfd_sink_return_val_if_fail ( video_sink, MM_ERROR_WFD_INVALID_ARGUMENT );
-       wfd_sink_return_val_if_fail ( wfd_sink && wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED );
+       wfd_sink_return_val_if_fail(video_sink, MM_ERROR_WFD_INVALID_ARGUMENT);
+       wfd_sink_return_val_if_fail(wfd_sink && wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* update display surface */
-//     mm_attrs_get_int_by_name(wfd_sink->attrs, "display_surface_type", &surface_type);
+       /*      mm_attrs_get_int_by_name(wfd_sink->attrs, "display_surface_type", &surface_type); */
        wfd_sink_debug("check display surface type attribute: %d", surface_type);
        mm_attrs_get_int_by_name(wfd_sink->attrs, "display_visible", &visible);
        wfd_sink_debug("check display visible attribute: %d", visible);
 
        /* configuring display */
-       switch ( surface_type )
-       {
-               case MM_DISPLAY_SURFACE_EVAS:
-               {
-                       void *object = NULL;
-                       gint scaling = 0;
-
-                       /* common case if using evas surface */
-                       mm_attrs_get_data_by_name(wfd_sink->attrs, "display_overlay", &object);
-                       mm_attrs_get_int_by_name(wfd_sink->attrs, "display_evas_do_scaling", &scaling);
-                       if (object)
-                       {
-                               wfd_sink_debug("set video param : evas-object %x", object);
-                               g_object_set(G_OBJECT(video_sink), "evas-object", object, NULL);
-                       }
-                       else
-                       {
-                               wfd_sink_error("no evas object");
-                               return MM_ERROR_WFD_INTERNAL;
-                       }
-               }
-               break;
-
-               case MM_DISPLAY_SURFACE_X:
-               {
-                       int *object = NULL;
-
-                       /* x surface */
-                       mm_attrs_get_data_by_name(wfd_sink->attrs, "display_overlay", (void**)&object);
-                       if (object)
-                       {
-                               xid = *object;
-                               wfd_sink_debug("xid = %lu", xid);
-                               gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink), xid);
+       switch (surface_type) {
+               case MM_DISPLAY_SURFACE_EVAS: {
+                               void *object = NULL;
+                               gint scaling = 0;
+
+                               /* common case if using evas surface */
+                               mm_attrs_get_data_by_name(wfd_sink->attrs, "display_overlay", &object);
+                               mm_attrs_get_int_by_name(wfd_sink->attrs, "display_evas_do_scaling", &scaling);
+                               if (object) {
+                                       wfd_sink_debug("set video param : evas-object %x", object);
+                                       g_object_set(G_OBJECT(video_sink), "evas-object", object, NULL);
+                               } else {
+                                       wfd_sink_error("no evas object");
+                                       return MM_ERROR_WFD_INTERNAL;
+                               }
                        }
-                       else
-                       {
-                               wfd_sink_warning("Handle is NULL. Set xid as 0.. but, it's not recommended.");
-                               gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink), 0);
+                       break;
+
+               case MM_DISPLAY_SURFACE_X: {
+                               int *object = NULL;
+
+                               /* x surface */
+                               mm_attrs_get_data_by_name(wfd_sink->attrs, "display_overlay", (void **)&object);
+                               if (object) {
+                                       xid = *object;
+                                       wfd_sink_debug("xid = %lu", xid);
+                                       gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink), xid);
+                               } else {
+                                       wfd_sink_warning("Handle is NULL. Set xid as 0.. but, it's not recommended.");
+                                       gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink), 0);
+                               }
                        }
-               }
-               break;
+                       break;
 
-               case MM_DISPLAY_SURFACE_NULL:
-               {
-                       /* do nothing */
-                       wfd_sink_error("Not Supported Surface.");
-                       return MM_ERROR_WFD_INTERNAL;
-               }
-               break;
+               case MM_DISPLAY_SURFACE_NULL: {
+                               /* do nothing */
+                               wfd_sink_error("Not Supported Surface.");
+                               return MM_ERROR_WFD_INTERNAL;
+                       }
+                       break;
        }
 
-       g_object_set (G_OBJECT(video_sink), "qos", FALSE, NULL );
-       g_object_set (G_OBJECT(video_sink), "async", wfd_sink->ini.video_sink_async, NULL);
-       g_object_set (G_OBJECT(video_sink), "max-lateness", (gint64)wfd_sink->ini.video_sink_max_lateness, NULL );
-       g_object_set (G_OBJECT(video_sink), "visible", visible, NULL);
-       g_object_set (G_OBJECT(video_sink), "ts-offset", (gint64)(wfd_sink->ini.sink_ts_offset), NULL );
+       g_object_set(G_OBJECT(video_sink), "qos", FALSE, NULL);
+       g_object_set(G_OBJECT(video_sink), "async", wfd_sink->ini.video_sink_async, NULL);
+       g_object_set(G_OBJECT(video_sink), "max-lateness", (gint64)wfd_sink->ini.video_sink_max_lateness, NULL);
+       g_object_set(G_OBJECT(video_sink), "visible", visible, NULL);
+       g_object_set(G_OBJECT(video_sink), "ts-offset", (gint64)(wfd_sink->ini.sink_ts_offset), NULL);
 
        wfd_sink_debug_fleave();
 
        return MM_ERROR_NONE;
 }
 
-static int __mm_wfd_sink_destroy_videobin(mm_wfd_sink_twfd_sink)
+static int __mm_wfd_sink_destroy_videobin(mm_wfd_sink_t *wfd_sink)
 {
        GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
-       MMWFDSinkGstElementvideobin = NULL;
-       GstObjectparent = NULL;
+       MMWFDSinkGstElement *videobin = NULL;
+       GstObject *parent = NULL;
        int i;
 
-       wfd_sink_debug_fenter ();
+       wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED );
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        if (wfd_sink->pipeline &&
-               wfd_sink->pipeline->videobin &&
-               wfd_sink->pipeline->videobin[WFD_SINK_V_BIN].gst)
-       {
+           wfd_sink->pipeline->videobin &&
+           wfd_sink->pipeline->videobin[WFD_SINK_V_BIN].gst) {
                videobin = wfd_sink->pipeline->videobin;
-       }
-       else
-       {
+       } else {
                wfd_sink_debug("videobin is not created, nothing to destroy\n");
                return MM_ERROR_NONE;
        }
 
 
-       parent = gst_element_get_parent (videobin[WFD_SINK_V_BIN].gst);
-       if (!parent)
-       {
+       parent = gst_element_get_parent(videobin[WFD_SINK_V_BIN].gst);
+       if (!parent) {
                wfd_sink_debug("videobin has no parent.. need to relase by itself\n");
 
-               if (GST_STATE(videobin[WFD_SINK_V_BIN].gst) >= GST_STATE_READY)
-               {
+               if (GST_STATE(videobin[WFD_SINK_V_BIN].gst) >= GST_STATE_READY) {
                        wfd_sink_debug("try to change state of videobin to NULL\n");
-                       ret = gst_element_set_state (videobin[WFD_SINK_V_BIN].gst, GST_STATE_NULL);
-                       if ( ret != GST_STATE_CHANGE_SUCCESS )
-                       {
+                       ret = gst_element_set_state(videobin[WFD_SINK_V_BIN].gst, GST_STATE_NULL);
+                       if (ret != GST_STATE_CHANGE_SUCCESS) {
                                wfd_sink_error("failed to change state of videobin to NULL\n");
                                return MM_ERROR_WFD_INTERNAL;
                        }
                }
                /* release element which are not added to bin */
-               for (i = 1; i < WFD_SINK_V_NUM; i++)    /* NOTE : skip bin */
-               {
-                       if (videobin[i].gst)
-                       {
-                               parent = gst_element_get_parent (videobin[i].gst);
-                               if (!parent)
-                               {
+               for (i = 1; i < WFD_SINK_V_NUM; i++) {  /* NOTE : skip bin */
+                       if (videobin[i].gst) {
+                               parent = gst_element_get_parent(videobin[i].gst);
+                               if (!parent) {
                                        wfd_sink_debug("unref %s(current ref %d)\n",
-                                               GST_STR_NULL(GST_ELEMENT_NAME(videobin[i].gst)),
-                                               ((GObject *) videobin[i].gst)->ref_count);
+                                                      GST_STR_NULL(GST_ELEMENT_NAME(videobin[i].gst)),
+                                                      ((GObject *) videobin[i].gst)->ref_count);
                                        gst_object_unref(GST_OBJECT(videobin[i].gst));
                                        videobin[i].gst = NULL;
-                               }
-                               else
-                               {
+                               } else {
                                        wfd_sink_debug("unref %s(current ref %d)\n",
-                                               GST_STR_NULL(GST_ELEMENT_NAME(videobin[i].gst)),
-                                               ((GObject *) videobin[i].gst)->ref_count);
+                                                      GST_STR_NULL(GST_ELEMENT_NAME(videobin[i].gst)),
+                                                      ((GObject *) videobin[i].gst)->ref_count);
                                        gst_object_unref(GST_OBJECT(parent));
                                }
                        }
                }
                /* release audiobin with it's childs */
-               if (videobin[WFD_SINK_V_BIN].gst )
-               {
-                       gst_object_unref (GST_OBJECT(videobin[WFD_SINK_V_BIN].gst));
+               if (videobin[WFD_SINK_V_BIN].gst) {
+                       gst_object_unref(GST_OBJECT(videobin[WFD_SINK_V_BIN].gst));
                }
-       }
-       else
-       {
-               wfd_sink_debug("videobin has parent (%s), unref it \n",
-                       GST_STR_NULL(GST_OBJECT_NAME(GST_OBJECT(parent))));
+       } else {
+               wfd_sink_debug("videobin has parent(%s), unref it \n",
+                              GST_STR_NULL(GST_OBJECT_NAME(GST_OBJECT(parent))));
 
-               gst_object_unref (GST_OBJECT(parent));
+               gst_object_unref(GST_OBJECT(parent));
        }
 
        wfd_sink_debug_fleave();
@@ -2781,120 +2595,107 @@ static int __mm_wfd_sink_destroy_videobin(mm_wfd_sink_t* wfd_sink)
 
 static int __mm_wfd_sink_create_videobin(mm_wfd_sink_t *wfd_sink)
 {
-       MMWFDSinkGstElementfirst_element = NULL;
-       MMWFDSinkGstElementvideobin = NULL;
-       GListelement_bucket = NULL;
+       MMWFDSinkGstElement *first_element = NULL;
+       MMWFDSinkGstElement *videobin = NULL;
+       GList *element_bucket = NULL;
        GstPad *pad = NULL;
        GstPad *ghostpad = NULL;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->mainbin,
-               MM_ERROR_WFD_NOT_INITIALIZED );
+       wfd_sink_return_val_if_fail(wfd_sink &&
+                                   wfd_sink->pipeline &&
+                                   wfd_sink->pipeline->mainbin,
+                                   MM_ERROR_WFD_NOT_INITIALIZED);
 
        /* alloc handles */
-       videobin = (MMWFDSinkGstElement*)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_V_NUM);
-       if (!videobin )
-       {
-               wfd_sink_error ("failed to allocate memory for videobin\n");
+       videobin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_V_NUM);
+       if (!videobin) {
+               wfd_sink_error("failed to allocate memory for videobin\n");
                return MM_ERROR_WFD_NO_FREE_SPACE;
        }
 
        /* create videobin */
        videobin[WFD_SINK_V_BIN].id = WFD_SINK_V_BIN;
        videobin[WFD_SINK_V_BIN].gst = gst_bin_new("videobin");
-       if ( !videobin[WFD_SINK_V_BIN].gst )
-       {
-               wfd_sink_error ("failed to create videobin\n");
+       if (!videobin[WFD_SINK_V_BIN].gst) {
+               wfd_sink_error("failed to create videobin\n");
                goto CREATE_ERROR;
        }
 
        /* queue - drm - parse - dec - sink */
        /* create queue */
-       MMWFDSINK_CREATE_ELEMENT (videobin, WFD_SINK_V_QUEUE, "queue", "video_queue", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, videobin[WFD_SINK_V_QUEUE].gst,  "sink" );
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, videobin[WFD_SINK_V_QUEUE].gst,  "src" );
-       if (videobin[WFD_SINK_V_QUEUE].gst)
-       {
-               g_object_set(G_OBJECT (videobin[WFD_SINK_V_QUEUE].gst), "max-size-bytes", 0, NULL);
-               g_object_set(G_OBJECT (videobin[WFD_SINK_V_QUEUE].gst), "max-size-buffers", 0, NULL);
-               g_object_set(G_OBJECT (videobin[WFD_SINK_V_QUEUE].gst), "max-size-time", (guint64)3000000000ULL, NULL);
-               g_signal_connect (videobin[WFD_SINK_V_QUEUE].gst, "overrun",
-                       G_CALLBACK(__mm_wfd_sink_queue_overrun), wfd_sink);
+       MMWFDSINK_CREATE_ELEMENT(videobin, WFD_SINK_V_QUEUE, "queue", "video_queue", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, videobin[WFD_SINK_V_QUEUE].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, videobin[WFD_SINK_V_QUEUE].gst,  "src");
+       if (videobin[WFD_SINK_V_QUEUE].gst) {
+               g_object_set(G_OBJECT(videobin[WFD_SINK_V_QUEUE].gst), "max-size-bytes", 0, NULL);
+               g_object_set(G_OBJECT(videobin[WFD_SINK_V_QUEUE].gst), "max-size-buffers", 0, NULL);
+               g_object_set(G_OBJECT(videobin[WFD_SINK_V_QUEUE].gst), "max-size-time", (guint64)3000000000ULL, NULL);
+               g_signal_connect(videobin[WFD_SINK_V_QUEUE].gst, "overrun",
+                                G_CALLBACK(__mm_wfd_sink_queue_overrun), wfd_sink);
        }
 
        /* create parser */
-       MMWFDSINK_CREATE_ELEMENT (videobin, WFD_SINK_V_PARSE, wfd_sink->ini.name_of_video_parser, "video_parser", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, videobin[WFD_SINK_V_PARSE].gst,  "sink" );
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, videobin[WFD_SINK_V_PARSE].gst,  "src" );
+       MMWFDSINK_CREATE_ELEMENT(videobin, WFD_SINK_V_PARSE, wfd_sink->ini.name_of_video_parser, "video_parser", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, videobin[WFD_SINK_V_PARSE].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, videobin[WFD_SINK_V_PARSE].gst,  "src");
        if (videobin[WFD_SINK_V_PARSE].gst)
-               g_object_set (G_OBJECT(videobin[WFD_SINK_V_PARSE].gst), "wfd-mode", TRUE, NULL );
+               g_object_set(G_OBJECT(videobin[WFD_SINK_V_PARSE].gst), "wfd-mode", TRUE, NULL);
 
        /* create dec */
-       MMWFDSINK_CREATE_ELEMENT (videobin, WFD_SINK_V_DEC, wfd_sink->ini.name_of_video_decoder, "video_dec", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, videobin[WFD_SINK_V_DEC].gst,  "sink" );
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, videobin[WFD_SINK_V_DEC].gst,  "src" );
-       if (videobin[WFD_SINK_V_DEC].gst)
-       {
-               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_videodec(wfd_sink, videobin[WFD_SINK_V_DEC].gst))
-               {
-                       wfd_sink_error ("failed to set video sink property....\n");
+       MMWFDSINK_CREATE_ELEMENT(videobin, WFD_SINK_V_DEC, wfd_sink->ini.name_of_video_decoder, "video_dec", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, videobin[WFD_SINK_V_DEC].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, videobin[WFD_SINK_V_DEC].gst,  "src");
+       if (videobin[WFD_SINK_V_DEC].gst) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_videodec(wfd_sink, videobin[WFD_SINK_V_DEC].gst)) {
+                       wfd_sink_error("failed to set video sink property....\n");
                        goto CREATE_ERROR;
                }
        }
 
        /* create sink */
-       MMWFDSINK_CREATE_ELEMENT (videobin, WFD_SINK_V_SINK, wfd_sink->ini.name_of_video_sink, "video_sink", TRUE);
-       MMWFDSINK_PAD_PROBE( wfd_sink, NULL, videobin[WFD_SINK_V_SINK].gst,  "sink" );
-       if (videobin[WFD_SINK_V_SINK].gst)
-       {
-               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_videosink(wfd_sink, videobin[WFD_SINK_V_SINK].gst))
-               {
-                       wfd_sink_error ("failed to set video sink property....\n");
+       MMWFDSINK_CREATE_ELEMENT(videobin, WFD_SINK_V_SINK, wfd_sink->ini.name_of_video_sink, "video_sink", TRUE);
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, videobin[WFD_SINK_V_SINK].gst,  "sink");
+       if (videobin[WFD_SINK_V_SINK].gst) {
+               if (MM_ERROR_NONE != __mm_wfd_sink_prepare_videosink(wfd_sink, videobin[WFD_SINK_V_SINK].gst)) {
+                       wfd_sink_error("failed to set video sink property....\n");
                        goto CREATE_ERROR;
                }
        }
 
        /* adding created elements to videobin */
-       if( !__mm_wfd_sink_gst_element_add_bucket_to_bin(GST_BIN_CAST(videobin[WFD_SINK_V_BIN].gst), element_bucket, FALSE))
-       {
-               wfd_sink_error ("failed to add elements\n");
+       if (!__mm_wfd_sink_gst_element_add_bucket_to_bin(GST_BIN_CAST(videobin[WFD_SINK_V_BIN].gst), element_bucket, FALSE)) {
+               wfd_sink_error("failed to add elements\n");
                goto CREATE_ERROR;
        }
 
        /* linking elements in the bucket by added order. */
-       if ( __mm_wfd_sink_gst_element_link_bucket (element_bucket) == -1 )
-       {
+       if (__mm_wfd_sink_gst_element_link_bucket(element_bucket) == -1) {
                wfd_sink_error("failed to link elements\n");
                goto CREATE_ERROR;
        }
 
        /* get first element's sinkpad for creating ghostpad */
-       first_element =  (MMWFDSinkGstElement *)g_list_nth_data(element_bucket, 0);
-       if (!first_element)
-       {
+       first_element = (MMWFDSinkGstElement *)g_list_nth_data(element_bucket, 0);
+       if (!first_element) {
                wfd_sink_error("failed to get first element of videobin\n");
                goto CREATE_ERROR;
        }
 
        pad = gst_element_get_static_pad(GST_ELEMENT(first_element->gst), "sink");
-       if (!pad)
-       {
+       if (!pad) {
                wfd_sink_error("failed to get pad from first element(%s) of videobin\n", GST_ELEMENT_NAME(first_element->gst));
                goto CREATE_ERROR;
        }
 
-       ghostpad = gst_ghost_pad_new ("sink", pad);
-       if (!ghostpad)
-       {
+       ghostpad = gst_ghost_pad_new("sink", pad);
+       if (!ghostpad) {
                wfd_sink_error("failed to create ghostpad\n");
                goto CREATE_ERROR;
        }
 
-       if (FALSE == gst_element_add_pad (videobin[WFD_SINK_V_BIN].gst, ghostpad) )
-       {
+       if (FALSE == gst_element_add_pad(videobin[WFD_SINK_V_BIN].gst, ghostpad)) {
                wfd_sink_error("failed to add ghostpad to videobin\n");
                goto CREATE_ERROR;
        }
@@ -2908,10 +2709,9 @@ static int __mm_wfd_sink_create_videobin(mm_wfd_sink_t *wfd_sink)
        /* take it */
        wfd_sink->pipeline->videobin = videobin;
 
-       if (wfd_sink->ini.video_sink_async)
-       {
+       if (wfd_sink->ini.video_sink_async) {
                GstBus *bus = NULL;
-               bus = gst_element_get_bus(videobin[WFD_SINK_V_BIN].gst );
+               bus = gst_element_get_bus(videobin[WFD_SINK_V_BIN].gst);
                if (bus)
                        gst_bus_set_sync_handler(bus, _mm_wfd_bus_sync_callback, wfd_sink, NULL);
                gst_object_unref(bus);
@@ -2921,34 +2721,34 @@ static int __mm_wfd_sink_create_videobin(mm_wfd_sink_t *wfd_sink)
 
        return MM_ERROR_NONE;
 
-/* ERRORS */
+       /* ERRORS */
 CREATE_ERROR:
        wfd_sink_error("failed to create videobin, releasing all\n");
 
        if (pad)
-               gst_object_unref (GST_OBJECT(pad));
+               gst_object_unref(GST_OBJECT(pad));
        pad = NULL;
 
        if (ghostpad)
-               gst_object_unref (GST_OBJECT(ghostpad));
+               gst_object_unref(GST_OBJECT(ghostpad));
        ghostpad = NULL;
 
-       g_list_free (element_bucket);
+       g_list_free(element_bucket);
 
        __mm_wfd_sink_destroy_videobin(wfd_sink);
 
-       MMWFDSINK_FREEIF (videobin);
+       MMWFDSINK_FREEIF(videobin);
 
        return MM_ERROR_WFD_INTERNAL;
 }
 
-static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_twfd_sink)
+static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink)
 {
        GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
 
-       wfd_sink_debug_fenter ();
+       wfd_sink_debug_fenter();
 
-       wfd_sink_return_val_if_fail (wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED );
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
 
        if (wfd_sink->prev_audio_dec_src_pad)
                gst_object_unref(GST_OBJECT(wfd_sink->prev_audio_dec_src_pad));
@@ -2959,42 +2759,37 @@ static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t* wfd_sink)
        wfd_sink->next_audio_dec_sink_pad = NULL;
 
        /* cleanup gst stuffs */
-       if ( wfd_sink->pipeline )
-       {
-               MMWFDSinkGstElement* mainbin = wfd_sink->pipeline->mainbin;
+       if (wfd_sink->pipeline) {
+               MMWFDSinkGstElement *mainbin = wfd_sink->pipeline->mainbin;
 
-               if ( mainbin )
-               {
-                       MMWFDSinkGstElement* audiobin = wfd_sink->pipeline->audiobin;
-                       MMWFDSinkGstElement* videobin = wfd_sink->pipeline->videobin;
+               if (mainbin) {
+                       MMWFDSinkGstElement *audiobin = wfd_sink->pipeline->audiobin;
+                       MMWFDSinkGstElement *videobin = wfd_sink->pipeline->videobin;
 
-                       if (MM_ERROR_NONE != __mm_wfd_sink_destroy_videobin(wfd_sink))
-                       {
+                       if (MM_ERROR_NONE != __mm_wfd_sink_destroy_videobin(wfd_sink)) {
                                wfd_sink_error("failed to destroy videobin\n");
                                return MM_ERROR_WFD_INTERNAL;
                        }
 
-                       if (MM_ERROR_NONE != __mm_wfd_sink_destroy_audiobin(wfd_sink))
-                       {
+                       if (MM_ERROR_NONE != __mm_wfd_sink_destroy_audiobin(wfd_sink)) {
                                wfd_sink_error("failed to destroy audiobin\n");
                                return MM_ERROR_WFD_INTERNAL;
                        }
 
-                       ret = gst_element_set_state (mainbin[WFD_SINK_M_PIPE].gst, GST_STATE_NULL);
-                       if ( ret != GST_STATE_CHANGE_SUCCESS )
-                       {
+                       ret = gst_element_set_state(mainbin[WFD_SINK_M_PIPE].gst, GST_STATE_NULL);
+                       if (ret != GST_STATE_CHANGE_SUCCESS) {
                                wfd_sink_error("failed to change state of mainbin to NULL\n");
                                return MM_ERROR_WFD_INTERNAL;
                        }
 
                        gst_object_unref(GST_OBJECT(mainbin[WFD_SINK_M_PIPE].gst));
 
-                       MMWFDSINK_FREEIF( audiobin );
-                       MMWFDSINK_FREEIF( videobin );
-                       MMWFDSINK_FREEIF( mainbin );
+                       MMWFDSINK_FREEIF(audiobin);
+                       MMWFDSINK_FREEIF(videobin);
+                       MMWFDSINK_FREEIF(mainbin);
                }
 
-               MMWFDSINK_FREEIF( wfd_sink->pipeline );
+               MMWFDSINK_FREEIF(wfd_sink->pipeline);
        }
 
        wfd_sink->added_av_pad_num = 0;
@@ -3010,7 +2805,7 @@ static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t* wfd_sink)
 static void
 __mm_wfd_sink_dump_pipeline_state(mm_wfd_sink_t *wfd_sink)
 {
-       GstIterator*iter = NULL;
+       GstIterator *iter = NULL;
        gboolean done = FALSE;
 
        GstElement *item = NULL;
@@ -3018,68 +2813,63 @@ __mm_wfd_sink_dump_pipeline_state(mm_wfd_sink_t *wfd_sink)
 
        GstState state = GST_STATE_VOID_PENDING;
        GstState pending = GST_STATE_VOID_PENDING;
-       GstClockTime time = 200*GST_MSECOND;
+       GstClockTime time = 200 * GST_MSECOND;
 
        wfd_sink_debug_fenter();
 
-       wfd_sink_return_if_fail ( wfd_sink &&
-               wfd_sink->pipeline &&
-               wfd_sink->pipeline->mainbin &&
-               wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst);
+       wfd_sink_return_if_fail(wfd_sink &&
+                               wfd_sink->pipeline &&
+                               wfd_sink->pipeline->mainbin &&
+                               wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst);
 
        iter = gst_bin_iterate_recurse(GST_BIN(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst));
 
-       if ( iter != NULL )
-       {
-               while (!done)
-               {
-                       switch ( gst_iterator_next (iter, (gpointer)&item) )
-                       {
+       if (iter != NULL) {
+               while (!done) {
+                       switch (gst_iterator_next(iter, (gpointer)&item)) {
                                case GST_ITERATOR_OK:
-                                       gst_element_get_state(GST_ELEMENT (item),&state, &pending, time);
-
-                                       factory = gst_element_get_factory (item) ;
-                                       if (factory)
-                                       {
-                                                wfd_sink_error("%s:%s : From:%s To:%s refcount : %d\n",
-                                                       GST_STR_NULL(GST_OBJECT_NAME(factory)),
-                                                       GST_STR_NULL(GST_ELEMENT_NAME(item)),
-                                                       gst_element_state_get_name(state),
-                                                       gst_element_state_get_name(pending),
-                                                       GST_OBJECT_REFCOUNT_VALUE(item));
+                                       gst_element_get_state(GST_ELEMENT(item), &state, &pending, time);
+
+                                       factory = gst_element_get_factory(item) ;
+                                       if (factory) {
+                                               wfd_sink_error("%s:%s : From:%s To:%s refcount : %d\n",
+                                                              GST_STR_NULL(GST_OBJECT_NAME(factory)),
+                                                              GST_STR_NULL(GST_ELEMENT_NAME(item)),
+                                                              gst_element_state_get_name(state),
+                                                              gst_element_state_get_name(pending),
+                                                              GST_OBJECT_REFCOUNT_VALUE(item));
                                        }
-                                        gst_object_unref (item);
-                                        break;
-                                case GST_ITERATOR_RESYNC:
-                                        gst_iterator_resync (iter);
-                                        break;
-                                case GST_ITERATOR_ERROR:
-                                        done = TRUE;
-                                        break;
-                                case GST_ITERATOR_DONE:
-                                        done = TRUE;
-                                        break;
-                        }
+                                       gst_object_unref(item);
+                                       break;
+                               case GST_ITERATOR_RESYNC:
+                                       gst_iterator_resync(iter);
+                                       break;
+                               case GST_ITERATOR_ERROR:
+                                       done = TRUE;
+                                       break;
+                               case GST_ITERATOR_DONE:
+                                       done = TRUE;
+                                       break;
+                       }
                }
        }
 
        item = GST_ELEMENT_CAST(wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst);
 
-       gst_element_get_state(GST_ELEMENT (item),&state, &pending, time);
+       gst_element_get_state(GST_ELEMENT(item), &state, &pending, time);
 
-       factory = gst_element_get_factory (item) ;
-       if (factory)
-       {
+       factory = gst_element_get_factory(item) ;
+       if (factory) {
                wfd_sink_error("%s:%s : From:%s To:%s refcount : %d\n",
-                       GST_OBJECT_NAME(factory),
-                       GST_ELEMENT_NAME(item),
-                       gst_element_state_get_name(state),
-                       gst_element_state_get_name(pending),
-                       GST_OBJECT_REFCOUNT_VALUE(item) );
+                              GST_OBJECT_NAME(factory),
+                              GST_ELEMENT_NAME(item),
+                              gst_element_state_get_name(state),
+                              gst_element_state_get_name(pending),
+                              GST_OBJECT_REFCOUNT_VALUE(item));
        }
 
-       if ( iter )
-               gst_iterator_free (iter);
+       if (iter)
+               gst_iterator_free(iter);
 
        wfd_sink_debug_fleave();
 
@@ -3087,10 +2877,9 @@ __mm_wfd_sink_dump_pipeline_state(mm_wfd_sink_t *wfd_sink)
 }
 
 const gchar *
-__mm_wfds_sink_get_state_name ( MMWFDSinkStateType state )
+__mm_wfds_sink_get_state_name(MMWFDSinkStateType state)
 {
-       switch ( state )
-       {
+       switch (state) {
                case MM_WFD_SINK_STATE_NONE:
                        return "NONE";
                case MM_WFD_SINK_STATE_NULL:
@@ -3109,3 +2898,55 @@ __mm_wfds_sink_get_state_name ( MMWFDSinkStateType state )
                        return "INVAID";
        }
 }
+static void __mm_wfd_sink_prepare_video_resolution(gint resolution, guint *CEA_resolution,
+                                                   guint *VESA_resolution, guint *HH_resolution)
+{
+       if (resolution == MM_WFD_SINK_RESOLUTION_UNKNOWN) return;
+
+       *CEA_resolution = 0;
+       *VESA_resolution = 0;
+       *HH_resolution = 0;
+
+       if (resolution & MM_WFD_SINK_RESOLUTION_1920x1080_P30)
+               *CEA_resolution |= WFD_CEA_1920x1080P30;
+
+       if (resolution & MM_WFD_SINK_RESOLUTION_1280x720_P30)
+               *CEA_resolution |= WFD_CEA_1280x720P30;
+
+       if (resolution & MM_WFD_SINK_RESOLUTION_960x540_P30)
+               *HH_resolution |= WFD_HH_960x540P30;
+
+       if (resolution & MM_WFD_SINK_RESOLUTION_864x480_P30)
+               *HH_resolution |= WFD_HH_864x480P30;
+
+       if (resolution & MM_WFD_SINK_RESOLUTION_720x480_P60)
+               *CEA_resolution |= WFD_CEA_720x480P60;
+
+       if (resolution & MM_WFD_SINK_RESOLUTION_640x480_P60)
+               *CEA_resolution |= WFD_CEA_640x480P60;
+
+       if (resolution & MM_WFD_SINK_RESOLUTION_640x360_P30)
+               *HH_resolution |= WFD_HH_640x360P30;
+}
+
+int _mm_wfd_sink_set_resolution(mm_wfd_sink_t *wfd_sink, MMWFDSinkResolution resolution)
+{
+       MMWFDSinkStateType cur_state = MM_WFD_SINK_STATE_NONE;
+
+       wfd_sink_debug_fenter();
+
+       wfd_sink_return_val_if_fail(wfd_sink, MM_ERROR_WFD_NOT_INITIALIZED);
+
+       MMWFDSINK_PRINT_STATE(wfd_sink);
+       cur_state = MMWFDSINK_CURRENT_STATE(wfd_sink);
+       if (cur_state != MM_WFD_SINK_STATE_NULL) {
+               wfd_sink_error("This function must be called when MM_WFD_SINK_STATE_NULL");
+               return MM_ERROR_WFD_INVALID_STATE;
+       }
+
+       wfd_sink->supportive_resolution = resolution;
+
+       wfd_sink_debug_fleave();
+
+       return MM_ERROR_NONE;
+}
index d03dda5..c6c9c83 100755 (executable)
 #define DUMP_TS_DATA_PATH "/var/tmp/"
 
 static GstPadProbeReturn
-_mm_wfd_sink_util_dump (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
+_mm_wfd_sink_util_dump(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
 {
        gint8 *data = NULL;
        gint size = 0;
        FILE *f = NULL;
-       char buf[256] = {0,};
-       char path[256] = {0,};
+       char buf[256] = {0, };
+       char path[256] = {0, };
 
-       snprintf(path , sizeof(path), "%s%s_%s.ts", DUMP_TS_DATA_PATH,
-               gst_element_get_name(gst_pad_get_parent_element(pad)), gst_pad_get_name(pad));
+       snprintf(path, sizeof(path), "%s%s_%s.ts", DUMP_TS_DATA_PATH,
+                gst_element_get_name(gst_pad_get_parent_element(pad)), gst_pad_get_name(pad));
 
        if (info && info->type & GST_PAD_PROBE_TYPE_BUFFER) {
                GstMapInfo buf_info;
-               GstBuffer *buffer = gst_pad_probe_info_get_buffer (info);
+               GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
 
                gst_buffer_map(buffer, &buf_info, GST_MAP_READ);
 
-               wfd_sink_debug ("got buffer %p with size %d", buffer, buf_info.size);
+               wfd_sink_debug("got buffer %p with size %d", buffer, buf_info.size);
                data = (gint8 *)(buf_info.data);
                size = buf_info.size;
                f = fopen(path, "a");
-               if(f == NULL)
-               {
+               if (f == NULL) {
                        strerror_r(errno, buf, sizeof(buf));
                        wfd_sink_error("failed to fopen! : %s", buf);
                        return GST_PAD_PROBE_OK;
@@ -62,57 +61,52 @@ _mm_wfd_sink_util_dump (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
 }
 
 static GstPadProbeReturn
-_mm_wfd_sink_util_pad_probe_cb(GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
+_mm_wfd_sink_util_pad_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
 {
-       GstElementparent = NULL;
+       GstElement *parent = NULL;
 
        wfd_sink_return_val_if_fail(info &&
-               info->type != GST_PAD_PROBE_TYPE_INVALID,
-               GST_PAD_PROBE_DROP);
+                                   info->type != GST_PAD_PROBE_TYPE_INVALID,
+                                   GST_PAD_PROBE_DROP);
        wfd_sink_return_val_if_fail(pad, GST_PAD_PROBE_DROP);
 
-       parent = (GstElement*)gst_object_get_parent(GST_OBJECT(pad));
-       if(!parent)
-       {
+       parent = (GstElement *)gst_object_get_parent(GST_OBJECT(pad));
+       if (!parent) {
                wfd_sink_error("failed to get parent of pad");
                return GST_PAD_PROBE_DROP;
        }
 
-       if (info->type & GST_PAD_PROBE_TYPE_BUFFER)
-       {
-               GstBuffer *buffer = gst_pad_probe_info_get_buffer (info);
+       if (info->type & GST_PAD_PROBE_TYPE_BUFFER) {
+               GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
                /* show name and timestamp */
                wfd_sink_debug("BUFFER PROBE : %s:%s :  %u:%02u:%02u.%09u  (%"G_GSSIZE_FORMAT" bytes)\n",
-                       GST_STR_NULL(GST_ELEMENT_NAME(parent)),
-                       GST_STR_NULL(GST_PAD_NAME(pad)),
-                       GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)),
-                       gst_buffer_get_size(buffer));
-       }
-       else if (info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM ||
-               info->type & GST_PAD_PROBE_TYPE_EVENT_UPSTREAM ||
-               info->type & GST_PAD_PROBE_TYPE_EVENT_FLUSH ||
-               info->type & GST_PAD_PROBE_TYPE_EVENT_BOTH)
-       {
-               GstEvent *event = gst_pad_probe_info_get_event (info);
+                              GST_STR_NULL(GST_ELEMENT_NAME(parent)),
+                              GST_STR_NULL(GST_PAD_NAME(pad)),
+                              GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)),
+                              gst_buffer_get_size(buffer));
+       } else if (info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM ||
+                  info->type & GST_PAD_PROBE_TYPE_EVENT_UPSTREAM ||
+                  info->type & GST_PAD_PROBE_TYPE_EVENT_FLUSH ||
+                  info->type & GST_PAD_PROBE_TYPE_EVENT_BOTH) {
+               GstEvent *event = gst_pad_probe_info_get_event(info);
 
                /* show name and event type */
                wfd_sink_debug("EVENT PROBE : %s:%s :  %s\n",
-                       GST_STR_NULL(GST_ELEMENT_NAME(parent)),
-                       GST_STR_NULL(GST_PAD_NAME(pad)),
-                       GST_EVENT_TYPE_NAME(event));
-
-               if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT)
-               {
-                       const GstSegment* segment = NULL;
-                       gst_event_parse_segment (event, &segment);
+                              GST_STR_NULL(GST_ELEMENT_NAME(parent)),
+                              GST_STR_NULL(GST_PAD_NAME(pad)),
+                              GST_EVENT_TYPE_NAME(event));
+
+               if (GST_EVENT_TYPE(event) == GST_EVENT_SEGMENT) {
+                       const GstSegment *segment = NULL;
+                       gst_event_parse_segment(event, &segment);
                        if (segment)
-                               wfd_sink_debug ("NEWSEGMENT : %" G_GINT64_FORMAT
-                                       " -- %"  G_GINT64_FORMAT ", time %" G_GINT64_FORMAT " \n",
-                                       segment->start, segment->stop, segment->time);
+                               wfd_sink_debug("NEWSEGMENT : %" G_GINT64_FORMAT
+                                              " -- %"  G_GINT64_FORMAT ", time %" G_GINT64_FORMAT " \n",
+                                              segment->start, segment->stop, segment->time);
                }
        }
 
-       if ( parent )
+       if (parent)
                gst_object_unref(parent);
 
        return GST_PAD_PROBE_OK;
@@ -121,24 +115,20 @@ _mm_wfd_sink_util_pad_probe_cb(GstPad * pad, GstPadProbeInfo * info, gpointer u_
 void
 mm_wfd_sink_util_add_pad_probe(GstPad *pad, GstElement *element, const gchar *pad_name)
 {
-       GstPad * probe_pad = NULL;
+       GstPad *probe_pad = NULL;
 
-       if (!pad)
-       {
-               if(element && pad_name)
+       if (!pad) {
+               if (element && pad_name)
                        probe_pad = gst_element_get_static_pad(element, pad_name);
-       }
-       else
-       {
+       } else {
                probe_pad = pad;
                gst_object_ref(probe_pad);
        }
 
-       if (probe_pad)
-       {
-               wfd_sink_debug ("add pad(%s) probe", GST_STR_NULL(GST_PAD_NAME(probe_pad)));
+       if (probe_pad) {
+               wfd_sink_debug("add pad(%s) probe", GST_STR_NULL(GST_PAD_NAME(probe_pad)));
                gst_pad_add_probe(probe_pad, GST_PAD_PROBE_TYPE_DATA_BOTH,
-                       _mm_wfd_sink_util_pad_probe_cb, (gpointer)NULL, NULL);
+                                 _mm_wfd_sink_util_pad_probe_cb, (gpointer)NULL, NULL);
                gst_object_unref(probe_pad);
        }
 }
@@ -146,51 +136,48 @@ mm_wfd_sink_util_add_pad_probe(GstPad *pad, GstElement *element, const gchar *pa
 void
 mm_wfd_sink_util_add_pad_probe_for_data_dump(GstElement *element, const gchar *pad_name)
 {
-       GstPad * probe_pad = NULL;
+       GstPad *probe_pad = NULL;
 
-       if(element && pad_name)
+       if (element && pad_name)
                probe_pad = gst_element_get_static_pad(element, pad_name);
 
-       if (probe_pad)
-       {
-               wfd_sink_debug ("add pad(%s) probe", GST_STR_NULL(GST_PAD_NAME(probe_pad)));
+       if (probe_pad) {
+               wfd_sink_debug("add pad(%s) probe", GST_STR_NULL(GST_PAD_NAME(probe_pad)));
                gst_pad_add_probe(probe_pad, GST_PAD_PROBE_TYPE_BUFFER, _mm_wfd_sink_util_dump, (gpointer)NULL, NULL);
                gst_object_unref(probe_pad);
        }
 }
 
 static GstPadProbeReturn
-_mm_wfd_sink_util_check_first_buffer_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
+_mm_wfd_sink_util_check_first_buffer_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
 {
-       GstElementparent = NULL;
+       GstElement *parent = NULL;
        GstBuffer *buffer = NULL;
-       guint *probe_id = (guint*)user_data;
+       guint *probe_id = (guint *)user_data;
 
        wfd_sink_return_val_if_fail(pad, GST_PAD_PROBE_DROP);
        wfd_sink_return_val_if_fail(info, GST_PAD_PROBE_DROP);
 
        parent = GST_ELEMENT_CAST(gst_object_get_parent(GST_OBJECT(pad)));
-       if( parent == NULL)
-       {
+       if (parent == NULL) {
                wfd_sink_error("The parent of pad is NULL.");
                return GST_PAD_PROBE_DROP;
        }
 
-       buffer = gst_pad_probe_info_get_buffer (info);
+       buffer = gst_pad_probe_info_get_buffer(info);
 
        wfd_sink_debug("FIRST BUFFER PROBE : %s:%s :  %u:%02u:%02u.%09u (%"G_GSSIZE_FORMAT" bytes)\n",
-               GST_STR_NULL(GST_ELEMENT_NAME(parent)), GST_STR_NULL(GST_PAD_NAME(pad)),
-               GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)), gst_buffer_get_size(buffer));
+                      GST_STR_NULL(GST_ELEMENT_NAME(parent)), GST_STR_NULL(GST_PAD_NAME(pad)),
+                      GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)), gst_buffer_get_size(buffer));
 
-       if (probe_id && *probe_id >0)
-       {
+       if (probe_id && *probe_id > 0) {
                wfd_sink_debug("remove buffer probe[%d]\n", *probe_id);
                gst_pad_remove_probe(pad, *probe_id);
 
                MMWFDSINK_FREEIF(probe_id);
        }
 
-       if ( parent )
+       if (parent)
                gst_object_unref(parent);
 
        return GST_PAD_PROBE_REMOVE;
@@ -199,33 +186,28 @@ _mm_wfd_sink_util_check_first_buffer_cb (GstPad * pad, GstPadProbeInfo * info, g
 void
 mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer(GstPad *pad, GstElement *element, const gchar *pad_name)
 {
-       GstPad * probe_pad = NULL;
+       GstPad *probe_pad = NULL;
        guint *probe_id = NULL;
 
-       if (!pad)
-       {
-               if(element && pad_name)
+       if (!pad) {
+               if (element && pad_name)
                        probe_pad = gst_element_get_static_pad(element, pad_name);
-       }
-       else
-       {
+       } else {
                probe_pad = pad;
                gst_object_ref(probe_pad);
        }
 
-       if (probe_pad)
-       {
+       if (probe_pad) {
                probe_id  = g_malloc0(sizeof(guint));
-               if (!probe_id)
-               {
+               if (!probe_id) {
                        wfd_sink_error("failed to allocate memory for probe id\n");
                        gst_object_unref(probe_pad);
                        return;
                }
 
                *probe_id = gst_pad_add_probe(probe_pad, GST_PAD_PROBE_TYPE_BUFFER, _mm_wfd_sink_util_check_first_buffer_cb, (gpointer)probe_id, NULL);
-               wfd_sink_debug ("add pad(%s) probe, %d",
-                       GST_STR_NULL(GST_PAD_NAME(probe_pad)), *probe_id);
+               wfd_sink_debug("add pad(%s) probe, %d",
+                              GST_STR_NULL(GST_PAD_NAME(probe_pad)), *probe_id);
 
                gst_object_unref(probe_pad);
        }