From: Hyunil Park Date: Tue, 2 Jun 2015 08:44:42 +0000 (+0900) Subject: 1. Sync 2.4 code to 3.0 X-Git-Tag: accepted/tizen/3.0.2015.q2/common/20150615.091756^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=554b1f03da28a7d514d6bd60c6250f601b74388c;p=platform%2Fcore%2Fapi%2Fplayer.git 1. Sync 2.4 code to 3.0 2. Apply tbm_surface_internal_create_with_bos() Change-Id: I37ca80284fd0ae4f550d40c059dcd97e2c4507dd Signed-off-by: Hyunil Park --- diff --git a/CMakeLists.txt b/CMakeLists.txt index db2bb42..432b30b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,19 @@ PROJECT(${fw_name}) SET(CMAKE_INSTALL_PREFIX /usr) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(INC_DIR include) -INCLUDE_DIRECTORIES(${INC_DIR}) +IF (TIZEN_WEARABLE) +SET(INC_DIR include/wearable) +ENDIF (TIZEN_WEARABLE) -SET(dependents "libtbm capi-media-tool dlog mm-player capi-base-common capi-media-sound-manager gstreamer-1.0 evas ecore elementary") +IF (TIZEN_MOBILE) +SET(INC_DIR include/mobile) +ENDIF (TIZEN_MOBILE) + +SET(INC_COM_DIR include) + +INCLUDE_DIRECTORIES(${INC_DIR}, ${INC_COM_DIR}) + +SET(dependents "libtbm capi-media-tool dlog mm-player capi-base-common capi-media-sound-manager gstreamer-1.0 evas ecore elementary capi-system-info") SET(pc_dependents "libtbm capi-media-tool capi-base-common capi-media-sound-manager") INCLUDE(FindPkgConfig) @@ -19,7 +28,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "-I./include ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Wno-error=unused-but-set-variable -DGST_EXT_TIME_ANALYSIS") +SET(CMAKE_C_FLAGS "-I./${INC_DIR} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Wno-error=unused-but-set-variable -DGST_EXT_TIME_ANALYSIS") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") @@ -36,9 +45,15 @@ ENDIF(X11_SUPPORT) ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DTIZEN_DEBUG") +IF (TIZEN_MOBILE) +ADD_DEFINITIONS("-DTIZEN_MOBILE") +ENDIF(TIZEN_MOBILE) + SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") -aux_source_directory(src SOURCES) +#aux_source_directory(src SOURCES) +SET(SOURCES src/player.c src/player_internal.c) + ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) diff --git a/include/player.h b/include/mobile/player.h old mode 100644 new mode 100755 similarity index 76% rename from include/player.h rename to include/mobile/player.h index a65d3ad..e49a84e --- a/include/player.h +++ b/include/mobile/player.h @@ -17,10 +17,6 @@ #ifndef __TIZEN_MEDIA_PLAYER_H__ #define __TIZEN_MEDIA_PLAYER_H__ -#ifndef DEPRECATED -#define DEPRECATED __attribute__((deprecated)) -#endif - #include #include #include @@ -137,6 +133,28 @@ typedef enum } audio_latency_mode_e; /** + * @brief Enumeration for stream type. + * @since_tizen 2.4 + */ +typedef enum +{ + PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */ + PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */ + PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */ + PLAYER_STREAM_TYPE_TEXT, /**< Text type */ +} player_stream_type_e; + +/** + * @brief Enumeration of media stream buffer status + * @since_tizen 2.4 + */ +typedef enum +{ + PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, + PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW, +} player_media_stream_buffer_status_e; + +/** * @brief The player display handle. * @since_tizen 2.3 */ @@ -147,8 +165,7 @@ typedef void* player_display_h; * @brief Definition for a display handle from evas object. * @since_tizen 2.3 */ -#include -#define GET_DISPLAY(x) ((void*)((intptr_t)(x))) //solve cast pointer error for x86_64 +#define GET_DISPLAY(x) (void*)(x) #endif /** @@ -265,8 +282,7 @@ typedef void (*player_completed_cb)(void *user_data); * @brief Called when the seek operation is completed. * @since_tizen 2.3 * @param[in] user_data The user data passed from the callback registration function - * @see player_set_position() - * @see player_set_position_ratio() + * @see player_set_play_position() */ typedef void (*player_seek_completed_cb)(void *user_data); @@ -338,6 +354,57 @@ typedef void (*player_video_captured_cb)(unsigned char *data, int width, int hei typedef void (*player_media_packet_video_decoded_cb)(media_packet_h pkt, void *user_data); /** + * @brief Called when the buffer level drops below the threshold of max size or no free space in buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_media_stream_buffer_status_cb() + * @see player_set_media_stream_buffer_max_size() + * @see player_set_media_stream_buffer_min_threshold() + */ +typedef void (*player_media_stream_buffer_status_cb) (player_media_stream_buffer_status_e status, void *user_data); + +/** + * @brief Called to notify the next push-buffer offset when seeking is occurred. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @details The next push-buffer should produce buffers from the new offset. + * @param[in] offset The new byte position to seek + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void (*player_media_stream_seek_cb) (unsigned long long offset, void *user_data); + +/** + * @brief Called to notify the video stream changed. + * @since_tizen 2.4 + * @details The video stream changing is detected just before rendering operation. + * @param[in] width The width of the captured image + * @param[in] height The height of the captured image + * @param[in] fps The frame per second of the video \n + It can be @c 0 if there is no video stream information. + * @param[in] bit_rate The video bit rate [Hz] \n + * It can be an invalid value if there is no video stream information. + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_video_stream_changed_cb() + */ +typedef void (*player_video_stream_changed_cb) (int width, int height, int fps, int bit_rate, void *user_data); + +/** + * @brief Called to notify the audio stream changed. + * @since_tizen 2.4 + * @details The audio stream changing is detected just before rendering operation. + * @param[in] sample_rate The audio sample rate [Hz] \n + * Value can be invalid if there is no audio stream information. + * @param[in] channel The audio channel (1: mono, 2: stereo) \n + * Value can be invalid if there is no audio stream information. + * @param[in] bit_rate The audio bit rate [Hz] \n + * Value can be invalid if there is no audio stream information. + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_audio_stream_changed_cb() + */ +typedef void (*player_audio_stream_changed_cb) (int sample_rate, int channel, int bit_rate, void *user_data); + +/** * @brief Creates a player handle for playing multimedia content. * @since_tizen 2.3 * @remarks You must release @a player by using player_destroy().\n @@ -402,7 +469,7 @@ int player_prepare(player_h player); * @remarks The mediastorage privilege(http://tizen.org/privilege/mediastorage) should be added if any video/audio files are used to play located in the internal storage. * @remarks The externalstorage privilege(http://tizen.org/privilege/externalstorage) should be added if any video/audio files are used to play located in the external storage. * @remarks The internet privilege(http://tizen.org/privilege/internet) should be added if any URLs are used to play from network. - * @param[in] player The handle to the media player + * @param[in] player The handle to the media player * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function * @return @c 0 on success, @@ -778,6 +845,8 @@ int player_is_looping(player_h player, bool *looping); * @since_tizen 2.3 * @remarks To get @a display to set, use #GET_DISPLAY(). * @remarks To use the multiple surface display mode, use player_set_display() again with a different display type. + * @remarks We are not supporting changing display between different types. \n + * If you want to change display handle after calling player_prepare(), you must use the same display type as what you set before. * @param[in] player The handle to the media player * @param[in] type The display type * @param[in] display The handle to display @@ -793,6 +862,240 @@ int player_is_looping(player_h player, bool *looping); int player_set_display(player_h player, player_display_type_e type, player_display_h display); /** + * @brief Registers a media packet video callback function to be called once per frame. + * @since_tizen 2.3 + * @remarks This function should be called before preparing. \n + * A registered callback is called on the internal thread of the player. \n + * A video frame can be retrieved using a registered callback as a media packet.\n + * The callback function holds the same buffer that will be drawn on the display device.\n + * So if you change the media packet in a registerd callback, it will be displayed on the device\n + * and the media packet is available until it's destroyed by media_packet_destroy(). + * @param[in] player The handle to the media player + * @param[in] callback The callback function to be registered + * @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_STATE Invalid state + * @pre The player's state should be #PLAYER_STATE_IDLE. And, #PLAYER_DISPLAY_TYPE_NONE should be set by calling player_set_display. + * @see player_unset_media_packet_video_frame_decoded_cb + */ +int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @param[in] player The handle to the media player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player's state should be #PLAYER_STATE_READY or #PLAYER_STATE_IDLE + * @see player_set_media_packet_video_frame_decoded_cb() + */ +int player_unset_media_packet_video_frame_decoded_cb(player_h player); + +/** + * @brief Pushes elementary stream to decode audio or video + * @since_tizen 2.4 + * @param[in] player The handle to media player + * @param[in] packet The media packet to decode + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE File not supported + * @pre The player state must be set to #PLAYER_STATE_IDLE at least. + * @see player_set_media_stream_info() + */ +int player_push_media_stream(player_h player, media_packet_h packet); + +/** + * @brief Sets contents information for media stream + * @since_tizen 2.4 + * @remarks AV format should be set before pushing elementary stream with player_push_media_stream(). + * @remarks AAC can be supported. + * @remarks H.264 can be supported. + * @remarks This API should be called before calling the player_prepare() or player_prepare_async() \n + to reflect the media information when pipeline is created. + * @param[in] player The handle to media player + * @param[in] type The type of target stream + * @param[in] format The media format to set audio information + * @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 + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_push_media_stream() + */ +int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format); + +/** + * @brief Pushes elementary stream to decode audio or video + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to media player + * @param[in] packet The media packet to decode + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE File not supported + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_media_stream_info() + */ +int player_push_media_stream(player_h player, media_packet_h packet); + +/** + * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] callback The buffer status callback function to register + * @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_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_media_stream_buffer_status_cb() will be invoked. + * @see player_unset_media_stream_buffer_status_cb() + * @see player_media_stream_buffer_status_cb() + */ +int player_set_media_stream_buffer_status_cb(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb callback, void *user_data); + +/** + * @brief Unregisters the buffer status callback function. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_media_stream_buffer_status_cb() + */ +int player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e type); + +/** + * @brief Registers a callback function to be invoked when seeking is occurred. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] callback The callback function to register + * @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_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_media_stream_seek_cb() will be invoked. + * @see player_unset_media_stream_seek_cb() + * @see player_media_stream_seek_cb() + */ +int player_set_media_stream_seek_cb(player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data); + +/** + * @brief Unregisters the seek callback function. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_media_stream_seek_cb() + */ +int player_unset_media_stream_seek_cb(player_h player, player_stream_type_e type); + +/** + * @brief Sets the max size bytes of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level over the max size, player_media_stream_buffer_status_cb() will be invoked with overflow status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] max_size The max bytes of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_get_media_stream_buffer_max_size() + * @see player_media_stream_buffer_status_cb() + */ +int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size); + +/** + * @brief Gets the max size bytes of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level over the max size, player_media_stream_buffer_status_cb() will be invoked with overflow status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] max_size The max bytes of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_media_stream_buffer_max_size() + * @see player_media_stream_buffer_status_cb() + */ +int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *max_size); + +/** + * @brief Sets the buffer threshold percent of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level drops below the percent value, player_media_stream_buffer_status_cb() will be invoked with underrun status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] percent The minimum threshold(0~100) of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_get_media_stream_buffer_min_threshold() + * @see player_media_stream_buffer_status_cb() + */ +int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent); + +/** + * @brief Gets the buffer threshold percent of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level drops below the percent value, player_media_stream_buffer_status_cb() will be invoked with underrun status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] percent The minimum threshold(0~100) of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_media_stream_buffer_min_threshold() + * @see player_media_stream_buffer_status_cb() + */ +int player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *percent); + +/** * @} */ @@ -870,7 +1173,6 @@ int player_is_display_visible(player_h player, bool* visible); * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_STATE Invalid state * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature - * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE In case of using evasimagesink by PLAYER_DISPLAY_TYPE_EVAS * @see player_set_display * @see player_get_display_rotation() */ @@ -915,7 +1217,7 @@ int player_get_display_rotation( player_h player, player_display_rotation_e *rot * @retval #PLAYER_ERROR_OUT_OF_MEMORY Not enough memory is available * @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_PLAYING or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. */ int player_get_content_info(player_h player, player_content_info_e key, char ** value); @@ -935,7 +1237,7 @@ int player_get_content_info(player_h player, player_content_info_e key, char ** * @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_PLAYING or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. */ int player_get_codec_info(player_h player, char **audio_codec, char **video_codec); @@ -956,7 +1258,7 @@ int player_get_codec_info(player_h player, char **audio_codec, char **video_code * @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_PLAYING or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. */ int player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate); @@ -975,7 +1277,7 @@ int player_get_audio_stream_info(player_h player, int *sample_rate, int *channel * @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_PLAYING or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. */ int player_get_video_stream_info(player_h player, int *fps, int *bit_rate); @@ -994,7 +1296,7 @@ int player_get_video_stream_info(player_h player, int *fps, int *bit_rate); * @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_PLAYING or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. */ int player_get_video_size(player_h player, int *width, int *height); @@ -1011,7 +1313,7 @@ int player_get_video_size(player_h player, int *width, int *height); * @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_PLAYING or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. */ int player_get_album_art(player_h player, void **album_art, int *size); @@ -1028,7 +1330,7 @@ int player_get_album_art(player_h player, void **album_art, int *size); * @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_PLAYING or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. * @see player_set_uri() * @see player_set_memory_buffer() */ @@ -1374,6 +1676,7 @@ int player_unset_error_cb(player_h player); * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature * @post player_buffering_cb() will be invoked. * @see player_unset_buffering_cb() * @see player_set_uri() @@ -1406,6 +1709,7 @@ int player_unset_buffering_cb(player_h player); * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). * @see player_set_progressive_download_message_cb() * @see player_unset_progressive_download_message_cb() @@ -1440,6 +1744,7 @@ int player_get_progressive_download_status(player_h player, unsigned long *curre * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature * @pre The path to download must be set by calling player_set_progressive_download_path(). * @post player_pd_message_cb() will be invoked. * @see player_unset_progressive_download_message_cb() @@ -1535,9 +1840,8 @@ int player_set_subtitle_updated_cb(player_h player, player_subtitle_updated_cb c int player_unset_subtitle_updated_cb(player_h player); /** - * @internal * @brief Sets the seek position for the subtitle. - * @since_tizen 2.3 + * @since_tizen 2.3.1 * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported. * @param[in] player The handle to the media player * @param[in] millisecond The position in milliseconds from the start to the seek point @@ -1553,38 +1857,140 @@ int player_unset_subtitle_updated_cb(player_h player); int player_set_subtitle_position_offset(player_h player, int millisecond); /** - * @brief Registers a media packet video callback function to be called once per frame. - * @since_tizen 2.3 - * @remarks This function should be called before preparing. \n - * A registered callback is called on the internal thread of the player. \n - * A video frame can be retrieved using a registered callback as a media packet.\n - * The callback function holds the same buffer that will be drawn on the display device.\n - * So if you change the media packet in a registerd callback, it will be displayed on the device\n - * and the media packet is available until it's destroyed by media_packet_destroy(). + * @brief Registers a callback function to be invoked when video stream is changed. + * @since_tizen 2.4 + * @remarks The stream changing is detected just before rendering operation. + * @param[in] player The handle to the media player + * @param[in] callback The stream changed callback function to register + * @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_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_video_stream_changed_cb() will be invoked. + * @see player_unset_video_stream_changed_cb() + * @see player_video_stream_changed_cb() + */ +int player_set_video_stream_changed_cb (player_h player, player_video_stream_changed_cb callback, void *user_data); + +/** + * @brief Unregisters the video stream changed callback function. + * @since_tizen 2.4 * @param[in] player The handle to the media player - * @param[in] callback The callback function to be registered + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_video_stream_changed_cb() + */ +int player_unset_video_stream_changed_cb (player_h player); + +/** + * @brief Registers a callback function to be invoked when audio stream is changed. + * @since_tizen 2.4 + * @remarks The stream changing is detected just before rendering operation. + * @param[in] player The handle to the media player + * @param[in] callback The stream changed callback function to register * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, + * @return @c 0 on success, * otherwise a negative error value * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #PLAYER_ERROR_INVALID_STATE Invalid state - * @pre The player's state should be #PLAYER_STATE_IDLE. And, #PLAYER_DISPLAY_TYPE_NONE should be set by calling player_set_display. - * @see player_unset_media_packet_video_frame_decoded_cb + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_audio_stream_changed_cb() will be invoked. + * @see player_unset_audio_stream_changed_cb() + * @see player_audio_stream_changed_cb() */ -int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data); +int player_set_audio_stream_changed_cb (player_h player, player_audio_stream_changed_cb callback, void *user_data); /** - * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @brief Unregisters the audio stream changed callback function. + * @since_tizen 2.4 * @param[in] player The handle to the media player * @return @c 0 on success, * otherwise a negative error value * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter - * @see player_set_media_packet_video_frame_decoded_cb() + * @see player_set_audio_stream_changed_cb() */ -int player_unset_media_packet_video_frame_decoded_cb(player_h player); +int player_unset_audio_stream_changed_cb (player_h player); + +/** + * @brief Gets current track index. + * @since_tizen 2.4 + * @details Index starts from 0. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] index The index of track + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + */ +int player_get_current_track(player_h player, player_stream_type_e type, int *index); + +/** + * @brief Gets language code of a track. + * @since_tizen 2.4 + * @remarks @a code must be released with @c free() by caller + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] index The index of track + * @param[out] code A language code in ISO 639-1. "und" will be returned if the language is undefined. + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + */ +int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **code); + +/** + * @brief Gets the track count. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] count The number of track + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + */ +int player_get_track_count(player_h player, player_stream_type_e type, int *count); + +/** + * @brief Selects a track to play. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] index The index of track + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + * @see player_get_current_track() + */ +int player_select_track(player_h player, player_stream_type_e type, int index); /** * @} diff --git a/include/mobile/player_internal.h b/include/mobile/player_internal.h new file mode 100755 index 0000000..6ed62e2 --- /dev/null +++ b/include/mobile/player_internal.h @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __TIZEN_MEDIA_PLAYER_INTERNAL_H__ +#define __TIZEN_MEDIA_PLAYER_INTERNAL_H__ +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file player_internal.h + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief This file contains the media player API for custom features. + * @since_tizen 2.4 + */ +typedef struct +{ + void *data; /**< PCM data */ + int size; /**< Data Size */ + int channel; /**< Channel */ + int rate; /**< Samplerate */ + int depth; /**< Depth */ + bool little_endian; /**< Endianness */ + guint64 channel_mask; /**< channel_mask */ +} player_audio_raw_data_s; + +/** + * @brief Called when the audio frame is decoded. + * @since_tizen 2.4 + * @param[in] audio_raw_frame The decoded audio frame data type + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_audio_frame_decoded_cb() + * @see player_unset_audio_frame_decoded_cb() + */ +typedef void (*player_audio_pcm_extraction_cb)(player_audio_raw_data_s *audio_raw_frame, void *user_data); + + +/** + * @brief Registers a callback function to be invoked when audio frame is decoded. Audio only contents is possible. If included video, error happens. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] sync Sync on the clock + * @param[in] callback The callback function to register + * @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 + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @post player_audio_pcm_extraction_cb() will be invoked. + * @see player_unset_audio_frame_decoded_cb_ex() + */ +int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif + +#endif //__TIZEN_MEDIA_PLAYER_PRODUCT_H__ + + diff --git a/include/player_private.h b/include/player_private.h index fa7d2df..db01284 100755 --- a/include/player_private.h +++ b/include/player_private.h @@ -18,6 +18,7 @@ #define __TIZEN_MEDIA_PLAYER_PRIVATE_H__ #include #include +#include #ifdef __cplusplus extern "C" { @@ -27,6 +28,7 @@ extern "C" { #undef LOG_TAG #endif #define LOG_TAG "TIZEN_N_PLAYER" +//#define USE_ECORE_FUNCTIONS #define PLAYER_CHECK_CONDITION(condition,error,msg) \ if(condition) {} else \ @@ -45,6 +47,49 @@ extern "C" { PLAYER_CHECK_CONDITION(arg <= max,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") \ PLAYER_CHECK_CONDITION(arg >= min,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") +#ifdef TIZEN_TTRACE +#include +#define PLAYER_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_VIDEO, NAME) +#define PLAYER_TRACE_END() traceEnd(TTRACE_TAG_VIDEO) +#define PLAYER_TRACE_ASYNC_BEGIN(NAME, COOKIE) traceAsyncBegin (TTRACE_TAG_VIDEO, COOKIE, NAME); +#define PLAYER_TRACE_ASYNC_END(NAME, COOKIE) traceAsyncEnd(TTRACE_TAG_VIDEO, COOKIE, NAME); +#else +#define PLAYER_TRACE_BEGIN(NAME) +#define PLAYER_TRACE_END() +#define PLAYER_TRACE_ASYNC_BEGIN(NAME, KEY) +#define PLAYER_TRACE_ASYNC_END(NAME, KEY) +#endif + +#define PLAYER_NETWORK_AVAILABLE_CHECK() \ +do \ +{ \ + bool enabled = FALSE; \ + bool supported = FALSE; \ + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool("http://tizen.org/feature/network.wifi", &enabled)) \ + { \ + LOGI("[%s] wifi status = %d", __FUNCTION__, enabled); \ + if (enabled) supported = TRUE; \ + } \ + else \ + { \ + LOGE("[%s] SYSTEM_INFO_ERROR", __FUNCTION__); \ + } \ + if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool("http://tizen.org/feature/network.telephony", &enabled)) \ + { \ + LOGI("[%s] telephony status = %d", __FUNCTION__, enabled); \ + if (enabled) supported = TRUE; \ + } \ + else \ + { \ + LOGE("[%s] SYSTEM_INFO_ERROR", __FUNCTION__); \ + } \ + if (!supported) \ + { \ + LOGE("[%s] PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE", __FUNCTION__); \ + return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE; \ + } \ +} while (0) + typedef enum { _PLAYER_EVENT_TYPE_PREPARE, _PLAYER_EVENT_TYPE_COMPLETE, @@ -61,9 +106,31 @@ typedef enum { _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT, _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET, _PLAYER_EVENT_TYPE_MISSED_PLUGIN, +#ifdef _PLAYER_FOR_PRODUCT + _PLAYER_EVENT_TYPE_IMAGE_BUFFER, + _PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE, +#endif + _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, + _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, + _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, + _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, + _PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED, + _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, _PLAYER_EVENT_TYPE_NUM }_player_event_e; +#ifndef USE_ECORE_FUNCTIONS +typedef enum { + PLAYER_MESSAGE_NONE, + PLAYER_MESSAGE_PREPARED, + PLAYER_MESSAGE_ERROR, + PLAYER_MESSAGE_SEEK_DONE, + PLAYER_MESSAGE_EOS, + PLAYER_MESSAGE_LOOP_EXIT, + PLAYER_MESSAGE_MAX +}_player_message_e; +#endif + typedef struct _player_s{ MMHandleType mm_handle; const void* user_cb[_PLAYER_EVENT_TYPE_NUM]; @@ -79,7 +146,15 @@ typedef struct _player_s{ bool is_display_visible; bool is_progressive_download; pthread_t prepare_async_thread; +#ifdef USE_ECORE_FUNCTIONS GHashTable *ecore_jobs; +#else + pthread_t message_thread; + GQueue *message_queue; + GMutex message_queue_lock; + GCond message_queue_cond; + int current_message; +#endif player_error_e error_code; bool is_doing_jobs; media_format_h pkt_fmt; diff --git a/include/wearable/player.h b/include/wearable/player.h new file mode 100755 index 0000000..a9defc4 --- /dev/null +++ b/include/wearable/player.h @@ -0,0 +1,2002 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __TIZEN_MEDIA_PLAYER_H__ +#define __TIZEN_MEDIA_PLAYER_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PLAYER_ERROR_CLASS TIZEN_ERROR_PLAYER | 0x20 + +/** + * @file player.h + * @brief This file contains the media player API. + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief The media player's type handle. + * @since_tizen 2.3.1 + */ +typedef struct player_s *player_h; + +/** + * @brief Enumeration for media player state. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_STATE_NONE, /**< Player is not created */ + PLAYER_STATE_IDLE, /**< Player is created, but not prepared */ + PLAYER_STATE_READY, /**< Player is ready to play media */ + PLAYER_STATE_PLAYING, /**< Player is playing media */ + PLAYER_STATE_PAUSED, /**< Player is paused while playing media */ +} player_state_e; + +/** + * @brief Enumeration for media player's error codes. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + PLAYER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + PLAYER_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file or directory */ + PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ + PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on the device */ + PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + PLAYER_ERROR_SEEK_FAILED = PLAYER_ERROR_CLASS | 0x01, /**< Seek operation failure */ + PLAYER_ERROR_INVALID_STATE = PLAYER_ERROR_CLASS | 0x02, /**< Invalid state */ + PLAYER_ERROR_NOT_SUPPORTED_FILE = PLAYER_ERROR_CLASS | 0x03, /**< File format not supported */ + PLAYER_ERROR_INVALID_URI = PLAYER_ERROR_CLASS | 0x04, /**< Invalid URI */ + PLAYER_ERROR_SOUND_POLICY = PLAYER_ERROR_CLASS | 0x05, /**< Sound policy error */ + PLAYER_ERROR_CONNECTION_FAILED = PLAYER_ERROR_CLASS | 0x06, /**< Streaming connection failed */ + PLAYER_ERROR_VIDEO_CAPTURE_FAILED = PLAYER_ERROR_CLASS | 0x07, /**< Video capture failed */ + PLAYER_ERROR_DRM_EXPIRED = PLAYER_ERROR_CLASS | 0x08, /**< Expired license */ + PLAYER_ERROR_DRM_NO_LICENSE = PLAYER_ERROR_CLASS | 0x09, /**< No license */ + PLAYER_ERROR_DRM_FUTURE_USE = PLAYER_ERROR_CLASS | 0x0a, /**< License for future use */ + PLAYER_ERROR_DRM_NOT_PERMITTED = PLAYER_ERROR_CLASS | 0x0b, /**< Format not permitted */ + PLAYER_ERROR_RESOURCE_LIMIT = PLAYER_ERROR_CLASS | 0x0c, /**< Resource limit */ + PLAYER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ +} player_error_e; + +/** + * @brief Enumeration for media player's interruption type. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed */ + PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application */ + PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call */ + PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones */ + PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */ + PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm */ + PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency */ + PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification */ +} player_interrupted_code_e; + +/** + * @brief Enumeration for progressive download message type. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_PD_STARTED = 0, /**< Progressive download is started */ + PLAYER_PD_COMPLETED, /**< Progressive download is completed */ +} player_pd_message_type_e; + +/** + * @brief Enumeration for display type. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */ + PLAYER_DISPLAY_TYPE_NONE, /**< This disposes off buffers */ +} player_display_type_e; + +/** + * @brief Enumeration for audio latency mode. + * @since_tizen 2.3.1 + */ +typedef enum +{ + AUDIO_LATENCY_MODE_LOW = 0, /**< Low audio latency mode */ + AUDIO_LATENCY_MODE_MID, /**< Middle audio latency mode */ + AUDIO_LATENCY_MODE_HIGH, /**< High audio latency mode */ +} audio_latency_mode_e; + +/** + * @brief Enumeration for stream type. + * @since_tizen 2.4 + */ +typedef enum +{ + PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */ + PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */ + PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */ + PLAYER_STREAM_TYPE_TEXT, /**< Text type */ +} player_stream_type_e; + +/** + * @brief Enumeration of media stream buffer status + * @since_tizen 2.4 + */ +typedef enum +{ + PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, + PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW, +} player_media_stream_buffer_status_e; + +/** + * @brief The player display handle. + * @since_tizen 2.3.1 + */ +typedef void* player_display_h; + +#ifndef GET_DISPLAY +/** + * @brief Definition for a display handle from evas object. + * @since_tizen 2.3.1 + */ +#define GET_DISPLAY(x) (void*)(x) +#endif + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_DISPLAY_MODULE + * @{ + */ + +/** + * @brief Enumeration for display rotation type. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_DISPLAY_ROTATION_NONE, /**< Display is not rotated */ + PLAYER_DISPLAY_ROTATION_90, /**< Display is rotated 90 degrees */ + PLAYER_DISPLAY_ROTATION_180, /**< Display is rotated 180 degrees */ + PLAYER_DISPLAY_ROTATION_270, /**< Display is rotated 270 degrees */ +} player_display_rotation_e; + +/** + * @brief Enumeration for x surface display aspect ratio. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_DISPLAY_MODE_LETTER_BOX = 0, /**< Letter box */ + PLAYER_DISPLAY_MODE_ORIGIN_SIZE, /**< Origin size */ + PLAYER_DISPLAY_MODE_FULL_SCREEN, /**< Full-screen */ + PLAYER_DISPLAY_MODE_CROPPED_FULL, /**< Cropped full-screen */ + PLAYER_DISPLAY_MODE_ORIGIN_OR_LETTER, /**< Origin size (if surface size is larger than video size(width/height)) or Letter box (if video size(width/height) is larger than surface size) */ + PLAYER_DISPLAY_MODE_DST_ROI, /**< Dst ROI mode */ +} player_display_mode_e; + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE + * @{ + */ + +/** + * @brief Enumeration for media stream content information. + * @since_tizen 2.3.1 + */ +typedef enum +{ + PLAYER_CONTENT_INFO_ALBUM, /**< Album */ + PLAYER_CONTENT_INFO_ARTIST, /**< Artist */ + PLAYER_CONTENT_INFO_AUTHOR, /**< Author */ + PLAYER_CONTENT_INFO_GENRE, /**< Genre */ + PLAYER_CONTENT_INFO_TITLE, /**< Title */ + PLAYER_CONTENT_INFO_YEAR, /**< Year */ +} player_content_info_e; + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_PLAYER_SUBTITLE_MODULE + * @{ + */ + +/** + * @brief Called when the subtitle is updated. + * @since_tizen 2.3.1 + * @param[in] duration The duration of the updated subtitle + * @param[in] text The text of the updated subtitle + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_subtitle_updated_cb() + * @see player_unset_subtitle_updated_cb() + */ +typedef void (*player_subtitle_updated_cb)(unsigned long duration, char *text, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief Called when the media player is prepared. + * @since_tizen 2.3.1 + * @details It will be invoked when player has reached the begin of stream. + * @param[in] user_data The user data passed from the callback registration function + * @pre player_prepare_async() will cause this callback. + * @post The player state will be #PLAYER_STATE_READY. + * @see player_prepare_async() + */ +typedef void (*player_prepared_cb)(void *user_data); + +/** + * @brief Called when the media player is completed. + * @since_tizen 2.3.1 + * @details It will be invoked when player has reached the end of the stream. + * @param[in] user_data The user data passed from the callback registration function + * @pre It will be invoked when the playback is completed if you register this callback using player_set_completed_cb(). + * @see player_set_completed_cb() + * @see player_unset_completed_cb() + */ +typedef void (*player_completed_cb)(void *user_data); + +/** + * @brief Called when the seek operation is completed. + * @since_tizen 2.3.1 + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_play_position() + */ +typedef void (*player_seek_completed_cb)(void *user_data); + +/** + * @brief Called when the media player is interrupted. + * @since_tizen 2.3.1 + * @param[in] error_code The interrupted error code + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_interrupted_cb() + * @see player_unset_interrupted_cb() + */ +typedef void (*player_interrupted_cb)(player_interrupted_code_e code, void *user_data); + +/** + * @brief Called when an error occurs in the media player. + * @since_tizen 2.3.1 + * @param[in] error_code The error code + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_error_cb() + * @see player_unset_error_cb() + * @see #player_error_e + */ +typedef void (*player_error_cb)(int error_code, void *user_data); + +/** + * @brief Called when the buffering percentage of the media playback is updated. + * @since_tizen 2.3.1 + * @details If the buffer is full, it will return 100%. + * @param[in] percent The percentage of buffering completed (0~100) + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_buffering_cb() + * @see player_unset_buffering_cb() + */ +typedef void (*player_buffering_cb)(int percent, void *user_data); + +/** + * @brief Called when progressive download is started or completed. + * @since_tizen 2.3.1 + * @param[in] type The message type for progressive download + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_progressive_download_path() + */ +typedef void (*player_pd_message_cb)(player_pd_message_type_e type, void *user_data); + +/** + * @brief Called when the video is captured. + * @since_tizen 2.3.1 + * @remarks The color space format of the captured image is IMAGE_UTIL_COLORSPACE_RGB888. + * @param[in] data The captured image buffer + * @param[in] width The width of the captured image + * @param[in] height The height of the captured image + * @param[in] size The size of the captured image + * @param[in] user_data The user data passed from the callback registration function + * @see player_capture_video() + */ +typedef void (*player_video_captured_cb)(unsigned char *data, int width, int height, unsigned int size, void *user_data); + +/** + * @brief Called to register for notifications about delivering media packet when every video frame is decoded. + * @since_tizen 2.3.1 + * + * @remarks This function is issued in the context of gstreamer so the UI update code should not be directly invoked.\n + * the packet should be released by media_packet_destroy() after use. \n + * Otherwises, decoder can't work more because it can't have enough buffer to fill decoded frame. + * + * @param[in] pkt Reference pointer to the media packet + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void (*player_media_packet_video_decoded_cb)(media_packet_h pkt, void *user_data); + +/** + * @brief Called when the buffer level drops below the threshold of max size or no free space in buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_media_stream_buffer_status_cb() + * @see player_set_media_stream_buffer_max_size() + * @see player_set_media_stream_buffer_min_threshold() + */ +typedef void (*player_media_stream_buffer_status_cb) (player_media_stream_buffer_status_e status, void *user_data); + +/** + * @brief Called to notify the next push-buffer offset when seeking is occurred. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @details The next push-buffer should produce buffers from the new offset. + * @param[in] offset The new byte position to seek + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void (*player_media_stream_seek_cb) (unsigned long long offset, void *user_data); + +/** + * @brief Called to notify the video stream changed. + * @since_tizen 2.4 + * @details The video stream changing is detected just before rendering operation. + * @param[in] width The width of the captured image + * @param[in] height The height of the captured image + * @param[in] fps The frame per second of the video \n + It can be @c 0 if there is no video stream information. + * @param[in] bit_rate The video bit rate [Hz] \n + * It can be an invalid value if there is no video stream information. + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_video_stream_changed_cb() + */ +typedef void (*player_video_stream_changed_cb) (int width, int height, int fps, int bit_rate, void *user_data); + +/** + * @brief Called to notify the audio stream changed. + * @since_tizen 2.4 + * @details The audio stream changing is detected just before rendering operation. + * @param[in] sample_rate The audio sample rate [Hz] \n + * Value can be invalid if there is no audio stream information. + * @param[in] channel The audio channel (1: mono, 2: stereo) \n + * Value can be invalid if there is no audio stream information. + * @param[in] bit_rate The audio bit rate [Hz] \n + * Value can be invalid if there is no audio stream information. + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_audio_stream_changed_cb() + */ +typedef void (*player_audio_stream_changed_cb) (int sample_rate, int channel, int bit_rate, void *user_data); + +/** + * @brief Creates a player handle for playing multimedia content. + * @since_tizen 2.3.1 + * @remarks You must release @a player by using player_destroy().\n + * Although you can create multiple player handles at the same time, + * the player cannot guarantee proper operation because of limited resources, such as + * audio or display device. + * + * @param[out] player A new handle to the media player + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @post The player state will be #PLAYER_STATE_IDLE. + * @see player_destroy() + */ +int player_create(player_h *player); + +/** + * @brief Destroys the media player handle and releases all its resources. + * @since_tizen 2.3.1 + * @remarks To completely shutdown player operation, call this function with a valid player handle from any player state. + * @param[in] player The handle to the media player to be destroyed + * @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 + * @pre The player state must be set to #PLAYER_STATE_IDLE. + * @post The player state will be #PLAYER_STATE_NONE. + * @see player_create() + */ +int player_destroy(player_h player); + +/** + * @brief Prepares the media player for playback. + * @since_tizen 2.3.1 + * @remarks The mediastorage privilege(http://tizen.org/privilege/mediastorage) should be added if any video/audio files are used to play located in the internal storage. + * @remarks The externalstorage privilege(http://tizen.org/privilege/externalstorage) should be added if any video/audio files are used to play located in the external storage. + * @remarks The internet privilege(http://tizen.org/privilege/internet) should be added if any URLs are used to play from network. + * @param[in] player The handle to the media player + * @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_URI Invalid URI + * @retval #PLAYER_ERROR_NO_SUCH_FILE File not found + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE File not supported + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_PERMISSION_DENIED Permission denied + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). After that, call player_set_uri() to load the media content you want to play. + * @post The player state will be #PLAYER_STATE_READY. + * @see player_prepare_async() + * @see player_unprepare() + * @see player_set_uri() + */ +int player_prepare(player_h player); + +/** + * @brief Prepares the media player for playback, asynchronously. + * @since_tizen 2.3.1 + * @remarks The mediastorage privilege(http://tizen.org/privilege/mediastorage) should be added if any video/audio files are used to play located in the internal storage. + * @remarks The externalstorage privilege(http://tizen.org/privilege/externalstorage) should be added if any video/audio files are used to play located in the external storage. + * @remarks The internet privilege(http://tizen.org/privilege/internet) should be added if any URLs are used to play from network. + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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_URI Invalid URI + * @retval #PLAYER_ERROR_NO_SUCH_FILE File not found + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE File not supported + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_PERMISSION_DENIED Permission denied + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). After that, call player_set_uri() to load the media content you want to play. + * @post It invokes player_prepared_cb() when playback is prepared. + * @see player_prepare() + * @see player_prepared_cb() + * @see player_unprepare() + * @see player_set_uri() + */ +int player_prepare_async (player_h player, player_prepared_cb callback, void* user_data); + +/** + * @brief Resets the media player. + * @details The most recently used media is reset and no longer associated with the player. + * Playback is no longer possible. If you want to use the player again, you will have to set the data URI and call + * player_prepare() again. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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 should be higher than #PLAYER_STATE_IDLE. + * @post The player state will be #PLAYER_STATE_IDLE. + * @see player_prepare() + */ +int player_unprepare(player_h player); + +/** + * @brief Sets the data source (file-path, HTTP or RSTP URI) to use. + * + * @details Associates media contents, referred to by the URI, with the player. + * If the function call is successful, subsequent calls to player_prepare() and player_start() will start playing the media. + * @since_tizen 2.3.1 + * @remarks If you use HTTP or RSTP, URI should start with "http://" or "rtsp://". The default protocol is "file://". + * If you provide an invalid URI, you won't receive an error message until you call player_start(). + * + * @param[in] player The handle to the media player + * @param[in] uri The content location, such as the file path, the URI of the HTTP or RSTP stream you want to play + * + * @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 set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_memory_buffer() + */ +int player_set_uri(player_h player, const char * uri); + +/** + * @brief Sets memory as the data source. + * + * @details Associates media content, cached in memory, with the player. Unlike the case of player_set_uri(), the media resides in memory. + * If the function call is successful, subsequent calls to player_prepare() and player_start() will start playing the media. + * @since_tizen 2.3.1 + * @remarks If you provide an invalid data, you won't receive an error message until you call player_start(). + * + * @param[in] player The handle to the media player + * @param[in] data The memory pointer of media data + * @param[in] size The size of media data + * @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 set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_uri() + */ +int player_set_memory_buffer(player_h player, const void * data, int size); + +/** + * @brief Gets the player's current state. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] state The current state of the player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see #player_state_e + */ +int player_get_state(player_h player, player_state_e *state); + +/** + * @brief Sets the player's volume. + * @since_tizen 2.3.1 + * @details Setting this volume adjusts the player's instance volume, not the system volume. + * The valid range is from 0 to 1.0, inclusive (1.0 = 100%). Default value is 1.0. + * To change system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API. + * Finally, it does not support to set other value into each channel currently. + * + * @param[in] player The handle to the media player + * @param[in] left The left volume scalar + * @param[in] right The right volume scalar + * @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_get_volume() + */ +int player_set_volume(player_h player, float left, float right); + +/** + * @brief Gets the player's current volume factor. + * @since_tizen 2.3.1 + * @details The range of @a left and @a right is from @c 0 to @c 1.0, inclusive (1.0 = 100%). + * This function gets the player volume, not the system volume. + * To get the system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API. + * + * @param[in] player The handle to the media player + * @param[out] left The current left volume scalar + * @param[out] right The current right volume scalar + * @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_set_volume() + */ +int player_get_volume(player_h player, float *left, float *right); + +/** + * @brief Sets the player's volume type. + * @since_tizen 2.3.1 + * @remarks The default sound type of the player is #SOUND_TYPE_MEDIA. + * To get the current sound type, use sound_manager_get_current_sound_type(). + * + * @param[in] player The handle to the media player + * @param[in] type The sound type + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create(). + * @see sound_manager_get_current_sound_type() + */ +int player_set_sound_type(player_h player, sound_type_e type); + +/** + * @brief Sets the audio latency mode. + * @since_tizen 2.3.1 + * @remarks The default audio latency mode of the player is #AUDIO_LATENCY_MODE_MID. + * To get the current audio latency mode, use player_get_audio_latency_mode(). + * If it's high mode, audio output interval can be increased so, it can keep more audio data to play. + * But, state transition like pause or resume can be more slower than default(mid) mode. + * + * @param[in] player The handle to the media player + * @param[in] latency_mode The latency mode to be applied to the audio + * @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 #audio_latency_mode_e + * @see player_get_audio_latency_mode() + */ +int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode); + +/** + * @brief Gets the current audio latency mode. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] latency_mode The latency mode to get from the audio + * @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 #audio_latency_mode_e + * @see player_set_audio_latency_mode() + */ +int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency_mode); + +/** + * @brief Starts or resumes playback. + * @since_tizen 2.3.1 + * @details Plays current media content, or resumes play if paused. + * + * @param[in] player The handle to the media player + * @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 + * @retval #PLAYER_ERROR_CONNECTION_FAILED Network connection failed + * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error + * @pre player_prepare() must be called before calling this function. + * @pre The player state must be set to #PLAYER_STATE_READY by calling player_prepare() or set to #PLAYER_STATE_PAUSED by calling player_pause(). + * @post The player state will be #PLAYER_STATE_PLAYING. + * @post It invokes player_completed_cb() when playback completes, if you set a callback with player_set_completed_cb(). + * @post It invokes player_pd_message_cb() when progressive download starts or completes, if you set a download path with player_set_progressive_download_path() and a callback with player_set_progressive_download_message_cb(). + * @see player_prepare() + * @see player_prepare_async() + * @see player_stop() + * @see player_pause() + * @see player_set_completed_cb() + * @see player_completed_cb() + * @see player_set_progressive_download_path() + * @see player_set_progressive_download_message_cb() + * @see player_pd_message_cb() + */ +int player_start(player_h player); + +/** + * @brief Stops playing media content. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid state + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error + * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling player_start() or set to #PLAYER_STATE_PAUSED by calling player_pause(). + * @post The player state will be #PLAYER_STATE_READY. + * @post The downloading will be aborted if you use progressive download. + * @see player_start() + * @see player_pause() + */ +int player_stop(player_h player); + +/** + * @brief Pauses the player. + * @since_tizen 2.3.1 + * @remarks You can resume playback using player_start(). + * + * @param[in] player The handle to the media player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid state + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error + * @pre The player state must be set to #PLAYER_STATE_PLAYING. + * @post The player state will be #PLAYER_STATE_READY. + * @see player_start() + */ +int player_pause(player_h player); + +/** + * @brief Sets the seek position for playback, asynchronously. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] millisecond The position in milliseconds from the start to the seek point + * @param[in] accurate If @c true the selected position is returned, but this might be considerably slow, + * otherwise @c false + * @param[in] callback The callback function to register + * @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 + * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post It invokes player_seek_completed_cb() when seek operation completes, if you set a callback. + * @see player_get_play_position() + */ +int player_set_play_position(player_h player, int millisecond, bool accurate, player_seek_completed_cb callback, void *user_data); + +/** + * @brief Gets the current position in milliseconds. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] millisecond The current position in milliseconds + * @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_SEEK_FAILED Seek operation failure + * @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_play_position() + */ +int player_get_play_position(player_h player, int *millisecond); + +/** + * @brief Sets the player's mute status. + * @since_tizen 2.3.1 + * @details If the mute status is @c true, no sounds are played. + * If it is @c false, sounds are played at the previously set volume level. + * Until this function is called, by default the player is not muted. + * + * @param[in] player The handle to the media player + * @param[in] muted The new mute status: (@c true = mute, @c false = not muted) + * @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 + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_is_muted() + */ +int player_set_mute(player_h player, bool muted); + +/** + * @brief Gets the player's mute status. + * @since_tizen 2.3.1 + * @details If the mute status is @c true, no sounds are played. + * If it is @c false, sounds are played at the previously set volume level. + * + * @param[in] player The handle to the media player + * @param[out] muted The current mute status: (@c true = mute, @c false = not muted) + * @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 + * @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_mute() + */ +int player_is_muted(player_h player, bool *muted); + +/** + * @brief Sets the player's looping status. + * @since_tizen 2.3.1 + * @details If the looping status is @c true, playback automatically restarts upon finishing. + * If it is @c false, it won't. The default value is @c false. + * + * @param[in] player The handle to the media player + * @param[in] looping The new looping status: (@c true = looping, @c false = non-looping ) + * @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_is_looping() + */ +int player_set_looping(player_h player, bool looping); + +/** + * @brief Gets the player's looping status. + * @since_tizen 2.3.1 + * @details If the looping status is @c true, playback automatically restarts upon finishing. + * If it is @c false, it won't. + * + * @param[in] player The handle to the media player + * @param[out] looping The looping status: (@c true = looping, @c false = non-looping ) + * @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_looping() + */ +int player_is_looping(player_h player, bool *looping); + +/** + * @brief Sets the video display. + * @since_tizen 2.3.1 + * @remarks To get @a display to set, use #GET_DISPLAY(). + * @remarks To use the multiple surface display mode, use player_set_display() again with a different display type. + * @remarks We are not supporting changing display between different types. \n + * If you want to change display handle after calling player_prepare(), you must use the same display type as what you set before. + * @param[in] player The handle to the media player + * @param[in] type The display type + * @param[in] display The handle to display + * @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_display_rotation + */ +int player_set_display(player_h player, player_display_type_e type, player_display_h display); + +/** + * @brief Registers a media packet video callback function to be called once per frame. + * @since_tizen 2.3.1 + * @remarks This function should be called before preparing. \n + * A registered callback is called on the internal thread of the player. \n + * A video frame can be retrieved using a registered callback as a media packet.\n + * The callback function holds the same buffer that will be drawn on the display device.\n + * So if you change the media packet in a registerd callback, it will be displayed on the device\n + * and the media packet is available until it's destroyed by media_packet_destroy(). + * @param[in] player The handle to the media player + * @param[in] callback The callback function to be registered + * @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_STATE Invalid state + * @pre The player's state should be #PLAYER_STATE_IDLE. And, #PLAYER_DISPLAY_TYPE_NONE should be set by calling player_set_display. + * @see player_unset_media_packet_video_frame_decoded_cb + */ +int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player's state should be #PLAYER_STATE_READY or #PLAYER_STATE_IDLE + * @see player_set_media_packet_video_frame_decoded_cb() + */ +int player_unset_media_packet_video_frame_decoded_cb(player_h player); + +/** + * @brief Pushes elementary stream to decode audio or video + * @since_tizen 2.4 + * @param[in] player The handle to media player + * @param[in] packet The media packet to decode + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE File not supported + * @pre The player state must be set to #PLAYER_STATE_IDLE at least. + * @see player_set_media_stream_info() + */ +int player_push_media_stream(player_h player, media_packet_h packet); + +/** + * @brief Sets contents information for media stream + * @since_tizen 2.4 + * @remarks AV format should be set before pushing elementary stream with player_push_media_stream(). + * @remarks AAC can be supported. + * @remarks H.264 can be supported. + * @remarks This API should be called before calling the player_prepare() or player_prepare_async() \n + to reflect the media information when pipeline is created. + * @param[in] player The handle to media player + * @param[in] type The type of target stream + * @param[in] format The media format to set audio information + * @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 + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_push_media_stream() + */ +int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format); + +/** + * @brief Pushes elementary stream to decode audio or video + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to media player + * @param[in] packet The media packet to decode + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE File not supported + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_media_stream_info() + */ +int player_push_media_stream(player_h player, media_packet_h packet); + +/** + * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] callback The buffer status callback function to register + * @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_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_media_stream_buffer_status_cb() will be invoked. + * @see player_unset_media_stream_buffer_status_cb() + * @see player_media_stream_buffer_status_cb() + */ +int player_set_media_stream_buffer_status_cb(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb callback, void *user_data); + +/** + * @brief Unregisters the buffer status callback function. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_media_stream_buffer_status_cb() + */ +int player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e type); + +/** + * @brief Registers a callback function to be invoked when seeking is occurred. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] callback The callback function to register + * @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_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_media_stream_seek_cb() will be invoked. + * @see player_unset_media_stream_seek_cb() + * @see player_media_stream_seek_cb() + */ +int player_set_media_stream_seek_cb(player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data); + +/** + * @brief Unregisters the seek callback function. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_media_stream_seek_cb() + */ +int player_unset_media_stream_seek_cb(player_h player, player_stream_type_e type); + +/** + * @brief Sets the max size bytes of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level over the max size, player_media_stream_buffer_status_cb() will be invoked with overflow status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] max_size The max bytes of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_get_media_stream_buffer_max_size() + * @see player_media_stream_buffer_status_cb() + */ +int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size); + +/** + * @brief Gets the max size bytes of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level over the max size, player_media_stream_buffer_status_cb() will be invoked with overflow status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] max_size The max bytes of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_media_stream_buffer_max_size() + * @see player_media_stream_buffer_status_cb() + */ +int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *max_size); + +/** + * @brief Sets the buffer threshold percent of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level drops below the percent value, player_media_stream_buffer_status_cb() will be invoked with underrun status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] percent The minimum threshold(0~100) of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_get_media_stream_buffer_min_threshold() + * @see player_media_stream_buffer_status_cb() + */ +int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent); + +/** + * @brief Gets the buffer threshold percent of buffer. + * @since_tizen 2.4 + * @remarks This API is used for media stream playback only. + * @remarks If the buffer level drops below the percent value, player_media_stream_buffer_status_cb() will be invoked with underrun status. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] percent The minimum threshold(0~100) of buffer + * @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 player state + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_media_stream_buffer_min_threshold() + * @see player_media_stream_buffer_status_cb() + */ +int player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *percent); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_DISPLAY_MODULE + * @{ + */ + +/** + * @brief Sets the video display mode. + * @since_tizen 2.3.1 + * @remarks If no display is set, no operation is performed. + * @param[in] player The handle to the media player + * @param[in] mode The display mode + * @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 + * @pre The player should support display mode changes. + * @see player_get_display_mode() + */ +int player_set_display_mode(player_h player, player_display_mode_e mode); + +/** + * @brief Gets the video display mode. + * @since_tizen 2.3.1 + * @remarks If no display is set, no operation is performed. + * @param[in] player The handle to the media player + * @param[out] mode The current display mode + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_display_mode() + */ +int player_get_display_mode(player_h player, player_display_mode_e *mode); + +/** + * @brief Sets the visibility of the x surface video display + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] visible The visibility of the display (@c true = visible, @c false = non-visible ) + * @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 + * @see player_is_display_visible() + */ +int player_set_display_visible(player_h player, bool visible); + +/** + * @brief Gets the visibility of the x surface video display. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] visible The current visibility of the display (@c true = visible, @c false = non-visible ) + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_display_visible() + */ +int player_is_display_visible(player_h player, bool* visible); + +/** + * @brief Sets the rotation settings of the video surface display. + * @since_tizen 2.3.1 + * @details Use this function to change the video orientation to portrait mode. + * @param[in] player The handle to the media player + * @param[in] rotation The rotation of the display + * @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 + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature + * @see player_set_display + * @see player_get_display_rotation() + */ +int player_set_display_rotation(player_h player, player_display_rotation_e rotation); + +/** + * @brief Gets the rotation of the video surface display. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] rotation The current rotation of the display + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_display_rotation() + */ +int player_get_display_rotation( player_h player, player_display_rotation_e *rotation); + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE + * @{ + */ + + /** + * @brief Gets the media content information. + * @since_tizen 2.3.1 + * @remarks You must release @a value using @c free(). + * @remarks The playback type should be local playback or HTTP streaming playback. + * @param[in] player The handle to the media player + * @param[in] key The key attribute name to get + * @param[out] value The value of the key attribute \n + * It can be an empty string if there is no content information. + * @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_OUT_OF_MEMORY Not enough memory is available + * @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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + */ +int player_get_content_info(player_h player, player_content_info_e key, char ** value); + +/** + * @brief Gets the audio and video codec information. + * @since_tizen 2.3.1 + * @remarks You must release @a audio_codec and @a video_codec using free(). + * @remarks The playback type should be local playback or HTTP streaming playback. + * @param[in] player The handle to the media player + * @param[out] audio_codec The name of the audio codec \n + * It can be @c NULL if there is no audio codec. + * @param[out] video_codec The name of the video codec \n + * It can be @c NULL if there is no video codec. + * @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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + */ +int player_get_codec_info(player_h player, char **audio_codec, char **video_codec); + +/** + * @brief Gets the audio stream information. + * @since_tizen 2.3.1 + * @remarks The playback type should be local playback or HTTP streaming playback. + * @param[in] player The handle to the media player + * @param[out] sample_rate The audio sample rate [Hz] \n + * Value can be invalid if there is no audio stream information. + * @param[out] channel The audio channel (1: mono, 2: stereo) \n + * Value can be invalid if there is no audio stream information. + * @param[out] bit_rate The audio bit rate [Hz] \n + * Value can be invalid if there is no audio stream information. + * @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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + */ +int player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate); + +/** + * @brief Gets the video stream information. + * @since_tizen 2.3.1 + * @remarks The playback type should be local playback or HTTP streaming playback. + * @param[in] player The handle to the media player + * @param[out] fps The frame per second of the video \n + * It can be @c 0 if there is no video stream information. + * @param[out] bit_rate The video bit rate [Hz] \n + * It can be an invalid value if there is no video stream information. + * @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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + */ +int player_get_video_stream_info(player_h player, int *fps, int *bit_rate); + +/** + * @brief Gets the video display's height and width. + * @since_tizen 2.3.1 + * @remarks The playback type should be local playback or HTTP streaming playback. + * @param[in] player The handle to the media player + * @param[out] width The width of the video \n + * Value can be invalid if there is no video or no display is set. + * @param[out] height The height of the video \n + * Value can be invalid value if there is no video or no display is set. + * @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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + */ +int player_get_video_size(player_h player, int *width, int *height); + +/** + * @brief Gets the album art in the media resource. + * @since_tizen 2.3.1 + * @remarks You must not release @a album_art. It will be released by framework when the player is destroyed. + * @param[in] player The handle to the media player + * @param[out] album_art The encoded artwork image + * @param[out] size The encoded artwork size + * @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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + */ +int player_get_album_art(player_h player, void **album_art, int *size); + +/** + * @brief Gets the total running time of the associated media. + * @since_tizen 2.3.1 + * @remarks The media source is associated with the player, using either player_set_uri() or player_set_memory_buffer(). + * @remarks The playback type should be local playback or HTTP streaming playback. + * @param[in] player The handle to the media player + * @param[out] duration The duration in milliseconds + * @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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + * @see player_set_uri() + * @see player_set_memory_buffer() + */ +int player_get_duration(player_h player, int *duration); + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE + * @{ + */ + +/** + * @brief Gets the number of equalizer bands. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] count The number of equalizer bands + * @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 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_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_get_equalizer_bands_count (player_h player, int *count); + +/** + * @brief Sets the gain set for the given equalizer band. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] index The index of the equalizer band to be set + * @param[in] level The new gain in decibel that is set to the given band [dB] + * @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_audio_effect_get_equalizer_bands_count() + * @see player_audio_effect_get_equalizer_level_range() + * @see player_audio_effect_get_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level); + +/** + * @brief Gets the gain set for the given equalizer band. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] index The index of the requested equalizer band + * @param[out] level The gain in decibel of the given band [dB] + * @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 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_audio_effect_set_equalizer_band_level() + */ +int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level); + +/** + * @brief Sets all bands of the equalizer. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] band_levels The list of band levels to be set + * @param[in] length The length of the band level + * @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_audio_effect_get_equalizer_bands_count() + * @see player_audio_effect_get_equalizer_level_range() + * @see player_audio_effect_set_equalizer_band_level() + */ +int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length); + +/** + * @brief Gets the valid band level range of the equalizer. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] min The minimum value to be set [dB] + * @param[out] max The maximum value to be set [dB] + * @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 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_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_get_equalizer_level_range(player_h player, int* min, int* max); + +/** + * @brief Gets the band frequency of the equalizer. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] index The index of the requested equalizer band + * @param[out] frequency The frequency of the given band [dB] + * @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 player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *frequency); + +/** + * @brief Gets the band frequency range of the equalizer. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] index The index of the requested equalizer band + * @param[out] range The frequency range of the given band [dB] + * @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 player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *range); + +/** + * @brief Clears the equalizer effect. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_equalizer_clear(player_h player); + +/** + * @brief Checks whether the custom equalizer effect is available. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] available If @c true the specified audio effect is available, + * otherwise @c false + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @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_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_equalizer_is_available(player_h player, bool *available); + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief Captures the video frame, asynchronously. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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 + * Video type should be set using player_set_display() otherwises, audio stream is only processed even though video file is set. + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling player_start() or set to #PLAYER_STATE_PAUSED by calling player_pause(). + * @post It invokes player_video_captured_cb() when capture completes, if you set a callback. + * @see player_video_captured_cb() + */ +int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data); + +/** + * @brief Sets the cookie for streaming playback. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] cookie The cookie to set + * @param[in] size The size of the cookie + * @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 set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_streaming_user_agent() + */ +int player_set_streaming_cookie(player_h player, const char *cookie, int size); + +/** + * @brief Sets the streaming user agent for playback. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] user_agent The user agent to set + * @param[in] size The size of the user agent + * @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 set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_streaming_cookie() + */ +int player_set_streaming_user_agent(player_h player, const char *user_agent, int size); + +/** + * @brief Gets the download progress for streaming playback. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] start The starting position in percentage [0, 100] + * @param[out] current The current position in percentage [0, 100] + * @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 set to #PLAYER_STATE_PLAYING by calling player_start() or set to #PLAYER_STATE_PAUSED by calling player_pause(). + */ +int player_get_streaming_download_progress(player_h player, int *start, int *current); + +/** + * @brief Registers a callback function to be invoked when the playback is finished. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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 + * @post player_completed_cb() will be invoked. + * @see player_unset_completed_cb() + * @see player_completed_cb() + * @see player_start() + */ +int player_set_completed_cb(player_h player, player_completed_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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_set_completed_cb() + */ +int player_unset_completed_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when the playback is interrupted or the interrupt is completed. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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 + * @post player_interrupted_cb() will be invoked. + * @see player_unset_interrupted_cb() + * @see #player_interrupted_code_e + * @see player_interrupted_cb() + */ +int player_set_interrupted_cb(player_h player, player_interrupted_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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_set_interrupted_cb() + */ +int player_unset_interrupted_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when an error occurs. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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 + * @post player_error_cb() will be invoked. + * @see player_unset_error_cb() + * @see player_error_cb() + */ +int player_set_error_cb(player_h player, player_error_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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_set_error_cb() + */ +int player_unset_error_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when there is a change in the buffering status of a media stream. + * @since_tizen 2.3.1 + * @remarks The media resource should be streamed over the network. + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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 + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature + * @post player_buffering_cb() will be invoked. + * @see player_unset_buffering_cb() + * @see player_set_uri() + * @see player_buffering_cb() + */ +int player_set_buffering_cb(player_h player, player_buffering_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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_set_buffering_cb() + */ +int player_unset_buffering_cb(player_h player); + +/** + * @brief Sets a path to download, progressively. + * @since_tizen 2.3.1 + * @remarks Progressive download will be started when you invoke player_start(). + * @param[in] player The handle to the media player + * @param[in] path The absolute path to download + * @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 + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @see player_set_progressive_download_message_cb() + * @see player_unset_progressive_download_message_cb() + */ +int player_set_progressive_download_path(player_h player, const char *path); + +/** + * @brief Gets the status of progressive download. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[out] current The current download position (bytes) + * @param[out] total_size The total size of the file (bytes) + * @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 progressive download path must be set by calling player_set_progressive_download_path(). + * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling player_start() or set to #PLAYER_STATE_PAUSED by calling player_pause(). + */ +int player_get_progressive_download_status(player_h player, unsigned long *current, unsigned long *total_size); + +/** + * @brief Registers a callback function to be invoked when progressive download is started or completed. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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 + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature + * @pre The path to download must be set by calling player_set_progressive_download_path(). + * @post player_pd_message_cb() will be invoked. + * @see player_unset_progressive_download_message_cb() + * @see player_set_progressive_download_path() + */ +int player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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_set_progressive_download_message_cb() + */ +int player_unset_progressive_download_message_cb(player_h player); + +/** + * @brief Sets the playback rate. + * @since_tizen 2.3.1 + * @details The default value is @c 1.0. + * @remarks #PLAYER_ERROR_INVALID_OPERATION occurs when streaming playback. + * @remarks No operation is performed, if @a rate is @c 0. + * @remarks The sound is muted, when playback rate is under @c 0.0 and over @c 2.0. + * @param[in] player The handle to the media player + * @param[in] rate The playback rate (-5.0x ~ 5.0x) + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling player_start(). + * @pre The player state must be set to #PLAYER_STATE_READY by calling player_prepare() or set to #PLAYER_STATE_PLAYING by calling player_start() or set to #PLAYER_STATE_PAUSED by calling player_pause(). + */ +int player_set_playback_rate(player_h player, float rate); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_SUBTITLE_MODULE + * @{ + */ + +/** + * @brief Sets a subtitle path. + * @since_tizen 2.3.1 + * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported. + * @param[in] player The handle to the media player + * @param[in] path The absolute path of the subtitle file, it can be @c NULL in the #PLAYER_STATE_IDLE state. + * @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. + * @pre The path value can be @c NULL for reset when the player state is set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + */ +int player_set_subtitle_path(player_h player,const char *path); + +/** + * @brief Registers a callback function to be invoked when a subtitle updates. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @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 + * @pre The subtitle must be set by calling player_set_subtitle_path(). + * @post player_subtitle_updated_cb() will be invoked. + * @see player_unset_subtitle_updated_cb() + * @see player_subtitle_updated_cb() + * @see player_set_subtitle_path() + */ +int player_set_subtitle_updated_cb(player_h player, player_subtitle_updated_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.3.1 + * @param[in] player The handle to the media player + * @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_set_subtitle_updated_cb() + */ +int player_unset_subtitle_updated_cb(player_h player); + +/** + * @brief Sets the seek position for the subtitle. + * @since_tizen 2.3.1 + * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported. + * @param[in] player The handle to the media player + * @param[in] millisecond The position in milliseconds from the start to the seek point + * @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 subtitle must be set by calling player_set_subtitle_path(). + * @pre The player state must be one of these: #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED. + */ +int player_set_subtitle_position_offset(player_h player, int millisecond); + +/** + * @brief Registers a callback function to be invoked when video stream is changed. + * @since_tizen 2.4 + * @remarks The stream changing is detected just before rendering operation. + * @param[in] player The handle to the media player + * @param[in] callback The stream changed callback function to register + * @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_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_video_stream_changed_cb() will be invoked. + * @see player_unset_video_stream_changed_cb() + * @see player_video_stream_changed_cb() + */ +int player_set_video_stream_changed_cb (player_h player, player_video_stream_changed_cb callback, void *user_data); + +/** + * @brief Unregisters the video stream changed callback function. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_video_stream_changed_cb() + */ +int player_unset_video_stream_changed_cb (player_h player); + +/** + * @brief Registers a callback function to be invoked when audio stream is changed. + * @since_tizen 2.4 + * @remarks The stream changing is detected just before rendering operation. + * @param[in] player The handle to the media player + * @param[in] callback The stream changed callback function to register + * @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_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare(). + * @post player_audio_stream_changed_cb() will be invoked. + * @see player_unset_audio_stream_changed_cb() + * @see player_audio_stream_changed_cb() + */ +int player_set_audio_stream_changed_cb (player_h player, player_audio_stream_changed_cb callback, void *user_data); + +/** + * @brief Unregisters the audio stream changed callback function. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_audio_stream_changed_cb() + */ +int player_unset_audio_stream_changed_cb (player_h player); + +/** + * @brief Gets current track index. + * @since_tizen 2.4 + * @details Index starts from 0. + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] index The index of track + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + */ +int player_get_current_track(player_h player, player_stream_type_e type, int *index); + +/** + * @brief Gets language code of a track. + * @since_tizen 2.4 + * @remarks @a code must be released with @c free() by caller + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] index The index of track + * @param[out] code A language code in ISO 639-1. "und" will be returned if the language is undefined. + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + */ +int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **code); + +/** + * @brief Gets the track count. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[out] count The number of track + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + */ +int player_get_track_count(player_h player, player_stream_type_e type, int *count); + +/** + * @brief Selects a track to play. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] type The type of target stream + * @param[in] index The index of track + * @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 + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED + * @see player_get_current_track() + */ +int player_select_track(player_h player, player_stream_type_e type, int index); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MEDIA_PLAYER_H__ */ diff --git a/include/wearable/player_internal.h b/include/wearable/player_internal.h new file mode 100644 index 0000000..6ed62e2 --- /dev/null +++ b/include/wearable/player_internal.h @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __TIZEN_MEDIA_PLAYER_INTERNAL_H__ +#define __TIZEN_MEDIA_PLAYER_INTERNAL_H__ +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file player_internal.h + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief This file contains the media player API for custom features. + * @since_tizen 2.4 + */ +typedef struct +{ + void *data; /**< PCM data */ + int size; /**< Data Size */ + int channel; /**< Channel */ + int rate; /**< Samplerate */ + int depth; /**< Depth */ + bool little_endian; /**< Endianness */ + guint64 channel_mask; /**< channel_mask */ +} player_audio_raw_data_s; + +/** + * @brief Called when the audio frame is decoded. + * @since_tizen 2.4 + * @param[in] audio_raw_frame The decoded audio frame data type + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_audio_frame_decoded_cb() + * @see player_unset_audio_frame_decoded_cb() + */ +typedef void (*player_audio_pcm_extraction_cb)(player_audio_raw_data_s *audio_raw_frame, void *user_data); + + +/** + * @brief Registers a callback function to be invoked when audio frame is decoded. Audio only contents is possible. If included video, error happens. + * @since_tizen 2.4 + * @param[in] player The handle to the media player + * @param[in] sync Sync on the clock + * @param[in] callback The callback function to register + * @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 + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_NOT_SUPPORTD Not supported + * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @post player_audio_pcm_extraction_cb() will be invoked. + * @see player_unset_audio_frame_decoded_cb_ex() + */ +int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif + +#endif //__TIZEN_MEDIA_PLAYER_PRODUCT_H__ + + diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index 25d1f7f..c247978 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -3,8 +3,8 @@ Name: capi-media-player Summary: A Media Player library in Tizen Native API -Version: 0.1.3 -Release: 2 +Version: 0.2.3 +Release: 0 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -28,6 +28,8 @@ BuildRequires: pkgconfig(ecore-wayland) %endif BuildRequires: pkgconfig(capi-media-tool) BuildRequires: pkgconfig(libtbm) +#BuildRequires: pkgconfig(ttrace) +BuildRequires: pkgconfig(capi-system-info) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -58,16 +60,23 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" %endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ +%if "%{?profile}" == "wearable" + -DTIZEN_WEARABLE=YES \ + %else + -DTIZEN_MOBILE=YES \ + %endif %if %{with wayland} - -DWAYLAND_SUPPORT=On \ + -DWAYLAND_SUPPORT=On \ %else - -DWAYLAND_SUPPORT=Off \ + -DWAYLAND_SUPPORT=Off \ %endif %if %{with x} - -DX11_SUPPORT=On + -DX11_SUPPORT=On \ %else - -DX11_SUPPORT=Off + -DX11_SUPPORT=Off \ %endif + -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ + -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} @@ -78,6 +87,7 @@ mkdir -p %{buildroot}/usr/bin cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} cp test/player_test %{buildroot}/usr/bin cp test/player_media_packet_test %{buildroot}/usr/bin +cp test/player_es_push_test %{buildroot}/usr/bin %make_install diff --git a/src/player.c b/src/player.c index 2dfa3f3..51a5916 100755 --- a/src/player.c +++ b/src/player.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #define __JOB_KEY_PREPARED "prepared" #define __JOB_KEY_ERROR "error" @@ -48,6 +48,19 @@ } \ }while(0) +#ifndef USE_ECORE_FUNCTIONS +#define __RELEASEIF_MESSAGE_THREAD(thread_id) \ + do { \ + if (thread_id) \ + { \ + pthread_join(thread_id, NULL); \ + thread_id = 0; \ + LOGI("message thread released\n"); \ + } \ + }while(0) +#endif + +#ifdef USE_ECORE_FUNCTIONS #define __DELETE_ECORE_ITEM(ecore_job) \ do { \ if (ecore_job) \ @@ -74,6 +87,39 @@ g_hash_table_remove(handle->ecore_jobs, job_key); \ handle->is_doing_jobs = FALSE; \ } while(0) +#else +#define __GET_MESSAGE(handle) \ + do { \ + if(handle && handle->message_queue){ \ + g_mutex_lock (&handle->message_queue_lock); \ + if(g_queue_is_empty (handle->message_queue)) \ + { \ + g_cond_wait (&handle->message_queue_cond,&handle->message_queue_lock); \ + } \ + handle->current_message = (int)g_queue_pop_head (handle->message_queue); \ + g_mutex_unlock (&handle->message_queue_lock); \ + LOGI("Retrived message [%d] from queue",handle->current_message); \ + }else{ \ + LOGI("Failed to retrive message from queue"); \ + handle->current_message = PLAYER_MESSAGE_NONE; \ + } \ + }while(0) + +#define __ADD_MESSAGE(handle, message) \ + do { \ + if(handle && handle->message_queue){ \ + g_mutex_lock (&handle->message_queue_lock); \ + if(message==PLAYER_MESSAGE_LOOP_EXIT) \ + g_queue_clear(handle->message_queue); \ + g_queue_push_tail (handle->message_queue,(gpointer)message); \ + g_cond_signal (&handle->message_queue_cond); \ + g_mutex_unlock (&handle->message_queue_lock); \ + LOGI("Adding message [%d] to queue", message); \ + }else{\ + LOGI("Failed to add message [%d] to queue", message); \ + }\ + }while(0) +#endif /* * Internal Implementation @@ -345,11 +391,7 @@ int _player_media_packet_finalize(media_packet_h pkt, int error_code, void *user } /*LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret);*/ - - if (internal_buffer) { - gst_buffer_unref((GstBuffer *)internal_buffer); - internal_buffer = NULL; - } + mm_player_media_packet_video_stream_internal_buffer_unref(internal_buffer); ret = media_packet_get_tbm_surface(pkt, &tsurf); if (ret != MEDIA_PACKET_ERROR_NONE) { @@ -424,6 +466,8 @@ static int __set_callback(_player_event_e type, player_h player, void* callback, PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); player_s * handle = (player_s *) player; + if (_PLAYER_EVENT_TYPE_BUFFERING == type) + PLAYER_NETWORK_AVAILABLE_CHECK(); handle->user_cb[type] = callback; handle->user_data[type] = user_data; LOGI("[%s] Event type : %d ",__FUNCTION__, type); @@ -440,6 +484,7 @@ static int __unset_callback(_player_event_e type, player_h player) return PLAYER_ERROR_NONE; } +#ifdef USE_ECORE_FUNCTIONS static void __job_prepared_cb(void *user_data) { player_s * handle = (player_s*)user_data; @@ -484,6 +529,96 @@ static void __job_eos_cb(void *user_data) __REMOVE_ECORE_JOB(handle, __JOB_KEY_EOS); LOGI("End"); } +#else +static void __message_cb_loop(void *data) +{ + bool running = TRUE; + player_s * handle = (player_s*)data; + if(!handle){ + LOGE("null handle in __message_cb_loop"); + return; + } + do{ + __GET_MESSAGE(handle); + switch(handle->current_message){ + case PLAYER_MESSAGE_NONE: + { + LOGW("PLAYER_MESSAGE_NONE"); + running = FALSE; + } + break; + case PLAYER_MESSAGE_PREPARED: + { + LOGW("PLAYER_MESSAGE_PREPARED"); + if(handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]){ + handle->is_doing_jobs = TRUE; + handle->state = PLAYER_STATE_READY; + ((player_prepared_cb)handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[_PLAYER_EVENT_TYPE_PREPARE]); + handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_PREPARE] = NULL; + handle->is_doing_jobs = FALSE; + }else{ + LOGE("null handle in PLAYER_MESSAGE_PREPARED"); + } + } + break; + case PLAYER_MESSAGE_ERROR: + { + LOGW("PLAYER_MESSAGE_ERROR"); + if(handle->user_cb[_PLAYER_EVENT_TYPE_ERROR]){ + handle->is_doing_jobs = TRUE; + ((player_error_cb)handle->user_cb[_PLAYER_EVENT_TYPE_ERROR])(handle->error_code,handle->user_data[_PLAYER_EVENT_TYPE_ERROR]); + handle->is_doing_jobs = FALSE; + }else{ + LOGE("null handle in PLAYER_MESSAGE_ERROR"); + } + } + break; + case PLAYER_MESSAGE_SEEK_DONE: + { + LOGW("PLAYER_MESSAGE_SEEK_DONE"); + if(handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]){ + handle->is_doing_jobs = TRUE; + ((player_seek_completed_cb)handle->user_cb[_PLAYER_EVENT_TYPE_SEEK])(handle->user_data[_PLAYER_EVENT_TYPE_SEEK]); + handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = NULL; + handle->is_doing_jobs = FALSE; + }else{ + LOGE("null handle in PLAYER_MESSAGE_SEEK_DONE"); + } + } + break; + case PLAYER_MESSAGE_EOS: + { + LOGW("PLAYER_MESSAGE_EOS"); + if(handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE]){ + handle->is_doing_jobs = TRUE; + ((player_completed_cb)handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[_PLAYER_EVENT_TYPE_COMPLETE]); + handle->is_doing_jobs = FALSE; + }else{ + LOGE("null handle in PLAYER_MESSAGE_EOS"); + } + } + break; + case PLAYER_MESSAGE_LOOP_EXIT: + { + LOGW("PLAYER_MESSAGE_LOOP_EXIT"); + running = FALSE; + } + break; + case PLAYER_MESSAGE_MAX: + { + LOGW("PLAYER_MESSAGE_MAX"); + running = FALSE; + } + break; + default: + break; + } + }while(running); + return; +} +#endif static int __msg_callback(int message, void *param, void *user_data) { @@ -504,7 +639,12 @@ static int __msg_callback(int message, void *param, void *user_data) if(handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) // asyc && prepared cb has been set { LOGI("[%s] Prepared! [current state : %d]", __FUNCTION__, handle->state); + PLAYER_TRACE_ASYNC_END("MM:PLAYER:PREPARE_ASYNC", *(int *)handle); +#ifdef USE_ECORE_FUNCTIONS __ADD_ECORE_JOB(handle, __JOB_KEY_PREPARED, __job_prepared_cb); +#else + __ADD_MESSAGE(handle,PLAYER_MESSAGE_PREPARED); +#endif } } break; @@ -520,7 +660,11 @@ static int __msg_callback(int message, void *param, void *user_data) case MM_MESSAGE_END_OF_STREAM://0x105 if( handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE] ) { +#ifdef USE_ECORE_FUNCTIONS __ADD_ECORE_JOB(handle, __JOB_KEY_EOS, __job_eos_cb); +#else + __ADD_MESSAGE(handle,PLAYER_MESSAGE_EOS); +#endif } break; case MM_MESSAGE_BUFFERING: //0x103 @@ -623,7 +767,11 @@ static int __msg_callback(int message, void *param, void *user_data) } if( handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) { +#ifdef USE_ECORE_FUNCTIONS __ADD_ECORE_JOB(handle, __JOB_KEY_SEEK_DONE, __job_seek_done_cb); +#else + __ADD_MESSAGE(handle,PLAYER_MESSAGE_SEEK_DONE); +#endif } break; case MM_MESSAGE_UNKNOWN: //0x00 @@ -644,7 +792,11 @@ static int __msg_callback(int message, void *param, void *user_data) if(err_code != PLAYER_ERROR_NONE && handle->user_cb[_PLAYER_EVENT_TYPE_ERROR]) { handle->error_code = err_code; +#ifdef USE_ECORE_FUNCTIONS __ADD_ECORE_JOB(handle, __JOB_KEY_ERROR, __job_error_cb); +#else + __ADD_MESSAGE(handle,PLAYER_MESSAGE_ERROR); +#endif } LOGW("[%s] End", __FUNCTION__); return 1; @@ -678,14 +830,35 @@ static bool __video_stream_callback(void *stream, void *user_data) ret |= _player_get_media_packet_mimetype(video_stream->format, &mimetype); if (bo_num > 0 && ret == PLAYER_ERROR_NONE) { - tsurf = tbm_surface_internal_create_with_bos(video_stream->width, video_stream->height, bo_format, (tbm_bo *)video_stream->bo, bo_num); + tbm_surface_info_s info; + memset(&info, 0, sizeof(tbm_surface_info_s)); + info.width = video_stream->width; + info.height = video_stream->height; + info.format = bo_format; + info.bpp = tbm_surface_internal_get_bpp(bo_format); + info.num_planes = tbm_surface_internal_get_num_planes(bo_format); + info.size = 0; + for(i = 0; i < info.num_planes; i++) { + info.planes[i].stride = video_stream->stride[i]; + info.planes[i].size = video_stream->stride[i] * video_stream->elevation[i]; + if(i < bo_num) + info.planes[i].offset = 0; + else + info.planes[i].offset = info.planes[i - 1].size; + info.size += info.planes[i].size; + } + tsurf = tbm_surface_internal_create_with_bos(&info , + (tbm_bo *)video_stream->bo, bo_num); /*LOGD("tbm surface %p", tsurf);*/ } else if (bo_num == 0) { int plane_idx = 0; tbm_surface_info_s tsuri; - unsigned char *ptr = video_stream->data; + unsigned char *ptr = video_stream->data[0]; + unsigned char *ptr2 = video_stream->data[1]; if (!ptr) return TRUE; + if (!ptr2 && video_stream->format == MM_PIXEL_FORMAT_NV12T) + return TRUE; tsurf = tbm_surface_create(video_stream->width, video_stream->height, bo_format); if (tsurf) { @@ -695,9 +868,15 @@ static bool __video_stream_callback(void *stream, void *user_data) return TRUE; } - for ( plane_idx = 0; plane_idx < tsuri.num_planes; plane_idx++ ) { - memcpy(tsuri.planes[plane_idx].ptr, ptr, tsuri.planes[plane_idx].size); - ptr += tsuri.planes[plane_idx].size; + if (video_stream->format == MM_PIXEL_FORMAT_NV12T) { + memcpy(tsuri.planes[0].ptr, ptr, tsuri.planes[0].size); + memcpy(tsuri.planes[1].ptr, ptr2, tsuri.planes[1].size); + } + else { + for ( plane_idx = 0; plane_idx < tsuri.num_planes; plane_idx++ ) { + memcpy(tsuri.planes[plane_idx].ptr, ptr, tsuri.planes[plane_idx].size); + ptr += tsuri.planes[plane_idx].size; + } } } else { LOGW("tbm_surface_create failed"); @@ -711,12 +890,14 @@ static bool __video_stream_callback(void *stream, void *user_data) int pkt_fmt_height = 0; media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12; - media_format_get_video_info(handle->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL); + media_format_get_video_info(handle->pkt_fmt, &pkt_fmt_mimetype, + &pkt_fmt_width, &pkt_fmt_height, NULL, NULL); if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != video_stream->width || pkt_fmt_height != video_stream->height) { LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d", - pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, video_stream->width, video_stream->height); + pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, + video_stream->width, video_stream->height); media_format_unref(handle->pkt_fmt); handle->pkt_fmt = NULL; make_pkt_fmt = true; @@ -727,7 +908,8 @@ static bool __video_stream_callback(void *stream, void *user_data) /* create packet format */ if (make_pkt_fmt) { - LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, video_stream->width, video_stream->height); + LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, + video_stream->width, video_stream->height); ret = media_format_create(&handle->pkt_fmt); if (ret == MEDIA_FORMAT_ERROR_NONE) { ret = media_format_set_video_mime(handle->pkt_fmt, mimetype); @@ -748,7 +930,8 @@ static bool __video_stream_callback(void *stream, void *user_data) tsurf = NULL; } } else { - LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d", video_stream->width, video_stream->height, video_stream->format, bo_num); + LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d", + video_stream->width, video_stream->height, video_stream->format, bo_num); } if (pkt) { @@ -764,9 +947,8 @@ static bool __video_stream_callback(void *stream, void *user_data) media_packet_destroy(pkt); pkt = NULL; } else { - /* increase ref count of gst buffer */ - if (video_stream->internal_buffer) - gst_buffer_ref((GstBuffer *)video_stream->internal_buffer); + mm_player_media_packet_video_stream_internal_buffer_ref( + video_stream->internal_buffer); /* call media packet callback */ ((player_media_packet_video_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME])(pkt, handle->user_data[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]); @@ -801,6 +983,8 @@ static int __pd_message_callback(int message, void *param, void *user_data) } return 0; } + +#ifdef USE_ECORE_FUNCTIONS static void __job_key_to_remove(gpointer key) { LOGI("%s",key); @@ -813,6 +997,7 @@ static void __job_value_to_destroy(gpointer value) LOGI("%p", job); __DELETE_ECORE_ITEM(job); } +#endif /* * Public Implementation @@ -821,6 +1006,7 @@ static void __job_value_to_destroy(gpointer value) int player_create (player_h *player) { PLAYER_INSTANCE_CHECK(player); + PLAYER_TRACE_BEGIN("MM:PLAYER:CREATE"); player_s * handle; handle = (player_s*)malloc( sizeof(player_s)); if (handle != NULL) @@ -846,8 +1032,21 @@ int player_create (player_h *player) handle->display_type = MM_DISPLAY_SURFACE_NULL; // means DISPLAY_TYPE_NONE(3) handle->is_stopped=false; handle->is_display_visible=true; +#ifdef USE_ECORE_FUNCTIONS handle->ecore_jobs = g_hash_table_new_full(g_str_hash, g_str_equal, __job_key_to_remove, __job_value_to_destroy); +#else + handle->message_queue = g_queue_new (); + g_mutex_init(&handle->message_queue_lock); + g_cond_init(&handle->message_queue_cond); + ret = pthread_create(&handle->message_thread, NULL,(void *)__message_cb_loop, (void *)handle); + if (ret != 0) + { + LOGE("[%s] failed to create message thread ret = %d", __FUNCTION__, ret); + return PLAYER_ERROR_OUT_OF_MEMORY; + } +#endif LOGI("[%s] new handle : %p", __FUNCTION__, *player); + PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } } @@ -855,6 +1054,7 @@ int player_create (player_h *player) int player_destroy (player_h player) { LOGI("[%s] Start, handle to destroy : %p", __FUNCTION__, player); + PLAYER_TRACE_BEGIN("MM:PLAYER:DESTROY"); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; if (handle->is_doing_jobs) @@ -862,12 +1062,19 @@ int player_destroy (player_h player) LOGE("jobs not completed. can't do destroy"); return PLAYER_ERROR_INVALID_OPERATION; } - +#ifdef USE_ECORE_FUNCTIONS g_hash_table_remove_all(handle->ecore_jobs); g_hash_table_unref(handle->ecore_jobs); - + handle->ecore_jobs = NULL; +#else + __ADD_MESSAGE(handle,PLAYER_MESSAGE_LOOP_EXIT); +#endif __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread); +#ifndef USE_ECORE_FUNCTIONS + __RELEASEIF_MESSAGE_THREAD(handle->message_thread); +#endif + int ret = mm_player_destroy(handle->mm_handle); if (handle->pkt_fmt) { @@ -885,9 +1092,20 @@ int player_destroy (player_h player) else { handle->state = PLAYER_STATE_NONE; +#ifndef USE_ECORE_FUNCTIONS + if(handle->message_queue){ + g_queue_free (handle->message_queue); + handle->message_queue = NULL; + } + + g_cond_broadcast(&handle->message_queue_cond); + g_mutex_clear(&handle->message_queue_lock); + g_cond_clear(&handle->message_queue_cond); +#endif free(handle); handle= NULL; LOGI("[%s] End", __FUNCTION__); + PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } } @@ -922,6 +1140,7 @@ int player_prepare_async (player_h player, player_prepared_cb callback, void* us LOGI("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; + PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle); PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); int ret; @@ -1003,6 +1222,7 @@ int player_prepare_async (player_h player, player_prepared_cb callback, void* us int player_prepare (player_h player) { LOGI("[%s] Start", __FUNCTION__); + PLAYER_TRACE_BEGIN("MM:PLAYER:PREPARE"); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); @@ -1072,6 +1292,7 @@ int player_prepare (player_h player) { handle->state = PLAYER_STATE_READY; LOGI("[%s] End", __FUNCTION__); + PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } } @@ -1079,6 +1300,7 @@ int player_prepare (player_h player) int player_unprepare (player_h player) { LOGI("[%s] Start", __FUNCTION__); + PLAYER_TRACE_BEGIN("MM:PLAYER:UNPREPARE"); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; @@ -1117,6 +1339,7 @@ int player_unprepare (player_h player) handle->is_display_visible=true; handle->is_progressive_download=false; LOGI("[%s] End", __FUNCTION__); + PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } } @@ -1138,58 +1361,6 @@ int player_set_uri (player_h player, const char *uri) return PLAYER_ERROR_NONE; } -int player_set_next_uri (player_h player, const char *uri) -{ - PLAYER_INSTANCE_CHECK(player); - player_s * handle = (player_s *) player; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) - { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); - return PLAYER_ERROR_INVALID_STATE; - } - - int ret = mm_player_set_next_uri(handle->mm_handle, uri); - - if(ret != MM_ERROR_NONE) - { - return __player_convert_error_code(ret,(char*)__FUNCTION__); - } - else - return PLAYER_ERROR_NONE; -} - -int player_get_next_uri (player_h player, char **uri) -{ - PLAYER_INSTANCE_CHECK(player); - player_s * handle = (player_s *) player; - char* next_uri = NULL; - - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) - { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); - return PLAYER_ERROR_INVALID_STATE; - } - - int ret = mm_player_get_next_uri(handle->mm_handle, &next_uri); - - if(ret != MM_ERROR_NONE) - { - return __player_convert_error_code(ret,(char*)__FUNCTION__); - } - else - { - *uri = NULL; - if(next_uri != NULL) - { - *uri = strdup(next_uri); - free(next_uri); - } - - next_uri = NULL; - return PLAYER_ERROR_NONE; - } -} - int player_set_memory_buffer (player_h player, const void *data, int size) { PLAYER_INSTANCE_CHECK(player); @@ -1267,11 +1438,7 @@ int player_set_sound_type(player_h player, sound_type_e type) PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) - { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); - return PLAYER_ERROR_INVALID_STATE; - } + PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); int ret = mm_player_set_attribute(handle->mm_handle, NULL,"sound_volume_type" , type, (char*)NULL); if(ret != MM_ERROR_NONE) @@ -1315,7 +1482,11 @@ int player_start (player_h player) int ret; if ( handle->state ==PLAYER_STATE_READY || handle->state ==PLAYER_STATE_PAUSED) { - if(handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS) + if(handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY +#ifdef TIZEN_MOBILE + || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS +#endif + ) { if(handle->is_display_visible) { @@ -1370,7 +1541,11 @@ int player_stop (player_h player) { int ret = mm_player_stop(handle->mm_handle); - if(handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS) + if(handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY +#ifdef TIZEN_MOBILE + || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS +#endif + ) { ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , 0, (char*)NULL); } @@ -1420,47 +1595,6 @@ int player_pause (player_h player) } } -int player_set_position (player_h player, int millisecond, player_seek_completed_cb callback, void *user_data) -{ - PLAYER_INSTANCE_CHECK(player); - PLAYER_CHECK_CONDITION(millisecond>=0 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); - player_s * handle = (player_s *) player; - if (!__player_state_validate(handle, PLAYER_STATE_READY)) - { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); - return PLAYER_ERROR_INVALID_STATE; - } - - if(handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) - { - LOGE("[%s] PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_SEEK_FAILED); - return PLAYER_ERROR_SEEK_FAILED; - } - else - { - LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_SEEK); - handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = callback; - handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = user_data; - } - int ret = mm_player_set_attribute(handle->mm_handle, NULL, "accurate_seek", 1, (char*)NULL); - if(ret != MM_ERROR_NONE) - { - return __player_convert_error_code(ret,(char*)__FUNCTION__); - } - - ret = mm_player_set_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond); - if(ret != MM_ERROR_NONE) - { - handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = NULL; - handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = NULL; - return __player_convert_error_code(ret,(char*)__FUNCTION__); - } - else - { - return PLAYER_ERROR_NONE; - } -} - int player_set_play_position (player_h player, int millisecond, bool accurate, player_seek_completed_cb callback, void *user_data) { PLAYER_INSTANCE_CHECK(player); @@ -1629,7 +1763,7 @@ int player_get_duration (player_h player, int *duration) PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(duration); player_s * handle = (player_s *) player; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + if (!__player_state_validate(handle, PLAYER_STATE_READY)) { LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; @@ -1734,6 +1868,7 @@ int player_set_display(player_h player, player_display_type_e type, player_displ set_handle = &(handle->display_handle); #endif } +#ifdef TIZEN_MOBILE else if (type == PLAYER_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) { /* evas object surface */ @@ -1741,6 +1876,7 @@ int player_set_display(player_h player, player_display_type_e type, player_displ handle->display_handle = display; set_handle = display; } +#endif else { LOGE("invalid surface type"); @@ -1799,6 +1935,11 @@ int player_set_display(player_h player, player_display_type_e type, player_displ } else //changing surface case { + if (handle->state >= PLAYER_STATE_READY) + { + LOGE("[%s] it is not available to change display surface from %d to %d",__FUNCTION__, handle->display_type, type); + return PLAYER_ERROR_INVALID_OPERATION; + } ret = mm_player_change_videosink(handle->mm_handle, type, set_handle); if (ret != MM_ERROR_NONE) { @@ -2011,7 +2152,7 @@ int player_get_content_info(player_h player, player_content_info_e key, char ** attr = MM_PLAYER_TAG_DATE; break; default: - attr=NULL; + attr=NULL; } int ret = mm_player_get_attribute(handle->mm_handle, NULL,attr ,&val, &val_len, (char*)NULL); @@ -2166,6 +2307,12 @@ int player_audio_effect_get_equalizer_bands_count (player_h player, int *count) PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(count); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_get_eq_bands_number(handle->mm_handle, count); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); @@ -2178,6 +2325,12 @@ int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_level PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(band_levels); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length); if(ret != MM_ERROR_NONE) { @@ -2194,6 +2347,12 @@ int player_audio_effect_set_equalizer_band_level(player_h player, int index, int { PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_set_level(handle->mm_handle,MM_AUDIO_EFFECT_CUSTOM_EQ, index, level); if(ret != MM_ERROR_NONE) { @@ -2211,6 +2370,12 @@ int player_audio_effect_get_equalizer_band_level(player_h player, int index, int PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(level); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_get_level(handle->mm_handle,MM_AUDIO_EFFECT_CUSTOM_EQ, index, level); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); @@ -2224,6 +2389,12 @@ int player_audio_effect_get_equalizer_level_range(player_h player, int* min, int PLAYER_NULL_ARG_CHECK(min); PLAYER_NULL_ARG_CHECK(max); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_get_level_range(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, min, max); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); @@ -2236,6 +2407,12 @@ int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(frequency); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_get_eq_bands_freq(handle->mm_handle, index, frequency); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); @@ -2248,6 +2425,12 @@ int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(range); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_get_eq_bands_width(handle->mm_handle, index, range); if(ret != MM_ERROR_NONE) return __player_convert_error_code(ret,(char*)__FUNCTION__); @@ -2259,6 +2442,12 @@ int player_audio_effect_equalizer_clear(player_h player) { PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_audio_effect_custom_clear_eq_all(handle->mm_handle); if(ret != MM_ERROR_NONE) { @@ -2276,6 +2465,12 @@ int player_audio_effect_equalizer_is_available(player_h player, bool *available) PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(available); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_is_supported_custom_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ); if(ret != MM_ERROR_NONE) *available = FALSE; @@ -2327,6 +2522,7 @@ int player_set_progressive_download_path(player_h player, const char *path) { PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(path); + PLAYER_NETWORK_AVAILABLE_CHECK(); player_s * handle = (player_s *) player; PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); @@ -2529,6 +2725,8 @@ int player_set_progressive_download_message_cb(player_h player, player_pd_messag { PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); + PLAYER_NETWORK_AVAILABLE_CHECK(); + player_s * handle = (player_s *) player; if (handle->state != PLAYER_STATE_IDLE && handle->state != PLAYER_STATE_READY) { @@ -2562,19 +2760,6 @@ int player_unset_progressive_download_message_cb(player_h player) return PLAYER_ERROR_NONE; } -int player_ignore_session(player_h player) -{ - PLAYER_INSTANCE_CHECK(player); - player_s * handle = (player_s *) player; - PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); - - int ret = MM_ERROR_NONE; //CHECK = mm_player_ignore_session(handle->mm_handle); - if(ret != MM_ERROR_NONE) - return __player_convert_error_code(ret,(char*)__FUNCTION__); - else - return PLAYER_ERROR_NONE; -} - int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data) { PLAYER_INSTANCE_CHECK(player); @@ -2614,3 +2799,638 @@ int player_unset_media_packet_video_frame_decoded_cb(player_h player) else return PLAYER_ERROR_NONE; } + +static bool __audio_stream_changed_callback (void *user_data) +{ + player_s * handle = (player_s*)user_data; + _player_event_e event_type = _PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED; + + LOGE("[%s] event type %d", __FUNCTION__, event_type); + + if(handle->user_cb[event_type]) + { + int sample_rate = 0, channel = 0, bit_rate = 0; + + int ret = mm_player_get_attribute(handle->mm_handle, NULL, + MM_PLAYER_AUDIO_SAMPLERATE, &sample_rate, + MM_PLAYER_AUDIO_CHANNEL, &channel, + MM_PLAYER_AUDIO_BITRATE, &bit_rate, (char*)NULL); + + if(ret != MM_ERROR_NONE) + { + LOGE("[%s] get attr is failed", __FUNCTION__); + return FALSE; + } + + ((player_audio_stream_changed_cb)handle->user_cb[event_type])(sample_rate, channel, bit_rate, handle->user_data[event_type]); + } + else + { + LOGE("[%s] audio stream changed cb was not set.", __FUNCTION__); + return FALSE; + } + + return TRUE; +} + +static bool __video_stream_changed_callback (void *user_data) +{ + player_s * handle = (player_s*)user_data; + _player_event_e event_type = _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED; + + LOGE("[%s] event type %d", __FUNCTION__, event_type); + + if(handle->user_cb[event_type]) + { + int width = 0, height = 0, fps = 0, bit_rate = 0; + int ret = mm_player_get_attribute(handle->mm_handle, NULL, + MM_PLAYER_VIDEO_WIDTH, &width, + MM_PLAYER_VIDEO_HEIGHT, &height, + "content_video_fps", &fps, + "content_video_bitrate", &bit_rate, (char*)NULL); + + if(ret != MM_ERROR_NONE) + { + LOGE("[%s] get attr is failed", __FUNCTION__); + return FALSE; + } + + ((player_video_stream_changed_cb)handle->user_cb[event_type])(width, height, fps, bit_rate, handle->user_data[event_type]); + } + else + { + LOGE("[%s] video stream changed cb was not set.", __FUNCTION__); + return FALSE; + } + + return TRUE; +} + +int player_set_audio_stream_changed_cb (player_h player, player_audio_stream_changed_cb callback, void *user_data) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + if (handle->state != PLAYER_STATE_IDLE ) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + ret = mm_player_set_audio_stream_changed_callback ( handle->mm_handle, + (mm_player_stream_changed_callback)__audio_stream_changed_callback, (void*)handle ); + + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + + return __set_callback(_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED, player, callback, user_data); +} + +int player_unset_audio_stream_changed_cb (player_h player) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + __unset_callback(_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED, player); + + ret = mm_player_set_audio_stream_changed_callback(handle->mm_handle, NULL, NULL); + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_set_video_stream_changed_cb (player_h player, player_video_stream_changed_cb callback, void *user_data) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + if (handle->state != PLAYER_STATE_IDLE ) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + ret = mm_player_set_video_stream_changed_callback ( handle->mm_handle, + (mm_player_stream_changed_callback)__video_stream_changed_callback, (void*)handle ); + + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + + return __set_callback(_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player, callback, user_data); +} + +int player_unset_video_stream_changed_cb (player_h player) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + __unset_callback(_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player); + + ret = mm_player_set_video_stream_changed_callback(handle->mm_handle, NULL, NULL); + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +static bool __media_stream_buffer_status_callback(player_stream_type_e type, + player_media_stream_buffer_status_e status, + void *user_data) +{ + player_s * handle = (player_s*)user_data; + _player_event_e event_type; + + if (type == PLAYER_STREAM_TYPE_AUDIO) + event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS; + else if (type == PLAYER_STREAM_TYPE_VIDEO) + event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS; + else + return FALSE; + + LOGE("[%s] event type %d", __FUNCTION__, event_type); + + if (handle->user_cb[event_type]) + { + ((player_media_stream_buffer_status_cb)handle->user_cb[event_type])(status, handle->user_data[event_type]); + } + else + { + LOGE("[%s][type:%d] buffer status cb was not set.", __FUNCTION__, type); + return FALSE; + } + + return TRUE; +} + +static bool __media_stream_seek_data_callback(player_stream_type_e type, + unsigned long long offset, + void *user_data) +{ + player_s * handle = (player_s*)user_data; + _player_event_e event_type; + + if (type == PLAYER_STREAM_TYPE_AUDIO) + event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK; + else if (type == PLAYER_STREAM_TYPE_VIDEO) + event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK; + else + return FALSE; + + LOGE("[%s] event type %d", __FUNCTION__, event_type); + + if(handle->user_cb[event_type]) + { + ((player_media_stream_seek_cb)handle->user_cb[event_type])(offset, handle->user_data[event_type]); + } + else + { + LOGE("[%s][type:%d] seek cb was not set.", __FUNCTION__, type); + return FALSE; + } + + return TRUE; +} + +int player_set_media_stream_buffer_status_cb ( player_h player, + player_stream_type_e type, + player_media_stream_buffer_status_cb callback, + void *user_data) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + if (handle->state != PLAYER_STATE_IDLE ) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + // the type can be expaned with default and text. + if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)" ,__FUNCTION__, type); + return PLAYER_ERROR_INVALID_PARAMETER; + } + + ret = mm_player_set_media_stream_buffer_status_callback ( handle->mm_handle, type, + (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback, (void*)handle ); + + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + + if (type == PLAYER_STREAM_TYPE_VIDEO) + return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player, callback, user_data); + else if (type == PLAYER_STREAM_TYPE_AUDIO) + return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player, callback, user_data); + else + return PLAYER_ERROR_INVALID_PARAMETER; +} + +int player_unset_media_stream_buffer_status_cb (player_h player, player_stream_type_e type) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + if (type == PLAYER_STREAM_TYPE_VIDEO) + __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player); + else if (type == PLAYER_STREAM_TYPE_AUDIO) + __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player); + else + return PLAYER_ERROR_INVALID_PARAMETER; + + ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, NULL, NULL); + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_set_media_stream_seek_cb (player_h player, + player_stream_type_e type, + player_media_stream_seek_cb callback, + void *user_data) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + if (handle->state != PLAYER_STATE_IDLE ) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + // the type can be expaned with default and text. + if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)" ,__FUNCTION__, type); + return PLAYER_ERROR_INVALID_PARAMETER; + } + + ret = mm_player_set_media_stream_seek_data_callback ( handle->mm_handle, type, + (mm_player_media_stream_seek_data_callback)__media_stream_seek_data_callback, (void*)handle ); + + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + + if (type == PLAYER_STREAM_TYPE_VIDEO) + return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player, callback, user_data); + else if (type == PLAYER_STREAM_TYPE_AUDIO) + return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player, callback, user_data); + else + return PLAYER_ERROR_INVALID_PARAMETER; +} + +int player_unset_media_stream_seek_cb (player_h player, player_stream_type_e type) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + if (type == PLAYER_STREAM_TYPE_VIDEO) + __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player); + else if (type == PLAYER_STREAM_TYPE_AUDIO) + __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player); + else + return PLAYER_ERROR_INVALID_PARAMETER; + + ret = mm_player_set_media_stream_seek_data_callback(handle->mm_handle, type, NULL, NULL); + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_push_media_stream(player_h player, media_packet_h packet) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + /**/ + PLAYER_CHECK_CONDITION(handle->error_code == PLAYER_ERROR_NONE, PLAYER_ERROR_NOT_SUPPORTED_FILE, "can't support this format"); + if (handle->state < PLAYER_STATE_IDLE || handle->state > PLAYER_STATE_PAUSED) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" , + __FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + + int ret = mm_player_submit_packet(handle->mm_handle, packet); + + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + if (type == PLAYER_STREAM_TYPE_VIDEO) + ret = mm_player_set_video_info(handle->mm_handle, format); + else if (type == PLAYER_STREAM_TYPE_AUDIO) + ret = mm_player_set_audio_info(handle->mm_handle, format); + else + return PLAYER_ERROR_INVALID_PARAMETER; + + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } + + return PLAYER_ERROR_NONE; +} + +int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + ret = mm_player_set_media_stream_buffer_max_size(handle->mm_handle, type, max_size); + + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *max_size) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(max_size); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + unsigned long long _max_size; + int ret = mm_player_get_media_stream_buffer_max_size(handle->mm_handle, type, &_max_size); + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *max_size = _max_size; + return PLAYER_ERROR_NONE; + } +} + +int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent) +{ + int ret; + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + ret = mm_player_set_media_stream_buffer_min_percent(handle->mm_handle, type, percent); + + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *percent) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(percent); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + unsigned int _value; + int ret = mm_player_get_media_stream_buffer_min_percent(handle->mm_handle, type, &_value); + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *percent = _value; + return PLAYER_ERROR_NONE; + } +} + +#if 0 +int player_set_subtitle_stream_info(player_h player, player_subtitle_stream_info_s *info) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret = mm_player_set_subtitle_info(handle->mm_handle, (MMPlayerSubtitleStreamInfo *)info); + + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } + + return PLAYER_ERROR_NONE; +} +#endif + +int player_get_track_count(player_h player, player_stream_type_e type, int *count) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(count); + player_s * handle = (player_s *) player; + + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + MMPlayerTrackType track_type = 0; + switch(type) + { + case PLAYER_STREAM_TYPE_AUDIO: + track_type = MM_PLAYER_TRACK_TYPE_AUDIO; + break; + case PLAYER_STREAM_TYPE_VIDEO: + track_type = MM_PLAYER_TRACK_TYPE_VIDEO; + break; + case PLAYER_STREAM_TYPE_TEXT: + track_type = MM_PLAYER_TRACK_TYPE_TEXT; + break; + default: + LOGE("invalid stream type %d", type); + return PLAYER_ERROR_INVALID_PARAMETER; + } + + int ret = mm_player_get_track_count(handle->mm_handle, track_type, count); + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} + +int player_get_current_track(player_h player, player_stream_type_e type, int *index) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(index); + player_s * handle = (player_s *) player; + + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + MMPlayerTrackType track_type = 0; + switch(type) + { + case PLAYER_STREAM_TYPE_AUDIO: + track_type = MM_PLAYER_TRACK_TYPE_AUDIO; + break; + case PLAYER_STREAM_TYPE_VIDEO: + track_type = MM_PLAYER_TRACK_TYPE_VIDEO; + break; + case PLAYER_STREAM_TYPE_TEXT: + track_type = MM_PLAYER_TRACK_TYPE_TEXT; + break; + default: + LOGE("invalid stream type %d", type); + return PLAYER_ERROR_INVALID_PARAMETER; + } + + int ret = mm_player_get_current_track(handle->mm_handle, track_type, index); + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} + +int player_select_track(player_h player, player_stream_type_e type, int index) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(index>=0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + MMPlayerTrackType track_type = 0; + switch(type) + { + case PLAYER_STREAM_TYPE_AUDIO: + track_type = MM_PLAYER_TRACK_TYPE_AUDIO; + break; + case PLAYER_STREAM_TYPE_VIDEO: + track_type = MM_PLAYER_TRACK_TYPE_VIDEO; + break; + case PLAYER_STREAM_TYPE_TEXT: + track_type = MM_PLAYER_TRACK_TYPE_TEXT; + break; + default: + LOGE("invalid stream type %d", type); + return PLAYER_ERROR_INVALID_PARAMETER; + } + + int ret = mm_player_select_track(handle->mm_handle, track_type, index); + if(ret != MM_ERROR_NONE) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} + +int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **code) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(code); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + char* language_code=NULL; + const int code_len=2; + MMPlayerTrackType track_type = 0; + switch(type) + { + case PLAYER_STREAM_TYPE_AUDIO: + track_type = MM_PLAYER_TRACK_TYPE_AUDIO; + break; + case PLAYER_STREAM_TYPE_VIDEO: + track_type = MM_PLAYER_TRACK_TYPE_VIDEO; + break; + case PLAYER_STREAM_TYPE_TEXT: + track_type = MM_PLAYER_TRACK_TYPE_TEXT; + break; + default: + LOGE("invalid stream type %d", type); + return PLAYER_ERROR_INVALID_PARAMETER; + } + + int ret = mm_player_get_track_language_code(handle->mm_handle, track_type, index, &language_code); + if(ret != MM_ERROR_NONE) + { + if(language_code!=NULL) + free(language_code); + + language_code=NULL; + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *code = NULL; + if(language_code!=NULL) + { + *code = strndup(language_code, code_len); + free(language_code); + } + else + *code = strndup("und", code_len); + + language_code=NULL; + return PLAYER_ERROR_NONE; + } +} diff --git a/src/player_internal.c b/src/player_internal.c new file mode 100755 index 0000000..c94a146 --- /dev/null +++ b/src/player_internal.c @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +/* +* Internal Macros +*/ +#define PLAYER_SET_CALLBACK(event_type, handle, callback, user_data) \ +do \ +{ \ + PLAYER_INSTANCE_CHECK(handle); \ + PLAYER_NULL_ARG_CHECK(callback); \ + handle->user_cb[event_type] = callback; \ + handle->user_data[event_type] = user_data; \ + LOGI("[%s] Event type : %d ",__FUNCTION__, event_type); \ +}while(0) \ + +bool __audio_stream_callback_ex(MMPlayerAudioStreamDataType *stream, void *user_data) +{ + player_s * handle = (player_s*)user_data; + if( handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] ) + { + if(handle->state==PLAYER_STATE_PLAYING || handle->state==PLAYER_STATE_PAUSED) + { + ((player_audio_pcm_extraction_cb)handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME])((player_audio_raw_data_s *)stream, handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME]); + } + else + { + LOGE("[%s] Skip stream - current state : %d", __FUNCTION__,handle->state); + } + } + return TRUE; +} + +int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction",TRUE, "pcm_extraction_start_msec", 0, "pcm_extraction_end_msec", 0, NULL); + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + + ret = mm_player_set_audio_stream_callback_ex(handle->mm_handle, sync, __audio_stream_callback_ex, (void*)handle); + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + + PLAYER_SET_CALLBACK(_PLAYER_EVENT_TYPE_AUDIO_FRAME, handle, callback, user_data); + return PLAYER_ERROR_NONE; +} + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 50f5c71..9caaf00 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(fw_test "${fw_name}-test") -INCLUDE_DIRECTORIES(../include) +INCLUDE_DIRECTORIES(../include/mobile) link_directories(${CMAKE_SOURCE_DIR}/../) IF(X11_SUPPORT) @@ -19,7 +19,7 @@ FOREACH(flag ${${fw_test}_CFLAGS}) ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib/gstreamer-0.10") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib/gstreamer-1.0") IF(WAYLAND_SUPPORT) ADD_DEFINITIONS("-DHAVE_WAYLAND") @@ -35,5 +35,6 @@ FOREACH(src ${sources}) MESSAGE("${src_name}") ADD_EXECUTABLE(${src_name} ${src}) TARGET_LINK_LIBRARIES(${src_name} capi-media-player ${${fw_test}_LDFLAGS}) + INSTALL(TARGETS ${src_name} DESTINATION bin) ENDFOREACH() diff --git a/test/player_es_push_test.c b/test/player_es_push_test.c new file mode 100755 index 0000000..3eeb47e --- /dev/null +++ b/test/player_es_push_test.c @@ -0,0 +1,589 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#define KEY_END "XF86Stop" +#define ES_FEEDING_PATH "es_buff://push_mode" +//#define ES_FEEDING_PATH "es_buff://pull_mode" + +#define ES_DEFAULT_DIR_PATH "/opt/usr/media/" +#define ES_DEFAULT_H264_VIDEO_PATH ES_DEFAULT_DIR_PATH"Simpsons.h264" +#define ES_DEFAULT_VIDEO_FORMAT_TYPE MEDIA_FORMAT_H264_SP +#define ES_DEFAULT_VIDEO_FORMAT_WIDTH 1280 +#define ES_DEFAULT_VIDEO_FORMAT_HEIGHT 544 +#define ES_DEFAULT_VIDEO_PTS_OFFSET 20000000 +#define ES_DEFAULT_NUMBER_OF_FEED 2000 + +unsigned char sps[100]; +unsigned char pps[100]; +unsigned char tmp_buf[1000000]; +static int sps_len, pps_len; + +#ifdef PACKAGE +#undef PACKAGE +#endif +#define PACKAGE "player_es_push_test" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "PLAYER_TEST" + +static int app_create(void *data); +static int app_reset(bundle *b, void *data); +static int app_resume(void *data); +static int app_pause(void *data); +static int app_terminate(void *data); + +struct appcore_ops ops = { + .create = app_create, + .terminate = app_terminate, + .pause = app_pause, + .resume = app_resume, + .reset = app_reset, +}; + +typedef struct appdata { + Evas_Object *win; + Evas_Object *rect; + player_h player_handle; + media_packet_h video_pkt; + media_format_h video_fmt; + FILE *file_src; + pthread_t feeding_thread_id; +} appdata_s; + +static void +win_delete_request_cb(void *data , Evas_Object *obj , void *event_info) +{ + elm_exit(); +} + +static Eina_Bool +keydown_cb(void *data , int type , void *event) +{ + //appdata_s *ad = data; + Ecore_Event_Key *ev = event; + + LOGD("start"); + + if (!strcmp(ev->keyname, KEY_END)) { + /* Let window go to hide state. */ + //elm_win_lower(ad->win); + LOGD("elm exit"); + elm_exit(); + + return ECORE_CALLBACK_DONE; + } + + LOGD("done"); + + return ECORE_CALLBACK_PASS_ON; +} + +static void win_del(void *data, Evas_Object *obj, void *event) +{ + elm_exit(); +} + +static Evas_Object* create_win(const char *name) +{ + Evas_Object *eo = NULL; + + eo = elm_win_add(NULL, name, ELM_WIN_BASIC); + if (eo) { + elm_win_title_set(eo, name); + elm_win_borderless_set(eo, EINA_TRUE); + evas_object_smart_callback_add(eo, "delete,request",win_del, NULL); + elm_win_autodel_set(eo, EINA_TRUE); + } + return eo; +} + +static Evas_Object *create_render_rect(Evas_Object *pParent) +{ + if(!pParent) { + return NULL; + } + + Evas *pEvas = evas_object_evas_get(pParent); + Evas_Object *pObj = evas_object_rectangle_add(pEvas); + if(pObj == NULL) { + return NULL; + } + + evas_object_size_hint_weight_set(pObj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_color_set(pObj, 0, 0, 0, 0); + evas_object_render_op_set(pObj, EVAS_RENDER_COPY); + evas_object_show(pObj); + elm_win_resize_object_add(pParent, pObj); + + return pObj; +} + +static void +create_base_gui(appdata_s *ad) +{ + /* Enable GLES Backened */ + elm_config_preferred_engine_set("opengl_x11"); + + /* Window */ + ad->win = create_win(PACKAGE);//elm_win_util_standard_add(PACKAGE, PACKAGE); + ad->rect = create_render_rect(ad->win); + /* This is not supported in 3.0 + elm_win_wm_desktop_layout_support_set(ad->win, EINA_TRUE);*/ + elm_win_autodel_set(ad->win, EINA_TRUE); + evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, ad); + + /* Show window after base gui is set up */ + elm_win_activate(ad->win); + evas_object_show(ad->win); +} + +static int app_create(void *data) +{ + /* Hook to take necessary actions before main event loop starts + Initialize UI resources and application's data + If this function returns true, the main loop of application starts + If this function returns false, the application is terminated */ + appdata_s *ad = data; + + LOGD("start"); + + create_base_gui(ad); + ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, keydown_cb, NULL); + + /* open test file*/ + ad->file_src = fopen(ES_DEFAULT_H264_VIDEO_PATH, "r"); + + LOGD("done"); + + return 0; +} + +static int app_pause(void *data) +{ + /* Take necessary actions when application becomes invisible. */ + appdata_s *ad = (appdata_s *)data; + int ret = PLAYER_ERROR_NONE; + + LOGD("start"); + + if (ad == NULL) { + LOGE("appdata is NULL"); + return -1; + } + + if (ad->player_handle == NULL) { + printf("player_handle is NULL"); + return -1; + } + + if (ad->feeding_thread_id) + { + pthread_join(ad->feeding_thread_id, NULL); + ad->feeding_thread_id = 0; + } + + player_unset_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO); + player_unset_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO); + player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO); + player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO); + + ret = player_unprepare(ad->player_handle); + if (ret != PLAYER_ERROR_NONE) { + printf("player_unprepare failed : 0x%x", ret); + return false; + } + + /* unref media format */ + if (ad->video_fmt) + media_format_unref(ad->video_fmt); + + fclose(ad->file_src); + + /* destroy player handle */ + ret = player_destroy(ad->player_handle); + if (ret != PLAYER_ERROR_NONE) { + printf("player_destroy failed : 0x%x", ret); + return false; + } + + ad->player_handle = NULL; + + LOGD("done"); + + return 0; +} + +static int app_resume(void *data) +{ + LOGD("start"); + + LOGD("done"); + + return 0; +} + +static void _player_prepared_cb(void *user_data) +{ + int ret = PLAYER_ERROR_NONE; + appdata_s *ad = (appdata_s *)user_data; + + LOGD("prepared"); + + ret = player_start(ad->player_handle); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player start failed : 0x%x", ret); + } + LOGD("done"); +} + +unsigned int bytestream2nalunit(FILE *fd, unsigned char* nal) +{ + int nal_length = 0; + size_t result; + int read_size = 1; + unsigned char buffer[1000000]; + unsigned char val, zero_count, i; + int nal_unit_type = 0; + int init; + + zero_count = 0; + if (feof(fd)) + return -1; + + result = fread(buffer, 1, read_size, fd); + + if(result != read_size) + { + //exit(1); + return -1; + } + val = buffer[0]; + while (!val) + { + if ((zero_count == 2 || zero_count == 3) && val == 1) + { + break; + } + zero_count++; + result = fread(buffer, 1, read_size, fd); + + if(result != read_size) + { + break; + } + val = buffer[0]; + } + nal[nal_length++] = 0; + nal[nal_length++] = 0; + nal[nal_length++] = 0; + nal[nal_length++] = 1; + zero_count = 0; + init = 1; + while(1) + { + if (feof(fd)) + return nal_length; + + result = fread(buffer, 1, read_size, fd); + if(result != read_size) + { + break; + } + val = buffer[0]; + + if(init) { + nal_unit_type = val & 0xf; + init = 0; + } + if (!val) + { + zero_count++; + } + else + { + if ((zero_count == 2 || zero_count == 3 || zero_count == 4) && (val == 1)) + { + break; + } + else + { + for (i = 0; ivideo_fmt, NULL, NULL, &ad->video_pkt) != MEDIA_PACKET_ERROR_NONE) { + LOGE("media_packet_create_alloc failed\n"); + return; + } + + if (media_packet_get_buffer_data_ptr(ad->video_pkt, &buf_data_ptr) != MEDIA_PACKET_ERROR_NONE) { + LOGE("media_packet_get_buffer_data_ptr failed\n"); + return; + } + + if (media_packet_set_pts(ad->video_pkt, (uint64_t)(pts/1000000)) != MEDIA_PACKET_ERROR_NONE) { + LOGE("media_packet_set_pts failed\n"); + return; + } + + /* NOTE: In case of H.264 video, stream format for feeding is NAL unit. + * And, SPS(0x67) and PPS(0x68) should be located before IDR.(0x65). + */ + read = bytestream2nalunit(ad->file_src, buf_data_ptr); + LOGD("real length = %d\n", read); + if (read == 0) { + LOGD("input file read failed\n"); + return; + } + + if (media_packet_set_buffer_size(ad->video_pkt, (uint64_t)read) != MEDIA_PACKET_ERROR_NONE) { + LOGE("media_packet_set_buffer_size failed\n"); + return; + } + + /* push media packet */ + player_push_media_stream(ad->player_handle, ad->video_pkt); + pts += ES_DEFAULT_VIDEO_PTS_OFFSET; + + /* destroy media packet after use*/ + media_packet_destroy(ad->video_pkt); + ad->video_pkt = NULL; + return; +} + +static void feed_video_data_thread_func(void *data) +{ + gboolean exit = FALSE; + appdata_s *ad = (appdata_s *)data; + + while (!exit) + { + static int frame_count = 0; + + if (frame_count < ES_DEFAULT_NUMBER_OF_FEED) { + feed_video_data(ad); + frame_count++; + } else { + exit = TRUE; + } + } +} + +void _video_buffer_status_cb (player_media_stream_buffer_status_e status, void *user_data) +{ + if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) + { + LOGE("video buffer is underrun state"); + } + else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) + { + LOGE("video buffer is overrun state"); + } +} + +void _audio_buffer_status_cb (player_media_stream_buffer_status_e status, void *user_data) +{ + if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) + LOGE("audio buffer is underrun state"); + else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) + LOGE("audio buffer is overrun state"); +} + +void _video_seek_data_cb (unsigned long long offset, void *user_data) +{ + LOGE("seek offset of video is %llu", offset); +} + +void _audio_seek_data_cb (unsigned long long offset, void *user_data) +{ + LOGE("seek offset of audio is %llu", offset); +} + +static int app_reset(bundle *b, void *data) +{ + /* Take necessary actions when application becomes visible. */ + appdata_s *ad = (appdata_s *)data; + int ret = PLAYER_ERROR_NONE; + + LOGD("start"); + + if (ad == NULL) { + LOGE("appdata is NULL"); + return -1; + } + + ret = player_create(&ad->player_handle); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player_create failed : 0x%x", ret); + return -1; + } + + ret = player_set_display(ad->player_handle, PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(ad->win)); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player_set_display failed : 0x%x", ret); + goto FAILED; + } + + ret = player_set_uri(ad->player_handle, ES_FEEDING_PATH); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player_set_uri failed : 0x%x", ret); + goto FAILED; + } + + /* get media format format */ + ret = media_format_create(&ad->video_fmt); + if (ret != MEDIA_FORMAT_ERROR_NONE) { + LOGE("media_format_create : 0x%x", ret); + goto FAILED; + } + + /* set video format */ + media_format_set_video_mime(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_TYPE); + media_format_set_video_width(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_WIDTH); + media_format_set_video_height(ad->video_fmt,ES_DEFAULT_VIDEO_FORMAT_HEIGHT); + + ret = player_set_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_buffer_status_cb, (void*)ad); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player set video buffer status cb failed : 0x%x", ret); + goto FAILED; + } + ret = player_set_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_buffer_status_cb, (void*)ad); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player set audio buffer status cb failed : 0x%x", ret); + goto FAILED; + } + + ret = player_set_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_seek_data_cb, (void*)ad); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player set seek data cb for video failed : 0x%x", ret); + goto FAILED; + } + ret = player_set_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_seek_data_cb, (void*)ad); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player set seek data cb for audio failed : 0x%x", ret); + goto FAILED; + } + + /* send media packet to player */ + player_set_media_stream_info(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, ad->video_fmt); + + ret = player_prepare_async(ad->player_handle, _player_prepared_cb, (void*)ad); + if (ret != PLAYER_ERROR_NONE) { + LOGE("player prepare failed : 0x%x", ret); + goto FAILED; + } + + pthread_create(&ad->feeding_thread_id, NULL, (void*)feed_video_data_thread_func, (void *)ad); + + LOGD("done"); + + return 0; + +FAILED: + if (ad->player_handle) { + player_destroy(ad->player_handle); + ad->player_handle = NULL; + } + + return -1; +} + +static int app_terminate(void *data) +{ + /* Release all resources. */ + appdata_s *ad = (appdata_s *)data; + + LOGD("start"); + + if (ad == NULL) { + LOGE("appdata is NULL"); + return -1; + } + + app_pause(data); + + LOGD("done"); + + return 0; +} + +int main(int argc, char *argv[]) +{ + int ret = 0; + static appdata_s ad = {0,}; + + LOGD("start"); + + memset(&ad, 0x0, sizeof(appdata_s)); + + LOGD("call appcore_efl_main"); + + ops.data = &ad; + + ret = appcore_efl_main(PACKAGE, &argc, &argv, &ops); + + LOGD("appcore_efl_main() ret = 0x%x", ret); + + return ret; +} diff --git a/test/player_media_packet_test.c b/test/player_media_packet_test.c index ff9fdd3..1ae79cc 100755 --- a/test/player_media_packet_test.c +++ b/test/player_media_packet_test.c @@ -22,7 +22,7 @@ #include #define KEY_END "XF86Stop" -#define MEDIA_FILE_PATH "/root/1.mp4" +#define MEDIA_FILE_PATH "/opt/usr/media/Color.mp4" #ifdef PACKAGE #undef PACKAGE #endif @@ -94,7 +94,8 @@ create_base_gui(appdata_s *ad) /* Window */ ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); - //elm_win_wm_desktop_layout_support_set(ad->win, EINA_TRUE); + /* This is not supported in 3.0 + elm_win_wm_desktop_layout_support_set(ad->win, EINA_TRUE); */ elm_win_autodel_set(ad->win, EINA_TRUE); #if 0 if (elm_win_wm_rotation_supported_get(ad->win)) { @@ -153,52 +154,20 @@ _media_packet_video_decoded_cb(media_packet_h packet, void *user_data) return; } -int _save(unsigned char * src, int length) -{ //unlink(CAPTUERD_IMAGE_SAVE_PATH); - FILE* fp; - char filename[256] = {0,}; - static int WRITE_COUNT = 0; - - //gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; - sprintf (filename, "ALBUM_ART_IMAGE_%d", WRITE_COUNT); - WRITE_COUNT++; - fp=fopen(filename, "w+"); - if(fp==NULL) - { - g_print("file open error!!\n"); - return FALSE; - } - else - { - g_print("open success\n"); - if(fwrite(src, 1, length, fp )!=1) - { - g_print("file write error!!\n"); - fclose(fp); - return FALSE; - } - g_print("write success(%s)\n", filename); - fclose(fp); - } - - return TRUE; -} - - static void pipe_cb(void *data, void *buf, unsigned int len) { /* Now, we get a player surface to be set here. */ appdata_s *ad = data; tbm_surface_h surface; +#if _CAN_USE_NATIVE_SURFACE_TBM Evas_Native_Surface surf; +#endif + tbm_surface_info_s suf_info; + uint32_t plane_idx; int ret; GList *last_item = NULL; - - tbm_surface_info_s suf_info; - uint32_t num_planes; - LOGD("start"); g_mutex_lock(&ad->buffer_lock); @@ -227,14 +196,7 @@ pipe_cb(void *data, void *buf, unsigned int len) return; } -// g_mutex_unlock(&ad->buffer_lock); - - LOGE("Test : media packet"); - ret = media_packet_get_tbm_surface(ad->packet, &surface); - LOGD("surface %p", surface); - printf("surface %p\n",surface); - if (ret != MEDIA_PACKET_ERROR_NONE) { LOGE("Failed to get surface from media packet. ret(0x%x)", ret); @@ -246,15 +208,11 @@ pipe_cb(void *data, void *buf, unsigned int len) return; } - tbm_surface_get_info(surface,&suf_info); - num_planes = suf_info.num_planes; - LOGD("surface %lu", num_planes); - printf("surface %lu\n", num_planes); - - _save(suf_info.planes[0].ptr, suf_info.planes[0].size); + LOGD("surface %p", surface); g_mutex_unlock(&ad->buffer_lock); -#if 0 /*NATIVE_SURFACE_TBM is not supported , It will be supported */ + +#if _CAN_USE_NATIVE_SURFACE_TBM /* Set tbm surface to image native surface */ memset(&surf, 0x0, sizeof(surf)); surf.version = EVAS_NATIVE_SURFACE_VERSION; @@ -265,11 +223,35 @@ pipe_cb(void *data, void *buf, unsigned int len) /* Set dirty image region to be redrawn */ evas_object_image_data_update_add(ad->img, 0, 0, ad->w, ad->h); +#else + unsigned char *ptr = NULL; + unsigned char *buf_data = NULL; + media_format_h format = NULL; + media_format_mimetype_e mimetype; + + media_packet_get_format(ad->packet, &format); + media_format_get_video_info(format, &mimetype, NULL, NULL, NULL, NULL); + + if (mimetype == MEDIA_FORMAT_I420 || mimetype == MEDIA_FORMAT_NV12 || mimetype == MEDIA_FORMAT_NV12T) { + + tbm_surface_get_info(surface,&suf_info); + buf_data = (unsigned char*)g_malloc0(suf_info.size); + ptr = buf_data; + + for (plane_idx = 0; plane_idx < suf_info.num_planes; plane_idx++) { + memcpy(ptr, suf_info.planes[plane_idx].ptr, suf_info.planes[plane_idx].size); + ptr += suf_info.planes[plane_idx].size; + } + /* dump buf data here, if needed */ + g_free(buf_data); + } #endif + LOGD("done"); return; } + static int app_create(void *data) { /* Hook to take necessary actions before main event loop starts diff --git a/test/player_test.c b/test/player_test.c index d9480ee..d6f22e5 100755 --- a/test/player_test.c +++ b/test/player_test.c @@ -14,12 +14,13 @@ * limitations under the License. */ #include +#include +#include #include #include #include #include #include - #ifdef HAVE_X11 #include #endif @@ -27,7 +28,6 @@ #include #include #endif - //#define _USE_X_DIRECT_ #ifdef _USE_X_DIRECT_ #include @@ -39,10 +39,27 @@ #define INI_SAMPLE_LIST_MAX 9 #define DEFAULT_HTTP_TIMEOUT -1 -gboolean g_memory_playback = FALSE; -char g_uri[MAX_STRING_LEN]; -char g_subtitle_uri[MAX_STRING_LEN]; -FILE *g_pcm_fd; +static gboolean g_memory_playback = FALSE; +static char g_uri[MAX_STRING_LEN]; +static char g_subtitle_uri[MAX_STRING_LEN]; +static FILE *g_pcm_fd; + +static gboolean is_es_push_mode = FALSE; +static pthread_t g_feed_video_thread_id = 0; +static bool g_thread_end = FALSE; +static media_packet_h g_audio_pkt = NULL; +static media_format_h g_audio_fmt = NULL; + +static media_packet_h g_video_pkt = NULL; +static media_format_h g_video_fmt = NULL; + + +//#define DUMP_OUTBUF 1 +#if DUMP_OUTBUF +FILE *fp_out1 = NULL; +FILE *fp_out2 = NULL; +#endif + enum { CURRENT_STATUS_MAINMENU, @@ -62,6 +79,8 @@ enum CURRENT_STATUS_DISPLAY_SRC_CROP, CURRENT_STATUS_SUBTITLE_FILENAME, CURRENT_STATUS_AUDIO_EQUALIZER, + CURRENT_STATUS_PLAYBACK_RATE, + CURRENT_STATUS_SWITCH_SUBTITLE, }; #define MAX_HANDLE 20 @@ -233,6 +252,26 @@ static void prepared_cb(void *user_data) g_print("[Player_Test] prepared_cb!!!!\n"); } +static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s *audio_raw_frame, void *user_data) +{ + player_audio_raw_data_s* audio_raw = (player_audio_raw_data_s*) audio_raw_frame; + + g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %lld\n", audio_raw->channel, audio_raw->channel_mask); + +#ifdef DUMP_OUTBUF + if (audio_raw_frame != NULL) + { + if(audio_raw->channel_mask == 1) + fwrite(audio_raw_frame->data, 1, audio_raw_frame->size, fp_out1); + + else if(audio_raw->channel_mask == 2) + fwrite(audio_raw_frame->data, 1, audio_raw_frame->size, fp_out2); + } + +#endif + +} + static void progress_down_cb(player_pd_message_type_e type, void *user_data) { g_print("[Player_Test] progress_down_cb!!!! type : %d\n", type); @@ -305,7 +344,7 @@ int _save(unsigned char * src, int length) else { g_print("open success\n"); - if(fwrite(src, 1, length, fp )!=1) + if(fwrite(src, 1, length, fp ) < 1) { g_print("file write error!!\n"); fclose(fp); @@ -410,6 +449,227 @@ static void player_set_memory_buffer_test() g_print("player_set_memory_buffer ret : %d\n", ret); } +#ifdef TEST_ES +int video_packet_count = 0; + +static void buffer_need_video_data_cb(unsigned int size, void *user_data) +{ + int real_read_len = 0; + char fname[128]; + char fptsname[128]; + static guint64 pts = 0L; + + FILE *fp = NULL; + guint8 *buff_ptr = NULL; + void *src = NULL; + + memset(fname, 0, 128); + memset(fptsname, 0, 128); + + video_packet_count++; + + if (video_packet_count > 1000) + { + g_print("EOS.\n"); +// player_submit_packet(g_player[0], NULL, 0, 0, 1); + player_push_media_stream(g_player[0], NULL); + g_thread_end = TRUE; + } +// snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); +// snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); + snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count); + snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count); + + fp = fopen(fptsname, "rb"); + if (fp) + { + int pts_len = 0; + pts_len = fread(&pts, 1, sizeof(guint64), fp); + if (pts_len != sizeof(guint64)) + { + g_print("Warning, pts value can be wrong.\n"); + } + fclose(fp); + fp = NULL; + } + + fp = fopen(fname, "rb"); + if (fp) + { + buff_ptr = (guint8 *)g_malloc0(1048576); + real_read_len = fread(buff_ptr, 1, size, fp); + fclose(fp); + fp = NULL; + } + g_print("video need data - data size : %d, pts : %lld\n", real_read_len, pts); +#if 0 + player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts/1000000), 1); +#else + /* create media packet */ + if (g_video_pkt) { + media_packet_destroy(g_video_pkt); + g_video_pkt = NULL; + } + + media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt); + + g_print("packet = %p, src = %p\n", g_video_pkt, src); + + + if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE) + return; + + if (media_packet_set_pts(g_video_pkt, (uint64_t)(pts/1000000)) != MEDIA_PACKET_ERROR_NONE) + return; + + if (media_packet_set_buffer_size(g_video_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE) + return; + + memcpy(src, buff_ptr, real_read_len); + + /* then, push it */ + player_push_media_stream(g_player[0], g_video_pkt); +#endif + + if (buff_ptr) + { + g_free(buff_ptr); + buff_ptr = NULL; + } +} + +int audio_packet_count = 0; +static void buffer_need_audio_data_cb(unsigned int size, void *user_data) +{ + int real_read_len = 0; + char fname[128]; + FILE *fp = NULL; + guint8 *buff_ptr = NULL; + void *src = NULL; + + memset(fname, 0, 128); + audio_packet_count++; + + if (audio_packet_count > 1000) + { + g_print("EOS.\n"); +// player_submit_packet(g_player[0], NULL, 0, 0, 0); + player_push_media_stream(g_player[0], NULL); + g_thread_end = TRUE; + } + +// snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); + snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count); + + static guint64 audio_pts = 0; + guint64 audio_dur = 21333333; + + fp = fopen(fname, "rb"); + if (fp) + { + buff_ptr = (guint8 *)g_malloc0(1048576); + real_read_len = fread(buff_ptr, 1, size, fp); + fclose(fp); + fp = NULL; + + g_print("\t audio need data - data size : %d, pts : %lld\n", real_read_len, audio_pts); + } +#if 0 + player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts/1000000), 0); +#else + /* create media packet */ + if (g_audio_pkt) { + media_packet_destroy(g_audio_pkt); + g_audio_pkt = NULL; + } + media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt); + + g_print("packet = %p, src = %p\n", g_audio_pkt, src); + + + if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE) + return; + + if (media_packet_set_pts(g_audio_pkt, (uint64_t)(audio_pts/1000000)) != MEDIA_PACKET_ERROR_NONE) + return; + + if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE) + return; + + memcpy(src, buff_ptr, real_read_len); + + /* then, push it */ + player_push_media_stream(g_player[0], g_audio_pkt); +#endif + + audio_pts += audio_dur; + + if (buff_ptr) + { + g_free(buff_ptr); + buff_ptr = NULL; + } +} + +static void set_content_info(bool is_push_mode) +{ + /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */ +// unsigned char codec_data[45] = {0x0,0x0,0x1,0xb0,0x1,0x0,0x0,0x1,0xb5,0x89,0x13,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x20,0x0,0xc4,0x8d,0x88,0x5d,0xad,0x14,0x4,0x22,0x14,0x43,0x0,0x0,0x1,0xb2,0x4c,0x61,0x76,0x63,0x35,0x31,0x2e,0x34,0x30,0x2e,0x34}; + + /* create media format */ + media_format_create(&g_audio_fmt); + media_format_create(&g_video_fmt); + + //Video + /* configure media format for video and set to player */ + media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP); + media_format_set_video_width(g_video_fmt, 640); + media_format_set_video_height(g_video_fmt,272); +// player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); + + //Audio--aac--StarWars.mp4 + media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC); + media_format_set_audio_channel(g_audio_fmt, 2); + media_format_set_audio_samplerate(g_audio_fmt, 48000); +// player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); +#if 0 +// video_info->mime = g_strdup("video/mpeg"); //CODEC_ID_MPEG4VIDEO + video_info->width = 640; + video_info->height = 272; + video_info->version = 4; + video_info->framerate_den = 100; + video_info->framerate_num = 2997; + + video_info->extradata_size = 45; + video_info->codec_extradata = codec_data; + player_set_video_stream_info(g_player[0], video_info); + + + //audio--aac--StarWars.mp4 +// audio_info->mime = g_strdup("audio/mpeg"); + //audio_info->version = 2; +// audio_info->user_info = 0; //raw +#endif + +#ifdef _ES_PULL_ + if (!is_push_mode) + { + player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void*)g_player[0]); + player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void*)g_player[0]); + } +#endif +} + +static void feed_video_data_thread_func(void *data) +{ + while (!g_thread_end) + { + buffer_need_video_data_cb(1048576, NULL); + buffer_need_audio_data_cb(1048576, NULL); + } +} +#endif + static void _player_prepare(bool async) { int ret = FALSE; @@ -449,7 +709,27 @@ static void _player_prepare(bool async) player_set_uri(g_player[i], g_uri); } } +#ifdef TEST_ES + if (strstr(g_uri, "es_buff://")) + { + is_es_push_mode = FALSE; + video_packet_count = 0; + audio_packet_count = 0; + if (strstr(g_uri, "es_buff://push_mode")) + { + set_content_info(TRUE); + async = TRUE; + is_es_push_mode = TRUE; + } +#ifdef _ES_PULL_ + else + { + set_content_info(FALSE); + } +#endif + } +#endif if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) { if ( async ) @@ -493,6 +773,12 @@ static void _player_prepare(bool async) } } +#ifdef TEST_ES + if (is_es_push_mode) { + pthread_create(&g_feed_video_thread_id, NULL, (void*)feed_video_data_thread_func, NULL); + } +#endif + } static void _player_unprepare() @@ -520,7 +806,6 @@ static void _player_unprepare() ret = player_unset_error_cb(g_player[0]); g_print("player_unset_error_cb ret %d\n", ret); - } else { @@ -571,6 +856,7 @@ static void _player_unprepare() static void _player_destroy() { int i = 0; + if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) { player_unprepare(g_player[0]); @@ -592,6 +878,20 @@ static void _player_destroy() } } } + + if (g_video_pkt) + media_packet_destroy(g_video_pkt); + + if (g_audio_pkt) + media_packet_destroy(g_audio_pkt); + +#if DUMP_OUTBUF + if (fp_out1) + fclose(fp_out1); + if (fp_out2) + fclose(fp_out2); +#endif + } static void _player_play() @@ -630,6 +930,14 @@ static void _player_stop() g_print("player_stop returned [%d]", bRet); } } +#ifdef TEST_ES + g_thread_end = TRUE; + if (g_feed_video_thread_id) + { + pthread_join(g_feed_video_thread_id, NULL); + g_feed_video_thread_id = 0; + } +#endif } static void _player_resume() @@ -737,6 +1045,14 @@ static void set_position(int position) } } +static void set_playback_rate(float rate) +{ + if ( player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE ) + { + g_print("failed to set playback rate\n"); + } +} + static void get_duration() { int duration = 0; @@ -746,6 +1062,19 @@ static void get_duration() g_print(" ==> [Player_Test] Duration: [%d ] msec\n",duration); } +static void audio_frame_decoded_cb_ex() +{ + int ret; + +#if DUMP_OUTBUF + fp_out1 = fopen("/opt/usr/media/out1.pcm", "wb"); + fp_out2 = fopen("/opt/usr/media/out2.pcm", "wb"); +#endif + + ret = player_set_pcm_extraction_mode(g_player[0], false, _audio_frame_decoded_cb_ex, &ret); + g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex return: %d\n", ret); +} + static void get_stream_info() { int w = 0; @@ -840,10 +1169,16 @@ static void change_surface(int option) surface_type = PLAYER_DISPLAY_TYPE_OVERLAY; g_print("change surface type to X\n"); break; +#ifdef TIZEN_MOBILE case 1: /* EVAS surface */ surface_type = PLAYER_DISPLAY_TYPE_EVAS; g_print("change surface type to EVAS\n"); break; +#endif + case 2: + g_print("change surface type to NONE\n"); + player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL); + break; default: g_print("invalid surface type\n"); return; @@ -1044,6 +1379,19 @@ static void input_subtitle_filename(char *subtitle_filename) player_set_subtitle_path (g_player[0], g_subtitle_uri); } +static void switch_subtitle(int index) +{ + char* lang_code = NULL; + if (player_select_track (g_player[0], PLAYER_STREAM_TYPE_TEXT, index) != PLAYER_ERROR_NONE) + { + g_print("player_select_track failed\n"); + } + if (player_get_track_language_code(g_player[0], PLAYER_STREAM_TYPE_TEXT, index, &lang_code) == PLAYER_ERROR_NONE) { + g_print("selected track code %s\n", lang_code); + free(lang_code); + } +} + static void capture_video() { if( player_capture_video(g_player[0],video_captured_cb,NULL)!=PLAYER_ERROR_NONE) @@ -1137,6 +1485,12 @@ void quit_program() } } elm_exit(); + + if (g_audio_fmt) + media_format_unref(g_audio_fmt); + + if (g_video_fmt) + media_format_unref(g_video_fmt); } void play_with_ini(char *file_path) @@ -1339,7 +1693,7 @@ void _interpret_main_menu(char *cmd) } else if(len == 2) { - if (strncmp(cmd, "pr", 2) == 0) + if (strncmp(cmd, "pr", 2) == 0) { _player_prepare(FALSE); // sync } @@ -1372,6 +1726,18 @@ void _interpret_main_menu(char *cmd) { g_menu_state = CURRENT_STATUS_HANDLE_NUM; } + else if (strncmp(cmd, "tr", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_PLAYBACK_RATE; + } + else if (strncmp(cmd, "ss", 2) == 0 ) + { + g_menu_state = CURRENT_STATUS_SWITCH_SUBTITLE; + } + else if(strncmp(cmd, "X3", 2) == 0) + { + audio_frame_decoded_cb_ex(); + } else { g_print("unknown menu \n"); @@ -1411,12 +1777,14 @@ void display_sub_basic() g_print("[ volume ] f. Set Volume\t"); g_print("g. Get Volume\t"); g_print("z. Set Sound type\t"); + g_print("k. Set Sound Stream Info.\t"); g_print("[ mute ] h. Set Mute\t"); g_print("i. Get Mute\n"); g_print("[audio eq] E. Set Audio EQ\t"); g_print("H. Get Audio EQ\n"); g_print("[position] j. Set Position \t"); g_print("l. Get Position\n"); + g_print("[trick] tr. set playback rate\n"); g_print("[duration] m. Get Duration\n"); g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n"); g_print("[Looping] o. Set Looping\t"); @@ -1429,9 +1797,11 @@ void display_sub_basic() g_print("[x display] t. Set display Rotation\t"); g_print("[Track] tl. Get Track language info(single only)\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"); g_print("[etc] sp. Set Progressive Download\t"); g_print("mp. memory playback\n"); + g_print("[audio_frame_decoded_cb_ex] X3. (input) set audio_frame_decoded_cb_ex callback \n"); g_print("\n"); g_print("=========================================================================================\n"); } @@ -1505,6 +1875,28 @@ static void displaymenu() { g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n"); } + else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE) + { + g_print(" *** input playback rate.(-5.0 ~ 5.0)\n"); + } + else if (g_menu_state == CURRENT_STATUS_SWITCH_SUBTITLE) + { + int count = 0, cur_index = 0; + int ret = 0; + + ret = player_get_track_count (g_player[0], PLAYER_STREAM_TYPE_TEXT, &count); + if(ret!=PLAYER_ERROR_NONE) + g_print ("player_get_track_count fail!!!!\n"); + else if (count) + { + g_print ("Total subtitle tracks = %d \n", count); + player_get_current_track (g_player[0], PLAYER_STREAM_TYPE_TEXT, &cur_index); + g_print ("Current index = %d \n", cur_index); + g_print (" *** input correct index 0 to %d\n:", (count - 1)); + } + else + g_print("no track\n"); + } else { g_print("*** unknown status.\n"); @@ -1708,6 +2100,20 @@ static void interpret (char *cmd) reset_menu_state(); } break; + case CURRENT_STATUS_PLAYBACK_RATE: + { + float rate = atof(cmd); + set_playback_rate(rate); + reset_menu_state(); + } + break; + case CURRENT_STATUS_SWITCH_SUBTITLE: + { + int index = atoi(cmd); + switch_subtitle(index); + reset_menu_state(); + } + break; } g_timeout_add(100, timeout_menu_display, 0); }