Add document in vce.h 66/171966/1
authorsungrae jo <seongrae.jo@samsung.com>
Thu, 8 Mar 2018 09:26:53 +0000 (18:26 +0900)
committersungrae jo <seongrae.jo@samsung.com>
Thu, 8 Mar 2018 09:26:53 +0000 (18:26 +0900)
Change-Id: I8ad2ef78d0f3f66ce9911ed33834bcd2f0e33677
Signed-off-by: sungrae jo <seongrae.jo@samsung.com>
include/vce.h
server/vcd_dbus.c
server/vcd_engine_agent.c
server/vcd_main.h
server/vcd_server.c

index a921cd1..3d0946a 100755 (executable)
@@ -39,9 +39,11 @@ typedef enum {
        VCE_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
        VCE_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
        VCE_ERROR_OUT_OF_NETWORK        = TIZEN_ERROR_NETWORK_DOWN,     /**< Out of network */
+    VCE_ERROR_RECORDER_BUSY    = TIZEN_ERROR_RESOURCE_BUSY,/**< Busy resource */
        VCE_ERROR_INVALID_STATE         = TIZEN_ERROR_VOICE_CONTROL | 0x011, /**< Invalid state */
        VCE_ERROR_INVALID_LANGUAGE      = TIZEN_ERROR_VOICE_CONTROL | 0x012, /**< Invalid language */
        VCE_ERROR_OPERATION_FAILED      = TIZEN_ERROR_VOICE_CONTROL | 0x014, /**< Operation failed */
+    VCE_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
        VCE_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_VOICE_CONTROL | 0x022 /**< Not supported feature of current engine */
 } vce_error_e;
 
@@ -74,72 +76,71 @@ typedef enum {
        VCE_COMMAND_FORMAT_VFIXED_AND_FIXED,    /**< variable-fixed command + Fixed command */
        VCE_COMMAND_FORMAT_FIXED_AND_NONFIXED,  /**< Fixed command + Non-fixed command */
        VCE_COMMAND_FORMAT_NONFIXED_AND_FIXED,  /**< Non-fixed command + Fixed command */
-       VCE_COMMAND_FORMAT_ACTION,
-       VCE_COMMAND_FORMAT_PARTIAL
+    VCE_COMMAND_FORMAT_ACTION,              /**< Action command */
+    VCE_COMMAND_FORMAT_PARTIAL              /**< Partial matched command */
 } vce_command_format_e;
 
 /**
-* @brief Definition for foreground command type.
+* @brief Enumerations of speech detect.
 * @since_tizen 5.0
 */
-#define VCE_COMMAND_TYPE_FOREGROUND    1
+typedef enum {
+    VCE_SPEECH_DETECT_NONE = 0,        /**< No event */
+    VCE_SPEECH_DETECT_BEGIN,   /**< Begin of speech detected */
+    VCE_SPEECH_DETECT_END,             /**< End of speech detected */
+} vce_speech_detect_e;
 
 /**
-* @brief Definition for background command type.
+* @brief Enumerations of ASR result events.
 * @since_tizen 5.0
 */
-#define VCE_COMMAND_TYPE_BACKGROUND    2
+typedef enum {
+    VCE_ASR_RESULT_EVENT_FINAL_RESULT = 0, /**< Event when the ASR result is last data or ASR result is only one result */
+    VCE_ASR_RESULT_EVENT_PARTIAL_RESULT,   /**< Event when the ASR result exist, not first and not last */
+    VCE_ASR_RESULT_EVENT_ERROR             /**< Event when the ASR result is failed */
+} vce_asr_result_event_e;
 
 /**
-* @brief Definition for widget command type.
+* @brief A structure of handle for VC command.
 * @since_tizen 5.0
 */
-#define VCE_COMMAND_TYPE_WIDGET                3
+typedef int vce_cmd_h;
 
 /**
-* @brief Definition for system command type.
+* @brief Definition for foreground command type.
 * @since_tizen 5.0
 */
-#define VCE_COMMAND_TYPE_SYSTEM                4
+#define VCE_COMMAND_TYPE_FOREGROUND    1
 
 /**
-* @brief Definition for system background command type.
+* @brief Definition for background command type.
 * @since_tizen 5.0
 */
-#define VCE_COMMAND_TYPE_SYSTEM_BACKGROUND     5
+#define VCE_COMMAND_TYPE_BACKGROUND    2
 
 /**
-* @brief Definitions for exclusive command type.
+* @brief Definition for widget command type.
 * @since_tizen 5.0
 */
