[0.6.185] send pcm_format info to client
[platform/core/multimedia/libmm-player.git] / src / mm_player_priv.c
index 8e1edcc..df00ea4 100644 (file)
 #include <sys/time.h>
 #include <stdlib.h>
 #include <dlog.h>
+#include <gio/gio.h>
 
 #include <mm_error.h>
 #include <mm_attrs.h>
-#include <mm_attrs_private.h>
+#include <mm_sound.h>
 
 #include "mm_player_priv.h"
 #include "mm_player_ini.h"
 #define DEFAULT_PLAYBACK_RATE                  1.0
 #define DEFAULT_NUM_OF_V_OUT_BUFFER            3
 
-#define MMPLAYER_USE_FILE_FOR_BUFFERING(player) \
-       (((player)->profile.uri_type != MM_PLAYER_URI_TYPE_HLS) && \
-       (player->ini.http_use_file_buffer) && \
-       (player->http_file_buffering_path) && \
-       (strlen(player->http_file_buffering_path) > 0))
-
 #define PLAYER_DISPLAY_MODE_DST_ROI            5
 
 #define ADAPTIVE_VARIANT_DEFAULT_VALUE -1 /* auto */
 
-/* For PD mode */
-#define PLAYER_PD_EXT_MAX_SIZE_BYTE            1024 * 1024 * 3
-#define PLAYER_PD_STATE_CHANGE_TIME            20 /* sec */
-
 #define PLAYER_SPHERICAL_DEFAULT_YAW   0  /* sync from video360 plugin */
 #define PLAYER_SPHERICAL_DEFAULT_PITCH 0
 #define PLAYER_SPHERICAL_DEFAULT_H_FOV 120
 
 #define FAKE_SINK_MAX_LATENESS         G_GINT64_CONSTANT(20000000) /* set 20ms as waylandsink */
 
+#define DEFAULT_PCM_OUT_FORMAT         "F32LE"
+#define DEFAULT_PCM_OUT_SAMPLERATE     44100
+#define DEFAULT_PCM_OUT_CHANNEL        2
+
 /*---------------------------------------------------------------------------
 |    LOCAL CONSTANT DEFINITIONS:                                                                                       |
 ---------------------------------------------------------------------------*/
 /*---------------------------------------------------------------------------
 |    LOCAL DATA TYPE DEFINITIONS:                                                                                      |
 ---------------------------------------------------------------------------*/
+/* NOTE : GstAutoplugSelectResult is defined in gstplay-enum.h but not exposed
+ We are defining our own and will be removed when it actually exposed */
+typedef enum {
+       GST_AUTOPLUG_SELECT_TRY,
+       GST_AUTOPLUG_SELECT_EXPOSE,
+       GST_AUTOPLUG_SELECT_SKIP
+} GstAutoplugSelectResult;
 
 /*---------------------------------------------------------------------------
 |    GLOBAL VARIABLE DEFINITIONS:                                                                                      |
@@ -134,78 +136,77 @@ static sound_stream_info_h stream_info;
 /*---------------------------------------------------------------------------
 |    LOCAL FUNCTION PROTOTYPES:                                                                                                |
 ---------------------------------------------------------------------------*/
-static int             __mmplayer_gst_create_pipeline(mm_player_t* player);
-static int             __mmplayer_gst_destroy_pipeline(mm_player_t* player);
-static int             __mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps *caps, MMDisplaySurfaceType surface_type);
-static int             __mmplayer_gst_create_audio_pipeline(mm_player_t* player);
-static int             __mmplayer_gst_create_text_pipeline(mm_player_t* player);
-static int             __mmplayer_gst_create_text_sink_bin(mm_player_t* player);
-
-static GstPadProbeReturn       __mmplayer_gst_selector_blocked(GstPadpad, GstPadProbeInfo *info, gpointer data);
-static void            __mmplayer_gst_decode_no_more_pads(GstElementelem, gpointer data);
-static void            __mmplayer_gst_decode_callback(GstElement *decodebin, GstPad *pad, gpointer data);
-static void            __mmplayer_gst_decode_unknown_type(GstElement *elem,  GstPadpad, GstCaps *caps, gpointer data);
-static gboolean __mmplayer_gst_decode_autoplug_continue(GstElement *bin,  GstPad* pad, GstCaps * caps,  gpointer data);
-static void __mmplayer_gst_decode_pad_removed(GstElement *elem,  GstPadnew_pad, gpointer data);
+static int             __mmplayer_gst_create_pipeline(mmplayer_t *player);
+static int             __mmplayer_gst_destroy_pipeline(mmplayer_t *player);
+static int             __mmplayer_gst_create_text_pipeline(mmplayer_t *player);
+static int             __mmplayer_gst_create_video_sink_bin(mmplayer_t *player, GstCaps *caps, MMDisplaySurfaceType surface_type);
+static int             __mmplayer_gst_create_audio_sink_bin(mmplayer_t *player);
+static int             __mmplayer_gst_create_text_sink_bin(mmplayer_t *player);
+
+static GstPadProbeReturn       __mmplayer_gst_selector_blocked(GstPad *pad, GstPadProbeInfo *info, gpointer data);
+static void            __mmplayer_gst_decode_no_more_pads(GstElement *elem, gpointer data);
+static void            __mmplayer_gst_create_sinkbin(GstElement *decodebin, GstPad *pad, gpointer data);
+static void            __mmplayer_gst_decode_unknown_type(GstElement *elem,  GstPad *pad, GstCaps *caps, gpointer data);
+static gboolean __mmplayer_gst_decode_autoplug_continue(GstElement *bin,  GstPad *pad, GstCaps *caps,  gpointer data);
+static void __mmplayer_gst_decode_pad_removed(GstElement *elem,  GstPad *new_pad, gpointer data);
 static void __mmplayer_gst_decode_drained(GstElement *bin, gpointer data);
 static void    __mmplayer_pipeline_complete(GstElement *decodebin,  gpointer data);
-static gboolean __mmplayer_is_midi_type(gcharstr_caps);
+static gboolean __mmplayer_is_midi_type(gchar *str_caps);
 static gboolean __mmplayer_is_only_mp3_type(gchar *str_caps);
-static void    __mmplayer_set_audio_attrs(mm_player_t* player, GstCaps* caps);
-
-static gboolean        __mmplayer_update_subtitle(GstElementobject, GstBuffer *buffer, GstPad *pad, gpointer data);
-static void            __mmplayer_release_misc(mm_player_t* player);
-static void            __mmplayer_release_misc_post(mm_player_t* player);
-static gboolean        __mmplayer_init_gstreamer(mm_player_t* player);
-static void __mmplayer_video_stream_decoded_preroll_cb(GstElementobject, GstBuffer *buffer, GstPad *pad, gpointer data);
-static void __mmplayer_video_stream_decoded_render_cb(GstElementobject, GstBuffer *buffer, GstPad *pad, gpointer data);
+static void    __mmplayer_set_audio_attrs(mmplayer_t *player, GstCaps *caps);
+
+static gboolean        __mmplayer_update_subtitle(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data);
+static void            __mmplayer_release_misc(mmplayer_t *player);
+static void            __mmplayer_release_misc_post(mmplayer_t *player);
+static gboolean        __mmplayer_init_gstreamer(mmplayer_t *player);
+static void __mmplayer_video_stream_decoded_preroll_cb(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data);
+static void __mmplayer_video_stream_decoded_render_cb(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data);
 static GstPadProbeReturn __mmplayer_subtitle_adjust_position_probe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
-static int __mmplayer_change_selector_pad(mm_player_t* player, MMPlayerTrackType type, int index);
-
-static gboolean __mmplayer_check_subtitle(mm_player_t* player);
-static int             __mmplayer_handle_missed_plugin(mm_player_t* player);
-static int             __mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_class, const gchar* mime);
-static void            __mmplayer_add_sink(mm_player_t* player, GstElement* sink);
-static void            __mmplayer_del_sink(mm_player_t* player, GstElement* sink);
-static void            __mmplayer_release_signal_connection(mm_player_t* player, MMPlayerSignalType type);
+static int __mmplayer_change_selector_pad(mmplayer_t *player, mmplayer_track_type_e type, int index);
+
+static gboolean __mmplayer_check_subtitle(mmplayer_t *player);
+static int             __mmplayer_handle_missed_plugin(mmplayer_t *player);
+static int             __mmplayer_check_not_supported_codec(mmplayer_t *player, const gchar *factory_class, const gchar *mime);
+static void            __mmplayer_add_sink(mmplayer_t *player, GstElement *sink);
+static void            __mmplayer_del_sink(mmplayer_t *player, GstElement *sink);
+static void            __mmplayer_release_signal_connection(mmplayer_t *player, mmplayer_signal_type_e type);
 static gpointer __mmplayer_gapless_play_thread(gpointer data);
-static gboolean __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element);
+static gboolean __mmplayer_add_dump_buffer_probe(mmplayer_t *player, GstElement *element);
 static GstPadProbeReturn __mmplayer_dump_buffer_probe_cb(GstPad *pad,  GstPadProbeInfo *info, gpointer u_data);
 static void __mmplayer_release_dump_list(GList *dump_list);
-static int             __mmplayer_gst_realize(mm_player_t* player);
-static int             __mmplayer_gst_unrealize(mm_player_t* player);
-static int             __mmplayer_gst_adjust_subtitle_position(mm_player_t* player, int format, int position);
-static int             __mmplayer_gst_set_message_callback(mm_player_t* player, MMMessageCallback callback, gpointer user_param);
+static int             __mmplayer_gst_realize(mmplayer_t *player);
+static int             __mmplayer_gst_unrealize(mmplayer_t *player);
+static int             __mmplayer_gst_adjust_subtitle_position(mmplayer_t *player, int position);
+static int             __mmplayer_gst_set_message_callback(mmplayer_t *player, MMMessageCallback callback, gpointer user_param);
 
 /* util */
-static int __mmplayer_realize_streaming_ext(mm_player_t* player);
-static int __mmplayer_unrealize_streaming_ext(mm_player_t *player);
-static int __mmplayer_start_streaming_ext(mm_player_t *player);
-static int __mmplayer_destroy_streaming_ext(mm_player_t* player);
-static gboolean __mmplayer_verify_gapless_play_path(mm_player_t *player);
-static void __mmplayer_activate_next_source(mm_player_t *player, GstState target);
-static void __mmplayer_check_pipeline(mm_player_t* player);
-static gboolean __mmplayer_deactivate_selector(mm_player_t *player, MMPlayerTrackType type);
-static void __mmplayer_deactivate_old_path(mm_player_t *player);
-static int __mmplayer_gst_create_plain_text_elements(mm_player_t* player);
-static guint32 _mmplayer_convert_fourcc_string_to_value(const gchar* format_name);
-static void            __mmplayer_gst_caps_notify_cb(GstPad * pad, GParamSpec * unused, gpointer data);
-static void            __mmplayer_audio_stream_send_data(mm_player_t* player, mm_player_audio_stream_buff_t *a_buffer);
-static void            __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_type);
+static gboolean __mmplayer_verify_gapless_play_path(mmplayer_t *player);
+static void __mmplayer_activate_next_source(mmplayer_t *player, GstState target);
+static void __mmplayer_check_pipeline(mmplayer_t *player);
+static gboolean __mmplayer_deactivate_selector(mmplayer_t *player, mmplayer_track_type_e type);
+static void __mmplayer_deactivate_old_path(mmplayer_t *player);
+static int __mmplayer_gst_create_plain_text_elements(mmplayer_t *player);
+static guint32 _mmplayer_convert_fourcc_string_to_value(const gchar *format_name);
+static void            __mmplayer_gst_caps_notify_cb(GstPad *pad, GParamSpec *unused, gpointer data);
+static void            __mmplayer_audio_stream_send_data(mmplayer_t *player, mmplayer_audio_stream_buff_t *a_buffer);
+static void            __mmplayer_initialize_storage_info(mmplayer_t *player, mmplayer_path_type_e path_type);
 static int             __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res, void *user_data);
-static gboolean __mmplayer_update_duration_attrs(mm_player_t *player, MMHandleType attrs);
-static gboolean __mmplayer_update_audio_attrs(mm_player_t *player, MMHandleType attrs);
-static gboolean __mmplayer_update_video_attrs(mm_player_t *player, MMHandleType attrs);
-static gboolean __mmplayer_update_bitrate_attrs(mm_player_t *player, MMHandleType attrs);
-
-static void __mmplayer_copy_uri_and_set_type(MMPlayerParseProfile* data, const char *uri, int uri_type);
-static int __mmplayer_set_mem_uri(MMPlayerParseProfile* data, char *path, void *param);
-static int __mmplayer_set_file_uri(MMPlayerParseProfile* data, const char *uri);
-
-static MMPlayerVideoStreamDataType* __mmplayer_create_stream_from_pad(GstPad *pad);
-static void __mmplayer_zerocopy_set_stride_elevation_bo(MMPlayerVideoStreamDataType *stream, GstMemory *mem);
-static gboolean __mmplayer_swcodec_set_stride_elevation(MMPlayerVideoStreamDataType *stream);
-static gboolean __mmplayer_swcodec_set_bo(mm_player_t *player, MMPlayerVideoStreamDataType *stream, GstMemory *mem);
+static gboolean __mmplayer_update_duration_value(mmplayer_t *player);
+static gboolean __mmplayer_update_audio_attrs(mmplayer_t *player, MMHandleType attrs);
+static gboolean __mmplayer_update_video_attrs(mmplayer_t *player, MMHandleType attrs);
+static gboolean __mmplayer_update_bitrate_attrs(mmplayer_t *player, MMHandleType attrs);
+
+static void __mmplayer_copy_uri_and_set_type(mmplayer_parse_profile_t *data, const char *uri, int uri_type);
+static int __mmplayer_set_mem_uri(mmplayer_parse_profile_t *data, char *path, void *param);
+static int __mmplayer_set_file_uri(mmplayer_parse_profile_t *data, const char *uri);
+
+static mmplayer_video_decoded_data_info_t *__mmplayer_create_stream_from_pad(GstPad *pad);
+static void __mmplayer_zerocopy_set_stride_elevation_bo(mmplayer_video_decoded_data_info_t *stream, GstMemory *mem);
+static gboolean __mmplayer_swcodec_set_stride_elevation(mmplayer_video_decoded_data_info_t *stream);
+static gboolean __mmplayer_swcodec_set_bo(mmplayer_t *player, mmplayer_video_decoded_data_info_t *stream, GstMemory *mem);
+
+static void __mmplayer_set_pause_state(mmplayer_t *player);
+static void __mmplayer_set_playing_state(mmplayer_t *player);
 /*===========================================================================================
 |                                                                                                                                                                                      |
 |  FUNCTION DEFINITIONS                                                                                                                                                |
@@ -214,7 +215,7 @@ static gboolean __mmplayer_swcodec_set_bo(mm_player_t *player, MMPlayerVideoStre
 
 #if 0 //debug
 static void
-print_tag(const GstTagList * list, const gchar * tag, gpointer unused)
+print_tag(const GstTagList *list, const gchar *tag, gpointer unused)
 {
        gint i, count;
 
@@ -228,13 +229,14 @@ print_tag(const GstTagList * list, const gchar * tag, gpointer unused)
                if (gst_tag_get_type(tag) == G_TYPE_STRING) {
                        if (!gst_tag_list_get_string_index(list, tag, i, &str))
                                g_assert_not_reached();
-               } else
+               } else {
                        str = g_strdup_value_contents(gst_tag_list_get_value_index(list, tag, i));
+               }
 
                if (i == 0)
-                       g_print("  %15s: %s\n", gst_tag_get_nick(tag), str);
+                       g_print("  %15s: %s", gst_tag_get_nick(tag), str);
                else
-                       g_print("                 : %s\n", str);
+                       g_print("                 : %s", str);
 
                g_free(str);
        }
@@ -244,7 +246,7 @@ print_tag(const GstTagList * list, const gchar * tag, gpointer unused)
 /* This function should be called after the pipeline goes PAUSED or higher
 state. */
 gboolean
-__mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag)
+__mmplayer_update_content_attrs(mmplayer_t *player, enum content_attr_flag flag)
 {
        static gboolean has_duration = FALSE;
        static gboolean has_video_attrs = FALSE;
@@ -295,7 +297,7 @@ __mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag
        }
 
        if ((flag & ATTR_DURATION) || (!has_duration && missing_only) || all)
-               has_duration = __mmplayer_update_duration_attrs(player, attrs);
+               has_duration = __mmplayer_update_duration_value(player);
 
        if ((flag & ATTR_AUDIO) || (!has_audio_attrs && missing_only) || all)
                has_audio_attrs = __mmplayer_update_audio_attrs(player, attrs);
@@ -307,8 +309,8 @@ __mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag
                has_bitrate = __mmplayer_update_bitrate_attrs(player, attrs);
 
        /* validate all */
-       if (mmf_attrs_commit(attrs)) {
-               LOGE("failed to update attributes\n");
+       if (mm_attrs_commit_all(attrs)) {
+               LOGE("failed to update attributes");
                return FALSE;
        }
 
@@ -317,7 +319,8 @@ __mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag
        return TRUE;
 }
 
-MMStreamingType __mmplayer_get_stream_service_type(mm_player_t* player)
+MMStreamingType
+__mmplayer_get_stream_service_type(mmplayer_t *player)
 {
        MMStreamingType streaming_type = STREAMING_SERVICE_NONE;
 
@@ -353,20 +356,18 @@ MMStreamingType __mmplayer_get_stream_service_type(mm_player_t* player)
        return streaming_type;
 }
 
-
 /* this function sets the player state and also report
  * it to applicaton by calling callback function
  */
 void
-__mmplayer_set_state(mm_player_t* player, int state)
+__mmplayer_set_state(mmplayer_t *player, int state)
 {
        MMMessageParamType msg = {0, };
-       gboolean post_bos = FALSE;
 
        MMPLAYER_RETURN_IF_FAIL(player);
 
        if (MMPLAYER_CURRENT_STATE(player) == state) {
-               LOGW("already same state(%s)\n", MMPLAYER_STATE_GET_NAME(state));
+               LOGW("already same state(%s)", MMPLAYER_STATE_GET_NAME(state));
                MMPLAYER_PENDING_STATE(player) = MM_PLAYER_STATE_NONE;
                return;
        }
@@ -385,77 +386,15 @@ __mmplayer_set_state(mm_player_t* player, int state)
        case MM_PLAYER_STATE_NULL:
        case MM_PLAYER_STATE_READY:
                break;
-
        case MM_PLAYER_STATE_PAUSED:
-               {
-                       if (!player->sent_bos) {
-                               /* rtsp case, get content attrs by GstMessage */
-                               if (!MMPLAYER_IS_RTSP_STREAMING(player)) {
-                                       /* it's first time to update all content attrs. */
-                                       __mmplayer_update_content_attrs(player, ATTR_ALL);
-                               }
-                       }
-               }
+               __mmplayer_set_pause_state(player);
                break;
-
        case MM_PLAYER_STATE_PLAYING:
-               {
-                       /* try to get content metadata */
-                       if (!player->sent_bos) {
-                               /* NOTE : giving ATTR_MISSING_ONLY may have dependency with
-                                * c-api since c-api doesn't use _start() anymore. It may not work propery with
-                                * legacy mmfw-player api */
-                               __mmplayer_update_content_attrs(player, ATTR_MISSING_ONLY);
-                       }
-
-                       if ((player->cmd == MMPLAYER_COMMAND_START) || (player->cmd == MMPLAYER_COMMAND_RESUME)) {
-                               if (!player->sent_bos)
-                                       __mmplayer_handle_missed_plugin(player);
-                       }
-
-                       if (player->resumed_by_rewind && player->playback_rate < 0.0) {
-                               /* initialize because auto resume is done well. */
-                               player->resumed_by_rewind = FALSE;
-                               player->playback_rate = 1.0;
-                       }
-
-                       if (!player->sent_bos) {
-                               /* check audio codec field is set or not
-                                * we can get it from typefinder or codec's caps.
-                                */
-                               gchar *audio_codec = NULL;
-                               mm_attrs_get_string_by_name(player->attrs, "content_audio_codec", &audio_codec);
-
-                               /* The codec format can't be sent for audio only case like amr, mid etc.
-                                * Because, parser don't make related TAG.
-                                * So, if it's not set yet, fill it with found data.
-                                */
-                               if (!audio_codec) {
-                                       if (g_strrstr(player->type, "audio/midi"))
-                                               audio_codec = g_strdup("MIDI");
-                                       else if (g_strrstr(player->type, "audio/x-amr"))
-                                               audio_codec = g_strdup("AMR");
-                                       else if (g_strrstr(player->type, "audio/mpeg") && !g_strrstr(player->type, "mpegversion= (int)1"))
-                                               audio_codec = g_strdup("AAC");
-                                       else
-                                               audio_codec = g_strdup("unknown");
-                                       mm_attrs_set_string_by_name(player->attrs, "content_audio_codec", audio_codec);
-
-                                       MMPLAYER_FREEIF(audio_codec);
-                                       if (mmf_attrs_commit(player->attrs))
-                                               LOGE("failed to update attributes\n");
-
-                                       LOGD("set audio codec type with caps\n");
-                               }
-
-                               post_bos = TRUE;
-                       }
-               }
+               __mmplayer_set_playing_state(player);
                break;
-
        case MM_PLAYER_STATE_NONE:
        default:
-               LOGW("invalid target state, there is nothing to do.\n");
+               LOGW("invalid target state, there is nothing to do.");
                break;
        }
 
@@ -470,18 +409,19 @@ __mmplayer_set_state(mm_player_t* player, int state)
                LOGD("player reach the target state (%s)", MMPLAYER_STATE_GET_NAME(MMPLAYER_TARGET_STATE(player)));
 
                /* state changed by resource callback */
-               if (player->interrupted_by_resource) {
+               if (player->interrupted_by_resource)
                        MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, &msg);
-               } else { /* state changed by usecase */
+               else /* state changed by usecase */
                        MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_CHANGED, &msg);
-               }
+
        } else {
-               LOGD("intermediate state, do nothing.\n");
+               LOGD("intermediate state, do nothing.");
                MMPLAYER_PRINT_STATE(player);
                return;
        }
 
-       if (post_bos) {
+       if (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PLAYING
+               && !player->sent_bos) {
                MMPLAYER_POST_MSG(player, MM_MESSAGE_BEGIN_OF_STREAM, NULL);
                player->sent_bos = TRUE;
        }
@@ -490,14 +430,14 @@ __mmplayer_set_state(mm_player_t* player, int state)
 }
 
 int
-__mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command)
+__mmplayer_check_state(mmplayer_t *player, mmplayer_command_state_e command)
 {
-       MMPlayerStateType current_state = MM_PLAYER_STATE_NUM;
-       MMPlayerStateType pending_state = MM_PLAYER_STATE_NUM;
+       mmplayer_state_e current_state = MM_PLAYER_STATE_NUM;
+       mmplayer_state_e pending_state = MM_PLAYER_STATE_NUM;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       //LOGD("incomming command : %d \n", command);
+       //LOGD("incomming command : %d ", command);
 
        current_state = MMPLAYER_CURRENT_STATE(player);
        pending_state = MMPLAYER_PENDING_STATE(player);
@@ -565,8 +505,9 @@ __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command)
                        goto ALREADY_GOING;
                } else if (pending_state == MM_PLAYER_STATE_PAUSED) {
                        LOGD("player is going to paused state, just change the pending state as playing");
-               } else
+               } else {
                        goto INVALID_STATE;
+               }
        }
        break;
 
@@ -626,8 +567,9 @@ __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command)
                        goto ALREADY_GOING;
                } else if (pending_state == MM_PLAYER_STATE_PAUSED) {
                        LOGD("player is going to paused state, just change the pending state as playing");
-               } else
+               } else {
                        goto INVALID_STATE;
+               }
        }
                break;
 
@@ -656,26 +598,27 @@ ALREADY_GOING:
        return MM_ERROR_PLAYER_NO_OP;
 }
 
-static gpointer __mmplayer_gapless_play_thread(gpointer data)
+static gpointer
+__mmplayer_gapless_play_thread(gpointer data)
 {
-       mm_player_t* player = (mm_player_t*) data;
-       MMPlayerGstElement *mainbin = NULL;
+       mmplayer_t *player = (mmplayer_t *)data;
+       mmplayer_gst_element_t *mainbin = NULL;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
 
        MMPLAYER_GAPLESS_PLAY_THREAD_LOCK(player);
        while (!player->gapless_play_thread_exit) {
-               LOGD("gapless play thread started. waiting for signal.\n");
+               LOGD("gapless play thread started. waiting for signal.");
                MMPLAYER_GAPLESS_PLAY_THREAD_WAIT(player);
 
-               LOGD("reconfigure pipeline for gapless play.\n");
+               LOGD("reconfigure pipeline for gapless play.");
 
                if (player->gapless_play_thread_exit) {
                        if (player->gapless.reconfigure) {
                                player->gapless.reconfigure = false;
                                MMPLAYER_PLAYBACK_UNLOCK(player);
                        }
-                       LOGD("exiting gapless play thread\n");
+                       LOGD("exiting gapless play thread");
                        break;
                }
 
@@ -702,7 +645,6 @@ __mmplayer_remove_g_source_from_context(GMainContext *context, guint source_id)
        MMPLAYER_FENTER();
 
        source = g_main_context_find_source_by_id(context, source_id);
-
        if (source != NULL) {
                LOGW("context: %p, source id: %d, source: %p", context, source_id, source);
                g_source_destroy(source);
@@ -711,9 +653,10 @@ __mmplayer_remove_g_source_from_context(GMainContext *context, guint source_id)
        MMPLAYER_FLEAVE();
 }
 
-void __mmplayer_bus_msg_thread_destroy(MMHandleType hplayer)
+void
+__mmplayer_bus_msg_thread_destroy(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        GstMessage *msg = NULL;
        GQueue *queue = NULL;
 
@@ -757,26 +700,20 @@ void __mmplayer_bus_msg_thread_destroy(MMHandleType hplayer)
 }
 
 gboolean
-__mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstElement* fakesink)
+__mmplayer_gst_remove_fakesink(mmplayer_t *player, mmplayer_gst_element_t *fakesink)
 {
-       GstElementparent = NULL;
+       GstElement *parent = NULL;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, FALSE);
-
-       /* if we have no fakesink. this meas we are using decodebin which doesn'
-       t need to add extra fakesink */
-       MMPLAYER_RETURN_VAL_IF_FAIL(fakesink, TRUE);
+       MMPLAYER_RETURN_VAL_IF_FAIL(fakesink && fakesink->gst, TRUE);
 
        /* lock */
        MMPLAYER_FSINK_LOCK(player);
 
-       if (!fakesink->gst)
-               goto ERROR;
-
        /* get parent of fakesink */
-       parent = (GstElement*)gst_object_get_parent((GstObject*)fakesink->gst);
+       parent = (GstElement *)gst_object_get_parent((GstObject *)fakesink->gst);
        if (!parent) {
-               LOGD("fakesink already removed\n");
+               LOGD("fakesink already removed");
                goto ERROR;
        }
 
@@ -786,13 +723,13 @@ __mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstElement* fakesink
         * so no need to wait for completion of state transiton
         */
        if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(fakesink->gst, GST_STATE_NULL))
-               LOGE("fakesink state change failure!\n");
+               LOGE("fakesink state change failure!");
                /* FIXIT : should I return here? or try to proceed to next? */
                /* return FALSE; */
 
        /* remove fakesink from it's parent */
        if (!gst_bin_remove(GST_BIN(parent), fakesink->gst)) {
-               LOGE("failed to remove fakesink\n");
+               LOGE("failed to remove fakesink");
 
                gst_object_unref(parent);
 
@@ -801,7 +738,7 @@ __mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstElement* fakesink
 
        gst_object_unref(parent);
 
-       LOGD("state-holder removed\n");
+       LOGD("state-holder removed");
 
        gst_element_set_locked_state(fakesink->gst, FALSE);
 
@@ -817,14 +754,14 @@ ERROR:
 }
 
 static GstPadProbeReturn
-__mmplayer_gst_selector_blocked(GstPadpad, GstPadProbeInfo *info, gpointer data)
+__mmplayer_gst_selector_blocked(GstPad *pad, GstPadProbeInfo *info, gpointer data)
 {
        LOGD("pad(%s:%s) is blocked", GST_DEBUG_PAD_NAME(pad));
        return GST_PAD_PROBE_OK;
 }
 
 static void
