From 002a265617c1a5e665d45de49b82b1a0f2ac17d9 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Mon, 14 Aug 2017 18:31:56 +0900 Subject: [PATCH] [0.3.67] add internal api to set buffering size Change-Id: I72c9ee2c92cc6b9c7fb58394812edb90e37daccc --- include/player.h | 1 - include/player_internal.h | 36 ++++++++++++++++++++++++++++ packaging/capi-media-player.spec | 2 +- src/player.c | 52 ++++++++++++++++++++++++++++++++++++++++ src/player_display.c | 3 ++- test/player_test.c | 45 ++++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+), 3 deletions(-) diff --git a/include/player.h b/include/player.h index 5ed48e8..5dfcfbb 100644 --- a/include/player.h +++ b/include/player.h @@ -2213,7 +2213,6 @@ int player_set_audio_only(player_h player, bool audio_only); */ int player_is_audio_only(player_h player, bool *audio_only); - /** * @} */ diff --git a/include/player_internal.h b/include/player_internal.h index b3c767d..f4a536d 100644 --- a/include/player_internal.h +++ b/include/player_internal.h @@ -529,6 +529,42 @@ int player_get_media_packet_video_frame_pool_size(player_h player, int *size); int player_enable_media_packet_video_frame_decoded_cb(player_h player, bool enable); /** + * @brief Sets the streaming buffering time + * @since_tizen 4.0 + * @remarks The player state have to be #PLAYER_STATE_IDLE to apply the buffer_ms. + * @param[in] player The handle to the media player + * @param[in] buffer_ms The buffer time to start playback + * @param[in] rebuffer_ms The buffer time during playback if player enter pause state for buffering. + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @if WEARABLE @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature @endif + * @pre The player state must be one of #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_get_streaming_buffering_time() + */ +int player_set_streaming_buffering_time (player_h player, int buffer_ms, int rebuffer_ms); + +/** + * @brief Gets the streaming buffering time + * @since_tizen 4.0 + * @remarks The player state have to be #PLAYER_STATE_IDLE to apply the buffer_ms. + * @param[in] player The handle to the media player + * @param[in] buffer_ms The buffer time to start playback + * @param[in] rebuffer_ms The buffer time during playback if player enter pause state for buffering. + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @if WEARABLE @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature @endif + * @pre The player state must be one of #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_get_streaming_buffering_time() + */ +int player_get_streaming_buffering_time (player_h player, int *buffer_ms, int *rebuffer_ms); + +/** * @} */ diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index 77e1e6d..bf3b820 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -1,6 +1,6 @@ Name: capi-media-player Summary: A Media Player API -Version: 0.3.66 +Version: 0.3.67 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index bb6ad47..e560841 100644 --- a/src/player.c +++ b/src/player.c @@ -4405,3 +4405,55 @@ int player_is_audio_only(player_h player, bool *paudio_only) LOGD("LEAVE 0x%X", ret); return ret; } + +int player_set_streaming_buffering_time(player_h player, int buffer_ms, int rebuffer_ms) +{ + int ret = PLAYER_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); + player_cli_s *pc = (player_cli_s *) player; + muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_BUFFERING_TIME; + char *ret_buf = NULL; + + LOGD("ENTER"); + + player_msg_send2(api, pc, ret_buf, ret, INT, buffer_ms, INT, rebuffer_ms); + g_free(ret_buf); + + LOGD("LEAVE 0x%X", ret); + return ret; + +} + +int player_get_streaming_buffering_time(player_h player, int *buffer_ms, int *rebuffer_ms) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(buffer_ms || rebuffer_ms); + + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_BUFFERING_TIME; + player_cli_s *pc = (player_cli_s *) player; + int buffering_time = 0, rebuffering_time = 0; + char *ret_buf = NULL; + + LOGD("ENTER"); + + player_msg_send(api, pc, ret_buf, ret); + + if (ret == PLAYER_ERROR_NONE) { + bool ret_val = true; + + player_msg_get2(ret_buf, buffering_time, INT, rebuffering_time, INT, ret_val); + if (ret_val) { + if (buffer_ms) *buffer_ms = buffering_time; + if (rebuffer_ms) *rebuffer_ms = rebuffering_time; + } else { + ret = PLAYER_ERROR_INVALID_OPERATION; + } + } + + g_free(ret_buf); + + LOGD("LEAVE 0x%X", ret); + return ret; + +} diff --git a/src/player_display.c b/src/player_display.c index abc6084..e0cb6f9 100644 --- a/src/player_display.c +++ b/src/player_display.c @@ -132,7 +132,7 @@ void _wl_client_finalize(wl_client * wlclient) LOGD("start finalize wlclient"); return_if_fail(wlclient != NULL) - if (wlclient->tz_surface) + if (wlclient->tz_surface) tizen_surface_destroy(wlclient->tz_surface); if (wlclient->tz_resource) @@ -141,5 +141,6 @@ void _wl_client_finalize(wl_client * wlclient) /* destroy registry */ if (wlclient->registry) wl_registry_destroy(wlclient->registry); + return; } diff --git a/test/player_test.c b/test/player_test.c index cdfdc52..6b1ab00 100644 --- a/test/player_test.c +++ b/test/player_test.c @@ -58,6 +58,11 @@ typedef struct { int height; } adaptive_variant_info_t; +typedef struct { + int buffer_ms; + int rebuffer_ms; +} buffer_size_t; + static tizen_profile_t _get_tizen_profile() { char *profileName; @@ -143,6 +148,8 @@ enum { CURRENT_STATUS_SET_MAX_WIDTH_VARIANT, CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT, CURRENT_STATUS_SET_AUDIO_ONLY, + CURRENT_STATUS_SET_PRE_BUFFERING_SIZE, + CURRENT_STATUS_SET_RE_BUFFERING_SIZE, }; typedef struct { @@ -162,6 +169,7 @@ static Evas_Object *g_eo[MAX_HANDLE] = { 0, }; static int g_current_surface_type = -1; static adaptive_variant_info_t max_limit = {-1, -1, -1}; +static buffer_size_t buff_size = {-1, -1}; typedef struct { Evas_Object *win; @@ -1406,6 +1414,22 @@ static void set_variant_limit() player_set_max_adaptive_variant_limit(g_player[0], max_limit.bandwidth, max_limit.width, max_limit.height); } +static void set_buffer_size() +{ + int ret = 0; + int buffer_ms = 0, rebuffer_ms = 0; + + ret = player_get_streaming_buffering_time(g_player[0], &buffer_ms, &rebuffer_ms); + if (ret != PLAYER_ERROR_NONE) + g_print("failed to get buffering time. 0x%X\n", ret); + else + g_print("current buffer size %d ms / %d ms\n", buffer_ms, rebuffer_ms); + + g_print("new buffer size %d ms / %d ms\n", buff_size.buffer_ms, buff_size.rebuffer_ms); + + player_set_streaming_buffering_time(g_player[0], buff_size.buffer_ms, buff_size.rebuffer_ms); +} + static void get_position() { int position = 0; @@ -1992,6 +2016,8 @@ void _interpret_main_menu(char *cmd) get_variant_limit(); } else if (strncmp(cmd, "ao", 2) == 0) { g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY; + } else if (strncmp(cmd, "bf", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE; } else { g_print("unknown menu \n"); } @@ -2055,6 +2081,7 @@ void display_sub_basic() g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t"); g_print("X4. set audio_cb with async \n"); g_print("[video_frame_decoded_cb] ep. enable tbm surface pool\n"); + g_print("[buffering] bf. set new buffering size\n"); g_print("[etc] sp. Set Progressive Download\t"); g_print("gp. Get Progressive Download status\t"); g_print("mp. memory playback\n"); @@ -2128,6 +2155,8 @@ static void displaymenu() g_print("*** set max height (default: -1) \n"); } else if (g_menu_state == CURRENT_STATUS_SET_AUDIO_ONLY) { g_print("*** set audio only mode (0:disable, 1:enable) \n"); + } else if (g_menu_state == CURRENT_STATUS_SET_PRE_BUFFERING_SIZE) { + g_print("*** set pre buffering size (ms) \n"); } else { g_print("*** unknown status.\n"); quit_program(); @@ -2371,6 +2400,22 @@ static void interpret(char *cmd) reset_menu_state(); } break; + case CURRENT_STATUS_SET_PRE_BUFFERING_SIZE: + { + int value = atoi(cmd); + buff_size.buffer_ms = value; + g_menu_state = CURRENT_STATUS_SET_RE_BUFFERING_SIZE; + } + break; + case CURRENT_STATUS_SET_RE_BUFFERING_SIZE: + { + int value = atoi(cmd); + buff_size.rebuffer_ms = value; + set_buffer_size(); + reset_menu_state(); + } + break; + } g_timeout_add(100, timeout_menu_display, 0); -- 2.7.4