-#define VCE_COMMAND_TYPE_EXCLUSIVE     6
-
+#define VCE_COMMAND_TYPE_WIDGET                3
 
 /**
-* @brief Enumerations of speech detect.
+* @brief Definition for system command type.
 * @since_tizen 5.0
 */
-typedef enum {
-       VCE_SPEECH_DETECT_NONE = 0,     /**< No event */
-       VCE_SPEECH_DETECT_BEGIN,        /**< Begin of speech detected */
-       VCE_SPEECH_DETECT_END,          /**< End of speech detected */
-} vce_speech_detect_e;
+#define VCE_COMMAND_TYPE_SYSTEM                4
 
 /**
-* @brief Enumerations of ASR result events
+* @brief Definition for system background command type.
 * @since_tizen 5.0
 */
-typedef enum {
-       VCE_ASR_RESULT_EVENT_FINAL_RESULT = 0,
-       VCE_ASR_RESULT_EVENT_PARTIAL_RESULT,
-       VCE_ASR_RESULT_EVENT_ERROR
-} vce_asr_result_event_e;
+#define VCE_COMMAND_TYPE_SYSTEM_BACKGROUND     5
 
 /**
-* @brief A structure of handle for VC command
+* @brief Definitions for exclusive command type.
 * @since_tizen 5.0
 */
-typedef int vce_cmd_h;
+#define VCE_COMMAND_TYPE_EXCLUSIVE     6
 
 /**
 * @brief Definition of bluetooth audio id.
@@ -155,32 +156,28 @@ typedef int vce_cmd_h;
 
 /**
 * @brief Definition for none message.
+* @since_tizen 5.0
 */
 #define VC_RESULT_MESSAGE_NONE                 "vc.result.message.none"
 
 /**
 * @brief Definition for failed recognition because the speech is too loud to listen.
+* @since_tizen 5.0
 */
 #define VC_RESULT_MESSAGE_ERROR_TOO_LOUD       "vc.result.message.error.too.loud"
 
-
-
 /**
 * @brief Called when VC engine informs the engine service user about whole supported languages.
 * @details This callback function is implemented by the engine service user. Therefore, the engine developer does NOT have to implement this callback function.
 * @since_tizen 5.0
 * @remarks This callback function is called by vce_foreach_supported_languages_cb() to retrieve the whole supported language list.
 *              @a user_data must be transferred from vce_foreach_supported_languages_cb().
-*
 * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code
 *              followed by ISO 639-1 for the two-letter language code \n
 *              For example, "ko_KR" for Korean, "en_US" for American English
 * @param[in] user_data The user data passed from the foreach function
-*
 * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
-*
 * @pre vce_foreach_supported_languages() will invoke this callback.
-*
 * @see vce_foreach_supported_languages()
 */
 typedef bool (*vce_supported_language_cb)(const char* language, void* user_data);
@@ -189,55 +186,50 @@ typedef bool (*vce_supported_language_cb)(const char* language, void* user_data)
 * @brief Called when the engine service user initializes VC engine.
 * @since_tizen 5.0
 * @remarks This callback function is mandatory and must be registered using vce_main().
-*
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #VCE_ERROR_INVALID_STATE Already initialized
 * @retval #VCE_ERROR_OPERATION_FAILED Operation failed
-*
 * @see vce_deinitialize_cb()
 */
 typedef int (*vce_initialize_cb)(void);
 
 /**
-* @brief Called when the engine service user deinitializes VC engine
+* @brief Called when the engine service user deinitializes VC engine.
 * @since_tizen 5.0
 * @remarks This callback function is mandatory and must be registered using vce_main().
-*
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_STATE Not initialized
-*
 * @see vce_initialize_cb()
 */
 typedef int (*vce_deinitialize_cb)(void);
 
 /**
 * @brief Called when the engine service user requests the recording format of VC engine.
-*
-* @param[in] audio_id The audio device id.
+* @since_tizen 5.0
+* @remarks This callback function is mandatory and must be registered using vce_main().
+* @param[out] audio_id The audio device id. (e.g. #VCE_AUDIO_ID_BLUETOOTH or VCE_AUDIO_ID_WIFI)
 * @param[out] types The format used by the recorder.
 * @param[out] rate The sample rate used by the recorder.
 * @param[out] channels The number of channels used by the recorder.
-*
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_PARAMETER Not initialized
 */
