[0.6.277] Update uridecodebin3 setting to sync GST 1.22.0
[platform/core/multimedia/libmm-player.git] / src / mm_player_gst.c
index 8d442fe..6679d43 100644 (file)
@@ -3047,124 +3047,68 @@ __mmplayer_gst_find_child_element(GstBin *bin, const gchar *element_name)
        return ch_element;
 }
 
-static void
-__mmplayer_gst_deep_element_added(GstElement *bin, GstBin *child, GstElement *element, gpointer data)
+static void __mmplayer_parsebin_setup(GstBin *bin, 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;
+       g_object_set(G_OBJECT(bin), "message-forward", TRUE, NULL);
 
-       LOGD("%s > %s > %s : %s", GST_ELEMENT_NAME(bin), GST_ELEMENT_NAME(child),
-               factory_name, GST_ELEMENT_NAME(element));
+       _mmplayer_add_signal_connection(player, G_OBJECT(bin),
+       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "unknown-type",
+                       G_CALLBACK(_mmplayer_gst_decode_unknown_type), (gpointer)player);
 
-       /* 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(bin),
+       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-select",
+                       G_CALLBACK(_mmplayer_gst_decode_autoplug_select), (gpointer)player);
+}
 
-               _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;
-       }
+static void __mmplayer_decodebin3_setup(GstBin *bin, gpointer data)
+{
+       mmplayer_t *player = (mmplayer_t *)data;
+       int video_codec_type = 0;
+       int audio_codec_type = 0;
 
-       if ((MMPLAYER_IS_STREAMING(player)) && (!MMPLAYER_IS_RTSP_STREAMING(player))) {
-               /* update queue2 setting */
-               if (g_strrstr(factory_name, "queue2") && (!mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst)) {
-                       gint64 dur_bytes = 0L;
-                       muxed_buffer_type_e type = MUXED_BUFFER_TYPE_MEM_QUEUE;
+       g_object_set(G_OBJECT(bin), "message-forward", TRUE, NULL);
 
-                       mainbin[MMPLAYER_M_MUXED_S_BUFFER].id = MMPLAYER_M_MUXED_S_BUFFER;
-                       mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst = element;
+       mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_VIDEO_CODEC_TYPE, &video_codec_type);
+       mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_AUDIO_CODEC_TYPE, &audio_codec_type);
 
-                       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("set codec type v(%d) a(%d)", video_codec_type, audio_codec_type);
 
-                       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;
-                       }
+       if (video_codec_type == MM_PLAYER_CODEC_TYPE_SW)
+               g_object_set(G_OBJECT(bin), "force-sw-decoders-for-video", TRUE, NULL);
+       if (audio_codec_type == MM_PLAYER_CODEC_TYPE_SW)
+               g_object_set(G_OBJECT(bin), "force-sw-decoders-for-audio", TRUE, NULL);
 
-                       _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") /* will be removed after gst 1.22.0 is applied */
-               || g_strrstr(factory_name, "identity")) {
-               if ((!MMPLAYER_IS_RTSP_STREAMING(player)) && (!mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst)) {
-                       GstElement *ch_element = __mmplayer_gst_find_child_element(child, "multiqueue");
-                       if (ch_element) {
-                               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;
-
-                               /* in case of multiqueue, max bytes size is defined with fixed value in mm_player_streaming.h */
-                               if (MMPLAYER_IS_STREAMING(player)) {
-                                       _mm_player_streaming_set_multiqueue(player->streamer, ch_element);
-                               } else {
-                                       g_object_set(G_OBJECT(ch_element),
-                                                                                       "max-size-time", (guint64)(5 * GST_SECOND),
-                                                                                       "use-interleave", FALSE, NULL);
-                               }
-                       }
-               }
-               int video_codec_type = 0;
-               int audio_codec_type = 0;
-
-               g_object_set(G_OBJECT(child), "message-forward", TRUE, NULL);
-               g_object_set(G_OBJECT(element), "message-forward", TRUE, NULL);
-               if (player->type_caps &&
-                       !MMPLAYER_IS_HTTP_LIVE_STREAMING(player) &&
-                       !MMPLAYER_IS_DASH_STREAMING(player))
-                       g_object_set(G_OBJECT(element), "sink-caps", player->type_caps, NULL);
-
-               mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_VIDEO_CODEC_TYPE, &video_codec_type);
-               mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_AUDIO_CODEC_TYPE, &audio_codec_type);
+       _mmplayer_add_signal_connection(player, G_OBJECT(bin), MM_PLAYER_SIGNAL_TYPE_AUTOPLUG,
+                       "request-resource", G_CALLBACK(__mmplayer_gst_decode_request_resource), (gpointer)player);
+}
 