-__mmplayer_gst_selector_update_start_time(mm_player_t* player, MMPlayerTrackType stream_type)
+__mmplayer_gst_selector_update_start_time(mmplayer_t *player, mmplayer_track_type_e stream_type)
 {
        gint64 stop_running_time = 0;
        gint64 position_running_time = 0;
@@ -888,11 +825,11 @@ __mmplayer_gst_selector_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer
 {
        GstPadProbeReturn ret = GST_PAD_PROBE_OK;
        GstEvent *event = GST_PAD_PROBE_INFO_DATA(info);
-       mm_player_t *player = (mm_player_t*)data;
+       mmplayer_t *player = (mmplayer_t *)data;
        GstCaps *caps = NULL;
        GstStructure *str = NULL;
        const gchar *name = NULL;
-       MMPlayerTrackType stream_type = MM_PLAYER_TRACK_TYPE_VIDEO;
+       mmplayer_track_type_e stream_type = MM_PLAYER_TRACK_TYPE_VIDEO;
        gboolean caps_ret = TRUE;
 
        if (GST_EVENT_IS_DOWNSTREAM(event) &&
@@ -1033,7 +970,7 @@ ERROR:
 
 /* create fakesink for audio or video path witout audiobin or videobin */
 static void
-__mmplayer_gst_make_fakesink(mm_player_t *player, GstPad *pad, const gchar *name)
+__mmplayer_gst_make_fakesink(mmplayer_t *player, GstPad *pad, const gchar *name)
 {
        GstElement *pipeline = NULL;
        GstElement *fakesink = NULL;
@@ -1068,34 +1005,12 @@ __mmplayer_gst_make_fakesink(mm_player_t *player, GstPad *pad, const gchar *name
        }
 
        if (strstr(name, "video")) {
-               player->video_fakesink = fakesink;
-
                if (player->v_stream_caps) {
                        gst_caps_unref(player->v_stream_caps);
                        player->v_stream_caps = NULL;
                }
-
                if (player->ini.set_dump_element_flag)
                        __mmplayer_add_dump_buffer_probe(player, fakesink);
-
-
-               if (player->set_mode.media_packet_video_stream) { /* export video decoded frame */
-                       g_object_set(G_OBJECT(fakesink), "signal-handoffs", TRUE, "max-lateness", FAKE_SINK_MAX_LATENESS, NULL);
-
-                       __mmplayer_add_signal_connection(player,
-                                                                       G_OBJECT(fakesink),
-                                                                       MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
-                                                                       "handoff",
-                                                                       G_CALLBACK(__mmplayer_video_stream_decoded_render_cb),
-                                                                       (gpointer)player);
-
-                       __mmplayer_add_signal_connection(player,
-                                                                       G_OBJECT(fakesink),
-                                                                       MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
-                                                                       "preroll-handoff",
-                                                                       G_CALLBACK(__mmplayer_video_stream_decoded_preroll_cb),
-                                                                       (gpointer)player);
-               }
        }
 
        g_object_set(G_OBJECT(fakesink), "sync", TRUE, NULL);
@@ -1109,8 +1024,8 @@ EXIT:
        return;
 }
 
-static GstElement*
-__mmplayer_gst_make_selector(mm_player_t *player, enum MainElementID elem_idx, MMPlayerTrackType stream_type)
+static GstElement *
+__mmplayer_gst_make_selector(mmplayer_t *player, main_element_id_e elem_idx, mmplayer_track_type_e stream_type)
 {
        GstElement *pipeline = NULL;
        GstElement *selector = NULL;
@@ -1144,6 +1059,8 @@ __mmplayer_gst_make_selector(mm_player_t *player, enum MainElementID elem_idx, M
        pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst;
        gst_bin_add(GST_BIN(pipeline), selector);
 
+       gst_object_unref(GST_OBJECT(srcpad));
+
        MMPLAYER_FLEAVE();
        return selector;
 }
@@ -1151,21 +1068,17 @@ __mmplayer_gst_make_selector(mm_player_t *player, enum MainElementID elem_idx, M
 void
 __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data)
 {
-       mm_player_t *player = NULL;
+       mmplayer_t *player = (mmplayer_t *)data;
        GstElement *selector = NULL;
        GstCaps *caps = NULL;
        GstStructure *str = NULL;
        const gchar *name = NULL;
        GstPad *sinkpad = NULL;
-       GstPad *srcpad = NULL;
        gboolean first_track = FALSE;
        gboolean caps_ret = TRUE;
 
-       enum MainElementID elem_idx = MMPLAYER_M_NUM;
-       MMPlayerTrackType stream_type = MM_PLAYER_TRACK_TYPE_AUDIO;
-
-       /* check handles */
-       player = (mm_player_t*)data;
+       main_element_id_e elem_idx = MMPLAYER_M_NUM;
+       mmplayer_track_type_e stream_type = MM_PLAYER_TRACK_TYPE_AUDIO;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(elem && pad);
@@ -1188,7 +1101,7 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data)
                caps_str = gst_caps_to_string(caps);
                if (caps_str && (strstr(caps_str, "ST12") || strstr(caps_str, "SN12") ||
                        strstr(caps_str, "SN21") || strstr(caps_str, "S420") || strstr(caps_str, "SR32")))
-                       player->set_mode.video_zc = TRUE;
+                       player->set_mode.video_zc = true;
 
                MMPLAYER_FREEIF(caps_str);
 
@@ -1198,11 +1111,13 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data)
                LOGD("surface type : %d", stype);
 
                if (MMPLAYER_IS_MS_BUFF_SRC(player)) {
-                       __mmplayer_gst_decode_callback(elem, pad, player);
+                       __mmplayer_gst_create_sinkbin(elem, pad, player);
                        goto DONE;
                }
 
-               if (stype == MM_DISPLAY_SURFACE_NULL) {
+               /* in case of exporting video frame, it requires the 360 video filter.
+                * it will be handled in _no_more_pads(). */
+               if ((stype == MM_DISPLAY_SURFACE_NULL) && (!player->set_mode.video_export)) {
                        __mmplayer_gst_make_fakesink(player, pad, name);
                        goto DONE;
                }
@@ -1214,14 +1129,16 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data)
                gint samplerate = 0;
                gint channels = 0;
 
-               gst_structure_get_int(str, "rate", &samplerate);
-               gst_structure_get_int(str, "channels", &channels);
-
-               if (MMPLAYER_IS_MS_BUFF_SRC(player)) {
-                       __mmplayer_gst_decode_callback(elem, pad, player);
+               if (MMPLAYER_IS_MS_BUFF_SRC(player) || player->build_audio_offload) {
+                       if (player->build_audio_offload)
+                               player->no_more_pad = TRUE; /* remove state holder */
+                       __mmplayer_gst_create_sinkbin(elem, pad, player);
                        goto DONE;
                }
 
+               gst_structure_get_int(str, "rate", &samplerate);
+               gst_structure_get_int(str, "channels", &channels);
+
                if ((channels > 0 && samplerate == 0)) { /* exclude audio decoding */
                        __mmplayer_gst_make_fakesink(player, pad, name);
                        goto DONE;
@@ -1266,7 +1183,7 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data)
                g_object_set(selector, "active-pad", sinkpad, NULL);
        }
 
-       __mmplayer_track_update_info(player, stream_type, sinkpad);
+       __mmplayer_track_update_selector_info(player, stream_type, sinkpad);
 
 DONE:
 ERROR:
@@ -1279,17 +1196,13 @@ ERROR:
                sinkpad = NULL;
        }
 
-       if (srcpad) {
-               gst_object_unref(GST_OBJECT(srcpad));
-               srcpad = NULL;
-       }
-
        return;
 }
 
-static gboolean __mmplayer_create_decode_path(mm_player_t* player, GstElement* selector, MMPlayerTrackType type)
+static gboolean
+__mmplayer_create_sink_path(mmplayer_t *player, GstElement *selector, mmplayer_track_type_e type)
 {
-       GstPadsrcpad = NULL;
+       GstPad *srcpad = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, FALSE);
@@ -1309,7 +1222,7 @@ static gboolean __mmplayer_create_decode_path(mm_player_t* player, GstElement* s
 
        LOGD("got pad %s:%s from selector", GST_DEBUG_PAD_NAME(srcpad));
 
-       __mmplayer_gst_decode_callback(selector, srcpad, player);
+       __mmplayer_gst_create_sinkbin(selector, srcpad, player);
 
        LOGD("unblocking %s:%s", GST_DEBUG_PAD_NAME(srcpad));
        if (player->selector[type].block_id) {
@@ -1326,16 +1239,16 @@ static gboolean __mmplayer_create_decode_path(mm_player_t* player, GstElement* s
        return TRUE;
 }
 
-static void __mmplayer_set_decode_track_info(mm_player_t* player, MMPlayerTrackType type)
+static void
+__mmplayer_set_decode_track_info(mmplayer_t *player, mmplayer_track_type_e type)
 {
        MMHandleType attrs = 0;
        gint active_index = 0;
-       gchar *attr_name = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player);
 
-       LOGD("type %d", type);
+       LOGD("type: %d, the num of track: %d", type, player->selector[type].total_track_num);
 
        /* change track to active pad */
        active_index = player->selector[type].active_pad_index;
@@ -1343,39 +1256,34 @@ static void __mmplayer_set_decode_track_info(mm_player_t* player, MMPlayerTrackT
                (__mmplayer_change_selector_pad(player, type, active_index) != MM_ERROR_NONE)) {
                LOGW("failed to change %d type track to %d", type, active_index);
                player->selector[type].active_pad_index = DEFAULT_TRACK;
-       }
-
-       LOGD("Total num of tracks = %d", player->selector[type].total_track_num);
-
-       if (type == MM_PLAYER_TRACK_TYPE_AUDIO) {
-               attr_name = "content_audio_track_num";
-       } else if (type == MM_PLAYER_TRACK_TYPE_TEXT) {
-               attr_name = "content_text_track_num";
-       } else {
-               LOGE("invalid type info %d", type);
                return;
        }
 
-       attrs = MMPLAYER_GET_ATTRS(player);
-       if (attrs) {
-               mm_attrs_set_int_by_name(attrs, attr_name, (gint)player->selector[type].total_track_num);
-               if (mmf_attrs_commit(attrs))
-                       LOGW("failed to commit attrs.");
-       } else {
-               LOGW("cannot get content attribute");
+       if (type == MM_PLAYER_TRACK_TYPE_TEXT) {
+               attrs = MMPLAYER_GET_ATTRS(player);
+               if (attrs) {
+                       mm_attrs_set_int_by_name(attrs, "content_text_track_num", player->selector[type].total_track_num);
+                       mm_attrs_set_int_by_name(attrs, "current_text_track_index", player->selector[type].active_pad_index);
+
+                       if (mm_attrs_commit_all(attrs))
+                               LOGW("failed to commit attrs.");
+               } else {
+                       LOGW("cannot get content attribute");
+               }
        }
 
        MMPLAYER_FLEAVE();
        return;
 }
 
-static gboolean __mmplayer_create_audio_decode_path(mm_player_t* player, GstElement* audio_selector)
+static gboolean
+__mmplayer_create_audio_sink_path(mmplayer_t *player, GstElement *audio_selector)
 {
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, FALSE);
 
        if (!audio_selector) {
-               LOGD("there is no audio track");
+               LOGD("there is no audio track, num_dynamic_pad %d", player->num_dynamic_pad);
 
                /* in case the source is changed, output can be changed. */
                if ((player->pipeline->audiobin) && (player->pipeline->audiobin[MMPLAYER_A_BIN].gst)) {
@@ -1397,9 +1305,9 @@ static gboolean __mmplayer_create_audio_decode_path(mm_player_t* player, GstElem
        /* apply the audio track information */
        __mmplayer_set_decode_track_info(player, MM_PLAYER_TRACK_TYPE_AUDIO);
 
-       /* create audio decode path */
-       if (!__mmplayer_create_decode_path(player, audio_selector, MM_PLAYER_TRACK_TYPE_AUDIO)) {
-               LOGE("failed to create audio decode path");
+       /* create audio sink path */
+       if (!__mmplayer_create_sink_path(player, audio_selector, MM_PLAYER_TRACK_TYPE_AUDIO)) {
+               LOGE("failed to create audio sink path");
                return FALSE;
        }
 
@@ -1407,7 +1315,8 @@ static gboolean __mmplayer_create_audio_decode_path(mm_player_t* player, GstElem
        return TRUE;
 }
 
-static gboolean __mmplayer_create_text_decode_path(mm_player_t* player, GstElement* text_selector)
+static gboolean
+__mmplayer_create_text_sink_path(mmplayer_t *player, GstElement *text_selector)
 {
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && text_selector, FALSE);
@@ -1426,8 +1335,8 @@ static gboolean __mmplayer_create_text_decode_path(mm_player_t* player, GstEleme
        /* create text decode path */
        player->no_more_pad = TRUE;
 
-       if (!__mmplayer_create_decode_path(player, text_selector, MM_PLAYER_TRACK_TYPE_TEXT)) {
-               LOGE("failed to create text decode path");
+       if (!__mmplayer_create_sink_path(player, text_selector, MM_PLAYER_TRACK_TYPE_TEXT)) {
+               LOGE("failed to create text sink path");
                return FALSE;
        }
 
@@ -1436,26 +1345,14 @@ static gboolean __mmplayer_create_text_decode_path(mm_player_t* player, GstEleme
 }
 
 static gboolean
-__mmplayer_gst_set_queue2_buffering(mm_player_t *player)
+__mmplayer_gst_set_queue2_buffering(mmplayer_t *player)
 {
-#define ESTIMATED_BUFFER_UNIT (1*1024*1024)
-
-       gint init_buffering_time = 0;
-       guint buffer_bytes = 0;
        gint64 dur_bytes = 0L;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline &&
                player->pipeline->mainbin && player->streamer, FALSE);
 
-       init_buffering_time = player->streamer->buffering_req.prebuffer_time;
-       buffer_bytes = (guint)(init_buffering_time/1000) * ESTIMATED_BUFFER_UNIT;
-
-       buffer_bytes = MAX(buffer_bytes, player->streamer->buffer_handle[BUFFER_TYPE_MUXED].buffering_bytes);
-       LOGD("pre buffer time: %d ms, buffer size : %d", init_buffering_time, buffer_bytes);
-
-       init_buffering_time = (init_buffering_time != 0) ? (init_buffering_time) : (player->ini.http_buffering_time);
-
        if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes))
                LOGE("fail to get duration.");
 
@@ -1464,12 +1361,7 @@ __mmplayer_gst_set_queue2_buffering(mm_player_t *player)
        __mm_player_streaming_set_queue2(player->streamer,
                                        player->pipeline->mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst,
                                        TRUE,                                                           /* use_buffering */
-                                       buffer_bytes,
-                                       init_buffering_time,
-                                       1.0,                                                            /* low percent */
-                                       player->ini.http_buffering_limit,       /* high percent */
                                        MUXED_BUFFER_TYPE_MAX,                          /* use previous buffer type setting */
-                                       NULL,
                                        ((dur_bytes > 0) ? ((guint64)dur_bytes) : 0));
 
        MMPLAYER_FLEAVE();
@@ -1479,13 +1371,13 @@ __mmplayer_gst_set_queue2_buffering(mm_player_t *player)
 static void
 __mmplayer_gst_decode_no_more_pads(GstElement *elem, gpointer data)
 {
-       mm_player_t *player = NULL;
+       mmplayer_t *player = NULL;
        GstElement *video_selector = NULL;
        GstElement *audio_selector = NULL;
        GstElement *text_selector = NULL;
 
        MMPLAYER_FENTER();
-       player = (mm_player_t*) data;
+       player = (mmplayer_t *)data;
 
        LOGD("no-more-pad signal handling");
 
@@ -1495,8 +1387,7 @@ __mmplayer_gst_decode_no_more_pads(GstElement *elem, gpointer data)
                goto EXIT;
        }
 
-       if ((!MMPLAYER_IS_HTTP_PD(player)) &&
-               (MMPLAYER_IS_HTTP_STREAMING(player)) &&
+       if ((MMPLAYER_IS_HTTP_STREAMING(player)) &&
                (!player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst) &&
                (player->pipeline->mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst)) {
                if (!__mmplayer_gst_set_queue2_buffering(player)) {
@@ -1509,23 +1400,28 @@ __mmplayer_gst_decode_no_more_pads(GstElement *elem, gpointer data)
        audio_selector = player->pipeline->mainbin[MMPLAYER_M_A_INPUT_SELECTOR].gst;
        text_selector = player->pipeline->mainbin[MMPLAYER_M_T_INPUT_SELECTOR].gst;
 
+       if (!video_selector && !audio_selector && !text_selector) {
+               LOGW("there is no selector");
+               player->no_more_pad = TRUE;
+               goto EXIT;
+       }
+
        /* create video path followed by video-select */
        if (video_selector && !audio_selector && !text_selector)
                player->no_more_pad = TRUE;
 
-       if (!__mmplayer_create_decode_path(player, video_selector, MM_PLAYER_TRACK_TYPE_VIDEO))
+       if (!__mmplayer_create_sink_path(player, video_selector, MM_PLAYER_TRACK_TYPE_VIDEO))
                goto EXIT;
 
        /* create audio path followed by audio-select */
        if (audio_selector && !text_selector)
                player->no_more_pad = TRUE;
 
-       if (!__mmplayer_create_audio_decode_path(player, audio_selector))
+       if (!__mmplayer_create_audio_sink_path(player, audio_selector))
                goto EXIT;
 
-
        /* create text path followed by text-select */
-       __mmplayer_create_text_decode_path(player, text_selector);
+       __mmplayer_create_text_sink_path(player, text_selector);
 
 EXIT:
        if (player->gapless.reconfigure) {
@@ -1533,38 +1429,90 @@ EXIT:
                MMPLAYER_PLAYBACK_UNLOCK(player);
        }
 
+       MMPLAYER_FLEAVE();
+}
+
+static gboolean
+__mmplayer_gst_add_sinkbin_to_pipeline(mmplayer_t *player, GstElement *sinkbin, GstPad *pad, gboolean reusing, gchar *sink_pad_name)
+{
+       gboolean ret = FALSE;
+       GstElement *pipeline = NULL;
+       GstPad *sinkpad = NULL;
+
        MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(sinkbin && pad, FALSE);
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, FALSE);
+
+       pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst;
+
+       sinkpad = gst_element_get_static_pad(GST_ELEMENT(sinkbin), sink_pad_name);
+       if (!sinkpad) {
+               LOGE("failed to get pad from sinkbin");
+               goto EXIT;
+       }
+
+       if (reusing) {
+               /* link only */
+               if (gst_pad_link(pad, sinkpad) != GST_PAD_LINK_OK) {
+                       LOGE("failed to link sinkbin for reusing");
+                       goto EXIT; /* exit either pass or fail */
+               }
+       } else {
+               /* warm up */
+               if (gst_element_set_state(sinkbin, GST_STATE_READY) == GST_STATE_CHANGE_FAILURE) {
+                       LOGE("failed to set state(READY) to sinkbin");
+                       goto EXIT;
+               }
+
+               /* add */
+               if (!gst_bin_add(GST_BIN(pipeline), sinkbin)) {
+                       LOGE("failed to add sinkbin to pipeline");
+                       goto EXIT;
+               }
+
+               /* link */
+               if (gst_pad_link(pad, sinkpad) != GST_PAD_LINK_OK) {
+                       LOGE("failed to link %s:%s - %s:%s", GST_DEBUG_PAD_NAME(pad), GST_DEBUG_PAD_NAME(sinkpad));
+                       goto EXIT;
+               }
+
+               /* run */
+               if (gst_element_set_state(sinkbin, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
+                       LOGE("failed to set state(PAUSED) to sinkbin");
+                       goto EXIT;
+               }
+       }
+
+       ret = TRUE;
+
+EXIT:
+       if (sinkpad)
+               gst_object_unref(GST_OBJECT(sinkpad));
+       sinkpad = NULL;
+
+       MMPLAYER_FLEAVE();
+       return ret;
 }
 
 static void
-__mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data)
+__mmplayer_gst_create_sinkbin(GstElement *elem, GstPad *pad, gpointer data)
 {
-       mm_player_t *player = NULL;
-       MMHandleType attrs = 0;
-       GstElement *pipeline = NULL;
+       mmplayer_t *player = NULL;
        GstCaps *caps = NULL;
        gchar *caps_str = NULL;
        GstStructure *str = NULL;
        const gchar *name = NULL;
-       GstPad *sinkpad = NULL;
        GstElement *sinkbin = NULL;
        gboolean reusing = FALSE;
-       GstElement *text_selector = NULL;
        gboolean caps_ret = TRUE;
+       gchar *sink_pad_name = "sink";
 
        /* check handles */
-       player = (mm_player_t*) data;
+       player = (mmplayer_t *)data;
 
+       MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(elem && pad);
-       MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->mainbin);
-
-       pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst;
-
-       attrs = MMPLAYER_GET_ATTRS(player);
-       if (!attrs) {
-               LOGE("cannot get content attribute\n");
-               goto ERROR;
-       }
+       MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && MMPLAYER_GET_ATTRS(player));
 
        MMPLAYER_GST_GET_CAPS_INFO(pad, caps, str, name, caps_ret);
        if (!caps_ret)
@@ -1575,204 +1523,98 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data)
        /* LOGD("detected mimetype : %s", name); */
        if (strstr(name, "audio")) {
                if (player->pipeline->audiobin == NULL) {
-                       if (__mmplayer_gst_create_audio_pipeline(player) != MM_ERROR_NONE) {
-                               LOGE("failed to create audiobin. continuing without audio\n");
+                       const gchar *audio_format = gst_structure_get_string(str, "format");
+                       if (audio_format) {
+                               LOGD("original audio format %s", audio_format);
+                               mm_attrs_set_string_by_name(player->attrs, "content_audio_format", audio_format);
+                       }
+
+                       if (__mmplayer_gst_create_audio_sink_bin(player) != MM_ERROR_NONE) {
+                               LOGE("failed to create audiobin. continuing without audio");
                                goto ERROR;
                        }
 
                        sinkbin = player->pipeline->audiobin[MMPLAYER_A_BIN].gst;
-                       LOGD("creating audiosink bin success");
+                       LOGD("creating audiobin success");
                } else {
                        reusing = TRUE;
                        sinkbin = player->pipeline->audiobin[MMPLAYER_A_BIN].gst;
-                       LOGD("reusing audiobin\n");
+                       LOGD("reusing audiobin");
                        __mmplayer_update_content_attrs(player, ATTR_AUDIO);
                }
-
-               if (player->selector[MM_PLAYER_TRACK_TYPE_AUDIO].total_track_num <= 0) // should not update if content have multi audio tracks
-                       mm_attrs_set_int_by_name(attrs, "content_audio_track_num", 1);
-
-               player->audiosink_linked  = 1;
-
-               sinkpad = gst_element_get_static_pad(GST_ELEMENT(sinkbin), "sink");
-               if (!sinkpad) {
-                       LOGE("failed to get pad from sinkbin\n");
-                       goto ERROR;
-               }
        } else if (strstr(name, "video")) {
-               if (caps_str && (strstr(caps_str, "ST12") || strstr(caps_str, "SN12") ||
-                       strstr(caps_str, "SN21") || strstr(caps_str, "S420") || strstr(caps_str, "SR32")))
-                       player->set_mode.video_zc = TRUE;
-
+               /* 1. zero copy is updated at _decode_pad_added()
+                * 2. NULL surface type is handled in _decode_pad_added() */
+               LOGD("zero copy %d", player->set_mode.video_zc);
                if (player->pipeline->videobin == NULL) {
-                       /* NOTE : not make videobin because application dose not want to play it even though file has video stream. */
-                       /* get video surface type */
                        int surface_type = 0;
                        mm_attrs_get_int_by_name(player->attrs, "display_surface_type", &surface_type);
                        LOGD("display_surface_type (%d)", surface_type);
 
-                       if (surface_type == MM_DISPLAY_SURFACE_NULL) {
-                               LOGD("surface_type is NULL");
-                               goto ERROR;
-                       }
-
-                       if (surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                               /* mark video overlay for acquire */
-                               if (player->video_overlay_resource == NULL) {
-                                       if (mm_resource_manager_mark_for_acquire(player->resource_manager,
-                                                       MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY,
-                                                       MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
-                                                       &player->video_overlay_resource)
-                                                       != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                                               LOGE("could not mark video_overlay resource for acquire\n");
-                                               goto ERROR;
-                                       }
+                       if (surface_type == MM_DISPLAY_SURFACE_OVERLAY && player->video_overlay_resource == NULL) {
+                               LOGD("mark video overlay for acquire");
+                               if (mm_resource_manager_mark_for_acquire(player->resource_manager,
+                                               MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY,
+                                               MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
+                                               &player->video_overlay_resource)
+                                               != MM_RESOURCE_MANAGER_ERROR_NONE) {
+                                       LOGE("could not mark video_overlay resource for acquire");
+                                       goto ERROR;
                                }
                        }
 
                        player->interrupted_by_resource = FALSE;
-                       /* acquire resources for video overlay */
+
                        if (mm_resource_manager_commit(player->resource_manager) !=
                                        MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               LOGE("could not acquire resources for video playing\n");
+                               LOGE("could not acquire resources for video playing");
                                goto ERROR;
                        }
 
-                       if (MM_ERROR_NONE !=  __mmplayer_gst_create_video_pipeline(player, caps, surface_type)) {
-                               LOGE("failed to create videobin. continuing without video\n");
+                       if (__mmplayer_gst_create_video_sink_bin(player, caps, surface_type) != MM_ERROR_NONE) {
+                               LOGE("failed to create videobin. continuing without video");
                                goto ERROR;
                        }
 
                        sinkbin = player->pipeline->videobin[MMPLAYER_V_BIN].gst;
-                       LOGD("creating videosink bin success\n");
+                       LOGD("creating videosink bin success");
                } else {
                        reusing = TRUE;
                        sinkbin = player->pipeline->videobin[MMPLAYER_V_BIN].gst;
-                       LOGD("re-using videobin\n");
+                       LOGD("re-using videobin");
                        __mmplayer_update_content_attrs(player, ATTR_VIDEO);
                }
-
-               player->videosink_linked  = 1;
-
-               sinkpad = gst_element_get_static_pad(GST_ELEMENT(sinkbin), "sink");
-               if (!sinkpad) {
-                       LOGE("failed to get pad from sinkbin\n");
-                       goto ERROR;
-               }
        } else if (strstr(name, "text")) {
                if (player->pipeline->textbin == NULL) {
-                       MMPlayerGstElement* mainbin = NULL;
-
-                       if (MM_ERROR_NONE !=  __mmplayer_gst_create_text_sink_bin(player)) {
-                               LOGE("failed to create text sink bin. continuing without text\n");
+                       if (__mmplayer_gst_create_text_sink_bin(player) != MM_ERROR_NONE) {
+                               LOGE("failed to create text sink bin. continuing without text");
                                goto ERROR;
                        }
 
                        sinkbin = player->pipeline->textbin[MMPLAYER_T_BIN].gst;
-                       LOGD("creating textsink bin success\n");
-
-                       /* FIXIT : track number shouldn't be hardcoded */
-                       mm_attrs_set_int_by_name(attrs, "content_text_track_num", 1);
-
                        player->textsink_linked  = 1;
-                       LOGI("player->textsink_linked set to 1\n");
-
-                       sinkpad = gst_element_get_static_pad(GST_ELEMENT(sinkbin), "text_sink");
-                       if (!sinkpad) {
-                               LOGE("failed to get pad from sinkbin\n");
-                               goto ERROR;
-                       }
-
-                       mainbin = player->pipeline->mainbin;
-
-                       if (!mainbin[MMPLAYER_M_T_INPUT_SELECTOR].gst) {
-                               /* input selector */
-                               text_selector = gst_element_factory_make("input-selector", "subtitle_inselector");
-                               if (!text_selector) {
-                                       LOGE("failed to create subtitle input selector element\n");
-                                       goto ERROR;
-                               }
-                               g_object_set(text_selector, "sync-streams", TRUE, NULL);
-
-                               mainbin[MMPLAYER_M_T_INPUT_SELECTOR].id = MMPLAYER_M_T_INPUT_SELECTOR;
-                               mainbin[MMPLAYER_M_T_INPUT_SELECTOR].gst = text_selector;
-
-                               /* warm up */
-                               if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(text_selector, GST_STATE_READY)) {
-                                       LOGE("failed to set state(READY) to sinkbin\n");
-                                       goto ERROR;
-                               }
-
-                               if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), text_selector)) {
-                                       LOGW("failed to add subtitle input selector\n");
-                                       goto ERROR;
-                               }
-
-                               LOGD("created element input-selector");
-
-                       } else {
-                               LOGD("already having subtitle input selector");
-                               text_selector = mainbin[MMPLAYER_M_T_INPUT_SELECTOR].gst;
-                       }
+                       LOGD("creating textsink bin success");
                } else {
                        if (!player->textsink_linked) {
-                               LOGD("re-using textbin\n");
-
+                               LOGD("re-using textbin");
                                reusing = TRUE;
                                sinkbin = player->pipeline->textbin[MMPLAYER_T_BIN].gst;
-
                                player->textsink_linked  = 1;
-                               LOGI("player->textsink_linked set to 1\n");
-                       } else
-                               LOGD("ignoring internal subtutle since external subtitle is available");
+                       } else {
+                               /* linked textbin exist which means that the external subtitle path exist already */
+                               LOGW("ignoring internal subtutle since external subtitle is available");
+                       }
                }
+               sink_pad_name = "text_sink";
        } else {
-               LOGW("unknown type of elementary stream!ignoring it...\n");
+               LOGW("unknown mime type %s, ignoring it", name);
                goto ERROR;
        }
 
-       if (sinkbin) {
-               if (!reusing) {
-                       /* warm up */
-                       if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(sinkbin, GST_STATE_READY)) {
-                               LOGE("failed to set state(READY) to sinkbin\n");
-                               goto ERROR;
-                       }
-
-                       /* Added for multi audio support to avoid adding audio bin again*/
-                       /* add */
-                       if (FALSE == gst_bin_add(GST_BIN(pipeline), sinkbin)) {
-                               LOGE("failed to add sinkbin to pipeline\n");
-                               goto ERROR;
-                       }
-               }
-
-               /* link */
-               if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad)) {
-                       LOGE("failed to get pad from sinkbin\n");
-                       goto ERROR;
-               }
-
-               if (!reusing) {
-                       /* run */
-                       if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(sinkbin, GST_STATE_PAUSED)) {
-                               LOGE("failed to set state(PAUSED) to sinkbin\n");
-                               goto ERROR;
-                       }
-
-                       if (text_selector) {
-                               if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(text_selector, GST_STATE_PAUSED)) {
-                                       LOGE("failed to set state(PAUSED) to sinkbin\n");
-                                       goto ERROR;
-                               }
-                       }
-               }
-
-               gst_object_unref(sinkpad);
-               sinkpad = NULL;
-       }
+       if (!__mmplayer_gst_add_sinkbin_to_pipeline(player, sinkbin, pad, reusing, sink_pad_name))
+               goto ERROR;
 
-       LOGD("[handle: %p] linking sink bin success", player);
+       LOGD("[handle: %p] success to create and link sink bin", player);
 
        /* FIXIT : we cannot hold callback for 'no-more-pad' signal because signal was emitted in
         * streaming task. if the task blocked, then buffer will not flow to the next element
@@ -1782,7 +1624,7 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data)
        if (player->num_dynamic_pad)
                player->num_dynamic_pad--;
 
-       LOGD("no more pads: %d stream count dec : %d(num of dynamic pad)\n", player->no_more_pad, player->num_dynamic_pad);
+       LOGD("no more pads: %d, stream count dec : %d(num of dynamic pad)", player->no_more_pad, player->num_dynamic_pad);
 
        if ((player->no_more_pad) && (player->num_dynamic_pad == 0))
                __mmplayer_pipeline_complete(NULL, player);
@@ -1794,18 +1636,11 @@ ERROR:
        if (caps)
                gst_caps_unref(caps);
 
-       if (sinkpad)
-               gst_object_unref(GST_OBJECT(sinkpad));
-
-       /* flusing out new attributes */
-       if (mmf_attrs_commit(attrs))
-               LOGE("failed to comit attributes\n");
-
        return;
 }
 
 static gboolean
-__mmplayer_get_property_value_for_rotation(mm_player_t* player, int display_angle, int orientation, int *value)
+__mmplayer_get_property_value_for_rotation(mmplayer_t *player, int display_angle, int orientation, int *value)
 {
        int required_angle = 0; /* Angle required for straight view */
        int rotation_angle = 0;
@@ -1854,13 +1689,13 @@ __mmplayer_get_property_value_for_rotation(mm_player_t* player, int display_angl
                break;
        }
 
-       LOGD("setting rotation property value : %d", value);
+       LOGD("setting rotation property value : %d", *value);
 
        return TRUE;
 }
 
 int
-__mmplayer_video_param_check_video_sink_bin(mm_player_t* player)
+__mmplayer_video_param_check_video_sink_bin(mmplayer_t *player)
 {
        /* check video sinkbin is created */
        MMPLAYER_RETURN_VAL_IF_FAIL(player &&
@@ -1874,7 +1709,7 @@ __mmplayer_video_param_check_video_sink_bin(mm_player_t* player)
 }
 
 int
-__mmplayer_get_video_angle(mm_player_t* player, int *display_angle, int *orientation)
+__mmplayer_get_video_angle(mmplayer_t *player, int *display_angle, int *orientation)
 {
        int display_rotation = 0;
        gchar *org_orient = NULL;
@@ -1934,7 +1769,7 @@ __mmplayer_get_video_angle(mm_player_t* player, int *display_angle, int *orienta
 }
 
 void
-__mmplayer_video_param_set_display_rotation(mm_player_t* player)
+__mmplayer_video_param_set_display_rotation(mmplayer_t *player)
 {
        int rotation_value = 0;
        int orientations = 0; // current supported angle values are 0, 90, 180, 270
@@ -1954,7 +1789,7 @@ __mmplayer_video_param_set_display_rotation(mm_player_t* player)
 }
 
 void
-__mmplayer_video_param_set_display_visible(mm_player_t* player)
+__mmplayer_video_param_set_display_visible(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
        int visible = 0;
@@ -1973,7 +1808,7 @@ __mmplayer_video_param_set_display_visible(mm_player_t* player)
 }
 
 void
-__mmplayer_video_param_set_display_method(mm_player_t* player)
+__mmplayer_video_param_set_display_method(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
        int display_method = 0;
@@ -1990,8 +1825,9 @@ __mmplayer_video_param_set_display_method(mm_player_t* player)
        g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "display-geometry-method", display_method, NULL);
        LOGD("set video param : method %d", display_method);
 }
+
 void
-__mmplayer_video_param_set_video_roi_area(mm_player_t* player)
+__mmplayer_video_param_set_video_roi_area(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
        void *handle = NULL;
@@ -2016,7 +1852,7 @@ __mmplayer_video_param_set_video_roi_area(mm_player_t* player)
 }
 
 void
-__mmplayer_video_param_set_roi_area(mm_player_t* player)
+__mmplayer_video_param_set_roi_area(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
        void *handle = NULL;
@@ -2053,8 +1889,9 @@ __mmplayer_video_param_set_roi_area(mm_player_t* player)
                        win_roi_x, win_roi_y, win_roi_width, win_roi_height);
        }
 }
+
 void
-__mmplayer_video_param_set_display_overlay(mm_player_t* player)
+__mmplayer_video_param_set_display_overlay(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
        void *handle = NULL;
@@ -2072,21 +1909,21 @@ __mmplayer_video_param_set_display_overlay(mm_player_t* player)
        if (handle) {
                /* default is using wl_surface_id */
                unsigned int wl_surface_id      = 0;
-               wl_surface_id = *(int*)handle;
-               LOGD("set video param : wl_surface_id %d %p", wl_surface_id, *(int*)handle);
+               wl_surface_id = *(int *)handle;
+               LOGD("set video param : wl_surface_id %d", wl_surface_id);
                gst_video_overlay_set_wl_window_wl_surface_id(
                                GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
-                               *(int*)handle);
-       } else
+                               *(int *)handle);
+       } else {
                /* FIXIT : is it error case? */
                LOGW("still we don't have a window handle on player attribute. create it's own surface.");
+       }
 }
 
-
 int
-__mmplayer_update_wayland_videosink_video_param(mm_player_t* player, char *param_name)
+__mmplayer_update_wayland_videosink_video_param(mmplayer_t *player, char *param_name)
 {
-       bool update_all_param = FALSE;
+       gboolean update_all_param = FALSE;
        MMPLAYER_FENTER();
 
        /* check video sinkbin is created */
@@ -2119,7 +1956,7 @@ __mmplayer_update_wayland_videosink_video_param(mm_player_t* player, char *param
 }
 
 int
-_mmplayer_update_video_param(mm_player_t* player, char *param_name)
+_mmplayer_update_video_param(mmplayer_t *player, char *param_name)
 {
        MMHandleType attrs = 0;
        int surface_type = 0;
@@ -2162,7 +1999,7 @@ int
 _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only)
 {
        gboolean disable_overlay = FALSE;
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -2192,7 +2029,7 @@ _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only)
                        ret = mm_resource_manager_mark_for_release(player->resource_manager,
                                        player->video_overlay_resource);
                        if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               LOGE("failed to mark overlay resource for release, ret(0x%x)\n", ret);
+                               LOGE("failed to mark overlay resource for release, ret(0x%x)", ret);
                                goto ERROR;
                        }
                        player->video_overlay_resource = NULL;
@@ -2200,7 +2037,7 @@ _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only)
 
                ret = mm_resource_manager_commit(player->resource_manager);
                if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       LOGE("failed to commit acquiring of overlay resource, ret(0x%x)\n", ret);
+                       LOGE("failed to commit acquiring of overlay resource, ret(0x%x)", ret);
                        goto ERROR;
                }
        } else {
@@ -2211,7 +2048,7 @@ _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only)
                                        MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
                                        &player->video_overlay_resource);
                        if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               LOGE("could not prepare for video_overlay resource\n");
+                               LOGE("could not prepare for video_overlay resource");
                                goto ERROR;
                        }
                }
@@ -2220,7 +2057,7 @@ _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only)
                /* acquire resources for video overlay */
                ret = mm_resource_manager_commit(player->resource_manager);
                if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       LOGE("could not acquire resources for video playing\n");
+                       LOGE("could not acquire resources for video playing");
                        goto ERROR;
                }
 
@@ -2237,7 +2074,7 @@ ERROR:
 int
 _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        gboolean disable_overlay = FALSE;
 
        MMPLAYER_FENTER();
@@ -2255,7 +2092,7 @@ _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only)
 
        g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "disable-overlay", &disable_overlay, NULL);
 
-       *paudio_only = (bool)(disable_overlay);
+       *paudio_only = (bool)disable_overlay;
 
        LOGD("audio_only : %d", *paudio_only);
 
@@ -2265,32 +2102,47 @@ _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only)
 }
 
 int
-__mmplayer_gst_element_link_bucket(GListelement_bucket)
+__mmplayer_gst_element_link_bucket(GList *element_bucket)
 {
-       GList* bucket = element_bucket;
-       MMPlayerGstElement* element = NULL;
-       MMPlayerGstElement* prv_element = NULL;
+       GList *bucket = element_bucket;
+       mmplayer_gst_element_t *element = NULL;
+       mmplayer_gst_element_t *prv_element = NULL;
+       GstElement *tee_element = NULL;
        gint successful_link_count = 0;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(element_bucket, -1);
 
-       prv_element = (MMPlayerGstElement*)bucket->data;
+       prv_element = (mmplayer_gst_element_t *)bucket->data;
        bucket = bucket->next;
 
        for (; bucket; bucket = bucket->next) {
-               element = (MMPlayerGstElement*)bucket->data;
+               element = (mmplayer_gst_element_t *)bucket->data;
 
                if (element && element->gst) {
                        if (prv_element && prv_element->gst) {
+                               if (strstr(GST_ELEMENT_NAME(element->gst), "audio-tee-queue") && strcmp(GST_ELEMENT_NAME(prv_element->gst), "audio-tee")) {
+                                       if (tee_element) {
+                                               prv_element->gst = tee_element;
+                                       } else {
+                                               LOGD("failed to make new audio branch - linking [%s] to [%s] is not supported",
+                                                       GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst)),
+                                                       GST_ELEMENT_NAME(GST_ELEMENT(element->gst)));
+                                               return -1;
+                                       }
+                               }
                                if (gst_element_link(GST_ELEMENT(prv_element->gst), GST_ELEMENT(element->gst))) {
-                                       LOGD("linking [%s] to [%s] success\n",
+                                       LOGD("linking [%s] to [%s] success",
                                                GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst)),
                                                GST_ELEMENT_NAME(GST_ELEMENT(element->gst)));
                                        successful_link_count++;
+                                       if (!strcmp(GST_ELEMENT_NAME(prv_element->gst), "audio-tee")) {
+                                               LOGD("keep audio-tee element for next audio pipeline branch");
+                                               tee_element = prv_element->gst;
+                                       }
                                } else {
-                                       LOGD("linking [%s] to [%s] failed\n",
+                                       LOGD("linking [%s] to [%s] failed",
                                                GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst)),
                                                GST_ELEMENT_NAME(GST_ELEMENT(element->gst)));
                                        return -1;
@@ -2307,10 +2159,10 @@ __mmplayer_gst_element_link_bucket(GList* element_bucket)
 }
 
 int