-typedef int (*vce_get_recording_format_cb)(const char* audio_id, vce_audio_type_e* types, int* rate, int* channels);
+typedef int (*vce_get_recording_format_cb)(const char* audio_id, const vce_audio_type_e* types, const int* rate, const int* channels);
 
 /**
 * @brief Called when the engine service user retrieves all supported languages of VC engine.
-*
+* @since_tizen 5.0
+* @remarks This callback function is mandatory and must be registered using vce_main().
 * @param[in] callback a callback function
 * @param[in] user_data The user data to be passed to the callback function
-*
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #VCE_ERROR_INVALID_STATE Not initialized
-*
 * @post This function invokes vce_supported_language_cb() repeatedly for getting supported languages.
 *
 * @see vce_supported_language_cb()
@@ -246,18 +238,17 @@ typedef int (*vce_foreach_supported_languages_cb)(vce_supported_language_cb call
 
 /**
 * @brief Called when the engine service user checks whether a language is supported or not.
-*
-* @param[in] language A language
-*
+* @since_tizen 5.0
+* @remarks This callback function is mandatory and must be registered using vce_main().
+* @param[out] language A language
 * @return @c true = supported, \n @c false = not supported.
 */
 typedef bool (*vce_is_language_supported_cb)(const char* language);
 
 /**
 * @brief Called when the engine service user sets language.
-*
+* @since_tizen 5.0
 * @param[in] language A language.
-*
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_LANGUAGE Invalid language
@@ -267,42 +258,42 @@ typedef int (*vce_set_language_cb)(const char* language);
 
 /**
 * @brief Called when the engine service user sets command list before recognition.
-*
-* @remark This function should set commands via vcd_foreach_command().
-*
-* @param[in] vc_command command handle.
-*
+* @since_tizen 5.0
+* @remarks This function should set commands via vcd_foreach_command().
+* @param[in] vc_command command handle. 
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #VCE_ERROR_INVALID_STATE Invalid state
 * @retval #VCE_ERROR_OPERATION_FAILED Operation failed
 * @retval #VCE_ERROR_NOT_SUPPORTED_FEATURE Not supported command type
-*
 * @post vce_start() is called after this function is successful.
-*
 * @see vce_start()
 * @see vcd_foreach_command()
 * @see vce_unset_commands()
+* @see vce_get_command_count()
 */
 typedef int (*vce_set_commands_cb)(vce_cmd_h vc_command);
 
 /**
 * @brief Called when the engine service user unsets command list for reset.
-*
+* @since_tizen 5.0
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #VCE_ERROR_INVALID_STATE Invalid state
 * @retval #VCE_ERROR_OPERATION_FAILED Operation failed
-*
-* @see vce_set_commands()
+* @see vce_set_commands_cb()
 */
-typedef int (*vce_unset_commands_cb)();
+typedef int (*vce_unset_commands_cb)(void);
 
 /**
 * @brief Called when the engine service user starts recognition.
-*
+* @since_tizen 5.0
+* @remarks This callback function is mandatory and must be registered using vce_main().
+* @param[in] stop_by_silence Silence detection option.
+*                   @c true to detect the silence,
+*                   @c false not to detect the silence
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
@@ -310,10 +301,8 @@ typedef int (*vce_unset_commands_cb)();
 * @retval #VCE_ERROR_INVALID_LANGUAGE Invalid language
 * @retval #VCE_ERROR_OUT_OF_NETWORK Out of network
 * @retval #VCE_ERROR_OPERATION_FAILED Operation failed
-*
 * @pre vcd_foreach_command() is successful.
-*
-* @see vce_set_recording_data()
+* @see vce_set_recording_data_cb()
 * @see vce_stop()
 * @see vce_cancel()
 */
