From: Eunhae Choi Date: Thu, 11 Jan 2018 07:27:33 +0000 (+0900) Subject: [0.3.81] add considering of audio codec_type X-Git-Tag: submit/tizen_4.0/20180118.070828^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5cee6a8cc7c7178e13ec3b0db2385448ead455e;p=platform%2Fcore%2Fapi%2Fplayer.git [0.3.81] add considering of audio codec_type Change-Id: I4759e7a4e3a28792f5da4bb77b31306cb01594ad (cherry picked from commit e0ff37b7dc109fdc72842ea82692f28ccb3bad99) --- diff --git a/include/player.h b/include/player.h index 2b897c6..216cbd6 100644 --- a/include/player.h +++ b/include/player.h @@ -604,7 +604,7 @@ int player_set_memory_buffer(player_h player, const void * data, int size); * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @see #player_state_e */ -int player_get_state(player_h player, player_state_e *state); +int player_get_state(player_h player, player_state_e *state); /** * @brief Sets the player's volume. diff --git a/include/player_internal.h b/include/player_internal.h index 87273b8..70ed9ed 100644 --- a/include/player_internal.h +++ b/include/player_internal.h @@ -39,13 +39,22 @@ typedef enum { * @brief Enumeration for video codec type. * @since_tizen 4.0 */ -typedef enum -{ +typedef enum { PLAYER_VIDEO_CODEC_TYPE_DEFAULT = 0, /**< This is an optional flag for using codec which has higher priority */ PLAYER_VIDEO_CODEC_TYPE_HW, /**< This is an optional flag for using the h/w codec */ PLAYER_VIDEO_CODEC_TYPE_SW, /**< This is an optional flag for using the s/w codec */ } player_video_codec_type_e; +/** + * @brief Enumeration for codec type. + * @since_tizen 4.0 + */ +typedef enum { + PLAYER_CODEC_TYPE_DEFAULT = 0, /**< This is an optional flag for using codec which has higher priority */ + PLAYER_CODEC_TYPE_HW, /**< This is an optional flag for using the h/w codec */ + PLAYER_CODEC_TYPE_SW, /**< This is an optional flag for using the s/w codec */ +} player_codec_type_e; + /** * @brief This file contains the media player API for custom features. * @since_tizen 2.4 @@ -737,6 +746,43 @@ int player_set_video_codec_type(player_h player, player_video_codec_type_e type) */ int player_get_video_codec_type(player_h player, player_video_codec_type_e *ptype); +/** + * @brief Set audio/video codec type as h/w codec or s/w codec. + * @since_tizen 4.0 + * @details The default codec type of the player is #PLAYER_CODEC_TYPE_DEFAULT. + * Usually the H/W codec has higher priority than S/W codec if it exist. + * @param[in] player The handle to the media player + * @param[in] stream_type The stream type and it have to be #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_VIDEO. + * @param[in] codec_type The codec type + * @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_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @see player_get_codec_type() + */ +int player_set_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e codec_type); + +/** + * @brief Get video codec type. + * @since_tizen 4.0 + * @param[in] player The handle to the media player + * @param[in] stream_type The stream type and it have to be #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_VIDEO. + * @param[out] pcodec_type The codec type + * @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_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_set_codec_type() + */ +int player_get_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e *pcodec_type); + + /** * @} */ diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index e0a002e..ba2cd2b 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.80 +Version: 0.3.81 Release: 0 Group: Multimedia/API License: Apache-2.0 @@ -45,12 +45,12 @@ Requires: %{name} = %{version}-%{release} %devel_desc %package display -Summary: A display interface library for Media Player libray +Summary: A display interface library for Media Player library Group: Display/Multimedia Requires: %{name} = %{version}-%{release} %description display -A display interface library for Media Player libray +A display interface library for Media Player library %package utils Summary: A test app for Media Player API diff --git a/src/player_internal.c b/src/player_internal.c index 0775770..60ec957 100644 --- a/src/player_internal.c +++ b/src/player_internal.c @@ -382,41 +382,87 @@ int player_enable_media_packet_video_frame_decoded_cb(player_h player, bool enab return ret; } -int player_set_video_codec_type(player_h player, player_video_codec_type_e type) +int player_set_video_codec_type(player_h player, player_video_codec_type_e codec_type) { PLAYER_INSTANCE_CHECK(player); int ret = PLAYER_ERROR_NONE; - muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_CODEC_TYPE; - player_cli_s *pc = (player_cli_s *)player; + muse_player_api_e api = MUSE_PLAYER_API_SET_CODEC_TYPE; + player_cli_s *pc = (player_cli_s *) player; char *ret_buf = NULL; + int stream_type = PLAYER_STREAM_TYPE_VIDEO; - LOGD("ENTER %d", type); + LOGD("ENTER %d", codec_type); - player_msg_send1(api, pc, ret_buf, ret, INT, type); + player_msg_send2(api, pc, ret_buf, ret, INT, stream_type, INT, codec_type); g_free(ret_buf); LOGD("LEAVE"); return ret; } -int player_get_video_codec_type(player_h player, player_video_codec_type_e *ptype) +int player_get_video_codec_type(player_h player, player_video_codec_type_e *pcodec_type) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(ptype); + PLAYER_NULL_ARG_CHECK(pcodec_type); int ret = PLAYER_ERROR_NONE; - muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_CODEC_TYPE; + muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_TYPE; player_cli_s *pc = (player_cli_s *) player; char *ret_buf = NULL; - int type = 0; + int stream_type = PLAYER_STREAM_TYPE_VIDEO; + int codec_type = 0; LOGD("ENTER"); - player_msg_send(api, pc, ret_buf, ret); + player_msg_send1(api, pc, ret_buf, ret, INT, stream_type); + if (ret == PLAYER_ERROR_NONE) { + player_msg_get(codec_type, ret_buf); + *pcodec_type = codec_type; + } + + g_free(ret_buf); + LOGD("LEAVE"); + return ret; +} + +int player_set_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e codec_type) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); + + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_SET_CODEC_TYPE; + player_cli_s *pc = (player_cli_s *) player; + char *ret_buf = NULL; + + LOGD("ENTER stream: %d, codec: %d", stream_type, codec_type); + + player_msg_send2(api, pc, ret_buf, ret, INT, stream_type, INT, codec_type); + + g_free(ret_buf); + LOGD("LEAVE"); + return ret; +} + +int player_get_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e *pcodec_type) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(pcodec_type); + PLAYER_CHECK_CONDITION(stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); + + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_TYPE; + player_cli_s *pc = (player_cli_s *) player; + char *ret_buf = NULL; + int codec_type = 0; + + LOGD("ENTER stream_type: %d", stream_type); + + player_msg_send1(api, pc, ret_buf, ret, INT, stream_type); if (ret == PLAYER_ERROR_NONE) { - player_msg_get(type, ret_buf); - *ptype = type; + player_msg_get(codec_type, ret_buf); + *pcodec_type = codec_type; } g_free(ret_buf); diff --git a/test/player_test.c b/test/player_test.c index b0dca60..10e9aae 100644 --- a/test/player_test.c +++ b/test/player_test.c @@ -166,13 +166,14 @@ enum { CURRENT_STATUS_SET_AUDIO_ONLY, CURRENT_STATUS_SET_PRE_BUFFERING_SIZE, CURRENT_STATUS_SET_RE_BUFFERING_SIZE, - CURRENT_STATUS_VIDEO_CODEC_TYPE, CURRENT_STATUS_VIDEO360_SET_ENABLE, CURRENT_STATUS_VIDEO360_SET_DOV, CURRENT_STATUS_VIDEO360_SET_DOV1, CURRENT_STATUS_VIDEO360_SET_FOV, CURRENT_STATUS_VIDEO360_SET_FOV1, CURRENT_STATUS_VIDEO360_SET_ZOOM, + CURRENT_STATUS_AUDIO_CODEC_TYPE, + CURRENT_STATUS_VIDEO_CODEC_TYPE, }; typedef struct { @@ -180,6 +181,11 @@ typedef struct { bool accurate; } player_seek_pos_t; +typedef struct { + int a_codec_type; + int v_codec_type; +} player_codec_type_t; + #define MAX_HANDLE 20 /* for video display */ @@ -206,6 +212,7 @@ typedef struct { static appdata ad; static player_h g_player[MAX_HANDLE] = { 0, }; static player_seek_pos_t seek_info = {0}; +static player_codec_type_t codec_type = {0}; int g_handle_num = 1; int g_menu_state = CURRENT_STATUS_MAINMENU; gboolean quit_pushing; @@ -1516,22 +1523,28 @@ static void get_duration() g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration); } -static void set_video_codec_type(int type) +static void set_codec_type(void) { int ret; - if (type < PLAYER_VIDEO_CODEC_TYPE_DEFAULT || type > PLAYER_VIDEO_CODEC_TYPE_SW) - type = PLAYER_VIDEO_CODEC_TYPE_DEFAULT; - ret = player_set_video_codec_type(g_player[0], type); - g_print(" ==> [Player_Test] player_set_video_codec_type(%d) return: %d\n", type, ret); + + ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, codec_type.a_codec_type); + g_print(" ==> [Player_Test] audio codec type (%d) return: %d\n", codec_type.a_codec_type, ret); + + ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, codec_type.v_codec_type); + g_print(" ==> [Player_Test] video codec type (%d) return: %d\n", codec_type.v_codec_type, ret); + } -static void get_video_codec_type() +static void get_codec_type(void) { - player_video_codec_type_e type = 0; int ret; - ret = player_get_video_codec_type(g_player[0], &type); - g_print(" ==> [Player_Test] player_get_video_codec_type() return : %d\n", ret); - g_print(" ==> [Player_Test] Codec type: [%d]\n", type); + player_codec_type_e atype = 0, vtype = 0; + + ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, &atype); + g_print(" ==> [Player_Test] Audio Codec type: [%d][ret 0x%X]\n", atype, ret); + + ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, &vtype); + g_print(" ==> [Player_Test] Video Codec type: [%d][ret 0x%X]\n", vtype, ret); } static void audio_frame_decoded_cb_ex(bool sync) @@ -2225,9 +2238,9 @@ void _interpret_main_menu(char *cmd) } else if (strncmp(cmd, "bf", 2) == 0) { g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE; } else if (strncmp(cmd, "C1", 2) == 0) { - g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE; + g_menu_state = CURRENT_STATUS_AUDIO_CODEC_TYPE; } else if (strncmp(cmd, "C2", 2) == 0) { - get_video_codec_type(); + get_codec_type(); } else { g_print("unknown menu \n"); } @@ -2399,8 +2412,6 @@ static void displaymenu() g_print("*** set pre buffering size (ms) \n"); } else if (g_menu_state == CURRENT_STATUS_SET_RE_BUFFERING_SIZE) { g_print("*** set re buffering size (ms) \n"); - } else if (g_menu_state == CURRENT_STATUS_VIDEO_CODEC_TYPE) { - g_print("*** set video codec type (1: HW, 2: SW) \n"); } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ENABLE) { g_print("*** input video 360 status (0: disabled (full panorama), 1: enabled)\n"); } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV) { @@ -2413,6 +2424,10 @@ static void displaymenu() g_print("*** input vertical field of view angle (1~180 deg.)\n"); } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM) { g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n"); + } else if (g_menu_state == CURRENT_STATUS_AUDIO_CODEC_TYPE) { + g_print("*** set audio codec type (1: HW, 2: SW) \n"); + } else if (g_menu_state == CURRENT_STATUS_VIDEO_CODEC_TYPE) { + g_print("*** set video codec type (1: HW, 2: SW) \n"); } else { g_print("*** unknown status.\n"); quit_program(); @@ -2673,13 +2688,6 @@ static void interpret(char *cmd) reset_menu_state(); } break; - case CURRENT_STATUS_VIDEO_CODEC_TYPE: - { - int value = atoi(cmd); - set_video_codec_type(value); - reset_menu_state(); - } - break; case CURRENT_STATUS_VIDEO360_SET_ENABLE: { int enable = atoi(cmd); @@ -2720,7 +2728,21 @@ static void interpret(char *cmd) reset_menu_state(); } break; - + case CURRENT_STATUS_AUDIO_CODEC_TYPE: + { + int value = atoi(cmd); + codec_type.a_codec_type = value; + g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE; + } + break; + case CURRENT_STATUS_VIDEO_CODEC_TYPE: + { + int value = atoi(cmd); + codec_type.v_codec_type = value; + set_codec_type(); + reset_menu_state(); + } + break; } g_timeout_add(100, timeout_menu_display, 0);