-__mmplayer_gst_element_add_bucket_to_bin(GstBin* bin, GList* element_bucket)
+__mmplayer_gst_element_add_bucket_to_bin(GstBin *bin, GList *element_bucket)
 {
-       GListbucket = element_bucket;
-       MMPlayerGstElement* element = NULL;
+       GList *bucket = element_bucket;
+       mmplayer_gst_element_t *element = NULL;
        int successful_add_count = 0;
 
        MMPLAYER_FENTER();
@@ -2319,11 +2171,11 @@ __mmplayer_gst_element_add_bucket_to_bin(GstBin* bin, GList* element_bucket)
        MMPLAYER_RETURN_VAL_IF_FAIL(bin, 0);
 
        for (; bucket; bucket = bucket->next) {
-               element = (MMPlayerGstElement*)bucket->data;
+               element = (mmplayer_gst_element_t *)bucket->data;
 
                if (element && element->gst) {
                        if (!gst_bin_add(bin, GST_ELEMENT(element->gst))) {
-                               LOGD("__mmplayer_gst_element_link_bucket : Adding element [%s]  to bin [%s] failed\n",
+                               LOGD("__mmplayer_gst_element_link_bucket : Adding element [%s]  to bin [%s] failed",
                                        GST_ELEMENT_NAME(GST_ELEMENT(element->gst)),
                                        GST_ELEMENT_NAME(GST_ELEMENT(bin)));
                                return 0;
@@ -2337,9 +2189,10 @@ __mmplayer_gst_element_add_bucket_to_bin(GstBin* bin, GList* element_bucket)
        return successful_add_count;
 }
 
-static void __mmplayer_gst_caps_notify_cb(GstPad *pad, GParamSpec *unused, gpointer data)
+static void
+__mmplayer_gst_caps_notify_cb(GstPad *pad, GParamSpec *unused, gpointer data)
 {
-       mm_player_t *player = (mm_player_t*) data;
+       mmplayer_t *player = (mmplayer_t *)data;
        GstCaps *caps = NULL;
        GstStructure *str = NULL;
        const char *name;
@@ -2391,35 +2244,8 @@ ERROR:
        return;
 }
 
-
-
-/**
- * This function is to create audio pipeline for playing.
- *
- * @param      player          [in]    handle of player
- *
- * @return     This function returns zero on success.
- * @remark
- * @see                __mmplayer_gst_create_midi_pipeline, __mmplayer_gst_create_video_pipeline
- */
-/* macro for code readability. just for sinkbin-creation functions */
-#define MMPLAYER_CREATE_ELEMENT(x_bin, x_id, x_factory, x_name, x_add_bucket, x_player) \
-do {\
-       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) {\
-               LOGE("failed to create %s \n", x_factory);\
-               goto ERROR;\
-       } else {\
-               if (x_player->ini.set_dump_element_flag)\
-                       __mmplayer_add_dump_buffer_probe(x_player, x_bin[x_id].gst);\
-       } \
-       if (x_add_bucket)\
-               element_bucket = g_list_append(element_bucket, &x_bin[x_id]);\
-} while (0);
-
 void
-__mmplayer_audio_stream_clear_buffer(mm_player_t* player, gboolean send_all)
+__mmplayer_audio_stream_clear_buffer(mmplayer_t *player, gboolean send_all)
 {
        GList *l = NULL;
 
@@ -2428,15 +2254,14 @@ __mmplayer_audio_stream_clear_buffer(mm_player_t* player, gboolean send_all)
 
        if (player->audio_stream_buff_list) {
                for (l = g_list_first(player->audio_stream_buff_list); l; l = g_list_next(l)) {
-                       mm_player_audio_stream_buff_t *tmp = (mm_player_audio_stream_buff_t *)l->data;
+                       mmplayer_audio_stream_buff_t *tmp = (mmplayer_audio_stream_buff_t *)l->data;
                        if (tmp) {
                                if (send_all) {
                                        LOGD("[%"G_GUINT64_FORMAT"] send remained data.", tmp->channel_mask);
                                        __mmplayer_audio_stream_send_data(player, tmp);
                                }
-                               if (tmp->pcm_data)
-                                       g_free(tmp->pcm_data);
-                               g_free(tmp);
+                               MMPLAYER_FREEIF(tmp->pcm_data);
+                               MMPLAYER_FREEIF(tmp);
                        }
                }
                g_list_free(player->audio_stream_buff_list);
@@ -2447,12 +2272,12 @@ __mmplayer_audio_stream_clear_buffer(mm_player_t* player, gboolean send_all)
 }
 
 static void
-__mmplayer_audio_stream_send_data(mm_player_t* player, mm_player_audio_stream_buff_t *a_buffer)
+__mmplayer_audio_stream_send_data(mmplayer_t *player, mmplayer_audio_stream_buff_t *a_buffer)
 {
-       MMPlayerAudioStreamDataType audio_stream = { 0, };
+       mmplayer_audio_decoded_data_info_t audio_stream = { 0, };
 
        MMPLAYER_FENTER();
-       MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb);
+       MMPLAYER_RETURN_IF_FAIL(player && player->audio_decoded_cb);
 
        audio_stream.bitrate = a_buffer->bitrate;
        audio_stream.channel = a_buffer->channel;
@@ -2461,18 +2286,19 @@ __mmplayer_audio_stream_send_data(mm_player_t* player, mm_player_audio_stream_bu
        audio_stream.channel_mask = a_buffer->channel_mask;
        audio_stream.data_size = a_buffer->data_size;
        audio_stream.data = a_buffer->pcm_data;
+       audio_stream.pcm_format = a_buffer->pcm_format;
 
-       /* LOGD("[%"G_GUINT64_FORMAT"] send data size:%d, %p", audio_stream.channel_mask, audio_stream.data_size, player->audio_stream_cb_user_param); */
-       player->audio_stream_render_cb(&audio_stream, player->audio_stream_cb_user_param);
+       /* LOGD("[%"G_GUINT64_FORMAT"] send data size:%d, %p", audio_stream.channel_mask, audio_stream.data_size, player->audio_decoded_cb_user_param); */
+       player->audio_decoded_cb(&audio_stream, player->audio_decoded_cb_user_param);
 
        MMPLAYER_FLEAVE();
 }
 
 static void
-__mmplayer_audio_stream_decoded_render_cb(GstElementobject, GstBuffer *buffer, GstPad *pad, gpointer data)
+__mmplayer_audio_stream_decoded_render_cb(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*) data;
-
+       mmplayer_t *player = (mmplayer_t *)data;
+       const gchar *pcm_format = NULL;
        gint channel = 0;
        gint rate = 0;
        gint depth = 0;
@@ -2480,12 +2306,12 @@ __mmplayer_audio_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
        guint64 channel_mask = 0;
        void *a_data = NULL;
        gint a_size = 0;
-       mm_player_audio_stream_buff_t *a_buffer = NULL;
+       mmplayer_audio_stream_buff_t *a_buffer = NULL;
        GstMapInfo mapinfo = GST_MAP_INFO_INIT;
        GList *l = NULL;
 
        MMPLAYER_FENTER();
-       MMPLAYER_RETURN_IF_FAIL(player && player->audio_stream_render_cb);
+       MMPLAYER_RETURN_IF_FAIL(player && player->audio_decoded_cb);
 
        gst_buffer_map(buffer, &mapinfo, GST_MAP_READ);
        a_data = mapinfo.data;
@@ -2495,6 +2321,7 @@ __mmplayer_audio_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
        GstStructure *structure = gst_caps_get_structure(caps, 0);
 
        /* MMPLAYER_LOG_GST_CAPS_TYPE(caps); */
+       pcm_format = gst_structure_get_string(structure, "format");
        gst_structure_get_int(structure, "rate", &rate);
        gst_structure_get_int(structure, "channels", &channel);
        gst_structure_get_int(structure, "depth", &depth);
@@ -2506,7 +2333,7 @@ __mmplayer_audio_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
         * The num of buffer list depends on the num of audio channels */
        if (player->audio_stream_buff_list) {
                for (l = g_list_first(player->audio_stream_buff_list); l; l = g_list_next(l)) {
-                       mm_player_audio_stream_buff_t *tmp = (mm_player_audio_stream_buff_t *)l->data;
+                       mmplayer_audio_stream_buff_t *tmp = (mmplayer_audio_stream_buff_t *)l->data;
                        if (tmp) {
                                if (channel_mask == tmp->channel_mask) {
                                        /* LOGD("[%"G_GUINT64_FORMAT"] total: %d, data: %d, buffer: %d", channel_mask, tmp->data_size, a_size, tmp->buff_size); */
@@ -2539,8 +2366,8 @@ __mmplayer_audio_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
                }
        }
 
-       /* create new audio stream data */
-       a_buffer = (mm_player_audio_stream_buff_t*)g_malloc0(sizeof(mm_player_audio_stream_buff_t));
+       /* create new audio stream data for newly found audio channel */
+       a_buffer = (mmplayer_audio_stream_buff_t *)g_try_malloc0(sizeof(mmplayer_audio_stream_buff_t));
        if (a_buffer == NULL) {
                LOGE("failed to alloc data.");
                goto DONE;
@@ -2548,17 +2375,18 @@ __mmplayer_audio_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
        a_buffer->bitrate = rate;
        a_buffer->channel = channel;
        a_buffer->depth = depth;
-       a_buffer->is_little_endian = (endianness == 1234 ? 1 : 0);
+       a_buffer->is_little_endian = (endianness == 1234 ? true : false);
        a_buffer->channel_mask = channel_mask;
        a_buffer->data_size = a_size;
+       a_buffer->pcm_format = util_convert_audio_pcm_str_to_media_format_mime(pcm_format);
 
-       if (!player->audio_stream_sink_sync) {
+       if (player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK) {
                /* If sync is FALSE, use buffer list to reduce the IPC. */
                a_buffer->buff_size = (a_size > player->ini.pcm_buffer_size) ? (a_size) : (player->ini.pcm_buffer_size);
-               a_buffer->pcm_data = g_malloc(a_buffer->buff_size);
+               a_buffer->pcm_data = g_try_malloc(a_buffer->buff_size);
                if (a_buffer->pcm_data == NULL) {
                        LOGE("failed to alloc data.");
-                       g_free(a_buffer);
+                       MMPLAYER_FREEIF(a_buffer);
                        goto DONE;
                }
                memcpy(a_buffer->pcm_data, a_data, a_size);
@@ -2568,7 +2396,7 @@ __mmplayer_audio_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
                /* If sync is TRUE, send data directly. */
                a_buffer->pcm_data = a_data;
                __mmplayer_audio_stream_send_data(player, a_buffer);
-               g_free(a_buffer);
+               MMPLAYER_FREEIF(a_buffer);
        }
 
 DONE:
@@ -2579,9 +2407,9 @@ DONE:
 static void
 __mmplayer_gst_audio_deinterleave_pad_added(GstElement *elem, GstPad *pad, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*)data;
-       MMPlayerGstElement* audiobin = player->pipeline->audiobin;
-       GstPadsinkpad = NULL;
+       mmplayer_t *player = (mmplayer_t *)data;
+       mmplayer_gst_element_t *audiobin = player->pipeline->audiobin;
+       GstPad *sinkpad = NULL;
        GstElement *queue = NULL, *sink = NULL;
 
        MMPLAYER_FENTER();
@@ -2589,36 +2417,43 @@ __mmplayer_gst_audio_deinterleave_pad_added(GstElement *elem, GstPad *pad, gpoin
 
        queue = gst_element_factory_make("queue", NULL);
        if (queue == NULL) {
-               LOGD("fail make queue\n");
+               LOGD("fail make queue");
                goto ERROR;
        }
 
        sink = gst_element_factory_make("fakesink", NULL);
        if (sink == NULL) {
-               LOGD("fail make fakesink\n");
+               LOGD("fail make fakesink");
                goto ERROR;
        }
 
        gst_bin_add_many(GST_BIN(audiobin[MMPLAYER_A_BIN].gst), queue, sink, NULL);
 
        if (!gst_element_link_pads_full(queue, "src", sink, "sink", GST_PAD_LINK_CHECK_NOTHING)) {
-               LOGW("failed to link queue & sink\n");
+               LOGW("failed to link queue & sink");
                goto ERROR;
        }
 
        sinkpad = gst_element_get_static_pad(queue, "sink");
 
        if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad)) {
-               LOGW("failed to link [%s:%s] to queue\n", GST_DEBUG_PAD_NAME(pad));
+               LOGW("failed to link [%s:%s] to queue", GST_DEBUG_PAD_NAME(pad));
                goto ERROR;
        }
 
-       LOGE("player->audio_stream_sink_sync: %d\n", player->audio_stream_sink_sync);
+       LOGE("audio_extract_opt : 0x%X", player->audio_extract_opt);
 
        gst_object_unref(sinkpad);
-       g_object_set(sink, "sync", player->audio_stream_sink_sync, NULL);
+       if (!(player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK))
+               g_object_set(sink, "sync", TRUE, NULL);
        g_object_set(sink, "signal-handoffs", TRUE, NULL);
 
+       /* keep the first sink reference only */
+       if (!audiobin[MMPLAYER_A_SINK].gst) {
+               audiobin[MMPLAYER_A_SINK].id = MMPLAYER_A_SINK;
+               audiobin[MMPLAYER_A_SINK].gst = sink;
+       }
+
        gst_element_set_state(sink, GST_STATE_PAUSED);
        gst_element_set_state(queue, GST_STATE_PAUSED);
 
@@ -2629,11 +2464,13 @@ __mmplayer_gst_audio_deinterleave_pad_added(GstElement *elem, GstPad *pad, gpoin
                G_CALLBACK(__mmplayer_audio_stream_decoded_render_cb),
                (gpointer)player);
 
+       __mmplayer_add_sink(player, sink);
+
        MMPLAYER_FLEAVE();
        return;
 
 ERROR:
-       LOGE("__mmplayer_gst_audio_deinterleave_pad_added ERROR\n");
+       LOGE("__mmplayer_gst_audio_deinterleave_pad_added ERROR");
        if (queue) {
                gst_object_unref(GST_OBJECT(queue));
                queue = NULL;
@@ -2650,7 +2487,8 @@ ERROR:
        return;
 }
 
-void __mmplayer_gst_set_pulsesink_property(mm_player_t* player, MMHandleType attrs)
+void
+__mmplayer_gst_set_pulsesink_property(mmplayer_t *player)
 {
        #define MAX_PROPS_LEN 128
        gint latency_mode = 0;
@@ -2667,26 +2505,21 @@ void __mmplayer_gst_set_pulsesink_property(mm_player_t* player, MMHandleType att
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->audiobin);
 
-       mm_attrs_get_int_by_name(attrs, "sound_stream_index", &stream_id);
-       mm_attrs_get_string_by_name(attrs, "sound_stream_type", &stream_type);
+       mm_attrs_get_int_by_name(player->attrs, "sound_stream_index", &stream_id);
+       mm_attrs_get_string_by_name(player->attrs, "sound_stream_type", &stream_type);
 
        if (!stream_type) {
                LOGE("stream_type is null.");
        } else {
-               if (player->sound.focus_id)
-                       snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_id=%d",
-                                       stream_type, stream_id, player->sound.focus_id);
-               else
-                       snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d",
-                                       stream_type, stream_id);
+               snprintf(stream_props, sizeof(stream_props) - 1, "props,media.role=%s, media.parent_id=%d",
+                               stream_type, stream_id);
                props = gst_structure_from_string(stream_props, NULL);
                g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "stream-properties", props, NULL);
-               LOGI("stream_type[%s], stream_id[%d], focus_id[%d], result[%s].",
-                       stream_type, stream_id, player->sound.focus_id, stream_props);
+               LOGI("stream_type[%s], stream_id[%d], result[%s].", stream_type, stream_id, stream_props);
                gst_structure_free(props);
        }
 
-       mm_attrs_get_int_by_name(attrs, "sound_latency_mode", &latency_mode);
+       mm_attrs_get_int_by_name(player->attrs, "sound_latency_mode", &latency_mode);
 
        switch (latency_mode) {
        case AUDIO_LATENCY_MODE_LOW:
@@ -2706,14 +2539,15 @@ void __mmplayer_gst_set_pulsesink_property(mm_player_t* player, MMHandleType att
 
        LOGD("audiosink property - latency=%s", latency);
 
-       g_free(latency);
+       MMPLAYER_FREEIF(latency);
 
        MMPLAYER_FLEAVE();
 }
 
-void __mmplayer_gst_set_openalsink_property(mm_player_t* player)
+void
+__mmplayer_gst_set_openalsink_property(mmplayer_t *player)
 {
-       MMPlayerGstElement *audiobin = NULL;
+       mmplayer_gst_element_t *audiobin = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->audiobin);
@@ -2729,8 +2563,8 @@ void __mmplayer_gst_set_openalsink_property(mm_player_t* player)
                        player->video360_pitch_radians <= M_PI_2 &&
                        player->video360_pitch_radians >= -M_PI_2) {
                g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst),
-                               "source-orientation-y", (int) (player->video360_yaw_radians * 180.0 / M_PI),
-                               "source-orientation-x", (int) (player->video360_pitch_radians * 180.0 / M_PI), NULL);
+                               "source-orientation-y", (int)(player->video360_yaw_radians * 180.0 / M_PI),
+                               "source-orientation-x", (int)(player->video360_pitch_radians * 180.0 / M_PI), NULL);
        } else if (player->video360_metadata.init_view_heading || player->video360_metadata.init_view_pitch) {
                g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst),
                                "source-orientation-y", player->video360_metadata.init_view_heading,
@@ -2741,188 +2575,357 @@ void __mmplayer_gst_set_openalsink_property(mm_player_t* player)
 }
 
 static int
-__mmplayer_gst_fill_audio_bucket(mm_player_t *player, GList **bucket)
+__mmplayer_gst_make_audio_playback_sink(mmplayer_t *player, GList **bucket)
 {
-       MMPlayerGstElement *audiobin = NULL;
-       MMHandleType attrs = 0;
-       GList *element_bucket = NULL;
-       GstCaps *acaps = NULL;
+       mmplayer_gst_element_t *audiobin = NULL;
        GstPad *sink_pad = NULL;
+       GstCaps *acaps = NULL;
+       gint channels = 0;
+       int pitch_control = 0;
+       double pitch_value = 1.0;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline &&
                                player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        audiobin = player->pipeline->audiobin;
-       attrs = MMPLAYER_GET_ATTRS(player);
 
-       /* converter */
-       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV, "audioconvert", "audio converter", TRUE, player);
+       LOGD("make element for normal audio playback");
 
-       /* replaygain volume */
-       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_RGVOL, "rgvolume", "audio rgvolume", TRUE, player);
-       if (player->sound.rg_enable)
-               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_RGVOL].gst), "enable-rgvolume", TRUE, NULL);
-       else
-               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_RGVOL].gst), "enable-rgvolume", FALSE, NULL);
+       /* audio bin structure for playback. {} means optional.
+          optional : pitch, audioeq, custom audioeq, openalsink for 360 audio content
+
+        * src - ... - {aconv - pitch} - aconv - rgvolume - resample - volume -
+                       {audioeq} - {custom audioeq} - pulsesink or {aconv - capsfilter - openalsink}
+        */
+
+       /* for pitch control */
+       mm_attrs_multiple_get(player->attrs, NULL,
+                               MM_PLAYER_PITCH_CONTROL, &pitch_control,
+                               MM_PLAYER_PITCH_VALUE, &pitch_value,
+                               NULL);
+
+       LOGD("pitch %d / %1.3f", pitch_control, pitch_value);
+       if (pitch_control && (player->videodec_linked == 0)) {
+               GstElementFactory *factory;
+
+               factory = gst_element_factory_find("pitch");
+               if (factory) {
+                       gst_object_unref(factory);
+
+                       /* converter */
+                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV_PITCH, "audioconvert", "audio convert pitch", *bucket, player);
+
+                       /* pitch */
+                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_PITCH, "pitch", "audio pitch", *bucket, player);
+                       g_object_set(G_OBJECT(audiobin[MMPLAYER_A_PITCH].gst), "pitch", (gdouble)pitch_value, NULL);
+               } else {
+                       LOGW("there is no pitch element");
+               }
+       }
+
+       /* converter */
+       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV, "audioconvert", "audio converter", *bucket, player);
+
+       /* replaygain volume */
+       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_RGVOL, "rgvolume", "audio rgvolume", *bucket, player);
+       if (player->sound.rg_enable)
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_RGVOL].gst), "enable-rgvolume", TRUE, NULL);
+       else
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_RGVOL].gst), "enable-rgvolume", FALSE, NULL);
 
        /* resampler */
-       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_RESAMPLER,  player->ini.audioresampler_element, "audio resampler", TRUE, player);
+       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_RESAMPLER,  player->ini.audioresampler_element, "audio resampler", *bucket, player);
 
-       if (player->audio_stream_render_cb) { /* pcm extraction only, no sound output */
-               gchar *dst_format = NULL;
-               int dst_len = 0;
-               int dst_samplerate = 0;
-               int dst_channels = 0;
-               GstCaps *caps = NULL;
-               char *caps_str = NULL;
+       /* for logical volume control */
+       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_VOL, "volume", "volume", *bucket, player);
+       g_object_set(G_OBJECT(audiobin[MMPLAYER_A_VOL].gst), "volume", player->sound.volume, NULL);
 
-               /* get conf. values */
-               mm_attrs_multiple_get(player->attrs, NULL,
-                                       "pcm_audioformat", &dst_format, &dst_len,
-                                       "pcm_extraction_samplerate", &dst_samplerate,
-                                       "pcm_extraction_channels", &dst_channels,
-                                       NULL);
+       if (player->sound.mute) {
+               LOGD("mute enabled");
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_VOL].gst), "mute", player->sound.mute, NULL);
+       }
 
-               LOGD("pcm info - format: %s(%d), samplerate : %d, channel: %d", dst_format, dst_len, dst_samplerate, dst_channels);
+       mm_attrs_get_int_by_name(player->attrs, "content_audio_channels", &channels);
 
-               /* capsfilter */
-               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CAPS_DEFAULT, "capsfilter", "audio capsfilter", TRUE, player);
-               caps = gst_caps_new_simple("audio/x-raw",
-                               "format", G_TYPE_STRING, dst_format,
-                               "rate", G_TYPE_INT, dst_samplerate,
-                               "channels", G_TYPE_INT, dst_channels,
-                               NULL);
+       /* audio effect element. if audio effect is enabled */
+       if ((strcmp(player->ini.audioeffect_element, ""))
+               && (channels <= 2)
+               && (player->ini.use_audio_effect_preset || player->ini.use_audio_effect_custom)) {
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_FILTER, player->ini.audioeffect_element, "audio effect filter", *bucket, player);
 
-               caps_str = gst_caps_to_string(caps);
-               LOGD("new caps : %s", caps_str);
+               LOGD("audio effect config. bypass = %d, effect type = %d", player->bypass_audio_effect, player->audio_effect_info.effect_type);
 
-               g_object_set(GST_ELEMENT(audiobin[MMPLAYER_A_CAPS_DEFAULT].gst), "caps", caps, NULL);
+               if ((!player->bypass_audio_effect)
+                       && (player->ini.use_audio_effect_preset || player->ini.use_audio_effect_custom)) {
+                       if (player->audio_effect_info.effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) {
+                               if (!_mmplayer_audio_effect_custom_apply(player))
+                                       LOGI("apply audio effect(custom) setting success");
+                       }
+               }
 
-               /* clean */
-               gst_caps_unref(caps);
-               MMPLAYER_FREEIF(caps_str);
+               if ((strcmp(player->ini.audioeffect_element_custom, ""))
+                       && (player->set_mode.rich_audio)) {
+                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_FILTER_SEC, player->ini.audioeffect_element_custom, "audio effect filter custom", *bucket, player);
+               }
+       }
 
-               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_DEINTERLEAVE, "deinterleave", "deinterleave", TRUE, player);
+       /* create audio sink */
+       LOGD("spherical %d, channels %d, ambisonic type %d, format %d, order %d",
+                       player->is_content_spherical, channels, player->video360_metadata.ambisonic_type,
+                       player->video360_metadata.ambisonic_format, player->video360_metadata.ambisonic_order);
 
-               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_DEINTERLEAVE].gst), "keep-positions", TRUE, NULL);
+       /* Note: qtdemux converts audio metadata defaults to openalsink defaults. */
+       if (player->is_360_feature_enabled &&
+               player->is_content_spherical &&
+               channels == 4 &&
+               player->video360_metadata.ambisonic_type == MMFILE_AMBISONIC_TYPE_PERIPHONIC &&
+               player->video360_metadata.ambisonic_format == MMFILE_AMBISONIC_FORMAT_AMB &&
+               player->video360_metadata.ambisonic_order == MMFILE_AMBISONIC_ORDER_FOA) {
 
-               /* raw pad handling signal, audiosink will be added after getting signal */
-               __mmplayer_add_signal_connection(player, G_OBJECT(audiobin[MMPLAYER_A_DEINTERLEAVE].gst),
-                               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added", G_CALLBACK(__mmplayer_gst_audio_deinterleave_pad_added), (gpointer)player);
+               strncpy(player->ini.audiosink_element, "openalsink", PLAYER_INI_MAX_STRLEN - 1);
 
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV_BFORMAT, "audioconvert", "audio-converter-bformat", *bucket, player);
+
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CAPS_360, "capsfilter", "audio-caps-filter", *bucket, player);
+               acaps = gst_caps_from_string(SPATIAL_AUDIO_CAPS);
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_CAPS_360].gst), "caps", acaps, NULL);
+               gst_caps_unref(acaps);
+
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, "openalsink", "audiosink", *bucket, player);
+
+               player->is_openal_plugin_used = TRUE;
        } else {
+               if (player->is_360_feature_enabled && player->is_content_spherical)
+                       LOGW("Audio track isn't of the ambisonic type and can't be played back as a spatial sound.");
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, player->ini.audiosink_element, "audiosink", *bucket, player);
+       }
 
-               /* normal playback */
-               gint channels = 0;
+       if ((MMPLAYER_IS_RTSP_STREAMING(player)) ||
+               (player->videodec_linked && player->ini.use_system_clock)) {
+               LOGD("system clock will be used.");
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "provide-clock", FALSE,  NULL);
+       }
 
-               /* for logical volume control */
-               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_VOL, "volume", "volume", TRUE, player);
-               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_VOL].gst), "volume", player->sound.volume, NULL);
+       if (g_strrstr(player->ini.audiosink_element, "pulsesink"))
+               __mmplayer_gst_set_pulsesink_property(player);
+       else if (g_strrstr(player->ini.audiosink_element, "openalsink"))
+               __mmplayer_gst_set_openalsink_property(player);
 
-               if (player->sound.mute) {
-                       LOGD("mute enabled");
-                       g_object_set(G_OBJECT(audiobin[MMPLAYER_A_VOL].gst), "mute", player->sound.mute, NULL);
-               }
+       /* qos on */
+       g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "qos", TRUE, NULL);       /* qos on */
+       g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "slave-method", GST_AUDIO_BASE_SINK_SLAVE_NONE, NULL);
 
-               /* check if multi-channels */
-               if (player->pipeline->mainbin && player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst) {
-                       GstPad *srcpad = NULL;
-                       GstCaps *caps = NULL;
+       sink_pad = gst_element_get_static_pad(audiobin[MMPLAYER_A_SINK].gst, "sink");
+       __mmplayer_add_signal_connection(player, G_OBJECT(sink_pad), MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
+                               "notify::caps", G_CALLBACK(__mmplayer_gst_caps_notify_cb), (gpointer)player);
+       gst_object_unref(GST_OBJECT(sink_pad));
 
-                       if ((srcpad = gst_element_get_static_pad(player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst, "src"))) {
-                               if ((caps = gst_pad_query_caps(srcpad, NULL))) {
-                                       /* MMPLAYER_LOG_GST_CAPS_TYPE(caps); */
-                                       GstStructure *str = gst_caps_get_structure(caps, 0);
-                                       if (str)
-                                               gst_structure_get_int(str, "channels", &channels);
-                                       gst_caps_unref(caps);
-                               }
-                               gst_object_unref(srcpad);
-                       }
-               }
+       __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst);
 
-               /* audio effect element. if audio effect is enabled */
-               if ((strcmp(player->ini.audioeffect_element, ""))
-                       && (channels <= 2)
-                       && (player->ini.use_audio_effect_preset || player->ini.use_audio_effect_custom)) {
-                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_FILTER, player->ini.audioeffect_element, "audio effect filter", TRUE, player);
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_NONE;
+
+ERROR: /* MMPLAYER_CREATE_ELEMENT */
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_PLAYER_INTERNAL;
+}
 
-                       LOGD("audio effect config. bypass = %d, effect type  = %d", player->bypass_audio_effect, player->audio_effect_info.effect_type);
+static int
+__mmplayer_gst_make_audio_extract_sink(mmplayer_t *player, GList **bucket)
+{
+       mmplayer_gst_element_t *audiobin = NULL;
+       enum audio_element_id extract_sink_id = MMPLAYER_A_SINK;
 
-                       if ((!player->bypass_audio_effect)
-                               && (player->ini.use_audio_effect_preset || player->ini.use_audio_effect_custom)) {
-                               if (player->audio_effect_info.effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) {
-                                       if (!_mmplayer_audio_effect_custom_apply(player))
-                                               LOGI("apply audio effect(custom) setting success");
-                               }
-                       }
+       gchar *dst_format = NULL;
+       int dst_len = 0;
+       int dst_samplerate = 0;
+       int dst_channels = 0;
+       GstCaps *caps = NULL;
+       char *caps_str = NULL;
 
-                       if ((strcmp(player->ini.audioeffect_element_custom, ""))
-                               && (player->set_mode.rich_audio))
-                               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_FILTER_SEC, player->ini.audioeffect_element_custom, "audio effect filter custom", TRUE, player);
-               }
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline &&
+                               player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-               /* create audio sink */
-               LOGD("360 spherical %d, channels %d, ambisonic type %d, format %d, order %d",
-                               player->is_content_spherical, channels, player->video360_metadata.ambisonic_type,
-                               player->video360_metadata.ambisonic_format, player->video360_metadata.ambisonic_order);
+       audiobin = player->pipeline->audiobin;
 
-               /* Note: qtdemux converts audio metadata defaults to openalsink defaults. */
-               if (player->is_360_feature_enabled &&
-                       player->is_content_spherical &&
-                       channels == 4 &&
-                       player->video360_metadata.ambisonic_type == MMFILE_AMBISONIC_TYPE_PERIPHONIC &&
-                       player->video360_metadata.ambisonic_format == MMFILE_AMBISONIC_FORMAT_AMB &&
-                       player->video360_metadata.ambisonic_order == MMFILE_AMBISONIC_ORDER_FOA) {
+       LOGD("make element for audio extract, option = 0x%X", player->audio_extract_opt);
 
-                       strncpy(player->ini.audiosink_element, "openalsink", PLAYER_INI_MAX_STRLEN - 1);
+       /* audio bin structure according to the mmplayer_audio_extract_opt_e.
 
-                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV_BFORMAT, "audioconvert", "audio-converter-bformat", TRUE, player);
+          [case 1] extract interleave audio pcm without playback
+                               : MM_PLAYER_AUDIO_EXTRACT_DEFAULT (sync)
+                                 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK (non sync)
 
-                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CAPS_360, "capsfilter", "audio-caps-filter", TRUE, player);
-                       acaps = gst_caps_from_string(SPATIAL_AUDIO_CAPS);
-                       g_object_set(G_OBJECT(audiobin[MMPLAYER_A_CAPS_360].gst), "caps", acaps, NULL);
-                       gst_caps_unref(acaps);
+                               * src - ... - aconv - resample - capsfilter - fakesink (sync or not)
 
-                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, "openalsink", "audiosink", TRUE, player);
+          [case 2] deinterleave for each channel without playback
+                               : MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE (sync)
+                                 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_AND_DEINTERLEAVE (non sync)
 
-                       player->is_openal_plugin_used = TRUE;
-               } else {
-                       if (player->is_360_feature_enabled && player->is_content_spherical)
-                               LOGW("Audio track isn't of the ambisonic type and can't be played back as a spatial sound.");
-                       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, player->ini.audiosink_element, "audiosink", TRUE, player);
-               }
+                               * src - ... - aconv - resample - capsfilter - deinterleave - fakesink (sync or not)
+                                                                                                                                                  - fakesink (sync or not)
+                                                                                                                                                  - ...      (sync or not)
+
+          [case 3] [case 1(sync only)] + playback
+                               : MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK
+
+                               * src - ... - tee - queue1 - playback path
+                                                                 - queue2 - [case1 pipeline with sync]
+
+          [case 4] [case 2(sync only)] + playback
+                               : MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE_WITH_PLAYBACK
 
-               if ((MMPLAYER_IS_RTSP_STREAMING(player)) ||
-                       (player->videodec_linked && player->ini.use_system_clock)) {
-                       LOGD("system clock will be used.");
-                       g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "provide-clock", FALSE,  NULL);
+                               * src - ... - tee - queue1 - playback path
+                                                                 - queue2 - [case2 pipeline with sync]
+
+        */
+
+       /* 1. create tee and playback path
+             'tee' should be added at first to copy the decoded stream
+        */
+       if (player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK) {
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_TEE, "tee", "audio-tee", *bucket, player);
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_TEE].gst), "num-src-pads", 2, NULL);
+
+               /* tee - path 1 : for playback path */
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_TEE_Q1, "queue", "audio-tee-queue1", *bucket, player);
+               __mmplayer_gst_make_audio_playback_sink(player, bucket);
+
+               /* tee - path 2 : for extract path */
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_TEE_Q2, "queue", "audio-tee-queue2", *bucket, player);
+               extract_sink_id = MMPLAYER_A_EXTRACT_SINK; /* there is another playback sink */
+       }
+
+       /* if there is tee, 'tee - path 2' is linked here */
+       /* converter */
+       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_EXTRACT_CONV, "audioconvert", "audio-ext-conv", *bucket, player);
+
+       /* resampler */
+       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_EXTRACT_RESAMPLER,  player->ini.audioresampler_element, "audio-ext-resampler", *bucket, player);
+
+       /* 2. decide the extract pcm format */
+       mm_attrs_multiple_get(player->attrs, NULL,
+                               "pcm_audioformat", &dst_format, &dst_len,
+                               "pcm_extraction_samplerate", &dst_samplerate,
+                               "pcm_extraction_channels", &dst_channels,
+                               NULL);
+
+       LOGD("required extract pcm format - format: %s(%d), samplerate : %d, channel: %d",
+                       dst_format, dst_len, dst_samplerate, dst_channels);
+
+       if (dst_format == NULL || dst_len == 0 || dst_samplerate == 0 || dst_channels == 0) {
+               mm_attrs_multiple_get(player->attrs, NULL,
+                                       "content_audio_format", &dst_format, &dst_len, /* get string and len */
+                                       "content_audio_samplerate", &dst_samplerate,
+                                       "content_audio_channels", &dst_channels,
+                                       NULL);
+
+               LOGD("apply the decoded pcm format - format: %s(%d), samplerate : %d, channel: %d",
+                               dst_format, dst_len, dst_samplerate, dst_channels);
+
+               /* If there is no enough information, set it to platform default value. */
+               if (dst_format == NULL || util_convert_audio_pcm_str_to_media_format_mime(dst_format) == MEDIA_FORMAT_MAX) {
+                       LOGD("set platform default format");
+                       dst_format = DEFAULT_PCM_OUT_FORMAT;
                }
+               if (dst_samplerate <= 0) dst_samplerate = DEFAULT_PCM_OUT_SAMPLERATE;
+               if (dst_channels <= 0)   dst_channels = DEFAULT_PCM_OUT_CHANNEL;
+       }
 
-               if (g_strrstr(player->ini.audiosink_element, "pulsesink"))
-                       __mmplayer_gst_set_pulsesink_property(player, attrs);
-               else if (g_strrstr(player->ini.audiosink_element, "openalsink"))
-                       __mmplayer_gst_set_openalsink_property(player);
+       /* 3. create capsfilter */
+       MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_EXTRACT_CAPS, "capsfilter", "audio-ext-caps", *bucket, player);
+       caps = gst_caps_new_simple("audio/x-raw",
+                       "format", G_TYPE_STRING, dst_format,
+                       "rate", G_TYPE_INT, dst_samplerate,
+                       "channels", G_TYPE_INT, dst_channels,
+                       NULL);
+
+       caps_str = gst_caps_to_string(caps);
+       LOGD("new caps : %s", caps_str);
 
-               /* qos on */
-               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "qos", TRUE, NULL);       /* qos on */
-               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "slave-method", GST_AUDIO_BASE_SINK_SLAVE_NONE, NULL);
+       g_object_set(GST_ELEMENT(audiobin[MMPLAYER_A_EXTRACT_CAPS].gst), "caps", caps, NULL);
 
-               sink_pad = gst_element_get_static_pad(audiobin[MMPLAYER_A_SINK].gst, "sink");
-               __mmplayer_add_signal_connection(player, G_OBJECT(sink_pad), MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
-                                       "notify::caps", G_CALLBACK(__mmplayer_gst_caps_notify_cb), (gpointer)player);
-               gst_object_unref(GST_OBJECT(sink_pad));
+       /* clean */
+       gst_caps_unref(caps);
+       MMPLAYER_FREEIF(caps_str);
+
+       /* 4-1. create deinterleave to extract pcm for each channel */
+       if (player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE) {
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_EXTRACT_DEINTERLEAVE, "deinterleave", "deinterleave", *bucket, player);
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_EXTRACT_DEINTERLEAVE].gst), "keep-positions", TRUE, NULL);
+
+               /* audiosink will be added after getting signal for each channel */
+               __mmplayer_add_signal_connection(player, G_OBJECT(audiobin[MMPLAYER_A_EXTRACT_DEINTERLEAVE].gst),
+                               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added", G_CALLBACK(__mmplayer_gst_audio_deinterleave_pad_added), (gpointer)player);
+       } else {
+       /* 4-2. create fakesink to extract interlevaed pcm */
+               LOGD("add audio fakesink for interleaved audio");
+               MMPLAYER_CREATE_ELEMENT(audiobin, extract_sink_id, "fakesink", "fakeaudiosink", *bucket, player);
+               if (!(player->audio_extract_opt & MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK))
+                       g_object_set(G_OBJECT(audiobin[extract_sink_id].gst), "sync", TRUE, NULL);
+               g_object_set(G_OBJECT(audiobin[extract_sink_id].gst), "signal-handoffs", TRUE, NULL);
+
+               __mmplayer_add_signal_connection(player,
+                       G_OBJECT(audiobin[extract_sink_id].gst),
+                       MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
+                       "handoff",
+                       G_CALLBACK(__mmplayer_audio_stream_decoded_render_cb),
+                       (gpointer)player);
+
+               __mmplayer_add_sink(player, audiobin[extract_sink_id].gst);
+       }
+
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_NONE;
+
+ERROR: /* MMPLAYER_CREATE_ELEMENT */
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_PLAYER_INTERNAL;
+}
+
+static int
+__mmplayer_gst_make_audio_bin_element(mmplayer_t *player, GList **bucket)
+{
+       int ret = MM_ERROR_NONE;
+       mmplayer_gst_element_t *audiobin = NULL;
+       GList *element_bucket = NULL;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline &&
+                               player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       audiobin = player->pipeline->audiobin;
+
+       if (player->build_audio_offload) { /* skip all the audio filters */
+               LOGD("create audio offload sink : %s", player->ini.audio_offload_sink_element);
+
+               MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, player->ini.audio_offload_sink_element, "audiosink", element_bucket, player);
+               g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "sync", TRUE,
+                               "volume", player->sound.volume, "mute", player->sound.mute, NULL);
 
                __mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst);
+               goto DONE;
        }
 
+       /* FIXME: need to mention the supportable condition at API reference */
+       if (player->audio_decoded_cb && (!MMPLAYER_IS_RTSP_STREAMING(player)))
+               ret = __mmplayer_gst_make_audio_extract_sink(player, &element_bucket);
+       else
+               ret = __mmplayer_gst_make_audio_playback_sink(player, &element_bucket);
+
+       if (ret != MM_ERROR_NONE)
+               goto ERROR;
+DONE:
+       LOGD("success to make audio bin element");
        *bucket = element_bucket;
 
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;
 
 ERROR:
+       LOGE("failed to make audio bin element");
        g_list_free(element_bucket);
 
        *bucket = NULL;
@@ -2931,10 +2934,10 @@ ERROR:
 }
 
 static int
-__mmplayer_gst_create_audio_pipeline(mm_player_t* player)
+__mmplayer_gst_create_audio_sink_bin(mmplayer_t *player)
 {
-       MMPlayerGstElement *first_element = NULL;
-       MMPlayerGstElement *audiobin = NULL;
+       mmplayer_gst_element_t *first_element = NULL;
+       mmplayer_gst_element_t *audiobin = NULL;
        GstPad *pad = NULL;
        GstPad *ghostpad = NULL;
        GList *element_bucket = NULL;
@@ -2944,7 +2947,7 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player)
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* alloc handles */
-       audiobin = (MMPlayerGstElement*)g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_A_NUM);
+       audiobin = (mmplayer_gst_element_t *)g_try_malloc0(sizeof(mmplayer_gst_element_t) * MMPLAYER_A_NUM);
        if (!audiobin) {
                LOGE("failed to allocate memory for audiobin");
                return MM_ERROR_PLAYER_NO_FREE_SPACE;
@@ -2962,7 +2965,7 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player)
        player->pipeline->audiobin = audiobin;
 
        /* create audio filters and audiosink */
-       if (__mmplayer_gst_fill_audio_bucket(player, &element_bucket) != MM_ERROR_NONE)
+       if (__mmplayer_gst_make_audio_bin_element(player, &element_bucket) != MM_ERROR_NONE)
                goto ERROR;
 
        /* adding created elements to bin */
@@ -2976,7 +2979,7 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player)
                goto ERROR;
 
        /* get first element's sinkpad for creating ghostpad */
