Merge branch 'tizen' into tizen_5.5_devel
[platform/core/multimedia/libmm-player.git] / src / mm_player_gst.c
index 7978600..a16c0d2 100644 (file)
 ========================================================================================== */
 
 /*---------------------------------------------------------------------------
-|    GLOBAL CONSTANT DEFINITIONS:                                                                                      |
----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-|    IMPORTED VARIABLE DECLARATIONS:                                                                           |
----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-|    IMPORTED FUNCTION DECLARATIONS:                                                                           |
----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-|    LOCAL #defines:                                                                                                           |
----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
 |    LOCAL CONSTANT DEFINITIONS:                                                                                       |
 ---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-|    LOCAL DATA TYPE DEFINITIONS:                                                                                      |
----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-|    GLOBAL VARIABLE DEFINITIONS:                                                                                      |
----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-|    LOCAL VARIABLE DEFINITIONS:                                                                                       |
----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-|    LOCAL FUNCTION PROTOTYPES:                                                                                                |
----------------------------------------------------------------------------*/
+#define MMPLAYER_TAG_INDENT 3
 
 /*===========================================================================================
 |                                                                                                                                                                                      |
@@ -117,12 +86,12 @@ __mmplayer_check_error_posted_from_activated_track(mmplayer_t *player, gchar *sr
 {
        /* check whether the error is posted from not-activated track or not */
        int msg_src_pos = 0;
-       gint active_pad_index = 0;
+       gint active_index = 0;
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->mainbin[MMPLAYER_M_A_INPUT_SELECTOR].gst, TRUE);
 
-       active_pad_index = player->selector[MM_PLAYER_TRACK_TYPE_AUDIO].active_pad_index;
-       LOGD("current  active pad index  -%d", active_pad_index);
+       active_index = player->track[MM_PLAYER_TRACK_TYPE_AUDIO].active_track_index;
+       LOGD("current  active pad index  -%d", active_index);
 
        if  (src_element_name) {
                int idx = 0;
@@ -140,10 +109,10 @@ __mmplayer_check_error_posted_from_activated_track(mmplayer_t *player, gchar *sr
                                idx++;
                        }
                }
-               LOGD("active pad = %d, error src index = %d", active_pad_index,  msg_src_pos);
+               LOGD("active pad = %d, error src index = %d", active_index,  msg_src_pos);
        }
 
-       if (active_pad_index != msg_src_pos) {
+       if (active_index != msg_src_pos) {
                LOGD("skip error because error is posted from no activated track");
                return FALSE;
        }
@@ -258,7 +227,8 @@ __mmplayer_gst_transform_gsterror(mmplayer_t *player, GstMessage *message, GErro
        LOGD("error code=%d, msg=%s, src element=%s, class=%s",
                        error->code, error->message, src_element_name, klass);
 
-       if (!__mmplayer_check_error_posted_from_activated_track(player, src_element_name))
+       if (!MMPLAYER_USE_URIDECODEBIN3(player) &&
+               !__mmplayer_check_error_posted_from_activated_track(player, src_element_name))
                return MM_ERROR_NONE;
 
        switch (error->code) {
@@ -965,6 +935,7 @@ __mmplayer_gst_check_useful_message(mmplayer_t *player, GstMessage *message)
        case GST_MESSAGE_ELEMENT:
        case GST_MESSAGE_DURATION_CHANGED:
        case GST_MESSAGE_ASYNC_START:
+       case GST_MESSAGE_STREAM_COLLECTION:
                retval = TRUE;
                break;
        case GST_MESSAGE_ASYNC_DONE:
@@ -1000,6 +971,35 @@ __mmplayer_gst_check_useful_message(mmplayer_t *player, GstMessage *message)
 
                break;
        }
+       case GST_MESSAGE_STREAMS_SELECTED:
+       {
+               if (!MMPLAYER_USE_URIDECODEBIN3(player))
+                       break; /* drop msg */
+
+               if ((MMPLAYER_IS_HTTP_STREAMING(player)) &&
+                       (!player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst) &&
+                       (player->pipeline->mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst)) {
+
+                       gint64 dur_bytes = 0L;
+
+                       if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes))
+                               LOGE("fail to get duration.");
+
+                       /* there is no mq, enable use-buffering on queue2 (ex) wav streaming
+                        * use file information was already set on Q2 when it was created. */
+                       _mm_player_streaming_set_queue2(player->streamer,
+                                                       player->pipeline->mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst,
+                                                       TRUE,                                                           /* use_buffering */
+                                                       MUXED_BUFFER_TYPE_MAX,                          /* use previous buffer type setting */
+                                                       ((dur_bytes > 0) ? ((guint64)dur_bytes) : 0));
+               }
+
+               LOGD("GST_MESSAGE_STREAMS_SELECTED");
+               player->no_more_pad = TRUE;
+               _mmplayer_pipeline_complete(NULL, player);
+               retval = TRUE;
+               break;
+       }
        default:
                retval = FALSE;
                break;
