From e5609471795b46cd9b0a8248f6f1c7e18a7e29d8 Mon Sep 17 00:00:00 2001 From: Hyunil Park Date: Wed, 29 Jul 2015 17:02:36 +0900 Subject: [PATCH] Change setting sound type (ACR of sound-manager) 1. Define Deprecated enum value of player_interrupted_code_e (ACR of asm) 2. Add deprecated comment for deprecating player_set_sound_type API (ACR of asm) 3. Add player_set_audio_policy_info API (ACR of asm) Change-Id: I16b4651806036cc16cd314a453fa4b0f524a3cc6 Signed-off-by: Hyunil Park --- doc/player_doc.h | 5 +++++ include/mobile/player.h | 41 +++++++++++++++++++++++++++++++-------- include/wearable/player.h | 39 ++++++++++++++++++++++++++++++------- src/player.c | 38 ++++++++++++++++++++++++++++++++++++ test/player_test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+), 15 deletions(-) mode change 100644 => 100755 doc/player_doc.h mode change 100644 => 100755 src/player.c mode change 100644 => 100755 test/player_test.c diff --git a/doc/player_doc.h b/doc/player_doc.h old mode 100644 new mode 100755 index 390172b..684006c --- a/doc/player_doc.h +++ b/doc/player_doc.h @@ -190,6 +190,11 @@ * This function must be called after player_create() * * + * player_set_audio_policy_info() + * IDLE + * This function must be called after player_create() + * + * * player_set_sound_type() * IDLE * This function must be called after player_create() diff --git a/include/mobile/player.h b/include/mobile/player.h index 0cd195e..2514436 100755 --- a/include/mobile/player.h +++ b/include/mobile/player.h @@ -90,14 +90,14 @@ typedef enum */ typedef enum { - PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed */ - PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application */ - PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call */ - PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones */ + PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones (Deprecated since 3.0)*/ PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */ - PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm */ - PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency */ - PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification */ + PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification (Deprecated since 3.0)*/ } player_interrupted_code_e; /** @@ -593,6 +593,7 @@ int player_set_volume(player_h player, float left, float right); int player_get_volume(player_h player, float *left, float *right); /** + * @deprecated Deprecated since 3.0. Use player_set_audio_policy_info() instead. * @brief Sets the player's volume type. * @since_tizen 2.3 * @remarks The default sound type of the player is #SOUND_TYPE_MEDIA. @@ -610,6 +611,28 @@ int player_get_volume(player_h player, float *left, float *right); int player_set_sound_type(player_h player, sound_type_e type); /** + * @brief Sets the player's sound manager stream information. + * @since_tizen 3.0 + * @remarks You can set sound stream information including audio routing and volume type. + * For more details, please refer to sound_manager.h + * + * @param[in] player The handle to the media player + * @param[in] stream_info The sound manager info type + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create(). + * @see #sound_stream_info_h + * @see sound_manager_create_stream_information() + * @see sound_manager_destroy_stream_information() + */ +int player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info); + +/** * @brief Sets the audio latency mode. * @since_tizen 2.3 * @remarks The default audio latency mode of the player is #AUDIO_LATENCY_MODE_MID. @@ -647,11 +670,13 @@ int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency /** * @brief Starts or resumes playback. * @since_tizen 2.3 + * @remarks Sound can be mixed with other sounds if you don't control the stream focus in sound-manager module since 3.0.\n + * You can refer to @ref CAPI_MEDIA_SUOND_MANAGER_MODULE. * @details Plays current media content, or resumes play if paused. * * @param[in] player The handle to the media player * @return @c 0 on success, - * otherwise a negative error value + * otherwise a negative error value * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation diff --git a/include/wearable/player.h b/include/wearable/player.h index 67b1db9..44b2414 100755 --- a/include/wearable/player.h +++ b/include/wearable/player.h @@ -90,14 +90,14 @@ typedef enum */ typedef enum { - PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed */ - PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application */ - PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call */ - PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones */ + PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application (Deprecated since 3.0) */ + PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones (Deprecated since 3.0)*/ PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */ - PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm */ - PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency */ - PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification */ + PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm (Deprecated since 3.0) */ + PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification (Deprecated since 3.0)*/ } player_interrupted_code_e; /** @@ -592,6 +592,7 @@ int player_set_volume(player_h player, float left, float right); int player_get_volume(player_h player, float *left, float *right); /** + * @deprecated Deprecated since 3.0. Use player_set_audio_policy_info() instead. * @brief Sets the player's volume type. * @since_tizen 2.3.1 * @remarks The default sound type of the player is #SOUND_TYPE_MEDIA. @@ -609,6 +610,28 @@ int player_get_volume(player_h player, float *left, float *right); int player_set_sound_type(player_h player, sound_type_e type); /** + * @brief Sets the player's sound manager stream information. + * @since_tizen 3.0 + * @remarks You can set sound stream information including audio routing and volume type. + * For more details, please refer to sound_manager.h + * + * @param[in] player The handle to the media player + * @param[in] stream_info The sound manager info type + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature + * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create(). + * @see #sound_stream_info_h + * @see sound_manager_create_stream_information() + * @see sound_manager_destroy_stream_information() + */ +int player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info); + +/** * @brief Sets the audio latency mode. * @since_tizen 2.3.1 * @remarks The default audio latency mode of the player is #AUDIO_LATENCY_MODE_MID. @@ -646,6 +669,8 @@ int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency /** * @brief Starts or resumes playback. * @since_tizen 2.3.1 + * @remarks Sound can be mixed with other sounds if you don't control the stream focus in sound-manager module since 3.0.\n + * You can refer to @ref CAPI_MEDIA_SUOND_MANAGER_MODULE. * @details Plays current media content, or resumes play if paused. * * @param[in] player The handle to the media player diff --git a/src/player.c b/src/player.c old mode 100644 new mode 100755 index 95753b0..1179ef7 --- a/src/player.c +++ b/src/player.c @@ -1517,6 +1517,44 @@ int player_set_sound_type(player_h player, sound_type_e type) return PLAYER_ERROR_NONE; } +int player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) 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) + { + return __player_convert_error_code(ret,(char*)__FUNCTION__); + } + 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_attribute(handle->mm_handle, NULL,"sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, (char*)NULL); + else + ret = MM_ERROR_PLAYER_INTERNAL; + } + } + + if(ret != MM_ERROR_NONE) + return __player_convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode) { PLAYER_INSTANCE_CHECK(player); diff --git a/test/player_test.c b/test/player_test.c old mode 100644 new mode 100755 index 2a98568..925fd68 --- a/test/player_test.c +++ b/test/player_test.c @@ -67,6 +67,7 @@ enum CURRENT_STATUS_FILENAME, CURRENT_STATUS_VOLUME, CURRENT_STATUS_SOUND_TYPE, + CURRENT_STATUS_SOUND_STREAM_INFO, CURRENT_STATUS_MUTE, CURRENT_STATUS_POSITION_TIME, CURRENT_STATUS_LOOPING, @@ -246,6 +247,7 @@ int g_handle_num = 1; int g_menu_state = CURRENT_STATUS_MAINMENU; char g_file_list[9][256]; gboolean quit_pushing; +sound_stream_info_h g_stream_info_h = NULL; static void prepared_cb(void *user_data) { @@ -871,6 +873,12 @@ static void _player_destroy() } } + if (g_stream_info_h) + { + sound_manager_destroy_stream_information(g_stream_info_h); + g_stream_info_h = NULL; + } + if (g_video_pkt) media_packet_destroy(g_video_pkt); @@ -1021,6 +1029,32 @@ static void set_sound_type(sound_type_e type) g_print("set sound type(%d) success", type); } +void focus_callback (sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data) +{ + g_print("FOCUS callback is called, reason_for_change(%d), additional_info(%s), userdata(%p)", reason_for_change, additional_info, user_data); + return; +} + +static void set_sound_stream_info(int type) +{ + if (g_stream_info_h) + { + g_print("stream information is already set, please destory handle and try again\n"); + return; + } + if (sound_manager_create_stream_information( type, focus_callback, g_player[0], &g_stream_info_h)) + { + g_print("failed to create stream_information()\n"); + return; + } + if ( player_set_audio_policy_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE ) + { + g_print("failed to set sound stream information(%p)\n", g_stream_info_h); + } + else + g_print("set stream information(%p) success", g_stream_info_h); +} + static void get_position() { int position = 0; @@ -1578,6 +1612,10 @@ void _interpret_main_menu(char *cmd) { g_menu_state = CURRENT_STATUS_SOUND_TYPE; } + else if (strncmp(cmd, "k", 1) == 0) + { + g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO; + } else if (strncmp(cmd, "h", 1) == 0 ) { g_menu_state = CURRENT_STATUS_MUTE; @@ -1832,6 +1870,10 @@ static void displaymenu() { g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n"); } + else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) + { + g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:RINGTONE 5:CALL 6:VOIP)\n"); + } else if (g_menu_state == CURRENT_STATUS_MUTE) { g_print("*** input mute value.(0: Not Mute, 1: Mute) \n"); @@ -1969,6 +2011,13 @@ static void interpret (char *cmd) reset_menu_state(); } break; + case CURRENT_STATUS_SOUND_STREAM_INFO: + { + int type = atoi(cmd); + set_sound_stream_info(type); + reset_menu_state(); + } + break; case CURRENT_STATUS_MUTE: { int mute = atoi(cmd); -- 2.7.4