-       first_element = (MMPlayerGstElement *)element_bucket->data;
+       first_element = (mmplayer_gst_element_t *)element_bucket->data;
        if (!first_element) {
                LOGE("failed to get first elem");
                goto ERROR;
@@ -3022,7 +3025,7 @@ ERROR:
        for (i = 1; i < MMPLAYER_A_NUM; i++) {
                /* NOTE : skip bin */
                if (audiobin[i].gst) {
-                       GstObjectparent = NULL;
+                       GstObject *parent = NULL;
                        parent = gst_element_get_parent(audiobin[i].gst);
 
                        if (!parent) {
@@ -3044,12 +3047,14 @@ ERROR:
        return MM_ERROR_PLAYER_INTERNAL;
 }
 
-static guint32 _mmplayer_convert_fourcc_string_to_value(const gchar* format_name)
+static guint32
+_mmplayer_convert_fourcc_string_to_value(const gchar *format_name)
 {
        return format_name[0] | (format_name[1] << 8) | (format_name[2] << 16) | (format_name[3] << 24);
 }
 
-int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo)
+int
+_mmplayer_video_stream_release_bo(mmplayer_t *player, void *bo)
 {
        int ret = MM_ERROR_NONE;
        GList *l = NULL;
@@ -3060,7 +3065,7 @@ int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo)
 
        if (player->video_bo_list) {
                for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
-                       mm_player_video_bo_info_t* tmp = (mm_player_video_bo_info_t *)l->data;
+                       mmplayer_video_bo_info_t *tmp = (mmplayer_video_bo_info_t *)l->data;
                        if (tmp && tmp->bo == bo) {
                                tmp->used = FALSE;
                                LOGD("release bo %p", bo);
@@ -3081,7 +3086,7 @@ int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo)
 }
 
 static void
-__mmplayer_video_stream_destroy_bo_list(mm_player_t* player)
+__mmplayer_video_stream_destroy_bo_list(mmplayer_t *player)
 {
        GList *l = NULL;
 
@@ -3092,7 +3097,7 @@ __mmplayer_video_stream_destroy_bo_list(mm_player_t* player)
        if (player->video_bo_list) {
                LOGD("destroy video_bo_list : %d", g_list_length(player->video_bo_list));
                for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
-                       mm_player_video_bo_info_t* tmp = (mm_player_video_bo_info_t *)l->data;
+                       mmplayer_video_bo_info_t *tmp = (mmplayer_video_bo_info_t *)l->data;
                        if (tmp) {
                                if (tmp->bo)
                                        tbm_bo_unref(tmp->bo);
@@ -3109,8 +3114,8 @@ __mmplayer_video_stream_destroy_bo_list(mm_player_t* player)
        return;
 }
 
-static void*
-__mmplayer_video_stream_get_bo(mm_player_t* player, int size)
+static void *
+__mmplayer_video_stream_get_bo(mmplayer_t *player, int size)
 {
        GList *l = NULL;
        MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
@@ -3139,7 +3144,7 @@ __mmplayer_video_stream_get_bo(mm_player_t* player, int size)
                }
 
                for (; idx < player->ini.num_of_video_bo; idx++) {
-                       mm_player_video_bo_info_t* bo_info = g_new(mm_player_video_bo_info_t, 1);
+                       mmplayer_video_bo_info_t *bo_info = g_new(mmplayer_video_bo_info_t, 1);
                        if (!bo_info) {
                                LOGE("Fail to alloc bo_info.");
                                break;
@@ -3147,7 +3152,7 @@ __mmplayer_video_stream_get_bo(mm_player_t* player, int size)
                        bo_info->bo = tbm_bo_alloc(player->bufmgr, size, TBM_BO_DEFAULT);
                        if (!bo_info->bo) {
                                LOGE("Fail to tbm_bo_alloc.");
-                               g_free(bo_info);
+                               MMPLAYER_FREEIF(bo_info);
                                break;
                        }
                        bo_info->used = FALSE;
@@ -3170,7 +3175,7 @@ __mmplayer_video_stream_get_bo(mm_player_t* player, int size)
        while (TRUE) {
                /* get bo from list*/
                for (l = g_list_first(player->video_bo_list); l; l = g_list_next(l)) {
-                       mm_player_video_bo_info_t* tmp = (mm_player_video_bo_info_t *)l->data;
+                       mmplayer_video_bo_info_t *tmp = (mmplayer_video_bo_info_t *)l->data;
                        if (tmp && (tmp->used == FALSE)) {
                                LOGD("found bo %p to use", tmp->bo);
                                tmp->used = TRUE;
@@ -3187,7 +3192,7 @@ __mmplayer_video_stream_get_bo(mm_player_t* player, int size)
                if (player->ini.video_bo_timeout <= 0) {
                        MMPLAYER_VIDEO_BO_WAIT(player);
                } else {
-                       gint64 timeout = g_get_monotonic_time() + player->ini.video_bo_timeout*G_TIME_SPAN_SECOND;
+                       gint64 timeout = g_get_monotonic_time() + player->ini.video_bo_timeout * G_TIME_SPAN_SECOND;
                        ret = MMPLAYER_VIDEO_BO_WAIT_UNTIL(player, timeout);
                }
                continue;
@@ -3195,34 +3200,34 @@ __mmplayer_video_stream_get_bo(mm_player_t* player, int size)
 }
 
 static void
-__mmplayer_video_stream_decoded_preroll_cb(GstElementobject, GstBuffer *buffer, GstPad *pad, gpointer data)
+__mmplayer_video_stream_decoded_preroll_cb(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*)data;
+       mmplayer_t *player = (mmplayer_t *)data;
        MMPLAYER_FENTER();
-       MMPLAYER_RETURN_IF_FAIL(player && player->video_stream_cb);
+       MMPLAYER_RETURN_IF_FAIL(player && player->video_decoded_cb);
 
        /* send prerolled pkt */
-       player->video_stream_prerolled = FALSE;
+       player->video_stream_prerolled = false;
 
        __mmplayer_video_stream_decoded_render_cb(object, buffer, pad, data);
 
        /* not to send prerolled pkt again */
-       player->video_stream_prerolled = TRUE;
+       player->video_stream_prerolled = true;
 }
 
 static void
-__mmplayer_video_stream_decoded_render_cb(GstElementobject, GstBuffer *buffer, GstPad *pad, gpointer data)
+__mmplayer_video_stream_decoded_render_cb(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*)data;
-       MMPlayerVideoStreamDataType *stream = NULL;
+       mmplayer_t *player = (mmplayer_t *)data;
+       mmplayer_video_decoded_data_info_t *stream = NULL;
        GstMemory *mem = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player);
-       MMPLAYER_RETURN_IF_FAIL(player->video_stream_cb);
+       MMPLAYER_RETURN_IF_FAIL(player->video_decoded_cb);
 
        if (player->video_stream_prerolled) {
-               player->video_stream_prerolled = FALSE;
+               player->video_stream_prerolled = false;
                LOGD("skip the prerolled pkt not to send it again");
                return;
        }
@@ -3243,7 +3248,7 @@ __mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
 
        /* check zero-copy */
        if (player->set_mode.video_zc &&
-               player->set_mode.media_packet_video_stream &&
+               player->set_mode.video_export &&
                gst_is_tizen_memory(mem)) {
                __mmplayer_zerocopy_set_stride_elevation_bo(stream, mem);
                stream->internal_buffer = gst_buffer_ref(buffer);
@@ -3255,8 +3260,8 @@ __mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
                        goto ERROR;
        }
 
-       if (!player->video_stream_cb(stream, player->video_stream_cb_user_param)) {
-               LOGE("failed to send video stream data.");
+       if (!player->video_decoded_cb(stream, player->video_decoded_cb_user_param)) {
+               LOGE("failed to send video decoded data.");
                goto ERROR;
        }
 
@@ -3278,14 +3283,14 @@ ERROR:
                if (stream->bo[0])
                        _mmplayer_video_stream_release_bo(player, stream->bo[0]);
        }
-       g_free(stream);
+       MMPLAYER_FREEIF(stream);
        return;
 }
 
 static void
-__mmplayer_gst_set_video360_property(mm_player_t *player)
+__mmplayer_gst_set_video360_property(mmplayer_t *player)
 {
-       MMPlayerGstElement *videobin = NULL;
+       mmplayer_gst_element_t *videobin = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->videobin);
@@ -3330,8 +3335,8 @@ __mmplayer_gst_set_video360_property(mm_player_t *player)
                        player->video360_pitch_radians <= M_PI_2 &&
                        player->video360_pitch_radians >= -M_PI_2) {
                g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
-                               "pose-yaw", (int) (player->video360_yaw_radians * 180.0 / M_PI),
-                               "pose-pitch", (int) (player->video360_pitch_radians * 180.0 / M_PI), NULL);
+                               "pose-yaw", (int)(player->video360_yaw_radians * 180.0 / M_PI),
+                               "pose-pitch", (int)(player->video360_pitch_radians * 180.0 / M_PI), NULL);
        } else if (player->video360_metadata.init_view_heading || player->video360_metadata.init_view_pitch) {
                g_object_set(G_OBJECT(videobin[MMPLAYER_V_360].gst),
                                "pose-yaw", player->video360_metadata.init_view_heading,
@@ -3346,7 +3351,7 @@ __mmplayer_gst_set_video360_property(mm_player_t *player)
 }
 
 static int
-__mmplayer_gst_create_video_filters(mm_player_t *player, MMDisplaySurfaceType surface_type, GList **bucket)
+__mmplayer_gst_create_video_filters(mmplayer_t *player, MMDisplaySurfaceType surface_type, GList **bucket)
 {
        gchar *video_csc = "videoconvert"; /* default colorspace converter */
        GList *element_bucket = NULL;
@@ -3357,7 +3362,7 @@ __mmplayer_gst_create_video_filters(mm_player_t *player, MMDisplaySurfaceType su
        /* create video360 filter */
        if (player->is_360_feature_enabled && player->is_content_spherical) {
                LOGD("create video360 element");
-               MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_360, "video360", "video-360", TRUE, player);
+               MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_360, "video360", "video-360", element_bucket, player);
                __mmplayer_gst_set_video360_property(player);
                goto EXIT;
        }
@@ -3370,10 +3375,7 @@ __mmplayer_gst_create_video_filters(mm_player_t *player, MMDisplaySurfaceType su
        /* in case of sw codec & overlay surface type, except 360 playback.
         * if libav video decoder is selected, videoconvert is required to render the shm wl-buffer which support RGB only via tizenwlsink. */
        LOGD("create video converter: %s", video_csc);
-       MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_CONV, video_csc, "video converter", TRUE, player);
-
-       /* set video rotator */
-       MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_FLIP, "videoflip", "video rotator", TRUE, player);
+       MMPLAYER_CREATE_ELEMENT(player->pipeline->videobin, MMPLAYER_V_CONV, video_csc, "video converter", element_bucket, player);
 
 EXIT:
        *bucket = element_bucket;
@@ -3388,8 +3390,8 @@ ERROR: /* refer MMPLAYER_CREATE_ELEMENT */
        return MM_ERROR_PLAYER_INTERNAL;
 }
 
-static gchar*
-__mmplayer_get_videosink_factory_name(mm_player_t *player, MMDisplaySurfaceType surface_type)
+static gchar *
+__mmplayer_get_videosink_factory_name(mmplayer_t *player, MMDisplaySurfaceType surface_type)
 {
        gchar *factory_name = NULL;
 
@@ -3398,11 +3400,8 @@ __mmplayer_get_videosink_factory_name(mm_player_t *player, MMDisplaySurfaceType
                if (strlen(player->ini.videosink_element_overlay) > 0)
                        factory_name = player->ini.videosink_element_overlay;
                break;
-       case MM_DISPLAY_SURFACE_NULL:
-               if (strlen(player->ini.videosink_element_fake) > 0)
-                       factory_name = player->ini.videosink_element_fake;
-               break;
        case MM_DISPLAY_SURFACE_REMOTE:
+       case MM_DISPLAY_SURFACE_NULL:
                if (strlen(player->ini.videosink_element_fake) > 0)
                        factory_name = player->ini.videosink_element_fake;
                break;
@@ -3416,11 +3415,12 @@ __mmplayer_get_videosink_factory_name(mm_player_t *player, MMDisplaySurfaceType
 }
 
 static int
-__mmplayer_gst_set_videosink_property(mm_player_t *player, MMDisplaySurfaceType surface_type)
+__mmplayer_gst_set_videosink_property(mmplayer_t *player, MMDisplaySurfaceType surface_type)
 {
        gchar *factory_name = NULL;
-       MMPlayerGstElement *videobin = NULL;
+       mmplayer_gst_element_t *videobin = NULL;
        MMHandleType attrs;
+       int gapless = 0;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->videobin, MM_ERROR_PLAYER_NOT_INITIALIZED);
@@ -3434,52 +3434,46 @@ __mmplayer_gst_set_videosink_property(mm_player_t *player, MMDisplaySurfaceType
                return MM_ERROR_PLAYER_INTERNAL;
        }
 
-       if (surface_type == MM_DISPLAY_SURFACE_OVERLAY || surface_type == MM_DISPLAY_SURFACE_REMOTE) {
-               int gapless = 0;
-
-               if (surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                       bool use_tbm = (player->set_mode.video_zc || (player->is_360_feature_enabled && player->is_content_spherical));
-                       LOGD("OVERLAY: selected videosink is %s", factory_name);
-
-                       if (!use_tbm) {
-                               /* support shard memory with S/W codec on HawkP */
-                               if (strncmp(factory_name, "tizenwlsink", strlen(factory_name)) == 0) {
-                                       g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst,
-                                               "use-tbm", use_tbm, NULL);
-                               }
+       LOGD("surface type %d, videosink factory name is %s", surface_type, factory_name);
+       if (surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+               bool use_tbm = (player->set_mode.video_zc || (player->is_360_feature_enabled && player->is_content_spherical));
+               if (!use_tbm) {
+                       /* support shard memory with S/W codec on HawkP */
+                       if (strncmp(factory_name, "tizenwlsink", strlen(factory_name)) == 0) {
+                               g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst,
+                                       "use-tbm", use_tbm, NULL);
                        }
-               } else {
-                       LOGE("REMOTE : add data probe at videosink");
-                       g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
-                                                                                       "sync", TRUE, "max-lateness", FAKE_SINK_MAX_LATENESS, NULL);
                }
+       } else {
+               g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+                                                                               "sync", TRUE, "max-lateness", FAKE_SINK_MAX_LATENESS, NULL);
+       }
 
-               mm_attrs_get_int_by_name(attrs, "gapless_mode", &gapless);
-               if (gapless > 0) {
-                       LOGD("disable last-sample");
-                       g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
-               }
+       mm_attrs_get_int_by_name(attrs, "gapless_mode", &gapless);
+       if (gapless > 0) {
+               LOGD("disable last-sample");
+               g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
+       }
 
-               if (player->set_mode.media_packet_video_stream) {
-                       int enable = 0;
-                       mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
-                       if (enable || (surface_type == MM_DISPLAY_SURFACE_REMOTE))
-                               g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst), "signal-handoffs", TRUE, NULL);
+       if (player->set_mode.video_export) {
+               int enable = 0;
+               mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
+               if (enable || (surface_type == MM_DISPLAY_SURFACE_REMOTE) || (surface_type == MM_DISPLAY_SURFACE_NULL))
+                       g_object_set(G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst), "signal-handoffs", TRUE, NULL);
 
-                       __mmplayer_add_signal_connection(player,
-                                                                       G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
-                                                                       MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
-                                                                       "handoff",
-                                                                       G_CALLBACK(__mmplayer_video_stream_decoded_render_cb),
-                                                                       (gpointer)player);
+               __mmplayer_add_signal_connection(player,
+                                                               G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+                                                               MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
+                                                               "handoff",
+                                                               G_CALLBACK(__mmplayer_video_stream_decoded_render_cb),
+                                                               (gpointer)player);
 
-                       __mmplayer_add_signal_connection(player,
-                                                                       G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
-                                                                       MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
-                                                                       "preroll-handoff",
-                                                                       G_CALLBACK(__mmplayer_video_stream_decoded_preroll_cb),
-                                                                       (gpointer)player);
-               }
+               __mmplayer_add_signal_connection(player,
+                                                               G_OBJECT(player->pipeline->videobin[MMPLAYER_V_SINK].gst),
+                                                               MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
+                                                               "preroll-handoff",
+                                                               G_CALLBACK(__mmplayer_video_stream_decoded_preroll_cb),
+                                                               (gpointer)player);
        }
 
        if (_mmplayer_update_video_param(player, "update_all_param") != MM_ERROR_NONE)
@@ -3501,23 +3495,23 @@ __mmplayer_gst_set_videosink_property(mm_player_t *player, MMDisplaySurfaceType
 }
 
 /**
- * VIDEO PIPELINE
+ * VIDEO BIN
  * - video overlay surface(arm/x86) : tizenwlsink
  */
 static int
-__mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDisplaySurfaceType surface_type)
+__mmplayer_gst_create_video_sink_bin(mmplayer_t *player, GstCaps *caps, MMDisplaySurfaceType surface_type)
 {
        GstPad *pad = NULL;
        GList *element_bucket = NULL;
-       MMPlayerGstElement *first_element = NULL;
-       MMPlayerGstElement *videobin = NULL;
+       mmplayer_gst_element_t *first_element = NULL;
+       mmplayer_gst_element_t *videobin = NULL;
        gchar *videosink_factory_name = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* alloc handles */
-       videobin = (MMPlayerGstElement*)g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_V_NUM);
+       videobin = (mmplayer_gst_element_t *)g_try_malloc0(sizeof(mmplayer_gst_element_t) * MMPLAYER_V_NUM);
        if (!videobin)
                return MM_ERROR_PLAYER_NO_FREE_SPACE;
 
@@ -3535,7 +3529,7 @@ __mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDispl
                goto ERROR;
 
        videosink_factory_name = __mmplayer_get_videosink_factory_name(player, surface_type);
-       MMPLAYER_CREATE_ELEMENT(videobin, MMPLAYER_V_SINK, videosink_factory_name, "videosink", TRUE, player);
+       MMPLAYER_CREATE_ELEMENT(videobin, MMPLAYER_V_SINK, videosink_factory_name, "videosink", element_bucket, player);
 
        /* additional setting for sink plug-in */
        if (__mmplayer_gst_set_videosink_property(player, surface_type) != MM_ERROR_NONE) {
@@ -3559,7 +3553,7 @@ __mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDispl
        }
 
        /* get first element's sinkpad for creating ghostpad */
-       first_element = (MMPlayerGstElement *)element_bucket->data;
+       first_element = (mmplayer_gst_element_t *)element_bucket->data;
        if (!first_element) {
                LOGE("failed to get first element from bucket");
                goto ERROR;
@@ -3603,18 +3597,19 @@ ERROR:
        return MM_ERROR_PLAYER_INTERNAL;
 }
 
-static int __mmplayer_gst_create_plain_text_elements(mm_player_t* player)
+static int
+__mmplayer_gst_create_plain_text_elements(mmplayer_t *player)
 {
        GList *element_bucket = NULL;
-       MMPlayerGstElement *textbin = player->pipeline->textbin;
+       mmplayer_gst_element_t *textbin = player->pipeline->textbin;
 
-       MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_QUEUE, "queue", "text_queue", TRUE, player);
-       MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_IDENTITY, "identity", "text_identity", TRUE, player);
+       MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_QUEUE, "queue", "text_queue", element_bucket, player);
+       MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_IDENTITY, "identity", "text_identity", element_bucket, player);
        g_object_set(G_OBJECT(textbin[MMPLAYER_T_IDENTITY].gst),
                                                        "signal-handoffs", FALSE,
                                                        NULL);
 
-       MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_FAKE_SINK, "fakesink", "text_fakesink", TRUE, player);
+       MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_FAKE_SINK, "fakesink", "text_fakesink", element_bucket, player);
        __mmplayer_add_signal_connection(player,
                                                        G_OBJECT(textbin[MMPLAYER_T_FAKE_SINK].gst),
                                                        MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
@@ -3626,14 +3621,14 @@ static int __mmplayer_gst_create_plain_text_elements(mm_player_t* player)
                                                "signal-handoffs", TRUE, "max-lateness", FAKE_SINK_MAX_LATENESS, NULL);
 
        if (!player->play_subtitle) {
-               LOGD("add textbin sink as sink element of whole pipeline.\n");
+               LOGD("add textbin sink as sink element of whole pipeline.");
                __mmplayer_add_sink(player, GST_ELEMENT(textbin[MMPLAYER_T_FAKE_SINK].gst));
        }
 
        /* adding created elements to bin */
-       LOGD("adding created elements to bin\n");
+       LOGD("adding created elements to bin");
        if (!__mmplayer_gst_element_add_bucket_to_bin(GST_BIN(textbin[MMPLAYER_T_BIN].gst), element_bucket)) {
-               LOGE("failed to add elements\n");
+               LOGE("failed to add elements");
                goto ERROR;
        }
 
@@ -3642,9 +3637,9 @@ static int __mmplayer_gst_create_plain_text_elements(mm_player_t* player)
        GST_OBJECT_FLAG_UNSET(textbin[MMPLAYER_T_FAKE_SINK].gst, GST_ELEMENT_FLAG_SINK);
 
        /* linking elements in the bucket by added order. */
-       LOGD("Linking elements in the bucket by added order.\n");
+       LOGD("Linking elements in the bucket by added order.");
        if (__mmplayer_gst_element_link_bucket(element_bucket) == -1) {
-               LOGE("failed to link elements\n");
+               LOGE("failed to link elements");
                goto ERROR;
        }
 
@@ -3665,12 +3660,12 @@ static int __mmplayer_gst_create_plain_text_elements(mm_player_t* player)
                gst_object_unref(pad);
 
                if (!ghostpad) {
-                       LOGE("failed to create ghostpad of textbin\n");
+                       LOGE("failed to create ghostpad of textbin");
                        goto ERROR;
                }
 
                if (!gst_element_add_pad(textbin[MMPLAYER_T_BIN].gst, ghostpad)) {
-                       LOGE("failed to add ghostpad to textbin\n");
+                       LOGE("failed to add ghostpad to textbin");
                        gst_object_unref(ghostpad);
                        goto ERROR;
                }
@@ -3690,9 +3685,10 @@ ERROR:
        return MM_ERROR_PLAYER_INTERNAL;
 }
 
-static int __mmplayer_gst_create_text_sink_bin(mm_player_t* player)
+static int
+__mmplayer_gst_create_text_sink_bin(mmplayer_t *player)
 {
-       MMPlayerGstElement *textbin = NULL;
+       mmplayer_gst_element_t *textbin = NULL;
        GList *element_bucket = NULL;
        int surface_type = 0;
        gint i = 0;
@@ -3702,9 +3698,9 @@ static int __mmplayer_gst_create_text_sink_bin(mm_player_t* player)
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* alloc handles */
-       textbin = (MMPlayerGstElement*)g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_T_NUM);
+       textbin = (mmplayer_gst_element_t *)g_try_malloc0(sizeof(mmplayer_gst_element_t) * MMPLAYER_T_NUM);
        if (!textbin) {
-               LOGE("failed to allocate memory for textbin\n");
+               LOGE("failed to allocate memory for textbin");
                return MM_ERROR_PLAYER_NO_FREE_SPACE;
        }
 
@@ -3712,7 +3708,7 @@ static int __mmplayer_gst_create_text_sink_bin(mm_player_t* player)
        textbin[MMPLAYER_T_BIN].id = MMPLAYER_T_BIN;
        textbin[MMPLAYER_T_BIN].gst = gst_bin_new("textbin");
        if (!textbin[MMPLAYER_T_BIN].gst) {
-               LOGE("failed to create textbin\n");
+               LOGE("failed to create textbin");
                goto ERROR;
        }
 
@@ -3727,7 +3723,7 @@ static int __mmplayer_gst_create_text_sink_bin(mm_player_t* player)
        case MM_DISPLAY_SURFACE_NULL:
        case MM_DISPLAY_SURFACE_REMOTE:
                if (__mmplayer_gst_create_plain_text_elements(player) != MM_ERROR_NONE) {
-                       LOGE("failed to make plain text elements\n");
+                       LOGE("failed to make plain text elements");
                        goto ERROR;
                }
                break;
@@ -3742,7 +3738,7 @@ static int __mmplayer_gst_create_text_sink_bin(mm_player_t* player)
 
 ERROR:
 
-       LOGD("ERROR : releasing textbin\n");
+       LOGD("ERROR : releasing textbin");
 
        g_list_free(element_bucket);
 
@@ -3753,7 +3749,7 @@ ERROR:
        for (i = 1; i < MMPLAYER_T_NUM; i++) {
                /* NOTE : skip bin */
                if (textbin[i].gst) {
-                       GstObjectparent = NULL;
+                       GstObject *parent = NULL;
                        parent = gst_element_get_parent(textbin[i].gst);
 
                        if (!parent) {
@@ -3776,12 +3772,11 @@ ERROR:
        return MM_ERROR_PLAYER_INTERNAL;
 }
 
-
 static int
-__mmplayer_gst_create_text_pipeline(mm_player_t* player)
+__mmplayer_gst_create_text_pipeline(mmplayer_t *player)
 {
-       MMPlayerGstElement* mainbin = NULL;
-       MMPlayerGstElement* textbin = NULL;
+       mmplayer_gst_element_t *mainbin = NULL;
+       mmplayer_gst_element_t *textbin = NULL;
        MMHandleType attrs = 0;
        GstElement *subsrc = NULL;
        GstElement *subparse = NULL;
@@ -3800,13 +3795,13 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
 
        attrs = MMPLAYER_GET_ATTRS(player);
        if (!attrs) {
-               LOGE("cannot get content attribute\n");
+               LOGE("cannot get content attribute");
                return MM_ERROR_PLAYER_INTERNAL;
        }
 
        mm_attrs_get_string_by_name(attrs, "subtitle_uri", &subtitle_uri);
        if (!subtitle_uri || strlen(subtitle_uri) < 1) {
-               LOGE("subtitle uri is not proper filepath.\n");
+               LOGE("subtitle uri is not proper filepath.");
                return MM_ERROR_PLAYER_INVALID_URI;
        }
 
@@ -3815,7 +3810,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
                return MM_ERROR_PLAYER_INVALID_URI;
        }
 
-       SECURE_LOGD("subtitle file path is [%s].\n", subtitle_uri);
+       SECURE_LOGD("subtitle file path is [%s].", subtitle_uri);
 
        MMPLAYER_SUBTITLE_INFO_LOCK(player);
        player->subtitle_language_list = NULL;
@@ -3824,7 +3819,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
        /* create the subtitle source */
        subsrc = gst_element_factory_make("filesrc", "subtitle_source");
        if (!subsrc) {
-               LOGE("failed to create filesrc element\n");
+               LOGE("failed to create filesrc element");
                goto ERROR;
        }
        g_object_set(G_OBJECT(subsrc), "location", subtitle_uri, NULL);
@@ -3833,7 +3828,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
        mainbin[MMPLAYER_M_SUBSRC].gst = subsrc;
 
        if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), subsrc)) {
-               LOGW("failed to add queue\n");
+               LOGW("failed to add queue");
                gst_object_unref(mainbin[MMPLAYER_M_SUBSRC].gst);
                mainbin[MMPLAYER_M_SUBSRC].gst = NULL;
                mainbin[MMPLAYER_M_SUBSRC].id = MMPLAYER_M_NUM;
@@ -3843,13 +3838,13 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
        /* subparse */
        subparse = gst_element_factory_make("subparse", "subtitle_parser");
        if (!subparse) {
-               LOGE("failed to create subparse element\n");
+               LOGE("failed to create subparse element");
                goto ERROR;
        }
 
        charset = util_get_charset(subtitle_uri);
        if (charset) {
-               LOGD("detected charset is %s\n", charset);
+               LOGD("detected charset is %s", charset);
                g_object_set(G_OBJECT(subparse), "subtitle-encoding", charset, NULL);
        }
 
@@ -3857,7 +3852,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
        mainbin[MMPLAYER_M_SUBPARSE].gst = subparse;
 
        if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), subparse)) {
-               LOGW("failed to add subparse\n");
+               LOGW("failed to add subparse");
                gst_object_unref(mainbin[MMPLAYER_M_SUBPARSE].gst);
                mainbin[MMPLAYER_M_SUBPARSE].gst = NULL;
                mainbin[MMPLAYER_M_SUBPARSE].id = MMPLAYER_M_NUM;
@@ -3865,25 +3860,25 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
        }
 
        if (!gst_element_link_pads(subsrc, "src", subparse, "sink")) {
-               LOGW("failed to link subsrc and subparse\n");
+               LOGW("failed to link subsrc and subparse");
                goto ERROR;
        }
 
        player->play_subtitle = TRUE;
        player->adjust_subtitle_pos = 0;
 
-       LOGD("play subtitle using subtitle file\n");
+       LOGD("play subtitle using subtitle file");
 
        if (player->pipeline->textbin == NULL) {
                if (MM_ERROR_NONE != __mmplayer_gst_create_text_sink_bin(player)) {
-                       LOGE("failed to create text sink bin. continuing without text\n");
+                       LOGE("failed to create text sink bin. continuing without text");
                        goto ERROR;
                }
 
                textbin = player->pipeline->textbin;
 
                if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), GST_ELEMENT(textbin[MMPLAYER_T_BIN].gst))) {
-                       LOGW("failed to add textbin\n");
+                       LOGW("failed to add textbin");
 
                        /* release signal */
                        __mmplayer_release_signal_connection(player, MM_PLAYER_SIGNAL_TYPE_TEXTBIN);
@@ -3899,7 +3894,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
 
                player->textsink_linked = 1;
                player->external_text_idx = 0;
-               LOGI("player->textsink_linked set to 1\n");
+               LOGI("textsink is linked");
        } else {
                textbin = player->pipeline->textbin;
                LOGD("text bin has been created. reuse it.");
@@ -3907,7 +3902,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player)
        }
 
        if (!gst_element_link_pads(subparse, "src", textbin[MMPLAYER_T_BIN].gst, "text_sink")) {
-               LOGW("failed to link subparse and textbin\n");
+               LOGW("failed to link subparse and textbin");
                goto ERROR;
        }
 
@@ -3954,9 +3949,9 @@ ERROR:
 }
 
 gboolean
-__mmplayer_update_subtitle(GstElementobject, GstBuffer *buffer, GstPad *pad, gpointer data)
+__mmplayer_update_subtitle(GstElement *object, GstBuffer *buffer, GstPad *pad, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*) data;
+       mmplayer_t *player = (mmplayer_t *)data;
        MMMessageParamType msg = {0, };
        GstClockTime duration = 0;
        gpointer text = NULL;
@@ -3977,22 +3972,32 @@ __mmplayer_update_subtitle(GstElement* object, GstBuffer *buffer, GstPad *pad, g
        gst_buffer_map(buffer, &mapinfo, GST_MAP_READ);
        text = mapinfo.data;
        text_size = mapinfo.size;
-       duration = GST_BUFFER_DURATION(buffer);
 
        if (player->set_mode.subtitle_off) {
-               LOGD("subtitle is OFF.\n");
+               LOGD("subtitle is OFF.");
                return TRUE;
        }
 
        if (!text || (text_size == 0)) {
-               LOGD("There is no subtitle to be displayed.\n");
+               LOGD("There is no subtitle to be displayed.");
                return TRUE;
        }
 
-       msg.data = (void *) text;
+       msg.data = (void *)text;
+
+       duration = GST_BUFFER_DURATION(buffer);
+
+       if (!GST_CLOCK_TIME_IS_VALID(duration)) {
+               if (player->duration > GST_BUFFER_PTS(buffer))
+                       duration = player->duration - GST_BUFFER_PTS(buffer);
+               else
+                       duration = 0;
+               LOGI("subtitle duration is invalid, subtitle duration change "
+                       "GST_CLOCK_TIME_NONE -> %" GST_TIME_FORMAT, GST_TIME_ARGS(duration));
+       }
        msg.subtitle.duration = GST_TIME_AS_MSECONDS(duration);
 
-       LOGD("update subtitle : [%ld msec] %s\n'", msg.subtitle.duration, (char*)msg.data);
+       LOGD("update subtitle : [%ld msec] %s", msg.subtitle.duration, (char *)msg.data);
 
        MMPLAYER_POST_MSG(player, MM_MESSAGE_UPDATE_SUBTITLE, &msg);
        gst_buffer_unmap(buffer, &mapinfo);
@@ -4005,7 +4010,7 @@ __mmplayer_update_subtitle(GstElement* object, GstBuffer *buffer, GstPad *pad, g
 static GstPadProbeReturn
 __mmplayer_subtitle_adjust_position_probe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
 {
-       mm_player_t *player = (mm_player_t *) u_data;
+       mmplayer_t *player = (mmplayer_t *)u_data;
        GstClockTime cur_timestamp = 0;
        gint64 adjusted_timestamp = 0;
        GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
@@ -4013,7 +4018,7 @@ __mmplayer_subtitle_adjust_position_probe(GstPad *pad, GstPadProbeInfo *info, gp
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
        if (player->set_mode.subtitle_off) {
-               LOGD("subtitle is OFF.\n");
+               LOGD("subtitle is OFF.");
                return TRUE;
        }
 
@@ -4023,7 +4028,7 @@ __mmplayer_subtitle_adjust_position_probe(GstPad *pad, GstPadProbeInfo *info, gp
        }
 
        cur_timestamp = GST_BUFFER_TIMESTAMP(buffer);
-       adjusted_timestamp = (gint64) cur_timestamp +((gint64) player->adjust_subtitle_pos * G_GINT64_CONSTANT(1000000));
+       adjusted_timestamp = (gint64)cur_timestamp + ((gint64)player->adjust_subtitle_pos * G_GINT64_CONSTANT(1000000));
 
        if (adjusted_timestamp < 0) {
                LOGD("adjusted_timestamp under zero");
@@ -4038,7 +4043,9 @@ __mmplayer_subtitle_adjust_position_probe(GstPad *pad, GstPadProbeInfo *info, gp
 
        return GST_PAD_PROBE_OK;
 }
-static int __mmplayer_gst_adjust_subtitle_position(mm_player_t* player, int format, int position)
+
+static int
+__mmplayer_gst_adjust_subtitle_position(mmplayer_t *player, int position)
 {
        MMPLAYER_FENTER();
 
@@ -4047,28 +4054,15 @@ static int __mmplayer_gst_adjust_subtitle_position(mm_player_t* player, int form
        MMPLAYER_RETURN_VAL_IF_FAIL(player->play_subtitle, MM_ERROR_NOT_SUPPORT_API);
 
        if (position == 0) {
-               LOGD("nothing to do\n");
+               LOGD("nothing to do");
                MMPLAYER_FLEAVE();
                return MM_ERROR_NONE;
        }
 
-       switch (format) {
-       case MM_PLAYER_POS_FORMAT_TIME:
-               {
-                       /* check current postion */
-                       player->adjust_subtitle_pos = position;
-
-                       LOGD("save adjust_subtitle_pos in player") ;
-               }
-               break;
+       /* check current postion */
+       player->adjust_subtitle_pos = position;
 
-       default:
-               {
-                       LOGW("invalid format.\n");
-                       MMPLAYER_FLEAVE();
-                       return MM_ERROR_INVALID_ARGUMENT;
-               }
-       }
+       LOGD("save adjust_subtitle_pos in player");
 
        MMPLAYER_FLEAVE();
 
@@ -4085,12 +4079,11 @@ static int __mmplayer_gst_adjust_subtitle_position(mm_player_t* player, int form
  * @see
  */
 static int
-__mmplayer_gst_create_pipeline(mm_player_t* player)
+__mmplayer_gst_create_pipeline(mmplayer_t *player)
 {
        int ret = MM_ERROR_NONE;
-       MMPlayerGstElement *mainbin = NULL;
+       mmplayer_gst_element_t *mainbin = NULL;
        MMHandleType attrs = 0;
-       gint mode = MM_PLAYER_PD_MODE_NONE;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
@@ -4108,12 +4101,12 @@ __mmplayer_gst_create_pipeline(mm_player_t* player)
                goto INIT_ERROR;
        }
 
-       player->pipeline = (MMPlayerGstPipelineInfo*) g_malloc0(sizeof(MMPlayerGstPipelineInfo));
+       player->pipeline = (mmplayer_pipeline_info_t *)g_malloc0(sizeof(mmplayer_pipeline_info_t));
        if (player->pipeline == NULL)
                goto INIT_ERROR;
 
        /* create mainbin */
-       mainbin = (MMPlayerGstElement*) g_malloc0(sizeof(MMPlayerGstElement) * MMPLAYER_M_NUM);
+       mainbin = (mmplayer_gst_element_t *)g_try_malloc0(sizeof(mmplayer_gst_element_t) * MMPLAYER_M_NUM);
        if (mainbin == NULL)
                goto INIT_ERROR;
 
@@ -4128,18 +4121,11 @@ __mmplayer_gst_create_pipeline(mm_player_t* player)
 
        player->pipeline->mainbin = mainbin;
 
-       /* check pd mode */
-       mm_attrs_get_int_by_name(attrs, "pd_mode", &mode);
-       player->pd_mode = mode;
-
        /* create the source and decoder elements */
-       if (MMPLAYER_IS_MS_BUFF_SRC(player)) {
+       if (MMPLAYER_IS_MS_BUFF_SRC(player))
                ret = __mmplayer_gst_build_es_pipeline(player);
-       } else if (MMPLAYER_IS_HTTP_STREAMING(player) && MMPLAYER_IS_HTTP_PD(player)) {
-               ret = __mmplayer_gst_build_pd_pipeline(player);
-       } else {
+       else
                ret = __mmplayer_gst_build_pipeline(player);
-       }
 
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to create some elements");
@@ -4147,10 +4133,9 @@ __mmplayer_gst_create_pipeline(mm_player_t* player)
        }
 
        /* Note : check whether subtitle atrribute uri is set. If uri is set, then try to play subtitle file */
-       if (__mmplayer_check_subtitle(player)) {
-               if (__mmplayer_gst_create_text_pipeline(player) != MM_ERROR_NONE)
-                       LOGE("failed to create text pipeline");
-       }
+       if (__mmplayer_check_subtitle(player)
+               && (__mmplayer_gst_create_text_pipeline(player) != MM_ERROR_NONE))
+               LOGE("failed to create text pipeline");
 
        /* add bus watch */
        ret = __mmplayer_gst_add_bus_watch(player);
@@ -4168,7 +4153,7 @@ INIT_ERROR:
 }
 
 static void
-__mmplayer_reset_gapless_state(mm_player_t* player)
+__mmplayer_reset_gapless_state(mmplayer_t *player)
 {
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player
@@ -4176,14 +4161,14 @@ __mmplayer_reset_gapless_state(mm_player_t* player)
                && player->pipeline->audiobin
                && player->pipeline->audiobin[MMPLAYER_A_BIN].gst);
 
-       memset(&player->gapless, 0, sizeof(mm_player_gapless_t));
+       memset(&player->gapless, 0, sizeof(mmplayer_gapless_t));
 
        MMPLAYER_FLEAVE();
        return;
 }
 
 static int
-__mmplayer_gst_destroy_pipeline(mm_player_t* player)
+__mmplayer_gst_destroy_pipeline(mmplayer_t *player)
 {
        gint timeout = 0;
        int ret = MM_ERROR_NONE;
@@ -4194,11 +4179,9 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player)
 
        /* cleanup stuffs */
        MMPLAYER_FREEIF(player->type);
-       player->have_dynamic_pad = FALSE;
        player->no_more_pad = FALSE;
        player->num_dynamic_pad = 0;
        player->demux_pad_index = 0;
-       player->video_hub_download_mode = 0;
 
        MMPLAYER_SUBTITLE_INFO_LOCK(player);
        player->subtitle_language_list = NULL;
@@ -4207,7 +4190,7 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player)
        __mmplayer_reset_gapless_state(player);
 
        if (player->streamer) {
-               __mm_player_streaming_deinitialize(player->streamer);
+               __mm_player_streaming_initialize(player->streamer, FALSE);
                __mm_player_streaming_destroy(player->streamer);
                player->streamer = NULL;
        }
@@ -4222,16 +4205,16 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player)
 
        /* cleanup gst stuffs */
        if (player->pipeline) {
-               MMPlayerGstElement* mainbin = player->pipeline->mainbin;
-               GstTagListtag_list = player->pipeline->tag_list;
+               mmplayer_gst_element_t *mainbin = player->pipeline->mainbin;
+               GstTagList *tag_list = player->pipeline->tag_list;
 
                /* first we need to disconnect all signal hander */
                __mmplayer_release_signal_connection(player, MM_PLAYER_SIGNAL_TYPE_ALL);
 
                if (mainbin) {
-                       MMPlayerGstElement* audiobin = player->pipeline->audiobin;
-                       MMPlayerGstElement* videobin = player->pipeline->videobin;
-                       MMPlayerGstElement* textbin = player->pipeline->textbin;
+                       mmplayer_gst_element_t *audiobin = player->pipeline->audiobin;
+                       mmplayer_gst_element_t *videobin = player->pipeline->videobin;
+                       mmplayer_gst_element_t *textbin = player->pipeline->textbin;
                        GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(mainbin[MMPLAYER_M_PIPE].gst));
                        gst_bus_set_sync_handler(bus, NULL, NULL, NULL);
                        gst_object_unref(bus);
@@ -4239,11 +4222,11 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player)
                        timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player);
                        ret = __mmplayer_gst_set_state(player, mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_NULL, FALSE, timeout);
                        if (ret != MM_ERROR_NONE) {
-                               LOGE("fail to change state to NULL\n");
+                               LOGE("fail to change state to NULL");
                                return MM_ERROR_PLAYER_INTERNAL;
                        }
 
-                       LOGW("succeeded in changing state to NULL\n");
+                       LOGW("succeeded in changing state to NULL");
 
                        gst_object_unref(GST_OBJECT(mainbin[MMPLAYER_M_PIPE].gst));
 
@@ -4262,7 +4245,7 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player)
                }
 
                if (tag_list)
-                       gst_tag_list_free(tag_list);
+                       gst_tag_list_unref(tag_list);
 
                MMPLAYER_FREEIF(player->pipeline);
        }
@@ -4272,6 +4255,7 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player)
                gst_caps_unref(player->v_stream_caps);
                player->v_stream_caps = NULL;
        }
+
        if (player->a_stream_caps) {
                gst_caps_unref(player->a_stream_caps);
                player->a_stream_caps = NULL;
@@ -4292,14 +4276,15 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player)
                player->bufmgr = NULL;
        }
 
-       LOGW("finished destroy pipeline\n");
+       LOGW("finished destroy pipeline");
 
        MMPLAYER_FLEAVE();
 
        return ret;
 }
 
-static int __mmplayer_gst_realize(mm_player_t* player)
+static int
+__mmplayer_gst_realize(mmplayer_t *player)
 {
        gint timeout = 0;
        int ret = MM_ERROR_NONE;
@@ -4312,7 +4297,7 @@ static int __mmplayer_gst_realize(mm_player_t* player)
 
        ret = __mmplayer_gst_create_pipeline(player);
        if (ret) {
-               LOGE("failed to create pipeline\n");
+               LOGE("failed to create pipeline");
                return ret;
        }
 
@@ -4338,7 +4323,8 @@ static int __mmplayer_gst_realize(mm_player_t* player)
        return ret;
 }
 
