From: Eunhae Choi Date: Thu, 6 Jul 2017 10:00:57 +0000 (+0900) Subject: [0.3.64] add APIs to control the adaptive streaming variant X-Git-Tag: submit/tizen/20170707.065345^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d72b85478de0fad622be5d0d896255bd0f718517;p=platform%2Fcore%2Fapi%2Fplayer.git [0.3.64] add APIs to control the adaptive streaming variant - add API to retrieve the streaming variant info - add APIs to set/get max limit - add new test scenario Change-Id: I4c0b625468f81759f64013baa7a62383951fb845 --- diff --git a/include/player_private.h b/include/player_private.h index 01b2f28..04602f6 100644 --- a/include/player_private.h +++ b/include/player_private.h @@ -45,7 +45,7 @@ do { \ PLAYER_CHECK_CONDITION(player->state == expected_state, PLAYER_ERROR_INVALID_STATE, "PLAYER_ERROR_INVALID_STATE") #define PLAYER_NULL_ARG_CHECK(arg) \ - PLAYER_CHECK_CONDITION(arg != NULL, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") + PLAYER_CHECK_CONDITION((arg), PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") #define CONNECTION_RETRY 51 #define CONNECTION_TIME_OUT 50 /* ms */ diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index c1712e5..001b17a 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.63 +Version: 0.3.64 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index cbb7d03..fae750f 100644 --- a/src/player.c +++ b/src/player.c @@ -2120,8 +2120,7 @@ int player_set_volume(player_h player, float left, float right) int player_get_volume(player_h player, float *pleft, float *pright) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(pleft); - PLAYER_NULL_ARG_CHECK(pright); + PLAYER_NULL_ARG_CHECK(pleft && pright); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME; player_cli_s *pc = (player_cli_s *) player; @@ -2968,8 +2967,7 @@ int player_get_content_info(player_h player, player_content_info_e key, char **p int player_get_codec_info(player_h player, char **paudio_codec, char **pvideo_codec) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(paudio_codec); - PLAYER_NULL_ARG_CHECK(pvideo_codec); + PLAYER_NULL_ARG_CHECK(paudio_codec && pvideo_codec); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO; player_cli_s *pc = (player_cli_s *) player; @@ -2997,9 +2995,7 @@ int player_get_codec_info(player_h player, char **paudio_codec, char **pvideo_co int player_get_audio_stream_info(player_h player, int *psample_rate, int *pchannel, int *pbit_rate) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(psample_rate); - PLAYER_NULL_ARG_CHECK(pchannel); - PLAYER_NULL_ARG_CHECK(pbit_rate); + PLAYER_NULL_ARG_CHECK(psample_rate && pchannel && pbit_rate); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO; player_cli_s *pc = (player_cli_s *) player; @@ -3029,8 +3025,7 @@ int player_get_audio_stream_info(player_h player, int *psample_rate, int *pchann int player_get_video_stream_info(player_h player, int *pfps, int *pbit_rate) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(pfps); - PLAYER_NULL_ARG_CHECK(pbit_rate); + PLAYER_NULL_ARG_CHECK(pfps && pbit_rate); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO; player_cli_s *pc = (player_cli_s *) player; @@ -3058,8 +3053,7 @@ int player_get_video_stream_info(player_h player, int *pfps, int *pbit_rate) int player_get_video_size(player_h player, int *pwidth, int *pheight) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(pwidth); - PLAYER_NULL_ARG_CHECK(pheight); + PLAYER_NULL_ARG_CHECK(pwidth && pheight); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE; player_cli_s *pc = (player_cli_s *) player; @@ -3087,8 +3081,7 @@ int player_get_video_size(player_h player, int *pwidth, int *pheight) int player_get_album_art(player_h player, void **palbum_art, int *psize) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(palbum_art); - PLAYER_NULL_ARG_CHECK(psize); + PLAYER_NULL_ARG_CHECK(palbum_art && psize); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART; player_cli_s *pc = (player_cli_s *) player; @@ -3260,8 +3253,7 @@ int player_audio_effect_get_equalizer_band_level(player_h player, int index, int int player_audio_effect_get_equalizer_level_range(player_h player, int *pmin, int *pmax) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(pmin); - PLAYER_NULL_ARG_CHECK(pmax); + PLAYER_NULL_ARG_CHECK(pmin && pmax); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE; player_cli_s *pc = (player_cli_s *) player; @@ -3425,8 +3417,7 @@ int player_set_progressive_download_path(player_h player, const char *path) int player_get_progressive_download_status(player_h player, unsigned long *pcurrent, unsigned long *ptotal_size) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(pcurrent); - PLAYER_NULL_ARG_CHECK(ptotal_size); + PLAYER_NULL_ARG_CHECK(pcurrent && ptotal_size); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS; player_cli_s *pc = (player_cli_s *) player; @@ -3517,8 +3508,7 @@ int player_set_streaming_user_agent(player_h player, const char *user_agent, int int player_get_streaming_download_progress(player_h player, int *pstart, int *pcurrent) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(pstart); - PLAYER_NULL_ARG_CHECK(pcurrent); + PLAYER_NULL_ARG_CHECK(pstart && pcurrent); int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS; player_cli_s *pc = (player_cli_s *) player; @@ -4184,3 +4174,101 @@ int player_get_track_language_code(player_h player, player_stream_type_e type, i g_free(ret_buf); return ret; } + +int player_foreach_adaptive_variant(player_h player, player_adaptive_variant_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + int ret = PLAYER_ERROR_NONE; + player_cli_s *pc = (player_cli_s *) player; + muse_player_api_e api = MUSE_PLAYER_API_GET_ADAPTIVE_VARIANT_INFO; + char *ret_buf = NULL; + char var_info[MUSE_MSG_MAX_LENGTH] = { 0, }; + int idx = 0, num = 0; + int bandwidth = 0, width = 0, height = 0; + char *token = NULL; + char *ptr = NULL; + + LOGD("ENTER"); + + player_msg_send(api, pc, ret_buf, ret); + if (ret == PLAYER_ERROR_NONE) { + player_msg_get_type(num, ret_buf, INT); + if (num > 0) + player_msg_get_string(var_info, ret_buf); + else + LOGW("There is no stream variant info."); + } + + for (idx = 0 ; idx < num ; idx++) { + bandwidth = width = height = 0; + + token = strtok_r((ptr != NULL) ? (NULL) : (var_info), ",", &ptr); + if (!token) break; + bandwidth = atoi(token); + + token = strtok_r(NULL, ",", &ptr); + if (!token) break; + width = atoi(token); + + token = strtok_r(NULL, ",", &ptr); + if (!token) break; + height = atoi(token); + + callback(bandwidth, width, height, user_data); + } + + LOGD("LEAVE 0x%X", ret); + g_free(ret_buf); + return ret; +} + +int player_set_max_adaptive_variant_limit(player_h player, int bandwidth, int width, int height) +{ + 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_MAX_ADAPTIVE_VARIANT_LIMIT; + char *ret_buf = NULL; + + LOGD("ENTER"); + + player_msg_send3(api, pc, ret_buf, ret, INT, bandwidth, INT, width, INT, height); + g_free(ret_buf); + + LOGD("LEAVE 0x%X", ret); + return ret; + +} + +int player_get_max_adaptive_variant_limit(player_h player, int *pbandwidth, int *pwidth, int *pheight) +{ + int ret = PLAYER_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(pbandwidth && pwidth && pheight); + + player_cli_s *pc = (player_cli_s *) player; + muse_player_api_e api = MUSE_PLAYER_API_GET_MAX_ADAPTIVE_VARIANT_LIMIT; + char *ret_buf = NULL; + int bandwidth = -1, width = -1, height = -1; + + LOGD("ENTER"); + + player_msg_send(api, pc, ret_buf, ret); + if (ret == PLAYER_ERROR_NONE) { + bool ret_val = TRUE; + + player_msg_get3(ret_buf, bandwidth, INT, width, INT, height, INT, ret_val); + if (ret_val) { + *pbandwidth = bandwidth; + *pwidth = width; + *pheight = height; + } else { + ret = PLAYER_ERROR_INVALID_OPERATION; + } + } + g_free(ret_buf); + + LOGD("LEAVE 0x%X", ret); + return ret; +} diff --git a/test/player_test.c b/test/player_test.c index 4bdb652..3c6f451 100644 --- a/test/player_test.c +++ b/test/player_test.c @@ -51,6 +51,13 @@ typedef enum { TIZEN_PROFILE_IVI = 0x8, TIZEN_PROFILE_COMMON = 0x10, } tizen_profile_t; + +typedef struct { + int bandwidth; + int width; + int height; +} adaptive_variant_info_t; + static tizen_profile_t _get_tizen_profile() { char *profileName; @@ -132,6 +139,9 @@ enum { CURRENT_STATUS_GAPLESS, CURRENT_STATUS_GET_TRACK_INFO, CURRENT_STATUS_POSITION_ACCURATE, + CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT, + CURRENT_STATUS_SET_MAX_WIDTH_VARIANT, + CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT, }; typedef struct { @@ -150,6 +160,7 @@ static Evas_Object *selected_win_id; 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}; typedef struct { Evas_Object *win; @@ -1371,6 +1382,29 @@ static void set_sound_stream_info(int type) return; } +void variant_cb(int bandwidth, int width, int height, void *user_data) +{ + g_print(" ==> [Player_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height); +} + +static void get_variant_info() +{ + player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]); +} + +static void get_variant_limit() +{ + int bandwidth, width, height; + player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height); + g_print(" ==> [Player_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height); +} + +static void set_variant_limit() +{ + g_print(" ==> [Player_Test]set [b]%d, [w]%d, [h]%d\n", max_limit.bandwidth, max_limit.width, max_limit.height); + player_set_max_adaptive_variant_limit(g_player[0], max_limit.bandwidth, max_limit.width, max_limit.height); +} + static void get_position() { int position = 0; @@ -1931,6 +1965,12 @@ void _interpret_main_menu(char *cmd) g_menu_state = CURRENT_STATUS_GAPLESS; } else if (strncmp(cmd, "tl", 2) == 0) { g_menu_state = CURRENT_STATUS_GET_TRACK_INFO; + } else if (strncmp(cmd, "vi", 2) == 0) { + get_variant_info(); + } else if (strncmp(cmd, "vs", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT; + } else if (strncmp(cmd, "vg", 2) == 0) { + get_variant_limit(); } else { g_print("unknown menu \n"); } @@ -1981,6 +2021,9 @@ void display_sub_basic() g_print("s. Get display mode\n"); g_print("[overlay display] t. Set display Rotation\n"); g_print("[Track] tl. Get Track language info(single only)\n"); + g_print("[Variant] vi. Get Streaming Variant Info\t"); + g_print("vs. Set max limit of variant\t"); + g_print("vg. Get max limit of variant\n"); g_print("[subtitle] A. Set(or change) subtitle path\n"); g_print("[subtitle] ss. Select(or change) subtitle track\n"); g_print("[Video Capture] C. Capture \n"); @@ -2055,6 +2098,12 @@ static void displaymenu() g_print("*** input gapless value.(0:disable, 1: enable) \n"); } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) { g_print("*** input stream type.(1:audio, 3:text) \n"); + } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) { + g_print("*** set max bandwidth (default: -1) \n"); + } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) { + g_print("*** set max width (default: -1) \n"); + } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) { + g_print("*** set max height (default: -1) \n"); } else { g_print("*** unknown status.\n"); quit_program(); @@ -2269,6 +2318,28 @@ static void interpret(char *cmd) reset_menu_state(); } break; + case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT: + { + int value = atoi(cmd); + max_limit.bandwidth = value; + g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT; + } + break; + case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT: + { + int value = atoi(cmd); + max_limit.width = value; + g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT; + } + break; + case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT: + { + int value = atoi(cmd); + max_limit.height = value; + set_variant_limit(); + reset_menu_state(); + } + break; } g_timeout_add(100, timeout_menu_display, 0);