@@ -321,21 +310,17 @@ typedef int (*vce_start_cb)(bool stop_by_silence);
 
 /**
 * @brief Called when the engine service user sets recording data for speech recognition from recorder.
-*
-* @remark This function should be returned immediately after recording data copy.
-*
-* @param[in] data A recording data
-* @param[in] length A length of recording data
-* @param[out] silence_detected @c true Silence detected \n @c false No silence detected
-*
+* @since_tizen 5.0
+* @remarks This function should be returned immediately after recording data copy.
+* @param[out] data A recording data
+* @param[out] length A length of recording data
+* @param[in] speech_detected The status of speech (e.g. VCE_SPEECH_DETECT_BEGIN or VCE_SPEECH_DETECT_END)
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #VCE_ERROR_INVALID_STATE Invalid state
 * @retval #VCE_ERROR_OPERATION_FAILED Operation failed
-*
 * @pre vce_start() is successful.
-*
 * @see vce_start()
 * @see vce_cancel()
 * @see vce_stop()
@@ -344,15 +329,13 @@ typedef int(*vce_set_recording_data_cb)(const void* data, unsigned int length, v
 
 /**
 * @brief Called when the engine service user stops to get the result of recognition.
-*
+* @since_tizen 5.0
 * @return 0 on success, otherwise a negative error value
 * @retval #VCE_ERROR_NONE Successful
 * @retval #VCE_ERROR_INVALID_STATE Invalid state
 * @retval #VCE_ERROR_OPERATION_FAILED Operation failed
 * @retval #VCE_ERROR_OUT_OF_NETWORK Out of network
-*
 * @pre vce_set_recording_data() is successful.
-*
 * @see vce_start()
 * @see vce_set_recording_data()
 * @see vce_result_cb()
@@ -362,35 +345,31 @@ typedef int (*vce_stop_cb)(void);
 
 /**
 * @brief Called when the engine service user cancels the recognition process.
-*
+* @since_tizen 5.0
 * @return 0 on success, otherwise a negative error value.
 * @retval #VCE_ERROR_NONE Successful.
 * @retval #VCE_ERROR_INVALID_STATE Invalid state.
-*
 * @pre vce_start() is successful.
-*
 * @see vce_start()
 * @see vce_stop()
 */
 typedef int (*vce_cancel_cb)(void);
 
 /**
-* @brief Set audio recording type.
-*
+* @brief Called when the engine service user sets audio recording type.
+* @since_tizen 5.0
+* @param[in] audio Available agent or device type
 * @return 0 on success, otherwise a negative error value.
 * @retval #VCE_ERROR_NONE Successful.
-*
 */
-typedef int (*vce_set_audio_type)(const char* audio);
-
+typedef int (*vce_set_audio_type_cb)(const char* audio);
 
 /**
-* @brief Called when the engine service user sets domain (Agent or device type)
-*
+* @brief Called when the engine service user sets domain (Agent or device type).
+* @since_tizen 5.0
 * @param[in] domain Available agent or device type
-*
 * @return 0 on success, otherwise a negative error value.
-*
+* @retval #VCE_ERROR_NONE Successful.
 */
 typedef int (*vce_set_domain_cb)(const char* domain);
 
@@ -398,86 +377,76 @@ typedef int (*vce_set_domain_cb)(const char* domain);
 * @brief Called when the engine service user requests essential value from nlu result.
 * @since_tizen 5.0
 * @remarks This function is available inside vce_nlu_result_cb()
-*
 * @param[in] key NLU base info key
-* @parma[out] value NLU base info value
-*
+* @param[out] value NLU base info value
 * @return 0 on success, otherwise a negative error value.
-*
 */
 typedef int (*vce_nlu_base_info_requested_cb)(const char* key, char** value);
 
 /**
 * @brief Called when the engine service user sets private data between app and engine.
-*
+* @since_tizen 5.0
 * @param[in] key Private key
 * @param[in] data Private data
-*
 * @return 0 on success, otherwise a negative error value.
-*
 */
 typedef int (*vce_private_data_set_cb)(const char* key, const char* data);
 
 /**
 * @brief Called when the engine service user requests private data between app and engine.
-*
+* @since_tizen 5.0
 * @param[in] key Private key
 * @param[out] data Private data
-*
 * @return 0 on success, otherwise a negative error value.
-*
 */
 typedef int (*vce_private_data_requested_cb)(const char* key, char** data);
 
 /**
 * @brief Called when the engine service user requests process text.
-*
+* @since_tizen 5.0
 * @param[in] text Requested text
-*
 * @return 0 on success, otherwise a negative error value.
-*
 */
 typedef int (*vce_process_text_cb)(const char* text);
 
 /**
 * @brief Called when the engine service user requests list event.
-*
+* @since_tizen 5.0
 * @param[in] event Requested list event
-*
 * @return 0 on success, otherwise a negative error value.
-*
 */
 typedef int (*vce_process_list_event_cb)(const char* event);
 
 /**
 * @brief Called when the engine service user requests haptic event.
-*
+* @since_tizen 5.0
 * @param[in] event Requested haptic event
-*
 * @return 0 on success, otherwise a negative error value.
-*
 */
 typedef int (*vce_process_haptic_event_cb)(const char* event);
 
 /**
 * @brief Called when the engine service user requests the base information of VC engine.
 * @since_tizen 5.0
-*
+* @remarks This callback function is mandatory and must be registered using vce_main().
+*          The allocated @a engine_uuid, @a engine_name, and @a engine_setting will be released internally.
+*          In order to upload the engine at Tizen Appstore, both a service app and a ui app are necessary.
+*          Therefore, @a engine_setting must be transferred to the engine service user.
 * @param[out] engine_uuid The engine id
 * @param[out] engine_name The engine name
 * @param[out] engine_setting The setting path name
 * @param[out] use_network @c true to need network @c false not to need network.
+* @return @c 0 on success, 
+*         otherwise a negative error code on failure
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
 */
 typedef int (*vce_get_info_cb)(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network);
 
