From a47cbd75d3261c55625c2ec30be7e0a6f7fd0e74 Mon Sep 17 00:00:00 2001 From: Eunhye Choi Date: Mon, 15 Jul 2019 20:40:36 +0900 Subject: [PATCH] [ACR-1427] Get the supported input format of external media stream - Add API to get the supported input media format of external media source stream - Add new error code: PLAYER_ERROR_NOT_SUPPORTED_FORMAT - Add error return value of player_set_media_stream_info() PLAYER_ERROR_INVALID_OPERATION : missed error PLAYER_ERROR_NOT_SUPPORTED_FORMAT : newly added error Change-Id: I8c2bd94f8b72fec01c832c2ebce3d5afc41979bf --- include/player.h | 28 +++++++++++++++++++++++++--- src/player.c | 32 ++++++++++++++++++++++++++++++++ test/player_es_push_test.c | 8 ++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/include/player.h b/include/player.h index 9c0e08d..aa0ec21 100644 --- a/include/player.h +++ b/include/player.h @@ -95,6 +95,7 @@ typedef enum { PLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC = PLAYER_ERROR_CLASS | 0x0e, /**< Not supported audio codec but video can be played (Since 4.0) */ PLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC = PLAYER_ERROR_CLASS | 0x0f, /**< Not supported video codec but audio can be played (Since 4.0) */ PLAYER_ERROR_NOT_SUPPORTED_SUBTITLE = PLAYER_ERROR_CLASS | 0x10, /**< Not supported subtitle format (Since 4.0) */ + PLAYER_ERROR_NOT_SUPPORTED_FORMAT = PLAYER_ERROR_CLASS | 0x11, /**< Not supported format (Since 5.5) */ } player_error_e; /** @@ -1168,13 +1169,31 @@ int player_unset_media_packet_audio_frame_decoded_cb(player_h player); int player_push_media_stream(player_h player, media_packet_h packet); /** + * @brief Retrieves all supported media format for playback of external media stream. + * @details The supported media format can vary depending on the device capabilities. + * @since_tizen 5.5 + * @param[in] player The handle to the media player + * @param[in] callback The iteration callback function + * @param[in] user_data The user data to be passed to the callback function + * @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 + * @see player_supported_media_format_cb() + * @see player_set_media_stream_info() + * @see player_push_media_stream() + */ +int player_foreach_media_stream_supported_format(player_h player, player_supported_media_format_cb callback, void *user_data); + +/** * @brief Sets contents information for media stream. * @since_tizen @if WEARABLE 3.0 @else 2.4 @endif * @remarks AV format must be set before pushing elementary stream with player_push_media_stream(). * @remarks This function must be called before calling the player_prepare() or player_prepare_async() * to reflect the media information. - * @remarks AAC can be supported. - * @remarks H.264 can be supported. + * @remarks The supported media format MIME type can be checked + * by calling player_foreach_media_stream_supported_format(). (Since 5.5) * @param[in] player The handle to media player * @param[in] type The type of target stream * @param[in] format The media format to set media information @@ -1183,8 +1202,11 @@ int player_push_media_stream(player_h player, media_packet_h packet); * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FORMAT Not supported format (Since 5.5) * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). - * @see player_push_media_stream() + * @see player_push_media_stream() + * @see player_foreach_media_stream_supported_format() */ int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format); diff --git a/src/player.c b/src/player.c index c1ade03..b7d1e61 100644 --- a/src/player.c +++ b/src/player.c @@ -4506,6 +4506,38 @@ ERROR: return ret; } +int player_foreach_media_stream_supported_format(player_h player, player_supported_media_format_cb callback, void *user_data) +{ + int ret = PLAYER_ERROR_NONE; + player_cli_s *pc = (player_cli_s *)player; + muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_SUPPORTED_FORMAT; + char *ret_buf = NULL; + int format_info[MAX_SUPPORTED_MEDIA_FORMAT] = {0,}; + int len = 0, idx = 0; + + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + + LOGD("ENTER"); + + PLAYER_SEND_MSG(api, pc, ret_buf, ret); + + player_msg_get_type(len, ret_buf, INT); + player_msg_get_array(format_info, ret_buf); + + LOGD("num of format %d", len); + for (idx = 0 ; idx < len ; idx++) { + if (!callback(format_info[idx], user_data)) { + LOGW("stop foreach callback"); + break; + } + } + + LOGD("LEAVE 0x%X", ret); + g_free(ret_buf); + return ret; +} + int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format) { g_return_val_if_fail(format, PLAYER_ERROR_INVALID_OPERATION); diff --git a/test/player_es_push_test.c b/test/player_es_push_test.c index 0c56514..e13c070 100644 --- a/test/player_es_push_test.c +++ b/test/player_es_push_test.c @@ -491,6 +491,12 @@ void _audio_seek_data_cb(unsigned long long offset, void *user_data) LOGE("seek offset of audio is %llu", offset); } +static bool _supported_media_format_cb(media_format_mimetype_e format, void *user_data) +{ + g_print("- supported format mimetype 0x%X\n", format); + return true; +} + static int app_reset(bundle *b, void *data) { /* Take necessary actions when application becomes visible. */ @@ -558,6 +564,8 @@ static int app_reset(bundle *b, void *data) goto FAILED; } + player_foreach_media_stream_supported_format(ad->player_handle, _supported_media_format_cb, ad->player_handle); + /* send media packet to player */ player_set_media_stream_info(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, ad->video_fmt); -- 2.7.4