-static int __mmplayer_gst_unrealize(mm_player_t* player)
+static int
+__mmplayer_gst_unrealize(mmplayer_t *player)
 {
        int ret = MM_ERROR_NONE;
 
@@ -4355,7 +4341,7 @@ static int __mmplayer_gst_unrealize(mm_player_t* player)
        /* destroy pipeline */
        ret = __mmplayer_gst_destroy_pipeline(player);
        if (ret != MM_ERROR_NONE) {
-               LOGE("failed to destory pipeline\n");
+               LOGE("failed to destory pipeline");
                return ret;
        }
 
@@ -4371,37 +4357,38 @@ static int __mmplayer_gst_unrealize(mm_player_t* player)
 }
 
 static int
-__mmplayer_gst_set_message_callback(mm_player_t* player, MMMessageCallback callback, gpointer user_param)
+__mmplayer_gst_set_message_callback(mmplayer_t *player, MMMessageCallback callback, gpointer user_param)
 {
        MMPLAYER_FENTER();
 
        if (!player) {
-               LOGW("set_message_callback is called with invalid player handle\n");
+               LOGW("set_message_callback is called with invalid player handle");
                return MM_ERROR_PLAYER_NOT_INITIALIZED;
        }
 
        player->msg_cb = callback;
        player->msg_cb_param = user_param;
 
-       LOGD("msg_cb : %p     msg_cb_param : %p\n", callback, user_param);
+       LOGD("msg_cb : %p     msg_cb_param : %p", callback, user_param);
 
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;
 }
 
-int __mmplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile* data)
+int
+__mmplayer_parse_profile(const char *uri, void *param, mmplayer_parse_profile_t *data)
 {
        int ret = MM_ERROR_NONE;
        char *path = NULL;
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL(uri , FALSE);
-       MMPLAYER_RETURN_VAL_IF_FAIL(data , FALSE);
-       MMPLAYER_RETURN_VAL_IF_FAIL((strlen(uri) <= MM_MAX_URL_LEN), FALSE);
+       MMPLAYER_RETURN_VAL_IF_FAIL(uri, MM_ERROR_PLAYER_INVALID_URI);
+       MMPLAYER_RETURN_VAL_IF_FAIL(data, MM_ERROR_PLAYER_INTERNAL);
+       MMPLAYER_RETURN_VAL_IF_FAIL((strlen(uri) <= MM_MAX_URL_LEN), MM_ERROR_PLAYER_INVALID_URI);
 
-       memset(data, 0, sizeof(MMPlayerParseProfile));
+       memset(data, 0, sizeof(mmplayer_parse_profile_t));
 
        if (strstr(uri, "es_buff://")) {
                __mmplayer_copy_uri_and_set_type(data, uri, MM_PLAYER_URI_TYPE_MS_BUFF);
@@ -4429,8 +4416,8 @@ int __mmplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile*
                ret = MM_ERROR_PLAYER_PERMISSION_DENIED;
 
        /* dump parse result */
-       SECURE_LOGW("incoming uri : %s\n", uri);
-       LOGD("uri_type : %d, mem : %p, mem_size : %d, urgent : %s\n",
+       SECURE_LOGW("incoming uri : %s", uri);
+       LOGD("uri_type : %d, mem : %p, mem_size : %d, urgent : %s",
                data->uri_type, data->input_mem.buf, data->input_mem.len, data->urgent);
 
        MMPLAYER_FLEAVE();
@@ -4439,14 +4426,14 @@ int __mmplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile*
 }
 
 static gboolean
-__mmplayer_can_do_interrupt(mm_player_t *player)
+__mmplayer_can_do_interrupt(mmplayer_t *player)
 {
        if (!player || !player->pipeline || !player->attrs) {
                LOGW("not initialized");
                goto FAILED;
        }
 
-       if (player->audio_stream_render_cb) {
+       if (player->audio_decoded_cb) {
                LOGW("not support in pcm extraction mode");
                goto FAILED;
        }
@@ -4491,15 +4478,15 @@ static int
 __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res,
                void *user_data)
 {
-       mm_player_t *player = NULL;
+       mmplayer_t *player = NULL;
 
        MMPLAYER_FENTER();
 
        if (user_data == NULL) {
-               LOGE("- user_data is null\n");
+               LOGE("- user_data is null");
                return FALSE;
        }
-       player = (mm_player_t *)user_data;
+       player = (mmplayer_t *)user_data;
 
        /* do something to release resource here.
         * player stop and interrupt forwarding */
@@ -4538,7 +4525,7 @@ __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res,
 }
 
 static void
-__mmplayer_initialize_video_roi(mm_player_t *player)
+__mmplayer_initialize_video_roi(mmplayer_t *player)
 {
        player->video_roi.scale_x = 0.0;
        player->video_roi.scale_y = 0.0;
@@ -4552,7 +4539,7 @@ _mmplayer_create_player(MMHandleType handle)
        int ret = MM_ERROR_PLAYER_INTERNAL;
        bool enabled = false;
 
-       mm_player_t* player = MM_PLAYER_CAST(handle);
+       mmplayer_t *player = MM_PLAYER_CAST(handle);
 
        MMPLAYER_FENTER();
 
@@ -4571,13 +4558,13 @@ _mmplayer_create_player(MMHandleType handle)
        player->attrs = _mmplayer_construct_attribute(handle);
 
        if (!player->attrs) {
-               LOGE("Failed to construct attributes\n");
+               LOGE("Failed to construct attributes");
                return ret;
        }
 
        /* initialize gstreamer with configured parameter */
        if (!__mmplayer_init_gstreamer(player)) {
-               LOGE("Initializing gstreamer failed\n");
+               LOGE("Initializing gstreamer failed");
                _mmplayer_deconstruct_attribute(handle);
                return ret;
        }
@@ -4614,24 +4601,19 @@ _mmplayer_create_player(MMHandleType handle)
 
        ret = _mmplayer_initialize_video_capture(player);
        if (ret != MM_ERROR_NONE) {
-               LOGE("failed to initialize video capture\n");
+               LOGE("failed to initialize video capture");
                goto ERROR;
        }
 
        /* initialize resource manager */
-       if (MM_RESOURCE_MANAGER_ERROR_NONE != mm_resource_manager_create(
-                       MM_RESOURCE_MANAGER_APP_CLASS_MEDIA, __resource_release_cb, player,
-                       &player->resource_manager)) {
-               LOGE("failed to initialize resource manager\n");
+       if (mm_resource_manager_create(MM_RESOURCE_MANAGER_APP_CLASS_MEDIA,
+               __resource_release_cb, player, &player->resource_manager)
+               != MM_RESOURCE_MANAGER_ERROR_NONE) {
+               LOGE("failed to initialize resource manager");
                ret = MM_ERROR_PLAYER_INTERNAL;
                goto ERROR;
        }
 
-       if (MMPLAYER_IS_HTTP_PD(player)) {
-               player->pd_downloader = NULL;
-               player->pd_file_save_path = NULL;
-       }
-
        /* create video bo lock and cond */
        g_mutex_init(&player->video_bo_mutex);
        g_cond_init(&player->video_bo_cond);
@@ -4692,17 +4674,16 @@ _mmplayer_create_player(MMHandleType handle)
        MMPLAYER_STATE_CHANGE_TIMEOUT(player) = player->ini.localplayback_state_change_timeout;
        MMPLAYER_SET_STATE(player, MM_PLAYER_STATE_NULL);
 
+       MMPLAYER_FLEAVE();
+
        return MM_ERROR_NONE;
 
 ERROR:
        /* free lock */
        g_mutex_clear(&player->fsink_lock);
-
        /* free update tag lock */
        g_mutex_clear(&player->update_tag_lock);
-
        g_queue_free(player->bus_msg_q);
-
        /* free gapless play thread */
        if (player->gapless_play_thread) {
                MMPLAYER_GAPLESS_PLAY_THREAD_LOCK(player);
@@ -4726,32 +4707,32 @@ ERROR:
 }
 
 static gboolean
-__mmplayer_init_gstreamer(mm_player_t* player)
+__mmplayer_init_gstreamer(mmplayer_t *player)
 {
        static gboolean initialized = FALSE;
        static const int max_argc = 50;
-       gintargc = NULL;
-       gchar** argv = NULL;
-       gchar** argv2 = NULL;
+       gint *argc = NULL;
+       gchar **argv = NULL;
+       gchar **argv2 = NULL;
        GError *err = NULL;
        int i = 0;
        int arg_count = 0;
 
        if (initialized) {
-               LOGD("gstreamer already initialized.\n");
+               LOGD("gstreamer already initialized.");
                return TRUE;
        }
 
        /* alloc */
        argc = malloc(sizeof(int));
-       argv = malloc(sizeof(gchar*) * max_argc);
-       argv2 = malloc(sizeof(gchar*) * max_argc);
+       argv = malloc(sizeof(gchar *) * max_argc);
+       argv2 = malloc(sizeof(gchar *) * max_argc);
 
        if (!argc || !argv || !argv2)
                goto ERROR;
 
-       memset(argv, 0, sizeof(gchar*) * max_argc);
-       memset(argv2, 0, sizeof(gchar*) * max_argc);
+       memset(argv, 0, sizeof(gchar *) * max_argc);
+       memset(argv2, 0, sizeof(gchar *) * max_argc);
 
        /* add initial */
        *argc = 1;
@@ -4782,18 +4763,18 @@ __mmplayer_init_gstreamer(mm_player_t* player)
                (*argc)++;
        }
 
-       LOGD("initializing gstreamer with following parameter\n");
-       LOGD("argc : %d\n", *argc);
+       LOGD("initializing gstreamer with following parameter");
+       LOGD("argc : %d", *argc);
        arg_count = *argc;
 
        for (i = 0; i < arg_count; i++) {
                argv2[i] = argv[i];
-               LOGD("argv[%d] : %s\n", i, argv2[i]);
+               LOGD("argv[%d] : %s", i, argv2[i]);
        }
 
        /* initializing gstreamer */
        if (!gst_init_check(argc, &argv, &err)) {
-               LOGE("Could not initialize GStreamer: %s\n", err ? err->message : "unknown error occurred");
+               LOGE("Could not initialize GStreamer: %s", err ? err->message : "unknown error occurred");
                if (err)
                        g_error_free(err);
 
@@ -4801,7 +4782,7 @@ __mmplayer_init_gstreamer(mm_player_t* player)
        }
        /* release */
        for (i = 0; i < arg_count; i++) {
-               //LOGD("release - argv[%d] : %s\n", i, argv2[i]);
+               //LOGD("release - argv[%d] : %s", i, argv2[i]);
                MMPLAYER_FREEIF(argv2[i]);
        }
 
@@ -4818,7 +4799,7 @@ ERROR:
 
        /* release */
        for (i = 0; i < arg_count; i++) {
-               LOGD("free[%d] : %s\n", i, argv2[i]);
+               LOGD("free[%d] : %s", i, argv2[i]);
                MMPLAYER_FREEIF(argv2[i]);
        }
 
@@ -4829,26 +4810,13 @@ ERROR:
        return FALSE;
 }
 
-int
-__mmplayer_destroy_streaming_ext(mm_player_t* player)
-{
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       if (player->pd_downloader || MMPLAYER_IS_HTTP_PD(player)) {
-               _mmplayer_destroy_pd_downloader((MMHandleType)player);
-               MMPLAYER_FREEIF(player->pd_file_save_path);
-       }
-
-       return MM_ERROR_NONE;
-}
-
 static void
-__mmplayer_check_async_state_transition(mm_player_t* player)
+__mmplayer_check_async_state_transition(mmplayer_t *player)
 {
        GstState element_state = GST_STATE_VOID_PENDING;
        GstState element_pending_state = GST_STATE_VOID_PENDING;
        GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
-       GstElement * element = NULL;
+       GstElement *element = NULL;
        gboolean async = FALSE;
 
        /* check player handle */
@@ -4869,10 +4837,10 @@ __mmplayer_check_async_state_transition(mm_player_t* player)
 
        /* wait for state transition */
        element = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst;
-       ret = gst_element_get_state(element, &element_state, &element_pending_state, 1*GST_SECOND);
+       ret = gst_element_get_state(element, &element_state, &element_pending_state, 1 * GST_SECOND);
 
        if (ret == GST_STATE_CHANGE_FAILURE) {
-               LOGE(" [%s] state : %s   pending : %s \n",
+               LOGE(" [%s] state : %s   pending : %s",
                        GST_ELEMENT_NAME(element),
                        gst_element_state_get_name(element_state),
                        gst_element_state_get_name(element_pending_state));
@@ -4883,14 +4851,14 @@ __mmplayer_check_async_state_transition(mm_player_t* player)
                return;
        }
 
-       LOGD("[%s] element state has changed\n", GST_ELEMENT_NAME(element));
+       LOGD("[%s] element state has changed", GST_ELEMENT_NAME(element));
        return;
 }
 
 int
 _mmplayer_destroy(MMHandleType handle)
 {
-       mm_player_t* player = MM_PLAYER_CAST(handle);
+       mmplayer_t *player = MM_PLAYER_CAST(handle);
 
        MMPLAYER_FENTER();
 
@@ -4903,8 +4871,6 @@ _mmplayer_destroy(MMHandleType handle)
        /* check async state transition */
        __mmplayer_check_async_state_transition(player);
 
-       __mmplayer_destroy_streaming_ext(player);
-
        /* release gapless play thread */
        if (player->gapless_play_thread) {
                MMPLAYER_GAPLESS_PLAY_THREAD_LOCK(player);
@@ -4912,11 +4878,11 @@ _mmplayer_destroy(MMHandleType handle)
                MMPLAYER_GAPLESS_PLAY_THREAD_SIGNAL(player);
                MMPLAYER_GAPLESS_PLAY_THREAD_UNLOCK(player);
 
-               LOGD("waitting for gapless play thread exit\n");
+               LOGD("waitting for gapless play thread exit");
                g_thread_join(player->gapless_play_thread);
                g_mutex_clear(&player->gapless_play_thread_mutex);
                g_cond_clear(&player->gapless_play_thread_cond);
-               LOGD("gapless play thread released\n");
+               LOGD("gapless play thread released");
        }
 
        _mmplayer_release_video_capture(player);
@@ -4924,11 +4890,11 @@ _mmplayer_destroy(MMHandleType handle)
        /* de-initialize resource manager */
        if (MM_RESOURCE_MANAGER_ERROR_NONE != mm_resource_manager_destroy(
                        player->resource_manager))
-               LOGE("failed to deinitialize resource manager\n");
+               LOGE("failed to deinitialize resource manager");
 
        /* release pipeline */
        if (MM_ERROR_NONE != __mmplayer_gst_destroy_pipeline(player)) {
-               LOGE("failed to destory pipeline\n");
+               LOGE("failed to destory pipeline");
                return MM_ERROR_PLAYER_INTERNAL;
        }
 
@@ -4969,38 +4935,9 @@ _mmplayer_destroy(MMHandleType handle)
 }
 
 int
-__mmplayer_realize_streaming_ext(mm_player_t* player)
-{
-       int ret = MM_ERROR_NONE;
-
-       MMPLAYER_FENTER();
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       if (MMPLAYER_IS_HTTP_PD(player)) {
-               gboolean bret = FALSE;
-
-               player->pd_downloader = _mmplayer_create_pd_downloader();
-               if (!player->pd_downloader) {
-                       LOGE("Unable to create PD Downloader...");
-                       ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
-               }
-
-               bret = _mmplayer_realize_pd_downloader((MMHandleType)player, player->profile.uri, player->pd_file_save_path, player->pipeline->mainbin[MMPLAYER_M_SRC].gst);
-
-               if (FALSE == bret) {
-                       LOGE("Unable to create PD Downloader...");
-                       ret = MM_ERROR_PLAYER_NOT_INITIALIZED;
-               }
-       }
-
-       MMPLAYER_FLEAVE();
-       return ret;
-}
-
-int
 _mmplayer_realize(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        char *uri = NULL;
        void *param = NULL;
        MMHandleType attrs = 0;
@@ -5016,17 +4953,17 @@ _mmplayer_realize(MMHandleType hplayer)
 
        attrs = MMPLAYER_GET_ATTRS(player);
        if (!attrs) {
-               LOGE("fail to get attributes.\n");
+               LOGE("fail to get attributes.");
                return MM_ERROR_PLAYER_INTERNAL;
        }
        mm_attrs_get_string_by_name(attrs, "profile_uri", &uri);
        mm_attrs_get_data_by_name(attrs, "profile_user_param", &param);
 
        if (player->profile.uri_type == MM_PLAYER_URI_TYPE_NONE) {
-               ret = __mmplayer_parse_profile((const char*)uri, param, &player->profile);
+               ret = __mmplayer_parse_profile((const char *)uri, param, &player->profile);
 
                if (ret != MM_ERROR_NONE) {
-                       LOGE("failed to parse profile\n");
+                       LOGE("failed to parse profile");
                        return ret;
                }
        }
@@ -5039,22 +4976,18 @@ _mmplayer_realize(MMHandleType hplayer)
        }
 
        if (player->profile.uri_type == MM_PLAYER_URI_TYPE_URL_MMS) {
-               LOGW("mms protocol is not supported format.\n");
+               LOGW("mms protocol is not supported format.");
                return MM_ERROR_PLAYER_NOT_SUPPORTED_FORMAT;
        }
 
-       if (MMPLAYER_IS_HTTP_PD(player))
-               MMPLAYER_STATE_CHANGE_TIMEOUT(player) = PLAYER_PD_STATE_CHANGE_TIME;
-       else if (MMPLAYER_IS_STREAMING(player))
+       if (MMPLAYER_IS_STREAMING(player))
                MMPLAYER_STATE_CHANGE_TIMEOUT(player) = player->ini.live_state_change_timeout;
        else
                MMPLAYER_STATE_CHANGE_TIMEOUT(player) = player->ini.localplayback_state_change_timeout;
 
        player->smooth_streaming = FALSE;
        player->videodec_linked  = 0;
-       player->videosink_linked = 0;
        player->audiodec_linked  = 0;
-       player->audiosink_linked = 0;
        player->textsink_linked = 0;
        player->is_external_subtitle_present = FALSE;
        player->is_external_subtitle_added_now = FALSE;
@@ -5064,22 +4997,38 @@ _mmplayer_realize(MMHandleType hplayer)
        player->demux_pad_index = 0;
        player->subtitle_language_list = NULL;
        player->is_subtitle_force_drop = FALSE;
-       player->last_multiwin_status = FALSE;
 
        __mmplayer_track_initialize(player);
        __mmplayer_initialize_storage_info(player, MMPLAYER_PATH_MAX);
 
        if ((MMPLAYER_IS_STREAMING(player)) && (player->streamer == NULL)) {
+               gint prebuffer_ms = 0, rebuffer_ms = 0;
+
                player->streamer = __mm_player_streaming_create();
-               __mm_player_streaming_initialize(player->streamer);
+               __mm_player_streaming_initialize(player->streamer, TRUE);
+
+               mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_PREBUFFER_MS, &prebuffer_ms);
+               mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_REBUFFER_MS, &rebuffer_ms);
+
+               if (prebuffer_ms > 0) {
+                       prebuffer_ms = MAX(prebuffer_ms, 1000);
+                       player->streamer->buffering_req.prebuffer_time = prebuffer_ms;
+               }
+
+               if (rebuffer_ms > 0) {
+                       player->streamer->buffering_req.mode = MM_PLAYER_BUFFERING_MODE_FIXED;
+                       rebuffer_ms = MAX(rebuffer_ms, 1000);
+                       player->streamer->buffering_req.rebuffer_time = rebuffer_ms;
+               }
+
+               LOGD("buffering time %d ms, %d ms", player->streamer->buffering_req.prebuffer_time,
+                                                               player->streamer->buffering_req.rebuffer_time);
        }
 
        /* realize pipeline */
        ret = __mmplayer_gst_realize(player);
        if (ret != MM_ERROR_NONE)
-               LOGE("fail to realize the player.\n");
-       else
-               ret = __mmplayer_realize_streaming_ext(player);
+               LOGE("fail to realize the player.");
 
        MMPLAYER_BUS_MSG_THREAD_SIGNAL(player);
 
@@ -5089,23 +5038,9 @@ _mmplayer_realize(MMHandleType hplayer)
 }
 
 int
-__mmplayer_unrealize_streaming_ext(mm_player_t *player)
-{
-       MMPLAYER_FENTER();
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       /* destroy can called at anytime */
-       if (player->pd_downloader && MMPLAYER_IS_HTTP_PD(player))
-               _mmplayer_unrealize_pd_downloader((MMHandleType)player);
-
-       MMPLAYER_FLEAVE();
-       return MM_ERROR_NONE;
-}
-
-int
 _mmplayer_unrealize(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -5124,8 +5059,6 @@ _mmplayer_unrealize(MMHandleType hplayer)
        /* check async state transition */
        __mmplayer_check_async_state_transition(player);
 
-       __mmplayer_unrealize_streaming_ext(player);
-
        /* unrealize pipeline */
        ret = __mmplayer_gst_unrealize(player);
 
@@ -5136,7 +5069,7 @@ _mmplayer_unrealize(MMHandleType hplayer)
                                ret = mm_resource_manager_mark_for_release(player->resource_manager,
                                                player->video_decoder_resource);
                                if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
-                                       LOGE("failed to mark decoder resource for release, ret(0x%x)\n", ret);
+                                       LOGE("failed to mark decoder resource for release, ret(0x%x)", ret);
                                else
                                        player->video_decoder_resource = NULL;
                        }
@@ -5145,14 +5078,14 @@ _mmplayer_unrealize(MMHandleType hplayer)
                                ret = mm_resource_manager_mark_for_release(player->resource_manager,
                                                player->video_overlay_resource);
                                if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
-                                       LOGE("failed to mark overlay resource for release, ret(0x%x)\n", ret);
+                                       LOGE("failed to mark overlay resource for release, ret(0x%x)", ret);
                                else
                                        player->video_overlay_resource = NULL;
                        }
 
                        ret = mm_resource_manager_commit(player->resource_manager);
                        if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
-                               LOGE("failed to commit resource releases, ret(0x%x)\n", ret);
+                               LOGE("failed to commit resource releases, ret(0x%x)", ret);
                }
        } else
                LOGE("failed and don't change asm state to stop");
@@ -5165,7 +5098,7 @@ _mmplayer_unrealize(MMHandleType hplayer)
 int
 _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, gpointer user_param)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
@@ -5173,9 +5106,9 @@ _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback,
 }
 
 int
-_mmplayer_get_state(MMHandleType hplayer, intstate)
+_mmplayer_get_state(MMHandleType hplayer, int *state)
 {
-       mm_player_t *player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_INVALID_ARGUMENT);
 
@@ -5184,140 +5117,132 @@ _mmplayer_get_state(MMHandleType hplayer, int* state)
        return MM_ERROR_NONE;
 }
 
-
-int
-_mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume)
+static int
+__mmplayer_gst_set_volume_property(mmplayer_t *player, const char *prop_name)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
-       GstElement* vol_element = NULL;
-       int i = 0;
+       GstElement *vol_element = NULL;
+       enum audio_element_id volume_elem_id = MMPLAYER_A_VOL;
 
        MMPLAYER_FENTER();
-
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       LOGD("volume [L]=%f:[R]=%f\n",
-               volume.level[MM_VOLUME_CHANNEL_LEFT], volume.level[MM_VOLUME_CHANNEL_RIGHT]);
-
-       /* invalid factor range or not */
-       for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++) {
-               if (volume.level[i] < MM_VOLUME_FACTOR_MIN || volume.level[i] > MM_VOLUME_FACTOR_MAX) {
-                       LOGE("Invalid factor!(valid factor:0~1.0)\n");
-                       return MM_ERROR_INVALID_ARGUMENT;
-               }
-       }
-
-       /* not support to set other value into each channel */
-       if ((volume.level[MM_VOLUME_CHANNEL_LEFT] != volume.level[MM_VOLUME_CHANNEL_RIGHT]))
-               return MM_ERROR_INVALID_ARGUMENT;
-
-       /* Save volume to handle. Currently the first array element will be saved. */
-       player->sound.volume = volume.level[MM_VOLUME_CHANNEL_LEFT];
+       MMPLAYER_RETURN_VAL_IF_FAIL(prop_name, MM_ERROR_INVALID_ARGUMENT);
 
        /* check pipeline handle */
        if (!player->pipeline || !player->pipeline->audiobin) {
-               LOGD("audiobin is not created yet\n");
-               LOGD("but, current stored volume will be set when it's created.\n");
+               LOGD("'%s' will be applied when audiobin is created", prop_name);
 
-               /* NOTE : stored volume will be used in create_audiobin
+               /* NOTE : stored value will be used in create_audiobin
                 * returning MM_ERROR_NONE here makes application to able to
-                * set volume at anytime.
+                * set audio volume or mute at anytime.
                 */
                return MM_ERROR_NONE;
        }
 
-       /* setting volume to volume element */
-       vol_element = player->pipeline->audiobin[MMPLAYER_A_VOL].gst;
-
-       if (vol_element) {
-               LOGD("volume is set [%f]\n", player->sound.volume);
-               g_object_set(vol_element, "volume", player->sound.volume, NULL);
+       if (player->build_audio_offload) {
+               LOGD("offload pipeline");
+               volume_elem_id = MMPLAYER_A_SINK;
        }
 
-       MMPLAYER_FLEAVE();
+       vol_element = player->pipeline->audiobin[volume_elem_id].gst;
+       if (!vol_element) {
+               LOGE("failed to get vol element %d", volume_elem_id);
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
 
-       return MM_ERROR_NONE;
-}
+       LOGD("set '%s' property to element[%s]", prop_name, GST_ELEMENT_NAME(vol_element));
 
+       if (!g_object_class_find_property(G_OBJECT_GET_CLASS(vol_element), prop_name)) {
+               LOGE("there is no '%s' property", prop_name);
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
+       if (!strcmp(prop_name, "volume")) {
+               g_object_set(vol_element, "volume", player->sound.volume, NULL);
+       } else if (!strcmp(prop_name, "mute")) {
+               g_object_set(vol_element, "mute", player->sound.mute, NULL);
+       } else {
+               LOGE("invalid property %s", prop_name);
+               return MM_ERROR_PLAYER_INTERNAL;
+       }
+
+       return MM_ERROR_NONE;
+}
 
 int
-_mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType* volume)
+_mmplayer_set_volume(MMHandleType hplayer, float volume)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
-       int i = 0;
+       int ret = MM_ERROR_NONE;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
-
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
 
-       /* returning stored volume */
-       for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
-               volume->level[i] = player->sound.volume;
+       LOGD("volume = %f", volume);
 
-       MMPLAYER_FLEAVE();
+       /* invalid factor range or not */
+       if (volume < MM_VOLUME_FACTOR_MIN || volume > MM_VOLUME_FACTOR_MAX) {
+               LOGE("Invalid volume value");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
 
-       return MM_ERROR_NONE;
+       player->sound.volume = volume;
+
+       ret = __mmplayer_gst_set_volume_property(player, "volume");
+
+       MMPLAYER_FLEAVE();
+       return ret;
 }
 
 int
-_mmplayer_set_mute(MMHandleType hplayer, int mute)
+_mmplayer_get_volume(MMHandleType hplayer, float *volume)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
-       GstElement* vol_element = NULL;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
 
-       /* mute value shoud 0 or 1 */
-       if (mute != 0 && mute != 1) {
-               LOGE("bad mute value\n");
+       *volume = player->sound.volume;
 
-               /* FIXIT : definitly, we need _BAD_PARAM error code */
-               return MM_ERROR_INVALID_ARGUMENT;
-       }
+       LOGD("current vol = %f", *volume);
 
-       player->sound.mute = mute;
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_NONE;
+}
 
-       /* just hold mute value if pipeline is not ready */
-       if (!player->pipeline || !player->pipeline->audiobin) {
-               LOGD("pipeline is not ready. holding mute value\n");
-               return MM_ERROR_NONE;
-       }
+int
+_mmplayer_set_mute(MMHandleType hplayer, bool mute)
+{
+       int ret = MM_ERROR_NONE;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
-       vol_element = player->pipeline->audiobin[MMPLAYER_A_VOL].gst;
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       /* NOTE : volume will only created when the bt is enabled */
-       if (vol_element) {
-               LOGD("mute : %d\n", mute);
-               g_object_set(vol_element, "mute", mute, NULL);
-       } else
-               LOGD("volume elemnet is not created. using volume in audiosink\n");
+       LOGD("mute = %d", mute);
 
-       MMPLAYER_FLEAVE();
+       player->sound.mute = mute;
 
-       return MM_ERROR_NONE;
+       ret = __mmplayer_gst_set_volume_property(player, "mute");
+
+       MMPLAYER_FLEAVE();
+       return ret;
 }
 
 int
-_mmplayer_get_mute(MMHandleType hplayer, int* pmute)
+_mmplayer_get_mute(MMHandleType hplayer, bool *mute)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(pmute, MM_ERROR_INVALID_ARGUMENT);
+       MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
 
-       /* just hold mute value if pipeline is not ready */
-       if (!player->pipeline || !player->pipeline->audiobin) {
-               LOGD("pipeline is not ready. returning stored value\n");
-               *pmute = player->sound.mute;
-               return MM_ERROR_NONE;
-       }
+       *mute = player->sound.mute;
 
-       *pmute = player->sound.mute;
+       LOGD("current mute = %d", *mute);
 
        MMPLAYER_FLEAVE();
 
@@ -5327,7 +5252,7 @@ _mmplayer_get_mute(MMHandleType hplayer, int* pmute)
 int
 _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
@@ -5335,7 +5260,7 @@ _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_chan
 
        player->video_stream_changed_cb = callback;
        player->video_stream_changed_cb_user_param = user_param;
-       LOGD("Handle value is %p : %p\n", player, player->video_stream_changed_cb);
+       LOGD("Handle value is %p : %p", player, player->video_stream_changed_cb);
 
        MMPLAYER_FLEAVE();
 
@@ -5345,7 +5270,7 @@ _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_chan
 int
 _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
@@ -5353,7 +5278,7 @@ _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_chan
 
        player->audio_stream_changed_cb = callback;
        player->audio_stream_changed_cb_user_param = user_param;
-       LOGD("Handle value is %p : %p\n", player, player->audio_stream_changed_cb);
+       LOGD("Handle value is %p : %p", player, player->audio_stream_changed_cb);
 
        MMPLAYER_FLEAVE();
 
@@ -5361,18 +5286,18 @@ _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_chan
 }
 
 int
-_mmplayer_set_audiostream_cb(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback callback, void *user_param)
+_mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param)
 {
-       mm_player_t *player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       player->audio_stream_render_cb = callback;
-       player->audio_stream_cb_user_param = user_param;
-       player->audio_stream_sink_sync = sync;
-       LOGD("handle: %p, cb: %p, sync: %d", player, player->audio_stream_render_cb, player->audio_stream_sink_sync);
+       player->audio_decoded_cb = callback;
+       player->audio_decoded_cb_user_param = user_param;
+       player->audio_extract_opt = opt;
+       LOGD("handle: %p, cb: %p, opt: 0x%X", player, player->audio_decoded_cb, player->audio_extract_opt);
 
        MMPLAYER_FLEAVE();
 
@@ -5380,9 +5305,9 @@ _mmplayer_set_audiostream_cb(MMHandleType hplayer, bool sync, mm_player_audio_st
 }
 
 int
-_mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param)
+_mmplayer_set_video_decoded_cb(MMHandleType hplayer, mm_player_video_decoded_callback callback, void *user_param)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
@@ -5391,53 +5316,21 @@ _mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callba
        if (callback && !player->bufmgr)
                player->bufmgr = tbm_bufmgr_init(-1);
 
-       player->set_mode.media_packet_video_stream = (callback) ? TRUE : FALSE;
-       player->video_stream_cb = callback;
-       player->video_stream_cb_user_param = user_param;
+       player->set_mode.video_export = (callback) ? true : false;
+       player->video_decoded_cb = callback;
+       player->video_decoded_cb_user_param = user_param;
 
-       LOGD("Stream cb Handle value is %p : %p, enable:%d\n", player, player->video_stream_cb, player->set_mode.media_packet_video_stream);
+       LOGD("Stream cb Handle value is %p : %p, enable:%d", player, player->video_decoded_cb, player->set_mode.video_export);
 
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;
 }
 
-static int
-__mmplayer_start_streaming_ext(mm_player_t *player)
-{
-       gint ret = MM_ERROR_NONE;
-
-       MMPLAYER_FENTER();
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       if (MMPLAYER_IS_HTTP_PD(player)) {
-               if (!player->pd_downloader) {
-                       ret = __mmplayer_realize_streaming_ext(player);
-
-                       if (ret != MM_ERROR_NONE) {
-                               LOGE("failed to realize streaming ext\n");
-                               return ret;
-                       }
-               }
-
-               if (player->pd_downloader && player->pd_mode == MM_PLAYER_PD_MODE_URI) {
-                       ret = _mmplayer_start_pd_downloader((MMHandleType)player);
-                       if (!ret) {
-                               LOGE("ERROR while starting PD...\n");
-                               return MM_ERROR_PLAYER_NOT_INITIALIZED;
-                       }
-                       ret = MM_ERROR_NONE;
-               }
-       }
-
-       MMPLAYER_FLEAVE();
-       return ret;
-}
-
 int
 _mmplayer_start(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        gint ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -5447,17 +5340,10 @@ _mmplayer_start(MMHandleType hplayer)
        /* check current state */
        MMPLAYER_CHECK_STATE(player, MMPLAYER_COMMAND_START);
 
-       /* PD - start streaming */
-       ret = __mmplayer_start_streaming_ext(player);
-       if (ret != MM_ERROR_NONE) {
-               LOGE("failed to start streaming ext 0x%X", ret);
-               return ret;
-       }
-
        /* start pipeline */
        ret = __mmplayer_gst_start(player);
        if (ret != MM_ERROR_NONE)
-               LOGE("failed to start player.\n");
+               LOGE("failed to start player.");
 
        if ((player->streamer) && (player->streamer->buffering_state & MM_PLAYER_BUFFERING_IN_PROGRESS)) {
                LOGD("force playing start even during buffering");
@@ -5476,7 +5362,7 @@ _mmplayer_start(MMHandleType hplayer)
  * Because GST_ERROR_MESSAGE is posted by other plugin internally.
  */
 int
-__mmplayer_handle_missed_plugin(mm_player_t* player)
+__mmplayer_handle_missed_plugin(mmplayer_t *player)
 {
        MMMessageParamType msg_param;
        memset(&msg_param, 0, sizeof(MMMessageParamType));
@@ -5486,7 +5372,7 @@ __mmplayer_handle_missed_plugin(mm_player_t* player)
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       LOGD("not_supported_codec = 0x%02x, can_support_codec = 0x%02x\n",
+       LOGD("not_supported_codec = 0x%02x, can_support_codec = 0x%02x",
                        player->not_supported_codec, player->can_support_codec);
 
        if (player->not_found_demuxer) {
@@ -5513,12 +5399,12 @@ __mmplayer_handle_missed_plugin(mm_player_t* player)
                        memset(&msg_param, 0, sizeof(MMMessageParamType));
 
                        if (player->not_supported_codec ==  MISSING_PLUGIN_AUDIO) {
-                               LOGW("not found AUDIO codec, posting error code to application.\n");
+                               LOGW("not found AUDIO codec, posting error code to application.");
 
                                msg_param.code = MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND;
                                msg_param.data = g_strdup_printf("%s", player->unlinked_audio_mime);
                        } else if (player->not_supported_codec ==  MISSING_PLUGIN_VIDEO) {
-                               LOGW("not found VIDEO codec, posting error code to application.\n");
+                               LOGW("not found VIDEO codec, posting error code to application.");
 
                                msg_param.code = MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND;
                                msg_param.data = g_strdup_printf("%s", player->unlinked_video_mime);
@@ -5531,7 +5417,7 @@ __mmplayer_handle_missed_plugin(mm_player_t* player)
                        return MM_ERROR_NONE;
                } else {
                        // no any supported codec case
-                       LOGW("not found any codec, posting error code to application.\n");
+                       LOGW("not found any codec, posting error code to application.");
 
                        if (player->not_supported_codec ==  MISSING_PLUGIN_AUDIO) {
                                msg_param.code = MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND;
@@ -5552,34 +5438,35 @@ __mmplayer_handle_missed_plugin(mm_player_t* player)
        return MM_ERROR_NONE;
 }
 
-static void __mmplayer_check_pipeline(mm_player_t* player)
+static void
+__mmplayer_check_pipeline(mmplayer_t *player)
 {
        GstState element_state = GST_STATE_VOID_PENDING;
        GstState element_pending_state = GST_STATE_VOID_PENDING;
        gint timeout = 0;
        int ret = MM_ERROR_NONE;
 
-       if (player->gapless.reconfigure) {
-               LOGW("pipeline is under construction.\n");
+       if (!player->gapless.reconfigure)
+               return;
 
-               MMPLAYER_PLAYBACK_LOCK(player);
-               MMPLAYER_PLAYBACK_UNLOCK(player);
+       LOGW("pipeline is under construction.");
 
-               timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player);
+       MMPLAYER_PLAYBACK_LOCK(player);
+       MMPLAYER_PLAYBACK_UNLOCK(player);
 
-               /* wait for state transition */
-               ret = gst_element_get_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &element_state, &element_pending_state, timeout * GST_SECOND);
+       timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player);
 
-               if (ret == GST_STATE_CHANGE_FAILURE)
-                       LOGE("failed to change pipeline state within %d sec\n", timeout);
-       }
+       /* wait for state transition */
+       ret = gst_element_get_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &element_state, &element_pending_state, timeout * GST_SECOND);
+       if (ret == GST_STATE_CHANGE_FAILURE)
+               LOGE("failed to change pipeline state within %d sec", timeout);
 }
 
 /* NOTE : it should be able to call 'stop' anytime*/
 int
 _mmplayer_stop(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -5596,8 +5483,6 @@ _mmplayer_stop(MMHandleType hplayer)
        /* NOTE : application should not wait for EOS after calling STOP */
        __mmplayer_cancel_eos_timer(player);
 
-       __mmplayer_unrealize_streaming_ext(player);
-
        /* reset */
        player->seek_state = MMPLAYER_SEEK_NONE;
 
@@ -5605,7 +5490,7 @@ _mmplayer_stop(MMHandleType hplayer)
        ret = __mmplayer_gst_stop(player);
 
        if (ret != MM_ERROR_NONE)
-               LOGE("failed to stop player.\n");
+               LOGE("failed to stop player.");
 
        MMPLAYER_FLEAVE();
 
@@ -5615,7 +5500,7 @@ _mmplayer_stop(MMHandleType hplayer)
 int
 _mmplayer_pause(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        gint64 pos_nsec = 0;
        gboolean async = FALSE;
        gint ret = MM_ERROR_NONE;
@@ -5654,7 +5539,7 @@ _mmplayer_pause(MMHandleType hplayer)
                        * elements
                        */
                        if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_nsec))
-                               LOGW("getting current position failed in paused\n");
+                               LOGW("getting current position failed in paused");
 
                        player->last_position = pos_nsec;
 
@@ -5679,7 +5564,7 @@ _mmplayer_pause(MMHandleType hplayer)
        ret = __mmplayer_gst_pause(player, async);
 
        if (ret != MM_ERROR_NONE)
-               LOGE("failed to pause player. ret : 0x%x\n", ret);
+               LOGE("failed to pause player. ret : 0x%x", ret);
 
        if (MMPLAYER_PREV_STATE(player) == MM_PLAYER_STATE_READY && MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED) {
                if (MM_ERROR_NONE != _mmplayer_update_video_param(player, "display_rotation"))
@@ -5695,7 +5580,7 @@ _mmplayer_pause(MMHandleType hplayer)
 int
 _mmplayer_abort_pause(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -5719,11 +5604,10 @@ _mmplayer_abort_pause(MMHandleType hplayer)
        return ret;
 }
 
-
 int
 _mmplayer_resume(MMHandleType hplayer)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
        gboolean async = FALSE;
 
@@ -5747,7 +5631,7 @@ _mmplayer_resume(MMHandleType hplayer)
 
        ret = __mmplayer_gst_resume(player, async);
        if (ret != MM_ERROR_NONE)
-               LOGE("failed to resume player.\n");
+               LOGE("failed to resume player.");
 
        if ((player->streamer) && (player->streamer->buffering_state & MM_PLAYER_BUFFERING_IN_PROGRESS)) {
                LOGD("force resume even during buffering");
@@ -5762,12 +5646,12 @@ _mmplayer_resume(MMHandleType hplayer)
 int
 _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        gint64 pos_nsec = 0;
        int ret = MM_ERROR_NONE;
-       int mute = FALSE;
+       bool mute = false;
        signed long long start = 0, stop = 0;
-       MMPlayerStateType current_state = MM_PLAYER_STATE_NONE;
+       mmplayer_state_e current_state = MM_PLAYER_STATE_NONE;
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
@@ -5776,7 +5660,7 @@ _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
        /* The sound of video is not supported under 0.0 and over 2.0. */
        if (rate >= TRICK_PLAY_MUTE_THRESHOLD_MAX || rate < TRICK_PLAY_MUTE_THRESHOLD_MIN) {
                if (player->can_support_codec & FOUND_PLUGIN_VIDEO)
-                       mute = TRUE;
+                       mute = true;
        }
        _mmplayer_set_mute(hplayer, mute);
 
@@ -5785,7 +5669,7 @@ _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
 
        /* If the position is reached at start potion during fast backward, EOS is posted.
         * So, This EOS have to be classified with it which is posted at reaching the end of stream.
-        * */
+        */
        player->playback_rate = rate;
 
        current_state = MMPLAYER_CURRENT_STATE(player);
@@ -5815,11 +5699,11 @@ _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
                                (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
                                GST_SEEK_TYPE_SET, start,
                                GST_SEEK_TYPE_SET, stop)) {
-               LOGE("failed to set speed playback\n");
+               LOGE("failed to set speed playback");
                return MM_ERROR_PLAYER_SEEK;
        }
 
-       LOGD("succeeded to set speed playback as %0.1f\n", rate);
+       LOGD("succeeded to set speed playback as %0.1f", rate);
 
        MMPLAYER_FLEAVE();
 
@@ -5829,7 +5713,7 @@ _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
 int
 _mmplayer_set_position(MMHandleType hplayer, gint64 position)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -5849,7 +5733,7 @@ _mmplayer_set_position(MMHandleType hplayer, gint64 position)
 int
 _mmplayer_get_position(MMHandleType hplayer, gint64 *position)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
@@ -5862,40 +5746,43 @@ _mmplayer_get_position(MMHandleType hplayer, gint64 *position)
 int
 _mmplayer_get_duration(MMHandleType hplayer, gint64 *duration)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_RETURN_VAL_IF_FAIL(duration, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
+       if (g_strrstr(player->type, "video/mpegts"))
+               __mmplayer_update_duration_value(player);
+
        *duration = player->duration;
        return ret;
 }
 
 int
-_mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos)
+_mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       ret = __mmplayer_gst_get_buffer_position(player, format, start_pos, stop_pos);
+       ret = __mmplayer_gst_get_buffer_position(player, start_pos, end_pos);
 
        return ret;
 }
 
 int
-_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int position)
+_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int position)
 {
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       ret = __mmplayer_gst_adjust_subtitle_position(player, format, position);
+       ret = __mmplayer_gst_adjust_subtitle_position(player, position);
 
        MMPLAYER_FLEAVE();
 
@@ -5903,7 +5790,7 @@ _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int position
 }
 
 static gboolean