-
-/**
-* Daemon API.
-*/
-
 /**
 * @brief Called to retrieve the commands.
-*
+* @since_tizen 5.0
 * @param[in] id command id
 * @param[in] type command type
 * @param[in] format command format
@@ -485,95 +454,12 @@ typedef int (*vce_get_info_cb)(char** engine_uuid, char** engine_name, char** en
 * @param[in] param parameter text
 * @param[in] domain command domain
 * @param[in] user_data The user data passed from the foreach function
-*
 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
 * @pre vce_get_foreach_command() will invoke this callback.
-*
 * @see vce_get_foreach_command()
 */
 typedef bool (*vce_command_cb)(int id, int type, int format, const char* command, const char* param, int domain, void* user_data);
 
-/**
-* @brief Retrieves all commands using callback function.
-*
-* @param[in] vce_command The handle to be passed to the vce_set_commands() function
-* @param[in] callback The callback function to invoke
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCE_ERROR_NONE Successful
-* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
-* @retval #VCE_ERROR_INVALID_STATE Invalid state
-*
-* @post        This function invokes vce_command_cb() repeatedly for getting commands.
-*
-* @see vce_foreach_command_cb()
-* @see vce_set_commands()
-*/
-int vce_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data);
-
-/**
-* @brief Gets command length.
-*
-* @param[in] vce_command The handle to be passed to the vce_set_commands() function
-*
-* @return the value greater than 0 on success, otherwise a negative error value
-*
-* @see vce_set_commands()
-*/
-int vce_get_command_count(vce_cmd_h vce_command);
-
-/**
-* @brief Gets current audio type.
-*
-* @remarks audio_type must be released using free() when it is no longer required.
-*
-* @param[in] audio_type Current audio type  (e.g. #VCE_AUDIO_ID_BLUETOOTH or usb device id)
-*
-* @return the value greater than 0 on success, otherwise a negative error value
-*
-*/
-int vce_get_audio_type(char** audio_type);
-
-/**
-* @brief Sets private data to Manager client.
-*
-* @param[in] key Private key
-* @param[in] data Private data
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-int vce_set_private_data(const char* key, const char* data);
-
-/**
-* @brief Gets private data from Manager client.
-*
-* @param[in] key Private key
-* @param[out] data Private data
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-int vce_get_private_data(const char* key, char** data);
-
-/**
-* @brief Request start recording.
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-int vce_start_recording();
-
-/**
-* @brief Request stop recording.
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-int vce_stop_recording();
-
 
 /**
 * @brief A structure for the VC engine functions.
@@ -604,7 +490,7 @@ typedef struct {
        vce_stop_cb                     stop;                   /**< Stop recording for getting result */
        vce_cancel_cb                   cancel;                 /**< Cancel recording and processing */
 
-       vce_set_audio_type              set_audio_type;         /**< Set audio type */
+       vce_set_audio_type_cb           set_audio_type;         /**< Set audio type */
 
        vce_set_domain_cb                       set_domain;             /**< Set domain */
        vce_process_text_cb             process_text;           /**< Request to process text */