@@ -1895,6 +1895,81 @@ __mmplayer_gst_handle_async_done_message(mmplayer_t *player, GstMessage *msg)
 }
 
 static void
+__mmplayer_print_tag_foreach(const GstTagList *tags, const gchar *tag, gpointer user_data)
+{
+       GValue val = { 0, };
+       gchar *str = NULL;
+       guint indent = GPOINTER_TO_UINT(user_data);
+
+       if (!gst_tag_list_copy_value(&val, tags, tag))
+               return;
+
+       if (G_VALUE_HOLDS_STRING(&val))
+               str = g_value_dup_string(&val);
+       else
+               str = gst_value_serialize(&val);
+
+       LOGD("%*s%s: %s\n", 2 * indent, " ", gst_tag_get_nick(tag), str);
+       g_free(str);
+       g_value_unset(&val);
+}
+
+static void
+__mmplayer_dump_collection(GstStreamCollection * collection)
+{
+       guint i = 0;
+       GstTagList *tags = NULL;
+       GstCaps *caps = NULL;
+
+       for (i = 0; i < gst_stream_collection_get_size(collection); i++) {
+               GstStream *stream = gst_stream_collection_get_stream(collection, i);
+               LOGD ("collection: Stream %u type %s flags 0x%x\n", i,
+                               gst_stream_type_get_name(gst_stream_get_stream_type(stream)),
+                               gst_stream_get_stream_flags(stream));
+               LOGD ("  ID: %s\n", gst_stream_get_stream_id(stream));
+
+               caps = gst_stream_get_caps(stream);
+               if (caps) {
+                       gchar *caps_str = gst_caps_to_string(caps);
+                       LOGD ("  caps: %s\n", caps_str);
+                       g_free(caps_str);
+                       gst_caps_unref(caps);
+               }
+
+               tags = gst_stream_get_tags(stream);
+               if (tags) {
+                       LOGD ("  tags:\n");
+                       gst_tag_list_foreach(tags, __mmplayer_print_tag_foreach, GUINT_TO_POINTER(MMPLAYER_TAG_INDENT));
+                       gst_tag_list_unref(tags);
+               }
+       }
+}
+
+static void
+__mmplayer_stream_notify_cb(GstStreamCollection *collection,
+                       GstStream *stream, GParamSpec *pspec, gpointer data)
+{
+       LOGD ("Got stream-notify from stream %s for %s (collection %p)\n",
+                               gst_stream_get_stream_id(stream), pspec->name, collection);
+       if (g_str_equal(pspec->name, "caps")) {
+               GstCaps *caps = gst_stream_get_caps(stream);
+               gchar *caps_str = gst_caps_to_string(caps);
+               LOGD (" New caps: %s\n", caps_str);
+               g_free(caps_str);
+               gst_caps_unref(caps);
+       }
+
+       if (g_str_equal (pspec->name, "tags")) {
+               GstTagList *tags = gst_stream_get_tags(stream);
+               if (tags) {
+                       LOGD ("  tags:\n");
+                       gst_tag_list_foreach(tags, __mmplayer_print_tag_foreach, GUINT_TO_POINTER(MMPLAYER_TAG_INDENT));
+                       gst_tag_list_unref(tags);
+               }
+       }
+}
+
+static void
 __mmplayer_gst_bus_msg_callback(GstMessage *msg, gpointer data)
 {
        mmplayer_t *player = (mmplayer_t *)(data);
@@ -1998,6 +2073,43 @@ __mmplayer_gst_bus_msg_callback(GstMessage *msg, gpointer data)
        case GST_MESSAGE_ASYNC_DONE:
                __mmplayer_gst_handle_async_done_message(player, msg);
                break;
+       case GST_MESSAGE_STREAM_COLLECTION:
+       {
+               GstStreamCollection *collection = NULL;
+               LOGD("GST_MESSAGE_STREAM_COLLECTION : %s", GST_ELEMENT_NAME(GST_MESSAGE_SRC(msg)));
+
+               gst_message_parse_stream_collection(msg, &collection);
+               if (collection) {
+                       __mmplayer_dump_collection(collection);
+                       if (player->collection && player->stream_notify_id) {
+                               g_signal_handler_disconnect(player->collection, player->stream_notify_id);
+                               player->stream_notify_id = 0;
+                       }
+                       gst_object_replace((GstObject **)&player->collection, (GstObject *)collection);
+                       if (player->collection) {
+                               player->stream_notify_id = g_signal_connect(player->collection, "stream-notify",
+                                                       (GCallback)__mmplayer_stream_notify_cb, player);
+                       }
+                       gst_object_unref(collection);
+               }
+       } break;
+       case GST_MESSAGE_STREAMS_SELECTED:
+       {
+               GstStreamCollection *collection = NULL;
+               LOGD("GST_MESSAGE_STREAMS_SELECTED : %s", GST_ELEMENT_NAME(GST_MESSAGE_SRC(msg)));
+
+               gst_message_parse_streams_selected(msg, &collection);
+               if (collection) {
+                       guint i = 0, len = 0;
+                       len = gst_message_streams_selected_get_size(msg);
+                       for (i = 0; i < len; i++) {
+                               GstStream *stream = gst_message_streams_selected_get_stream(msg, i);
+                               LOGD ("  Stream #%d : %s\n", i, gst_stream_get_stream_id(stream));
+                               gst_object_unref(stream);
+                       }
+                       gst_object_unref (collection);
+               }
+       } break;
 
 #ifdef __DEBUG__
        case GST_MESSAGE_REQUEST_STATE:         LOGD("GST_MESSAGE_REQUEST_STATE"); break;
@@ -2630,7 +2742,7 @@ __mmplayer_gst_rtp_no_more_pads(GstElement *element,  gpointer data)
 
                if (!_mmplayer_gst_remove_fakesink(player,
                        &player->pipeline->mainbin[MMPLAYER_M_SRC_FAKESINK]))
-                       /* NOTE : __mmplayer_pipeline_complete() can be called several time. because
+                       /* NOTE : _mmplayer_pipeline_complete() can be called several time. because
                         * signaling mechanism(pad-added, no-more-pad, new-decoded-pad) from various
                         * source element are not same. To overcome this situation, this function will called
                         * several places and several times. Therefore, this is not an error case.
@@ -2688,6 +2800,307 @@ __mmplayer_gst_make_rtsp_src(mmplayer_t *player)
        return element;
 }
 
+void __mmplayer_http_src_setup(GstElement *source, gpointer data)
+{
+#define HTTP_SOURCE_BLOCK_SIZE (64 * 1024)
+
+       mmplayer_t *player = (mmplayer_t *)data;
+       MMHandleType attrs = 0;
+       gchar *user_agent, *cookies, **cookie_list;
+       gint http_timeout = DEFAULT_HTTP_TIMEOUT;
+       user_agent = cookies = NULL;
+       cookie_list = NULL;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_IF_FAIL(player);
+
+       LOGD("source element %s", GST_ELEMENT_NAME(source));
+
+       /* get profile attribute */
+       attrs = MMPLAYER_GET_ATTRS(player);
+       if (!attrs) {
+               LOGE("failed to get content attribute");
+               return;
+       }
+
+       /* get attribute */
+       mm_attrs_get_string_by_name(attrs, "streaming_cookie", &cookies);
+       mm_attrs_get_string_by_name(attrs, "streaming_user_agent", &user_agent);
+
+       if (player->ini.http_timeout != DEFAULT_HTTP_TIMEOUT)
+               http_timeout = player->ini.http_timeout;
+
+       /* get attribute */
+       SECURE_LOGD("cookies : %s", cookies);
+       SECURE_LOGD("user_agent :  %s", user_agent);
+       LOGD("timeout : %d", http_timeout);
+
+       /* setting property to streaming source */
+       g_object_set(G_OBJECT(source), "timeout", http_timeout, "blocksize", (unsigned long)(HTTP_SOURCE_BLOCK_SIZE), NULL);
+
+       /* parsing cookies */
+       if ((cookie_list = _mmplayer_get_cookie_list((const char *)cookies))) {
+               g_object_set(G_OBJECT(source), "cookies", cookie_list, NULL);
+               g_strfreev(cookie_list);
+       }
+
+       if (user_agent)
+               g_object_set(G_OBJECT(source), "user-agent", user_agent, NULL);
+
+       MMPLAYER_FLEAVE();
+       return;
+}
+
+static void
+__mmplayer_gst_found_source(GObject *object, GObject *orig, GParamSpec *pspec, gpointer data)
+{
+       mmplayer_t *player = (mmplayer_t *)data;
+       GstElement *source = NULL;
+
+       MMPLAYER_FENTER();
+       LOGD("%s >> %s", GST_ELEMENT_NAME(object), pspec->name);
+
+       g_object_get(orig, pspec->name, &source, NULL);
+
+       player->pipeline->mainbin[MMPLAYER_M_SRC].id = MMPLAYER_M_SRC;
+       player->pipeline->mainbin[MMPLAYER_M_SRC].gst = source;
+
+       if (MMPLAYER_IS_HTTP_STREAMING(player)) {
+               __mmplayer_http_src_setup(source, data);
+       } else if (MMPLAYER_IS_SMOOTH_STREAMING(player)) {
+               g_object_set(G_OBJECT(source), "timeout", DEFAULT_HTTP_TIMEOUT, NULL);
+       } else if (player->profile.uri_type == MM_PLAYER_URI_TYPE_MEM) {
+               g_object_set(source, "stream-type", GST_APP_STREAM_TYPE_RANDOM_ACCESS,
+                       "size", (gint64)player->profile.input_mem.len, "blocksize", 20480, NULL);
+
+               _mmplayer_add_signal_connection(player, G_OBJECT(source), MM_PLAYER_SIGNAL_TYPE_OTHERS, "seek-data",
+                                                                               G_CALLBACK(__mmplayer_gst_appsrc_seek_data_mem), (gpointer)&player->profile.input_mem);
+               _mmplayer_add_signal_connection(player, G_OBJECT(source), MM_PLAYER_SIGNAL_TYPE_OTHERS, "need-data",
+                                                                               G_CALLBACK(__mmplayer_gst_appsrc_feed_data_mem), (gpointer)&player->profile.input_mem);
+       }
+       MMPLAYER_FLEAVE();
+}
+
+gint __mmplayer_gst_select_stream (GstElement * uridecodebin, GstStreamCollection * collection,
+    GstStream * stream, gpointer data)
+{
+       GstStreamType stype = gst_stream_get_stream_type (stream);
+       mmplayer_t *player = (mmplayer_t *)data;
+       mmplayer_track_type_e type = MM_PLAYER_TRACK_TYPE_MAX;
+
+       if (stype & GST_STREAM_TYPE_AUDIO) {
+               LOGW("AUDIO type 0x%X", stype);
+               type = MM_PLAYER_TRACK_TYPE_AUDIO;
+       }
+
+       if (stype & GST_STREAM_TYPE_VIDEO) {
+               LOGW("VIDEO type 0x%X", stype);
+               if (type != MM_PLAYER_TRACK_TYPE_MAX) {
+                       LOGE("Multi Stream 0x%X", type);
+                       return -1;
+               }
+               type = MM_PLAYER_TRACK_TYPE_VIDEO;
+       }
+
+       if (stype & GST_STREAM_TYPE_TEXT) {
+               LOGW("TEXT type 0x%X", stype);
+               if (type != MM_PLAYER_TRACK_TYPE_MAX) {
+                       LOGE("Multi Stream 0x%X", type);
+                       return -1;
+               }
+               type = MM_PLAYER_TRACK_TYPE_TEXT;
+       }
+
+       _mmplayer_track_update_stream(player, type, stream);
+
+       if (player->track[type].active_track_index == (player->track[type].total_track_num - 1)) {
+               LOGD("select this stream, type : %d, idx : %d", type, player->track[type].active_track_index);
+               return 1;
+       }
+
+       return -1;
+}
+
+void
+__mmplayer_gst_deep_element_added(GstElement *bin, GstBin *child, GstElement *element, gpointer data)
+{
+       gchar *factory_name = NULL;
+       mmplayer_t *player = (mmplayer_t *)data;
+       mmplayer_gst_element_t *mainbin = NULL;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->mainbin);
+
+       factory_name = GST_OBJECT_NAME(gst_element_get_factory(element));
+       mainbin = player->pipeline->mainbin;
+
+       LOGD("%s > %s > %s : %s", GST_ELEMENT_NAME(bin), GST_ELEMENT_NAME(child),
+               factory_name, GST_ELEMENT_NAME(element));
+
+       /* keep the first typefind reference only */
+       if (!mainbin[MMPLAYER_M_TYPEFIND].gst && g_strrstr(factory_name, "typefind")) {  // FIXME : not required for local playback+
+               mainbin[MMPLAYER_M_TYPEFIND].id = MMPLAYER_M_TYPEFIND;
+               mainbin[MMPLAYER_M_TYPEFIND].gst = element;
+
+               _mmplayer_add_signal_connection(player, G_OBJECT(element),
+                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "have-type", G_CALLBACK(_mmplayer_typefind_have_type), (gpointer)player);
+               LOGD("typefind reference is added");
+               return;
+       }
+
+       if (!mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst && g_strrstr(factory_name, "queue2")) { // fix me :streaming only..
+
+               gint64 dur_bytes = 0L;
+               muxed_buffer_type_e type = MUXED_BUFFER_TYPE_MEM_QUEUE;
+
+               mainbin[MMPLAYER_M_MUXED_S_BUFFER].id = MMPLAYER_M_MUXED_S_BUFFER;
+               mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst = element;
+
+               if (!gst_element_query_duration(mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes))
+                       LOGW("failed to get duration from source %s", GST_ELEMENT_NAME(mainbin[MMPLAYER_M_SRC].gst));
+
+               LOGD("type %s, dur_bytes = %"G_GINT64_FORMAT, player->type, 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 ((!g_strrstr(player->type, "video/mpegts")) && (!g_strrstr(player->type, "application/x-hls"))) {
+                               type = MUXED_BUFFER_TYPE_MEM_RING_BUFFER;
+                               player->streamer->ring_buffer_size = player->ini.http_ring_buffer_size;
+                       }
+               } else {
+                       dur_bytes = 0;
+               }
+
+               _mm_player_streaming_set_queue2(player->streamer,
+                                                                               element,
+                                                                               FALSE,
+                                                                               type,
+                                                                               (guint64)dur_bytes); /* no meaning at the moment */
+
+               return;
+       }
+
+       if (g_strrstr(factory_name, "parsebin")) {
+               if (!mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst) {
+                       GstIterator *iter = NULL;
+                       GValue item = {0, };
+                       GstElement *ch_element = NULL;
+                       GstElementFactory *ch_factory = NULL;
+
+                       iter = gst_bin_iterate_recurse(child);
+                       if (iter != NULL) {
+                               while (gst_iterator_next(iter, &item) == GST_ITERATOR_OK) {
+                                       ch_element = g_value_get_object(&item);
+                                       ch_factory = gst_element_get_factory(ch_element);
+
+                                       if (g_strrstr(GST_OBJECT_NAME(ch_factory), "multiqueue")) {
+                                               player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].id = MMPLAYER_M_DEMUXED_S_BUFFER;
+                                               player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst = ch_element;
+
+                                               if ((MMPLAYER_IS_HTTP_STREAMING(player)) ||
+                                                       (MMPLAYER_IS_HTTP_LIVE_STREAMING(player)) ||
+                                                       (MMPLAYER_IS_DASH_STREAMING(player))) {
+                                                       _mm_player_streaming_set_multiqueue(player->streamer, ch_element);
+                                               }
+                                               g_value_reset(&item);
+                                               break;
+                                       }
+                                       g_value_reset(&item);
+                               }
+                               gst_iterator_free(iter);
+                       }
+               }
+       }
+
+       if (g_strrstr(factory_name, "parsebin")) {
+
+               g_object_set(G_OBJECT(child), "message-forward", TRUE, NULL);
+               g_object_set(G_OBJECT(element), "message-forward", TRUE, NULL);
+
+               mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].id = MMPLAYER_M_AUTOPLUG_PARSEBIN;
+               mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].gst = element;
+               _mmplayer_add_signal_connection(player, G_OBJECT(element),
+                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "unknown-type", G_CALLBACK(_mmplayer_gst_decode_unknown_type), (gpointer)player);
+
+               _mmplayer_add_signal_connection(player, G_OBJECT(element),
+                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-continue", G_CALLBACK(_mmplayer_gst_decode_autoplug_continue), (gpointer)player);
+
+               if (player->need_video_dec_sorting || player->need_audio_dec_sorting)
+                       _mmplayer_add_signal_connection(player, G_OBJECT(element),
+                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-sort", G_CALLBACK(_mmplayer_gst_decode_autoplug_sort), (gpointer)player);
+
+               _mmplayer_add_signal_connection(player, G_OBJECT(element),
+                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-select", G_CALLBACK(_mmplayer_gst_decode_autoplug_select), (gpointer)player);
+
+       } else {
+               _mmplayer_gst_element_added((GstElement *)child, element, data);
+       }
+       return;
+}
+
+void
+__mmplayer_gst_deep_element_removed(GstElement *bin, GstBin *child, GstElement *element, gpointer data)
+{
+       LOGD("%s > %s > %s", GST_ELEMENT_NAME(bin), GST_ELEMENT_NAME(child), GST_ELEMENT_NAME(element));
+       return;
+}
+
+static GstElement *
+__mmplayer_gst_make_uridecodebin(mmplayer_t *player)
+{
+       GstElement *uridecodebin3 = NULL;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL);
+
+       uridecodebin3 = gst_element_factory_make("uridecodebin3", "uridecodebin3");
+       if (!uridecodebin3) {
+               LOGE("failed to create uridecodebin3");
+               return NULL;
+       }
+
+       /* get attribute */
+       SECURE_LOGD("uri : %s", player->profile.uri);
+
+       /* setting property to streaming source */
+       g_object_set(G_OBJECT(uridecodebin3), "uri", player->profile.uri,
+                       "message-forward", TRUE,
+                       "buffer-size", DEFAULT_BUFFER_SIZE_BYTES, NULL);
+
+       _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "deep-notify::source", G_CALLBACK(__mmplayer_gst_found_source), (gpointer)player);
+
+       _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added", G_CALLBACK(_mmplayer_gst_decode_pad_added), (gpointer)player);
+
+       _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-removed", G_CALLBACK(_mmplayer_gst_decode_pad_removed), (gpointer)player);
+
+       _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "no-more-pads", G_CALLBACK(_mmplayer_gst_decode_no_more_pads), (gpointer)player);
+
+       _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "select-stream", G_CALLBACK(__mmplayer_gst_select_stream), (gpointer)player);
+
+/* FIXME: need to be added for gapless playback
+       _mmplayer_add_signal_connection(player, G_OBJECT(element),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "about-to-finish", G_CALLBACK(_mmplayer_gst_decode_drained), (gpointer)player);
+*/
+
+       _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "deep-element-added", G_CALLBACK(__mmplayer_gst_deep_element_added), (gpointer)player);
+
+       _mmplayer_add_signal_connection(player, G_OBJECT(uridecodebin3),
+               MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "deep-element-removed", G_CALLBACK(__mmplayer_gst_deep_element_removed), (gpointer)player);
+
+       if (MMPLAYER_URL_HAS_DASH_SUFFIX(player))
+               LOGW("[DASH] this is still experimental feature");
+
+       MMPLAYER_FLEAVE();
+       return uridecodebin3;
+}
+
 static GstElement *
 __mmplayer_gst_make_http_src(mmplayer_t *player)
 {
@@ -3176,9 +3589,11 @@ _mmplayer_gst_pause(mmplayer_t *player, gboolean async)
                return ret;
        }
 