-__mmplayer_is_midi_type(gcharstr_caps)
+__mmplayer_is_midi_type(gchar *str_caps)
 {
        if ((g_strrstr(str_caps, "audio/midi")) ||
                (g_strrstr(str_caps, "application/x-gst_ff-mmf")) ||
@@ -5912,7 +5799,7 @@ __mmplayer_is_midi_type(gchar* str_caps)
                (g_strrstr(str_caps, "audio/mobile-xmf")) ||
                (g_strrstr(str_caps, "audio/xmf")) ||
                (g_strrstr(str_caps, "audio/mxmf"))) {
-               LOGD("midi\n");
+               LOGD("midi");
                return TRUE;
        }
 
@@ -5923,15 +5810,15 @@ static gboolean
 __mmplayer_is_only_mp3_type(gchar *str_caps)
 {
        if (g_strrstr(str_caps, "application/x-id3") ||
-               (g_strrstr(str_caps, "audio/mpeg") && g_strrstr(str_caps, "mpegversion= (int)1")))
+               (g_strrstr(str_caps, "audio/mpeg") && g_strrstr(str_caps, "mpegversion=(int)1")))
                return TRUE;
        return FALSE;
 }
 
 static void
-__mmplayer_set_audio_attrs(mm_player_t* player, GstCaps* caps)
+__mmplayer_set_audio_attrs(mmplayer_t *player, GstCaps *caps)
 {
-       GstStructurecaps_structure = NULL;
+       GstStructure *caps_structure = NULL;
        gint samplerate = 0;
        gint channels = 0;
 
@@ -5947,45 +5834,58 @@ __mmplayer_set_audio_attrs(mm_player_t* player, GstCaps* caps)
        gst_structure_get_int(caps_structure, "channels", &channels);
        mm_attrs_set_int_by_name(player->attrs, "content_audio_channels", channels);
 
-       LOGD("audio samplerate : %d     channels : %d\n", samplerate, channels);
+       LOGD("audio samplerate : %d     channels : %d", samplerate, channels);
 }
 
 static void
-__mmplayer_update_content_type_info(mm_player_t* player)
+__mmplayer_update_content_type_info(mmplayer_t *player)
 {
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player && player->type);
 
        if (__mmplayer_is_midi_type(player->type)) {
                player->bypass_audio_effect = TRUE;
-       } else if (g_strrstr(player->type, "application/x-hls")) {
+               return;
+       }
+
+       if (!player->streamer) {
+               LOGD("no need to check streaming type");
+               return;
+       }
+
+       if (g_strrstr(player->type, "application/x-hls")) {
                /* If it can't know exact type when it parses uri because of redirection case,
                 * it will be fixed by typefinder or when doing autoplugging.
                 */
                player->profile.uri_type = MM_PLAYER_URI_TYPE_HLS;
-               if (player->streamer) {
-                       player->streamer->is_adaptive_streaming = TRUE;
-                       player->streamer->buffering_req.mode = MM_PLAYER_BUFFERING_MODE_FIXED;
-                       player->streamer->buffering_req.rebuffer_time = 5 * 1000;
-               }
+               player->streamer->is_adaptive_streaming = TRUE;
        } else if (g_strrstr(player->type, "application/dash+xml")) {
                player->profile.uri_type = MM_PLAYER_URI_TYPE_DASH;
-               if (player->streamer) {
-                       player->streamer->is_adaptive_streaming = TRUE;
-                       player->streamer->buffering_req.mode = MM_PLAYER_BUFFERING_MODE_FIXED;
+               player->streamer->is_adaptive_streaming = TRUE;
+       }
+
+       /* in case of TS, fixed buffering mode should be used because player can not get exact duration time */
+       if ((player->streamer->is_adaptive_streaming) || (g_strrstr(player->type, "video/mpegts"))) {
+               player->streamer->buffering_req.mode = MM_PLAYER_BUFFERING_MODE_FIXED;
+
+               if (player->streamer->buffering_req.rebuffer_time <= MIN_BUFFERING_TIME) { /* if user did not set the rebuffer value */
+                       if (player->streamer->is_adaptive_streaming)
+                               player->streamer->buffering_req.rebuffer_time = DEFAULT_ADAPTIVE_REBUFFER_TIME;
+                       else
+                               player->streamer->buffering_req.rebuffer_time = DEFAULT_REBUFFERING_TIME;
                }
        }
 
-       LOGD("uri type : %d", player->profile.uri_type);
+       LOGD("uri type : %d, %d", player->profile.uri_type, player->streamer->buffering_req.rebuffer_time);
        MMPLAYER_FLEAVE();
 }
 
 void
 __mmplayer_typefind_have_type(GstElement *tf, guint probability,
-GstCaps *caps, gpointer data)
+       GstCaps *caps, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*)data;
-       GstPadpad = NULL;
+       mmplayer_t *player = (mmplayer_t *)data;
+       GstPad *pad = NULL;
 
        MMPLAYER_FENTER();
 
@@ -5994,14 +5894,13 @@ GstCaps *caps, gpointer data)
        /* store type string */
        MMPLAYER_FREEIF(player->type);
        player->type = gst_caps_to_string(caps);
-       if (player->type) {
-               LOGD("[handle: %p] media type %s found, probability %d%% / %d\n",
+       if (player->type)
+               LOGD("[handle: %p] media type %s found, probability %d%% / %d",
                                player, player->type, probability, gst_caps_get_size(caps));
-       }
 
        if ((!MMPLAYER_IS_RTSP_STREAMING(player)) &&
                (g_strrstr(player->type, "audio/x-raw-int"))) {
-               LOGE("not support media format\n");
+               LOGE("not support media format");
 
                if (player->msg_posted == FALSE) {
                        MMMessageParamType msg_param;
@@ -6020,23 +5919,21 @@ GstCaps *caps, gpointer data)
 
        pad = gst_element_get_static_pad(tf, "src");
        if (!pad) {
-               LOGE("fail to get typefind src pad.\n");
+               LOGE("fail to get typefind src pad.");
                return;
        }
 
        if (!__mmplayer_gst_create_decoder(player, pad, caps)) {
                gboolean async = FALSE;
-               LOGE("failed to autoplug %s\n", player->type);
+               LOGE("failed to autoplug %s", player->type);
 
                mm_attrs_get_int_by_name(player->attrs, "profile_prepare_async", &async);
 
                if (async && player->msg_posted == FALSE)
                        __mmplayer_handle_missed_plugin(player);
 
-               goto DONE;
        }
 
-DONE:
        gst_object_unref(GST_OBJECT(pad));
 
        MMPLAYER_FLEAVE();
@@ -6045,7 +5942,7 @@ DONE:
 }
 
 GstElement *
-__mmplayer_gst_make_decodebin(mm_player_t* player)
+__mmplayer_gst_make_decodebin(mmplayer_t *player)
 {
        GstElement *decodebin = NULL;
 
@@ -6055,7 +5952,7 @@ __mmplayer_gst_make_decodebin(mm_player_t* player)
        decodebin = gst_element_factory_make("decodebin", NULL);
 
        if (!decodebin) {
-               LOGE("fail to create decodebin\n");
+               LOGE("fail to create decodebin");
                goto ERROR;
        }
 
@@ -6097,14 +5994,13 @@ ERROR:
        return decodebin;
 }
 
-static GstElement*
-__mmplayer_gst_make_queue2(mm_player_t *player)
+static GstElement *
+__mmplayer_gst_make_queue2(mmplayer_t *player)
 {
-       GstElementqueue2 = NULL;
+       GstElement *queue2 = NULL;
        gint64 dur_bytes = 0L;
-       guint max_buffer_size_bytes = 0;
-       MMPlayerGstElement *mainbin = NULL;
-       MuxedBufferType type = MUXED_BUFFER_TYPE_MEM_QUEUE;
+       mmplayer_gst_element_t *mainbin = NULL;
+       muxed_buffer_type_e type = MUXED_BUFFER_TYPE_MEM_QUEUE;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, NULL);
@@ -6118,14 +6014,14 @@ __mmplayer_gst_make_queue2(mm_player_t *player)
        }
 
        if (!gst_element_query_duration(mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes))
-               LOGE("failed to get duration from source %s", GST_ELEMENT_NAME(mainbin[MMPLAYER_M_SRC].gst));
+               LOGW("failed to get duration from source %s", GST_ELEMENT_NAME(mainbin[MMPLAYER_M_SRC].gst));
 
        LOGD("dur_bytes = %"G_GINT64_FORMAT, dur_bytes);
 
+       /* NOTE : in case of ts streaming, player could not get the correct duration info *
+        *                skip the pull mode(file or ring buffering) setting. */
        if (dur_bytes > 0) {
-               if (MMPLAYER_USE_FILE_FOR_BUFFERING(player)) {
-                       type = MUXED_BUFFER_TYPE_FILE;
-               } else {
+               if (!g_strrstr(player->type, "video/mpegts")) {
                        type = MUXED_BUFFER_TYPE_MEM_RING_BUFFER;
                        player->streamer->ring_buffer_size = player->ini.http_ring_buffer_size;
                }
@@ -6133,43 +6029,30 @@ __mmplayer_gst_make_queue2(mm_player_t *player)
                dur_bytes = 0;
        }
 
-       /* NOTE : in case of ts streaming, player cannot get the correct duration info *
-        *                skip the pull mode(file or ring buffering) setting. */
-       if (!g_strrstr(player->type, "video/mpegts")) {
-               max_buffer_size_bytes = (type == MUXED_BUFFER_TYPE_FILE) ? (player->ini.http_max_size_bytes) : (5*1024*1024);
-               LOGD("max_buffer_size_bytes = %d", max_buffer_size_bytes);
-
-               __mm_player_streaming_set_queue2(player->streamer,
-                                                                               queue2,
-                                                                               FALSE,
-                                                                               max_buffer_size_bytes,
-                                                                               player->ini.http_buffering_time,
-                                                                               1.0,                                                            /* no meaning */
-                                                                               player->ini.http_buffering_limit,       /* no meaning */
-                                                                               type,
-                                                                               player->http_file_buffering_path,
-                                                                               (guint64)dur_bytes);
-       }
+       __mm_player_streaming_set_queue2(player->streamer,
+                                                                       queue2,
+                                                                       FALSE,
+                                                                       type,
+                                                                       (guint64)dur_bytes); /* no meaning at the moment */
 
        return queue2;
 }
 
 gboolean
-__mmplayer_gst_create_decoder(mm_player_t* player, GstPad *srcpad, const GstCaps *caps)
+__mmplayer_gst_create_decoder(mmplayer_t *player, GstPad *srcpad, const GstCaps *caps)
 {
-       MMPlayerGstElement* mainbin = NULL;
-       GstElement* decodebin = NULL;
-       GstElement* queue2 = NULL;
-       GstPad* sinkpad = NULL;
-       GstPad* qsrcpad = NULL;
-       gint init_buffering_time = player->streamer->buffering_req.prebuffer_time;
+       mmplayer_gst_element_t *mainbin = NULL;
+       GstElement *decodebin = NULL;
+       GstElement *queue2 = NULL;
+       GstPad *sinkpad = NULL;
+       GstPad *qsrcpad = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, FALSE);
 
        mainbin = player->pipeline->mainbin;
 
-       if ((!MMPLAYER_IS_HTTP_PD(player)) && (MMPLAYER_IS_HTTP_STREAMING(player))) {
+       if (MMPLAYER_IS_HTTP_STREAMING(player)) {
 
                if (mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst) {
                        LOGW("need to check: muxed buffer is not null");
@@ -6217,7 +6100,7 @@ __mmplayer_gst_create_decoder(mm_player_t* player, GstPad *srcpad, const GstCaps
        }
 
        if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), decodebin)) {
-               LOGE("failed to add decodebin\n");
+               LOGE("failed to add decodebin");
                goto ERROR;
        }
 
@@ -6236,6 +6119,8 @@ __mmplayer_gst_create_decoder(mm_player_t* player, GstPad *srcpad, const GstCaps
 
        gst_object_unref(GST_OBJECT(sinkpad));
        sinkpad = NULL;
+       gst_object_unref(GST_OBJECT(qsrcpad));
+       qsrcpad = NULL;
 
        mainbin[MMPLAYER_M_AUTOPLUG].id = MMPLAYER_M_AUTOPLUG;
        mainbin[MMPLAYER_M_AUTOPLUG].gst = decodebin;
@@ -6243,26 +6128,26 @@ __mmplayer_gst_create_decoder(mm_player_t* player, GstPad *srcpad, const GstCaps
        /* set decodebin property about buffer in streaming playback. *
         * in case of HLS/DASH, it does not need to have big buffer   *
         * because it is kind of adaptive streaming.                  */
-       if (!MMPLAYER_IS_HTTP_PD(player) &&
-           (MMPLAYER_IS_HTTP_STREAMING(player) || MMPLAYER_IS_HTTP_LIVE_STREAMING(player) || MMPLAYER_IS_DASH_STREAMING(player))) {
-           gdouble high_percent = 0.0;
+       if (MMPLAYER_IS_HTTP_STREAMING(player) || MMPLAYER_IS_HTTP_LIVE_STREAMING(player) || MMPLAYER_IS_DASH_STREAMING(player)) {
+               gint init_buffering_time = DEFAULT_PREBUFFERING_TIME;
+               gint high_percent = 0;
+
+               if (player->streamer->buffering_req.prebuffer_time > MIN_BUFFERING_TIME)
+                       init_buffering_time = player->streamer->buffering_req.prebuffer_time;
 
-               init_buffering_time = (init_buffering_time != 0) ? (init_buffering_time) : (player->ini.http_buffering_time);
-               high_percent = (gdouble)(init_buffering_time * 100) / GET_MAX_BUFFER_TIME(player->streamer);
+               high_percent = (gint)ceil((gdouble)(init_buffering_time * 100) / MAX_BUFFER_SIZE_TIME);
 
-               LOGD("decodebin setting - bytes: %d, time: %d ms, per: 1~%d",
-                       GET_MAX_BUFFER_BYTES(player->streamer), GET_MAX_BUFFER_TIME(player->streamer), (gint)high_percent);
+               LOGD("buffering time %d, per: 1~%d", init_buffering_time, high_percent);
 
                g_object_set(G_OBJECT(decodebin), "use-buffering", TRUE,
-                                                                                       "high-percent", (gint)high_percent,
-                                                                                       "low-percent", (gint)DEFAULT_BUFFER_LOW_PERCENT,
-                                                                                       "max-size-bytes", GET_MAX_BUFFER_BYTES(player->streamer),
-                                                                                       "max-size-time", (guint64)(GET_MAX_BUFFER_TIME(player->streamer) * GST_MSECOND),
+                                                                                       "high-percent", high_percent,
+                                                                                       "max-size-bytes", MAX_BUFFER_SIZE_BYTES,
+                                                                                       "max-size-time", (guint64)(MAX_BUFFER_SIZE_TIME * GST_MSECOND),
                                                                                        "max-size-buffers", 0, NULL);  // disable or automatic
        }
 
-       if (GST_STATE_CHANGE_FAILURE == gst_element_sync_state_with_parent(decodebin)) {
-               LOGE("failed to sync decodebin state with parent\n");
+       if (gst_element_sync_state_with_parent(decodebin) == GST_STATE_CHANGE_FAILURE) {
+               LOGE("failed to sync decodebin state with parent");
                goto ERROR;
        }
 
@@ -6275,6 +6160,9 @@ ERROR:
        if (sinkpad)
                gst_object_unref(GST_OBJECT(sinkpad));
 
+       if (qsrcpad)
+               gst_object_unref(GST_OBJECT(qsrcpad));
+
        if (queue2) {
                /* NOTE : Trying to dispose element queue0, but it is in READY instead of the NULL state.
                 * You need to explicitly set elements to the NULL state before
@@ -6310,14 +6198,14 @@ ERROR:
 }
 
 static int
-__mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_class, const gchar* mime)
+__mmplayer_check_not_supported_codec(mmplayer_t *player, const gchar *factory_class, const gchar *mime)
 {
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_RETURN_VAL_IF_FAIL(mime, MM_ERROR_INVALID_ARGUMENT);
 
-       LOGD("class : %s, mime : %s \n", factory_class, mime);
+       LOGD("class : %s, mime : %s", factory_class, mime);
 
        /* add missing plugin */
        /* NOTE : msl should check missing plugin for image mime type.
@@ -6326,7 +6214,7 @@ __mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_c
         */
        if (!(player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst)) {
                if (!(player->can_support_codec | player->videodec_linked | player->audiodec_linked)) {
-                       LOGD("not found demuxer\n");
+                       LOGD("not found demuxer");
                        player->not_found_demuxer = TRUE;
                        player->unlinked_demuxer_mime = g_strdup_printf("%s", mime);
 
@@ -6336,22 +6224,22 @@ __mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_c
 
        if (!g_strrstr(factory_class, "Demuxer")) {
                if ((g_str_has_prefix(mime, "video")) || (g_str_has_prefix(mime, "image"))) {
-                       LOGD("can support codec=0x%X, vdec_linked=%d, adec_linked=%d\n",
+                       LOGD("can support codec=0x%X, vdec_linked=%d, adec_linked=%d",
                                player->can_support_codec, player->videodec_linked, player->audiodec_linked);
 
                        /* check that clip have multi tracks or not */
                        if ((player->can_support_codec & FOUND_PLUGIN_VIDEO) && (player->videodec_linked)) {
-                               LOGD("video plugin is already linked\n");
+                               LOGD("video plugin is already linked");
                        } else {
-                               LOGW("add VIDEO to missing plugin\n");
+                               LOGW("add VIDEO to missing plugin");
                                player->not_supported_codec |= MISSING_PLUGIN_VIDEO;
                                player->unlinked_video_mime = g_strdup_printf("%s", mime);
                        }
                } else if (g_str_has_prefix(mime, "audio")) {
                        if ((player->can_support_codec & FOUND_PLUGIN_AUDIO) && (player->audiodec_linked)) {
-                               LOGD("audio plugin is already linked\n");
+                               LOGD("audio plugin is already linked");
                        } else {
-                               LOGW("add AUDIO to missing plugin\n");
+                               LOGW("add AUDIO to missing plugin");
                                player->not_supported_codec |= MISSING_PLUGIN_AUDIO;
                                player->unlinked_audio_mime = g_strdup_printf("%s", mime);
                        }
@@ -6364,11 +6252,10 @@ DONE:
        return MM_ERROR_NONE;
 }
 
-
 static void
 __mmplayer_pipeline_complete(GstElement *decodebin,  gpointer data)
 {
-       mm_player_t* player = (mm_player_t*)data;
+       mmplayer_t *player = (mmplayer_t *)data;
 
        MMPLAYER_FENTER();
 
@@ -6420,9 +6307,9 @@ __mmplayer_check_profile(void)
 }
 
 static gboolean
-__mmplayer_get_next_uri(mm_player_t *player)
+__mmplayer_get_next_uri(mmplayer_t *player)
 {
-       MMPlayerParseProfile profile;
+       mmplayer_parse_profile_t profile;
        gint uri_idx = 0;
        guint num_of_list = 0;
        char *uri = NULL;
@@ -6433,12 +6320,12 @@ __mmplayer_get_next_uri(mm_player_t *player)
        LOGD("num of uri list = %d, current uri idx %d", num_of_list, uri_idx);
        for (uri_idx++; uri_idx < num_of_list; uri_idx++) {
                uri = g_list_nth_data(player->uri_info.uri_list, uri_idx);
-               if (uri == NULL) {
+               if (!uri) {
                        LOGW("next uri does not exist");
                        continue;
                }
 
-               if (__mmplayer_parse_profile((const char*)uri, NULL, &profile) != MM_ERROR_NONE) {
+               if (__mmplayer_parse_profile((const char *)uri, NULL, &profile) != MM_ERROR_NONE) {
                        LOGE("failed to parse profile");
                        continue;
                }
@@ -6461,7 +6348,7 @@ __mmplayer_get_next_uri(mm_player_t *player)
        player->uri_info.uri_idx = uri_idx;
        mm_attrs_set_string_by_name(player->attrs, "profile_uri", uri);
 
-       if (mmf_attrs_commit(player->attrs)) {
+       if (mm_attrs_commit_all(player->attrs)) {
                LOGE("failed to commit");
                return FALSE;
        }
@@ -6471,13 +6358,12 @@ __mmplayer_get_next_uri(mm_player_t *player)
 }
 
 static gboolean
-__mmplayer_verify_gapless_play_path(mm_player_t *player)
+__mmplayer_verify_gapless_play_path(mmplayer_t *player)
 {
 #define REPEAT_COUNT_INFINITELY -1
 #define REPEAT_COUNT_MIN 2
 
        MMHandleType attrs = 0;
-       gint mode = MM_PLAYER_PD_MODE_NONE;
        gint video = 0;
        gint count = 0;
        gint gapless = 0;
@@ -6489,13 +6375,13 @@ __mmplayer_verify_gapless_play_path(mm_player_t *player)
        LOGD("checking for gapless play option");
 
        if (player->pipeline->textbin) {
-               LOGE("subtitle path is enabled. gapless play is not supported.\n");
+               LOGE("subtitle path is enabled. gapless play is not supported.");
                goto ERROR;
        }
 
        attrs = MMPLAYER_GET_ATTRS(player);
        if (!attrs) {
-               LOGE("fail to get attributes.\n");
+               LOGE("fail to get attributes.");
                goto ERROR;
        }
 
@@ -6508,13 +6394,6 @@ __mmplayer_verify_gapless_play_path(mm_player_t *player)
                goto ERROR;
        }
 
-       if (mm_attrs_get_int_by_name(attrs, "pd_mode", &mode) == MM_ERROR_NONE) {
-               if (mode == TRUE) {
-                       LOGW("pd mode\n");
-                       goto ERROR;
-               }
-       }
-
        if (mm_attrs_get_int_by_name(attrs, "profile_play_count", &count) != MM_ERROR_NONE)
                LOGE("failed to get play count");
 
@@ -6538,17 +6417,15 @@ __mmplayer_verify_gapless_play_path(mm_player_t *player)
                        /* decrease play count */
                        /* we succeeded to rewind. update play count and then wait for next EOS */
                        count--;
-
                        mm_attrs_set_int_by_name(attrs, "profile_play_count", count);
-
                        /* commit attribute */
-                       if (mmf_attrs_commit(attrs))
+                       if (mm_attrs_commit_all(attrs))
                                LOGE("failed to commit attribute");
+
                } else if (count != REPEAT_COUNT_INFINITELY) {
                        LOGD("there is no next uri and no repeat");
                        goto ERROR;
                }
-
                LOGD("looping cnt %d", count);
        } else {
                /* gapless playback path */
@@ -6557,7 +6434,6 @@ __mmplayer_verify_gapless_play_path(mm_player_t *player)
                        goto ERROR;
                }
        }
-
        return TRUE;
 
 ERROR:
@@ -6566,7 +6442,7 @@ ERROR:
 }
 
 static void
-__mmplayer_initialize_gapless_play(mm_player_t *player)
+__mmplayer_initialize_gapless_play(mmplayer_t *player)
 {
        int i;
 
@@ -6575,14 +6451,12 @@ __mmplayer_initialize_gapless_play(mm_player_t *player)
        player->smooth_streaming = FALSE;
        player->videodec_linked = 0;
        player->audiodec_linked = 0;
-       player->videosink_linked = 0;
-       player->audiosink_linked = 0;
        player->textsink_linked = 0;
        player->is_external_subtitle_present = FALSE;
        player->is_external_subtitle_added_now = FALSE;
        player->not_supported_codec = MISSING_PLUGIN_NONE;
        player->can_support_codec = FOUND_PLUGIN_NONE;
-       player->pending_seek.is_pending = FALSE;
+       player->pending_seek.is_pending = false;
        player->pending_seek.pos = 0;
        player->msg_posted = FALSE;
        player->has_many_types = FALSE;
@@ -6611,17 +6485,6 @@ __mmplayer_initialize_gapless_play(mm_player_t *player)
 
        mm_attrs_set_int_by_name(player->attrs, "content_video_found", 0);
 
-       /* clean found parsers */
-       if (player->parsers) {
-               GList *parsers = player->parsers;
-               for (; parsers; parsers = g_list_next(parsers)) {
-                       gchar *name = parsers->data;
-                       MMPLAYER_FREEIF(name);
-               }
-               g_list_free(player->parsers);
-               player->parsers = NULL;
-       }
-
        /* clean found audio decoders */
        if (player->audio_decoders) {
                GList *a_dec = player->audio_decoders;
@@ -6637,14 +6500,14 @@ __mmplayer_initialize_gapless_play(mm_player_t *player)
 }
 
 static void
-__mmplayer_activate_next_source(mm_player_t *player, GstState target)
+__mmplayer_activate_next_source(mmplayer_t *player, GstState target)
 {
-       MMPlayerGstElement *mainbin = NULL;
+       mmplayer_gst_element_t *mainbin = NULL;
        MMMessageParamType msg_param = {0,};
        GstElement *element = NULL;
        MMHandleType attrs = 0;
        char *uri = NULL;
-       enum MainElementID elem_idx = MMPLAYER_M_NUM;
+       main_element_id_e elem_idx = MMPLAYER_M_NUM;
 
        MMPLAYER_FENTER();
 
@@ -6667,7 +6530,7 @@ __mmplayer_activate_next_source(mm_player_t *player, GstState target)
 
        mm_attrs_get_string_by_name(attrs, "profile_uri", &uri);
 
-       if (__mmplayer_parse_profile((const char*)uri, NULL, &player->profile) != MM_ERROR_NONE) {
+       if (__mmplayer_parse_profile((const char *)uri, NULL, &player->profile) != MM_ERROR_NONE) {
                LOGE("failed to parse profile");
                msg_param.code = MM_ERROR_PLAYER_INVALID_URI;
                goto ERROR;
@@ -6702,7 +6565,7 @@ __mmplayer_activate_next_source(mm_player_t *player, GstState target)
        if (MMPLAYER_IS_HTTP_STREAMING(player)) {
                if (player->streamer == NULL) {
                        player->streamer = __mm_player_streaming_create();
-                       __mm_player_streaming_initialize(player->streamer);
+                       __mm_player_streaming_initialize(player->streamer, TRUE);
                }
 
                elem_idx = MMPLAYER_M_TYPEFIND;
@@ -6770,12 +6633,12 @@ ERROR:
 }
 
 static gboolean
-__mmplayer_deactivate_selector(mm_player_t *player, MMPlayerTrackType type)
+__mmplayer_deactivate_selector(mmplayer_t *player, mmplayer_track_type_e type)
 {
-       mm_player_selector_t *selector = &player->selector[type];
-       MMPlayerGstElement *sinkbin = NULL;
-       enum MainElementID selectorId = MMPLAYER_M_NUM;
-       enum MainElementID sinkId = MMPLAYER_M_NUM;
+       mmplayer_selector_t *selector = &player->selector[type];
+       mmplayer_gst_element_t *sinkbin = NULL;
+       main_element_id_e selectorId = MMPLAYER_M_NUM;
+       main_element_id_e sinkId = MMPLAYER_M_NUM;
        GstPad *srcpad = NULL;
        GstPad *sinkpad = NULL;
        gboolean send_notice = FALSE;
@@ -6860,7 +6723,7 @@ __mmplayer_deactivate_selector(mm_player_t *player, MMPlayerTrackType type)
 }
 
 static void
-__mmplayer_deactivate_old_path(mm_player_t *player)
+__mmplayer_deactivate_old_path(mmplayer_t *player)
 {
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player);
@@ -6876,7 +6739,7 @@ __mmplayer_deactivate_old_path(mm_player_t *player)
        __mmplayer_release_signal_connection(player, MM_PLAYER_SIGNAL_TYPE_AUTOPLUG);
 
        if (player->streamer) {
-               __mm_player_streaming_deinitialize(player->streamer);
+               __mm_player_streaming_initialize(player->streamer, FALSE);
                __mm_player_streaming_destroy(player->streamer);
                player->streamer = NULL;
        }
@@ -6902,46 +6765,32 @@ ERROR:
        return;
 }
 
-int _mmplayer_set_file_buffering_path(MMHandleType hplayer, const char* file_path)
-{
-       int result = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*) hplayer;
-       MMPLAYER_FENTER();
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       if (file_path) {
-               player->http_file_buffering_path = (gchar*)file_path;
-               LOGD("temp file path: %s\n", player->http_file_buffering_path);
-       }
-       MMPLAYER_FLEAVE();
-       return result;
-}
-
-int _mmplayer_set_uri(MMHandleType hplayer, const char* uri)
+int
+_mmplayer_set_uri(MMHandleType hplayer, const char *uri)
 {
        int result = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        mm_attrs_set_string_by_name(player->attrs, "profile_uri", uri);
-       if (mmf_attrs_commit(player->attrs)) {
-               LOGE("failed to commit the original uri.\n");
+       if (mm_attrs_commit_all(player->attrs)) {
+               LOGE("failed to commit the original uri.");
                result = MM_ERROR_PLAYER_INTERNAL;
        } else {
                if (_mmplayer_set_next_uri(hplayer, uri, TRUE) != MM_ERROR_NONE)
-                       LOGE("failed to add the original uri in the uri list.\n");
+                       LOGE("failed to add the original uri in the uri list.");
        }
 
        MMPLAYER_FLEAVE();
        return result;
 }
 
-int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_path)
+int
+_mmplayer_set_next_uri(MMHandleType hplayer, const char *uri, bool is_first_path)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        guint num_of_list = 0;
 
        MMPLAYER_FENTER();
@@ -6950,21 +6799,21 @@ int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_
        MMPLAYER_RETURN_VAL_IF_FAIL(uri, MM_ERROR_INVALID_ARGUMENT);
 
        if (player->pipeline && player->pipeline->textbin) {
-               LOGE("subtitle path is enabled.\n");
+               LOGE("subtitle path is enabled.");
                return MM_ERROR_PLAYER_INVALID_STATE;
        }
 
        num_of_list = g_list_length(player->uri_info.uri_list);
 
-       if (is_first_path == TRUE) {
+       if (is_first_path) {
                if (num_of_list == 0) {
                        player->uri_info.uri_list = g_list_append(player->uri_info.uri_list, g_strdup(uri));
-                       LOGD("add original path : %s", uri);
+                       SECURE_LOGD("add original path : %s", uri);
                } else {
                        player->uri_info.uri_list = g_list_delete_link(player->uri_info.uri_list, g_list_nth(player->uri_info.uri_list, 0));
                        player->uri_info.uri_list = g_list_insert(player->uri_info.uri_list, g_strdup(uri), 0);
 
-                       LOGD("change original path : %s", uri);
+                       SECURE_LOGD("change original path : %s", uri);
                }
        } else {
                MMHandleType attrs = 0;
@@ -6984,125 +6833,337 @@ int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_
                                player->uri_info.uri_list = g_list_append(player->uri_info.uri_list, g_strdup(original_uri));
                                player->uri_info.uri_idx = 0;
 
-                               LOGD("add original path at first : %s(%d)", original_uri);
+                               SECURE_LOGD("add original path at first : %s", original_uri);
                        }
                }
 
                player->uri_info.uri_list = g_list_append(player->uri_info.uri_list, g_strdup(uri));
-               LOGD("add new path : %s(total num of list = %d)", uri, g_list_length(player->uri_info.uri_list));
+               SECURE_LOGD("add new path : %s(total num of list = %d)", uri, g_list_length(player->uri_info.uri_list));
+       }
+
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_NONE;
+}
+
+int
+_mmplayer_get_next_uri(MMHandleType hplayer, char **uri)
+{
+       mmplayer_t *player = (mmplayer_t *)hplayer;
+       char *next_uri = NULL;
+       guint num_of_list = 0;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       num_of_list = g_list_length(player->uri_info.uri_list);
+
+       if (num_of_list > 0) {
+               gint uri_idx = player->uri_info.uri_idx;
+
+               if (uri_idx < num_of_list-1)
+                       uri_idx++;
+               else
+                       uri_idx = 0;
+
+               next_uri = g_list_nth_data(player->uri_info.uri_list, uri_idx);
+               LOGE("next uri idx : %d, uri = %s", uri_idx, next_uri);
+
+               *uri = g_strdup(next_uri);
        }
 
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;
 }
 
-int _mmplayer_get_next_uri(MMHandleType hplayer, char** uri)
-{
-       mm_player_t* player = (mm_player_t*) hplayer;
-       char *next_uri = NULL;
-       guint num_of_list = 0;
+static void
+__mmplayer_gst_decode_unknown_type(GstElement *elem,  GstPad *pad,
+       GstCaps *caps, gpointer data)
+{
+       mmplayer_t *player = (mmplayer_t *)data;
+       const gchar *klass = NULL;
+       const gchar *mime = NULL;
+       gchar *caps_str = NULL;
+
+       klass = gst_element_factory_get_metadata(gst_element_get_factory(elem), GST_ELEMENT_METADATA_KLASS);
+       mime = gst_structure_get_name(gst_caps_get_structure(caps, 0));
+       caps_str = gst_caps_to_string(caps);
+
+       LOGW("unknown type of caps : %s from %s",
+                                       caps_str, GST_ELEMENT_NAME(elem));
+
+       MMPLAYER_FREEIF(caps_str);
+
+       /* There is no available codec. */
+       __mmplayer_check_not_supported_codec(player, klass, mime);
+}
+
+static gboolean
+__mmplayer_gst_decode_autoplug_continue(GstElement *bin,  GstPad *pad,
+       GstCaps *caps,  gpointer data)
+{
+       mmplayer_t *player = (mmplayer_t *)data;
+       const char *mime = NULL;
+       gboolean ret = TRUE;
+
+       MMPLAYER_LOG_GST_CAPS_TYPE(caps);
+       mime = gst_structure_get_name(gst_caps_get_structure(caps, 0));
+
+       if (g_str_has_prefix(mime, "audio")) {
+               GstStructure *caps_structure = NULL;
+               gint samplerate = 0;
+               gint channels = 0;
+               gchar *caps_str = NULL;
+
+               caps_structure = gst_caps_get_structure(caps, 0);
+               gst_structure_get_int(caps_structure, "rate", &samplerate);
+               gst_structure_get_int(caps_structure, "channels", &channels);
+
+               if ((channels > 0 && samplerate == 0)) {
+                       LOGD("exclude audio...");
+                       ret = FALSE;
+               }
+
+               caps_str = gst_caps_to_string(caps);
+               /* set it directly because not sent by TAG */
+               if (g_strrstr(caps_str, "mobile-xmf"))
+                       mm_attrs_set_string_by_name(player->attrs, "content_audio_codec", "mobile-xmf");
+               MMPLAYER_FREEIF(caps_str);
+       } else if (g_str_has_prefix(mime, "video") && !player->ini.video_playback_supported) {
+               MMMessageParamType msg_param;
+               memset(&msg_param, 0, sizeof(MMMessageParamType));
+               msg_param.code = MM_ERROR_NOT_SUPPORT_API;
+               MMPLAYER_POST_MSG(player, MM_MESSAGE_ERROR, &msg_param);
+               LOGD("video file is not supported on this device");
+               ret = FALSE;
+       } else if (g_str_has_prefix(mime, "video") && player->videodec_linked) {
+               LOGD("already video linked");
+               ret = FALSE;
+       } else {
+               LOGD("found new stream");
+       }
+
+       return ret;
+}
+
+static gboolean
+__mmplayer_is_audio_offload_device_type(mmplayer_t *player)
+{
+       gboolean ret = TRUE;
+       GDBusConnection *conn = NULL;
+       GError *err = NULL;
+       GVariant *result = NULL;
+       const gchar *dbus_device_type = NULL;
+       const gchar *dbus_ret = NULL;
+       gint idx = 0;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (!conn || err) {
+               LOGE("failed g_bus_get_sync() (%s)", err ? err->message : NULL);
+               g_error_free(err);
+               ret = FALSE;
+               goto DONE;
+       }
+
+       result = g_dbus_connection_call_sync(conn,
+                                       "org.pulseaudio.Server",
+                                       "/org/pulseaudio/StreamManager",
+                                       "org.pulseaudio.StreamManager",
+                                       "GetCurrentMediaRoutingPath",
+                                       g_variant_new("(s)", "out"),
+                                       G_VARIANT_TYPE("(ss)"),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       2000,
+                                       NULL,
+                                       &err);
+       if (!result || err) {
+               LOGE("failed g_dbus_connection_call_sync() (%s)", err ? err->message : NULL);
+               g_error_free(err);
+               ret = FALSE;
+               goto DONE;
+       }
+
+       /* device type is listed in stream-map.json at mmfw-sysconf */
+       g_variant_get(result, "(&s&s)", &dbus_device_type, &dbus_ret);
+
+       LOGI("g_dbus_connection_call_sync() success (%s, %s)", dbus_device_type, dbus_ret);
+       if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+               ret = FALSE;
+               goto DONE;
+       }
+
+       /* the device type is listed in ini file among audio-jack, bt-a2dp, usb-audio, builtin-speaker */
+       for (idx = 0; player->ini.audio_offload_device_type[idx][0] != '\0'; idx++) {
+               if (strstr(dbus_device_type, player->ini.audio_offload_device_type[idx])) {
+                       LOGD("audio offload is supportable");
+                       ret = TRUE;
+                       goto DONE;
+               }
+       }
+
+       LOGD("audio offload is not supportable");
+       ret = FALSE;
+
+DONE:
+       g_variant_unref(result);
+       g_object_unref(conn);
+
+       return ret;
+}
+
+static void __mmplayer_rebuild_audio_pipeline(mmplayer_t *player)
+{
+       mmplayer_state_e current_state = MM_PLAYER_STATE_NONE;
+       gint64 position = 0;
+
+       MMPLAYER_RETURN_IF_FAIL(player && player->attrs &&
+               player->pipeline && player->pipeline->mainbin);
+
+       MMPLAYER_CMD_LOCK(player);
+       current_state = MMPLAYER_CURRENT_STATE(player);
+
+       if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &position))
+               LOGW("getting current position failed in paused");
+
+       _mmplayer_unrealize((MMHandleType)player);
+       _mmplayer_realize((MMHandleType)player);
+
+       _mmplayer_set_position((MMHandleType)player, position);
 
-       MMPLAYER_FENTER();
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       /* async not to be blocked in streaming case */
+       mm_attrs_set_int_by_name(player->attrs, "profile_prepare_async", TRUE);
+       if (mm_attrs_commit_all(player->attrs))
+               LOGE("failed to commit");
 
-       num_of_list = g_list_length(player->uri_info.uri_list);
+       _mmplayer_pause((MMHandleType)player);
 
-       if (num_of_list > 0) {
-               gint uri_idx = player->uri_info.uri_idx;
+       if (current_state == MM_PLAYER_STATE_PLAYING)
+               _mmplayer_start((MMHandleType)player);
+       MMPLAYER_CMD_UNLOCK(player);
 
-               if (uri_idx < num_of_list-1)
-                       uri_idx++;
-               else
-                       uri_idx = 0;
+       LOGD("rebuilding audio pipeline is completed.");
+}
 
-               next_uri = g_list_nth_data(player->uri_info.uri_list, uri_idx);
-               LOGE("next uri idx : %d, uri = %s\n", uri_idx, next_uri);
+void __mmplayer_audio_device_connected_cb(MMSoundDevice_t device_h, bool is_connected, void *user_data)
+{
+       mmplayer_t *player = (mmplayer_t *)user_data;
+       mm_sound_device_type_e dev_type = MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER;
+       gboolean is_supportable = FALSE;
 
-               *uri = g_strdup(next_uri);
+       if (mm_sound_get_device_type(device_h, &dev_type) != MM_ERROR_NONE)
+               LOGW("failed to get device type");
+       else
+               LOGD("dev type (%d), connected (%d)", dev_type, is_connected);
+
+       if ((dev_type != MM_SOUND_DEVICE_TYPE_BLUETOOTH_A2DP) &&
+               (dev_type != MM_SOUND_DEVICE_TYPE_AUDIOJACK) &&
+               (dev_type != MM_SOUND_DEVICE_TYPE_USB_AUDIO)) {
+               LOGD("ignore this dev connected info");
+               return;
        }
 
-       MMPLAYER_FLEAVE();
-       return MM_ERROR_NONE;
+       is_supportable = __mmplayer_is_audio_offload_device_type(player);
+       if (player->build_audio_offload == is_supportable) {
+               LOGD("keep current pipeline without re-building");
+               return;
+       }
+
+       /* rebuild pipeline */
+       LOGD("re-build pipeline - offload: %d", is_supportable);
+       player->build_audio_offload = FALSE;
+       __mmplayer_rebuild_audio_pipeline(player);
+
+       return;
 }
 
-static void
-__mmplayer_gst_decode_unknown_type(GstElement *elem,  GstPad* pad,
-GstCaps *caps, gpointer data)
+static gboolean
+__mmplayer_add_audio_device_connected_cb(mmplayer_t *player)
 {
-       mm_player_t* player = (mm_player_t*)data;
-       const gchar* klass = NULL;
-       const gchar* mime = NULL;
-       gchar* caps_str = NULL;
-
-       klass = gst_element_factory_get_metadata(gst_element_get_factory(elem), GST_ELEMENT_METADATA_KLASS);
-       mime = gst_structure_get_name(gst_caps_get_structure(caps, 0));
-       caps_str = gst_caps_to_string(caps);
+       unsigned int id = 0;
 
-       LOGW("unknown type of caps : %s from %s",
-                                       caps_str, GST_ELEMENT_NAME(elem));
+       if (player->audio_device_cb_id != 0) {
+               LOGW("audio device connected cb was already added (%u)", player->audio_device_cb_id);
+               return TRUE;
+       }
 
-       MMPLAYER_FREEIF(caps_str);
+       if (mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG,
+                               __mmplayer_audio_device_connected_cb, player, &id) == MM_ERROR_NONE) {
+               LOGD("added device connected cb (%u)", id);
+               player->audio_device_cb_id = id;
+       } else {
+               LOGW("failed to add device connected cb");
+               return FALSE;
+       }
 
-       /* There is no available codec. */
-       __mmplayer_check_not_supported_codec(player, klass, mime);
+       return TRUE;
 }
 
 static gboolean
-__mmplayer_gst_decode_autoplug_continue(GstElement *bin,  GstPad* pad,
-GstCaps * caps,  gpointer data)
+__mmplayer_can_build_audio_offload_path(mmplayer_t *player)
 {
-       mm_player_t* player = (mm_player_t*)data;
-       const char* mime = NULL;
-       gboolean ret = TRUE;
+       gboolean ret = FALSE;
+       GstElementFactory *factory = NULL;
 
-       MMPLAYER_LOG_GST_CAPS_TYPE(caps);
-       mime = gst_structure_get_name(gst_caps_get_structure(caps, 0));
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->attrs, FALSE);
 
-       if (g_str_has_prefix(mime, "audio")) {
-               GstStructure* caps_structure = NULL;
-               gint samplerate = 0;
-               gint channels = 0;
-               gchar *caps_str = NULL;
+       LOGD("current stream : %s, sink: %s", player->type, player->ini.audio_offload_sink_element);
+       if (!__mmplayer_is_only_mp3_type(player->type))
+               goto DONE;
 
-               caps_structure = gst_caps_get_structure(caps, 0);
-               gst_structure_get_int(caps_structure, "rate", &samplerate);
-               gst_structure_get_int(caps_structure, "channels", &channels);
+       if (!strcmp(player->ini.audio_offload_sink_element, "")) {
+               LOGD("there is no audio offload sink");
+               goto DONE;
+       }
 
-               if ((channels > 0 && samplerate == 0)) {
-                       LOGD("exclude audio...");
-                       ret = FALSE;
-               }
+       if (player->ini.audio_offload_device_type[0][0] == '\0') {
+               LOGW("there is no audio device type to support offload");
+               goto DONE;
+       }
 
-               caps_str = gst_caps_to_string(caps);
-               /* set it directly because not sent by TAG */
-               if (g_strrstr(caps_str, "mobile-xmf"))
-                       mm_attrs_set_string_by_name(player->attrs, "content_audio_codec", "mobile-xmf");
-               MMPLAYER_FREEIF(caps_str);
-       } else if (g_str_has_prefix(mime, "video") && !player->ini.video_playback_supported) {
-               MMMessageParamType msg_param;
-               memset(&msg_param, 0, sizeof(MMMessageParamType));
-               msg_param.code = MM_ERROR_NOT_SUPPORT_API;
-               MMPLAYER_POST_MSG(player, MM_MESSAGE_ERROR, &msg_param);
-               LOGD("video file is not supported on this device");
-               ret = FALSE;
-       } else if (g_str_has_prefix(mime, "video") && player->videodec_linked) {
-               LOGD("already video linked");
-               ret = FALSE;
-       } else {
-               LOGD("found new stream");
+       factory = gst_element_factory_find(player->ini.audio_offload_sink_element);
+       if (!factory) {
+               LOGW("there is no installed audio offload sink element");
+               goto DONE;
        }
+       gst_object_unref(factory);
+
+       if (!__mmplayer_add_audio_device_connected_cb(player))
+               goto DONE;
+
+       if (!__mmplayer_is_audio_offload_device_type(player))
+               goto DONE;
 
+       LOGD("audio offload can be built");
+       ret = TRUE;
+
+DONE:
+       MMPLAYER_FLEAVE();
        return ret;
 }
 
-static int
-__mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* caps, char* factory_name)
+static GstAutoplugSelectResult
+__mmplayer_check_codec_info(mmplayer_t *player, const char *klass, GstCaps *caps, char *factory_name)
 {
-       int ret = MM_ERROR_NONE;
+       GstAutoplugSelectResult ret = GST_AUTOPLUG_SELECT_TRY;
        int idx = 0;
        int codec_type = MM_PLAYER_CODEC_TYPE_DEFAULT;
+       int audio_offload = 0;
 
        if ((g_strrstr(klass, "Codec/Decoder/Audio"))) {
+               mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_AUDIO_OFFLOAD, &audio_offload); /* user requirement */
+
+               if (audio_offload && __mmplayer_can_build_audio_offload_path(player)) {
+                       LOGD("expose audio path to build offload output path");
+                       player->build_audio_offload = TRUE;
+                       /* update codec info */
+                       player->not_supported_codec &= MISSING_PLUGIN_VIDEO;
+                       player->can_support_codec |= FOUND_PLUGIN_AUDIO;
+                       player->audiodec_linked = 1;
+
+                       ret = GST_AUTOPLUG_SELECT_EXPOSE;
+                       goto DONE;
+               }
+
                mm_attrs_get_int_by_name(player->attrs, "audio_codec_type", &codec_type);
 
                LOGD("audio codec type: %d", codec_type);
@@ -7111,7 +7172,7 @@ __mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* cap
                        for (idx = 0; player->ini.audiocodec_element_sw[idx][0] != '\0'; idx++) {
                                if (strstr(factory_name, player->ini.audiocodec_element_sw[idx])) {
                                        LOGW("skipping sw acodec:[%s] by codec type", factory_name);
-                                       ret = MM_ERROR_PLAYER_INTERNAL;
+                                       ret = GST_AUTOPLUG_SELECT_SKIP;
                                        goto DONE;
                                }
                        }
@@ -7120,7 +7181,7 @@ __mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* cap
                        if (strcmp(player->ini.audiocodec_element_hw, "") &&
                            g_strrstr(factory_name, player->ini.audiocodec_element_hw)) {
                                LOGW("skipping hw acodec:[%s] by codec type", factory_name);
-                               ret = MM_ERROR_PLAYER_INTERNAL;
+                               ret = GST_AUTOPLUG_SELECT_SKIP;
                                goto DONE;
                        }
                }
@@ -7144,7 +7205,7 @@ __mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* cap
                        for (idx = 0; player->ini.videocodec_element_sw[idx][0] != '\0'; idx++) {
                                if (strstr(factory_name, player->ini.videocodec_element_sw[idx])) {
                                        LOGW("skipping sw vcodec:[%s] by codec type", factory_name);
-                                       ret = MM_ERROR_PLAYER_INTERNAL;
+                                       ret = GST_AUTOPLUG_SELECT_SKIP;
                                        goto DONE;
                                }
                        }
@@ -7152,7 +7213,7 @@ __mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* cap
                        /* hw codec is skipped */
                        if (g_strrstr(factory_name, player->ini.videocodec_element_hw)) {
                                LOGW("skipping hw vcodec:[%s] by codec type", factory_name);
-                               ret = MM_ERROR_PLAYER_INTERNAL;
+                               ret = GST_AUTOPLUG_SELECT_SKIP;
                                goto DONE;
                        }
                }
@@ -7168,12 +7229,12 @@ __mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* cap
                                                &player->video_decoder_resource)
                                        != MM_RESOURCE_MANAGER_ERROR_NONE) {
                                        LOGE("could not mark video_decoder resource for acquire");
-                                       ret = MM_ERROR_PLAYER_INTERNAL;
+                                       ret = GST_AUTOPLUG_SELECT_SKIP;
                                        goto DONE;
                                }
                        } else {
                                LOGW("video decoder resource is already acquired, skip it.");
-                               ret = MM_ERROR_PLAYER_INTERNAL;
+                               ret = GST_AUTOPLUG_SELECT_SKIP;
                                goto DONE;
                        }
 
@@ -7181,8 +7242,8 @@ __mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* cap
                        /* acquire resources for video playing */
                        if (mm_resource_manager_commit(player->resource_manager)
                                        != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               LOGE("could not acquire resources for video decoding\n");
-                               ret = MM_ERROR_PLAYER_INTERNAL;
+                               LOGE("could not acquire resources for video decoding");
+                               ret = GST_AUTOPLUG_SELECT_SKIP;
                                goto DONE;
                        }
                }
@@ -7198,23 +7259,15 @@ DONE:
 }
 
 gint