-               /* CAUTION: if there is hw decoder, the rank value has to be higher than sw decoder
-                  and codec default type in ini has to be hw.
-                */
-               LOGD("set codec type v(%d) a(%d)", video_codec_type, audio_codec_type);
-               if (video_codec_type == MM_PLAYER_CODEC_TYPE_SW)
-                       g_object_set(G_OBJECT(child), "force-sw-decoders-for-video", TRUE, NULL);
-               if (audio_codec_type == MM_PLAYER_CODEC_TYPE_SW)
-                       g_object_set(G_OBJECT(child), "force-sw-decoders-for-audio", 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);
+static 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_add_signal_connection(player, G_OBJECT(element),
-                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-continue", G_CALLBACK(_mmplayer_gst_decode_autoplug_continue), (gpointer)player);
+       MMPLAYER_FENTER();
+       MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->mainbin);
 
-               _mmplayer_add_signal_connection(player, G_OBJECT(element),
-                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "autoplug-select", G_CALLBACK(_mmplayer_gst_decode_autoplug_select), (gpointer)player);
+       factory_name = GST_OBJECT_NAME(gst_element_get_factory(element));
 
-               _mmplayer_add_signal_connection(player, G_OBJECT(child),
-                       MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "request-resource", G_CALLBACK(__mmplayer_gst_decode_request_resource), (gpointer)player);
+       LOGD("child: %s, elem: %s (%s)", GST_ELEMENT_NAME(child), factory_name, GST_ELEMENT_NAME(element));
 
+       if (g_strrstr(factory_name, "urisourcebin")) {
+               GstElement *dbin3 = __mmplayer_gst_find_child_element(child, "decodebin3");
+               if (dbin3)
+                       __mmplayer_decodebin3_setup(GST_BIN(dbin3), data);
+               else
+                       LOGW("failed to find decodebin3");
+       } else if (g_strrstr(factory_name, "parsebin")) {
+               g_object_set(G_OBJECT(child), "message-forward", TRUE, NULL); /* urisourcebin */
+               __mmplayer_parsebin_setup(GST_BIN(element), data);
        } else {
-               _mmplayer_gst_element_added((GstElement *)child, element, data);
+               _mmplayer_gst_element_added(child, element, data);
        }
-       return;
 }
 
 static void
@@ -3229,7 +3173,8 @@ __mmplayer_gst_make_uridecodebin(mmplayer_t *player)
        /* 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);
+                       "buffer-size", DEFAULT_BUFFER_SIZE_BYTES,
+                       "use-buffering", TRUE, 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);
@@ -3881,7 +3826,7 @@ _mmplayer_gst_send_event_to_sink(mmplayer_t *player, GstEvent *event)
        }
 
        /* Note : Textbin is not linked to the video or audio bin.
-        * It needs to send the event to the text sink seperately.
+        * It needs to send the event to the text sink separately.
         */
        if (player->play_subtitle && player->pipeline) {
                GstElement *text_sink = GST_ELEMENT_CAST(player->pipeline->textbin[MMPLAYER_T_FAKE_SINK].gst);