-       if ((!MMPLAYER_IS_RTSP_STREAMING(player)) && (!player->video_decoded_cb) &&
-               (!player->pipeline->videobin) && (!player->pipeline->audiobin))
-               return MM_ERROR_PLAYER_CODEC_NOT_FOUND;
+       if (!MMPLAYER_USE_URIDECODEBIN3(player)) {
+               if ((!MMPLAYER_IS_RTSP_STREAMING(player)) && (!player->video_decoded_cb) &&
+                       (!player->pipeline->videobin) && (!player->pipeline->audiobin))
+                       return MM_ERROR_PLAYER_CODEC_NOT_FOUND;
+       }
 
        MMPLAYER_SET_STATE(player, MM_PLAYER_STATE_PAUSED);
 
@@ -3698,6 +4113,72 @@ _mmplayer_gst_build_es_pipeline(mmplayer_t *player)
        return MM_ERROR_NONE;
 }
 
+static int
+__mmplayer_gst_build_pipeline_with_src(mmplayer_t *player)
+{
+       mmplayer_gst_element_t *mainbin = NULL;
+       GstElement *autoplug_elem = NULL;
+
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline &&
+                               player->pipeline->mainbin, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       mainbin = player->pipeline->mainbin;
+
+       LOGD("uri type %d", player->profile.uri_type);
+
+       autoplug_elem = __mmplayer_gst_make_uridecodebin(player);
+       if (!autoplug_elem) {
+               LOGE("failed to create uridecodebin3 element");
+               goto ERROR;
+       }
+
+       LOGD("autoplug elem is created %s", GST_ELEMENT_NAME(autoplug_elem));
+       mainbin[MMPLAYER_M_AUTOPLUG].id = MMPLAYER_M_AUTOPLUG;
+       mainbin[MMPLAYER_M_AUTOPLUG].gst = autoplug_elem;
+
+       if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), autoplug_elem)) {
+               LOGE("failed to add uridecodebin to pipeline");
+               goto ERROR;
+       }
+
+       /* FIXME: required ?*/
+       /* create fakesink element for keeping the pipeline state PAUSED. if needed */
+       mainbin[MMPLAYER_M_SRC_FAKESINK].id = MMPLAYER_M_SRC_FAKESINK;
+       mainbin[MMPLAYER_M_SRC_FAKESINK].gst = gst_element_factory_make("fakesink", "state-holder");
+
+       if (!mainbin[MMPLAYER_M_SRC_FAKESINK].gst) {
+               LOGE("failed to create fakesink");
+               goto ERROR;
+       }
+       GST_OBJECT_FLAG_UNSET(mainbin[MMPLAYER_M_SRC_FAKESINK].gst, GST_ELEMENT_FLAG_SINK);
+
+       /* take ownership of fakesink. we are reusing it */
+       gst_object_ref(mainbin[MMPLAYER_M_SRC_FAKESINK].gst);
+
+       if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), mainbin[MMPLAYER_M_SRC_FAKESINK].gst)) {
+               LOGE("failed to add fakesink to bin");
+               gst_object_unref(mainbin[MMPLAYER_M_SRC_FAKESINK].gst);
+               goto ERROR;
+       }
+
+       MMPLAYER_FLEAVE();
+       return MM_ERROR_NONE;
+
+ERROR:
+
+       if (mainbin[MMPLAYER_M_AUTOPLUG].gst)
+               gst_object_unref(GST_OBJECT(mainbin[MMPLAYER_M_AUTOPLUG].gst));
+
+       if (mainbin[MMPLAYER_M_SRC_FAKESINK].gst)
+               gst_object_unref(GST_OBJECT(mainbin[MMPLAYER_M_SRC_FAKESINK].gst));
+
+       mainbin[MMPLAYER_M_AUTOPLUG].gst = NULL;
+       mainbin[MMPLAYER_M_SRC_FAKESINK].gst = NULL;
+
+       return MM_ERROR_PLAYER_INTERNAL;
+}
+
 int
 _mmplayer_gst_build_pipeline(mmplayer_t *player)
 {
@@ -3719,14 +4200,31 @@ _mmplayer_gst_build_pipeline(mmplayer_t *player)
                src_elem = __mmplayer_gst_make_rtsp_src(player);
                break;
        case MM_PLAYER_URI_TYPE_URL_HTTP:
+               if (player->ini.use_uridecodebin3) {
+                       LOGD("uridecodebin include src element.");
+                       return __mmplayer_gst_build_pipeline_with_src(player);
+               }
                src_elem = __mmplayer_gst_make_http_src(player);
                break;
        case MM_PLAYER_URI_TYPE_FILE:
+               if (player->ini.use_uridecodebin3) {
+                       if (!_mmplayer_get_storage_info(player->profile.uri, &player->storage_info[MMPLAYER_PATH_VOD])) {
+                               LOGE("failed to get storage info");
+                               break;
+                       }
+                       LOGD("uridecodebin include src element.");
+                       return __mmplayer_gst_build_pipeline_with_src(player);
+               }
                src_elem = __mmplayer_gst_make_file_src(player);
                break;
        case MM_PLAYER_URI_TYPE_SS:
                {
                        gint http_timeout = DEFAULT_HTTP_TIMEOUT;
+                       if (player->ini.use_uridecodebin3) {
+                               LOGD("uridecodebin include src element.");
+                               return __mmplayer_gst_build_pipeline_with_src(player);
+                       }
+
                        src_elem = gst_element_factory_make("souphttpsrc", "http streaming source");
                        if (!src_elem) {
                                LOGE("failed to create http streaming source element[%s]", player->ini.httpsrc_element);
@@ -3746,6 +4244,13 @@ _mmplayer_gst_build_pipeline(mmplayer_t *player)
                {
                        GstAppStreamType stream_type = GST_APP_STREAM_TYPE_RANDOM_ACCESS;
 
+                       if (player->ini.use_uridecodebin3) {
+                               LOGD("uridecodebin include src element.");
+
+                               g_strlcpy(player->profile.uri, "appsrc://", MM_MAX_URL_LEN);
+                               return __mmplayer_gst_build_pipeline_with_src(player);
+                       }
+
                        src_elem = gst_element_factory_make("appsrc", "mem-source");
                        if (!src_elem) {
                                LOGE("failed to create appsrc element");
@@ -4025,14 +4530,14 @@ _mmplayer_activate_next_source(mmplayer_t *player, GstState target)
                goto ERROR;
        }
 
-       if (!MMPLAYER_IS_HTTP_STREAMING(player)) {
-               if (gst_element_set_state(mainbin[MMPLAYER_M_AUTOPLUG].gst, target) == GST_STATE_CHANGE_FAILURE) {
-                       LOGE("Failed to change state of decodebin");
+       if (MMPLAYER_IS_HTTP_STREAMING(player)) {
+               if (gst_element_set_state(mainbin[MMPLAYER_M_TYPEFIND].gst, target) == GST_STATE_CHANGE_FAILURE) {  // ????
+                       LOGE("Failed to change state of src element");
                        goto ERROR;
                }
        } else {
-               if (gst_element_set_state(mainbin[MMPLAYER_M_TYPEFIND].gst, target) == GST_STATE_CHANGE_FAILURE) {
-                       LOGE("Failed to change state of src element");
+               if (gst_element_set_state(mainbin[MMPLAYER_M_AUTOPLUG].gst, target) == GST_STATE_CHANGE_FAILURE) {
+                       LOGE("Failed to change state of decodebin");
                        goto ERROR;
                }
        }