-__mmplayer_gst_decode_autoplug_select(GstElement *bin,  GstPadpad,
-GstCaps* caps, GstElementFactory* factory, gpointer data)
+__mmplayer_gst_decode_autoplug_select(GstElement *bin,  GstPad *pad,
+       GstCaps *caps, GstElementFactory *factory, gpointer data)
 {
-       /* NOTE : GstAutoplugSelectResult is defined in gstplay-enum.h but not exposed
-        We are defining our own and will be removed when it actually exposed */
-       typedef enum {
-               GST_AUTOPLUG_SELECT_TRY,
-               GST_AUTOPLUG_SELECT_EXPOSE,
-               GST_AUTOPLUG_SELECT_SKIP
-       } GstAutoplugSelectResult;
-
        GstAutoplugSelectResult result = GST_AUTOPLUG_SELECT_TRY;
-       mm_player_t* player = (mm_player_t*)data;
+       mmplayer_t *player = (mmplayer_t *)data;
 
-       gcharfactory_name = NULL;
-       gcharcaps_str = NULL;
-       const gcharklass = NULL;
+       gchar *factory_name = NULL;
+       gchar *caps_str = NULL;
+       const gchar *klass = NULL;
        gint idx = 0;
 
        factory_name = GST_OBJECT_NAME(factory);
@@ -7267,7 +7320,7 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
         * So, those plugins should be skipped for error handling.
         */
        if (g_strrstr(klass, "Codec/Decoder/Image")) {
-               LOGD("skipping [%s] by not required\n", factory_name);
+               LOGD("skipping [%s] by not required", factory_name);
                result = GST_AUTOPLUG_SELECT_SKIP;
                goto DONE;
        }
@@ -7275,13 +7328,13 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
        if ((MMPLAYER_IS_MS_BUFF_SRC(player)) &&
                (g_strrstr(klass, "Codec/Demuxer") || (g_strrstr(klass, "Codec/Parser")))) {
                // TO CHECK : subtitle if needed, add subparse exception.
-               LOGD("skipping parser/demuxer [%s] in es player by not required\n", factory_name);
+               LOGD("skipping parser/demuxer [%s] in es player by not required", factory_name);
                result = GST_AUTOPLUG_SELECT_SKIP;
                goto DONE;
        }
 
        if (g_strrstr(factory_name, "mpegpsdemux")) {
-               LOGD("skipping PS container - not support\n");
+               LOGD("skipping PS container - not support");
                result = GST_AUTOPLUG_SELECT_SKIP;
                goto DONE;
        }
@@ -7298,8 +7351,8 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
 
                /* don't make video because of not required */
                if ((stype == MM_DISPLAY_SURFACE_NULL) &&
-                       (player->set_mode.media_packet_video_stream == FALSE)) {
-                       LOGD("no video because it's not required. -> return expose");
+                       (!player->set_mode.video_export)) {
+                       LOGD("no need video decoding, expose pad");
                        result = GST_AUTOPLUG_SELECT_EXPOSE;
                        goto DONE;
                }
@@ -7322,9 +7375,9 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
        }
 
        if (g_strrstr(klass, "Codec/Decoder")) {
-               if (__mmplayer_check_codec_info(player, klass, caps, factory_name) != MM_ERROR_NONE) {
-                       LOGD("skipping %s codec", factory_name);
-                       result = GST_AUTOPLUG_SELECT_SKIP;
+               result = __mmplayer_check_codec_info(player, klass, caps, factory_name);
+               if (result != GST_AUTOPLUG_SELECT_TRY) {
+                       LOGW("skip add decoder");
                        goto DONE;
                }
        }
@@ -7336,30 +7389,33 @@ DONE:
 }
 
 static void
-__mmplayer_gst_decode_pad_removed(GstElement *elem,  GstPadnew_pad,
-gpointer data)
+__mmplayer_gst_decode_pad_removed(GstElement *elem,  GstPad *new_pad,
+       gpointer data)
 {
-       //mm_player_t* player = (mm_player_t*)data;
-       GstCapscaps = NULL;
+       //mmplayer_t *player = (mmplayer_t *)data;
+       GstCaps *caps = NULL;
 
-       LOGD("[Decodebin2] pad-removed signal\n");
+       LOGD("[Decodebin2] pad-removed signal");
 
        caps = gst_pad_query_caps(new_pad, NULL);
-       if (caps) {
-               gchar* caps_str = NULL;
-               caps_str = gst_caps_to_string(caps);
+       if (!caps) {
+               LOGW("query caps is NULL");
+               return;
+       }
 
-               LOGD("pad removed caps : %s from %s", caps_str, GST_ELEMENT_NAME(elem));
+       gchar *caps_str = NULL;
+       caps_str = gst_caps_to_string(caps);
 
-               MMPLAYER_FREEIF(caps_str);
-               gst_caps_unref(caps);
-       }
+       LOGD("pad removed caps : %s from %s", caps_str, GST_ELEMENT_NAME(elem));
+
+       MMPLAYER_FREEIF(caps_str);
+       gst_caps_unref(caps);
 }
 
 static void
 __mmplayer_gst_decode_drained(GstElement *bin, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*)data;
+       mmplayer_t *player = (mmplayer_t *)data;
        GstIterator *iter = NULL;
        GValue item = { 0, };
        GstPad *pad = NULL;
@@ -7433,32 +7489,23 @@ __mmplayer_gst_decode_drained(GstElement *bin, gpointer data)
 void
 __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data)
 {
-       mm_player_t* player = (mm_player_t*)data;
-       const gcharklass = NULL;
-       gcharfactory_name = NULL;
+       mmplayer_t *player = (mmplayer_t *)data;
+       const gchar *klass = NULL;
+       gchar *factory_name = NULL;
 
        klass = gst_element_factory_get_metadata(gst_element_get_factory(element), GST_ELEMENT_METADATA_KLASS);
        factory_name = GST_OBJECT_NAME(gst_element_get_factory(element));
 
-       LOGD("new elem klass: %s, factory_name: %s, new elem name : %s\n", klass, factory_name, GST_ELEMENT_NAME(element));
+       LOGD("new elem klass: %s, factory_name: %s, new elem name : %s", klass, factory_name, GST_ELEMENT_NAME(element));
 
        if (__mmplayer_add_dump_buffer_probe(player, element))
                LOGD("add buffer probe");
 
-       //<-
        if (g_strrstr(klass, "Codec/Decoder/Audio")) {
-               gcharselected = NULL;
+               gchar *selected = NULL;
                selected = g_strdup(GST_ELEMENT_NAME(element));
                player->audio_decoders = g_list_append(player->audio_decoders, selected);
        }
-       //-> temp code
-
-       if (g_strrstr(klass, "Parser")) {
-               gchar* selected = NULL;
-
-               selected = g_strdup(factory_name);
-               player->parsers = g_list_append(player->parsers, selected);
-       }
 
        if (g_strrstr(klass, "Demuxer/Adaptive")) {
                player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].id = MMPLAYER_M_ADAPTIVE_DEMUX;
@@ -7472,20 +7519,10 @@ __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data
                                                "max-video-width", player->adaptive_info.limit.width,
                                                "max-video-height", player->adaptive_info.limit.height, NULL);
 