@@ -613,30 +499,121 @@ typedef struct {
 } vce_request_callback_s;
 
 /**
-* @brief Loads the engine.
-*
+* @brief Main function for Voice Control (VC) engine.
+* @details This function is the main function for operating VC engine.
+* @since_tizen 5.0
+* @privlevel public
+* @privilege %http://tizen.org/privilege/recorder
+* @remarks The service_app_main() should be used for working the engine after this function.
 * @param[in] argc The argument count(original)
 * @param[in] argv The argument(original)
 * @param[in] callback The structure of engine request callback function
-*
-* @return This function returns zero on success, or negative with error code on failure
+* @return This function returns @c zero on success, 
+*         or negative with error code on failure
 * @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
 * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
 * @retval #VCE_ERROR_OPERATION_FAILED Operation failed
-*
 * @pre The vce_get_engine_info() should be successful.
 * @post The daemon calls engine functions of vce_funcs_s.
-*
 * @see vce_get_engine_info()
 * @see vce_unload_engine()
-*/
-int vce_main(int argc, char** argv, vce_request_callback_s *callback);
+* @see vce_request_callback_s
+* @code
+#include <vce.h>
+
+// Required callback functions - MUST BE IMPLEMENTED
+static int vce_default_initialize();
+static int vce_default_deinitialize(void);
+
+static int vce_default_get_info(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network);
+static int vce_default_get_recording_format(const char* audio_id, vce_audio_type_e* types, int* rate, int* channels);
+static int vce_default_foreach_langs(vce_supported_language_cb callback, void* user_data);
+static bool vce_default_is_lang_supported(const char* lang);
+
+static int vce_default_set_language(const char* language);
+static int vce_default_set_commands(vce_cmd_h vc_command);
+static int vce_default_unset_commands();
+
+static int vce_default_start(bool stop_by_silence);
+static int vce_default_set_recording(const void* data, unsigned int length, vce_speech_detect_e* silence_detected);
+static int vce_default_stop();
+static int vce_default_cancel(void);
+
+static int vce_default_set_audio_type(const char* audio_type);
+static int vce_default_set_domain(const char* domain);
+static int vce_default_process_text(const char* text);
+static int vce_default_process_list_event(const char* event);
+static int vce_default_process_haptic_event(const char* event);
+
+// Optional callback function
+static int vce_default_private_data_set_cb(const char* key, const char* data);
+
+int main(int argc, char* argv[])
+{
+       // 1. Create a structure 'vce_request_callback_s'
+       vce_request_callback_s callback = {0,};
+
+       callback.version = 1;
+
+       callback.initialize     = vce_default_initialize;
+       callback.deinitialize   = vce_default_deinitialize;
+
+       callback.get_info       = vce_default_get_info;
+       callback.get_recording_format   = vce_default_get_recording_format;
+       callback.foreach_langs  = vce_default_foreach_langs;
+       callback.is_lang_supported      = vce_default_is_lang_supported;
+
+       callback.set_language   = vce_default_set_language;
+       callback.set_commands   = vce_default_set_commands;
+       callback.unset_commands = vce_default_unset_commands;
+
+       callback.start          = vce_default_start;
+       callback.set_recording  = vce_default_set_recording;
+       callback.stop           = vce_default_stop;
+       callback.cancel         = vce_default_cancel;
+
+       callback.set_audio_type = vce_default_set_audio_type;
+       callback.set_domain     = vce_default_set_domain;
+       callback.process_text   = vce_default_process_text;
+       callback.process_list_event     = vce_default_process_list_event;
+       callback.process_haptic_event   = vce_default_process_haptic_event;
+
+    // 2. Run 'vce_main()'
+       if (0 != vce_main(argc, argv, &callback)) {
+               SLOG(LOG_ERROR, TAG_VCE, "[ERROR] Fail to vce main");
+               return -1;
+       }
+
+       // Optional
+       vce_set_private_data_set_cb(vce_default_private_data_set_cb);
+
+    // 3. Set event callbacks for service app and Run 'service_app_main()'
+       char ad[50] = {0,};
+       service_app_lifecycle_callback_s event_callback;
+       app_event_handler_h handlers[5] = {NULL, };
+
+       event_callback.create = service_app_create;
+       event_callback.terminate = service_app_terminate;
+       event_callback.app_control = service_app_control;
+
+       service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
+       service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
+       service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
+       service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
+
+       return service_app_main(argc, argv, &event_callback, ad);
+}
 
+* @endcode
+*/
+int vce_main(int argc, char** argv, vce_request_callback_s* callback);
 
 /**
 * @brief Sends the results to the engine service user.
 * @since_tizen 5.0
-*
 * @param[in] event A result event
 * @param[in] result_id Result ids
 * @param[in] count Result count
@@ -646,33 +623,51 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback);
 * @param[in] msg Engine message (e.g. #VC_RESULT_MESSAGE_NONE, #VC_RESULT_MESSAGE_ERROR_TOO_LOUD)
 * @param[out] user_info A user info (e.g. If ASR result is consumed, the value is 0x01. If not, the value is 0x00.)
 * @param[in] user_data The user data passed from set callback function
-*
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+* @retval #VCE_ERROR_INVALID_STATE Invalid state
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
 * @pre The vce_main() function should be invoked before this function is called.
 *              vce_stop_cb() will invoke this callback.
-*
 * @see vce_stop_cb()
 */
