From 8a1883e1e0b19173c9bcfcaf83f5008c9f4b3521 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Mon, 14 Aug 2017 18:14:47 +0900 Subject: [PATCH] [0.6.59] use ms for buffering and remove deadcode Change-Id: I45c1bcbdb6f39c2bf5f8d0392a3e7d04d4ac9f06 --- packaging/libmm-player.spec | 2 +- src/include/mm_player.h | 45 +----------- src/include/mm_player_ini.h | 2 +- src/include/mm_player_priv.h | 2 - src/include/mm_player_streaming.h | 25 ++++--- src/mm_player.c | 30 -------- src/mm_player_ini.c | 6 +- src/mm_player_priv.c | 79 ++------------------ src/mm_player_streaming.c | 148 ++++++++++++++++---------------------- 9 files changed, 88 insertions(+), 251 deletions(-) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index 7102bb5..ded3b14 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.58 +Version: 0.6.59 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_player.h b/src/include/mm_player.h index 29f9cdd..4d4149e 100644 --- a/src/include/mm_player.h +++ b/src/include/mm_player.h @@ -773,8 +773,7 @@ typedef enum { typedef enum { MM_PLAYER_BUFFERING_MODE_ADAPTIVE = 0, /**< default, If buffering is occurred, player will consider the bandwidth to adjust buffer setting. */ MM_PLAYER_BUFFERING_MODE_FIXED, /**< player will set buffer size with this fixed size value. */ - MM_PLAYER_BUFFERING_MODE_SLINK, /**< If buffering is occurred, player will adjust buffer setting and no more buffering will be occurred again. */ - MM_PLAYER_BUFFERING_MODE_MAX = MM_PLAYER_BUFFERING_MODE_SLINK, + MM_PLAYER_BUFFERING_MODE_MAX, }MMPlayerBufferingMode; typedef enum @@ -1868,48 +1867,6 @@ int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType ty int mm_player_get_current_track(MMHandleType hplayer, MMPlayerTrackType type, int *index); /** - * This function is to set the buffer size for streaming playback. \n - * - * @param player [in] Handle of player - * @param second [in] Size of initial buffer - * - * @return This function returns zero on success, or negative value with error code. - * @remark None - * @par Example - * @code -gint second = 10; //10sec - -if (mm_player_set_prepare_buffering_time(g_player, second) != MM_ERROR_NONE) -{ - LOGE("failed to set buffer size\n"); -} - * @endcode - */ - -int mm_player_set_prepare_buffering_time(MMHandleType player, int second); - -/** - * This function is to set the runtime buffering mode for streaming playback. \n - * - * @param player [in] Handle of player - * @param mode [in] mode of runtime buffering - * @param second [in] max size of buffering - * - * @return This function returns zero on success, or negative value with error code. - * @remark None - * @par Example - * @code - -if (mm_player_set_runtime_buffering_mode(g_player, MM_PLAYER_BUFFERING_MODE_ADAPTIVE, 10) != MM_ERROR_NONE) -{ - LOGE("failed to set buffering mode\n"); -} - * @endcode - */ - -int mm_player_set_runtime_buffering_mode(MMHandleType player, MMPlayerBufferingMode mode, int second); - -/** * This function is to set the start position of zoom * * @param player [in] handle of player diff --git a/src/include/mm_player_ini.h b/src/include/mm_player_ini.h index b5840bb..7f312aa 100644 --- a/src/include/mm_player_ini.h +++ b/src/include/mm_player_ini.h @@ -87,7 +87,7 @@ typedef struct __mm_player_ini { guint http_ring_buffer_size; gdouble http_buffering_limit; guint http_max_size_bytes; - gdouble http_buffering_time; + gint http_buffering_time; gint http_timeout; /* audio effect */ diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index 2971088..467b1a3 100644 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -851,8 +851,6 @@ gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type, int index); int _mmplayer_sync_subtitle_pipeline(mm_player_t* player); -int _mmplayer_set_prepare_buffering_time(MMHandleType hplayer, int second); -int _mmplayer_set_runtime_buffering_mode(MMHandleType hplayer, MMPlayerBufferingMode mode, int second); int _mmplayer_set_display_zoom(MMHandleType hplayer, float level, int x, int y); int _mmplayer_get_display_zoom(MMHandleType hplayer, float *level, int *x, int *y); int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode); diff --git a/src/include/mm_player_streaming.h b/src/include/mm_player_streaming.h index 46659ca..4ea7638 100644 --- a/src/include/mm_player_streaming.h +++ b/src/include/mm_player_streaming.h @@ -35,18 +35,18 @@ #define MIN_BUFFER_PERCENT 0.0 #define MAX_BUFFER_PERCENT 100.0 #define MIN_BUFFERING_TIME 3.0 -#define MAX_BUFFERING_TIME 10.0 +#define MAX_BUFFERING_TIME (10*1000) /* ms */ #define MAX_DECODEBIN_BUFFER_BYTES (32 * 1024 * 1024) /* byte */ -#define MAX_DECODEBIN_BUFFER_TIME 15 /* sec */ +#define MAX_DECODEBIN_BUFFER_TIME (15*1000) /* ms */ #define MAX_DECODEBIN_ADAPTIVE_BUFFER_BYTES (2 * 1024 * 1024) /* byte */ -#define MAX_DECODEBIN_ADAPTIVE_BUFFER_TIME 5 /* sec */ +#define MAX_DECODEBIN_ADAPTIVE_BUFFER_TIME (5*1000) /* ms */ #define DEFAULT_BUFFER_SIZE_BYTES 4194304 /* 4 MBytes */ -#define DEFAULT_PLAYING_TIME 10 /* 10 sec */ -#define DEFAULT_ADAPTIVE_PLAYING_TIME 3 /* 3 sec */ +#define DEFAULT_PLAYING_TIME (10*1000) /* ms */ +#define DEFAULT_ADAPTIVE_PLAYING_TIME (3*1000) /* ms */ -#define DEFAULT_BUFFERING_TIME 3.0 /* 3sec */ +#define DEFAULT_BUFFERING_TIME (3*1000) /* ms */ #define DEFAULT_BUFFER_LOW_PERCENT 1.0 /* 1% */ #define DEFAULT_BUFFER_HIGH_PERCENT 99.0 /* 15% */ #define DEFAULT_RING_BUFFER_SIZE (20*1024*1024) /* 20MBytes */ @@ -98,16 +98,15 @@ typedef enum { typedef struct { MMPlayerBufferingMode mode; gboolean is_pre_buffering; - gint initial_second; - gint runtime_second; - + gint prebuffer_time; /* ms */ + gint rebuffer_time; /* ms */ } streaming_requirement_t; typedef struct { GstElement* buffer; /* buffering element of playback pipeline */ guint buffering_bytes; - gdouble buffering_time; // mq : max buffering time value till now + gint buffering_time; // mq : max buffering time value till now gdouble buffer_high_percent; gdouble buffer_low_percent; @@ -117,7 +116,7 @@ typedef struct { typedef struct { gboolean buffering_monitor; gint64 prev_pos; - gdouble buffering_time; // DEFAULT_BUFFERING_TIME + gint buffering_time; // DEFAULT_BUFFERING_TIME } streaming_default_t; typedef struct { @@ -149,7 +148,7 @@ void __mm_player_streaming_set_queue2(mm_player_streaming_t* streamer, GstElement* buffer, gboolean use_buffering, guint buffering_bytes, - gdouble buffering_time, + gint buffering_time, gdouble low_percent, gdouble high_percent, muxed_buffer_type_e type, @@ -158,7 +157,7 @@ void __mm_player_streaming_set_queue2(mm_player_streaming_t* streamer, void __mm_player_streaming_set_multiqueue(mm_player_streaming_t* streamer, GstElement* buffer, gboolean use_buffering, - gdouble buffering_time, + gint buffering_time, gdouble low_percent, gdouble high_percent); void __mm_player_streaming_sync_property(mm_player_streaming_t* streamer, GstElement* decodebin); diff --git a/src/mm_player.c b/src/mm_player.c index 62d3dce..741a5a0 100644 --- a/src/mm_player.c +++ b/src/mm_player.c @@ -272,36 +272,6 @@ int mm_player_do_video_capture(MMHandleType player) return result; } -int mm_player_set_prepare_buffering_time(MMHandleType player, int second) -{ - int result = MM_ERROR_NONE; - - MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - - MMPLAYER_CMD_LOCK( player ); - - result = _mmplayer_set_prepare_buffering_time(player, second); - - MMPLAYER_CMD_UNLOCK( player ); - - return result; -} - -int mm_player_set_runtime_buffering_mode(MMHandleType player, MMPlayerBufferingMode mode, int second) -{ - int result = MM_ERROR_NONE; - - MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - - MMPLAYER_CMD_LOCK( player ); - - result = _mmplayer_set_runtime_buffering_mode(player, mode, second); - - MMPLAYER_CMD_UNLOCK( player ); - - return result; -} - int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume) { int result = MM_ERROR_NONE; diff --git a/src/mm_player_ini.c b/src/mm_player_ini.c index 886cdb4..d303994 100644 --- a/src/mm_player_ini.c +++ b/src/mm_player_ini.c @@ -174,7 +174,7 @@ mm_player_ini_load(mm_player_ini_t* ini) ini->http_ring_buffer_size = iniparser_getint(dict, "http streaming:http ring buffer size", DEFAULT_HTTP_RING_BUFFER_SIZE); ini->http_buffering_limit = iniparser_getdouble(dict, "http streaming:http buffering high limit", DEFAULT_HTTP_BUFFERING_LIMIT); ini->http_max_size_bytes = iniparser_getint(dict, "http streaming:http max size bytes", DEFAULT_HTTP_MAX_SIZE_BYTES); - ini->http_buffering_time = iniparser_getdouble(dict, "http streaming:http buffering time", DEFAULT_HTTP_BUFFERING_TIME); + ini->http_buffering_time = (gint)(iniparser_getdouble(dict, "http streaming:http buffering time", DEFAULT_HTTP_BUFFERING_TIME) * 1000); ini->http_timeout = iniparser_getint(dict, "http streaming:http timeout", DEFAULT_HTTP_TIMEOUT); /* dump buffer for debug */ @@ -222,7 +222,7 @@ mm_player_ini_load(mm_player_ini_t* ini) ini->http_use_file_buffer = DEFAULT_HTTP_USE_FILE_BUFFER; ini->http_ring_buffer_size = DEFAULT_HTTP_RING_BUFFER_SIZE; ini->http_max_size_bytes = DEFAULT_HTTP_MAX_SIZE_BYTES; - ini->http_buffering_time = DEFAULT_HTTP_BUFFERING_TIME; + ini->http_buffering_time = (gint)(DEFAULT_HTTP_BUFFERING_TIME*1000); ini->http_timeout = DEFAULT_HTTP_TIMEOUT; /* dump buffer for debug */ @@ -274,7 +274,7 @@ mm_player_ini_load(mm_player_ini_t* ini) LOGD("http use file buffer : %d \n", ini->http_use_file_buffer); LOGD("http ring buffer size : %d \n", ini->http_ring_buffer_size); LOGD("http max_size bytes : %d \n", ini->http_max_size_bytes); - LOGD("http buffering time : %f \n", ini->http_buffering_time); + LOGD("http buffering time : %d \n", ini->http_buffering_time); LOGD("http timeout : %d \n", ini->http_timeout); return MM_ERROR_NONE; diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 710c200..f3c45e7 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -3264,11 +3264,11 @@ __mmplayer_gst_decode_no_more_pads(GstElement *elem, gpointer data) goto ERROR; } - gdouble init_buffering_time = (gdouble)player->streamer->buffering_req.initial_second; - guint buffer_bytes = init_buffering_time * ESTIMATED_BUFFER_UNIT; + gint init_buffering_time = player->streamer->buffering_req.prebuffer_time; + guint 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("[Decodebin2] set use-buffering on Q2(pre buffer time: %d sec, buffer size : %d)\n", (gint)init_buffering_time, buffer_bytes); + LOGD("[Decodebin2] set use-buffering on Q2(pre buffer time: %d ms, buffer size : %d)\n", init_buffering_time, buffer_bytes); init_buffering_time = (init_buffering_time != 0) ? (init_buffering_time) : (player->ini.http_buffering_time); @@ -6626,9 +6626,9 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) } if (MMPLAYER_IS_HTTP_PD(player)) { - gdouble pre_buffering_time = (gdouble)player->streamer->buffering_req.initial_second; + gint pre_buffering_time = player->streamer->buffering_req.prebuffer_time; - LOGD("Picked queue2 element(pre buffer : %d sec)....\n", pre_buffering_time); + LOGD("Picked queue2 element(pre buffer : %d ms)....\n", pre_buffering_time); element = gst_element_factory_make("queue2", "queue2"); if (!element) { LOGE("failed to create http streaming buffer element\n"); @@ -9430,71 +9430,6 @@ _mmplayer_set_audiostream_cb(MMHandleType hplayer, mm_player_audio_stream_callba return MM_ERROR_NONE; } -// set prepare size -int -_mmplayer_set_prepare_buffering_time(MMHandleType hplayer, int second) -{ - 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) - return MM_ERROR_PLAYER_INVALID_STATE; - - LOGD("pre buffer size : %d sec\n", second); - - if (second <= 0) { - LOGE("bad size value\n"); - return MM_ERROR_INVALID_ARGUMENT; - } - - if (player->streamer == NULL) { - player->streamer = __mm_player_streaming_create(); - __mm_player_streaming_initialize(player->streamer); - } - - player->streamer->buffering_req.initial_second = second; - - MMPLAYER_FLEAVE(); - - return MM_ERROR_NONE; -} - -// set runtime mode -int -_mmplayer_set_runtime_buffering_mode(MMHandleType hplayer, MMPlayerBufferingMode mode, int second) -{ - mm_player_t* player = (mm_player_t*) hplayer; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - - LOGD("mode %d\n", mode); - - if ((mode > MM_PLAYER_BUFFERING_MODE_MAX) || - ((mode == MM_PLAYER_BUFFERING_MODE_FIXED) && (second <= 0))) - return MM_ERROR_INVALID_ARGUMENT; - - if (player->streamer == NULL) { - player->streamer = __mm_player_streaming_create(); - __mm_player_streaming_initialize(player->streamer); - } - - player->streamer->buffering_req.mode = mode; - - if ((second > 0) && - ((mode == MM_PLAYER_BUFFERING_MODE_FIXED) || - (mode == MM_PLAYER_BUFFERING_MODE_ADAPTIVE))) - player->streamer->buffering_req.runtime_second = second; - - MMPLAYER_FLEAVE(); - - return MM_ERROR_NONE; -} - static int __mmplayer_start_streaming_ext(mm_player_t *player) { @@ -10204,7 +10139,7 @@ __mmplayer_update_content_type_info(mm_player_t* player) if (player->streamer) { player->streamer->is_adaptive_streaming = TRUE; player->streamer->buffering_req.mode = MM_PLAYER_BUFFERING_MODE_FIXED; - player->streamer->buffering_req.runtime_second = 5; + player->streamer->buffering_req.rebuffer_time = 5 * 1000; } } else if (g_strrstr(player->type, "application/dash+xml")) { player->profile.uri_type = MM_PLAYER_URI_TYPE_DASH; @@ -10361,7 +10296,7 @@ __mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstC gint64 dur_bytes = 0L; guint max_buffer_size_bytes = 0; - gdouble init_buffering_time = (gdouble)player->streamer->buffering_req.initial_second; + gint init_buffering_time = player->streamer->buffering_req.prebuffer_time; MMPLAYER_FENTER(); MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, FALSE); diff --git a/src/mm_player_streaming.c b/src/mm_player_streaming.c index f198daf..c343ce6 100644 --- a/src/mm_player_streaming.c +++ b/src/mm_player_streaming.c @@ -25,12 +25,10 @@ #include "mm_player_utils.h" #include "mm_player_streaming.h" -#define TO_THE_END 0 - typedef struct { gint byte_in_rate; // byte gint byte_out_rate; // byte - gdouble time_rate; // second + gint time_rate; // ms guint buffer_criteria; // byte } streaming_bitrate_info_t; @@ -42,7 +40,7 @@ typedef struct { typedef struct { guint buffering_bytes; // bytes - gdouble buffering_time; // second + gint buffering_time; // ms gdouble percent_byte; gdouble percent_time; } streaming_buffer_info_t; @@ -50,7 +48,7 @@ typedef struct { static void streaming_check_buffer_percent(gdouble in_low, gdouble in_high, gdouble *out_low, gdouble *out_high); static void streaming_set_buffer_percent(mm_player_streaming_t* streamer, BufferType type, gdouble low_percent, gdouble high_percent_byte, gdouble high_percent_time); static void streaming_set_queue2_queue_type(mm_player_streaming_t* streamer, muxed_buffer_type_e type, gchar * file_path, guint64 content_size); -static void streaming_set_buffer_size(mm_player_streaming_t* streamer, BufferType type, guint buffering_bytes, gdouble buffering_time); +static void streaming_set_buffer_size(mm_player_streaming_t* streamer, BufferType type, guint buffering_bytes, gint buffering_time); static void streaming_update_buffering_status(mm_player_streaming_t* streamer, GstMessage *buffering_msg, gint64 position); static void streaming_get_current_bitrate_info(mm_player_streaming_t* streamer, GstMessage *buffering_msg, @@ -59,7 +57,7 @@ static void streaming_get_current_bitrate_info(mm_player_streaming_t* streamer, static void streaming_handle_fixed_buffering_mode(mm_player_streaming_t* streamer, gint byte_out_rate, - gdouble fixed_buffering_time, + gint fixed_buffering_time, streaming_buffer_info_t* buffer_info); static void streaming_handle_adaptive_buffering_mode(mm_player_streaming_t* streamer, @@ -119,8 +117,8 @@ void __mm_player_streaming_initialize(mm_player_streaming_t* streamer) streamer->buffering_req.mode = MM_PLAYER_BUFFERING_MODE_ADAPTIVE; streamer->buffering_req.is_pre_buffering = FALSE; - streamer->buffering_req.initial_second = 0; - streamer->buffering_req.runtime_second = 0; + streamer->buffering_req.prebuffer_time = 0; + streamer->buffering_req.rebuffer_time = 0; streamer->default_val.buffering_monitor = FALSE; streamer->default_val.buffering_time = DEFAULT_BUFFERING_TIME; @@ -152,8 +150,8 @@ void __mm_player_streaming_deinitialize(mm_player_streaming_t* streamer) streamer->buffering_req.mode = MM_PLAYER_BUFFERING_MODE_ADAPTIVE; streamer->buffering_req.is_pre_buffering = FALSE; - streamer->buffering_req.initial_second = 0; - streamer->buffering_req.runtime_second = 0; + streamer->buffering_req.prebuffer_time = 0; + streamer->buffering_req.rebuffer_time = 0; streamer->default_val.buffering_monitor = FALSE; streamer->default_val.buffering_time = DEFAULT_BUFFERING_TIME; @@ -395,7 +393,7 @@ streaming_set_queue2_queue_type(mm_player_streaming_t* streamer, muxed_buffer_ty } static void -streaming_set_buffer_size(mm_player_streaming_t* streamer, BufferType type, guint buffering_bytes, gdouble buffering_time) +streaming_set_buffer_size(mm_player_streaming_t* streamer, BufferType type, guint buffering_bytes, gint buffering_time) { streaming_buffer_t* buffer_handle = NULL; @@ -414,19 +412,19 @@ streaming_set_buffer_size(mm_player_streaming_t* streamer, BufferType type, guin g_object_set(G_OBJECT(buffer_handle->buffer), "max-size-bytes", GET_MAX_BUFFER_BYTES(streamer), /* mq size is fixed, control it with high/low percent value*/ - "max-size-time", ((guint)ceil(buffering_time) * GST_SECOND), + "max-size-time", (guint64)(buffering_time * GST_MSECOND), "max-size-buffers", 0, NULL); /* disable */ buffer_handle->buffering_time = buffering_time; buffer_handle->buffering_bytes = GET_MAX_BUFFER_BYTES(streamer); - LOGD("max-size-time : %f", buffering_time); + LOGD("max-size-time : %d ms", buffering_time); } else { /* queue2 */ if (buffer_handle->is_live) g_object_set(G_OBJECT(buffer_handle->buffer), "max-size-bytes", buffering_bytes, - "max-size-time", (guint64)(buffering_time*GST_SECOND), + "max-size-time", (guint64)(buffering_time*GST_MSECOND), "max-size-buffers", 0, "use-rate-estimate", TRUE, NULL); else @@ -451,7 +449,7 @@ void __mm_player_streaming_set_queue2(mm_player_streaming_t* streamer, GstElement* buffer, gboolean use_buffering, guint buffering_bytes, - gdouble buffering_time, + gint buffering_time, gdouble low_percent, gdouble high_percent, muxed_buffer_type_e type, @@ -470,15 +468,15 @@ void __mm_player_streaming_set_queue2(mm_player_streaming_t* streamer, streamer->streaming_buffer_type = BUFFER_TYPE_MUXED; if (content_size > 0) { - if (streamer->buffering_req.initial_second > 0) + if (streamer->buffering_req.prebuffer_time > 0) streamer->buffering_req.is_pre_buffering = TRUE; else - streamer->buffering_req.initial_second = (gint)ceil(buffering_time); + streamer->buffering_req.prebuffer_time = buffering_time; } else { LOGD("live streaming without mq"); streamer->buffer_handle[BUFFER_TYPE_MUXED].is_live = TRUE; - streamer->buffering_req.initial_second = buffering_time = DEFAULT_BUFFERING_TIME; + streamer->buffering_req.prebuffer_time = buffering_time = DEFAULT_BUFFERING_TIME; } } @@ -506,7 +504,7 @@ void __mm_player_streaming_sync_property(mm_player_streaming_t* streamer, GstEle if ((streamer->need_sync) && (streamer->streaming_buffer_type == BUFFER_TYPE_DEMUXED)) { g_object_set(G_OBJECT(decodebin), "max-size-bytes", buffer_handle->buffering_bytes, - "max-size-time", (guint64)(ceil(buffer_handle->buffering_time) * GST_SECOND), + "max-size-time", (guint64)(buffer_handle->buffering_time * GST_MSECOND), "low-percent", (gint)buffer_handle->buffer_low_percent, "high-percent", (gint)buffer_handle->buffer_high_percent, NULL); @@ -518,18 +516,18 @@ void __mm_player_streaming_sync_property(mm_player_streaming_t* streamer, GstEle void __mm_player_streaming_set_multiqueue(mm_player_streaming_t* streamer, GstElement* buffer, gboolean use_buffering, - gdouble buffering_time, + gint buffering_time, gdouble low_percent, gdouble high_percent) { streaming_buffer_t* buffer_handle = NULL; - gdouble pre_buffering_time = 0.0; + gint pre_buffering_time = 0; MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(streamer); buffer_handle = &(streamer->buffer_handle[BUFFER_TYPE_DEMUXED]); - pre_buffering_time = (gdouble)streamer->buffering_req.initial_second; + pre_buffering_time = streamer->buffering_req.prebuffer_time; if (buffer) { buffer_handle->buffer = buffer; @@ -545,14 +543,14 @@ void __mm_player_streaming_set_multiqueue(mm_player_streaming_t* streamer, g_object_set(G_OBJECT(buffer_handle->buffer), "use-buffering", use_buffering, NULL); } - LOGD("pre_buffering: %2.2f, during playing: %2.2f\n", pre_buffering_time, buffering_time); + LOGD("pre_buffering: %d ms, during playing: %d ms\n", pre_buffering_time, buffering_time); - if (pre_buffering_time <= 0.0) { + if (pre_buffering_time <= 0) { pre_buffering_time = GET_DEFAULT_PLAYING_TIME(streamer); - streamer->buffering_req.initial_second = (gint)ceil(buffering_time); + streamer->buffering_req.prebuffer_time = buffering_time; } - high_percent = (pre_buffering_time * 100) / GET_MAX_BUFFER_TIME(streamer); + high_percent = (gdouble)(pre_buffering_time * 100) / GET_MAX_BUFFER_TIME(streamer); LOGD("high_percent %2.3f %%\n", high_percent); streaming_set_buffer_size(streamer, BUFFER_TYPE_DEMUXED, GET_MAX_BUFFER_BYTES(streamer), GET_MAX_BUFFER_TIME(streamer)); @@ -580,7 +578,7 @@ streaming_get_current_bitrate_info(mm_player_streaming_t* streamer, guint buffer_criteria = 0; guint estimated_content_bitrate = 0; - gdouble buffer_buffering_time = DEFAULT_BUFFERING_TIME; + gint buffer_buffering_time = DEFAULT_BUFFERING_TIME; MMPLAYER_FENTER(); @@ -627,7 +625,7 @@ streaming_get_current_bitrate_info(mm_player_streaming_t* streamer, LOGW("There is no content bitrate information\n"); if ((in_rate > 0) && (out_rate > 0)) - buffer_buffering_time = (gdouble)out_rate / (gdouble)in_rate; + buffer_buffering_time = (gint)(out_rate / in_rate)*1000; else if ((in_rate <= 0) && (out_rate > 0)) buffer_buffering_time = MAX_BUFFERING_TIME; else @@ -642,13 +640,13 @@ streaming_get_current_bitrate_info(mm_player_streaming_t* streamer, static void streaming_handle_fixed_buffering_mode(mm_player_streaming_t* streamer, gint byte_out_rate, - gdouble fixed_buffering_time, + gint fixed_buffering_time, streaming_buffer_info_t* buffer_info) { streaming_buffer_t* buffer_handle = NULL; guint buffering_bytes = 0; - gdouble buffering_time = 0.0; + gint buffering_time = 0; gdouble per_byte = 0.0; gdouble per_time = 0.0; @@ -658,7 +656,7 @@ streaming_handle_fixed_buffering_mode(mm_player_streaming_t* streamer, buffer_handle = &(streamer->buffer_handle[streamer->streaming_buffer_type]); buffering_time = fixed_buffering_time; - LOGD("buffering time: %2.2f sec, out rate: %d\n", buffering_time, byte_out_rate); + LOGD("buffering time: %d ms, out rate: %d\n", buffering_time, byte_out_rate); if ((buffering_time > 0) && (byte_out_rate > 0)) { buffering_bytes = GET_NEW_BUFFERING_BYTE(byte_out_rate * buffering_time); @@ -673,7 +671,7 @@ streaming_handle_fixed_buffering_mode(mm_player_streaming_t* streamer, GET_PERCENT(buffering_time, GET_CURRENT_BUFFERING_TIME(buffer_handle), buffer_handle->buffer_high_percent, per_time); GET_PERCENT(buffering_bytes, GET_CURRENT_BUFFERING_BYTE(buffer_handle), buffer_handle->buffer_high_percent, per_byte); - LOGD("bytes %d, time %f, per_byte %f, per_time %f\n", + LOGD("bytes %d, time %d, per_byte %f, per_time %f\n", buffering_bytes, buffering_time, per_byte, per_time); (*buffer_info).buffering_bytes = buffering_bytes; @@ -693,22 +691,21 @@ streaming_handle_adaptive_buffering_mode(mm_player_streaming_t* streamer, gint buffering_bytes = 0; gint adj_buffering_bytes = 0; - gdouble buffer_buffering_time = 0.0; + gint buffer_buffering_time = 0; gdouble per_byte = 0.0; gdouble per_time = 0.0; gdouble portion = 0.0; - gdouble default_buffering_time = 0.0; + gint default_buffering_time = 0; MMPLAYER_RETURN_IF_FAIL(streamer); MMPLAYER_RETURN_IF_FAIL(buffer_info); - LOGD("pos %lld, dur %lld, size %lld, in/out:%d/%d, buffer_criteria:%d, time_rate:%f, need:%d sec\n", + LOGD("pos %lld, dur %lld, size %lld, in/out:%d/%d, buffer_criteria:%d, time_rate:%d, need:%d ms\n", content_info.position, content_info.duration, content_info.content_size, bitrate_info.byte_in_rate, bitrate_info.byte_out_rate, bitrate_info.buffer_criteria, bitrate_info.time_rate, expected_play_time); - if (((expected_play_time == TO_THE_END) && (content_info.position <= 0)) || - (content_info.duration <= 0) || + if ((content_info.duration <= 0) || (content_info.content_size <= 0)) { LOGW("keep previous setting.\n"); return; @@ -722,11 +719,7 @@ streaming_handle_adaptive_buffering_mode(mm_player_streaming_t* streamer, buffer_handle = &(streamer->buffer_handle[streamer->streaming_buffer_type]); if (bitrate_info.byte_in_rate < bitrate_info.byte_out_rate) { - if (expected_play_time != TO_THE_END) - portion = (double)(expected_play_time * GST_SECOND) / (double)content_info.duration; - else - portion = (1 - (double)content_info.position/(double)content_info.duration); - + portion = (double)(expected_play_time * GST_MSECOND) / (double)content_info.duration; buffering_bytes = GET_NEW_BUFFERING_BYTE(((double)content_info.content_size * portion) \ * (1 - (double)bitrate_info.byte_in_rate/(double)bitrate_info.byte_out_rate)); } else { @@ -738,28 +731,28 @@ streaming_handle_adaptive_buffering_mode(mm_player_streaming_t* streamer, } if (buffering_bytes > 0) - buffer_buffering_time = (gdouble)buffering_bytes / (gdouble)bitrate_info.byte_out_rate; + buffer_buffering_time = (gint)(buffering_bytes / bitrate_info.byte_out_rate)*1000; if (content_info.position <= 0) { /* if the buffer is filled under 50%, MSL use the original default buffering time. if not, MSL use just 2 sec as a default buffering time. (to reduce initial buffering time) */ - default_buffering_time = streamer->default_val.buffering_time - ((gdouble)streamer->buffering_percent/50); + default_buffering_time = streamer->default_val.buffering_time - ((gdouble)streamer->buffering_percent/50)*1000; } else default_buffering_time = streamer->default_val.buffering_time; if (buffer_buffering_time < default_buffering_time) { - LOGD("adjusted time: %2.2f -> %2.2f\n", buffer_buffering_time, default_buffering_time); + LOGD("adjusted time: %d -> %d ms\n", buffer_buffering_time, default_buffering_time); LOGD("adjusted bytes : %d or %d or %d\n", buffering_bytes, - (gint)(bitrate_info.byte_out_rate * buffer_buffering_time), - (gint)(bitrate_info.buffer_criteria * buffer_buffering_time)); + (gint)(bitrate_info.byte_out_rate * buffer_buffering_time/1000), + (gint)(bitrate_info.buffer_criteria * buffer_buffering_time/1000)); /* start monitoring the abmormal state */ if (content_info.position > 0) streamer->default_val.buffering_monitor = TRUE; buffer_buffering_time = default_buffering_time; - adj_buffering_bytes = GET_NEW_BUFFERING_BYTE(bitrate_info.byte_out_rate * (gint)ceil(buffer_buffering_time)); + adj_buffering_bytes = GET_NEW_BUFFERING_BYTE(bitrate_info.byte_out_rate * (gint)ceil((gdouble)buffer_buffering_time/1000)); buffering_bytes = MAX(buffering_bytes, adj_buffering_bytes); } @@ -819,7 +812,7 @@ streaming_update_buffer_setting(mm_player_streaming_t* streamer, streaming_get_current_bitrate_info(streamer, buffering_msg, content_info, &bitrate_info); - LOGD("buffering mode %d, new info in_r:%d, out_r:%d, cb:%d, bt:%f\n", + LOGD("buffering mode %d, new info in_r:%d, out_r:%d, cb:%d, bt:%d\n", buffering_mode, bitrate_info.byte_in_rate, bitrate_info.byte_out_rate, bitrate_info.buffer_criteria, bitrate_info.time_rate); @@ -830,29 +823,24 @@ streaming_update_buffer_setting(mm_player_streaming_t* streamer, /******************** * (1) fixed mode * ********************/ - gdouble buffering_time = 0.0; + gint buffering_time = 0; if (streamer->buffering_req.is_pre_buffering == TRUE) - buffering_time = (gdouble)streamer->buffering_req.initial_second; + buffering_time = streamer->buffering_req.prebuffer_time; else - buffering_time = (gdouble)streamer->buffering_req.runtime_second; + buffering_time = streamer->buffering_req.rebuffer_time; streaming_handle_fixed_buffering_mode(streamer, bitrate_info.byte_out_rate, buffering_time, &buffer_info); - } else if (buffering_mode == MM_PLAYER_BUFFERING_MODE_SLINK) { - /*********************************** - * (2) once mode for samsung link * - ***********************************/ - streaming_handle_adaptive_buffering_mode(streamer, content_info, bitrate_info, &buffer_info, TO_THE_END); } else { /********************************* - * (3) adaptive mode (default) * + * (2) adaptive mode (default) * *********************************/ gint expected_play_time = DEFAULT_PLAYING_TIME; - if (streamer->buffering_req.runtime_second > 0) - expected_play_time = streamer->buffering_req.runtime_second; + if (streamer->buffering_req.rebuffer_time > 0) + expected_play_time = streamer->buffering_req.rebuffer_time; else if ((position == 0) && (streamer->is_buffering)) - expected_play_time = streamer->buffering_req.initial_second; + expected_play_time = streamer->buffering_req.prebuffer_time; if (expected_play_time <= 0) expected_play_time = DEFAULT_PLAYING_TIME; @@ -863,7 +851,7 @@ streaming_update_buffer_setting(mm_player_streaming_t* streamer, buffer_handle->buffering_time = buffer_info.buffering_time; } - LOGD("adj buffer(%d) %d->%d bytes/%2.2f->%2.2f sec\n", + LOGD("adj buffer(%d) %d->%d bytes/%d->%d ms\n", streamer->streaming_buffer_type, GET_CURRENT_BUFFERING_BYTE(buffer_handle), buffer_info.buffering_bytes, GET_CURRENT_BUFFERING_TIME(buffer_handle), buffer_info.buffering_time); @@ -872,7 +860,7 @@ streaming_update_buffer_setting(mm_player_streaming_t* streamer, if (((GET_CURRENT_BUFFERING_BYTE(buffer_handle) < buffer_info.buffering_bytes) && IS_MUXED_BUFFERING_MODE(streamer)) || ((GET_CURRENT_BUFFERING_TIME(buffer_handle) < buffer_info.buffering_time) && IS_DEMUXED_BUFFERING_MODE(streamer))) { if (duration > 0 && position > 0) { - gdouble buffering_time_limit = (gdouble)(duration - position)/GST_SECOND; + gint buffering_time_limit = (gint)(duration - position)/GST_MSECOND; if (buffer_info.buffering_time > buffering_time_limit) buffer_info.buffering_time = buffering_time_limit; @@ -883,7 +871,7 @@ streaming_update_buffer_setting(mm_player_streaming_t* streamer, streaming_set_buffer_percent(streamer, streamer->streaming_buffer_type, low_percent, buffer_info.percent_byte, buffer_info.percent_time); - LOGD("buffer setting: size %d, time %f, per %f\n", + LOGD("buffer setting: size %d, time %d, per %f\n", GET_CURRENT_BUFFERING_BYTE(buffer_handle), GET_CURRENT_BUFFERING_TIME(buffer_handle), buffer_handle->buffer_high_percent); @@ -894,32 +882,33 @@ streaming_update_buffer_setting(mm_player_streaming_t* streamer, static void streaming_adjust_min_threshold(mm_player_streaming_t* streamer, gint64 position) { -#define DEFAULT_TIME_PAD 1 /* sec */ +#define DEFAULT_TIME_PAD 1000 /* ms */ gint playing_time = 0; MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(streamer); - playing_time = (gint)((position - streamer->default_val.prev_pos) / GST_SECOND); + playing_time = (gint)((position - streamer->default_val.prev_pos) / GST_MSECOND); LOGD("buffering monitor = %s\n", (streamer->default_val.buffering_monitor) ? "ON" : "OFF"); - LOGD("playing_time (%d sec) = %lld - %lld \n", playing_time, position, streamer->default_val.prev_pos); - LOGD("default time : %2.3f, prev buffering t : %2.3f\n", + LOGD("playing_time (%d ms) = %lld - %lld \n", playing_time, position, streamer->default_val.prev_pos); + LOGD("default time : %d, prev buffering t : %d\n", streamer->default_val.buffering_time, streamer->buffer_handle[streamer->streaming_buffer_type].buffering_time); - if ((streamer->default_val.buffering_monitor) && (playing_time <= (gint)streamer->default_val.buffering_time)) { + if ((streamer->default_val.buffering_monitor) && (playing_time <= streamer->default_val.buffering_time)) { gint time_gap = 0; - time_gap = (gint)(streamer->default_val.buffering_time - DEFAULT_BUFFERING_TIME); + time_gap = streamer->default_val.buffering_time - DEFAULT_BUFFERING_TIME; if (time_gap <= 0) time_gap = DEFAULT_TIME_PAD; streamer->default_val.buffering_time += time_gap*2; streamer->default_val.buffering_time = MIN(streamer->default_val.buffering_time, MAX_BUFFERING_TIME); - } else + } else { streamer->default_val.buffering_time = DEFAULT_BUFFERING_TIME; + } - LOGD("new default min value %2.3f \n", streamer->default_val.buffering_time); + LOGD("new default min value %d \n", streamer->default_val.buffering_time); streamer->default_val.buffering_monitor = FALSE; streamer->default_val.prev_pos = position; @@ -929,7 +918,6 @@ static void streaming_update_buffering_status(mm_player_streaming_t* streamer, GstMessage *buffering_msg, gint64 position) { gint buffer_percent = 0; - gboolean increased_per = TRUE; MMPLAYER_FENTER(); @@ -955,8 +943,7 @@ streaming_update_buffering_status(mm_player_streaming_t* streamer, GstMessage *b LOGD("[%s] buffering %d%%....\n", GST_OBJECT_NAME(GST_MESSAGE_SRC(buffering_msg)), buffer_percent); streamer->buffering_percent = buffer_percent; - } else - increased_per = FALSE; + } if ((streamer->buffering_percent == MAX_BUFFER_PERCENT) || (streamer->is_buffering_done == TRUE)) { streamer->is_buffering = FALSE; @@ -965,15 +952,6 @@ streaming_update_buffering_status(mm_player_streaming_t* streamer, GstMessage *b streamer->is_buffering_done = FALSE; else streamer->buffering_percent = MAX_BUFFER_PERCENT; - } else { - /* need to update periodically in case of slink mode */ - if ((increased_per == TRUE) && - (buffer_percent%10 == 0) && - (streamer->buffering_req.mode == MM_PLAYER_BUFFERING_MODE_SLINK) && - (streamer->buffering_req.is_pre_buffering == FALSE)) { - /* Update buffer setting to reflect data receiving rate for slink mode */ - streamer->need_update = TRUE; - } } } @@ -991,7 +969,7 @@ void __mm_player_streaming_buffering(mm_player_streaming_t* streamer, MMPLAYER_RETURN_IF_FAIL((GST_MESSAGE_TYPE(buffering_msg) == GST_MESSAGE_BUFFERING)); if (buffering_msg) { - if (position > (gint64)(streamer->buffering_req.initial_second * GST_SECOND)) + if (position > (gint64)(streamer->buffering_req.prebuffer_time * GST_MSECOND)) streamer->buffering_req.is_pre_buffering = FALSE; streaming_update_buffering_status(streamer, buffering_msg, position); -- 2.7.4