-       } else if (g_strrstr(klass, "Demux") || g_strrstr(klass, "Parse")) {
-               /* FIXIT : first value will be overwritten if there's more
-                * than 1 demuxer/parser
-                */
-
-               //LOGD("plugged element is demuxer. take it\n");
+       } else if (g_strrstr(klass, "Demuxer")) {
+               //LOGD("plugged element is demuxer. take it");
                player->pipeline->mainbin[MMPLAYER_M_DEMUX].id = MMPLAYER_M_DEMUX;
                player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst = element;
-
-               /*Added for multi audio support */ // Q. del?
-               if (g_strrstr(klass, "Demux")) {
-                       player->pipeline->mainbin[MMPLAYER_M_DEMUX_EX].id = MMPLAYER_M_DEMUX_EX;
-                       player->pipeline->mainbin[MMPLAYER_M_DEMUX_EX].gst = element;
-               }
        }
 
        if (g_strrstr(factory_name, "asfdemux") || g_strrstr(factory_name, "qtdemux") || g_strrstr(factory_name, "avidemux")) {
@@ -7496,13 +7533,10 @@ __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data
 
        // to support trust-zone only
        if (g_strrstr(factory_name, "asfdemux")) {
-               LOGD("set file-location %s\n", player->profile.uri);
+               LOGD("set file-location %s", player->profile.uri);
                g_object_set(G_OBJECT(element), "file-location", player->profile.uri, NULL);
-
-               if (player->video_hub_download_mode == TRUE)
-                       g_object_set(G_OBJECT(element), "downloading-mode", player->video_hub_download_mode, NULL);
        } else if (g_strrstr(factory_name, "legacyh264parse")) {
-               LOGD("[%s] output-format to legacyh264parse\n", "mssdemux");
+               LOGD("[%s] output-format to legacyh264parse", "mssdemux");
                g_object_set(G_OBJECT(element), "output-format", 1, NULL); /* NALU/Byte Stream format */
        } else if (g_strrstr(factory_name, "mpegaudioparse")) {
                if ((MMPLAYER_IS_HTTP_STREAMING(player)) &&
@@ -7521,12 +7555,11 @@ __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data
                player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].id = MMPLAYER_M_DEMUXED_S_BUFFER;
                player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst = element;
 
-               if (!MMPLAYER_IS_HTTP_PD(player) &&
-                       ((MMPLAYER_IS_HTTP_STREAMING(player)) ||
+               if ((MMPLAYER_IS_HTTP_STREAMING(player)) ||
                        (MMPLAYER_IS_HTTP_LIVE_STREAMING(player)) ||
-                       (MMPLAYER_IS_DASH_STREAMING(player)))) {
+                       (MMPLAYER_IS_DASH_STREAMING(player))) {
                        /* in case of multiqueue, max bytes size is defined with fixed value in mm_player_streaming.h*/
-                       __mm_player_streaming_set_multiqueue(player->streamer, element, player->ini.http_buffering_time, 1.0, player->ini.http_buffering_limit);
+                       __mm_player_streaming_set_multiqueue(player->streamer, element);
                        __mm_player_streaming_sync_property(player->streamer, player->pipeline->mainbin[MMPLAYER_M_AUTOPLUG].gst);
                }
 
@@ -7536,7 +7569,7 @@ __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data
 }
 
 static void
-__mmplayer_release_misc(mm_player_t* player)
+__mmplayer_release_misc(mmplayer_t *player)
 {
        int i;
        bool cur_mode = player->set_mode.rich_audio;
@@ -7544,13 +7577,13 @@ __mmplayer_release_misc(mm_player_t* player)
 
        MMPLAYER_RETURN_IF_FAIL(player);
 
-       player->video_stream_cb = NULL;
-       player->video_stream_cb_user_param = NULL;
-       player->video_stream_prerolled = FALSE;
+       player->video_decoded_cb = NULL;
+       player->video_decoded_cb_user_param = NULL;
+       player->video_stream_prerolled = false;
 
-       player->audio_stream_render_cb = NULL;
-       player->audio_stream_cb_user_param = NULL;
-       player->audio_stream_sink_sync = false;
+       player->audio_decoded_cb = NULL;
+       player->audio_decoded_cb_user_param = NULL;
+       player->audio_extract_opt = MM_PLAYER_AUDIO_EXTRACT_DEFAULT;
 
        player->video_stream_changed_cb = NULL;
        player->video_stream_changed_cb_user_param = NULL;
@@ -7573,21 +7606,25 @@ __mmplayer_release_misc(mm_player_t* player)
        player->http_content_size = 0;
        player->not_supported_codec = MISSING_PLUGIN_NONE;
        player->can_support_codec = FOUND_PLUGIN_NONE;
-       player->pending_seek.is_pending = FALSE;
+       player->pending_seek.is_pending = false;
        player->pending_seek.pos = 0;
        player->msg_posted = FALSE;
        player->has_many_types = FALSE;
        player->is_subtitle_force_drop = FALSE;
        player->play_subtitle = FALSE;
        player->adjust_subtitle_pos = 0;
-       player->last_multiwin_status = FALSE;
        player->has_closed_caption = FALSE;
-       player->set_mode.media_packet_video_stream = FALSE;
+       player->set_mode.video_export = false;
        player->profile.uri_type = MM_PLAYER_URI_TYPE_NONE;
-       memset(&player->set_mode, 0, sizeof(MMPlayerSetMode));
+       memset(&player->set_mode, 0, sizeof(mmplayer_setting_mode_t));
        /* recover mode */
        player->set_mode.rich_audio = cur_mode;
 
+       if (player->audio_device_cb_id > 0 &&
+               mm_sound_remove_device_connected_callback(player->audio_device_cb_id) != MM_ERROR_NONE)
+               LOGW("failed to remove audio device_connected_callback");
+       player->audio_device_cb_id = 0;
+
        for (i = 0; i < MM_PLAYER_STREAM_COUNT_MAX; i++) {
                player->bitrate[i] = 0;
                player->maximum_bitrate[i] = 0;
@@ -7639,7 +7676,7 @@ __mmplayer_release_misc(mm_player_t* player)
 }
 
 static void
-__mmplayer_release_misc_post(mm_player_t* player)
+__mmplayer_release_misc_post(mmplayer_t *player)
 {
        char *original_uri = NULL;
        MMPLAYER_FENTER();
@@ -7650,17 +7687,6 @@ __mmplayer_release_misc_post(mm_player_t* player)
 
        mm_attrs_set_int_by_name(player->attrs, "content_video_found", 0);
 
-       /* clean found parsers */
-       if (player->parsers) {
-               GList *parsers = player->parsers;
-               for (; parsers; parsers = g_list_next(parsers)) {
-                       gchar *name = parsers->data;
-                       MMPLAYER_FREEIF(name);
-               }
-               g_list_free(player->parsers);
-               player->parsers = NULL;
-       }
-
        /* clean found audio decoders */
        if (player->audio_decoders) {
                GList *a_dec = player->audio_decoders;
@@ -7678,10 +7704,10 @@ __mmplayer_release_misc_post(mm_player_t* player)
 
                if (player->attrs) {
                        mm_attrs_set_string_by_name(player->attrs, "profile_uri", original_uri);
-                       LOGD("restore original uri = %s\n", original_uri);
+                       LOGD("restore original uri = %s", original_uri);
 
-                       if (mmf_attrs_commit(player->attrs))
-                               LOGE("failed to commit the original uri.\n");
+                       if (mm_attrs_commit_all(player->attrs))
+                               LOGE("failed to commit the original uri.");
                }
 
                GList *uri_list = player->uri_info.uri_list;
@@ -7712,7 +7738,7 @@ __mmplayer_release_misc_post(mm_player_t* player)
 }
 
 gboolean
-__mmplayer_check_subtitle(mm_player_t* player)
+__mmplayer_check_subtitle(mmplayer_t *player)
 {
        MMHandleType attrs = 0;
        char *subtitle_uri = NULL;
@@ -7730,7 +7756,7 @@ __mmplayer_check_subtitle(mm_player_t* player)
        if (!subtitle_uri || !strlen(subtitle_uri))
                return FALSE;
 
-       SECURE_LOGD("subtitle uri is %s[%d]", subtitle_uri, strlen(subtitle_uri));
+       SECURE_LOGD("subtitle uri is %s[%zu]", subtitle_uri, strlen(subtitle_uri));
        player->is_external_subtitle_present = TRUE;
 
        MMPLAYER_FLEAVE();
@@ -7739,7 +7765,7 @@ __mmplayer_check_subtitle(mm_player_t* player)
 }
 
 void
-__mmplayer_cancel_eos_timer(mm_player_t* player)
+__mmplayer_cancel_eos_timer(mmplayer_t *player)
 {
        MMPLAYER_RETURN_IF_FAIL(player);
 
@@ -7753,38 +7779,36 @@ __mmplayer_cancel_eos_timer(mm_player_t* player)
 }
 
 static void
-__mmplayer_add_sink(mm_player_t* player, GstElement* sink)
+__mmplayer_add_sink(mmplayer_t *player, GstElement *sink)
 {
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_IF_FAIL(player);
        MMPLAYER_RETURN_IF_FAIL(sink);
 
-       player->sink_elements =
-               g_list_append(player->sink_elements, sink);
+       player->sink_elements = g_list_append(player->sink_elements, sink);
 
        MMPLAYER_FLEAVE();
 }
 
 static void
-__mmplayer_del_sink(mm_player_t* player, GstElement* sink)
+__mmplayer_del_sink(mmplayer_t *player, GstElement *sink)
 {
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_IF_FAIL(player);
        MMPLAYER_RETURN_IF_FAIL(sink);
 
-       player->sink_elements =
-                       g_list_remove(player->sink_elements, sink);
+       player->sink_elements = g_list_remove(player->sink_elements, sink);
 
        MMPLAYER_FLEAVE();
 }
 
 void
-__mmplayer_add_signal_connection(mm_player_t* player, GObject* object,
-                       MMPlayerSignalType type, const gchar* signal, GCallback cb_funct, gpointer u_data)
+__mmplayer_add_signal_connection(mmplayer_t *player, GObject *object,
+       mmplayer_signal_type_e type, const gchar *signal, GCallback cb_funct, gpointer u_data)
 {
-       MMPlayerSignalItem* item = NULL;
+       mmplayer_signal_item_t *item = NULL;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_IF_FAIL(player);
@@ -7794,7 +7818,7 @@ __mmplayer_add_signal_connection(mm_player_t* player, GObject* object,
                return;
        }
 
-       item = (MMPlayerSignalItem*)g_malloc(sizeof(MMPlayerSignalItem));
+       item = (mmplayer_signal_item_t *)g_try_malloc(sizeof(mmplayer_signal_item_t));
        if (!item) {
                LOGE("cannot connect signal [%s]", signal);
                return;
@@ -7826,10 +7850,10 @@ __mmplayer_add_signal_connection(mm_player_t* player, GObject* object,
  *    g_signal_handler_disconnect(instance, id);
  */
 static void
-__mmplayer_release_signal_connection(mm_player_t* player, MMPlayerSignalType type)
+__mmplayer_release_signal_connection(mmplayer_t *player, mmplayer_signal_type_e type)
 {
-       GListsig_list = NULL;
-       MMPlayerSignalItem* item = NULL;
+       GList *sig_list = NULL;
+       mmplayer_signal_item_t *item = NULL;
 
        MMPLAYER_FENTER();
 
@@ -7867,9 +7891,10 @@ __mmplayer_release_signal_connection(mm_player_t* player, MMPlayerSignalType typ
        return;
 }
 
-int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay)
+int
+_mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay)
 {
-       mm_player_t* player = 0;
+       mmplayer_t *player = 0;
        int prev_display_surface_type = 0;
        void *prev_display_overlay = NULL;
 
@@ -7914,7 +7939,7 @@ int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface
        LOGD("store display attribute for given surface type(%d)", surface_type);
        mm_attrs_set_int_by_name(player->attrs, "display_surface_type", surface_type);
        mm_attrs_set_data_by_name(player->attrs, "display_overlay", display_overlay, sizeof(display_overlay));
-       if (mmf_attrs_commit(player->attrs)) {
+       if (mm_attrs_commit_all(player->attrs)) {
                LOGE("failed to commit attribute");
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_INTERNAL;
@@ -7925,9 +7950,10 @@ int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface
 }
 
 /* Note : if silent is true, then subtitle would not be displayed. :*/
-int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent)
+int
+_mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
@@ -7936,17 +7962,18 @@ int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent)
 
        player->set_mode.subtitle_off = silent;
 
-       LOGD("subtitle is %s.\n", player->set_mode.subtitle_off ? "ON" : "OFF");
+       LOGD("subtitle is %s.", player->set_mode.subtitle_off ? "ON" : "OFF");
 
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;
 }
 
-int _mmplayer_sync_subtitle_pipeline(mm_player_t* player)
+int
+_mmplayer_sync_subtitle_pipeline(mmplayer_t *player)
 {
-       MMPlayerGstElement* mainbin = NULL;
-       MMPlayerGstElement* textbin = NULL;
+       mmplayer_gst_element_t *mainbin = NULL;
+       mmplayer_gst_element_t *textbin = NULL;
        GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
        GstState current_state = GST_STATE_VOID_PENDING;
        GstState element_state = GST_STATE_VOID_PENDING;
@@ -7990,12 +8017,11 @@ int _mmplayer_sync_subtitle_pipeline(mm_player_t* player)
 
                ret = gst_element_get_state(mainbin[MMPLAYER_M_SUBSRC].gst, &element_state, &element_pending_state, 5 * GST_SECOND);
                if (GST_STATE_CHANGE_FAILURE == ret) {
-                       LOGE("fail to state change.\n");
+                       LOGE("fail to state change.");
                        result = MM_ERROR_PLAYER_INTERNAL;
                        goto ERROR;
                }
        }
-
        gst_element_set_base_time(textbin[MMPLAYER_T_BIN].gst, base_time);
        gst_element_set_start_time(textbin[MMPLAYER_T_BIN].gst, start_time);
 
@@ -8007,7 +8033,7 @@ int _mmplayer_sync_subtitle_pipeline(mm_player_t* player)
        // seek to current position
        if (!gst_element_query_position(mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &time)) {
                result = MM_ERROR_PLAYER_INVALID_STATE;
-               LOGE("gst_element_query_position failed, invalid state\n");
+               LOGE("gst_element_query_position failed, invalid state");
                goto ERROR;
        }
 
@@ -8048,16 +8074,16 @@ ERROR:
 }
 
 static int
-__mmplayer_change_external_subtitle_language(mm_player_t* player, const char* filepath)
+__mmplayer_change_external_subtitle_language(mmplayer_t *player, const char *filepath)
 {
        GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
        GstState current_state = GST_STATE_VOID_PENDING;
 
        MMHandleType attrs = 0;
-       MMPlayerGstElement* mainbin = NULL;
-       MMPlayerGstElement* textbin = NULL;
+       mmplayer_gst_element_t *mainbin = NULL;
+       mmplayer_gst_element_t *textbin = NULL;
 
-       gcharsubtitle_uri = NULL;
+       gchar *subtitle_uri = NULL;
        int result = MM_ERROR_NONE;
        const gchar *charset = NULL;
 
@@ -8076,20 +8102,20 @@ __mmplayer_change_external_subtitle_language(mm_player_t* player, const char* fi
        current_state = GST_STATE(mainbin[MMPLAYER_M_PIPE].gst);
        if (current_state < GST_STATE_READY) {
                result = MM_ERROR_PLAYER_INVALID_STATE;
-               LOGE("Pipeline is not in proper state\n");
+               LOGE("Pipeline is not in proper state");
                goto EXIT;
        }
 
        attrs = MMPLAYER_GET_ATTRS(player);
        if (!attrs) {
-               LOGE("cannot get content attribute\n");
+               LOGE("cannot get content attribute");
                result = MM_ERROR_PLAYER_INTERNAL;
                goto EXIT;
        }
 
        mm_attrs_get_string_by_name(attrs, "subtitle_uri", &subtitle_uri);
        if (!subtitle_uri || strlen(subtitle_uri) < 1) {
-               LOGE("subtitle uri is not proper filepath\n");
+               LOGE("subtitle uri is not proper filepath");
                result = MM_ERROR_PLAYER_INVALID_URI;
                goto EXIT;
        }
@@ -8100,16 +8126,16 @@ __mmplayer_change_external_subtitle_language(mm_player_t* player, const char* fi
                goto EXIT;
        }
 
-       LOGD("old subtitle file path is [%s]\n", subtitle_uri);
-       LOGD("new subtitle file path is [%s]\n", filepath);
+       LOGD("old subtitle file path is [%s]", subtitle_uri);
+       LOGD("new subtitle file path is [%s]", filepath);
 
        if (!strcmp(filepath, subtitle_uri)) {
-               LOGD("No need to swtich subtitle, as input filepath is same as current filepath\n");
+               LOGD("No need to swtich subtitle, as input filepath is same as current filepath");
                goto EXIT;
        } else {
                mm_attrs_set_string_by_name(player->attrs, "subtitle_uri", filepath);
-               if (mmf_attrs_commit(player->attrs)) {
-                       LOGE("failed to commit.\n");
+               if (mm_attrs_commit_all(player->attrs)) {
+                       LOGE("failed to commit.");
                        goto EXIT;
                }
        }
@@ -8146,7 +8172,7 @@ __mmplayer_change_external_subtitle_language(mm_player_t* player, const char* fi
 
        charset = util_get_charset(filepath);
        if (charset) {
-               LOGD("detected charset is %s\n", charset);
+               LOGD("detected charset is %s", charset);
                g_object_set(G_OBJECT(mainbin[MMPLAYER_M_SUBPARSE].gst), "subtitle-encoding", charset, NULL);
        }
 
@@ -8158,10 +8184,11 @@ EXIT:
 }
 
 /* API to switch between external subtitles */
-int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filepath)
+int
+_mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath)
 {
        int result = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        char *path = NULL;
 
        MMPLAYER_FENTER();
@@ -8186,7 +8213,7 @@ int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filep
        if (!player->pipeline) {
                /* IDLE state */
                mm_attrs_set_string_by_name(player->attrs, "subtitle_uri", filepath);
-               if (mmf_attrs_commit(player->attrs)) {
+               if (mm_attrs_commit_all(player->attrs)) {
                        LOGE("failed to commit");       /* subtitle path will not be created */
                        return MM_ERROR_PLAYER_INTERNAL;
                }
@@ -8197,7 +8224,7 @@ int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filep
 
                if (!__mmplayer_check_subtitle(player)) {
                        mm_attrs_set_string_by_name(player->attrs, "subtitle_uri", filepath);
-                       if (mmf_attrs_commit(player->attrs)) {
+                       if (mm_attrs_commit_all(player->attrs)) {
                                LOGE("failed to commit");
                                return MM_ERROR_PLAYER_INTERNAL;
                        }
@@ -8229,14 +8256,14 @@ int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filep
 }
 
 static int
-__mmplayer_change_selector_pad(mm_player_t* player, MMPlayerTrackType type, int index)
+__mmplayer_change_selector_pad(mmplayer_t *player, mmplayer_track_type_e type, int index)
 {
        int result = MM_ERROR_NONE;
-       gcharchange_pad_name = NULL;
-       GstPadsinkpad = NULL;
-       MMPlayerGstElement* mainbin = NULL;
-       enum MainElementID elem_idx = MMPLAYER_M_NUM;
-       GstCapscaps = NULL;
+       gchar *change_pad_name = NULL;
+       GstPad *sinkpad = NULL;
+       mmplayer_gst_element_t *mainbin = NULL;
+       main_element_id_e elem_idx = MMPLAYER_M_NUM;
+       GstCaps *caps = NULL;
        gint total_track_num = 0;
 
        MMPLAYER_FENTER();
@@ -8244,7 +8271,7 @@ __mmplayer_change_selector_pad(mm_player_t* player, MMPlayerTrackType type, int
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin,
                                                                                                        MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       LOGD("Change Track(%d) to %d\n", type, index);
+       LOGD("Change Track(%d) to %d", type, index);
 
        mainbin = player->pipeline->mainbin;
 
@@ -8254,26 +8281,26 @@ __mmplayer_change_selector_pad(mm_player_t* player, MMPlayerTrackType type, int
                elem_idx = MMPLAYER_M_T_INPUT_SELECTOR;
        } else {
                /* Changing Video Track is not supported. */
-               LOGE("Track Type Error\n");
+               LOGE("Track Type Error");
                goto EXIT;
        }
 
        if (mainbin[elem_idx].gst == NULL) {
                result = MM_ERROR_PLAYER_NO_OP;
-               LOGD("Req track doesn't exist\n");
+               LOGD("Req track doesn't exist");
                goto EXIT;
        }
 
        total_track_num = player->selector[type].total_track_num;
        if (total_track_num <= 0) {
                result = MM_ERROR_PLAYER_NO_OP;
-               LOGD("Language list is not available \n");
+               LOGD("Language list is not available");
                goto EXIT;
        }
 
        if ((index < 0) || (index >= total_track_num)) {
                result = MM_ERROR_INVALID_ARGUMENT;
-               LOGD("Not a proper index : %d \n", index);
+               LOGD("Not a proper index : %d", index);
                goto EXIT;
        }
 
@@ -8281,11 +8308,11 @@ __mmplayer_change_selector_pad(mm_player_t* player, MMPlayerTrackType type, int
        change_pad_name = g_strdup_printf("sink_%u", index);
        if (change_pad_name == NULL) {
                result = MM_ERROR_PLAYER_INTERNAL;
-               LOGD("Pad does not exists\n");
+               LOGD("Pad does not exists");
                goto EXIT;
        }
 
-       LOGD("new active pad name: %s\n", change_pad_name);
+       LOGD("new active pad name: %s", change_pad_name);
 
        sinkpad = gst_element_get_static_pad(mainbin[elem_idx].gst, change_pad_name);
        if (sinkpad == NULL) {
@@ -8294,7 +8321,7 @@ __mmplayer_change_selector_pad(mm_player_t* player, MMPlayerTrackType type, int
                goto EXIT;
        }
 
-       LOGD("Set Active Pad - %s:%s\n", GST_DEBUG_PAD_NAME(sinkpad));
+       LOGD("Set Active Pad - %s:%s", GST_DEBUG_PAD_NAME(sinkpad));
        g_object_set(mainbin[elem_idx].gst, "active-pad", sinkpad, NULL);
 
        caps = gst_pad_get_current_caps(sinkpad);
@@ -8307,30 +8334,30 @@ __mmplayer_change_selector_pad(mm_player_t* player, MMPlayerTrackType type, int
                __mmplayer_set_audio_attrs(player, caps);
 
 EXIT:
-
        MMPLAYER_FREEIF(change_pad_name);
        return result;
 }
 
-int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type, int index)
+int
+_mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type, int index)
 {
        int result = MM_ERROR_NONE;
-       mm_player_t* player = NULL;
-       MMPlayerGstElement* mainbin = NULL;
+       mmplayer_t *player = NULL;
+       mmplayer_gst_element_t *mainbin = NULL;
 
        gint current_active_index = 0;
 
        GstState current_state = GST_STATE_VOID_PENDING;
-       GstEventevent = NULL;
+       GstEvent *event = NULL;
        gint64 time = 0;
 
        MMPLAYER_FENTER();
 
-       player = (mm_player_t*)hplayer;
+       player = (mmplayer_t *)hplayer;
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        if (!player->pipeline) {
-               LOGE("Track %d pre setting -> %d\n", type, index);
+               LOGE("Track %d pre setting -> %d", type, index);
 
                player->selector[type].active_pad_index = index;
                goto EXIT;
@@ -8352,20 +8379,22 @@ int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type
        current_state = GST_STATE(mainbin[MMPLAYER_M_PIPE].gst);
        if (current_state < GST_STATE_PAUSED) {
                result = MM_ERROR_PLAYER_INVALID_STATE;
-               LOGW("Pipeline not in porper state\n");
+               LOGW("Pipeline not in porper state");
                goto EXIT;
        }
 
        result = __mmplayer_change_selector_pad(player, type, index);
        if (result != MM_ERROR_NONE) {
-               LOGE("change selector pad error\n");
+               LOGE("change selector pad error");
                goto EXIT;
        }
 
        player->selector[type].active_pad_index = index;
 
        if (current_state == GST_STATE_PLAYING) {
-               event = gst_event_new_seek(player->playback_rate, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SKIP), GST_SEEK_TYPE_SET, time, GST_SEEK_TYPE_NONE, -1);
+               event = gst_event_new_seek(player->playback_rate, GST_FORMAT_TIME,
+                       (GstSeekFlags)(GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SKIP),
+                       GST_SEEK_TYPE_SET, time, GST_SEEK_TYPE_NONE, -1);
                if (event) {
                        __mmplayer_gst_send_event_to_sink(player, event);
                } else {
@@ -8378,9 +8407,10 @@ EXIT:
        return result;
 }
 
-int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int* silent)
+int
+_mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
@@ -8389,47 +8419,15 @@ int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int* silent)
 
        *silent = player->set_mode.subtitle_off;
 
-       LOGD("subtitle is %s.\n", silent ? "ON" : "OFF");
+       LOGD("subtitle is %s.", silent ? "ON" : "OFF");
 
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;
 }
 
-int
-_mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode)
-{
-       mm_player_t* player = (mm_player_t*) hplayer;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       if (MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_NULL) {
-               MMPLAYER_PRINT_STATE(player);
-               LOGE("wrong-state : can't set the download mode to parse");
-               return MM_ERROR_PLAYER_INVALID_STATE;
-       }
-
-       LOGD("set video hub download mode to %s", (mode) ? "ON" : "OFF");
-       player->video_hub_download_mode = mode;
-
-       return MM_ERROR_NONE;
-}
-
-int
-_mmplayer_enable_sync_handler(MMHandleType hplayer, bool enable)
-{
-       mm_player_t* player = (mm_player_t*) hplayer;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       LOGD("enable sync handler : %s", (enable) ? "ON" : "OFF");
-       player->sync_handler = enable;
-
-       return MM_ERROR_NONE;
-}
-
 static gboolean
-__mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element)
+__mmplayer_add_dump_buffer_probe(mmplayer_t *player, GstElement *element)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
        MMPLAYER_RETURN_VAL_IF_FAIL(element, FALSE);
@@ -8442,9 +8440,8 @@ __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element)
        for (idx = 0; player->ini.dump_element_keyword[idx][0] != '\0'; idx++) {
                if (g_strrstr(factory_name, player->ini.dump_element_keyword[idx])) {
                        LOGD("dump [%s] sink pad", player->ini.dump_element_keyword[idx]);
-                       mm_player_dump_t *dump_s;
-                       dump_s = g_malloc(sizeof(mm_player_dump_t));
-
+                       mmplayer_dump_t *dump_s;
+                       dump_s = g_try_malloc(sizeof(mmplayer_dump_t));
                        if (dump_s == NULL) {
                                LOGE("malloc fail");
                                return FALSE;
@@ -8455,8 +8452,8 @@ __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element)
                        dump_s->dump_pad = gst_element_get_static_pad(element, "sink");
 
                        if (dump_s->dump_pad) {
-                               memset(dump_file_name, 0x00, PLAYER_INI_MAX_STRLEN*2);
-                               snprintf(dump_file_name, PLAYER_INI_MAX_STRLEN*2, "%s/%s_sink_pad.dump", player->ini.dump_element_path, player->ini.dump_element_keyword[idx]);
+                               memset(dump_file_name, 0x00, PLAYER_INI_MAX_STRLEN * 2);
+                               snprintf(dump_file_name, PLAYER_INI_MAX_STRLEN * 2, "%s/%s_sink_pad.dump", player->ini.dump_element_path, player->ini.dump_element_keyword[idx]);
                                dump_s->dump_element_file = fopen(dump_file_name, "w+");
                                dump_s->probe_handle_id = gst_pad_add_probe(dump_s->dump_pad, GST_PAD_PROBE_TYPE_BUFFER, __mmplayer_dump_buffer_probe_cb, dump_s->dump_element_file, NULL);
                                /* add list for removed buffer probe and close FILE */
@@ -8464,12 +8461,9 @@ __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element)
                                LOGD("%s sink pad added buffer probe for dump", factory_name);
                                return TRUE;
                        } else {
-                               g_free(dump_s);
-                               dump_s = NULL;
+                               MMPLAYER_FREEIF(dump_s);
                                LOGE("failed to get %s sink pad added", factory_name);
                        }
-
-
                }
        }
        return FALSE;
@@ -8478,12 +8472,12 @@ __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element)
 static GstPadProbeReturn
 __mmplayer_dump_buffer_probe_cb(GstPad *pad,  GstPadProbeInfo *info, gpointer u_data)
 {
-       FILE *dump_data = (FILE *) u_data;
+       FILE *dump_data = (FILE *)u_data;
 //     int written = 0;
        GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
        GstMapInfo probe_info = GST_MAP_INFO_INIT;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL(dump_data, FALSE);
+       MMPLAYER_RETURN_VAL_IF_FAIL(dump_data, GST_PAD_PROBE_PASS);
 
        gst_buffer_map(buffer, &probe_info, GST_MAP_READ);
 
@@ -8491,49 +8485,55 @@ __mmplayer_dump_buffer_probe_cb(GstPad *pad,  GstPadProbeInfo *info, gpointer u_
 
        fwrite(probe_info.data, 1, probe_info.size , dump_data);
 
+       gst_buffer_unmap(buffer, &probe_info);
+
        return GST_PAD_PROBE_OK;
 }
 
 static void
 __mmplayer_release_dump_list(GList *dump_list)
 {
-       if (dump_list) {
-               GList *d_list = dump_list;
-               for (; d_list; d_list = g_list_next(d_list)) {
-                       mm_player_dump_t *dump_s = d_list->data;
-                       if (dump_s->dump_pad) {
-                               if (dump_s->probe_handle_id)
-                                       gst_pad_remove_probe(dump_s->dump_pad, dump_s->probe_handle_id);
-                       }
-                       if (dump_s->dump_element_file) {
-                               fclose(dump_s->dump_element_file);
-                               dump_s->dump_element_file = NULL;
-                       }
-                       MMPLAYER_FREEIF(dump_s);
+       GList *d_list = dump_list;
+
+       if (!d_list)
+               return;
+
+       for (; d_list; d_list = g_list_next(d_list)) {
+               mmplayer_dump_t *dump_s = d_list->data;
+               if (dump_s->dump_pad) {
+                       if (dump_s->probe_handle_id)
+                               gst_pad_remove_probe(dump_s->dump_pad, dump_s->probe_handle_id);
+                       gst_object_unref(GST_OBJECT(dump_s->dump_pad));
+               }
+               if (dump_s->dump_element_file) {
+                       fclose(dump_s->dump_element_file);
+                       dump_s->dump_element_file = NULL;
                }
-               g_list_free(dump_list);
-               dump_list = NULL;
+               MMPLAYER_FREEIF(dump_s);
        }
+       g_list_free(dump_list);
+       dump_list = NULL;
 }
 
 int
-_mmplayer_has_closed_caption(MMHandleType hplayer, boolexist)
+_mmplayer_has_closed_caption(MMHandleType hplayer, bool *exist)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
 
-       *exist = player->has_closed_caption;
+       *exist = (bool)player->has_closed_caption;
 
        MMPLAYER_FLEAVE();
 
        return MM_ERROR_NONE;
 }
 
-void _mm_player_video_stream_internal_buffer_unref(void *buffer)
+void
+_mm_player_video_stream_internal_buffer_unref(void *buffer)
 {
        MMPLAYER_FENTER();
        if (buffer) {
@@ -8544,32 +8544,31 @@ void _mm_player_video_stream_internal_buffer_unref(void *buffer)
        MMPLAYER_FLEAVE();
 }
 
-int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout)
+int
+_mmplayer_get_timeout(MMHandleType hplayer, int *timeout)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
 
-       if (MMPLAYER_IS_HTTP_PD(player))
-               /* consider the timeout both download pipeline and playback pipeline */
-               *timeout = player->ini.live_state_change_timeout + PLAYER_PD_STATE_CHANGE_TIME;
-       else if (MMPLAYER_IS_STREAMING(player))
-               *timeout = player->ini.live_state_change_timeout;
+       if (MMPLAYER_IS_STREAMING(player))
+               *timeout = (int)player->ini.live_state_change_timeout;
        else
-               *timeout = player->ini.localplayback_state_change_timeout;
+               *timeout = (int)player->ini.localplayback_state_change_timeout;
 
-       LOGD("timeout = %d\n", *timeout);
+       LOGD("timeout = %d", *timeout);
 
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;
 }
 
-int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num)
+int
+_mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
 
@@ -8579,14 +8578,14 @@ int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *
        *num = player->video_num_buffers;
        *extra_num = player->video_extra_num_buffers;
 
-       LOGD("state %d, num %d(%d)\n", MMPLAYER_CURRENT_STATE(player), *num, *extra_num);
+       LOGD("state %d, num %d(%d)", MMPLAYER_CURRENT_STATE(player), *num, *extra_num);
 
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;
 }
 
 static void
-__mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_type)
+__mmplayer_initialize_storage_info(mmplayer_t *player, mmplayer_path_type_e path_type)
 {
        int i = 0;
        MMPLAYER_FENTER();
@@ -8608,10 +8607,11 @@ __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_ty
        MMPLAYER_FLEAVE();
 }
 
-int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state)
+int
+_mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state)
 {
        int ret = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*)hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        MMMessageParamType msg_param = {0, };
 
        MMPLAYER_FENTER();
@@ -8623,8 +8623,10 @@ int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int st
                return MM_ERROR_NONE;
 
        /* FIXME: text path should be handled seperately. */
-       if (((player->storage_info[MMPLAYER_PATH_VOD].type == STORAGE_TYPE_EXTERNAL) && (player->storage_info[MMPLAYER_PATH_VOD].id == id)) ||
-               ((player->storage_info[MMPLAYER_PATH_TEXT].type == STORAGE_TYPE_EXTERNAL) && (player->storage_info[MMPLAYER_PATH_TEXT].id == id))) {
+       if (((player->storage_info[MMPLAYER_PATH_VOD].type == STORAGE_TYPE_EXTERNAL)
+               && (player->storage_info[MMPLAYER_PATH_VOD].id == id)) ||
+               ((player->storage_info[MMPLAYER_PATH_TEXT].type == STORAGE_TYPE_EXTERNAL)
+               && (player->storage_info[MMPLAYER_PATH_TEXT].id == id))) {
                LOGW("external storage is removed");
 
                if (player->msg_posted == FALSE) {
@@ -8644,10 +8646,11 @@ int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int st
        return ret;
 }
 
-int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info)
+int
+_mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info)
 {
        int ret = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int idx = 0, total = 0;
        gchar *result = NULL, *tmp = NULL;
 
@@ -8663,7 +8666,7 @@ int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **v
 
        result = g_strdup("");
        for (idx = 0 ; idx < total ; idx++) {
-               VariantData *v_data = NULL;
+               stream_variant_t *v_data = NULL;
                v_data = g_list_nth_data(player->adaptive_info.var_list, idx);
 
                if (v_data) {
@@ -8686,10 +8689,11 @@ int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **v
        return ret;
 }
 
-int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height)
+int
+_mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height)
 {
        int ret = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
@@ -8713,10 +8717,11 @@ int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth
 
 }
 
-int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height)
+int
+_mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height)
 {
        int ret = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
@@ -8732,64 +8737,36 @@ int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidt
        return ret;
 }
 
-int _mmplayer_set_streaming_buffering_time(MMHandleType hplayer, int buffer_ms, int rebuffer_ms)
-{
-       int ret = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*) hplayer;
-
-       MMPLAYER_FENTER();
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       if (MMPLAYER_CURRENT_STATE(player) !=  MM_PLAYER_STATE_NULL)
-               LOGW("buffer_ms will not be applied.");
-
-
-       LOGD("set buffering time %d ms / %d ms", buffer_ms, rebuffer_ms);
-
-       if (player->streamer == NULL) {
-               player->streamer = __mm_player_streaming_create();
-               __mm_player_streaming_initialize(player->streamer);
-       }
-
-       if (buffer_ms >= 0)
-               player->streamer->buffering_req.prebuffer_time = buffer_ms;
-
-       if (rebuffer_ms >= 0)
-               player->streamer->buffering_req.rebuffer_time = rebuffer_ms;
-
-       MMPLAYER_FLEAVE();
-       return ret;
-
-}
-
-int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *buffer_ms, int *rebuffer_ms)
+int
+_mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *prebuffer_ms, int *rebuffer_ms)
 {
        int ret = MM_ERROR_NONE;
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
 
        MMPLAYER_FENTER();
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->streamer, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(prebuffer_ms && rebuffer_ms, MM_ERROR_COMMON_INVALID_ARGUMENT);
+       MMPLAYER_RETURN_VAL_IF_FAIL(MMPLAYER_IS_STREAMING(player), MM_ERROR_PLAYER_NO_OP);
 
-       if (player->streamer == NULL) {
-               player->streamer = __mm_player_streaming_create();
-               __mm_player_streaming_initialize(player->streamer);
-       }
+       *prebuffer_ms = player->streamer->buffering_req.prebuffer_time;
 
-       *buffer_ms = player->streamer->buffering_req.prebuffer_time;
-       *rebuffer_ms = player->streamer->buffering_req.rebuffer_time;
+       if (player->streamer->buffering_req.rebuffer_time > MIN_BUFFERING_TIME)
+               *rebuffer_ms = player->streamer->buffering_req.rebuffer_time;
+       else /* live case */
+               *rebuffer_ms = DEFAULT_LIVE_REBUFFER_TIME;
 
-       LOGD("buffering time %d ms / %d ms", *buffer_ms, *rebuffer_ms);
+       LOGD("buffering time %d ms / %d ms", *prebuffer_ms, *rebuffer_ms);
 
        MMPLAYER_FLEAVE();
        return ret;
 }
 
-int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
+int
+_mmplayer_set_codec_type(MMHandleType hplayer, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type)
 {
 #define IDX_FIRST_SW_CODEC 0
-       mm_player_t* player = (mm_player_t*) hplayer;
-       const charattr_name = (stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE);
+       mmplayer_t *player = (mmplayer_t *)hplayer;
+       const char *attr_name = (stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE);
        MMHandleType attrs = 0;
 
        MMPLAYER_FENTER();
@@ -8835,7 +8812,7 @@ int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_typ
        attrs = MMPLAYER_GET_ATTRS(player);
        mm_attrs_set_int_by_name(attrs, attr_name, codec_type);
 
-       if (mmf_attrs_commit(player->attrs)) {
+       if (mm_attrs_commit_all(player->attrs)) {
                LOGE("failed to commit codec_type attributes");
                return MM_ERROR_PLAYER_INTERNAL;
        }
@@ -8847,8 +8824,8 @@ int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_typ
 int
 _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
-       GstElementrg_vol_element = NULL;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
+       GstElement *rg_vol_element = NULL;
 
        MMPLAYER_FENTER();
 
@@ -8858,7 +8835,7 @@ _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled)
 
        /* just hold rgvolume enable value if pipeline is not ready */
        if (!player->pipeline || !player->pipeline->audiobin) {
-               LOGD("pipeline is not ready. holding rgvolume enable value\n");
+               LOGD("pipeline is not ready. holding rgvolume enable value");
                return MM_ERROR_NONE;
        }
 
@@ -8882,8 +8859,8 @@ _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled)
 int
 _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
-       GstElementrg_vol_element = NULL;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
+       GstElement *rg_vol_element = NULL;
        gboolean enable = FALSE;
 
        MMPLAYER_FENTER();
@@ -8893,7 +8870,7 @@ _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled)
 
        /* just hold enable_rg value if pipeline is not ready */
        if (!player->pipeline || !player->pipeline->audiobin) {
-               LOGD("pipeline is not ready. holding rgvolume value (%d)\n", player->sound.rg_enable);
+               LOGD("pipeline is not ready. holding rgvolume value (%d)", player->sound.rg_enable);
                *enabled = player->sound.rg_enable;
                return MM_ERROR_NONE;
        }
@@ -8906,7 +8883,7 @@ _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled)
        }
 
        g_object_get(rg_vol_element, "enable-rgvolume", &enable, NULL);
-       *enabled = enable;
+       *enabled = (bool)enable;
 
        MMPLAYER_FLEAVE();
 
@@ -8916,7 +8893,7 @@ _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled)
 int
 _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        MMHandleType attrs = 0;
        void *handle = NULL;
        int ret = MM_ERROR_NONE;
@@ -8959,7 +8936,7 @@ _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_
 int
 _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height)
 {
-       mm_player_t* player = (mm_player_t*) hplayer;
+       mmplayer_t *player = (mmplayer_t *)hplayer;
        int ret = MM_ERROR_NONE;
 
        MMPLAYER_FENTER();
@@ -8979,7 +8956,7 @@ _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scal
 }
 
 static gboolean
-__mmplayer_update_duration_attrs(mm_player_t *player, MMHandleType attrs)
+__mmplayer_update_duration_value(mmplayer_t *player)
 {
        gboolean ret = FALSE;
        gint64 dur_nsec = 0;
@@ -9000,41 +8977,47 @@ __mmplayer_update_duration_attrs(mm_player_t *player, MMHandleType attrs)
        player->streaming_type =  __mmplayer_get_stream_service_type(player);
 
        /* check duration is OK */
-       if (dur_nsec == 0 && !MMPLAYER_IS_LIVE_STREAMING(player)) {
+       if (dur_nsec == 0 && !MMPLAYER_IS_LIVE_STREAMING(player))
                /* FIXIT : find another way to get duration here. */
                LOGW("finally it's failed to get duration from pipeline. progressbar will not work correctely!");
-       }
 
        return ret;
 }
 
 static gboolean
-__mmplayer_update_audio_attrs(mm_player_t *player, MMHandleType attrs)
+__mmplayer_update_audio_attrs(mmplayer_t *player, MMHandleType attrs)
 {
        /* update audio params
        NOTE : We need original audio params and it can be only obtained from src pad of audio
        decoder. Below code only valid when we are not using 'resampler' just before
        'audioconverter'. */
        GstCaps *caps_a = NULL;
-       GstPadpad = NULL;
+       GstPad *pad = NULL;
        gint samplerate = 0, channels = 0;
-       GstStructure* p = NULL;
+       GstStructure *p = NULL;
+       GstElement *aconv = NULL;
 
        LOGD("try to update audio attrs");
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->audiobin, FALSE);
-       MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, FALSE);
 
-       pad = gst_element_get_static_pad(
-                       player->pipeline->audiobin[MMPLAYER_A_CONV].gst, "sink");
+       if (player->pipeline->audiobin[MMPLAYER_A_CONV].gst) {
+               aconv = player->pipeline->audiobin[MMPLAYER_A_CONV].gst;
+       } else if (player->pipeline->audiobin[MMPLAYER_A_EXTRACT_CONV].gst) {
+               aconv = player->pipeline->audiobin[MMPLAYER_A_EXTRACT_CONV].gst;
+       } else {
+               LOGE("there is no audio converter");
+               return FALSE;
+       }
+
+       pad = gst_element_get_static_pad(aconv, "sink");
 
        if (!pad) {
-               LOGW("failed to get pad from audiosink");
+               LOGW("failed to get pad from audio converter");
                return FALSE;
        }
 
        caps_a = gst_pad_get_current_caps(pad);
-
        if (!caps_a) {
                LOGW("not ready to get audio caps");
                gst_object_unref(pad);
@@ -9060,15 +9043,15 @@ __mmplayer_update_audio_attrs(mm_player_t *player, MMHandleType attrs)
 }
 
 static gboolean
-__mmplayer_update_video_attrs(mm_player_t *player, MMHandleType attrs)
+__mmplayer_update_video_attrs(mmplayer_t *player, MMHandleType attrs)
 {
        LOGD("try to update video attrs");
 
        GstCaps *caps_v = NULL;
-       GstPadpad = NULL;
+       GstPad *pad = NULL;
        gint tmpNu, tmpDe;
        gint width, height;
-       GstStructurep = NULL;
+       GstStructure *p = NULL;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->videobin, FALSE);
        MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->videobin[MMPLAYER_V_SINK].gst, FALSE);
@@ -9115,7 +9098,7 @@ __mmplayer_update_video_attrs(mm_player_t *player, MMHandleType attrs)
 }
 
 static gboolean
-__mmplayer_update_bitrate_attrs(mm_player_t *player, MMHandleType attrs)
+__mmplayer_update_bitrate_attrs(mmplayer_t *player, MMHandleType attrs)
 {
        gboolean ret = FALSE;
        guint64 data_size = 0;
@@ -9144,7 +9127,7 @@ __mmplayer_update_bitrate_attrs(mm_player_t *player, MMHandleType attrs)
                msec_dur = GST_TIME_AS_MSECONDS(player->duration);
                if (msec_dur > 0) {
                        bitrate = data_size * 8 * 1000 / msec_dur;
-                       SECURE_LOGD("file size : %u, video bitrate = %llu", data_size, bitrate);
+                       SECURE_LOGD("file size : %"G_GUINT64_FORMAT", video bitrate = %"G_GUINT64_FORMAT, data_size, bitrate);
                        mm_attrs_set_int_by_name(attrs, "content_video_bitrate", bitrate);
 
                        ret = TRUE;
@@ -9162,14 +9145,16 @@ __mmplayer_update_bitrate_attrs(mm_player_t *player, MMHandleType attrs)
 
        return ret;
 }
+
 static void
-__mmplayer_copy_uri_and_set_type(MMPlayerParseProfile* data, const char *uri, int uri_type)
+__mmplayer_copy_uri_and_set_type(mmplayer_parse_profile_t *data, const char *uri, int uri_type)
 {
        strncpy(data->uri, uri, MM_MAX_URL_LEN - 1);
        data->uri_type = uri_type;
 }
+
 static int
-__mmplayer_set_mem_uri(MMPlayerParseProfile* data, char *path, void *param)
+__mmplayer_set_mem_uri(mmplayer_parse_profile_t *data, char *path, void *param)
 {
        int ret = MM_ERROR_PLAYER_INVALID_URI;
        int mem_size = 0;
@@ -9209,7 +9194,7 @@ __mmplayer_set_mem_uri(MMPlayerParseProfile* data, char *path, void *param)
                }
        }
 
-       LOGD("ext: %s, mem_size: %d, mmap(param): %p\n", ext, mem_size, param);
+       LOGD("ext: %s, mem_size: %d, mmap(param): %p", ext, mem_size, param);
 
        if (mem_size && param) {
                if (data->input_mem.buf)
@@ -9233,7 +9218,7 @@ __mmplayer_set_mem_uri(MMPlayerParseProfile* data, char *path, void *param)
 }
 
 static int
-__mmplayer_set_file_uri(MMPlayerParseProfile* data, const char *uri)
+__mmplayer_set_file_uri(mmplayer_parse_profile_t *data, const char *uri)
 {
        gchar *location = NULL;
        GError *err = NULL;
@@ -9247,8 +9232,8 @@ __mmplayer_set_file_uri(MMPlayerParseProfile* data, const char *uri)
                                (err != NULL) ? err->message : "unknown error");
                        if (err)
                                g_error_free(err);
-                       if (location)
-                               g_free(location);
+
+                       MMPLAYER_FREEIF(location);
 
                        data->uri_type = MM_PLAYER_URI_TYPE_NONE;
                        return MM_ERROR_PLAYER_INVALID_URI;
@@ -9265,7 +9250,7 @@ __mmplayer_set_file_uri(MMPlayerParseProfile* data, const char *uri)
        if (ret == MM_ERROR_NONE) {
                g_snprintf(data->uri,  MM_MAX_URL_LEN, "file://%s", path);
                if (util_is_sdp_file(path)) {
-                       LOGD("uri is actually a file but it's sdp file. giving it to rtspsrc\n");
+                       LOGD("uri is actually a file but it's sdp file. giving it to rtspsrc");
                        data->uri_type = MM_PLAYER_URI_TYPE_URL_RTSP;
                } else {
                        data->uri_type = MM_PLAYER_URI_TYPE_FILE;
@@ -9273,26 +9258,26 @@ __mmplayer_set_file_uri(MMPlayerParseProfile* data, const char *uri)
        } else if (ret == MM_ERROR_PLAYER_PERMISSION_DENIED) {
                data->uri_type = MM_PLAYER_URI_TYPE_NO_PERMISSION;
        } else {
-               LOGE("invalid uri, could not play..\n");
+               LOGE("invalid uri, could not play..");
                data->uri_type = MM_PLAYER_URI_TYPE_NONE;
        }
 
-       if (location)
-               g_free(location);
+       MMPLAYER_FREEIF(location);
 
        return ret;
 }
 
-static MMPlayerVideoStreamDataType*
+static mmplayer_video_decoded_data_info_t *
 __mmplayer_create_stream_from_pad(GstPad *pad)
 {
        GstCaps *caps = NULL;
        GstStructure *structure = NULL;
        unsigned int fourcc = 0;
        const gchar *string_format = NULL;
-       MMPlayerVideoStreamDataType *stream = NULL;
+       mmplayer_video_decoded_data_info_t *stream = NULL;
        gint width, height;
        MMPixelFormatType format;
+       GstVideoInfo info;
 
        caps = gst_pad_get_current_caps(pad);
        if (!caps) {
@@ -9305,9 +9290,11 @@ __mmplayer_create_stream_from_pad(GstPad *pad)
        gst_structure_get_int(structure, "width", &width);
        gst_structure_get_int(structure, "height", &height);
        string_format = gst_structure_get_string(structure, "format");
+
        if (string_format)
                fourcc = _mmplayer_convert_fourcc_string_to_value(string_format);
        format = util_get_pixtype(fourcc);
+       gst_video_info_from_caps(&info, caps);
        gst_caps_unref(caps);
 
        /* moved here */
@@ -9316,7 +9303,7 @@ __mmplayer_create_stream_from_pad(GstPad *pad)
                return NULL;
        }
 
-       stream = (MMPlayerVideoStreamDataType *)g_malloc0(sizeof(MMPlayerVideoStreamDataType));
+       stream = (mmplayer_video_decoded_data_info_t *)g_try_malloc0(sizeof(mmplayer_video_decoded_data_info_t));
        if (!stream) {
                LOGE("failed to alloc mem for video data");
                return NULL;
@@ -9325,27 +9312,40 @@ __mmplayer_create_stream_from_pad(GstPad *pad)
        stream->width = width;
        stream->height = height;
        stream->format = format;
+       stream->plane_num = GST_VIDEO_INFO_N_PLANES(&info);
 
        return stream;
 }
 
 static void
-__mmplayer_zerocopy_set_stride_elevation_bo(MMPlayerVideoStreamDataType *stream, GstMemory *mem)
+__mmplayer_zerocopy_set_stride_elevation_bo(mmplayer_video_decoded_data_info_t *stream, GstMemory *mem)
 {
        unsigned int pitch = 0;
+       unsigned int size = 0;
        int index = 0;
        tbm_surface_h surface = gst_tizen_memory_get_surface(mem);
+       tbm_bo bo = NULL;
 
        for (index = 0; index < gst_tizen_memory_get_num_bos(mem); index++) {
-               tbm_surface_internal_get_plane_data(surface, index, NULL, NULL, &pitch);
-               stream->bo[index] = tbm_bo_ref(gst_tizen_memory_get_bos(mem, index));
+               bo = gst_tizen_memory_get_bos(mem, index);
+               if (bo)
+                       stream->bo[index] = tbm_bo_ref(bo);
+               else
+                       LOGE("failed to get bo for index %d", index);
+       }
+
+       for (index = 0; index < stream->plane_num; index++) {
+               tbm_surface_internal_get_plane_data(surface, index, &size, NULL, &pitch);
                stream->stride[index] = pitch;
-               stream->elevation[index] = stream->height;
+               if (pitch)
+                       stream->elevation[index] = size / pitch;
+               else
+                       stream->elevation[index] = stream->height;
        }
 }
 
 static gboolean
-__mmplayer_swcodec_set_stride_elevation(MMPlayerVideoStreamDataType *stream)
+__mmplayer_swcodec_set_stride_elevation(mmplayer_video_decoded_data_info_t *stream)
 {
        if (stream->format == MM_PIXEL_FORMAT_I420) {
                int ret = TBM_SURFACE_ERROR_NONE;
@@ -9381,7 +9381,7 @@ __mmplayer_swcodec_set_stride_elevation(MMPlayerVideoStreamDataType *stream)
 }
 
 static gboolean
-__mmplayer_swcodec_set_bo(mm_player_t *player, MMPlayerVideoStreamDataType *stream, GstMemory *mem)
+__mmplayer_swcodec_set_bo(mmplayer_t *player, mmplayer_video_decoded_data_info_t *stream, GstMemory *mem)
 {
        tbm_bo_handle thandle;
        gboolean is_mapped;
@@ -9462,3 +9462,75 @@ ERROR:
 
        return FALSE;
 }
+
+static void
+__mmplayer_set_pause_state(mmplayer_t *player)
+{
+       if (player->sent_bos)
+               return;
+
+       /* rtsp case, get content attrs by GstMessage */
+       if (MMPLAYER_IS_RTSP_STREAMING(player))
+               return;
+
+       /* it's first time to update all content attrs. */
+       __mmplayer_update_content_attrs(player, ATTR_ALL);
+}
+
+static void
+__mmplayer_set_playing_state(mmplayer_t *player)
+{
+       gchar *audio_codec = NULL;
+
+       if (player->resumed_by_rewind && player->playback_rate < 0.0) {
+               /* initialize because auto resume is done well. */
+               player->resumed_by_rewind = FALSE;
+               player->playback_rate = 1.0;
+       }
+
+       if (player->sent_bos)
+               return;
+
+       /* try to get content metadata */
+
+       /* NOTE : giving ATTR_MISSING_ONLY may have dependency with
+        * c-api since c-api doesn't use _start() anymore. It may not work propery with
+        * legacy mmfw-player api
+        */
+       __mmplayer_update_content_attrs(player, ATTR_MISSING_ONLY);
+
+       if ((player->cmd == MMPLAYER_COMMAND_START)
+               || (player->cmd == MMPLAYER_COMMAND_RESUME)) {
+               __mmplayer_handle_missed_plugin(player);
+       }
+
+       /* check audio codec field is set or not
+        * we can get it from typefinder or codec's caps.
+        */
+       mm_attrs_get_string_by_name(player->attrs, "content_audio_codec", &audio_codec);
+
+       /* The codec format can't be sent for audio only case like amr, mid etc.
+        * Because, parser don't make related TAG.
+        * So, if it's not set yet, fill it with found data.
+        */
+       if (!audio_codec) {
+               if (g_strrstr(player->type, "audio/midi"))
+                       audio_codec = "MIDI";
+               else if (g_strrstr(player->type, "audio/x-amr"))
+                       audio_codec = "AMR";
+               else if (g_strrstr(player->type, "audio/mpeg")
+                               && !g_strrstr(player->type, "mpegversion=(int)1"))
+                       audio_codec = "AAC";
+               else
+                       audio_codec = "unknown";
+
+               mm_attrs_set_string_by_name(player->attrs, "content_audio_codec", audio_codec);
+
+               if (mm_attrs_commit_all(player->attrs))
+                       LOGE("failed to update attributes");
+
+               LOGD("set audio codec type with caps");
+       }
+
+       return;
+}