From feff5bb00f0c5e44002065ba6140a5bb1c04f660 Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Fri, 17 Apr 2020 13:39:40 +0900 Subject: [PATCH] Add new APIs for VC-mgr - vc_mgr_send_audio_streaming() - vc_mgr_set_audio_streaming_mode() - vc_mgr_change_background_volume() - vc_mgr_recover_background_volume() - vc_mgr_set_background_volume_ratio() Change-Id: I09dbbdf6f64ea78cb4476cf3e77adae588cb3ef0 Signed-off-by: sungrae jo --- include/voice_control_manager.h | 170 +++++++++++++++++++++++++++++++ include/voice_control_manager_internal.h | 23 ----- 2 files changed, 170 insertions(+), 23 deletions(-) diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index 1475dd7..49defd3 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -124,6 +124,36 @@ typedef enum { } vc_pre_result_event_e; /** + * @brief Enumeration of audio streaming event. + * @since_tizen 6.0 + */ +typedef enum { + VC_AUDIO_STREAMING_EVENT_FAIL = -1, /**< Failed */ + VC_AUDIO_STREAMING_EVENT_START = 1, /**< Start event */ + VC_AUDIO_STREAMING_EVENT_CONTINUE = 2, /**< Continue event */ + VC_AUDIO_STREAMING_EVENT_FINISH = 3 /**< Finish event */ +} vc_audio_streaming_event_e; + +/** + * @brief Enumeration of audio streaming mode. + * @since_tizen 6.0 + */ +typedef enum { + VC_AUDIO_STREAMING_MODE_VC_SERVICE = 0, /**< Use audio recording from VC service */ + VC_AUDIO_STREAMING_MODE_MULTI_ASSISTANT = 1, /**< Use audio streaming from multi-assistant */ + VC_AUDIO_STREAMING_MODE_OUTSIDE = 2, /**< Use audio streaming from outside */ +} vc_audio_streaming_mode_e; + +/** + * @brief Enumeration of background volume event. + * @since_tizen 6.0 + */ +typedef enum { + VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_NEARFIELD = 0, /**< Background volume event for near-field */ + VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_FARFIELD /**< Background volume event for far-field */ +} vc_background_volume_event_e; + +/** * @brief Called when client gets the all recognition results from voice control service. * @since_tizen 5.0 * @@ -1795,6 +1825,146 @@ int vc_mgr_unset_vc_tts_streaming_cb(void); */ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status); +/** + * @platform + * @brief Sends audio streaming to the engine service. + * @details Using this function, the developer can send audio streaming after vc_mgr_start() function is called. + * @since_tizen 6.0 + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @param[in] event Audio streaming event (e.g. #VC_AUDIO_STREAMING_EVENT_START, #VC_AUDIO_STREAMING_EVENT_CONTINUE) + * @param[in] buffer Audio streaming data + * @param[in] len Length of the audio streaming data + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_OUT_OF_MEMORY Not enough memory + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_SERVICE_STATE_RECORDING. + * + * @see vc_mgr_set_audio_streaming_mode() + */ +int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char *buffer, unsigned int len); + +/** + * @platform + * @brief Sets audio streaming mode. + * @since_tizen 6.0 + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @remarks The default audio streaming mode is #VC_AUDIO_STREAMING_MODE_VC_SERVICE. \n + * If you want to use other mode, you can set mode with vc_mgr_set_audio_streaming_mode(). + * + * @param[in] mode Audio streaming mode + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_SERVICE_STATE_READY. + * + * @see vc_mgr_send_audio_streaming() + */ +int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode); + +/** + * @platform + * @brief Changes background volume. + * @since_tizen 6.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/volume.set + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @remarks If @a event is #VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_NEARFIELD, the background volume will be reduced by 70%. + * And, if @a event is #VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_FARFIELD, the background volume will be muted. + * + * @param[in] event The background volume event + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * + * @see vc_mgr_reset_background_volume() + * @see vc_mgr_change_background_volume_by_ratio() + */ +int vc_mgr_change_background_volume(vc_background_volume_event_e event); + +/** + * @platform + * @brief Changes background volume ratio. + * @details Calling this function sets the background volume to a given percentage of its current value. + * @since_tizen 6.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/volume.set + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @param[in] ratio Current background volume ratio (Range 0.0 ~ 1.0) + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * + * @see vc_mgr_change_background_volume() + * @see vc_mgr_reset_background_volume() + */ +int vc_mgr_change_background_volume_by_ratio(double ratio); + +/** + * @platform + * @brief Resets background volume. + * @details This function reverts all changes made by vc_mgr_change_background_volume() and vc_mgr_change_background_volume_by_ratio(). + * @since_tizen 6.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/volume.set + * + * @privlevel platform + * @privilege %http://tizen.org/privilege/voicecontrol.manager + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_NOT_SUPPORTED VC not supported + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_OPERATION_FAILED Operation fail + * + * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. + * + * @see vc_mgr_change_background_volume() + * @see vc_mgr_change_background_volume_by_ratio() + */ +int vc_mgr_reset_background_volume(void); #ifdef __cplusplus } diff --git a/include/voice_control_manager_internal.h b/include/voice_control_manager_internal.h index 627f025..b86be95 100644 --- a/include/voice_control_manager_internal.h +++ b/include/voice_control_manager_internal.h @@ -28,19 +28,6 @@ extern "C" #endif typedef enum { - VC_AUDIO_STREAMING_EVENT_FAIL = -1, /**< Failed */ - VC_AUDIO_STREAMING_EVENT_START = 1, /**< Start event */ - VC_AUDIO_STREAMING_EVENT_CONTINUE = 2, /**< Continue event */ - VC_AUDIO_STREAMING_EVENT_FINISH = 3 /**< Finish event */ -} vc_audio_streaming_event_e; - -typedef enum { - VC_AUDIO_STREAMING_MODE_VC_SERVICE = 0, /**< Use audio recording from vc service */ - VC_AUDIO_STREAMING_MODE_MULTI_ASSISTANT = 1, /**< Use audio streaming from multi-assistant */ - VC_AUDIO_STREAMING_MODE_OUTSIDE = 2, /**< Use audio streaming from outside */ -} vc_audio_streaming_mode_e; - -typedef enum { VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_NEARFIELD, VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_FARFIELD } vc_system_volume_event_e; @@ -99,16 +86,6 @@ int vc_mgr_unset_demandable_client_rule(void); int vc_mgr_set_domain(const char* domain); /** - * @brief Sends audio streaming to the engine service. - * @since_tizen 5.0 - * - */ -int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* buffer, unsigned int len); - -int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e streaming_mode); - - -/** * @brief Changes system volume. * @since_tizen 5.0 * -- 2.7.4