-int vce_send_result(vce_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, void *user_data);
+int vce_send_result(vce_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, voiduser_data);
 
 /**
 * @brief Sends the ASR result to the engine service user.
 * @since_tizen 5.0
-*
 * @param[in] event A asr result event
 * @param[in] asr_result A asr result text
 * @param[in] user_data The user data passed from the start
-*
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
 * @pre The vce_main() function should be invoked before this function is called.
+* @see vce_start_cb()
 */
-int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data);
+int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, voiduser_data);
 
 /**
-* @brief Called when the daemon gets nlg(natural language generation) result.
-*
+* @brief Sends the nlg(natural language generation) result to the engine service user.
+* @since_tizen 5.0
 * @param[in] nlg_result A nlg result
 * @param[in] user_data The user data passed from the start
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+* @pre The vce_main() function should be invoked before this function is called.
+* @see vce_start_cb()
 */
-int vce_send_nlg_result(const char* nlg_result, void *user_data);
+int vce_send_nlg_result(const char* nlg_result, voiduser_data);
 
 /**
 * @brief Sends the error to the engine service user.
@@ -682,28 +677,41 @@ int vce_send_nlg_result(const char* nlg_result, void *user_data);
 *              #VCE_ERROR_IO_ERROR,
 *              #VCE_ERROR_INVALID_PARAMETER,
 *              #VCE_ERROR_OUT_OF_NETWORK,
+*       #VCE_ERROR_RECORDER_BUSY,
 *              #VCE_ERROR_INVALID_STATE,
 *              #VCE_ERROR_INVALID_LANGUAGE,
 *              #VCE_ERROR_OPERATION_FAILED,
+*              #VCE_ERROR_PERMISSION_DENIED,
 *              #VCE_ERROR_NOT_SUPPORTED_FEATURE.
 * @since_tizen 5.0
-*
 * @param[in] error Error type
 * @param[in] msg Error message
 * @param[in] user_data The user data passed from set callback function
-*
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
 * @pre The vce_main() function should be invoked before this function is called.
 */
-int vce_send_error(vce_error_e error, const char* msg, void *user_data);
+int vce_send_error(vce_error_e error, const char* msg, voiduser_data);
 
 /**
 * @brief Sets a callback function for setting the private data to the engine service.
 * @since_tizen 5.0
+* @privlevel public
+* @privilege %http://tizen.org/privilege/recorder
 * @remarks The vce_private_data_set_cb() function is called when the engine service user sets the private data to the engine service.
-*
 * @param[in] callback_func vce_private_data_set event callback function
-* @return
-*
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+* @pre The vce_main() function should be invoked before this function is called.
 * @see vce_private_data_set_cb()
 */
 int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func);
@@ -711,11 +719,17 @@ int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func);
 /**
 * @brief Sets a callback function for requesting the private data to the engine service.
 * @since_tizen 5.0
+* @privlevel public
+* @privilege %http://tizen.org/privilege/recorder
 * @remarks The vce_private_data_requested_cb() function is called when the engine service user requests the private data to the engine service.
-*
 * @param[in] callback_func vce_private_data_requested event callback function
-* @return
-*
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
 * @see vce_private_data_requested_cb()
 */
 int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_func);
@@ -724,14 +738,115 @@ int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_fun
 * @brief Sets a callback function for requesting the NLU base information to the engine service.
 * @since_tizen 5.0
 * @remarks The vce_nlu_base_info_requested_cb() function is called when the engine service user requests the NLU base information to the engine service.
-*
 * @param[in] callback_func vce_nlu_base_info_requested event callback function
-* @return
-*
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
 * @see vce_nlu_base_info_requested_cb()
 */
 int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func);
 
