From 9f8dfe028e3e8eea68d66961596632bddb4d6681 Mon Sep 17 00:00:00 2001 From: Hyunil Date: Thu, 30 Aug 2018 17:19:19 +0900 Subject: [PATCH 01/16] [VPR-306/ACR-1275] Add new API to set/get the video roi area Change-Id: I6df211d6ad036a8662627467cbac3b45a4544d2d Signed-off-by: Hyunil --- legacy/include/legacy_player.h | 51 ++++++++++++++++++++++++++++++++++++++++++ legacy/src/legacy_player.c | 36 +++++++++++++++++++++++++++++ muse/api.list | 2 ++ muse/src/muse_player.c | 51 +++++++++++++++++++++++++++++++++++++++++- 4 files changed, 139 insertions(+), 1 deletion(-) diff --git a/legacy/include/legacy_player.h b/legacy/include/legacy_player.h index 9556da8..c1527a7 100644 --- a/legacy/include/legacy_player.h +++ b/legacy/include/legacy_player.h @@ -1973,6 +1973,57 @@ int legacy_player_unset_retrieve_buffer_cb(player_h player); int legacy_player_manage_external_storage_state(player_h player, int id, int state); /** + * @brief Sets the ROI (Region Of Interest) area of the content video source. + * @details This function is to set the ROI area of video content to render it + * on #PLAYER_DISPLAY_TYPE_OVERLAY display with current display mode. + * It can be regarded as zooming operation because the selected video area will be rendered fit to the display. + * @since_tizen 5.0 + * @remarks This function requires the ratio value of the each coordinate and size based on the video resolution size + * to consider the dynamic resolution video content. + * @remarks The ROI area is valid only in #PLAYER_DISPLAY_TYPE_OVERLAY. + * @param[in] player The handle to the media player + * @param[in] scale_x X coordinate ratio value of the video source area based on the video width size \n + * Valid range is 0.0~1.0. + * @param[in] scale_y Y coordinate ratio value of the video source area based on the video height size \n + * Valid range is 0.0~1.0. + * @param[in] scale_width Width ratio value of the video source area based on the video width size \n + * Valid range is from greater than 0.0 to 1.0. + * @param[in] scale_height Height ratio value of the video source area based on the video height size \n + * Valid range is from greater than 0.0 to 1.0. + * @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 legacy_player_set_display() + * @see legacy_player_set_display_mode() + * @see legacy_player_get_video_size() + * @see legacy_player_get_video_roi_area() + */ +int legacy_player_set_video_roi_area(player_h player, double scale_x, double scale_y, double scale_width, double scale_height); + +/** + * @brief Gets the ROI (Region Of Interest) area of the content video source. + * @since_tizen 5.0 + * @remarks This function gets the ratio value of the each coordinate and size based on the video resolution size. + * @remarks The ROI area is valid only in #PLAYER_DISPLAY_TYPE_OVERLAY. + * @param[in] player The handle to the media player + * @param[out] scale_x The current X coordinate ratio value of the video source area based on the video width size + * @param[out] scale_y The current Y coordinate ratio value of the video source area based on the video height size + * @param[out] scale_width The current width ratio value of the video source area based on the video width size + * @param[out] scale_height The current height ratio value of the video source area based on the video height 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 + * @see legacy_player_set_display() + * @see legacy_player_get_video_size() + * @see legacy_player_set_video_roi_area() + */ +int legacy_player_get_video_roi_area(player_h player, double *scale_x, double *scale_y, double *scale_width, double *scale_height); + +/** * @brief Sets the ROI(Region Of Interest) area of display. * @since_tizen 3.0 * @remarks If no display is set, no operation is performed. diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index e5a82f0..5a8c2c1 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -2462,6 +2462,42 @@ int legacy_player_get_track_language_code(player_h player, player_stream_type_e } } +int legacy_player_set_video_roi_area(player_h player, double scale_x, + double scale_y, double scale_width, double scale_heights) +{ + PLAYER_INSTANCE_CHECK(player); + player_s *handle = (player_s *)player; + int ret; + + LOGD(""); + + ret = mm_player_set_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_heights); + if (ret != PLAYER_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int legacy_player_get_video_roi_area(player_h player, double *scale_x, + double *scale_y, double *scale_width, double *scale_height) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(scale_x); + PLAYER_NULL_ARG_CHECK(scale_y); + PLAYER_NULL_ARG_CHECK(scale_width); + PLAYER_NULL_ARG_CHECK(scale_height); + player_s *handle = (player_s *)player; + int ret; + + LOGD(""); + + ret = mm_player_get_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_height); + if (ret != PLAYER_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + int legacy_player_set_roi_area(player_h player, int x, int y, int w, int h) { PLAYER_INSTANCE_CHECK(player); diff --git a/muse/api.list b/muse/api.list index b8ad747..9a7f85d 100644 --- a/muse/api.list +++ b/muse/api.list @@ -25,6 +25,8 @@ get_duration set_display set_display_mode get_display_mode +set_video_roi_area +get_video_roi_area set_display_roi_area set_playback_rate set_display_rotation diff --git a/muse/src/muse_player.c b/muse/src/muse_player.c index 07936cf..2148723 100644 --- a/muse/src/muse_player.c +++ b/muse/src/muse_player.c @@ -1939,6 +1939,51 @@ int player_disp_get_display_mode(muse_module_h module) return ret; } +int player_disp_set_video_roi_area(muse_module_h module) +{ + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_ROI_AREA; + muse_player_handle_s *muse_player = NULL; + double x_scale = 0, y_scale = 0, w_scale = 0, h_scale = 0; + bool ret_val = TRUE; + + ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), + MUSE_TYPE_DOUBLE, "x_scale", (void *)&x_scale, + MUSE_TYPE_DOUBLE, "y_scale", (void *)&y_scale, + MUSE_TYPE_DOUBLE, "w_scale", (void *)&w_scale, + MUSE_TYPE_DOUBLE, "h_scale", (void *)&h_scale, + INVALID_MUSE_TYPE_VALUE); + if (ret_val) { + muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); + ret = legacy_player_set_video_roi_area(muse_player->player_handle, x_scale, + y_scale, w_scale, h_scale); + } + + PLAYER_RETURN_MSG(api, ret, module); + + return ret; +} + +int player_disp_get_video_roi_area(muse_module_h module) +{ + int ret = PLAYER_ERROR_NONE; + muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_ROI_AREA; + muse_player_handle_s *muse_player = NULL; + double scale_x = 0, scale_y = 0, scale_w = 0, scale_h = 0; + + muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); + + ret = legacy_player_get_video_roi_area(muse_player->player_handle, &scale_x, + &scale_y, &scale_w, &scale_h); + + PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_DOUBLE, "scale_x", scale_x, + MUSE_TYPE_DOUBLE, "scale_y", scale_y, + MUSE_TYPE_DOUBLE, "scale_w", scale_w, + MUSE_TYPE_DOUBLE, "scale_h", scale_h); + + return ret; +} + int player_disp_set_display_roi_area(muse_module_h module) { int ret = PLAYER_ERROR_NONE; @@ -1948,8 +1993,12 @@ int player_disp_set_display_roi_area(muse_module_h module) char *wl_win_msg = (char *)&wl_win; muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); + player_msg_get_array(wl_win_msg, muse_server_module_get_msg(module)); - ret = legacy_player_set_roi_area(muse_player->player_handle, wl_win.win_roi_x, wl_win.win_roi_y, wl_win.win_roi_width, wl_win.win_roi_height); + + ret = legacy_player_set_roi_area(muse_player->player_handle, wl_win.win_roi_x, + wl_win.win_roi_y, wl_win.win_roi_width, wl_win.win_roi_height); + PLAYER_RETURN_MSG(api, ret, module); return ret; -- 2.7.4 From 5390853d84e5658409b3d5d1410916a47ea7f50c Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Tue, 4 Sep 2018 19:19:36 +0900 Subject: [PATCH 02/16] [0.2.88] modify setting video roi function Change-Id: Iea9c3fb9c895852e02eaba99118ed04bf5f41695 --- legacy/src/legacy_player.c | 5 +++++ packaging/mmsvc-player.spec | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 5a8c2c1..1cabbc7 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -2471,6 +2471,11 @@ int legacy_player_set_video_roi_area(player_h player, double scale_x, LOGD(""); + if (handle->display_type != PLAYER_DISPLAY_TYPE_OVERLAY) { + LOGE("not supportable display type %d", handle->display_type); + return PLAYER_ERROR_INVALID_OPERATION; + } + ret = mm_player_set_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_heights); if (ret != PLAYER_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 52b0195..97f78cf 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.87 +Version: 0.2.88 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From d75803355c161e2ba0af9cbf752277f0f31137a7 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Tue, 23 Oct 2018 12:58:05 +0900 Subject: [PATCH 03/16] [0.2.89] update player state with the interrupt msg - mm player resource is released internally, so the player state have to be updated. Change-Id: Ica4ee6d9a2fc7866fd40fb2f97d594bb7bc2f4d6 --- legacy/src/legacy_player.c | 16 +++++++++++++++- packaging/mmsvc-player.spec | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 1cabbc7..080a30e 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -397,6 +397,14 @@ static void __message_cb_loop(void *data) return; } +static player_state_e __convert_player_state(MMPlayerStateType state) +{ + if (state == MM_PLAYER_STATE_NONE) + return PLAYER_STATE_NONE; + else + return state +1; +} + static int __msg_callback(int message, void *param, void *user_data) { player_s *handle = (player_s *)user_data; @@ -452,8 +460,14 @@ static int __msg_callback(int message, void *param, void *user_data) ((player_buffering_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])(msg->connection.buffering, handle->user_data[MUSE_PLAYER_EVENT_TYPE_BUFFERING]); break; case MM_MESSAGE_STATE_INTERRUPTED: /* 0x04 */ - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]) + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]) { + if (msg->union_type == MM_MSG_UNION_STATE) { + LOGW("received mm state msg prev:%d, curr:%d", msg->state.previous, msg->state.current); + handle->state = __convert_player_state(msg->state.current); + LOGW("player state is changed to %d by resource conflict", handle->state); + } ((player_interrupted_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]); + } break; case MM_MESSAGE_CONNECTION_TIMEOUT: /* 0x102 */ LOGI("[%s] PLAYER_ERROR_CONNECTION_FAILED (0x%08x) : CONNECTION_TIMEOUT", __FUNCTION__, PLAYER_ERROR_CONNECTION_FAILED); diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 97f78cf..3278002 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.88 +Version: 0.2.89 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From e5542de1bcb1e47963c3dd9348800b5c328bd1f8 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Tue, 6 Nov 2018 15:11:20 +0900 Subject: [PATCH 04/16] [0.2.90] use attr for pcm spec - remove unused attr - use attr for pcm spec Change-Id: Idfba9947b18575f906e8815b450e4e41608e891a --- legacy/src/legacy_player_internal.c | 29 ++++++++++++++++++----------- packaging/mmsvc-player.spec | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/legacy/src/legacy_player_internal.c b/legacy/src/legacy_player_internal.c index 2bb7247..e1b5639 100644 --- a/legacy/src/legacy_player_internal.c +++ b/legacy/src/legacy_player_internal.c @@ -63,10 +63,6 @@ int legacy_player_set_pcm_extraction_mode(player_h player, bool sync, player_aud PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction", TRUE, 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__); @@ -82,14 +78,25 @@ int legacy_player_set_pcm_spec(player_h player, const char *format, int samplera player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGE("[%s] legacy_player_set_pcm_spec %s %d %d", __FUNCTION__, format, samplerate, channel); - ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_audioformat", format, strlen(format), NULL); - if (ret != MM_ERROR_NONE) - return __player_convert_error_code(ret, (char *)__FUNCTION__); + LOGD("format: %s, rate: %d, ch: %d", format, samplerate, channel); - ret = mm_player_set_pcm_spec(handle->mm_handle, samplerate, channel); - if (ret != MM_ERROR_NONE) - return __player_convert_error_code(ret, (char *)__FUNCTION__); + if (format) { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_audioformat", format, strlen(format), NULL); + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + } + + if (samplerate > 0) { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction_samplerate", samplerate, NULL); + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + } + + if (channel > 0) { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction_channels", channel, NULL); + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + } return PLAYER_ERROR_NONE; } diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 3278002..67754a6 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.89 +Version: 0.2.90 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From 194568e85d8e81a9f36caabeae86f8dcdf0c4eca Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Tue, 6 Nov 2018 17:57:29 +0900 Subject: [PATCH 05/16] [0.2.90] apply the renamed interface Change-Id: I31f7e7ba1953088493ec2d45ab52ec5d8bc9be26 --- legacy/src/legacy_player_internal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/legacy/src/legacy_player_internal.c b/legacy/src/legacy_player_internal.c index e1b5639..c3d1f7e 100644 --- a/legacy/src/legacy_player_internal.c +++ b/legacy/src/legacy_player_internal.c @@ -40,7 +40,7 @@ do { \ LOGI("[%s] Event type : %d ", __FUNCTION__, event_type); \ } while (0) -bool __audio_stream_callback_ex(MMPlayerAudioStreamDataType *stream, void *user_data) +bool __audio_stream_callback(MMPlayerAudioStreamDataType *stream, void *user_data) { player_s *handle = (player_s *)user_data; @@ -63,7 +63,7 @@ int legacy_player_set_pcm_extraction_mode(player_h player, bool sync, player_aud PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - ret = mm_player_set_audio_stream_callback_ex(handle->mm_handle, sync, __audio_stream_callback_ex, (void *)handle); + ret = mm_player_set_audio_stream_callback(handle->mm_handle, sync, __audio_stream_callback, (void *)handle); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); -- 2.7.4 From 66281b9ab03a26fe78d57813e5333889ff0071cb Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Thu, 22 Nov 2018 20:38:53 +0900 Subject: [PATCH 06/16] [0.2.91] add initial unittest structure - this unit test will check legacy player function and muse player internal function. Change-Id: I7f373f3cccde6ce1bfccbd36fe2e3ac93b46f2fe --- CMakeLists.txt | 4 +++ legacy/CMakeLists.txt | 16 ++++----- legacy/include/legacy_player_private.h | 8 ----- muse/CMakeLists.txt | 16 ++++----- muse/include/muse_player.h | 2 +- muse/test/CMakeLists.txt | 2 +- packaging/mmsvc-player.spec | 15 ++++++-- unittest/CMakeLists.txt | 37 ++++++++++++++++++++ unittest/gtest_legacy_player.cpp | 51 ++++++++++++++++++++++++++++ unittest/gtest_legacy_player.h | 38 +++++++++++++++++++++ unittest/unittest.cpp | 62 ++++++++++++++++++++++++++++++++++ 11 files changed, 223 insertions(+), 28 deletions(-) create mode 100644 unittest/CMakeLists.txt create mode 100644 unittest/gtest_legacy_player.cpp create mode 100644 unittest/gtest_legacy_player.h create mode 100644 unittest/unittest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c27d20..87e25ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,10 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTAL ADD_SUBDIRECTORY(legacy) ADD_SUBDIRECTORY(muse) +IF(BUILD_TESTS) +ADD_SUBDIRECTORY(unittest) +ENDIF(BUILD_TESTS) + IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) diff --git a/legacy/CMakeLists.txt b/legacy/CMakeLists.txt index 7841f53..3bcba47 100644 --- a/legacy/CMakeLists.txt +++ b/legacy/CMakeLists.txt @@ -6,9 +6,9 @@ SET(submodule "player") # for package file SET(dependents "dlog mm-player capi-base-common capi-media-tool libtbm") -SET(fw_name "${service}-${submodule}") +SET(LEGACY_PLAYER "${service}-${submodule}") -PROJECT(${fw_name}) +PROJECT(${LEGACY_PLAYER}) SET(CMAKE_INSTALL_PREFIX /usr) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -17,8 +17,8 @@ SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_name} REQUIRED ${dependents}) -FOREACH(flag ${${fw_name}_CFLAGS}) +pkg_check_modules(${LEGACY_PLAYER} REQUIRED ${dependents}) +FOREACH(flag ${${LEGACY_PLAYER}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -39,16 +39,16 @@ ADD_DEFINITIONS("-DTIZEN_DEBUG") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") aux_source_directory(src LEGACY_SOURCES) -ADD_LIBRARY(${fw_name} SHARED ${LEGACY_SOURCES}) +ADD_LIBRARY(${LEGACY_PLAYER} SHARED ${LEGACY_SOURCES}) -TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) +TARGET_LINK_LIBRARIES(${LEGACY_PLAYER} ${${LEGACY_PLAYER}_LDFLAGS}) -SET_TARGET_PROPERTIES(${fw_name} +SET_TARGET_PROPERTIES(${LEGACY_PLAYER} PROPERTIES CLEAN_DIRECT_OUTPUT 1 ) -INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(TARGETS ${LEGACY_PLAYER} DESTINATION ${LIB_INSTALL_DIR}) INSTALL( DIRECTORY ${INC_DIR}/ DESTINATION include/media FILES_MATCHING diff --git a/legacy/include/legacy_player_private.h b/legacy/include/legacy_player_private.h index 340ebcc..f63dc39 100644 --- a/legacy/include/legacy_player_private.h +++ b/legacy/include/legacy_player_private.h @@ -17,20 +17,12 @@ #ifndef __TIZEN_MEDIA_LEGACY_PLAYER_PRIVATE_H__ #define __TIZEN_MEDIA_LEGACY_PLAYER_PRIVATE_H__ #include -#include "muse_player.h" #include "legacy_player.h" - #ifdef __cplusplus extern "C" { #endif -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "TIZEN_N_PLAYER" -//#define USE_ECORE_FUNCTIONS - #define PLAYER_CHECK_CONDITION(condition, error, msg) \ do { \ if (condition) {} else \ diff --git a/muse/CMakeLists.txt b/muse/CMakeLists.txt index 6c2ee8e..81781e4 100644 --- a/muse/CMakeLists.txt +++ b/muse/CMakeLists.txt @@ -3,9 +3,9 @@ SET(service "muse") SET(submodule "player") SET(dependents "dlog muse-server mm-common libtbm capi-system-info libtzplatform-config") -SET(fw_name "${service}-${submodule}") +SET(MUSE_PLAYER "${service}-${submodule}") -PROJECT(${fw_name}) +PROJECT(${MUSE_PLAYER}) SET(CMAKE_INSTALL_PREFIX /usr) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -14,8 +14,8 @@ SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_name} REQUIRED ${dependents}) -FOREACH(flag ${${fw_name}_CFLAGS}) +pkg_check_modules(${MUSE_PLAYER} REQUIRED ${dependents}) +FOREACH(flag ${${MUSE_PLAYER}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -38,16 +38,16 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") execute_process(COMMAND python make_api.py -l api.list WORKING_DIRECTORY ${service}) aux_source_directory(src MUSED_SOURCES) -ADD_LIBRARY(${fw_name} SHARED ${MUSED_SOURCES}) +ADD_LIBRARY(${MUSE_PLAYER} SHARED ${MUSED_SOURCES}) -TARGET_LINK_LIBRARIES(${fw_name} legacy-player ${${fw_name}_LDFLAGS}) +TARGET_LINK_LIBRARIES(${MUSE_PLAYER} legacy-player ${${MUSE_PLAYER}_LDFLAGS}) -SET_TARGET_PROPERTIES(${fw_name} +SET_TARGET_PROPERTIES(${MUSE_PLAYER} PROPERTIES CLEAN_DIRECT_OUTPUT 1 ) -INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(TARGETS ${MUSE_PLAYER} DESTINATION ${LIB_INSTALL_DIR}) INSTALL( DIRECTORY ${INC_DIR}/ DESTINATION include/media FILES_MATCHING diff --git a/muse/include/muse_player.h b/muse/include/muse_player.h index f95f651..4e559a6 100644 --- a/muse/include/muse_player.h +++ b/muse/include/muse_player.h @@ -26,7 +26,7 @@ extern "C" { #ifdef LOG_TAG #undef LOG_TAG #endif -#define LOG_TAG "TIZEN_N_PLAYER" +#define LOG_TAG "MMSVC_PLAYER" #define MUSE_PLAYER_HEAD_GAP(api) ((api)/(1000)+(1))*(1000) diff --git a/muse/test/CMakeLists.txt b/muse/test/CMakeLists.txt index 3530924..d89ea2b 100644 --- a/muse/test/CMakeLists.txt +++ b/muse/test/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -SET(fw_test "${fw_name}-test") +SET(fw_test "${MUSE_PLAYER}-test") INCLUDE_DIRECTORIES(../include, ../../legacy/include) link_directories(${CMAKE_SOURCE_DIR}/../) diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 67754a6..b33034f 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.90 +Version: 0.2.91 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 @@ -18,6 +18,9 @@ BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(ttrace) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(libtzplatform-config) +%if 0%{?gtests:1} +BuildRequires: pkgconfig(gmock) +%endif Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -46,7 +49,12 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" %endif export CFLAGS+=" -DTIZEN_FEATURE_ASM" MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ + +%cmake . \ + -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DFULLVER=%{version} \ + -DMAJORVER=${MAJORVER} \ + -DBUILD_TESTS=%{?gtests:1}%{!?gtests:0} \ %if "%{TIZEN_PRODUCT_TV}" == "1" -DTIZEN_FEATURE_EVAS_RENDERER=Off %else @@ -69,6 +77,9 @@ rm -rf %{buildroot} %license LICENSE.Apache-2.0 %{_libdir}/liblegacy-player.so %{_libdir}/libmuse-player.so +%if 0%{?gtests:1} +%{_bindir}/gtest-mmsvc-player +%endif %files devel %{_includedir}/media/*.h diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 0000000..0933b79 --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1,37 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(gtest-mmsvc-player C CXX) + +SET(GTEST_TEST "gtest-mmsvc-player") +SET(BINDIR "/usr/bin") + +INCLUDE(FindPkgConfig) +SET(REQUIRES_LIST ${REQUIRES_LIST} + glib-2.0 + gio-2.0 + gmock + dlog + mm-common + mm-player + capi-media-sound-manager +) +PKG_CHECK_MODULES(GTEST_TEST_PKGS REQUIRED ${REQUIRES_LIST}) + +FOREACH(flag ${GTEST_TEST_PKG_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/legacy/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/muse/include) +INCLUDE_DIRECTORIES(${GTEST_TEST_PKGS_INCLUDE_DIRS}) +LINK_DIRECTORIES(${GTEST_TEST_PKGS_LIBRARY_DIRS}) + +FILE(GLOB GTEST_TEST_SRCS *.cpp ${CMAKE_SOURCE_DIR}/legacy/src/legacy_player.c) +SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS}) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fpie") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fpie") + +ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS}) +TARGET_LINK_LIBRARIES(${GTEST_TEST} ${LEGACY_PLAYER} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKGS_LDFLAGS} -lgcov) + +INSTALL(TARGETS ${GTEST_TEST} DESTINATION ${BINDIR}) diff --git a/unittest/gtest_legacy_player.cpp b/unittest/gtest_legacy_player.cpp new file mode 100644 index 0000000..f36b751 --- /dev/null +++ b/unittest/gtest_legacy_player.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018 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 "legacy_player.h" +#include "gtest_legacy_player.h" + +LegacyPlayer::LegacyPlayer() +{ + legacy_player = NULL; +} + +LegacyPlayer::~LegacyPlayer() +{ + if (legacy_player) { + LOGD("[Cleanup] %p", legacy_player); + legacy_player_destroy(legacy_player); + legacy_player = NULL; + } +} + +int LegacyPlayer::Create(void) +{ + int ret = legacy_player_create(&legacy_player); + LOGD("[Create] %p", legacy_player); + return ret; +} + +int LegacyPlayer::Destroy(void) +{ + int ret = PLAYER_ERROR_NONE; + + LOGD("[Destroy] %p", legacy_player); + + ret = legacy_player_destroy(legacy_player); + legacy_player = NULL; + + return ret; +} diff --git a/unittest/gtest_legacy_player.h b/unittest/gtest_legacy_player.h new file mode 100644 index 0000000..bb41038 --- /dev/null +++ b/unittest/gtest_legacy_player.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018 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 __GTEST_LEGACY_PLAYER_H__ +#define __GTEST_LEGACY_PLAYER_H__ + +#include +#include "legacy_player.h" + +#undef LOG_TAG +#define LOG_TAG "GTEST_MMSVC_PLAYER" + +class LegacyPlayer { +private: + player_h legacy_player; + +public: + LegacyPlayer(); + virtual ~LegacyPlayer(); + + int Create(void); + int Destroy(void); +}; + +#endif /*__GTEST_LEGACY_PLAYER_H__*/ diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp new file mode 100644 index 0000000..8c8537a --- /dev/null +++ b/unittest/unittest.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 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 "gtest_legacy_player.h" + +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; + +class LegacyPlayerPreTest : public ::testing::Test { + protected: + void SetUp() { + std::cout << "SetUp()" << std::endl; + } + + void TearDown() { + std::cout << "TearDown()" << std::endl; + } +}; + +TEST(LegacyPlayerPreTest, Create_p) +{ + int ret = PLAYER_ERROR_NONE; + LegacyPlayer player; + + ret = player.Create(); + EXPECT_EQ(ret, PLAYER_ERROR_NONE); +} + +TEST(LegacyPlayerPreTest, Destroy_p) +{ + int ret = PLAYER_ERROR_NONE; + LegacyPlayer player; + + ret = player.Create(); + ASSERT_EQ(ret, PLAYER_ERROR_NONE); + + ret = player.Destroy(); + EXPECT_EQ(ret, PLAYER_ERROR_NONE); +} + +int main(int argc, char **argv) +{ + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} -- 2.7.4 From fdcb23ac6b2a1ced9383f1eac43f194068a1af43 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Thu, 6 Dec 2018 16:30:13 +0900 Subject: [PATCH 07/16] [0.2.92] remove progressive download path Change-Id: I052e62df124f8aa9e9d04cd3349afd19845dcf2b --- legacy/include/legacy_player.h | 91 --------------------- legacy/include/legacy_player_private.h | 1 - legacy/src/legacy_player.c | 143 +++------------------------------ muse/api.list | 2 - muse/include/muse_player.h | 1 - muse/src/muse_player.c | 61 -------------- packaging/mmsvc-player.spec | 2 +- 7 files changed, 14 insertions(+), 287 deletions(-) diff --git a/legacy/include/legacy_player.h b/legacy/include/legacy_player.h index c1527a7..c587fa3 100644 --- a/legacy/include/legacy_player.h +++ b/legacy/include/legacy_player.h @@ -91,15 +91,6 @@ typedef enum { } player_error_e; /** - * @brief Enumeration for progressive download message type. - * @since_tizen 2.3 - */ -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 */ @@ -310,15 +301,6 @@ typedef void (*player_error_cb)(int error_code, void *user_data); typedef void (*player_buffering_cb)(int percent, void *user_data); /** - * @brief Called when progressive download is started or completed. - * @since_tizen 2.3 - * @param[in] type The message type for progressive download - * @param[in] user_data The user data passed from the callback registration function - * @see legacy_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 * @remarks The color space format of the captured image is IMAGE_UTIL_COLORSPACE_RGB888. @@ -667,16 +649,12 @@ int legacy_player_get_audio_latency_mode(player_h player, audio_latency_mode_e * * @pre The player state must be set to #PLAYER_STATE_READY by calling legacy_player_prepare() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause(). * @post The player state will be #PLAYER_STATE_PLAYING. * @post It invokes legacy_player_completed_cb() when playback completes, if you set a callback with legacy_player_set_completed_cb(). - * @post It invokes legacy_player_pd_message_cb() when progressive download starts or completes, if you set a download path with legacy_player_set_progressive_download_path() and a callback with legacy_player_set_progressive_download_message_cb(). * @see legacy_player_prepare() * @see legacy_player_prepare_async() * @see legacy_player_stop() * @see legacy_player_pause() * @see legacy_player_set_completed_cb() * @see legacy_player_completed_cb() - * @see legacy_player_set_progressive_download_path() - * @see legacy_player_set_progressive_download_message_cb() - * @see legacy_player_pd_message_cb() */ int legacy_player_start(player_h player); @@ -693,7 +671,6 @@ int legacy_player_start(player_h player); * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause(). * @post The player state will be #PLAYER_STATE_READY. - * @post The downloading will be aborted if you use progressive download. * @see legacy_player_start() * @see legacy_player_pause() */ @@ -1660,74 +1637,6 @@ int legacy_player_set_buffering_cb(player_h player, player_buffering_cb callback int legacy_player_unset_buffering_cb(player_h player); /** - * @brief Sets a path to download, progressively. - * @since_tizen 2.3 - * @remarks Progressive download will be started when you invoke legacy_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 legacy_player_create() or legacy_player_unprepare(). - * @see legacy_player_set_progressive_download_message_cb() - * @see legacy_player_unset_progressive_download_message_cb() - */ -int legacy_player_set_progressive_download_path(player_h player, const char *path); - -/** - * @brief Gets the status of progressive download. - * @since_tizen 2.3 - * @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 legacy_player_set_progressive_download_path(). - * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause(). - */ -int legacy_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 - * @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 legacy_player_set_progressive_download_path(). - * @post legacy_player_pd_message_cb() will be invoked. - * @see legacy_player_unset_progressive_download_message_cb() - * @see legacy_player_set_progressive_download_path() - */ -int legacy_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 - * @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 legacy_player_set_progressive_download_message_cb() - */ -int legacy_player_unset_progressive_download_message_cb(player_h player); - -/** * @brief Sets the playback rate. * @since_tizen 2.3 * @details The default value is @c 1.0. diff --git a/legacy/include/legacy_player_private.h b/legacy/include/legacy_player_private.h index f63dc39..3bee2a1 100644 --- a/legacy/include/legacy_player_private.h +++ b/legacy/include/legacy_player_private.h @@ -108,7 +108,6 @@ typedef struct _player_s { player_state_e state; player_internal_state_e internal_state; bool is_display_visible; - bool is_progressive_download; bool is_media_stream; pthread_t prepare_async_thread; pthread_t message_thread; diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 080a30e..1f710c8 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -428,8 +428,7 @@ static int __msg_callback(int message, void *param, void *user_data) break; case MM_MESSAGE_STATE_CHANGED: /* 0x03 */ LOGI("STATE CHANGED INTERNALLY - from : %d, to : %d (CAPI State : %d)", msg->state.previous, msg->state.current, handle->state); - if ((handle->is_progressive_download && msg->state.previous == MM_PLAYER_STATE_NULL && msg->state.current == MM_PLAYER_STATE_READY) || - (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED)) { + if (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED) { LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { /* asyc && prepared cb has been set */ @@ -557,31 +556,6 @@ static int __msg_callback(int message, void *param, void *user_data) return 1; } -static int __pd_message_callback(int message, void *param, void *user_data) -{ - player_s *handle = (player_s *)user_data; - player_pd_message_type_e type; - switch (message) { - case MM_MESSAGE_PD_DOWNLOADER_START: - type = PLAYER_PD_STARTED; - break; - case MM_MESSAGE_PD_DOWNLOADER_END: - type = PLAYER_PD_COMPLETED; - break; - default: - return 0; - } - - LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); - - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD]) - ((player_pd_message_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD])(type, handle->user_data[MUSE_PLAYER_EVENT_TYPE_PD]); - - LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); - - return 0; -} - static MMDisplaySurfaceType __player_convert_display_type(player_display_type_e type) { switch (type) { @@ -601,7 +575,6 @@ bool _check_enabled_user_cb_lock(int type) { switch (type) { case MUSE_PLAYER_EVENT_TYPE_PREPARE: /* fall through */ - case MUSE_PLAYER_EVENT_TYPE_PD: /* fall through */ case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO: /* fall through */ case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO: /* fall through */ return TRUE; @@ -804,21 +777,19 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo goto ERROR; } - if (!handle->is_progressive_download) { - ret = pthread_create(&handle->prepare_async_thread, NULL, (void *)__prepare_async_thread_func, (void *)handle); + ret = pthread_create(&handle->prepare_async_thread, NULL, (void *)__prepare_async_thread_func, (void *)handle); - if (ret != 0) { - LOGE("[%s] failed to create thread ret = %d", __FUNCTION__, ret); - LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; - /* user_data will be free at player_disp_prepare_async() */ - handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; - } - LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); - __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); - return PLAYER_ERROR_OUT_OF_MEMORY; + if (ret != 0) { + LOGE("[%s] failed to create thread ret = %d", __FUNCTION__, ret); + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { + handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; + /* user_data will be free at player_disp_prepare_async() */ + handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); + __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); + return PLAYER_ERROR_OUT_OF_MEMORY; } LOGI("[%s] End", __FUNCTION__); @@ -886,9 +857,7 @@ int legacy_player_prepare(player_h player) return __player_convert_error_code(ret, (char *)__FUNCTION__); } - if (!handle->is_progressive_download) - ret = mm_player_pause(handle->mm_handle); - + ret = mm_player_pause(handle->mm_handle); if (ret != MM_ERROR_NONE) { int uret; uret = mm_player_unrealize(handle->mm_handle); @@ -948,7 +917,6 @@ int legacy_player_unprepare(player_h player) } else { __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); handle->is_display_visible = TRUE; - handle->is_progressive_download = FALSE; LOGI("[%s] End", __FUNCTION__); PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; @@ -1104,11 +1072,6 @@ int legacy_player_start(player_h player) LOGW("[%s] Failed to set display_visible '1' (0x%x)", __FUNCTION__, ret); } if (handle->internal_state == PLAYER_INTERNAL_STATE_STOPPED) { - if (handle->is_progressive_download) { - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); - return PLAYER_ERROR_INVALID_OPERATION; - } - ret = mm_player_start(handle->mm_handle); LOGI("[%s] stop -> start() ", __FUNCTION__); } else { @@ -1782,46 +1745,6 @@ int legacy_player_set_subtitle_position_offset(player_h player, int millisecond) return PLAYER_ERROR_NONE; } -int legacy_player_set_progressive_download_path(player_h player, const char *path) -{ - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(path); - - player_s *handle = (player_s *)player; - PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PD_MODE, MM_PLAYER_PD_MODE_URI, "pd_location", path, strlen(path), (char *)NULL); - if (ret != MM_ERROR_NONE) { - return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - handle->is_progressive_download = 1; - return PLAYER_ERROR_NONE; - } -} - -int legacy_player_get_progressive_download_status(player_h player, unsigned long *current, unsigned long *total_size) -{ - - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(current); - PLAYER_NULL_ARG_CHECK(total_size); - player_s *handle = (player_s *)player; - if (handle->state != PLAYER_STATE_PLAYING && 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; - } - guint64 _current; - guint64 _total; - int ret = mm_player_get_pd_status(handle->mm_handle, &_current, &_total); - if (ret != MM_ERROR_NONE) { - return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *current = _current; - *total_size = _total; - return PLAYER_ERROR_NONE; - } -} - int legacy_player_capture_video(player_h player, player_video_captured_cb callback, void *user_data) { PLAYER_INSTANCE_CHECK(player); @@ -1973,46 +1896,6 @@ int legacy_player_unset_subtitle_updated_cb(player_h player) return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player); } -int legacy_player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data) -{ - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(callback); - - player_s *handle = (player_s *)player; - - if (handle->state != PLAYER_STATE_IDLE && handle->state != 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; - } - - int ret = mm_player_set_pd_message_callback(handle->mm_handle, __pd_message_callback, (void *)handle); - if (ret != MM_ERROR_NONE) - return __player_convert_error_code(ret, (char *)__FUNCTION__); - - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD] = callback; - handle->user_data[MUSE_PLAYER_EVENT_TYPE_PD] = user_data; - LOGI("[%s] Event type : %d ", __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PD); - return PLAYER_ERROR_NONE; -} - -int legacy_player_unset_progressive_download_message_cb(player_h player) -{ - PLAYER_INSTANCE_CHECK(player); - player_s *handle = (player_s *)player; - - LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD] = NULL; - handle->user_data[MUSE_PLAYER_EVENT_TYPE_PD] = NULL; - LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); - LOGI("[%s] Event type : %d ", __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PD); - - int ret = mm_player_set_pd_message_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 legacy_player_release_video_stream_bo(player_h player, void* bo) { PLAYER_INSTANCE_CHECK(player); diff --git a/muse/api.list b/muse/api.list index 9a7f85d..837a155 100644 --- a/muse/api.list +++ b/muse/api.list @@ -48,8 +48,6 @@ audio_effect_get_equalizer_band_frequency audio_effect_get_equalizer_band_frequency_range audio_effect_equalizer_clear audio_effect_equalizer_is_available -set_progressive_download_path -get_progressive_download_status capture_video set_streaming_cookie set_streaming_user_agent diff --git a/muse/include/muse_player.h b/muse/include/muse_player.h index 4e559a6..1aaba4c 100644 --- a/muse/include/muse_player.h +++ b/muse/include/muse_player.h @@ -66,7 +66,6 @@ typedef enum { MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME, MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME, MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR, - MUSE_PLAYER_EVENT_TYPE_PD, MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT, MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET, MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN, diff --git a/muse/src/muse_player.c b/muse/src/muse_player.c index 2148723..858e274 100644 --- a/muse/src/muse_player.c +++ b/muse/src/muse_player.c @@ -585,17 +585,6 @@ static void _capture_video_cb(unsigned char *data, int width, int height, unsign return; } -static void _pd_msg_cb(player_pd_message_type_e type, void *user_data) -{ - muse_player_cb_e api = MUSE_PLAYER_CB_EVENT; - muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PD; - muse_module_h module = (muse_module_h)user_data; - - LOGD("ENTER"); - - PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "type", (int)type); -} - static int _get_tbm_surface_format(int in_format, uint32_t *out_format) { if (in_format <= MM_PIXEL_FORMAT_INVALID || in_format >= MM_PIXEL_FORMAT_NUM || out_format == NULL) { @@ -966,19 +955,6 @@ static void _set_buffering_cb(player_h player, void *module, bool set) legacy_player_unset_buffering_cb(player); } -static void _set_pd_msg_cb(player_h player, void *module, bool set) -{ - int ret = PLAYER_ERROR_NONE; - muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK; - - if (set) - ret = legacy_player_set_progressive_download_message_cb(player, _pd_msg_cb, module); - else - ret = legacy_player_unset_progressive_download_message_cb(player); - - PLAYER_RETURN_MSG(api, ret, module); -} - static void _set_media_packet_video_frame_cb(player_h player, void *data, bool set) { int ret = PLAYER_ERROR_NONE; @@ -1108,7 +1084,6 @@ static void (*set_callback_func[MUSE_PLAYER_EVENT_TYPE_NUM])(player_h player, vo _set_media_packet_video_frame_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */ NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME */ NULL, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */ - _set_pd_msg_cb, /* MUSE_PLAYER_EVENT_TYPE_PD */ NULL, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */ NULL, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */ NULL, /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */ @@ -2410,42 +2385,6 @@ int player_disp_audio_effect_equalizer_is_available(muse_module_h module) return ret; } -int player_disp_set_progressive_download_path(muse_module_h module) -{ - int ret = PLAYER_ERROR_NONE; - muse_player_handle_s *muse_player = NULL; - muse_player_api_e api = MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH; - char dw_path[MUSE_URI_MAX_LENGTH] = { 0, }; - - muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); - player_msg_get_string(dw_path, muse_server_module_get_msg(module)); - - if ((ret = _check_supportable(module, dw_path)) == PLAYER_ERROR_NONE) - ret = legacy_player_set_progressive_download_path(muse_player->player_handle, dw_path); - - PLAYER_RETURN_MSG(api, ret, module); - return ret; -} - -int player_disp_get_progressive_download_status(muse_module_h module) -{ - int ret = PLAYER_ERROR_NONE; - muse_player_handle_s *muse_player = NULL; - muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS; - unsigned long current = 0; - unsigned long total_size = 0; - - muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); - - ret = legacy_player_get_progressive_download_status(muse_player->player_handle, ¤t, &total_size); - - PLAYER_RETURN_MSG(api, ret, module, - MUSE_TYPE_POINTER, "current", (POINTER)current, - MUSE_TYPE_POINTER, "total_size", (POINTER)total_size); - - return ret; -} - int player_disp_capture_video(muse_module_h module) { int ret = PLAYER_ERROR_NONE; diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index b33034f..c9a6776 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.91 +Version: 0.2.92 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From aa006b32c934e185679255017ab8e8a70f0f6d31 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Fri, 7 Dec 2018 15:07:34 +0900 Subject: [PATCH 08/16] [0.2.93] fix dlog format error Change-Id: I7e874da33ffbca0d6cb8800698c4a3aee4bbec4c --- legacy/src/legacy_player.c | 10 +++++----- packaging/mmsvc-player.spec | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 1f710c8..6586c1f 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -2462,11 +2462,11 @@ int legacy_player_set_display(player_h player, player_display_type_e type, unsig if (ret != MM_ERROR_NONE) { handle->display_handle = temp; - LOGE("[%s] Failed to display surface change :%d", __FUNCTION__, ret); + LOGE("Failed to display surface change: %d", ret); } else { if (type != PLAYER_DISPLAY_TYPE_NONE) { handle->display_type = type; - LOGI("[%s] video display has been changed- type :%d, addr : 0x%x", __FUNCTION__, handle->display_type, handle->display_handle); + LOGI("video display has been changed- type: %d, addr: %p", handle->display_type, handle->display_handle); } else { LOGI("NULL surface"); } @@ -2477,14 +2477,14 @@ int legacy_player_set_display(player_h player, player_display_type_e type, unsig if (ret != MM_ERROR_NONE) { handle->display_handle = temp; if (ret == MM_ERROR_NOT_SUPPORT_API) { - LOGE("[%s] change video sink is not available.", __FUNCTION__); + LOGE("change video sink is not available."); ret = PLAYER_ERROR_NONE; } else { - LOGE("[%s] Failed to display surface change :%d", __FUNCTION__, ret); + LOGE("Failed to display surface change: %d", ret); } } else { handle->display_type = type; - LOGI("[%s] video display has been changed- type :%d, addr : 0x%x", __FUNCTION__, handle->display_type, handle->display_handle); + LOGI("video display has been changed- type: %d, addr: %p", handle->display_type, handle->display_handle); } } diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index c9a6776..e8874f7 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.92 +Version: 0.2.93 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From 2a40fcad770ebc9a9f298c2377a4498e0757f21f Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Mon, 10 Dec 2018 14:15:14 +0900 Subject: [PATCH 09/16] [0.2.94] remove additional handling of lang code - move the language code converting and error handling to libmm-player Change-Id: I7b036b345bee2ed6467ecc8aa7b64a03c097b6cb --- legacy/src/legacy_player.c | 30 +++++++----------------------- packaging/mmsvc-player.spec | 2 +- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 6586c1f..b83ab76 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -2315,7 +2315,6 @@ int legacy_player_get_track_language_code(player_h player, player_stream_type_e return PLAYER_ERROR_INVALID_STATE; } - char *language_code = NULL; MMPlayerTrackType track_type = 0; switch (type) { case PLAYER_STREAM_TYPE_AUDIO: @@ -2332,31 +2331,16 @@ int legacy_player_get_track_language_code(player_h player, player_stream_type_e 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); + *code = NULL; + int ret = mm_player_get_track_language_code(handle->mm_handle, track_type, index, code); - language_code = NULL; + if (ret != MM_ERROR_NONE) { return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - int code_len = 0; - *code = NULL; - if (language_code != NULL && strncmp(language_code, "und", 3)) { - code_len = 2; - *code = strndup(language_code, code_len); - } else { - code_len = 3; - *code = strndup("und", code_len); - } - *len = code_len; - - if (language_code) - free(language_code); - - language_code = NULL; - return PLAYER_ERROR_NONE; } + + LOGD("idx %d, lang code %s", index, *code); + *len = strlen(*code); + return PLAYER_ERROR_NONE; } int legacy_player_set_video_roi_area(player_h player, double scale_x, diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index e8874f7..5df9c50 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.93 +Version: 0.2.94 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From a01796fe88e0980fb9f6ab308c9889c318022b24 Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Fri, 14 Dec 2018 15:31:49 +0900 Subject: [PATCH 10/16] [0.2.95] Change memory allocation fuction malloc() to g_try_new0() Change-Id: I6c082d8bdbd78c70b27ec16fc7db0235d4a1a560 --- legacy/src/legacy_player.c | 10 ++++------ muse/src/muse_player.c | 13 ++++++------- packaging/mmsvc-player.spec | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index b83ab76..8627411 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -592,10 +592,8 @@ int legacy_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) - memset(handle, 0, sizeof(player_s)); - else { + handle = g_try_new0(player_s, 1); + if (!handle) { LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, PLAYER_ERROR_OUT_OF_MEMORY); return PLAYER_ERROR_OUT_OF_MEMORY; } @@ -603,7 +601,7 @@ int legacy_player_create(player_h *player) if (ret != MM_ERROR_NONE) { LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE); - free(handle); + g_free(handle); handle = NULL; return __player_convert_error_code(ret, (char *)__FUNCTION__); } else { @@ -687,7 +685,7 @@ int legacy_player_destroy(player_h player) g_mutex_clear(&handle->message_queue_lock); g_cond_clear(&handle->message_queue_cond); - free(handle); + g_free(handle); handle = NULL; LOGI("[%s] End", __FUNCTION__); PLAYER_TRACE_END(); diff --git a/muse/src/muse_player.c b/muse/src/muse_player.c index 858e274..1099abf 100644 --- a/muse/src/muse_player.c +++ b/muse/src/muse_player.c @@ -91,7 +91,7 @@ static bool _create_export_data(muse_player_handle_s *muse_player, void *data, i return FALSE; } - export_data = g_new0(muse_player_export_data_s, 1); + export_data = g_try_new0(muse_player_export_data_s, 1); if (export_data == NULL) { LOGE("failed to alloc export_data"); return FALSE; @@ -1325,14 +1325,13 @@ int player_disp_create(muse_module_h module) player_msg_get(pid, muse_server_module_get_msg(module)); /* init handle */ - muse_player = (muse_player_handle_s *)malloc(sizeof(muse_player_handle_s)); - if (muse_player == NULL) { + muse_player = g_try_new0(muse_player_handle_s, 1); + if (!muse_player) { ret = PLAYER_ERROR_OUT_OF_MEMORY; LOGE("failed to alloc handle 0x%x", ret); PLAYER_RETURN_MSG(api, ret, module); return ret; } - memset(muse_player, 0x0, sizeof(muse_player_handle_s)); /* get buffer mgr */ if (muse_server_ipc_get_bufmgr(&muse_player->bufmgr) != MM_ERROR_NONE) { @@ -1360,7 +1359,7 @@ int player_disp_create(muse_module_h module) ERROR: legacy_player_destroy(muse_player->player_handle); - free(muse_player); + g_free(muse_player); muse_player = NULL; PLAYER_RETURN_MSG(api, ret, module); return ret; @@ -1393,7 +1392,7 @@ int player_disp_destroy(muse_module_h module) muse_player->bufmgr = NULL; - free(muse_player); + g_free(muse_player); muse_player = NULL; PLAYER_RETURN_MSG(api, ret, module); @@ -1440,7 +1439,7 @@ int player_disp_prepare_async(muse_module_h module) muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); - prepare_data = g_new(prepare_data_s, 1); + prepare_data = g_try_new(prepare_data_s, 1); if (!prepare_data) { ret = PLAYER_ERROR_INVALID_OPERATION; goto ERROR; diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 5df9c50..df462fa 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.94 +Version: 0.2.95 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From 8b6bb2903fbd448ba8ba7dc865cb482b213d9a64 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Mon, 17 Dec 2018 17:15:36 +0900 Subject: [PATCH 11/16] [0.2.95] extend the pre-condition of _get_streaming_download_progress() - extend the pre-condition of _get_streaming_download_progress() which is related to the ACR-1329 - apply the changed interface of mm_player_get_buffer_position() - rename paramter of _get_streaming_download_progress() to make clear the meaning Change-Id: I2cf86b7f89c9fdea5dcd48343b53fa7ec5e0f696 --- legacy/include/legacy_player.h | 4 ++-- legacy/include/legacy_player_private.h | 2 +- legacy/src/legacy_player.c | 28 +++++++++++++--------------- muse/src/muse_player.c | 6 +++--- packaging/mmsvc-player.spec | 2 +- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/legacy/include/legacy_player.h b/legacy/include/legacy_player.h index c587fa3..40b861e 100644 --- a/legacy/include/legacy_player.h +++ b/legacy/include/legacy_player.h @@ -1501,7 +1501,7 @@ int legacy_player_set_streaming_user_agent(player_h player, const char *user_age * @since_tizen 2.3 * @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] + * @param[out] end The end position in percentage [0, 100] * @return @c 0 on success, * otherwise a negative error value * @retval #PLAYER_ERROR_NONE Successful @@ -1510,7 +1510,7 @@ int legacy_player_set_streaming_user_agent(player_h player, const char *user_age * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause(). */ -int legacy_player_get_streaming_download_progress(player_h player, int *start, int *current); +int legacy_player_get_streaming_download_progress(player_h player, int *start, int *end); /** * @brief Registers a callback function to be invoked when the playback is finished. diff --git a/legacy/include/legacy_player_private.h b/legacy/include/legacy_player_private.h index 3bee2a1..90d5b56 100644 --- a/legacy/include/legacy_player_private.h +++ b/legacy/include/legacy_player_private.h @@ -36,7 +36,7 @@ do { \ PLAYER_CHECK_CONDITION(player->state == expected_state, PLAYER_ERROR_INVALID_STATE, "PLAYER_ERROR_INVALID_STATE") #define PLAYER_NULL_ARG_CHECK(arg) \ - PLAYER_CHECK_CONDITION(arg != NULL, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") + PLAYER_CHECK_CONDITION((arg), PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") #define PLAYER_RANGE_ARG_CHECK(arg, min, max) \ do { \ diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index b83ab76..8398f2e 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -1812,26 +1812,24 @@ int legacy_player_set_streaming_user_agent(player_h player, const char *user_age return PLAYER_ERROR_NONE; } -int legacy_player_get_streaming_download_progress(player_h player, int *start, int *current) +int legacy_player_get_streaming_download_progress(player_h player, int *start_pos, int *end_pos) { - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(start); - PLAYER_NULL_ARG_CHECK(current); + int ret = MM_ERROR_NONE; player_s *handle = (player_s *)player; - if (handle->state != PLAYER_STATE_PLAYING && handle->state != PLAYER_STATE_PAUSED) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(start_pos && end_pos); + + if (!__player_state_validate(handle, PLAYER_STATE_READY)) { + LOGE("invalid state error, current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } - unsigned long _current = 0; - unsigned long _start = 0; - int ret = mm_player_get_buffer_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_PERCENT, &_start, &_current); - if (ret != MM_ERROR_NONE) { + + ret = mm_player_get_buffer_position(handle->mm_handle, start_pos, end_pos); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *start = (int)_start; - *current = (int)_current; - return PLAYER_ERROR_NONE; - } + + return PLAYER_ERROR_NONE; } int legacy_player_set_completed_cb(player_h player, player_completed_cb callback, void *user_data) diff --git a/muse/src/muse_player.c b/muse/src/muse_player.c index 858e274..6998368 100644 --- a/muse/src/muse_player.c +++ b/muse/src/muse_player.c @@ -2483,13 +2483,13 @@ int player_disp_get_streaming_download_progress(muse_module_h module) int ret = PLAYER_ERROR_NONE; muse_player_handle_s *muse_player = NULL; muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS; - int start, current; + int start_pos = 0, end_pos = 0; muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); - ret = legacy_player_get_streaming_download_progress(muse_player->player_handle, &start, ¤t); + ret = legacy_player_get_streaming_download_progress(muse_player->player_handle, &start_pos, &end_pos); - PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "start", start, MUSE_TYPE_INT, "current", current); + PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "start_pos", start_pos, MUSE_TYPE_INT, "end_pos", end_pos); return ret; } diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 5df9c50..df462fa 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.94 +Version: 0.2.95 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From 70b1ae062d03affeb8beb58dab5b5abc07834c36 Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Wed, 19 Dec 2018 16:19:36 +0900 Subject: [PATCH 12/16] [0.2.96] Apply tizen coding rule - modify space and brace - Change FALSE to false, TRUE to true, if variable type is bool. - Change postion of the variable declaration to top. Change-Id: I245d6f0c7f8a9d2ed48f42905f49a31a80127f41 --- legacy/include/legacy_player.h | 53 +- legacy/include/legacy_player_internal.h | 34 +- legacy/include/legacy_player_private.h | 60 +- legacy/src/legacy_player.c | 1289 +++++++++++++++---------------- legacy/src/legacy_player_internal.c | 166 ++-- muse/include/muse_player.h | 30 +- muse/include/muse_player_msg.h | 32 +- muse/include/muse_player_private.h | 28 +- muse/src/muse_player.c | 190 ++--- muse/src/muse_player_dispatcher.c | 31 +- muse/test/build_verify.c | 34 +- packaging/mmsvc-player.spec | 2 +- 12 files changed, 971 insertions(+), 978 deletions(-) diff --git a/legacy/include/legacy_player.h b/legacy/include/legacy_player.h index 40b861e..429192c 100644 --- a/legacy/include/legacy_player.h +++ b/legacy/include/legacy_player.h @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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_LEGACY_PLAYER_H__ #define __TIZEN_MEDIA_LEGACY_PLAYER_H__ @@ -134,14 +134,14 @@ typedef enum { * @brief The player display handle. * @since_tizen 2.3 */ -typedef void* player_display_h; +typedef void *player_display_h; #ifndef GET_DISPLAY /** * @brief Definition for a display handle from evas object. * @since_tizen 2.3 */ -#define GET_DISPLAY(x) (void*)(x) +#define GET_DISPLAY(x) (void *)(x) #endif /** @@ -329,7 +329,7 @@ typedef bool (*legacy_player_media_packet_video_decoded_cb)(void *video_data, vo * @see legacy_player_set_media_stream_buffer_max_size() * @see legacy_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); +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. @@ -339,7 +339,7 @@ typedef void (*player_media_stream_buffer_status_cb) (player_media_stream_buffer * @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); +typedef void (*player_media_stream_seek_cb)(unsigned long long offset, void *user_data); /** * @brief Called to notify the video stream changed. @@ -354,7 +354,7 @@ typedef void (*player_media_stream_seek_cb) (unsigned long long offset, void *us * @param[in] user_data The user data passed from the callback registration function * @see legacy_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); +typedef void (*player_video_stream_changed_cb)(int width, int height, int fps, int bit_rate, void *user_data); #ifdef TIZEN_FEATURE_EVAS_RENDERER /** @@ -454,7 +454,7 @@ int legacy_player_prepare(player_h player); * @see legacy_player_unprepare() * @see legacy_player_set_uri() */ -int legacy_player_prepare_async(player_h player, player_prepared_cb callback, void* user_data); +int legacy_player_prepare_async(player_h player, player_prepared_cb callback, void *user_data); /** * @brief Resets the media player. @@ -496,7 +496,7 @@ int legacy_player_unprepare(player_h player); * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare(). * @see legacy_player_set_memory_buffer() */ -int legacy_player_set_uri(player_h player, const char * uri); +int legacy_player_set_uri(player_h player, const char *uri); /** * @brief Sets memory as the data source. @@ -518,7 +518,7 @@ int legacy_player_set_uri(player_h player, const char * uri); * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare(). * @see legacy_player_set_uri() */ -int legacy_player_set_memory_buffer(player_h player, const void * data, int size); +int legacy_player_set_memory_buffer(player_h player, const void *data, int size); /** * @brief Gets the player's current state. @@ -828,7 +828,7 @@ int legacy_player_is_looping(player_h player, bool *looping); */ int legacy_player_set_display(player_h player, player_display_type_e type, unsigned int wl_surface_id); -int legacy_player_release_video_stream_bo(player_h player, void* bo); +int legacy_player_release_video_stream_bo(player_h player, void *bo); /** * @brief Registers a media packet video callback function to be called once per frame. @@ -1099,7 +1099,7 @@ int legacy_player_set_display_visible(player_h player, bool visible); * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @see legacy_player_set_display_visible() */ -int legacy_player_is_display_visible(player_h player, bool* visible); +int legacy_player_is_display_visible(player_h player, bool *visible); /** * @brief Sets the rotation settings of the video surface display. @@ -1159,7 +1159,7 @@ int legacy_player_get_display_rotation(player_h player, player_display_rotation_ * @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 legacy_player_get_content_info(player_h player, player_content_info_e key, char ** value); +int legacy_player_get_content_info(player_h player, player_content_info_e key, char **value); /** * @brief Gets the audio and video codec information. @@ -1372,7 +1372,7 @@ int legacy_player_audio_effect_set_equalizer_all_bands(player_h player, int *ban * @see legacy_player_audio_effect_set_equalizer_band_level() * @see legacy_player_audio_effect_set_equalizer_all_bands() */ -int legacy_player_audio_effect_get_equalizer_level_range(player_h player, int* min, int* max); +int legacy_player_audio_effect_get_equalizer_level_range(player_h player, int *min, int *max); /** * @brief Gets the band frequency of the equalizer. @@ -2134,4 +2134,3 @@ int legacy_player_is_replaygain_enabled(player_h player, bool *enabled); #endif #endif /* __TIZEN_MEDIA_LEGACY_PLAYER_H__ */ - diff --git a/legacy/include/legacy_player_internal.h b/legacy/include/legacy_player_internal.h index de70958..a2ca551 100644 --- a/legacy/include/legacy_player_internal.h +++ b/legacy/include/legacy_player_internal.h @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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_LEGACY_PLAYER_INTERNAL_H__ #define __TIZEN_MEDIA_LEGACY_PLAYER_INTERNAL_H__ @@ -77,7 +77,7 @@ typedef void (*player_audio_pcm_extraction_cb)(player_audio_raw_data_s *audio_ra * @see legacy_player_set_media_stream_buffer_max_size() * @see legacy_player_set_media_stream_buffer_min_threshold() */ -typedef void (*player_media_stream_buffer_status_cb_ex) (player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data); +typedef void (*player_media_stream_buffer_status_cb_ex)(player_media_stream_buffer_status_e status, unsigned long long bytes, 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. @@ -262,7 +262,7 @@ int legacy_player_set_gapless(player_h player, bool gapless); */ int legacy_player_is_gapless(player_h player, bool *gapless); - /** +/** * @brief Enables media_packet callback * @since_tizen 3.0 * @details If it is @c true, media_packet callback will be activated. @@ -326,5 +326,3 @@ int legacy_player_get_codec_type(player_h player, player_stream_type_e stream_ty #endif #endif //__TIZEN_MEDIA_LEGACY_PLAYER_INTERNAL_H__ - - diff --git a/legacy/include/legacy_player_private.h b/legacy/include/legacy_player_private.h index 90d5b56..f638d70 100644 --- a/legacy/include/legacy_player_private.h +++ b/legacy/include/legacy_player_private.h @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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_LEGACY_PLAYER_PRIVATE_H__ #define __TIZEN_MEDIA_LEGACY_PLAYER_PRIVATE_H__ @@ -24,10 +24,10 @@ extern "C" { #endif #define PLAYER_CHECK_CONDITION(condition, error, msg) \ -do { \ - if (condition) {} else \ - { LOGE("[%s] %s(0x%08x)", __FUNCTION__, msg, error); return error; } \ -} while (0) + do { \ + if (condition) {} else \ + { LOGE("[%s] %s(0x%08x)", __FUNCTION__, msg, error); return error; } \ + } while (0) #define PLAYER_INSTANCE_CHECK(player) \ PLAYER_CHECK_CONDITION(player != NULL, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") @@ -39,22 +39,22 @@ do { \ PLAYER_CHECK_CONDITION((arg), PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") #define PLAYER_RANGE_ARG_CHECK(arg, min, max) \ -do { \ - 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"); \ -} while (0) + do { \ + 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"); \ + } while (0) /* user_cb_lock */ #define LEGACY_PLAYER_USER_CB_LOCK(x_handle, type) \ do { \ if (_check_enabled_user_cb_lock(type)) \ - g_mutex_lock(&((player_s*)x_handle)->user_cb_lock[type]); \ + g_mutex_lock(&((player_s *)x_handle)->user_cb_lock[type]); \ } while (0) #define LEGACY_PLAYER_USER_CB_UNLOCK(x_handle, type) \ do { \ if (_check_enabled_user_cb_lock(type)) \ - g_mutex_unlock(&((player_s*)x_handle)->user_cb_lock[type]); \ + g_mutex_unlock(&((player_s *)x_handle)->user_cb_lock[type]); \ } while (0) @@ -99,11 +99,11 @@ typedef enum { typedef struct _player_s { MMHandleType mm_handle; - const void* user_cb[MUSE_PLAYER_EVENT_TYPE_NUM]; - void* user_data[MUSE_PLAYER_EVENT_TYPE_NUM]; + const void *user_cb[MUSE_PLAYER_EVENT_TYPE_NUM]; + void *user_data[MUSE_PLAYER_EVENT_TYPE_NUM]; GMutex user_cb_lock[MUSE_PLAYER_EVENT_TYPE_NUM]; - void* wl_display; - void* display_handle; + void *wl_display; + void *display_handle; player_display_type_e display_type; player_state_e state; player_internal_state_e internal_state; @@ -119,8 +119,8 @@ typedef struct _player_s { int64_t last_play_position; } player_s; -int __player_convert_error_code(int code, char* func_name); -bool __player_state_validate(player_s * handle, player_state_e threshold); +int __player_convert_error_code(int code, char *func_name); +bool __player_state_validate(player_s *handle, player_state_e threshold); #ifdef __cplusplus } diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 5838f64..17455fc 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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 @@ -80,8 +80,8 @@ } while (0) /* -* Internal Implementation -*/ + * Internal Implementation + */ int __player_convert_error_code(int code, char *func_name) { int ret = PLAYER_ERROR_INVALID_OPERATION; @@ -278,15 +278,16 @@ bool __player_state_validate(player_s *handle, player_state_e threshold) { if (handle->state < threshold) return false; + return true; } static int __set_callback(muse_player_event_e type, player_h player, void *callback, void *user_data) { + player_s *handle = (player_s *)player; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); - player_s *handle = (player_s *)player; handle->user_cb[type] = callback; handle->user_data[type] = user_data; LOGI("[%s] Event type : %d ", __FUNCTION__, type); @@ -295,8 +296,8 @@ static int __set_callback(muse_player_event_e type, player_h player, void *callb static int __unset_callback(muse_player_event_e type, player_h player) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + PLAYER_INSTANCE_CHECK(player); handle->user_cb[type] = NULL; handle->user_data[type] = NULL; LOGI("[%s] Event type : %d ", __FUNCTION__, type); @@ -305,7 +306,7 @@ static int __unset_callback(muse_player_event_e type, player_h player) static void __message_cb_loop(void *data) { - bool running = TRUE; + bool running = true; player_s *handle = (player_s *)data; if (!handle) { LOGE("null handle in __message_cb_loop"); @@ -317,7 +318,7 @@ static void __message_cb_loop(void *data) case PLAYER_MESSAGE_NONE: { LOGW("PLAYER_MESSAGE_NONE"); - running = FALSE; + running = false; } break; case PLAYER_MESSAGE_PREPARED: @@ -370,24 +371,23 @@ static void __message_cb_loop(void *data) case PLAYER_MESSAGE_GAPLESS_CONSTRUCTION: { LOGW("PLAYER_MESSAGE_GAPLESS_CONSTRUCTION"); - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]) { + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]) ((player_retrieve_buffer_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]); - } else { + else LOGE("null handle in PLAYER_MESSAGE_GAPLESS_CONSTRUCTION"); - } } break; #endif case PLAYER_MESSAGE_LOOP_EXIT: { LOGW("PLAYER_MESSAGE_LOOP_EXIT"); - running = FALSE; + running = false; } break; case PLAYER_MESSAGE_MAX: { LOGW("PLAYER_MESSAGE_MAX"); - running = FALSE; + running = false; } break; default: @@ -401,8 +401,8 @@ static player_state_e __convert_player_state(MMPlayerStateType state) { if (state == MM_PLAYER_STATE_NONE) return PLAYER_STATE_NONE; - else - return state +1; + + return state + 1; } static int __msg_callback(int message, void *param, void *user_data) @@ -443,15 +443,13 @@ static int __msg_callback(int message, void *param, void *user_data) LOGI("[%s] Ready to streaming information (BOS) [current state : %d]", __FUNCTION__, handle->state); break; case MM_MESSAGE_END_OF_STREAM: /* 0x105 */ - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE]) { + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE]) __ADD_MESSAGE(handle, PLAYER_MESSAGE_EOS); - } break; #ifdef TIZEN_FEATURE_EVAS_RENDERER case MM_MESSAGE_GAPLESS_CONSTRUCTION: /* 0x105 */ - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]) { + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]) __ADD_MESSAGE(handle, PLAYER_MESSAGE_GAPLESS_CONSTRUCTION); - } break; #endif case MM_MESSAGE_BUFFERING: /* 0x103 */ @@ -503,7 +501,7 @@ static int __msg_callback(int message, void *param, void *user_data) } /* capure->data have to be released to avoid mem leak in all cases. */ - if (capture && capture->data) { + if (capture) { g_free(capture->data); capture->data = NULL; } @@ -577,78 +575,78 @@ bool _check_enabled_user_cb_lock(int type) case MUSE_PLAYER_EVENT_TYPE_PREPARE: /* fall through */ case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO: /* fall through */ case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO: /* fall through */ - return TRUE; + return true; default: - return FALSE; + return false; } } /* -* Public Implementation -*/ + * Public Implementation + */ int legacy_player_create(player_h *player) { + player_s *handle; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_TRACE_BEGIN("MM:PLAYER:CREATE"); - player_s *handle; handle = g_try_new0(player_s, 1); if (!handle) { LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, PLAYER_ERROR_OUT_OF_MEMORY); return PLAYER_ERROR_OUT_OF_MEMORY; } - int ret = mm_player_create(&handle->mm_handle); + ret = mm_player_create(&handle->mm_handle); if (ret != MM_ERROR_NONE) { LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE); g_free(handle); handle = NULL; return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE; + } - *player = (player_h)handle; - __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); - handle->display_type = PLAYER_DISPLAY_TYPE_NONE; - handle->is_display_visible = TRUE; - handle->is_media_stream = FALSE; + muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE; - for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) { - if (_check_enabled_user_cb_lock(type)) - g_mutex_init(&handle->user_cb_lock[type]); - } + *player = (player_h)handle; + __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); + handle->display_type = PLAYER_DISPLAY_TYPE_NONE; + handle->is_display_visible = true; + handle->is_media_stream = false; - 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; - } + for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) { + if (_check_enabled_user_cb_lock(type)) + g_mutex_init(&handle->user_cb_lock[type]); + } - LOGI("[%s] new handle : %p", __FUNCTION__, *player); - PLAYER_TRACE_END(); - return PLAYER_ERROR_NONE; + 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; } + + LOGI("[%s] new handle : %p", __FUNCTION__, *player); + PLAYER_TRACE_END(); + return PLAYER_ERROR_NONE; } int legacy_player_destroy(player_h player) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; 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; __ADD_MESSAGE(handle, PLAYER_MESSAGE_LOOP_EXIT); LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; - if (handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { - g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]); - handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; - } + g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]); + handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); @@ -659,38 +657,36 @@ int legacy_player_destroy(player_h player) __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread); __RELEASEIF_MESSAGE_THREAD(handle->message_thread); - int ret = mm_player_destroy(handle->mm_handle); - - LOGI("[%s] Done mm_player_destroy", __FUNCTION__); - + ret = mm_player_destroy(handle->mm_handle); if (ret != MM_ERROR_NONE) { LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); return PLAYER_ERROR_INVALID_OPERATION; - } else { - muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE; - - __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE); + } + LOGI("[%s] Done mm_player_destroy", __FUNCTION__); - for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) { - if (_check_enabled_user_cb_lock(type)) - g_mutex_clear(&handle->user_cb_lock[type]); - } + muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE; - if (handle->message_queue) { - g_queue_free(handle->message_queue); - handle->message_queue = NULL; - } + __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE); - g_cond_broadcast(&handle->message_queue_cond); - g_mutex_clear(&handle->message_queue_lock); - g_cond_clear(&handle->message_queue_cond); + for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) { + if (_check_enabled_user_cb_lock(type)) + g_mutex_clear(&handle->user_cb_lock[type]); + } - g_free(handle); - handle = NULL; - LOGI("[%s] End", __FUNCTION__); - PLAYER_TRACE_END(); - return PLAYER_ERROR_NONE; + 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); + + g_free(handle); + handle = NULL; + LOGI("[%s] End", __FUNCTION__); + PLAYER_TRACE_END(); + return PLAYER_ERROR_NONE; } static void *__prepare_async_thread_func(void *data) @@ -720,13 +716,13 @@ static void *__prepare_async_thread_func(void *data) int legacy_player_prepare_async(player_h player, player_prepared_cb callback, void *user_data) { + player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; int visible = 0; int value = 0; 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); @@ -739,11 +735,12 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); return PLAYER_ERROR_INVALID_OPERATION; - } else { - /* LOGI("[%s] Event type : %d ",__FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PREPARE); */ - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback; - handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data; } + + /* LOGI("[%s] Event type : %d ",__FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PREPARE); */ + handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback; + handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data; + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle); @@ -812,12 +809,11 @@ int legacy_player_prepare(player_h player) { int ret = MM_ERROR_NONE; int visible = 0; - int value = 0; + player_s *handle = (player_s *)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); __player_update_state(handle, PLAYER_INTERNAL_STATE_PRE_READY); @@ -837,15 +833,9 @@ int legacy_player_prepare(player_h player) return __player_convert_error_code(ret, (char *)__FUNCTION__); } - if (!visible) - value = FALSE; - else - value = TRUE; - - ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL); - + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", visible, (char *)NULL); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set display display_visible '0' (0x%x)", __FUNCTION__, ret); + LOGW("[%s] Failed to set display display_visible '%d' (0x%x)", __FUNCTION__, visible, ret); } ret = mm_player_realize(handle->mm_handle); @@ -865,20 +855,21 @@ int legacy_player_prepare(player_h player) LOGE("[%s] Failed to pause - 0x%x", __FUNCTION__, ret); __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - __player_update_state(handle, PLAYER_INTERNAL_STATE_READY); - LOGI("[%s] End", __FUNCTION__); - PLAYER_TRACE_END(); - return PLAYER_ERROR_NONE; } + + __player_update_state(handle, PLAYER_INTERNAL_STATE_READY); + LOGI("[%s] End", __FUNCTION__); + PLAYER_TRACE_END(); + return PLAYER_ERROR_NONE; } int legacy_player_unprepare(player_h player) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; LOGI("[%s] Start", __FUNCTION__); PLAYER_TRACE_BEGIN("MM:PLAYER:UNPREPARE"); PLAYER_INSTANCE_CHECK(player); - player_s *handle = (player_s *)player; /* Initialize the setting regardless of error return */ if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) { @@ -895,10 +886,8 @@ int legacy_player_unprepare(player_h player) if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { LOGW("Need to check. prepare cb have to be reset before"); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; - if (handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { - g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]); - handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; - } + g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]); + handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; } LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); @@ -908,161 +897,165 @@ int legacy_player_unprepare(player_h player) __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread); - int ret = mm_player_unrealize(handle->mm_handle); - - if (ret != MM_ERROR_NONE) { + ret = mm_player_unrealize(handle->mm_handle); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); - handle->is_display_visible = TRUE; - LOGI("[%s] End", __FUNCTION__); - PLAYER_TRACE_END(); - return PLAYER_ERROR_NONE; - } + + __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); + handle->is_display_visible = true; + LOGI("[%s] End", __FUNCTION__); + PLAYER_TRACE_END(); + return PLAYER_ERROR_NONE; } int legacy_player_set_uri(player_h player, const char *uri) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(uri); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - handle->is_media_stream = FALSE; - int ret = mm_player_set_uri(handle->mm_handle, uri); - + handle->is_media_stream = false; + ret = mm_player_set_uri(handle->mm_handle, uri); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_memory_buffer(player_h player, const void *data, int size) { + player_s *handle = (player_s *)player; + char uri[PATH_MAX]; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(data); PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - char uri[PATH_MAX]; handle->is_media_stream = FALSE; snprintf(uri, sizeof(uri), "mem:///ext=%s,size=%d", "", size); - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_CONTENT_URI, uri, strlen(uri), MM_PLAYER_MEMORY_SRC, data, size, (char *)NULL); + ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_CONTENT_URI, uri, strlen(uri), MM_PLAYER_MEMORY_SRC, data, size, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_state(player_h player, player_state_e *state) { + player_s *handle = (player_s *)player; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(state); - player_s *handle = (player_s *)player; *state = handle->state; return PLAYER_ERROR_NONE; } int legacy_player_set_volume(player_h player, float left, float right) { + player_s *handle = (player_s *)player; + MMPlayerVolumeType vol; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(left >= 0 && left <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); PLAYER_CHECK_CONDITION(right >= 0 && right <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); - player_s *handle = (player_s *)player; - MMPlayerVolumeType vol; + vol.level[MM_VOLUME_CHANNEL_LEFT] = left; vol.level[MM_VOLUME_CHANNEL_RIGHT] = right; - int ret = mm_player_set_volume(handle->mm_handle, &vol); + ret = mm_player_set_volume(handle->mm_handle, &vol); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_volume(player_h player, float *left, float *right) { + player_s *handle = (player_s *)player; + MMPlayerVolumeType vol; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(left); PLAYER_NULL_ARG_CHECK(right); - player_s *handle = (player_s *)player; - MMPlayerVolumeType vol; - int ret = mm_player_get_volume(handle->mm_handle, &vol); + + ret = mm_player_get_volume(handle->mm_handle, &vol); if (ret != MM_ERROR_NONE) { return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *left = vol.level[MM_VOLUME_CHANNEL_LEFT]; - *right = vol.level[MM_VOLUME_CHANNEL_RIGHT]; - return PLAYER_ERROR_NONE; } + + *left = vol.level[MM_VOLUME_CHANNEL_LEFT]; + *right = vol.level[MM_VOLUME_CHANNEL_RIGHT]; + return PLAYER_ERROR_NONE; } int legacy_player_set_sound_stream_info(player_h player, sound_stream_info_h stream_info) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + bool is_available = false; + PLAYER_INSTANCE_CHECK(player); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - bool is_available = FALSE; - /* check if stream_info is valid */ - int ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_PLAYER, &is_available); - - if (ret != MM_ERROR_NONE) { + ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_PLAYER, &is_available); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); + + if (is_available) { + char *stream_type = NULL; + int stream_index = 0; + ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type); + ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index); + if (ret == SOUND_MANAGER_ERROR_NONE) + ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index); + else + ret = MM_ERROR_PLAYER_INTERNAL; } else { - if (is_available == FALSE) - ret = MM_ERROR_NOT_SUPPORT_API; - else { - char *stream_type = NULL; - int stream_index = 0; - ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type); - ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index); - if (ret == SOUND_MANAGER_ERROR_NONE) - ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index); - else - ret = MM_ERROR_PLAYER_INTERNAL; - } + ret = MM_ERROR_NOT_SUPPORT_API; } if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); - int ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL); + ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } -int legacy_player_get_audio_latency_mode(player_h player, audio_latency_mode_e * latency_mode) +int legacy_player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency_mode) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(latency_mode); - player_s *handle = (player_s *)player; - int ret = mm_player_get_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL); + ret = mm_player_get_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_start(player_h player) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; LOGI("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); - player_s *handle = (player_s *)player; - int ret; + if (handle->state > PLAYER_STATE_IDLE) { if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY && handle->is_display_visible) { ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL); @@ -1083,21 +1076,20 @@ int legacy_player_start(player_h player) return PLAYER_ERROR_INVALID_STATE; } - if (ret != MM_ERROR_NONE) { + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - __player_update_state(handle, PLAYER_INTERNAL_STATE_PLAYING); - LOGI("[%s] End", __FUNCTION__); - return PLAYER_ERROR_NONE; - } + + __player_update_state(handle, PLAYER_INTERNAL_STATE_PLAYING); + LOGI("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; } int legacy_player_stop(player_h player) { - LOGI("[%s] Start", __FUNCTION__); - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + LOGI("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); if (handle->state == PLAYER_STATE_PLAYING || handle->state == PLAYER_STATE_PAUSED) { if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY) { @@ -1109,60 +1101,63 @@ int legacy_player_stop(player_h player) ret = mm_player_stop(handle->mm_handle); if (ret != MM_ERROR_NONE) { return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) { - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL; - handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL; - } - - __player_update_state(handle, PLAYER_INTERNAL_STATE_STOPPED); + } - LOGI("[%s] End", __FUNCTION__); - return PLAYER_ERROR_NONE; + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) { + handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL; + handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL; } - } else { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); - return PLAYER_ERROR_INVALID_STATE; + + __player_update_state(handle, PLAYER_INTERNAL_STATE_STOPPED); + + LOGI("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; } + + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; } int legacy_player_pause(player_h player) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; LOGI("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_PLAYING); - int ret = mm_player_pause(handle->mm_handle); - if (ret != MM_ERROR_NONE) { + ret = mm_player_pause(handle->mm_handle); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - __player_update_state(handle, PLAYER_INTERNAL_STATE_PAUSED); - LOGI("[%s] End", __FUNCTION__); - return PLAYER_ERROR_NONE; - } + + __player_update_state(handle, PLAYER_INTERNAL_STATE_PAUSED); + LOGI("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; } int legacy_player_set_play_position(player_h player, int64_t nanoseconds, bool accurate, player_seek_completed_cb callback, void *user_data) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + int accurated = accurate ? 1 : 0; PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(nanoseconds >= 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[MUSE_PLAYER_EVENT_TYPE_SEEK] && handle->is_media_stream == FALSE) { + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] && !handle->is_media_stream) { LOGE("[%s] PLAYER_ERROR_SEEK_FAILED temp (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, pos : %"PRId64, __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_SEEK, nanoseconds); - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback; - handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data; } - int accurated = accurate ? 1 : 0; - int ret = mm_player_set_attribute(handle->mm_handle, NULL, "accurate_seek", accurated, (char *)NULL); + + LOGI("[%s] Event type : %d, pos : %"PRId64, __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_SEEK, nanoseconds); + handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback; + handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data; + + ret = mm_player_set_attribute(handle->mm_handle, NULL, "accurate_seek", accurated, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -1171,24 +1166,25 @@ int legacy_player_set_play_position(player_h player, int64_t nanoseconds, bool a handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL; handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL; return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; } + + return PLAYER_ERROR_NONE; } int legacy_player_get_play_position(player_h player, int64_t *nanoseconds) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; int64_t pos = 0; - PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(nanoseconds); - 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_get_position(handle->mm_handle, &pos); + ret = mm_player_get_position(handle->mm_handle, &pos); if (ret != MM_ERROR_NONE) { if (ret == MM_ERROR_PLAYER_NOT_INITIALIZED) { /* During playbak if a interrupt is occurred, the player can be destroyed internally. @@ -1202,89 +1198,83 @@ int legacy_player_get_play_position(player_h player, int64_t *nanoseconds) return PLAYER_ERROR_NONE; } } - return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *nanoseconds = pos; - return PLAYER_ERROR_NONE; } + + *nanoseconds = pos; + return PLAYER_ERROR_NONE; } int legacy_player_set_mute(player_h player, bool muted) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); - int ret = mm_player_set_mute(handle->mm_handle, muted); + ret = mm_player_set_mute(handle->mm_handle, muted); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_is_muted(player_h player, bool *muted) { + player_s *handle = (player_s *)player; + int _mute; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(muted); - player_s *handle = (player_s *)player; - int _mute; - int ret = mm_player_get_mute(handle->mm_handle, &_mute); - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_mute(handle->mm_handle, &_mute); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - if (_mute) - *muted = TRUE; - else - *muted = FALSE; - return PLAYER_ERROR_NONE; - } + + *muted = (bool)_mute; + + return PLAYER_ERROR_NONE; } int legacy_player_set_looping(player_h player, bool looping) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; - + int ret = MM_ERROR_NONE; int value = 0; - if (looping == TRUE) - value = -1; + PLAYER_INSTANCE_CHECK(player); - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, value, (char *)NULL); + if (looping) + value = -1; + ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, value, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_is_looping(player_h player, bool *looping) { - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(looping); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; int count; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(looping); - int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, &count, (char *)NULL); - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_PLAYBACK_COUNT, &count, (char *)NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - if (count == -1) - *looping = TRUE; - else - *looping = FALSE; - return PLAYER_ERROR_NONE; - } + *looping = (count == -1) ? true : false; + + return PLAYER_ERROR_NONE; } int legacy_player_get_duration(player_h player, int64_t *duration) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(duration); - int ret = MM_ERROR_NONE; - - 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); @@ -1292,9 +1282,8 @@ int legacy_player_get_duration(player_h player, int64_t *duration) } ret = mm_player_get_duration(handle->mm_handle, duration); - if (ret != MM_ERROR_NONE) { + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } LOGD("content dur: %"PRId64, *duration); return PLAYER_ERROR_NONE; @@ -1302,43 +1291,46 @@ int legacy_player_get_duration(player_h player, int64_t *duration) int legacy_player_set_display_mode(player_h player, player_display_mode_e mode) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); LOGI("[%s] mode:%d", __FUNCTION__, mode); - int ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL); + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_display_mode(player_h player, player_display_mode_e *mode) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(mode); - player_s *handle = (player_s *)player; - int ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL); + + ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_playback_rate(player_h player, float rate) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; LOGI("[%s] rate : %0.1f", __FUNCTION__, rate); PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.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; } - int ret = mm_player_set_play_speed(handle->mm_handle, rate, FALSE); - + ret = mm_player_set_play_speed(handle->mm_handle, rate, false); switch (ret) { case MM_ERROR_NONE: case MM_ERROR_PLAYER_NO_OP: @@ -1352,84 +1344,87 @@ int legacy_player_set_playback_rate(player_h player, float rate) default: return __player_convert_error_code(ret, (char *)__FUNCTION__); } + return ret; } int legacy_player_set_display_rotation(player_h player, player_display_rotation_e rotation) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL); + ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_display_rotation(player_h player, player_display_rotation_e *rotation) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(rotation); - player_s *handle = (player_s *)player; - int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL); + + ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_ROTATION, rotation, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_display_visible(player_h player, bool visible) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; - + int ret = MM_ERROR_NONE; int value = 0; - if (visible == TRUE) + PLAYER_INSTANCE_CHECK(player); + + if (visible) value = 1; - int ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL); - if (ret != MM_ERROR_NONE) { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - handle->is_display_visible = visible; - return PLAYER_ERROR_NONE; - } + + handle->is_display_visible = visible; + return PLAYER_ERROR_NONE; } int legacy_player_is_display_visible(player_h player, bool *visible) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + int value; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(visible); - player_s *handle = (player_s *)player; - int count; - int ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &count, (char *)NULL); - if (ret != MM_ERROR_NONE) { + + ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &value, (char *)NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - if (count == 0) - *visible = FALSE; - else - *visible = TRUE; - return PLAYER_ERROR_NONE; - } + *visible = (value == 0) ? false : true; + + return PLAYER_ERROR_NONE; } int legacy_player_get_content_info(player_h player, player_content_info_e key, char **value) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + char *attr = NULL; + char *val = NULL; + int val_len = 0; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(value); - 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 *attr = NULL; - char *val = NULL; - int val_len = 0; - switch (key) { case PLAYER_CONTENT_INFO_ALBUM: attr = MM_PLAYER_TAG_ALBUM; @@ -1453,73 +1448,75 @@ int legacy_player_get_content_info(player_h player, player_content_info_e key, c attr = NULL; } - int ret = mm_player_get_attribute(handle->mm_handle, NULL, attr, &val, &val_len, (char *)NULL); - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_attribute(handle->mm_handle, NULL, attr, &val, &val_len, (char *)NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *value = NULL; - if (val != NULL) - *value = strndup(val, val_len); - else - *value = strndup("", 0); - if (*value == NULL) { - LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x) : fail to strdup ", __FUNCTION__, PLAYER_ERROR_OUT_OF_MEMORY); - return PLAYER_ERROR_OUT_OF_MEMORY; - } - return PLAYER_ERROR_NONE; + *value = NULL; + if (val != NULL) + *value = strndup(val, val_len); + else + *value = strndup("", 0); + + if (*value == NULL) { + LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x) : fail to strdup ", __FUNCTION__, PLAYER_ERROR_OUT_OF_MEMORY); + return PLAYER_ERROR_OUT_OF_MEMORY; } + + return PLAYER_ERROR_NONE; } int legacy_player_get_codec_info(player_h player, char **audio_codec, char **video_codec) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + char *audio = NULL; + int audio_len = 0; + char *video = NULL; + int video_len = 0; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(audio_codec); PLAYER_NULL_ARG_CHECK(video_codec); - 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 *audio = NULL; - int audio_len = 0; - char *video = NULL; - int video_len = 0; - - int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_CODEC, &audio, &audio_len, MM_PLAYER_VIDEO_CODEC, &video, &video_len, (char *)NULL); - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_CODEC, &audio, &audio_len, MM_PLAYER_VIDEO_CODEC, &video, &video_len, (char *)NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *audio_codec = NULL; - if (audio != NULL) - *audio_codec = strndup(audio, audio_len); - else - *audio_codec = strndup("", 0); - *video_codec = NULL; - if (video != NULL) - *video_codec = strndup(video, video_len); - else - *video_codec = strndup("", 0); + *audio_codec = NULL; + if (audio != NULL) + *audio_codec = strndup(audio, audio_len); + else + *audio_codec = strndup("", 0); - LOGD("codec info: %s, %s", *audio_codec, *video_codec); - return PLAYER_ERROR_NONE; - } + *video_codec = NULL; + if (video != NULL) + *video_codec = strndup(video, video_len); + else + *video_codec = strndup("", 0); + + LOGD("codec info: %s, %s", *audio_codec, *video_codec); + return PLAYER_ERROR_NONE; } int legacy_player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(sample_rate); PLAYER_NULL_ARG_CHECK(channel); PLAYER_NULL_ARG_CHECK(bit_rate); - 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; } - 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); + 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) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -1528,15 +1525,17 @@ int legacy_player_get_audio_stream_info(player_h player, int *sample_rate, int * int legacy_player_get_video_stream_info(player_h player, int *fps, int *bit_rate) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(fps); PLAYER_NULL_ARG_CHECK(bit_rate); - 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; } - int ret = mm_player_get_attribute(handle->mm_handle, NULL, "content_video_fps", fps, "content_video_bitrate", bit_rate, (char *)NULL); + ret = mm_player_get_attribute(handle->mm_handle, NULL, "content_video_fps", fps, "content_video_bitrate", bit_rate, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -1545,38 +1544,39 @@ int legacy_player_get_video_stream_info(player_h player, int *fps, int *bit_rate int legacy_player_get_video_size(player_h player, int *width, int *height) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + int w; + int h; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(width); PLAYER_NULL_ARG_CHECK(height); - 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; } - int w; - int h; - int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &w, MM_PLAYER_VIDEO_HEIGHT, &h, (char *)NULL); - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &w, MM_PLAYER_VIDEO_HEIGHT, &h, (char *)NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *width = w; - *height = h; - LOGI("[%s] width : %d, height : %d", __FUNCTION__, w, h); - return PLAYER_ERROR_NONE; - } + + *width = w; + *height = h; + LOGI("[%s] width : %d, height : %d", __FUNCTION__, w, h); + return PLAYER_ERROR_NONE; } int legacy_player_get_album_art(player_h player, void **album_art, int *size) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(size); - 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; } - int ret = mm_player_get_attribute(handle->mm_handle, NULL, "tag_album_cover", album_art, size, (char *)NULL); + ret = mm_player_get_attribute(handle->mm_handle, NULL, "tag_album_cover", album_art, size, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -1585,181 +1585,195 @@ int legacy_player_get_album_art(player_h player, void **album_art, int *size) int legacy_player_audio_effect_get_equalizer_bands_count(player_h player, int *count) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(count); - player_s *handle = (player_s *)player; - int ret = mm_player_audio_effect_custom_get_eq_bands_number(handle->mm_handle, count); + 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__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(band_levels); - player_s *handle = (player_s *)player; - int ret = mm_player_audio_effect_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length); - if (ret != MM_ERROR_NONE) { + ret = mm_player_audio_effect_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - ret = mm_player_audio_effect_custom_apply(handle->mm_handle); - return (ret == MM_ERROR_NONE) ? PLAYER_ERROR_NONE : __player_convert_error_code(ret, (char *)__FUNCTION__); - } + + ret = mm_player_audio_effect_custom_apply(handle->mm_handle); + return (ret == MM_ERROR_NONE) ? PLAYER_ERROR_NONE : __player_convert_error_code(ret, (char *)__FUNCTION__); } int legacy_player_audio_effect_set_equalizer_band_level(player_h player, int index, int level) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); - int ret = mm_player_audio_effect_custom_set_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level); - if (ret != MM_ERROR_NONE) { + ret = mm_player_audio_effect_custom_set_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - ret = mm_player_audio_effect_custom_apply(handle->mm_handle); - return (ret == MM_ERROR_NONE) ? PLAYER_ERROR_NONE : __player_convert_error_code(ret, (char *)__FUNCTION__); - } + + ret = mm_player_audio_effect_custom_apply(handle->mm_handle); + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + + return PLAYER_ERROR_NONE; } int legacy_player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(level); - player_s *handle = (player_s *)player; - int ret = mm_player_audio_effect_custom_get_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level); + 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__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_audio_effect_get_equalizer_level_range(player_h player, int *min, int *max) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(min); PLAYER_NULL_ARG_CHECK(max); - player_s *handle = (player_s *)player; - int ret = mm_player_audio_effect_custom_get_level_range(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, min, max); + 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__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *frequency) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(frequency); - player_s *handle = (player_s *)player; - int ret = mm_player_audio_effect_custom_get_eq_bands_freq(handle->mm_handle, index, frequency); + 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__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *range) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(range); - player_s *handle = (player_s *)player; - int ret = mm_player_audio_effect_custom_get_eq_bands_width(handle->mm_handle, index, range); + 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__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_audio_effect_equalizer_clear(player_h player) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); - int ret = mm_player_audio_effect_custom_clear_eq_all(handle->mm_handle); - if (ret != MM_ERROR_NONE) { + ret = mm_player_audio_effect_custom_clear_eq_all(handle->mm_handle); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - ret = mm_player_audio_effect_custom_apply(handle->mm_handle); - return (ret == MM_ERROR_NONE) ? PLAYER_ERROR_NONE : __player_convert_error_code(ret, (char *)__FUNCTION__); - } + + ret = mm_player_audio_effect_custom_apply(handle->mm_handle); + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + + return PLAYER_ERROR_NONE; } int legacy_player_audio_effect_equalizer_is_available(player_h player, bool *available) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; 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); + ret = mm_player_is_supported_custom_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ); if (ret != MM_ERROR_NONE) - *available = FALSE; + *available = false; else - *available = TRUE; + *available = true; + return PLAYER_ERROR_NONE; } int legacy_player_set_subtitle_path(player_h player, const char *path) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if ((path == NULL) && (handle->state != PLAYER_STATE_IDLE)) return PLAYER_ERROR_INVALID_PARAMETER; - int ret = mm_player_set_external_subtitle_path(handle->mm_handle, path); + ret = mm_player_set_external_subtitle_path(handle->mm_handle, path); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_subtitle_position_offset(player_h player, int millisecond) { - PLAYER_INSTANCE_CHECK(player); /* PLAYER_CHECK_CONDITION(millisecond>=0 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); */ player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_PLAYING)) { 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_adjust_subtitle_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond); + ret = mm_player_adjust_subtitle_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_capture_video(player_h player, player_video_captured_cb callback, void *user_data) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); - - player_s *handle = (player_s *)player; if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) { LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : capturing... we can't do any more ", __FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED); return PLAYER_ERROR_VIDEO_CAPTURE_FAILED; - } else { - LOGI("[%s] Event type : %d ", __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_CAPTURE); - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback; - handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data; } + LOGI("[%s] Event type : %d ", __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_CAPTURE); + handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback; + handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data; + if (handle->state >= PLAYER_STATE_READY) { - int ret = mm_player_do_video_capture(handle->mm_handle); + ret = mm_player_do_video_capture(handle->mm_handle); if (ret == MM_ERROR_PLAYER_NO_OP) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; @@ -1770,54 +1784,54 @@ int legacy_player_capture_video(player_h player, player_video_captured_cb callba handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else - return PLAYER_ERROR_NONE; - } else { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); - handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; - handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; - return PLAYER_ERROR_INVALID_STATE; + } + return PLAYER_ERROR_NONE; } + + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + return PLAYER_ERROR_INVALID_STATE; } int legacy_player_set_streaming_cookie(player_h player, const char *cookie, int size) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(cookie); PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_COOKIE, cookie, size, (char *)NULL); + ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_COOKIE, cookie, size, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_streaming_user_agent(player_h player, const char *user_agent, int size) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(user_agent); PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_USER_AGENT, user_agent, size, (char *)NULL); + ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_STREAMING_USER_AGENT, user_agent, size, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_streaming_download_progress(player_h player, int *start_pos, int *end_pos) { - int ret = MM_ERROR_NONE; player_s *handle = (player_s *)player; - + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(start_pos && end_pos); - if (!__player_state_validate(handle, PLAYER_STATE_READY)) { LOGE("invalid state error, current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; @@ -1892,10 +1906,10 @@ int legacy_player_unset_subtitle_updated_cb(player_h player) return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player); } -int legacy_player_release_video_stream_bo(player_h player, void* bo) +int legacy_player_release_video_stream_bo(player_h player, void *bo) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + PLAYER_INSTANCE_CHECK(player); LOGD("ENTER %p %p", player, bo); @@ -1908,12 +1922,13 @@ int legacy_player_release_video_stream_bo(player_h player, void* bo) int legacy_player_set_media_packet_video_frame_decoded_cb(player_h player, legacy_player_media_packet_video_decoded_cb callback, void *user_data) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; 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_video_stream_callback(handle->mm_handle, (mm_player_video_stream_callback)callback, user_data); + ret = mm_player_set_video_stream_callback(handle->mm_handle, (mm_player_video_stream_callback)callback, user_data); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -1923,13 +1938,14 @@ int legacy_player_set_media_packet_video_frame_decoded_cb(player_h player, legac static bool __video_stream_changed_callback(void *user_data) { player_s *handle = (player_s *)user_data; + int ret = MM_ERROR_NONE; muse_player_event_e event_type = MUSE_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, + ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &width, MM_PLAYER_VIDEO_HEIGHT, &height, "content_video_fps", &fps, @@ -1937,28 +1953,25 @@ static bool __video_stream_changed_callback(void *user_data) if (ret != MM_ERROR_NONE) { LOGE("[%s] get attr is failed", __FUNCTION__); - return FALSE; + 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; } - return TRUE; + LOGE("[%s] video stream changed cb was not set.", __FUNCTION__); + return false; } int legacy_player_set_video_stream_changed_cb(player_h player, player_video_stream_changed_cb callback, void *user_data) { - int ret; + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); 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__); @@ -1984,7 +1997,7 @@ static bool __media_stream_buffer_status_callback(player_stream_type_e type, pla else if (type == PLAYER_STREAM_TYPE_VIDEO) event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS; else - return FALSE; + return false; LOGE("[%s] event type %d", __FUNCTION__, event_type); @@ -1992,10 +2005,10 @@ static bool __media_stream_buffer_status_callback(player_stream_type_e type, pla ((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 false; } - return TRUE; + return true; } static bool __media_stream_seek_data_callback(player_stream_type_e type, unsigned long long offset, void *user_data) @@ -2008,7 +2021,7 @@ static bool __media_stream_seek_data_callback(player_stream_type_e type, unsigne else if (type == PLAYER_STREAM_TYPE_VIDEO) event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK; else - return FALSE; + return false; LOGE("[%s] event type %d", __FUNCTION__, event_type); @@ -2016,18 +2029,18 @@ static bool __media_stream_seek_data_callback(player_stream_type_e type, unsigne ((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 false; } - return TRUE; + return true; } int legacy_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_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); /* the type can be expaned with default and text. */ @@ -2063,10 +2076,10 @@ int legacy_player_unset_media_stream_buffer_status_cb(player_h player, player_st int legacy_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_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); /* the type can be expaned with default and text. */ @@ -2076,14 +2089,13 @@ int legacy_player_set_media_stream_seek_cb(player_h player, player_stream_type_e } 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(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player, callback, user_data); - else - return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player, callback, user_data); + + return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player, callback, user_data); } int legacy_player_unset_media_stream_seek_cb(player_h player, player_stream_type_e type) @@ -2102,27 +2114,27 @@ int legacy_player_unset_media_stream_seek_cb(player_h player, player_stream_type int legacy_player_push_media_stream(player_h player, media_packet_h packet) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(handle->error_code == PLAYER_ERROR_NONE, PLAYER_ERROR_NOT_SUPPORTED_FILE, "can't support this format"); - int ret = mm_player_submit_packet(handle->mm_handle, packet); - + 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; + + return PLAYER_ERROR_NONE; } int legacy_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; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - handle->is_media_stream = TRUE; + handle->is_media_stream = true; if (type == PLAYER_STREAM_TYPE_VIDEO) ret = mm_player_set_video_info(handle->mm_handle, format); @@ -2133,92 +2145,89 @@ int legacy_player_set_media_stream_info(player_h player, player_stream_type_e ty if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; return PLAYER_ERROR_NONE; } int legacy_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; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(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; } 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; + + return PLAYER_ERROR_NONE; } int legacy_player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *max_size) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + unsigned long long _max_size; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(max_size); - player_s *handle = (player_s *)player; - 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) { + 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; - } + + *max_size = _max_size; + return PLAYER_ERROR_NONE; } int legacy_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; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(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; } 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; + + return PLAYER_ERROR_NONE; } int legacy_player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *percent) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + unsigned int _value; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(percent); - player_s *handle = (player_s *)player; - unsigned int _value; - int ret = mm_player_get_media_stream_buffer_min_percent(handle->mm_handle, type, &_value); - if (ret != MM_ERROR_NONE) { + 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; - } + + *percent = _value; + return PLAYER_ERROR_NONE; } int legacy_player_get_track_count(player_h player, player_stream_type_e type, int *count) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + MMPlayerTrackType track_type = 0; 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; @@ -2231,7 +2240,7 @@ int legacy_player_get_track_count(player_h player, player_stream_type_e type, in return PLAYER_ERROR_INVALID_PARAMETER; } - int ret = mm_player_get_track_count(handle->mm_handle, track_type, count); + 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__); @@ -2240,16 +2249,16 @@ int legacy_player_get_track_count(player_h player, player_stream_type_e type, in int legacy_player_get_current_track(player_h player, player_stream_type_e type, int *index) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + MMPlayerTrackType track_type = 0; 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; @@ -2262,7 +2271,7 @@ int legacy_player_get_current_track(player_h player, player_stream_type_e type, return PLAYER_ERROR_INVALID_PARAMETER; } - int ret = mm_player_get_current_track(handle->mm_handle, track_type, index); + 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__); @@ -2271,16 +2280,16 @@ int legacy_player_get_current_track(player_h player, player_stream_type_e type, int legacy_player_select_track(player_h player, player_stream_type_e type, int index) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + MMPlayerTrackType track_type = 0; 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; @@ -2293,7 +2302,7 @@ int legacy_player_select_track(player_h player, player_stream_type_e type, int i return PLAYER_ERROR_INVALID_PARAMETER; } - int ret = mm_player_select_track(handle->mm_handle, track_type, index); + ret = mm_player_select_track(handle->mm_handle, track_type, index); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -2302,16 +2311,17 @@ int legacy_player_select_track(player_h player, player_stream_type_e type, int i int legacy_player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **code, int *len) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + MMPlayerTrackType track_type = 0; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(code); PLAYER_NULL_ARG_CHECK(len); - 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; @@ -2328,11 +2338,9 @@ int legacy_player_get_track_language_code(player_h player, player_stream_type_e } *code = NULL; - int ret = mm_player_get_track_language_code(handle->mm_handle, track_type, index, code); - - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_track_language_code(handle->mm_handle, track_type, index, code); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } LOGD("idx %d, lang code %s", index, *code); *len = strlen(*code); @@ -2342,9 +2350,9 @@ int legacy_player_get_track_language_code(player_h player, player_stream_type_e int legacy_player_set_video_roi_area(player_h player, double scale_x, double scale_y, double scale_width, double scale_heights) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; - int ret; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); LOGD(""); @@ -2356,35 +2364,35 @@ int legacy_player_set_video_roi_area(player_h player, double scale_x, ret = mm_player_set_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_heights); if (ret != PLAYER_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_video_roi_area(player_h player, double *scale_x, double *scale_y, double *scale_width, double *scale_height) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(scale_x); PLAYER_NULL_ARG_CHECK(scale_y); PLAYER_NULL_ARG_CHECK(scale_width); PLAYER_NULL_ARG_CHECK(scale_height); - player_s *handle = (player_s *)player; - int ret; LOGD(""); ret = mm_player_get_video_roi_area(handle->mm_handle, scale_x, scale_y, scale_width, scale_height); if (ret != PLAYER_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_roi_area(player_h player, int x, int y, int w, int h) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; - int ret; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); LOGD(""); @@ -2392,19 +2400,18 @@ int legacy_player_set_roi_area(player_h player, int x, int y, int w, int h) ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_win_roi_x", x, "display_win_roi_y", y, "display_win_roi_width", w, "display_win_roi_height", h, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_display(player_h player, player_display_type_e type, unsigned int wl_surface_id) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; void *set_handle = NULL; - MMDisplaySurfaceType mmType = __player_convert_display_type(type); - int ret; void *temp = NULL; - + MMDisplaySurfaceType mmType = __player_convert_display_type(type); + PLAYER_INSTANCE_CHECK(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; @@ -2471,36 +2478,35 @@ int legacy_player_set_display(player_h player, player_display_type_e type, unsig if (ret != MM_ERROR_NONE) { handle->display_type = PLAYER_DISPLAY_TYPE_NONE; return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; } + + return PLAYER_ERROR_NONE; } int legacy_player_set_sound_stream_info_for_mused(player_h player, char *stream_type, int stream_index) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; - int ret; - + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); + if (stream_type == NULL || stream_index < 0) { LOGE("invalid parameter %p %d", stream_type, stream_index); return PLAYER_ERROR_INVALID_PARAMETER; } ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index); - if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_timeout_for_muse(player_h player, int *timeout) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; - int ret; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); ret = mm_player_get_timeout(handle->mm_handle, timeout); if (ret != MM_ERROR_NONE) @@ -2511,12 +2517,13 @@ int legacy_player_get_timeout_for_muse(player_h player, int *timeout) int legacy_player_get_num_of_video_out_buffers(player_h player, int *num, int *extra_num) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(num); PLAYER_NULL_ARG_CHECK(extra_num); - player_s *handle = (player_s *)player; - int ret = mm_player_get_num_of_video_out_buffers(handle->mm_handle, num, extra_num); + ret = mm_player_get_num_of_video_out_buffers(handle->mm_handle, num, extra_num); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -2525,40 +2532,39 @@ int legacy_player_get_num_of_video_out_buffers(player_h player, int *num, int *e int legacy_player_set_file_buffering_path(player_h player, const char *file_path) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(file_path); - player_s *handle = (player_s *)player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - int ret = mm_player_set_file_buffering_path(handle->mm_handle, file_path); - + ret = mm_player_set_file_buffering_path(handle->mm_handle, file_path); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_manage_external_storage_state(player_h player, int id, int state) { - int ret = PLAYER_ERROR_NONE; - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); ret = mm_player_manage_external_storage_state(handle->mm_handle, id, state); - if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_adaptive_variant_info(player_h player, int *num, char **var_info) { - int ret = PLAYER_ERROR_NONE; + int ret = MM_ERROR_NONE; + player_s *handle = (player_s *)player; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(num); PLAYER_NULL_ARG_CHECK(var_info); - 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); @@ -2566,7 +2572,6 @@ int legacy_player_get_adaptive_variant_info(player_h player, int *num, char **va } ret = mm_player_get_adaptive_variant_info(handle->mm_handle, num, var_info); - if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -2575,12 +2580,11 @@ int legacy_player_get_adaptive_variant_info(player_h player, int *num, char **va int legacy_player_set_max_adaptive_variant_limit(player_h player, int bandwidth, int width, int height) { - int ret; - PLAYER_INSTANCE_CHECK(player); + int ret = MM_ERROR_NONE; player_s *handle = (player_s *)player; + PLAYER_INSTANCE_CHECK(player); ret = mm_player_set_max_adaptive_variant_limit(handle->mm_handle, bandwidth, width, height); - if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -2589,14 +2593,14 @@ int legacy_player_set_max_adaptive_variant_limit(player_h player, int bandwidth, int legacy_player_get_max_adaptive_variant_limit(player_h player, int *bandwidth, int *width, int *height) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(bandwidth); PLAYER_NULL_ARG_CHECK(width); PLAYER_NULL_ARG_CHECK(height); - player_s *handle = (player_s *)player; - - int ret = mm_player_get_max_adaptive_variant_limit(handle->mm_handle, bandwidth, width, height); + ret = mm_player_get_max_adaptive_variant_limit(handle->mm_handle, bandwidth, width, height); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -2605,135 +2609,132 @@ int legacy_player_get_max_adaptive_variant_limit(player_h player, int *bandwidth int legacy_player_set_audio_only(player_h player, bool audio_only) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(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; } - int ret = mm_player_set_audio_only(handle->mm_handle, audio_only); + ret = mm_player_set_audio_only(handle->mm_handle, audio_only); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_is_audio_only(player_h player, bool *paudio_only) { - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(paudio_only); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; bool audio_only = false; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(paudio_only); - int ret = mm_player_get_audio_only(handle->mm_handle, &audio_only); - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_audio_only(handle->mm_handle, &audio_only); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *paudio_only = audio_only; - return PLAYER_ERROR_NONE; - } + + *paudio_only = audio_only; + return PLAYER_ERROR_NONE; } int legacy_player_set_streaming_buffering_time(player_h player, int buffer_ms, int rebuffer_ms) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); ret = mm_player_set_streaming_buffering_time(handle->mm_handle, buffer_ms, rebuffer_ms); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_get_streaming_buffering_time(player_h player, int *buffer_ms, int *rebuffer_ms) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(buffer_ms); PLAYER_NULL_ARG_CHECK(rebuffer_ms); - player_s *handle = (player_s *)player; - int ret = MM_ERROR_NONE; - 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; } ret = mm_player_get_streaming_buffering_time(handle->mm_handle, buffer_ms, rebuffer_ms); - if (ret != MM_ERROR_NONE) { + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; - } + + return PLAYER_ERROR_NONE; } int legacy_player_360_is_content_spherical(player_h player, bool *is_spherical) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(is_spherical); - player_s *handle = (player_s *)player; - if (!__player_state_validate(handle, PLAYER_STATE_READY)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } - int ret = mm_player_360_is_content_spherical(handle->mm_handle, is_spherical); - if (ret != MM_ERROR_NONE) { + ret = mm_player_360_is_content_spherical(handle->mm_handle, is_spherical); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; - } + + return PLAYER_ERROR_NONE; } int legacy_player_360_set_enabled(player_h player, bool enabled) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } - int ret = mm_player_360_set_enabled(handle->mm_handle, enabled); + ret = mm_player_360_set_enabled(handle->mm_handle, enabled); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_360_is_enabled(player_h player, bool *enabled) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(enabled); - - player_s *handle = (player_s *)player; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } - int ret = mm_player_360_is_enabled(handle->mm_handle, enabled); - if (ret != MM_ERROR_NONE) { + ret = mm_player_360_is_enabled(handle->mm_handle, enabled); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; - } + + return PLAYER_ERROR_NONE; } int legacy_player_360_set_direction_of_view(player_h player, float yaw, float pitch) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); @@ -2743,72 +2744,71 @@ int legacy_player_360_set_direction_of_view(player_h player, float yaw, float pi ret = mm_player_360_set_direction_of_view(handle->mm_handle, yaw, pitch); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_360_get_direction_of_view(player_h player, float *yaw, float *pitch) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(yaw); PLAYER_NULL_ARG_CHECK(pitch); - player_s *handle = (player_s *)player; - int ret = MM_ERROR_NONE; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } ret = mm_player_360_get_direction_of_view(handle->mm_handle, yaw, pitch); - if (ret != MM_ERROR_NONE) { + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; - } + + return PLAYER_ERROR_NONE; } int legacy_player_360_set_zoom(player_h player, float level) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } - int ret = mm_player_360_set_zoom(handle->mm_handle, level); + ret = mm_player_360_set_zoom(handle->mm_handle, level); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_360_get_zoom(player_h player, float *level) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } - int ret = mm_player_360_get_zoom(handle->mm_handle, level); - if (ret != MM_ERROR_NONE) { + ret = mm_player_360_get_zoom(handle->mm_handle, level); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; - } + + return PLAYER_ERROR_NONE; } int legacy_player_360_set_field_of_view(player_h player, int horizontal_degrees, int vertical_degrees) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); @@ -2818,38 +2818,35 @@ int legacy_player_360_set_field_of_view(player_h player, int horizontal_degrees, ret = mm_player_360_set_field_of_view(handle->mm_handle, horizontal_degrees, vertical_degrees); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_360_get_field_of_view(player_h player, int *horizontal_degrees, int *vertical_degrees) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(horizontal_degrees); PLAYER_NULL_ARG_CHECK(vertical_degrees); - player_s *handle = (player_s *)player; - int ret = MM_ERROR_NONE; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } ret = mm_player_360_get_field_of_view(handle->mm_handle, horizontal_degrees, vertical_degrees); - if (ret != MM_ERROR_NONE) { + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - return PLAYER_ERROR_NONE; - } + + return PLAYER_ERROR_NONE; } int legacy_player_set_replaygain_enabled(player_h player, bool enabled) { - PLAYER_INSTANCE_CHECK(player); - player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); @@ -2859,18 +2856,17 @@ int legacy_player_set_replaygain_enabled(player_h player, bool enabled) ret = mm_player_set_replaygain_enabled(handle->mm_handle, enabled); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_is_replaygain_enabled(player_h player, bool *enabled) { - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(enabled); - player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; bool _enable; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(enabled); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); @@ -2878,10 +2874,9 @@ int legacy_player_is_replaygain_enabled(player_h player, bool *enabled) } ret = mm_player_is_replaygain_enabled(handle->mm_handle, &_enable); - if (ret != MM_ERROR_NONE) { + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - *enabled = _enable; - return PLAYER_ERROR_NONE; - } + + *enabled = _enable; + return PLAYER_ERROR_NONE; } diff --git a/legacy/src/legacy_player_internal.c b/legacy/src/legacy_player_internal.c index c3d1f7e..26c3e9e 100644 --- a/legacy/src/legacy_player_internal.c +++ b/legacy/src/legacy_player_internal.c @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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 @@ -29,8 +29,8 @@ #include "legacy_player_private.h" /* -* Internal Macros -*/ + * Internal Macros + */ #define PLAYER_SET_CALLBACK(event_type, handle, callback, user_data) \ do { \ PLAYER_INSTANCE_CHECK(handle); \ @@ -51,15 +51,16 @@ bool __audio_stream_callback(MMPlayerAudioStreamDataType *stream, void *user_dat if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME]) ((player_audio_pcm_extraction_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME])((player_audio_raw_data_s *)stream, handle->user_data[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME]); + return true; } int legacy_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; int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); @@ -73,10 +74,9 @@ int legacy_player_set_pcm_extraction_mode(player_h player, bool sync, player_aud int legacy_player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel) { - PLAYER_INSTANCE_CHECK(player); - player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); LOGD("format: %s, rate: %d, ch: %d", format, samplerate, channel); @@ -103,17 +103,17 @@ int legacy_player_set_pcm_spec(player_h player, const char *format, int samplera int legacy_player_set_streaming_playback_rate(player_h player, float rate) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; LOGI("[%s] rate : %0.1f", __FUNCTION__, rate); PLAYER_INSTANCE_CHECK(player); - 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; } - int ret = mm_player_set_play_speed(handle->mm_handle, rate, TRUE); - + ret = mm_player_set_play_speed(handle->mm_handle, rate, true); switch (ret) { case MM_ERROR_NONE: case MM_ERROR_PLAYER_NO_OP: @@ -167,11 +167,11 @@ static bool __media_stream_buffer_status_callback_ex(player_stream_type_e type, int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data) { - int ret; - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(callback); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; muse_player_event_e event_type; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); if (handle->state != PLAYER_STATE_IDLE) { LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); @@ -190,7 +190,6 @@ int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_s 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_ex, (void *)handle); - if (ret != MM_ERROR_NONE) { LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); return __player_convert_error_code(ret, (char *)__FUNCTION__); @@ -209,9 +208,9 @@ int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_s int legacy_player_unset_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; muse_player_event_e event_type; + PLAYER_INSTANCE_CHECK(player); if (type == PLAYER_STREAM_TYPE_VIDEO) event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO; @@ -234,141 +233,140 @@ int legacy_player_unset_media_stream_buffer_status_cb_ex(player_h player, player int legacy_player_set_media_stream_dynamic_resolution(player_h player, bool drc) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - int ret = mm_player_set_media_stream_dynamic_resolution(handle->mm_handle, drc); - + ret = mm_player_set_media_stream_dynamic_resolution(handle->mm_handle, drc); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_next_uri(player_h player, const char *uri) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; 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); - + 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; + return __player_convert_error_code(ret, (char *)__FUNCTION__); + + return PLAYER_ERROR_NONE; } int legacy_player_get_next_uri(player_h player, char **uri) { + player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; 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_get_next_uri(handle->mm_handle, uri); /* uri will be free in muse_player.c*/ - + ret = mm_player_get_next_uri(handle->mm_handle, uri); /* uri will be free in muse_player.c*/ if (ret != MM_ERROR_NONE) - return __player_convert_error_code(ret, (char*)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + return __player_convert_error_code(ret, (char *)__FUNCTION__); + + return PLAYER_ERROR_NONE; } int legacy_player_set_gapless(player_h player, bool gapless) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; - + int ret = MM_ERROR_NONE; int value = 0; + PLAYER_INSTANCE_CHECK(player); + if (gapless == true) value = 1; - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_GAPLESS_MODE, value, (char *)NULL); - + ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_GAPLESS_MODE, value, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_is_gapless(player_h player, bool *gapless) { - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(gapless); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; int value; + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(gapless); - int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_GAPLESS_MODE, &value, (char *)NULL); - if (ret != MM_ERROR_NONE) { + ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_GAPLESS_MODE, &value, (char *)NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - } else { - if (value == 1) - *gapless = true; - else - *gapless = false; - return PLAYER_ERROR_NONE; - } + if (value == 1) + *gapless = true; + else + *gapless = false; + + return PLAYER_ERROR_NONE; + } int legacy_player_enable_media_packet_video_frame_decoded_cb(player_h player, bool enable) { - PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + int ret = MM_ERROR_NONE; + int value = 0; + PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); - int value = 0; - if (enable == true) + if (enable) value = 1; - int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_ENABLE_VIDEO_DECODED_CB, value, (char *)NULL); - + ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_ENABLE_VIDEO_DECODED_CB, value, (char *)NULL); if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + return PLAYER_ERROR_NONE; } int legacy_player_set_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e codec_type) { + player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); - - player_s * handle = (player_s *) player; PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); LOGI("stream %d, codec %d", stream_type, codec_type); ret = mm_player_set_codec_type(handle->mm_handle, stream_type, codec_type); if (ret != MM_ERROR_NONE) - return __player_convert_error_code(ret, (char*)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + return __player_convert_error_code(ret, (char *)__FUNCTION__); + + return PLAYER_ERROR_NONE; } int legacy_player_get_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e *pcodec_type) { + player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + const char *attr_name; PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(pcodec_type); PLAYER_CHECK_CONDITION(stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); - player_s * handle = (player_s *) player; - const char* attr_name = (stream_type == PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE); + attr_name = (stream_type == PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE); - ret = mm_player_get_attribute(handle->mm_handle, NULL, attr_name, pcodec_type, (char*)NULL); - if (ret != MM_ERROR_NONE) { - return __player_convert_error_code(ret, (char*)__FUNCTION__); - } else { - LOGD("stream %d, codec %d", stream_type, *pcodec_type); - return PLAYER_ERROR_NONE; - } -} + ret = mm_player_get_attribute(handle->mm_handle, NULL, attr_name, pcodec_type, (char *)NULL); + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char *)__FUNCTION__); + LOGD("stream %d, codec %d", stream_type, *pcodec_type); + return PLAYER_ERROR_NONE; +} diff --git a/muse/include/muse_player.h b/muse/include/muse_player.h index 1aaba4c..da83b16 100644 --- a/muse/include/muse_player.h +++ b/muse/include/muse_player.h @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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_MUSE_PLAYER_H__ #define __TIZEN_MEDIA_MUSE_PLAYER_H__ @@ -28,7 +28,7 @@ extern "C" { #endif #define LOG_TAG "MMSVC_PLAYER" -#define MUSE_PLAYER_HEAD_GAP(api) ((api)/(1000)+(1))*(1000) +#define MUSE_PLAYER_HEAD_GAP(api) ((api) / (1000) + (1)) * (1000) /** * @brief Auto-generated enumeration for the muse player APIs. diff --git a/muse/include/muse_player_msg.h b/muse/include/muse_player_msg.h index b1cf9a4..75fb031 100644 --- a/muse/include/muse_player_msg.h +++ b/muse/include/muse_player_msg.h @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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_MUSE_PLAYER_MSG_H__ #define __TIZEN_MEDIA_MUSE_PLAYER_MSG_H__ @@ -31,7 +31,7 @@ typedef int32_t INT; typedef int64_t INT64; typedef intptr_t POINTER; typedef double DOUBLE; -typedef const char* STRING; +typedef const char *STRING; typedef enum { PUSH_MEDIA_BUF_TYPE_TBM, @@ -58,7 +58,7 @@ typedef struct { int win_roi_height; } wl_win_msg_type; -extern int _player_disp_send_msg(int send_fd, char* msg, int *tfd); +extern int _player_disp_send_msg(int send_fd, char *msg, int *tfd); /** * @brief Get value from Message. diff --git a/muse/include/muse_player_private.h b/muse/include/muse_player_private.h index e582a3d..c5f52d8 100644 --- a/muse/include/muse_player_private.h +++ b/muse/include/muse_player_private.h @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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_MUSE_PLAYER_PRIVATE_H__ #define __TIZEN_MEDIA_MUSE_PLAYER_PRIVATE_H__ diff --git a/muse/src/muse_player.c b/muse/src/muse_player.c index 853419e..0e22a6b 100644 --- a/muse/src/muse_player.c +++ b/muse/src/muse_player.c @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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 _GNU_SOURCE #define _GNU_SOURCE @@ -83,18 +83,18 @@ static bool _create_export_data(muse_player_handle_s *muse_player, void *data, i if (muse_player == NULL) { LOGE("handle is NULL"); - return FALSE; + return false; } if (data == NULL || size <= 0) { LOGE("data is empty"); - return FALSE; + return false; } export_data = g_try_new0(muse_player_export_data_s, 1); if (export_data == NULL) { LOGE("failed to alloc export_data"); - return FALSE; + return false; } /* alloc and map the bo */ @@ -114,7 +114,7 @@ static bool _create_export_data(muse_player_handle_s *muse_player, void *data, i if (ext_size > 0 && ext_data != NULL) memcpy(thandle.ptr, ext_data, ext_size); - memcpy(thandle.ptr+ext_size, data, size); + memcpy(thandle.ptr + ext_size, data, size); tbm_bo_unmap(bo); @@ -139,29 +139,28 @@ static bool _create_export_data(muse_player_handle_s *muse_player, void *data, i *out_tfd = export_data->tfd; *out_key = export_data->key; - return TRUE; + return true; ERROR: if (bo) { tbm_bo_unref(bo); bo = NULL; } - if (export_data) { - g_free(export_data); - export_data = NULL; - } - return FALSE; + + g_free(export_data); + + return false; } -static bool _remove_export_data(muse_module_h module, int key, int remove_all) +static bool _remove_export_data(muse_module_h module, int key, bool remove_all) { - bool ret = TRUE; + bool ret = true; muse_player_handle_s *muse_player = NULL; /* LOGD("ENTER"); */ - if (module == NULL || (key < 0 && remove_all == FALSE)) { + if (module == NULL || (key < 0 && !remove_all)) { LOGE("invalid parameter %p, %d", module, key); - return FALSE; + return false; } muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); @@ -211,7 +210,7 @@ static bool _remove_export_data(muse_module_h module, int key, int remove_all) if (!remove_all) { LOGE("There is no key:%d in data_list", key); - ret = FALSE; + ret = false; } } @@ -313,8 +312,8 @@ static void _remove_export_media_packet(muse_module_h module) /* check the given path is indicating sdp file */ static bool _is_sdp_file(const char *path) { - gboolean ret = FALSE; - gchar* uri = NULL; + bool ret = false; + gchar *uri = NULL; if (!path) { LOGE("invalid path param"); @@ -324,7 +323,7 @@ static bool _is_sdp_file(const char *path) uri = g_ascii_strdown(path, -1); if (uri == NULL) - return FALSE; + return false; /* trimming */ g_strstrip(uri); @@ -354,13 +353,13 @@ static bool _check_network_availability(void) #define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi" #define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony" #define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet" - bool enabled = FALSE; - bool supported = FALSE; + bool enabled = false; + bool supported = false; if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_WIFI, &enabled)) { LOGI("wifi status = %d", enabled); if (enabled) - supported = TRUE; + supported = true; } else { LOGE("SYSTEM_INFO_ERROR"); } @@ -368,7 +367,7 @@ static bool _check_network_availability(void) if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &enabled)) { LOGI("telephony status = %d", enabled); if (enabled) - supported = TRUE; + supported = true; } else { LOGE("SYSTEM_INFO_ERROR"); } @@ -376,15 +375,15 @@ static bool _check_network_availability(void) if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &enabled)) { LOGI("ethernet status = %d", enabled); if (enabled) - supported = TRUE; + supported = true; } else { LOGE("SYSTEM_INFO_ERROR"); } if (!supported) - return FALSE; + return false; - return TRUE; + return true; } static int _check_supportable(muse_module_h module, char *path) @@ -421,7 +420,7 @@ static int _check_supportable(muse_module_h module, char *path) char *file_path = path; if (strncmp(path, "file://", strlen("file://")) == 0) - file_path = path+7; /* remove file prefix */ + file_path = path + 7; /* remove file prefix */ if (_is_sdp_file(file_path)) /* check internet privilege */ privilege = INTERNET_PRIVILEGE_NAME; @@ -557,7 +556,7 @@ static void _capture_video_cb(unsigned char *data, int width, int height, unsign muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_CAPTURE; muse_module_h module = (muse_module_h)user_data; muse_player_handle_s *muse_player = NULL; - bool ret = TRUE; + bool ret = true; tbm_fd tfd = INVALID_DEFAULT_VALUE; int key = INVALID_DEFAULT_VALUE; LOGD("ENTER"); @@ -796,7 +795,7 @@ static bool __video_decoded_callback(void *video_data, void *user_data) muse_player->video_data_list = g_list_append(muse_player->video_data_list, (gpointer)video_data); g_mutex_unlock(&muse_player->list_lock); - msg_len = (surface_info_size/sizeof(int) + (surface_info_size%sizeof(int) ? 1 : 0)); + msg_len = (surface_info_size / sizeof(int) + (surface_info_size % sizeof(int) ? 1 : 0)); PLAYER_SEND_EVENT_MSG_WITH_TFDS(api, ev, module, tfd, MUSE_TYPE_INT, "key[0]", key[0], MUSE_TYPE_INT, "key[1]", key[1], MUSE_TYPE_INT, "key[2]", key[2], MUSE_TYPE_INT, "key[3]", key[3], @@ -924,7 +923,7 @@ static void _subtitle_updated_cb(unsigned long duration, char *text, void *user_ LOGD("ENTER"); PLAYER_SEND_EVENT_MSG(api, ev, module, - MUSE_TYPE_INT, "duration", (int)duration, MUSE_TYPE_STRING, "text", (const char*)text); + MUSE_TYPE_INT, "duration", (int)duration, MUSE_TYPE_STRING, "text", (const char *)text); } static void _set_subtitle_cb(player_h player, void *module, bool set) @@ -1150,8 +1149,9 @@ static int _push_media_stream(muse_player_handle_s *muse_player, player_push_med ret |= media_format_set_audio_mime(muse_player->audio_format, push_media->mimetype); } format = muse_player->audio_format; - } else + } else { ret = MEDIA_FORMAT_ERROR_INVALID_PARAMETER; + } if (ret != MEDIA_FORMAT_ERROR_NONE) { LOGE("Invalid MIME %d", push_media->mimetype); @@ -1184,7 +1184,7 @@ static int _push_media_stream(muse_player_handle_s *muse_player, player_push_med return ret; } -static void _audio_frame_decoded_cb(player_audio_raw_data_s * audio_frame, void *user_data) +static void _audio_frame_decoded_cb(player_audio_raw_data_s *audio_frame, void *user_data) { muse_player_cb_e api = MUSE_PLAYER_CB_EVENT; muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME; @@ -1192,7 +1192,7 @@ static void _audio_frame_decoded_cb(player_audio_raw_data_s * audio_frame, void muse_player_handle_s *muse_player = NULL; void *data = NULL; int size = 0; - bool ret = TRUE; + bool ret = true; tbm_fd tfd = INVALID_DEFAULT_VALUE; int key = INVALID_DEFAULT_VALUE; @@ -1225,7 +1225,7 @@ static void _audio_frame_decoded_cb(player_audio_raw_data_s * audio_frame, void return; } -int _player_disp_send_msg(int send_fd, char* msg, int *tfd) +int _player_disp_send_msg(int send_fd, char *msg, int *tfd) { int send_len = 0; @@ -1234,11 +1234,11 @@ int _player_disp_send_msg(int send_fd, char* msg, int *tfd) return PLAYER_ERROR_INVALID_OPERATION; } - if (tfd != NULL) { + if (tfd != NULL) send_len = muse_core_msg_send_fd(send_fd, tfd, msg); - } else { + else send_len = muse_core_msg_send(send_fd, msg); - } + if (send_len <= 0) { LOGE("sending message failed"); return PLAYER_ERROR_INVALID_OPERATION; @@ -1247,7 +1247,7 @@ int _player_disp_send_msg(int send_fd, char* msg, int *tfd) return PLAYER_ERROR_NONE; } -int _player_disp_send_msg_async(int send_fd, char* msg) +int _player_disp_send_msg_async(int send_fd, char *msg) { int send_len = 0; @@ -1265,7 +1265,7 @@ int _player_disp_send_msg_async(int send_fd, char* msg) return PLAYER_ERROR_NONE; } -static bool _player_disp_get_param_value(char* buf, ...) +static bool _player_disp_get_param_value(char *buf, ...) { muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE; bool ret = true; @@ -1387,7 +1387,7 @@ int player_disp_destroy(muse_module_h module) muse_player->video_format = NULL; } - _remove_export_data(module, 0, TRUE); + _remove_export_data(module, 0, true); g_mutex_clear(&muse_player->list_lock); muse_player->bufmgr = NULL; @@ -1456,8 +1456,7 @@ int player_disp_prepare_async(muse_module_h module) } /* else is error */ ERROR: - if (prepare_data) - g_free(prepare_data); + g_free(prepare_data); PLAYER_RETURN_MSG(api, ret, module); return ret; @@ -1476,7 +1475,7 @@ int player_disp_unprepare(muse_module_h module) ret = legacy_player_unprepare(muse_player->player_handle); - _remove_export_data(module, 0, TRUE); + _remove_export_data(module, 0, true); PLAYER_RETURN_MSG(api, ret, module); @@ -1499,7 +1498,7 @@ int player_disp_set_uri(muse_module_h module) PLAYER_RETURN_MSG(api, ret, module); if (ret == PLAYER_ERROR_NONE) { - const char* file_buffering_path = muse_server_module_get_temporal_path(); + const char *file_buffering_path = muse_server_module_get_temporal_path(); LOGD("file buffering path : %s", file_buffering_path); if (file_buffering_path) @@ -1617,7 +1616,7 @@ int player_disp_deinit_memory_buffer(muse_module_h module) /* MUSE_PLAYER_API_DE if (player_msg_get(bo_addr, muse_server_module_get_msg(module))) { - bo = (tbm_bo) bo_addr; + bo = (tbm_bo)bo_addr; tbm_bo_unmap(bo); tbm_bo_unref(bo); @@ -1648,7 +1647,7 @@ int player_disp_set_volume(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME; muse_player_handle_s *muse_player = NULL; double left, right; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_DOUBLE, "left", (void *)&left, @@ -1688,7 +1687,7 @@ int player_disp_set_sound_stream_info(muse_module_h module) muse_player_handle_s *muse_player = NULL; int stream_index = 0; char stream_type[MUSE_URI_MAX_LENGTH] = { 0, }; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "stream_index", (void *)&stream_index, @@ -1746,7 +1745,7 @@ int player_disp_set_play_position(muse_module_h module) muse_player_handle_s *muse_player = NULL; int64_t pos = 0; int accurate = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT64, "pos", (void *)&pos, @@ -1919,7 +1918,7 @@ int player_disp_set_video_roi_area(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_ROI_AREA; muse_player_handle_s *muse_player = NULL; double x_scale = 0, y_scale = 0, w_scale = 0, h_scale = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_DOUBLE, "x_scale", (void *)&x_scale, @@ -2066,7 +2065,7 @@ int player_disp_get_content_info(muse_module_h module) int ret = PLAYER_ERROR_NONE; muse_player_handle_s *muse_player = NULL; muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO; - char *value; + char *value = NULL; player_content_info_e key; muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); @@ -2075,10 +2074,12 @@ int player_disp_get_content_info(muse_module_h module) ret = legacy_player_get_content_info(muse_player->player_handle, key, &value); if (ret == PLAYER_ERROR_NONE) { - PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_STRING, "value", (const char*)value); - free(value); - } else + PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_STRING, "value", (const char *)value); + if (value) + free(value); + } else { PLAYER_RETURN_MSG(api, ret, module); + } return ret; } @@ -2088,8 +2089,8 @@ int player_disp_get_codec_info(muse_module_h module) int ret = PLAYER_ERROR_NONE; muse_player_handle_s *muse_player = NULL; muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO; - char *video_codec; - char *audio_codec; + char *video_codec = NULL; + char *audio_codec = NULL; muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); @@ -2097,13 +2098,15 @@ int player_disp_get_codec_info(muse_module_h module) if (ret == PLAYER_ERROR_NONE) { PLAYER_RETURN_MSG(api, ret, module, - MUSE_TYPE_STRING, "audio_codec", (const char*)audio_codec, - MUSE_TYPE_STRING, "video_codec", (const char*)video_codec); - - free(audio_codec); - free(video_codec); - } else + MUSE_TYPE_STRING, "audio_codec", (const char *)audio_codec, + MUSE_TYPE_STRING, "video_codec", (const char *)video_codec); + if (audio_codec) + free(audio_codec); + if (video_codec) + free(video_codec); + } else { PLAYER_RETURN_MSG(api, ret, module); + } return ret; } @@ -2170,7 +2173,7 @@ int player_disp_get_album_art(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART; void *album_art = NULL; int size = 0; - bool ret_val = TRUE; + bool ret_val = true; tbm_fd tfd = INVALID_DEFAULT_VALUE; int key = INVALID_DEFAULT_VALUE; @@ -2268,7 +2271,7 @@ int player_disp_audio_effect_set_equalizer_band_level(muse_module_h module) muse_player_handle_s *muse_player = NULL; muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL; int index = 0, level = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "index", (void *)&index, @@ -2702,7 +2705,7 @@ int player_disp_return_video_data(muse_module_h module) /* MUSE_PLAYER_API_RETUR { MMPlayerVideoStreamDataType *v_data = NULL; muse_player_handle_s *muse_player = NULL; - bool find_data = FALSE; + bool find_data = false; player_msg_get_type(v_data, muse_server_module_get_msg(module), POINTER); @@ -2711,7 +2714,7 @@ int player_disp_return_video_data(muse_module_h module) /* MUSE_PLAYER_API_RETUR g_mutex_lock(&muse_player->list_lock); if (g_list_find(muse_player->video_data_list, v_data)) { muse_player->video_data_list = g_list_remove(muse_player->video_data_list, v_data); - find_data = TRUE; + find_data = true; } else { LOGW("the v_data(%p) is not in the exported list.", v_data); } @@ -2731,7 +2734,7 @@ int player_disp_set_media_stream_buffer_max_size(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE; player_stream_type_e type; unsigned long long max_size; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "type", (void *)&type, @@ -2778,7 +2781,7 @@ int player_disp_set_media_stream_buffer_min_threshold(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD; player_stream_type_e type; unsigned percent = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "type", (void *)&type, @@ -2880,7 +2883,7 @@ int player_disp_select_track(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK; player_stream_type_e type; int index = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "type", (void *)&type, @@ -2906,7 +2909,7 @@ int player_disp_get_track_language_code(muse_module_h module) int index = 0; char *code = NULL; int code_len = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "type", (void *)&type, @@ -2922,7 +2925,7 @@ int player_disp_get_track_language_code(muse_module_h module) if (ret == PLAYER_ERROR_NONE) PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "code_len", code_len, - MUSE_TYPE_STRING, "code", (const char*)code); + MUSE_TYPE_STRING, "code", (const char *)code); else PLAYER_RETURN_MSG(api, ret, module); @@ -2957,7 +2960,7 @@ int player_disp_set_pcm_spec(muse_module_h module) char format[MUSE_URI_MAX_LENGTH] = { 0, }; int samplerate = 0; int channel = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "samplerate", (void *)&samplerate, @@ -3004,7 +3007,7 @@ int player_disp_return_buffer(muse_module_h module) /* MUSE_PLAYER_API_RETURN_BU /* LOGD("handle : %p, key : %d", muse_player, key); */ - if (!_remove_export_data(module, key, FALSE)) + if (!_remove_export_data(module, key, false)) LOGE("failed to remove export data : key %d", key); /* This funct does not send return value to client. * @@ -3041,8 +3044,9 @@ int player_disp_get_next_uri(muse_module_h module) ret = legacy_player_get_next_uri(muse_player->player_handle, &next_uri); if (ret == PLAYER_ERROR_NONE) { - PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_STRING, "next_uri", (const char*)next_uri); - free(next_uri); + PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_STRING, "next_uri", (const char *)next_uri); + if (next_uri) + free(next_uri); } else { PLAYER_RETURN_MSG(api, ret, module); } @@ -3072,7 +3076,7 @@ int player_disp_is_gapless(muse_module_h module) int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_IS_GAPLESS; muse_player_handle_s *muse_player = NULL; - bool value = FALSE; + bool value = false; muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module); @@ -3138,7 +3142,7 @@ int player_disp_get_adaptive_variant_info(muse_module_h module) else PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "num", num, - MUSE_TYPE_STRING, "var_info", (const char*)var_info); + MUSE_TYPE_STRING, "var_info", (const char *)var_info); g_free(var_info); @@ -3150,7 +3154,7 @@ int player_disp_set_max_adaptive_variant_limit(muse_module_h module) int ret = PLAYER_ERROR_NONE; muse_player_api_e api = MUSE_PLAYER_API_SET_MAX_ADAPTIVE_VARIANT_LIMIT; muse_player_handle_s *muse_player = NULL; - bool ret_val = TRUE; + bool ret_val = true; int bandwidth = ADAPTIVE_VARIANT_DEFAULT_VALUE; int width = ADAPTIVE_VARIANT_DEFAULT_VALUE; int height = ADAPTIVE_VARIANT_DEFAULT_VALUE; @@ -3321,7 +3325,7 @@ int player_disp_360_set_direction_of_view(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_360_SET_DIRECTION_OF_VIEW; muse_player_handle_s *muse_player = NULL; double yaw, pitch; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_DOUBLE, "yaw", (void *)&yaw, @@ -3392,7 +3396,7 @@ int player_disp_360_set_field_of_view(muse_module_h module) muse_player_api_e api = MUSE_PLAYER_API_360_SET_FIELD_OF_VIEW; muse_player_handle_s *muse_player = NULL; int horizontal_degrees = 0, vertical_degrees = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_INT, "horizontal_degrees", (void *)&horizontal_degrees, @@ -3431,7 +3435,7 @@ int player_disp_360_set_zoom_with_field_of_view(muse_module_h module) muse_player_handle_s *muse_player = NULL; int horizontal_degrees = 0, vertical_degrees = 0; double level = 0; - bool ret_val = TRUE; + bool ret_val = true; ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module), MUSE_TYPE_DOUBLE, "level", (void *)&level, diff --git a/muse/src/muse_player_dispatcher.c b/muse/src/muse_player_dispatcher.c index 4e23d26..0b10f7c 100644 --- a/muse/src/muse_player_dispatcher.c +++ b/muse/src/muse_player_dispatcher.c @@ -1,18 +1,18 @@ /* -* 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. -*/ + * 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 "muse_player.h" @@ -95,7 +95,7 @@ static int player_cmd_external_storage_state_changed(muse_module_h module) return PLAYER_ERROR_NONE; } - storage_info = (muse_external_storage_info_t *)(data); + storage_info = (muse_external_storage_info_t *)data; LOGW("external state is changed %d:%d", storage_info->id, storage_info->state); legacy_player_manage_external_storage_state(muse_player->player_handle, storage_info->id, storage_info->state); @@ -127,4 +127,3 @@ int (*cmd_dispatcher[MUSE_MODULE_COMMAND_MAX])(muse_module_h module) = { int (*dispatcher[MUSE_PLAYER_API_MAX])(muse_module_h module) = { #include "muse_player_api.func" }; - diff --git a/muse/test/build_verify.c b/muse/test/build_verify.c index cd95d9e..f83cc96 100644 --- a/muse/test/build_verify.c +++ b/muse/test/build_verify.c @@ -1,25 +1,25 @@ /* -* 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. -*/ + * 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 "muse_player.h" #include "muse_player_msg.h" /* -* This is only for build verify -* Does NOT include package -*/ + * This is only for build verify + * Does NOT include package + */ int main() { diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index df462fa..2bf9856 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.95 +Version: 0.2.96 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From bafc69b83eec8191cb756470fecb6b16c03fe877 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Wed, 9 Jan 2019 15:00:22 +0900 Subject: [PATCH 13/16] [0.2.97] remove setting file path code - player do not need the file download path because the file buffering is removed. Change-Id: I62509689867b4ec2781952aa8d57242c9960db83 --- legacy/include/legacy_player.h | 13 ------------- legacy/src/legacy_player.c | 15 --------------- muse/src/muse_player.c | 8 -------- packaging/mmsvc-player.spec | 2 +- 4 files changed, 1 insertion(+), 37 deletions(-) diff --git a/legacy/include/legacy_player.h b/legacy/include/legacy_player.h index 429192c..3a1e30c 100644 --- a/legacy/include/legacy_player.h +++ b/legacy/include/legacy_player.h @@ -1997,19 +1997,6 @@ int legacy_player_get_timeout_for_muse(player_h player, int *timeout); int legacy_player_get_num_of_video_out_buffers(player_h player, int *num, int *extra_num); /** - * @brief Sets file path for buffering - * @since_tizen 3.0 - * @param[in] player The handle to the media player - * @param[in] file_path The file path for buffering - * @return @c 0 on success, - * otherwise a negative error value - * @retval #PLAYER_ERROR_NONE Successful - * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation - */ -int legacy_player_set_file_buffering_path(player_h player, const char *file_path); - -/** * @brief Retrieves all the streaming variant information. * @since_tizen 4.0 * @remarks This API is used for adaptive streaming(hls/mpeg dash) only. diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 17455fc..b4f4269 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -2530,21 +2530,6 @@ int legacy_player_get_num_of_video_out_buffers(player_h player, int *num, int *e return PLAYER_ERROR_NONE; } -int legacy_player_set_file_buffering_path(player_h player, const char *file_path) -{ - player_s *handle = (player_s *)player; - int ret = MM_ERROR_NONE; - PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(file_path); - PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); - - ret = mm_player_set_file_buffering_path(handle->mm_handle, file_path); - if (ret != MM_ERROR_NONE) - return __player_convert_error_code(ret, (char *)__FUNCTION__); - - return PLAYER_ERROR_NONE; -} - int legacy_player_manage_external_storage_state(player_h player, int id, int state) { player_s *handle = (player_s *)player; diff --git a/muse/src/muse_player.c b/muse/src/muse_player.c index 0e22a6b..ddc02f0 100644 --- a/muse/src/muse_player.c +++ b/muse/src/muse_player.c @@ -1496,14 +1496,6 @@ int player_disp_set_uri(muse_module_h module) ret = legacy_player_set_uri(muse_player->player_handle, path); PLAYER_RETURN_MSG(api, ret, module); - - if (ret == PLAYER_ERROR_NONE) { - const char *file_buffering_path = muse_server_module_get_temporal_path(); - - LOGD("file buffering path : %s", file_buffering_path); - if (file_buffering_path) - legacy_player_set_file_buffering_path(muse_player->player_handle, file_buffering_path); - } return ret; } diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 2bf9856..d61b417 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.96 +Version: 0.2.97 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From f28ce5fd0ed73f95933f5657016fe843c57ec288 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Wed, 9 Jan 2019 20:34:18 +0900 Subject: [PATCH 14/16] [0.2.98] avoid duplicated player releasement - the prepare_async thread is different from the dispatcher thread. so duplicated player releasement can cause crash by accessing invalid pointer. Change-Id: I1aae3bd17be4c49a037485d5be72dbf0936a389d --- legacy/include/legacy_player_private.h | 4 ++++ legacy/src/legacy_player.c | 32 +++++++++++++++++++++----------- packaging/mmsvc-player.spec | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/legacy/include/legacy_player_private.h b/legacy/include/legacy_player_private.h index f638d70..0b72b1a 100644 --- a/legacy/include/legacy_player_private.h +++ b/legacy/include/legacy_player_private.h @@ -23,6 +23,9 @@ extern "C" { #endif +#define LPLAYER_FENTER() LOGI(""); +#define LPLAYER_FLEAVE() LOGI(""); + #define PLAYER_CHECK_CONDITION(condition, error, msg) \ do { \ if (condition) {} else \ @@ -109,6 +112,7 @@ typedef struct _player_s { player_internal_state_e internal_state; bool is_display_visible; bool is_media_stream; + bool is_shutdown; pthread_t prepare_async_thread; pthread_t message_thread; GQueue *message_queue; diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index b4f4269..5f5477e 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -640,6 +640,8 @@ int legacy_player_destroy(player_h player) PLAYER_TRACE_BEGIN("MM:PLAYER:DESTROY"); PLAYER_INSTANCE_CHECK(player); + handle->is_shutdown = true; + __ADD_MESSAGE(handle, PLAYER_MESSAGE_LOOP_EXIT); LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); @@ -693,24 +695,28 @@ static void *__prepare_async_thread_func(void *data) { player_s *handle = data; int ret = MM_ERROR_NONE; - LOGI("[%s]", __FUNCTION__); + LPLAYER_FENTER(); ret = mm_player_pause(handle->mm_handle); if (ret != MM_ERROR_NONE) { - LOGE("[%s] Failed to pause - core fw error(0x%x)", __FUNCTION__, ret); + LOGE("Failed to pause - core fw error(0x%x)", ret); + __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); + if (handle->error_code == PLAYER_ERROR_NONE) { - /*MM_MESSAGE_ERROR will not be posted as legacy_player_prepare(sync API) works with return value - of mm_player_pause So in case of async API we post the error message to application from here */ + /* if there is no received error msg, it has to be posted here. */ MMMessageParamType msg_param; msg_param.code = ret; __msg_callback(MM_MESSAGE_ERROR, (void *)&msg_param, (void *)handle); } - ret = mm_player_unrealize(handle->mm_handle); - if (ret != MM_ERROR_NONE) - LOGE("[%s] Failed to unrealize - 0x%x", __FUNCTION__, ret); - __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); + + if (!handle->is_shutdown) { + ret = mm_player_unrealize(handle->mm_handle); + if (ret != MM_ERROR_NONE) + LOGE("Failed to unrealize - 0x%x", ret); + } } - LOGI("[%s], done", __FUNCTION__); + + LPLAYER_FLEAVE(); return NULL; } @@ -867,10 +873,13 @@ int legacy_player_unprepare(player_h player) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGI("[%s] Start", __FUNCTION__); + + LPLAYER_FENTER(); PLAYER_TRACE_BEGIN("MM:PLAYER:UNPREPARE"); PLAYER_INSTANCE_CHECK(player); + handle->is_shutdown = true; + /* Initialize the setting regardless of error return */ if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL; @@ -903,7 +912,8 @@ int legacy_player_unprepare(player_h player) __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); handle->is_display_visible = true; - LOGI("[%s] End", __FUNCTION__); + + LPLAYER_FLEAVE(); PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index d61b417..87a94c0 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.97 +Version: 0.2.98 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4 From 6b4ed1e0774262f52f3a41e931a5274da2e73417 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Wed, 9 Jan 2019 21:19:11 +0900 Subject: [PATCH 15/16] [0.2.98] modify log message - use function enter/leave macro - remove __FUNCTION__ which is included in dlog Change-Id: I6cc4d0b267ed2f338cc73759fcac3dc3f734e74c --- legacy/src/legacy_player.c | 232 ++++++++++++++++++++---------------- legacy/src/legacy_player_internal.c | 26 ++-- 2 files changed, 142 insertions(+), 116 deletions(-) diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 5f5477e..7c69e18 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -290,7 +290,7 @@ static int __set_callback(muse_player_event_e type, player_h player, void *callb handle->user_cb[type] = callback; handle->user_data[type] = user_data; - LOGI("[%s] Event type : %d ", __FUNCTION__, type); + LOGI("Event type : %d ", type); return PLAYER_ERROR_NONE; } @@ -300,7 +300,7 @@ static int __unset_callback(muse_player_event_e type, player_h player) PLAYER_INSTANCE_CHECK(player); handle->user_cb[type] = NULL; handle->user_data[type] = NULL; - LOGI("[%s] Event type : %d ", __FUNCTION__, type); + LOGI("Event type : %d ", type); return PLAYER_ERROR_NONE; } @@ -409,15 +409,16 @@ static int __msg_callback(int message, void *param, void *user_data) { player_s *handle = (player_s *)user_data; MMMessageParamType *msg = (MMMessageParamType *)param; - LOGW("[%s] Got message type : 0x%x", __FUNCTION__, message); player_error_e err_code = PLAYER_ERROR_NONE; + + LOGW("Got message type : 0x%x", message); switch (message) { case MM_MESSAGE_ERROR: /* 0x01 */ err_code = __player_convert_error_code(msg->code, (char *)__FUNCTION__); LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (PLAYER_ERROR_NOT_SUPPORTED_FILE == err_code && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { - LOGW("failed to pause, so prepare cb will be released soon"); + LOGW("Failed to pause, so prepare cb will be released soon"); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; if (handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]); @@ -432,7 +433,7 @@ static int __msg_callback(int message, void *param, void *user_data) LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { /* asyc && prepared cb has been set */ - LOGI("[%s] Prepared! [current state : %d]", __FUNCTION__, handle->state); + LOGI("Prepared! [current state : %d]", handle->state); PLAYER_TRACE_ASYNC_END("MM:PLAYER:PREPARE_ASYNC", *(int *)handle); __ADD_MESSAGE(handle, PLAYER_MESSAGE_PREPARED); } @@ -440,7 +441,7 @@ static int __msg_callback(int message, void *param, void *user_data) } break; case MM_MESSAGE_BEGIN_OF_STREAM: /* 0x104 */ - LOGI("[%s] Ready to streaming information (BOS) [current state : %d]", __FUNCTION__, handle->state); + LOGI("Ready to streaming information (BOS) [current state : %d]", handle->state); break; case MM_MESSAGE_END_OF_STREAM: /* 0x105 */ if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE]) @@ -467,7 +468,7 @@ static int __msg_callback(int message, void *param, void *user_data) } break; case MM_MESSAGE_CONNECTION_TIMEOUT: /* 0x102 */ - LOGI("[%s] PLAYER_ERROR_CONNECTION_FAILED (0x%08x) : CONNECTION_TIMEOUT", __FUNCTION__, PLAYER_ERROR_CONNECTION_FAILED); + LOGE("PLAYER_ERROR_CONNECTION_FAILED : CONNECTION_TIMEOUT"); err_code = PLAYER_ERROR_CONNECTION_FAILED; break; case MM_MESSAGE_UPDATE_SUBTITLE: /* 0x109 */ @@ -475,7 +476,7 @@ static int __msg_callback(int message, void *param, void *user_data) ((player_subtitle_updated_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE])(msg->subtitle.duration, (char *)msg->data, handle->user_data[MUSE_PLAYER_EVENT_TYPE_SUBTITLE]); break; case MM_MESSAGE_VIDEO_NOT_CAPTURED: /* 0x113 */ - LOGI("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x)", __FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED); + LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED"); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(PLAYER_ERROR_VIDEO_CAPTURE_FAILED, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]); break; @@ -485,7 +486,7 @@ static int __msg_callback(int message, void *param, void *user_data) if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) { if (!capture || !capture->data) { - LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : Failed to get capture data", PLAYER_ERROR_VIDEO_CAPTURE_FAILED); + LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED : Failed to get capture data"); err_code = PLAYER_ERROR_VIDEO_CAPTURE_FAILED; } else { LOGI("captured image ori: %d, width: %d, height: %d, size: %d", @@ -508,11 +509,11 @@ static int __msg_callback(int message, void *param, void *user_data) break; } case MM_MESSAGE_FILE_NOT_SUPPORTED: /* 0x10f */ - LOGI("[%s] PLAYER_ERROR_NOT_SUPPORTED_FILE (0x%08x) : FILE_NOT_SUPPORTED", __FUNCTION__, PLAYER_ERROR_NOT_SUPPORTED_FILE); + LOGE("PLAYER_ERROR_NOT_SUPPORTED_FILE : FILE_NOT_SUPPORTED"); err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE; break; case MM_MESSAGE_FILE_NOT_FOUND: /* 0x110 */ - LOGI("[%s] PLAYER_ERROR_NOT_SUPPORTED_FILE (0x%08x) : FILE_NOT_FOUND", __FUNCTION__, PLAYER_ERROR_NOT_SUPPORTED_FILE); + LOGE("PLAYER_ERROR_NOT_SUPPORTED_FILE : FILE_NOT_FOUND"); err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE; break; case MM_MESSAGE_SEEK_COMPLETED: /* 0x114 */ @@ -520,7 +521,7 @@ static int __msg_callback(int message, void *param, void *user_data) if (handle->is_display_visible) { int ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set display_visible '1' (0x%x)", __FUNCTION__, ret); + LOGW("Failed to set display_visible '1' (0x%x)", ret); } } if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) { @@ -550,7 +551,8 @@ static int __msg_callback(int message, void *param, void *user_data) handle->error_code = err_code; __ADD_MESSAGE(handle, PLAYER_MESSAGE_ERROR); } - LOGW("[%s] End", __FUNCTION__); + + LPLAYER_FLEAVE(); return 1; } @@ -589,16 +591,18 @@ int legacy_player_create(player_h *player) { player_s *handle; int ret = MM_ERROR_NONE; + PLAYER_INSTANCE_CHECK(player); PLAYER_TRACE_BEGIN("MM:PLAYER:CREATE"); + handle = g_try_new0(player_s, 1); if (!handle) { - LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, PLAYER_ERROR_OUT_OF_MEMORY); + LOGE("PLAYER_ERROR_OUT_OF_MEMORY"); return PLAYER_ERROR_OUT_OF_MEMORY; } ret = mm_player_create(&handle->mm_handle); if (ret != MM_ERROR_NONE) { - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + LOGE("Failed to create player 0x%X", ret); __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE); g_free(handle); handle = NULL; @@ -623,11 +627,11 @@ int legacy_player_create(player_h *player) 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); + LOGE("Failed to create message thread 0x%X", ret); return PLAYER_ERROR_OUT_OF_MEMORY; } - LOGI("[%s] new handle : %p", __FUNCTION__, *player); + LOGI("new handle : %p", *player); PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } @@ -636,7 +640,8 @@ int legacy_player_destroy(player_h player) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGI("[%s] Start, handle to destroy : %p", __FUNCTION__, player); + + LOGI("", player); PLAYER_TRACE_BEGIN("MM:PLAYER:DESTROY"); PLAYER_INSTANCE_CHECK(player); @@ -661,10 +666,10 @@ int legacy_player_destroy(player_h player) ret = mm_player_destroy(handle->mm_handle); if (ret != MM_ERROR_NONE) { - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + LOGE("Failed to player destroy 0x%X", ret); return PLAYER_ERROR_INVALID_OPERATION; } - LOGI("[%s] Done mm_player_destroy", __FUNCTION__); + LOGI("Done mm_player_destroy"); muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE; @@ -686,7 +691,8 @@ int legacy_player_destroy(player_h player) g_free(handle); handle = NULL; - LOGI("[%s] End", __FUNCTION__); + + LPLAYER_FLEAVE(); PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } @@ -727,7 +733,7 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo int visible = 0; int value = 0; - LOGI("[%s] Start", __FUNCTION__); + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); @@ -737,13 +743,13 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo handle->last_play_position = 0; if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing... we can't do any more ", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + LOGE("player is already prepareing"); LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); return PLAYER_ERROR_INVALID_OPERATION; } - /* LOGI("[%s] Event type : %d ",__FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PREPARE); */ + /* LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_PREPARE); */ handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback; handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data; @@ -751,12 +757,12 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set message callback function (0x%x)", __FUNCTION__, ret); + LOGW("Failed to set message callback function (0x%x)", ret); if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE) { ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char *)NULL); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", __FUNCTION__, ret); + LOGW("Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", ret); } else { /* FIXME : new funct path is needed to update video instead of set attr again */ @@ -774,14 +780,14 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo ret = mm_player_realize(handle->mm_handle); if (ret != MM_ERROR_NONE) { - LOGE("[%s] Failed to realize - 0x%x", __FUNCTION__, ret); + LOGE("Failed to realize - 0x%x", ret); goto ERROR; } ret = pthread_create(&handle->prepare_async_thread, NULL, (void *)__prepare_async_thread_func, (void *)handle); if (ret != 0) { - LOGE("[%s] failed to create thread ret = %d", __FUNCTION__, ret); + LOGE("Failed to create thread ret = %d", ret); LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL; @@ -793,7 +799,7 @@ int legacy_player_prepare_async(player_h player, player_prepared_cb callback, vo return PLAYER_ERROR_OUT_OF_MEMORY; } - LOGI("[%s] End", __FUNCTION__); + LPLAYER_FLEAVE(); return PLAYER_ERROR_NONE; ERROR: @@ -807,7 +813,7 @@ ERROR: LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE); __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); - LOGE("LEAVE mm_err:0x%X", ret); + LOGE("LEAVE 0x%X", ret); return __player_convert_error_code(ret, (char *)__FUNCTION__); } @@ -817,7 +823,7 @@ int legacy_player_prepare(player_h player) int visible = 0; player_s *handle = (player_s *)player; - LOGI("[%s] Start", __FUNCTION__); + LPLAYER_FENTER(); PLAYER_TRACE_BEGIN("MM:PLAYER:PREPARE"); PLAYER_INSTANCE_CHECK(player); PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE); @@ -826,12 +832,12 @@ int legacy_player_prepare(player_h player) handle->last_play_position = 0; ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set message callback function (0x%x)", __FUNCTION__, ret); + LOGW("Failed to set message callback function (0x%x)", ret); if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE) { ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char *)NULL); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", __FUNCTION__, ret); + LOGW("Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", ret); } else { ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL); if (ret != MM_ERROR_NONE) { @@ -841,12 +847,12 @@ int legacy_player_prepare(player_h player) ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", visible, (char *)NULL); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set display display_visible '%d' (0x%x)", __FUNCTION__, visible, ret); + LOGW("Failed to set display display_visible '%d' (0x%x)", visible, ret); } ret = mm_player_realize(handle->mm_handle); if (ret != MM_ERROR_NONE) { - LOGE("[%s] Failed to realize - 0x%x", __FUNCTION__, ret); + LOGE("Failed to realize - 0x%x", ret); __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); return __player_convert_error_code(ret, (char *)__FUNCTION__); } @@ -856,15 +862,16 @@ int legacy_player_prepare(player_h player) int uret; uret = mm_player_unrealize(handle->mm_handle); if (uret != MM_ERROR_NONE) - LOGE("[%s] Failed to unrealize - 0x%x", __FUNCTION__, uret); + LOGE("Failed to unrealize - 0x%x", uret); - LOGE("[%s] Failed to pause - 0x%x", __FUNCTION__, ret); + LOGE("Failed to pause - 0x%x", ret); __player_update_state(handle, PLAYER_INTERNAL_STATE_IDLE); return __player_convert_error_code(ret, (char *)__FUNCTION__); } __player_update_state(handle, PLAYER_INTERNAL_STATE_READY); - LOGI("[%s] End", __FUNCTION__); + + LPLAYER_FLEAVE(); PLAYER_TRACE_END(); return PLAYER_ERROR_NONE; } @@ -887,7 +894,7 @@ int legacy_player_unprepare(player_h player) } if (!__player_state_validate(handle, PLAYER_STATE_READY) && !handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1063,18 +1070,19 @@ int legacy_player_start(player_h player) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGI("[%s] Start", __FUNCTION__); + + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); if (handle->state > PLAYER_STATE_IDLE) { if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY && handle->is_display_visible) { ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set display_visible '1' (0x%x)", __FUNCTION__, ret); + LOGW("Failed to set display_visible '1' (0x%x)", ret); } if (handle->internal_state == PLAYER_INTERNAL_STATE_STOPPED) { ret = mm_player_start(handle->mm_handle); - LOGI("[%s] stop -> start() ", __FUNCTION__); + LOGI("stop -> start() "); } else { if (handle->state == PLAYER_STATE_READY) ret = mm_player_start(handle->mm_handle); @@ -1082,7 +1090,7 @@ int legacy_player_start(player_h player) ret = mm_player_resume(handle->mm_handle); } } else { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1090,7 +1098,8 @@ int legacy_player_start(player_h player) return __player_convert_error_code(ret, (char *)__FUNCTION__); __player_update_state(handle, PLAYER_INTERNAL_STATE_PLAYING); - LOGI("[%s] End", __FUNCTION__); + + LPLAYER_FLEAVE(); return PLAYER_ERROR_NONE; } @@ -1098,14 +1107,15 @@ int legacy_player_stop(player_h player) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGI("[%s] Start", __FUNCTION__); + + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); if (handle->state == PLAYER_STATE_PLAYING || handle->state == PLAYER_STATE_PAUSED) { if (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY) { ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 0, (char *)NULL); if (ret != MM_ERROR_NONE) - LOGW("[%s] Failed to set display_visible '0' (0x%x)", __FUNCTION__, ret); + LOGW("Failed to set display_visible '0' (0x%x)", ret); } ret = mm_player_stop(handle->mm_handle); @@ -1120,11 +1130,11 @@ int legacy_player_stop(player_h player) __player_update_state(handle, PLAYER_INTERNAL_STATE_STOPPED); - LOGI("[%s] End", __FUNCTION__); + LPLAYER_FLEAVE(); return PLAYER_ERROR_NONE; } - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1132,7 +1142,8 @@ int legacy_player_pause(player_h player) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGI("[%s] Start", __FUNCTION__); + + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); PLAYER_STATE_CHECK(handle, PLAYER_STATE_PLAYING); @@ -1141,7 +1152,8 @@ int legacy_player_pause(player_h player) return __player_convert_error_code(ret, (char *)__FUNCTION__); __player_update_state(handle, PLAYER_INTERNAL_STATE_PAUSED); - LOGI("[%s] End", __FUNCTION__); + + LPLAYER_FLEAVE(); return PLAYER_ERROR_NONE; } @@ -1150,20 +1162,22 @@ int legacy_player_set_play_position(player_h player, int64_t nanoseconds, bool a player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; int accurated = accurate ? 1 : 0; + + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(nanoseconds >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] && !handle->is_media_stream) { - LOGE("[%s] PLAYER_ERROR_SEEK_FAILED temp (0x%08x) : seeking... we can't do any more ", __FUNCTION__, PLAYER_ERROR_SEEK_FAILED); + LOGE("previous seeking request is in processing."); return PLAYER_ERROR_SEEK_FAILED; } - LOGI("[%s] Event type : %d, pos : %"PRId64, __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_SEEK, nanoseconds); + LOGI("Event type : %d, pos : %"PRId64, MUSE_PLAYER_EVENT_TYPE_SEEK, nanoseconds); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback; handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data; @@ -1178,6 +1192,7 @@ int legacy_player_set_play_position(player_h player, int64_t nanoseconds, bool a return __player_convert_error_code(ret, (char *)__FUNCTION__); } + LPLAYER_FLEAVE(); return PLAYER_ERROR_NONE; } @@ -1190,7 +1205,7 @@ int legacy_player_get_play_position(player_h player, int64_t *nanoseconds) PLAYER_NULL_ARG_CHECK(nanoseconds); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1287,7 +1302,7 @@ int legacy_player_get_duration(player_h player, int64_t *duration) PLAYER_NULL_ARG_CHECK(duration); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1303,8 +1318,9 @@ int legacy_player_set_display_mode(player_h player, player_display_mode_e mode) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + + LOGI("", mode); PLAYER_INSTANCE_CHECK(player); - LOGI("[%s] mode:%d", __FUNCTION__, mode); ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL); if (ret != MM_ERROR_NONE) @@ -1331,12 +1347,12 @@ int legacy_player_set_playback_rate(player_h player, float rate) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGI("[%s] rate : %0.1f", __FUNCTION__, rate); + LOGI("", rate); PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1348,7 +1364,7 @@ int legacy_player_set_playback_rate(player_h player, float rate) break; case MM_ERROR_NOT_SUPPORT_API: case MM_ERROR_PLAYER_SEEK: - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x) : seek error", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + LOGE("PLAYER_ERROR_INVALID_OPERATION : seek error"); ret = PLAYER_ERROR_INVALID_OPERATION; break; default: @@ -1431,7 +1447,7 @@ int legacy_player_get_content_info(player_h player, player_content_info_e key, c PLAYER_NULL_ARG_CHECK(value); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1469,7 +1485,7 @@ int legacy_player_get_content_info(player_h player, player_content_info_e key, c *value = strndup("", 0); if (*value == NULL) { - LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x) : fail to strdup ", __FUNCTION__, PLAYER_ERROR_OUT_OF_MEMORY); + LOGE("PLAYER_ERROR_OUT_OF_MEMORY : fail to strdup"); return PLAYER_ERROR_OUT_OF_MEMORY; } @@ -1489,7 +1505,7 @@ int legacy_player_get_codec_info(player_h player, char **audio_codec, char **vid PLAYER_NULL_ARG_CHECK(video_codec); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1523,7 +1539,7 @@ int legacy_player_get_audio_stream_info(player_h player, int *sample_rate, int * PLAYER_NULL_ARG_CHECK(bit_rate); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } 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); @@ -1542,7 +1558,7 @@ int legacy_player_get_video_stream_info(player_h player, int *fps, int *bit_rate PLAYER_NULL_ARG_CHECK(bit_rate); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } ret = mm_player_get_attribute(handle->mm_handle, NULL, "content_video_fps", fps, "content_video_bitrate", bit_rate, (char *)NULL); @@ -1562,7 +1578,7 @@ int legacy_player_get_video_size(player_h player, int *width, int *height) PLAYER_NULL_ARG_CHECK(width); PLAYER_NULL_ARG_CHECK(height); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &w, MM_PLAYER_VIDEO_HEIGHT, &h, (char *)NULL); @@ -1571,7 +1587,7 @@ int legacy_player_get_video_size(player_h player, int *width, int *height) *width = w; *height = h; - LOGI("[%s] width : %d, height : %d", __FUNCTION__, w, h); + LOGI("width : %d, height : %d", w, h); return PLAYER_ERROR_NONE; } @@ -1582,7 +1598,7 @@ int legacy_player_get_album_art(player_h player, void **album_art, int *size) PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(size); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1720,7 +1736,7 @@ int legacy_player_audio_effect_equalizer_is_available(player_h player, bool *ava PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(available); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1737,6 +1753,8 @@ int legacy_player_set_subtitle_path(player_h player, const char *path) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); if ((path == NULL) && (handle->state != PLAYER_STATE_IDLE)) @@ -1746,6 +1764,7 @@ int legacy_player_set_subtitle_path(player_h player, const char *path) if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); + LPLAYER_FLEAVE(); return PLAYER_ERROR_NONE; } @@ -1756,7 +1775,7 @@ int legacy_player_set_subtitle_position_offset(player_h player, int millisecond) int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_PLAYING)) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -1771,14 +1790,16 @@ int legacy_player_capture_video(player_h player, player_video_captured_cb callba { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; + + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) { - LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : capturing... we can't do any more ", __FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED); + LOGE("previous capturing request is in processing."); return PLAYER_ERROR_VIDEO_CAPTURE_FAILED; } - LOGI("[%s] Event type : %d ", __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_CAPTURE); + LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_CAPTURE); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback; handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data; @@ -1787,7 +1808,7 @@ int legacy_player_capture_video(player_h player, player_video_captured_cb callba if (ret == MM_ERROR_PLAYER_NO_OP) { handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : video display must be set : %d", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION, handle->display_type); + LOGE("PLAYER_ERROR_INVALID_OPERATION : video display must be set : %d", handle->display_type); return PLAYER_ERROR_INVALID_OPERATION; } if (ret != MM_ERROR_NONE) { @@ -1798,9 +1819,11 @@ int legacy_player_capture_video(player_h player, player_video_captured_cb callba return PLAYER_ERROR_NONE; } - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + + LPLAYER_FLEAVE(); return PLAYER_ERROR_INVALID_STATE; } @@ -1951,7 +1974,7 @@ static bool __video_stream_changed_callback(void *user_data) int ret = MM_ERROR_NONE; muse_player_event_e event_type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED; - LOGE("[%s] event type %d", __FUNCTION__, event_type); + LOGE("event type %d", event_type); if (handle->user_cb[event_type]) { int width = 0, height = 0, fps = 0, bit_rate = 0; @@ -1962,14 +1985,14 @@ static bool __video_stream_changed_callback(void *user_data) "content_video_bitrate", &bit_rate, (char *)NULL); if (ret != MM_ERROR_NONE) { - LOGE("[%s] get attr is failed", __FUNCTION__); + LOGE("get attr is failed"); return false; } ((player_video_stream_changed_cb)handle->user_cb[event_type])(width, height, fps, bit_rate, handle->user_data[event_type]); return true; } - LOGE("[%s] video stream changed cb was not set.", __FUNCTION__); + LOGE("video stream changed cb was not set."); return false; } @@ -2009,12 +2032,12 @@ static bool __media_stream_buffer_status_callback(player_stream_type_e type, pla else return false; - LOGE("[%s] event type %d", __FUNCTION__, event_type); + LOGE("event type %d", 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); + LOGE("[type:%d] buffer status cb was not set.", type); return false; } @@ -2033,12 +2056,12 @@ static bool __media_stream_seek_data_callback(player_stream_type_e type, unsigne else return false; - LOGE("[%s] event type %d", __FUNCTION__, event_type); + LOGE("event type %d", 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); + LOGE("[type:%d] seek cb was not set.", type); return false; } @@ -2055,7 +2078,7 @@ int legacy_player_set_media_stream_buffer_status_cb(player_h player, player_stre /* 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); + LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type); return PLAYER_ERROR_INVALID_PARAMETER; } @@ -2094,7 +2117,7 @@ int legacy_player_set_media_stream_seek_cb(player_h player, player_stream_type_e /* 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); + LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type); return PLAYER_ERROR_INVALID_PARAMETER; } @@ -2165,7 +2188,7 @@ int legacy_player_set_media_stream_buffer_max_size(player_h player, player_strea int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2198,7 +2221,7 @@ int legacy_player_set_media_stream_buffer_min_threshold(player_h player, player_ int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2234,7 +2257,7 @@ int legacy_player_get_track_count(player_h player, player_stream_type_e type, in PLAYER_NULL_ARG_CHECK(count); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2265,7 +2288,7 @@ int legacy_player_get_current_track(player_h player, player_stream_type_e type, PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(index); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2293,10 +2316,12 @@ int legacy_player_select_track(player_h player, player_stream_type_e type, int i player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; MMPlayerTrackType track_type = 0; + + LPLAYER_FENTER(); PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(index >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER"); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2316,6 +2341,7 @@ int legacy_player_select_track(player_h player, player_stream_type_e type, int i if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); + LPLAYER_FLEAVE(); return PLAYER_ERROR_NONE; } @@ -2328,7 +2354,7 @@ int legacy_player_get_track_language_code(player_h player, player_stream_type_e PLAYER_NULL_ARG_CHECK(code); PLAYER_NULL_ARG_CHECK(len); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2423,7 +2449,7 @@ int legacy_player_set_display(player_h player, player_display_type_e type, unsig MMDisplaySurfaceType mmType = __player_convert_display_type(type); PLAYER_INSTANCE_CHECK(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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2562,7 +2588,7 @@ int legacy_player_get_adaptive_variant_info(player_h player, int *num, char **va PLAYER_NULL_ARG_CHECK(var_info); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2609,7 +2635,7 @@ int legacy_player_set_audio_only(player_h player, bool audio_only) PLAYER_INSTANCE_CHECK(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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2659,7 +2685,7 @@ int legacy_player_get_streaming_buffering_time(player_h player, int *buffer_ms, PLAYER_NULL_ARG_CHECK(rebuffer_ms); 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2678,7 +2704,7 @@ int legacy_player_360_is_content_spherical(player_h player, bool *is_spherical) PLAYER_NULL_ARG_CHECK(is_spherical); if (!__player_state_validate(handle, PLAYER_STATE_READY)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2696,7 +2722,7 @@ int legacy_player_360_set_enabled(player_h player, bool enabled) PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2714,7 +2740,7 @@ int legacy_player_360_is_enabled(player_h player, bool *enabled) PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(enabled); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2732,7 +2758,7 @@ int legacy_player_360_set_direction_of_view(player_h player, float yaw, float pi PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2752,7 +2778,7 @@ int legacy_player_360_get_direction_of_view(player_h player, float *yaw, float * PLAYER_NULL_ARG_CHECK(pitch); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2770,7 +2796,7 @@ int legacy_player_360_set_zoom(player_h player, float level) PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2788,7 +2814,7 @@ int legacy_player_360_get_zoom(player_h player, float *level) PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2806,7 +2832,7 @@ int legacy_player_360_set_field_of_view(player_h player, int horizontal_degrees, PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2826,7 +2852,7 @@ int legacy_player_360_get_field_of_view(player_h player, int *horizontal_degrees PLAYER_NULL_ARG_CHECK(vertical_degrees); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2844,7 +2870,7 @@ int legacy_player_set_replaygain_enabled(player_h player, bool enabled) PLAYER_INSTANCE_CHECK(player); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -2864,7 +2890,7 @@ int legacy_player_is_replaygain_enabled(player_h player, bool *enabled) PLAYER_NULL_ARG_CHECK(enabled); if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d", PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } diff --git a/legacy/src/legacy_player_internal.c b/legacy/src/legacy_player_internal.c index 26c3e9e..5e9851a 100644 --- a/legacy/src/legacy_player_internal.c +++ b/legacy/src/legacy_player_internal.c @@ -37,7 +37,7 @@ do { \ 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); \ + LOGI("Event type : %d ", event_type); \ } while (0) bool __audio_stream_callback(MMPlayerAudioStreamDataType *stream, void *user_data) @@ -45,7 +45,7 @@ bool __audio_stream_callback(MMPlayerAudioStreamDataType *stream, void *user_dat player_s *handle = (player_s *)user_data; 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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return true; } @@ -105,11 +105,11 @@ int legacy_player_set_streaming_playback_rate(player_h player, float rate) { player_s *handle = (player_s *)player; int ret = MM_ERROR_NONE; - LOGI("[%s] rate : %0.1f", __FUNCTION__, rate); + LOGI("rate : %0.1f", rate); PLAYER_INSTANCE_CHECK(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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -121,7 +121,7 @@ int legacy_player_set_streaming_playback_rate(player_h player, float rate) break; case MM_ERROR_NOT_SUPPORT_API: case MM_ERROR_PLAYER_SEEK: - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x) : seek error", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + LOGE("PLAYER_ERROR_INVALID_OPERATION : seek error"); ret = PLAYER_ERROR_INVALID_OPERATION; break; default: @@ -147,14 +147,14 @@ static bool __media_stream_buffer_status_callback_ex(player_stream_type_e type, else return false; - LOGE("[%s] event type %d, status %d, bytes %llu", __FUNCTION__, event_type, status, bytes); + LOGE("event type %d, status %d, bytes %llu", event_type, status, bytes); LEGACY_PLAYER_USER_CB_LOCK(handle, event_type); if (handle->user_cb[event_type]) { ((player_media_stream_buffer_status_cb_ex)handle->user_cb[event_type])(status, bytes, handle->user_data[event_type]); } else { - LOGE("[%s][type:%d] buffer status cb was not set.", __FUNCTION__, type); + LOGE("[type:%d] buffer status cb was not set.", type); LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); return false; } @@ -174,12 +174,12 @@ int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_s PLAYER_NULL_ARG_CHECK(callback); if (handle->state != PLAYER_STATE_IDLE) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", 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); + LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type); return PLAYER_ERROR_INVALID_PARAMETER; } @@ -202,7 +202,7 @@ int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_s LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); - LOGI("[%s] Event type : %d ", __FUNCTION__, type); + LOGI("Event type : %d ", type); return PLAYER_ERROR_NONE; } @@ -226,7 +226,7 @@ int legacy_player_unset_media_stream_buffer_status_cb_ex(player_h player, player LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); - LOGI("[%s] Event type : %d ", __FUNCTION__, type); + LOGI("Event type : %d ", type); return PLAYER_ERROR_NONE; } @@ -251,7 +251,7 @@ int legacy_player_set_next_uri(player_h player, const char *uri) int ret = MM_ERROR_NONE; PLAYER_INSTANCE_CHECK(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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -269,7 +269,7 @@ int legacy_player_get_next_uri(player_h player, char **uri) PLAYER_INSTANCE_CHECK(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); + LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state); return PLAYER_ERROR_INVALID_STATE; } -- 2.7.4 From 5625c06ef9f273b307ff2fda9c3debcb840c5359 Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Mon, 7 Jan 2019 14:10:43 +0900 Subject: [PATCH 16/16] [0.2.99] Use codec data if media_packet has codec_data Change-Id: Ic08405baf6fff97bfd90ecb6b67db517f0032826 --- muse/include/muse_player_msg.h | 2 ++ muse/src/muse_player.c | 4 ++++ packaging/mmsvc-player.spec | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/muse/include/muse_player_msg.h b/muse/include/muse_player_msg.h index 75fb031..5d72051 100644 --- a/muse/include/muse_player_msg.h +++ b/muse/include/muse_player_msg.h @@ -47,6 +47,8 @@ typedef struct _player_push_media_msg_type { int height; media_format_mimetype_e mimetype; media_buffer_flags_e flags; + char codec_data[512]; + unsigned int codec_data_size; } player_push_media_msg_type; typedef struct { diff --git a/muse/src/muse_player.c b/muse/src/muse_player.c index ddc02f0..1a341c2 100644 --- a/muse/src/muse_player.c +++ b/muse/src/muse_player.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1172,6 +1173,9 @@ static int _push_media_stream(muse_player_handle_s *muse_player, player_push_med } } + if (push_media->codec_data_size > 0) + media_packet_set_codec_data(packet, push_media->codec_data, push_media->codec_data_size); + media_packet_set_pts(packet, push_media->pts); media_packet_set_flags(packet, push_media->flags); diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 87a94c0..e0068bc 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.98 +Version: 0.2.99 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4