From: Eunhye Choi Date: Thu, 16 Jan 2020 02:14:51 +0000 (+0900) Subject: add queue setting for buffering X-Git-Tag: accepted/tizen/unified/20200415.121431~1^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35736c0a1c9c49cc6118511ebfb130543148d479;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git add queue setting for buffering Change-Id: Icea1e0e5c3ba99f4c86a2fa6f7318cf0af623780 --- diff --git a/src/include/mm_player_ini.h b/src/include/mm_player_ini.h index d92f132..b2bed73 100644 --- a/src/include/mm_player_ini.h +++ b/src/include/mm_player_ini.h @@ -173,11 +173,11 @@ typedef struct { #define DEFAULT_NUM_OF_VIDEO_BO 10 #define DEFAULT_TIMEOUT_OF_VIDEO_BO 10 /* sec */ #define DEFAULT_AUDIO_OFFLOAD_SINK "" -#define DEFAULT_USE_URIDECODEBIN3 FALSE #define DEFAULT_SUPPORT_AUDIO_EFFECT FALSE /* with HW audio codec */ #define DEFAULT_SUPPORT_PCM_EXPORTING FALSE /* with HW audio codec */ #define DEFAULT_SUPPORT_PITCH_CONTROL FALSE /* with HW audio codec */ #define DEFAULT_SUPPORT_REPLAYGAIN_CONTROL FALSE /* with HW audio codec */ +#define DEFAULT_USE_URIDECODEBIN3 FALSE /* http streaming */ #define DEFAULT_HTTPSRC "souphttpsrc" diff --git a/src/mm_player_gst.c b/src/mm_player_gst.c index 686d54a..476ed61 100644 --- a/src/mm_player_gst.c +++ b/src/mm_player_gst.c @@ -1009,6 +1009,24 @@ __mmplayer_gst_check_useful_message(mmplayer_t *player, GstMessage *message) 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); @@ -2783,34 +2801,106 @@ __mmplayer_gst_deep_element_added(GstElement *bin, GstBin *child, GstElement *el { 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 (!player->pipeline->mainbin[MMPLAYER_M_TYPEFIND].gst && g_strrstr(factory_name, "typefind")) { - player->pipeline->mainbin[MMPLAYER_M_TYPEFIND].id = MMPLAYER_M_TYPEFIND; - player->pipeline->mainbin[MMPLAYER_M_TYPEFIND].gst = element; + if (!mainbin[MMPLAYER_M_TYPEFIND].gst && g_strrstr(factory_name, "typefind")) { + 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); + + } else if (!mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst && g_strrstr(factory_name, "queue2")) { + + 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 */ + } else if (g_strrstr(factory_name, "parsebin")) { - player->pipeline->mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].id = MMPLAYER_M_AUTOPLUG_PARSEBIN; - player->pipeline->mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].gst = element; + + if (!mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst) { + GstIterator *iter = NULL; + GValue item = {0, }; + GstElement *ch_element = NULL; + GstElementFactory *ch_factory = NULL; + + g_object_set(G_OBJECT(child), "message-forward", TRUE, 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); + } + } + 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; } @@ -2825,7 +2915,6 @@ static GstElement * __mmplayer_gst_make_uridecodebin(mmplayer_t *player) { GstElement *uridecodebin3 = NULL; - GstElement *decodebin3 = NULL, *multiqueue = NULL; MMPLAYER_FENTER(); MMPLAYER_RETURN_VAL_IF_FAIL(player, NULL); @@ -2839,21 +2928,6 @@ __mmplayer_gst_make_uridecodebin(mmplayer_t *player) /* get attribute */ SECURE_LOGD("uri : %s", player->profile.uri); - decodebin3 = gst_bin_get_by_name((GstBin *)uridecodebin3, "decodebin3-0"); - - if (decodebin3) { - g_object_set(G_OBJECT(decodebin3), "message-forward", TRUE, NULL); - multiqueue = gst_bin_get_by_name((GstBin *)decodebin3, "multiqueue0"); - } - - if (multiqueue) { - player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].id = MMPLAYER_M_DEMUXED_S_BUFFER; - player->pipeline->mainbin[MMPLAYER_M_DEMUXED_S_BUFFER].gst = multiqueue; - - /* in case of multiqueue, max bytes size is defined with fixed value in mm_player_streaming.h */ - _mm_player_streaming_set_multiqueue(player->streamer, multiqueue); - } - /* setting property to streaming source */ g_object_set(G_OBJECT(uridecodebin3), "uri", player->profile.uri, "message-forward", TRUE, NULL); diff --git a/src/mm_player_streaming.c b/src/mm_player_streaming.c index 6f5cd28..285e9d4 100644 --- a/src/mm_player_streaming.c +++ b/src/mm_player_streaming.c @@ -325,7 +325,8 @@ static void __streaming_set_buffer_size(mmplayer_streaming_t *streamer, g_object_set(G_OBJECT(buffer_handle->buffer), "max-size-bytes", MAX_BUFFER_SIZE_BYTES, /* mq size is fixed, control it with high/low watermark value*/ "max-size-time", (guint64)(buffering_time * GST_MSECOND), - "max-size-buffers", 0, NULL); /* disable */ + "max-size-buffers", 0, /* disable */ + "use-interleave", FALSE, NULL); GET_CURRENT_BUFFERING_TIME(buffer_handle) = buffering_time; GET_CURRENT_BUFFERING_BYTE(buffer_handle) = MAX_BUFFER_SIZE_BYTES;