+/**
+* @brief Retrieves all commands using callback function.
+* @since_tizen 5.0
+* @param[in] vce_command The handle to be passed to the vce_set_commands() function
+* @param[in] callback The callback function to invoke
+* @param[in] user_data The user data to be passed to the callback function
+* @return 0 on success, otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+* @retval #VCE_ERROR_INVALID_STATE Invalid state
+* @post        This function invokes vce_command_cb() repeatedly for getting commands.
+* @see vce_foreach_command_cb()
+* @see vce_set_commands()
+*/
+int vce_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data);
+
+/**
+* @brief Gets command length.
+* @since_tizen 5.0
+* @param[in] vce_command The handle to be passed to the vce_set_commands() function
+* @return the value greater than 0 on success
+* @see vce_set_commands()
+*/
+int vce_get_command_count(vce_cmd_h vce_command);
+
+/**
+* @brief Gets current audio type.
+* @since_tizen 5.0
+* @remarks audio_type must be released using free() when it is no longer required.
+* @param[in] audio_type Current audio type (e.g. #VCE_AUDIO_ID_BLUETOOTH or VCE_AUDIO_ID_WIFI)
+* @return the value greater than 0 on success, otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int vce_get_audio_type(char** audio_type);
+
+/**
+* @brief Sets private data to Manager client.
+* @since_tizen 5.0
+* @privlevel public
+* @privilege %http://tizen.org/privilege/recorder
+* @param[in] key Private key
+* @param[in] data Private data
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_INVALID_STATE Invalid state
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failed
+*/
+int vce_set_private_data(const char* key, const char* data);
+
+/**
+* @brief Gets private data from Manager client.
+* @since_tizen 5.0
+* @privlevel public
+* @privilege %http://tizen.org/privilege/recorder
+* @param[in] key Private key
+* @param[out] data Private data
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_INVALID_STATE Invalid state
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failed
+*/
+int vce_get_private_data(const char* key, char** data);
+
+/**
+* @brief Request start recording.
+* @since_tizen 5.0
+* @privlevel public
+* @privilege %http://tizen.org/privilege/recorder
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+* @retval #VCE_ERROR_RECORDER_BUSY Busy recorder
+*/
+int vce_start_recording(void);
+
+/**
+* @brief Request stop recording.
+* @since_tizen 5.0
+* @privlevel public
+* @privilege %http://tizen.org/privilege/recorder
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+*/
+int vce_stop_recording(void);
 
 #ifdef __cplusplus
 }
index a60006a..fec9af1 100755 (executable)
@@ -875,7 +875,7 @@ int vcdc_send_request_get_private_data(int pid, const char* key, char** data)
                        if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) {
                                SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Unknown service. Client is not available");
                                dbus_error_free(&err);
-                               return 0;
+                               return VCD_ERROR_NONE;
                        }
                }
                dbus_error_free(&err);
index 4b562b3..cd861bc 100644 (file)
@@ -105,6 +105,10 @@ int vcd_engine_agent_init()
                SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] There is No default voice in config");
                /* Set default voice */
                g_default_lang = strdup(VC_BASE_LANGUAGE);
+               if (NULL == g_default_lang) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Fail to allocate memory");
+                       return VCD_ERROR_OUT_OF_MEMORY;
+               }
        }
 
        SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent Initialize");
index a4e5705..9393804 100644 (file)
@@ -96,7 +96,7 @@ typedef struct {
        vce_stop_cb                     stop;                   /**< Stop recording for getting result */
        vce_cancel_cb                   cancel;                 /**< Cancel recording and processing */
 
-       vce_set_audio_type              set_audio_type;         /**< Set audio type */
+       vce_set_audio_type_cb           set_audio_type;         /**< Set audio type */
 
        vce_set_domain_cb                       set_domain;             /**< Set domain */
        vce_process_text_cb             process_text;           /**< Request to process text */
index 688e21d..a525662 100755 (executable)
@@ -425,12 +425,21 @@ static Eina_Bool __vcd_send_selected_result(void *data)
 
 int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
 {
+       int ret = __vcd_server_launch_manager_app();
+       if (0 != ret) {
+               SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+               return ret;
+       }
+
        if (NULL != asr_result) {
                SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
-               vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+               ret = vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+               if (0 != ret) {
+                       SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+               }
        }
 
-       return VCD_ERROR_NONE;
+       return ret;
 }
 
 int vcd_send_nlg_result(const char* nlg_result, void *user_data)
@@ -918,9 +927,14 @@ int vcd_send_error(vce_error_e error, const char* msg, void *user_data)
        char* error_msg = NULL;
        if (NULL != msg) {
                error_msg = strdup(msg);
+               if (NULL == error_msg) {
+                       return VCD_ERROR_OUT_OF_MEMORY;
+               }
        }
 
-       if (0 != vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg)) {
+       int ret = VCD_ERROR_NONE;
+       ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg);
+       if (VCD_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send error signal");
        }
 
@@ -929,7 +943,7 @@ int vcd_send_error(vce_error_e error, const char* msg, void *user_data)
                error_msg = NULL;
        }
 
-       return VCD_ERROR_NONE;
+       return ret;
 }
 
 /*