INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_common.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_key_defines.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_manager.h DESTINATION ${INCLUDEDIR})
-INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_plugin_engine.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_setting.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ${CMAKE_BINARY_DIR}/include/voice_control_widget.h DESTINATION ${INCLUDEDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/include/vce.h DESTINATION ${INCLUDEDIR})
--- /dev/null
+/*
+* Copyright (c) 2011-2017 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 __VCE_H__
+#define __VCE_H__
+
+#include <tizen.h>
+
+/**
+* @addtogroup CAPI_UIX_VCE_MODULE
+* @{
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @brief Enumerations of error codes.
+* @since_tizen 5.0
+*/
+typedef enum {
+ VCE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ VCE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
+ 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_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_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_VOICE_CONTROL | 0x022 /**< Not supported feature of current engine */
+} vce_error_e;
+
+/**
+* @brief Enumerations of audio type.
+* @since_tizen 5.0
+*/
+typedef enum {
+ VCE_AUDIO_TYPE_PCM_S16_LE = 0, /**< Signed 16bit audio type, Little endian */
+ VCE_AUDIO_TYPE_PCM_U8 /**< Unsigned 8bit audio type */
+} vce_audio_type_e;
+
+/**
+* @brief Enumerations of callback event.
+* @since_tizen 5.0
+*/
+typedef enum {
+ VCE_RESULT_EVENT_SUCCESS = 0, /**< Event when the recognition full result is ready */
+ VCE_RESULT_EVENT_REJECTED, /**< Event when the recognition result is rejected */
+ VCE_RESULT_EVENT_ERROR /**< Event when the recognition has failed */
+} vce_result_event_e;
+
+/**
+* @brief Enumerations of command type.
+* @since_tizen 5.0
+*/
+typedef enum {
+ VCE_COMMAND_FORMAT_FIXED = 0, /**< Fixed command */
+ VCE_COMMAND_FORMAT_FIXED_AND_VFIXED, /**< Fixed command + variable-fixed command */
+ 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_e;
+
+/**
+* @brief Definition for foreground command type.
+* @since_tizen 5.0
+*/
+#define VCE_COMMAND_TYPE_FOREGROUND 1
+
+/**
+* @brief Definition for background command type.
+* @since_tizen 5.0
+*/
+#define VCE_COMMAND_TYPE_BACKGROUND 2
+
+/**
+* @brief Definition for widget command type.
+* @since_tizen 5.0
+*/
+#define VCE_COMMAND_TYPE_WIDGET 3
+
+/**
+* @brief Definition for system command type.
+* @since_tizen 5.0
+*/
+#define VCE_COMMAND_TYPE_SYSTEM 4
+
+/**
+* @brief Definition for system background command type.
+* @since_tizen 5.0
+*/
+#define VCE_COMMAND_TYPE_SYSTEM_BACKGROUND 5
+
+/**
+* @brief Definitions for exclusive command type.
+* @since_tizen 5.0
+*/
+#define VCE_COMMAND_TYPE_EXCLUSIVE 6
+
+
+/**
+* @brief Enumerations of speech detect.
+* @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;
+
+/**
+* @brief Enumerations of ASR result events
+* @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;
+
+/**
+* @brief A structure of handle for VC command
+* @since_tizen 5.0
+*/
+typedef int vce_cmd_h;
+
+/**
+* @brief Definition of bluetooth audio id.
+* @since_tizen 5.0
+*/
+#define VCE_AUDIO_ID_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio id */
+
+/**
+* @brief Definition of Wi-Fi audio id.
+* @since_tizen 5.0
+*/
+#define VCE_AUDIO_ID_WIFI "VC_AUDIO_ID_WIFI" /**< Wi-Fi audio id */
+
+/**
+* @brief Definition for none message.
+*/
+#define VC_RESULT_MESSAGE_NONE "vc.result.message.none"
+
+/**
+* @brief Definition for failed recognition because the speech is too loud to listen.
+*/
+#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);
+
+/**
+* @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
+* @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.
+* @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);
+
+/**
+* @brief Called when the engine service user retrieves all supported languages of VC engine.
+*
+* @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()
+*/
+typedef int (*vce_foreach_supported_languages_cb)(vce_supported_language_cb callback, void* user_data);
+
+/**
+* @brief Called when the engine service user checks whether a language is supported or not.
+*
+* @param[in] 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.
+*
+* @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
+* @retval #VCE_ERROR_INVALID_STATE Not initialized
+*/
+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.
+*
+* @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()
+*/
+typedef int (*vce_set_commands_cb)(vce_cmd_h vc_command);
+
+/**
+* @brief Called when the engine service user unsets command list for reset.
+*
+* @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()
+*/
+typedef int (*vce_unset_commands_cb)();
+
+/**
+* @brief Called when the engine service user starts recognition.
+*
+* @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_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_stop()
+* @see vce_cancel()
+*/
+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
+*
+* @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()
+*/
+typedef int(*vce_set_recording_data_cb)(const void* data, unsigned int length, vce_speech_detect_e* speech_detected);
+
+/**
+* @brief Called when the engine service user stops to get the result of recognition.
+*
+* @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()
+* @see vce_cancel()
+*/
+typedef int (*vce_stop_cb)(void);
+
+/**
+* @brief Called when the engine service user cancels the recognition process.
+*
+* @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.
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful.
+*
+*/
+typedef int (*vce_set_audio_type)(const char* audio);
+
+
+/**
+* @brief Called when the engine service user sets domain (Agent or device type)
+*
+* @param[in] domain Available agent or device type
+*
+* @return 0 on success, otherwise a negative error value.
+*
+*/
+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
+*
+* @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.
+*
+* @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.
+*
+* @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.
+*
+* @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.
+*
+* @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.
+*
+* @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
+*
+* @param[in] engine_uuid The engine id
+* @param[in] engine_name The engine name
+*/
+typedef int (*vce_get_info_cb)(char** engine_uuid, char** engine_name);
+
+
+/**
+* Daemon API.
+*/
+
+/**
+* @brief Called to retrieve the commands.
+*
+* @param[in] id command id
+* @param[in] type command type
+* @param[in] format command format
+* @param[in] command command text
+* @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.
+* @details This structure contains essential callback functions for operating VC engine.
+* @since_tizen 5.0
+* @remarks These functions ar mandatory for operating VC engine. Therefore, all functions MUST be implemented.
+*/
+typedef struct {
+ int version; /**< Version */
+
+ /* Get engine information */
+ vce_get_info_cb get_info; /**< Called when the engine service user requests the basic information of VC engine */
+ vce_get_recording_format_cb get_recording_format; /**< Get recording format */
+ vce_foreach_supported_languages_cb foreach_langs; /**< Foreach language list */
+ vce_is_language_supported_cb is_lang_supported; /**< Check language */
+
+ vce_initialize_cb initialize; /**< Initialize engine */
+ vce_deinitialize_cb deinitialize; /**< Shutdown engine */
+
+ /* Set info */
+ vce_set_language_cb set_language; /**< Set language */
+ vce_set_commands_cb set_commands; /**< Request to set current commands */
+ vce_unset_commands_cb unset_commands; /**< Request to unset current commands */
+
+ /* Control recognition */
+ vce_start_cb start; /**< Start recognition */
+ vce_set_recording_data_cb set_recording; /**< Set recording data */
+ 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_domain_cb set_domain; /**< Set domain */
+ vce_process_text_cb process_text; /**< Request to process text */
+ vce_process_list_event_cb process_list_event; /**< Request to process list event */
+ vce_process_haptic_event_cb process_haptic_event; /**< Request to process haptic event */
+} vce_request_callback_s;
+
+/**
+* @brief Loads the engine.
+*
+* @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
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @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);
+
+
+/**
+* @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
+* @param[in] all_result All result text
+* @param[in] non_fixed_result Non-fixed command result text
+* @param[in] nlu_result NLU result text
+* @param[in] msg Engine message (e.g. #VC_RESULT_MESSAGE_NONE, #VC_RESULT_MESSAGE_ERROR_TOO_LOUD)
+* @param[in] user_data The user data passed from set callback function
+*
+* @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, void *user_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
+*
+* @pre The vce_main() function should be invoked before this function is called.
+*/
+int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data);
+
+/**
+* @brief Called when the daemon gets nlg(natural language generation) result.
+*
+* @param[in] nlg_result A nlg result
+* @param[in] user_data The user data passed from the start
+*/
+int vce_send_nlg_result(const char* nlg_result, void *user_data);
+
+/**
+* @brief Sends the error to the engine service user.
+* @details The following error codes can be delivered.
+* #VCE_ERROR_NONE,
+* #VCE_ERROR_OUT_OF_MEMORY,
+* #VCE_ERROR_IO_ERROR,
+* #VCE_ERROR_INVALID_PARAMETER,
+* #VCE_ERROR_OUT_OF_NETWORK,
+* #VCE_ERROR_INVALID_STATE,
+* #VCE_ERROR_INVALID_LANGUAGE,
+* #VCE_ERROR_OPERATION_FAILED,
+* #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
+*
+* @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);
+
+/**
+* @brief Sets a callback function for setting the private data to the engine service.
+* @since_tizen 5.0
+* @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
+*
+* @see vce_private_data_set_cb()
+*/
+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
+* @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
+*
+* @see vce_private_data_requested_cb()
+*/
+int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_func);
+
+/**
+* @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
+*
+* @see vce_nlu_base_info_requested_cb()
+*/
+int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+* @}@}
+*/
+
+#endif /* __VCE_H__ */
+
+
Description: Voice control engine header
Requires: glib-2.0 dbus-1 capi-base-common
Version: @VERSION@
+Libs: -L${libdir} -l@PROJECT_NAME@_engine
Cflags: -I${includedir}
VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */
VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In progress to ready (Since 3.0) */
VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In progress to recording (Since 3.0) */
- VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In progress to processing (Since 3.0) */
+ VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021, /**< In progress to processing (Since 3.0) */
+ VC_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_VOICE_CONTROL | 0x022 /**< Not supported feature of current engine (Since 4.0) */
} vc_error_e;
/**
- * @brief Definition of audio-in type.
+ * @brief Definition of bluetooth audio-in type.
*/
#define VC_AUDIO_TYPE_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio type */
/**
- * @brief Definition of audio-in type.
+ * @brief Definition of Wi-Fi audio-in type.
*/
-#define VC_AUDIO_TYPE_MSF "VC_AUDIO_ID_MSF" /**< MSF (wifi) audio type */
+#define VC_AUDIO_TYPE_WIFI "VC_AUDIO_ID_WIFI" /**< Wi-Fi audio type */
/**
* @brief Definition for foreground command type.
+++ /dev/null
-/*
-* Copyright (c) 2011-2015 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 __VOICE_CONTROL_PLUGIN_ENGINE_H__
-#define __VOICE_CONTROL_PLUGIN_ENGINE_H__
-
-#include <tizen.h>
-
-/**
-* @addtogroup VOICE_CONTROL_PLUGIN_ENGINE
-* @{
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-* @brief Enumerations of error codes.
-*/
-typedef enum {
- VCP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- VCP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
- VCP_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
- VCP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
- VCP_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Out of network */
- VCP_ERROR_INVALID_STATE = -0x0100031, /**< Invalid state */
- VCP_ERROR_INVALID_LANGUAGE = -0x0100032, /**< Invalid language */
- VCP_ERROR_OPERATION_FAILED = -0x0100034, /**< Operation failed */
- VCP_ERROR_NOT_SUPPORTED_FEATURE = -0x0100035 /**< Not supported feature */
-} vcp_error_e;
-
-/**
-* @brief Enumerations of audio type.
-*/
-typedef enum {
- VCP_AUDIO_TYPE_PCM_S16_LE = 0, /**< Signed 16bit audio type, Little endian */
- VCP_AUDIO_TYPE_PCM_U8 /**< Unsigned 8bit audio type */
-} vcp_audio_type_e;
-
-/**
-* @brief Enumerations of callback event.
-*/
-typedef enum {
- VCP_RESULT_EVENT_SUCCESS = 0, /**< Event when the recognition full result is ready */
- VCP_RESULT_EVENT_REJECTED, /**< Event when the recognition result is rejected */
- VCP_RESULT_EVENT_ERROR /**< Event when the recognition has failed */
-} vcp_result_event_e;
-
-/**
-* @brief Enumerations of command type.
-*/
-typedef enum {
- VCP_COMMAND_FORMAT_FIXED = 0, /**< Fixed command */
- VCP_COMMAND_FORMAT_FIXED_AND_VFIXED, /**< Fixed command + variable-fixed command */
- VCP_COMMAND_FORMAT_VFIXED_AND_FIXED, /**< variable-fixed command + Fixed command */
- VCP_COMMAND_FORMAT_FIXED_AND_NONFIXED, /**< Fixed command + Non-fixed command */
- VCP_COMMAND_FORMAT_NONFIXED_AND_FIXED, /**< Non-fixed command + Fixed command */
- VCP_COMMAND_FORMAT_ACTION,
- VCP_COMMAND_FORMAT_PARTIAL
-} vcp_command_format_e;
-
-/**
-* @brief Definition for foreground command type.
-* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
-*/
-#define VCP_COMMAND_TYPE_FOREGROUND 1
-
-/**
-* @brief Definition for background command type.
-* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
-*/
-#define VCP_COMMAND_TYPE_BACKGROUND 2
-
-/**
-* @brief Definition for widget command type.
-* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
-*/
-#define VCP_COMMAND_TYPE_WIDGET 3
-
-/**
-* @brief Definition for system command type.
-* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
-*/
-#define VCP_COMMAND_TYPE_SYSTEM 4
-
-/**
-* @brief Definition for exclusive command type.
-* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
-*/
-#define VCP_COMMAND_TYPE_SYSTEM_BACKGROUND 5
-
-/**
-* @brief Definitions for exclusive command type.
-* @since_tizen 2.4
-*/
-#define VCP_COMMAND_TYPE_EXCLUSIVE 6
-
-
-/**
-* @brief Enumerations of speech detect.
-*/
-typedef enum {
- VCP_SPEECH_DETECT_NONE = 0, /**< No event */
- VCP_SPEECH_DETECT_BEGIN, /**< Begin of speech detected */
- VCP_SPEECH_DETECT_END, /**< End of speech detected */
-} vcp_speech_detect_e;
-
-typedef enum {
- VCP_ASR_RESULT_EVENT_FINAL_RESULT = 0,
- VCP_ASR_RESULT_EVENT_PARTIAL_RESULT,
- VCP_ASR_RESULT_EVENT_ERROR
-} vcp_asr_result_event_e;
-
-/**
-* @brief A structure of handle for VC command
-*/
-typedef int vcp_cmd_h;
-
-/**
- * @brief Definition of bluetooth audio id.
-*/
-#define VCP_AUDIO_ID_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio id */
-
-/**
- * @brief Definition of MSF(wifi) audio id.
-*/
-#define VCP_AUDIO_ID_MSF "VC_AUDIO_ID_MSF" /**< MSF (wifi) audio id */
-
-/**
-* @brief Definition for none message.
-*/
-#define VC_RESULT_MESSAGE_NONE "vc.result.message.none"
-
-/**
-* @brief Definition for failed recognition because the speech is too loud to listen.
-*/
-#define VC_RESULT_MESSAGE_ERROR_TOO_LOUD "vc.result.message.error.too.loud"
-
-
-/**
-* @brief Called when the daemon gets synthesized result.
-*
-* @param[in] event A result event
-* @param[in] result_id Result ids
-* @param[in] count Result count
-* @param[in] all_result All result text
-* @param[in] non_fixed_result Non-fixed command result text
-* @param[in] nlu_result NLU result text
-* @param[in] msg Engine message (e.g. #VC_RESULT_MESSAGE_NONE, #VC_RESULT_MESSAGE_ERROR_TOO_LOUD)
-* @param[in] user_data The user data passed from set callback function
-*
-* @pre vcpe_stop() will invoke this callback.
-*
-* @see vcpe_stop()
-*/
-typedef void (*vcpe_result_cb)(vcp_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, void *user_data);
-
-
-/**
-* @brief Called when the daemon gets ASR result.
-*
-* @param[in] event A asr result event
-* @param[in] pre_result result text
-* @param[in] user_data The user data passed from the start
-*/
-typedef void (*vcpe_asr_result_cb)(vcp_asr_result_event_e event, const char* asr_result, void *user_data);
-
-/**
-* @brief Called when the daemon gets nlg result.
-*
-* @param[in] nlg_result Nlg result
-* @param[in] user_data The user data passed from the start
-*/
-typedef void (*vcpe_nlg_result_cb)(const char* nlg_result, void *user_data);
-
-/**
-* @brief Called when the daemon gets error.
-*
-* @param[in] error Error type
-* @param[in] msg Error message
-* @param[in] user_data The user data passed from set callback function
-*
-*/
-typedef void (*vcpe_error_cb)(vcp_error_e error, const char* msg, void *user_data);
-
-/**
-* @brief Called to retrieve the supported languages.
-*
-* @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 vcpe_foreach_supported_languages() will invoke this callback.
-*
-* @see vcpe_foreach_supported_languages()
-*/
-typedef bool (*vcpe_supported_language_cb)(const char* language, void* user_data);
-
-/**
-* @brief Initializes the engine.
-*
-* @param[in] result_cb A callback function for recognition result
-* @param[in] silence_cb A callback function for silence detection
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_INVALID_STATE Already initialized
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-*
-* @see vcpe_deinitialize()
-*/
-typedef int (*vcpe_initialize)(void);
-
-/**
-* @brief Deinitializes the engine
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_STATE Not initialized
-*
-* @see vcpe_initialize()
-*/
-typedef void (*vcpe_deinitialize)(void);
-
-/**
-* @brief Registers a callback function for getting recognition result.
-*
-* @param[in] callback Callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-*
-* @see vcpe_result_cb()
-*/
-typedef int (*vcpe_set_result_cb)(vcpe_result_cb callback, void* user_data);
-
-/**
-* @brief Registers a callback function for getting ASR recognition result.
-*
-* @param[in] callback Callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-*
-* @see vcpe_asr_result_cb()
-*/
-typedef int (*vcpe_set_asr_result_cb)(vcpe_asr_result_cb callback, void* user_data);
-
-/**
-* @brief Registers a callback function for getting nlg result.
-*
-* @param[in] callback Callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-*
-*/
-typedef int (*vcpe_set_nlg_result_cb)(vcpe_nlg_result_cb, void* user_data);
-
-#if 0
-/**
-* @brief Registers a callback function for getting partial recognition result.
-*
-* @param[in] callback Callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-*
-* @see vcpe_pre_result_cb()
-*/
-typedef int (*vcpe_set_pre_result_cb)(vcpe_pre_result_cb callback, void* user_data);
-#endif
-
-/**
-* @brief Registers a callback function for error.
-*
-* @param[in] callback Callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-*
-*/
-typedef int (*vcpe_set_error_cb)(vcpe_error_cb callback, void* user_data);
-
-#if 0
-/**
-* @brief Registers a callback function for getting NLU result.
-*
-* @param[in] callback Callback function to register
-* @param[in] user_data The user data to be passed to the callback function
-*
-* @return 0 on success, otherwise a negative error value
-*
-*/
-typedef int (*vcpe_set_nlu_result_cb)(vcpe_nlu_result_cb, void* user_data);
-#endif
-
-/**
-* @brief Gets recording format of the engine.
-*
-* @param[in] audio_id The audio device id.
-* @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 #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Not initialized
-*/
-typedef int (*vcpe_get_recording_format)(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels);
-
-/**
-* @brief Retrieves all supported languages of the engine.
-*
-* @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 #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_INVALID_STATE Not initialized
-*
-* @post This function invokes vcpe_supported_language_cb() repeatedly for getting supported languages.
-*
-* @see vcpe_supported_language_cb()
-*/
-typedef int (*vcpe_foreach_supported_languages)(vcpe_supported_language_cb callback, void* user_data);
-
-/**
-* @brief Checks whether a language is supported or not.
-*
-* @param[in] language A language
-*
-* @return @c true = supported, \n @c false = not supported.
-*/
-typedef bool (*vcpe_is_language_supported)(const char* language);
-
-/**
-* @brief Sets language.
-*
-* @param[in] language language.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_LANGUAGE Invalid language
-* @retval #VCP_ERROR_INVALID_STATE Not initialized
-*/
-typedef int (*vcpe_set_language)(const char* language);
-
-/**
-* @brief Sets command list before recognition.
-*
-* @remark This function should set commands via vcpd_foreach_command().
-*
-* @param[in] vcp_command command handle.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_INVALID_STATE Invalid state
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-* @retval #VCP_ERROR_NOT_SUPPORTED_FEATURE Not supported command type
-*
-* @post vcpe_start() is called after this function is successful.
-*
-* @see vcpe_start()
-* @see vcpd_foreach_command()
-* @see vcpe_unset_commands()
-*/
-typedef int (*vcpe_set_commands)(vcp_cmd_h vcp_command);
-
-/**
-* @brief Unset command list for reset.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_INVALID_STATE Invalid state
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-*
-* @see vcpe_set_commands()
-*/
-typedef int (*vcpe_unset_commands)();
-
-/**
-* @brief Start recognition.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_INVALID_STATE Invalid state
-* @retval #VCP_ERROR_INVALID_LANGUAGE Invalid language
-* @retval #VCP_ERROR_OUT_OF_NETWORK Out of network
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-*
-* @pre vcpd_foreach_command() is successful.
-*
-* @see vcpe_set_recording_data()
-* @see vcpe_stop()
-* @see vcpe_cancel()
-*/
-typedef int (*vcpe_start)(bool stop_by_silence);
-
-/**
-* @brief 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
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_INVALID_STATE Invalid state
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-*
-* @pre vcpe_start() is successful.
-*
-* @see vcpe_start()
-* @see vcpe_cancel()
-* @see vcpe_stop()
-*/
-typedef int(*vcpe_set_recording_data)(const void* data, unsigned int length, vcp_speech_detect_e* speech_detected);
-
-/**
-* @brief Stops to get the result of recognition.
-*
-* @return 0 on success, otherwise a negative error value
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_STATE Invalid state
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-* @retval #VCP_ERROR_OUT_OF_NETWORK Out of network
-*
-* @pre vcpe_set_recording_data() is successful.
-*
-* @see vcpe_start()
-* @see vcpe_set_recording_data()
-* @see vcpe_result_cb()
-* @see vcpe_cancel()
-*/
-typedef int (*vcpe_stop)(void);
-
-/**
-* @brief Cancels the recognition process.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #VCP_ERROR_NONE Successful.
-* @retval #VCP_ERROR_INVALID_STATE Invalid state.
-*
-* @pre vcpe_start() is successful.
-*
-* @see vcpe_start()
-* @see vcpe_stop()
-*/
-typedef int (*vcpe_cancel)(void);
-
-/**
-* @brief Set audio recording type.
-*
-* @return 0 on success, otherwise a negative error value.
-* @retval #VCP_ERROR_NONE Successful.
-*
-*/
-typedef int (*vcpe_set_audio_type)(const char* audio);
-
-/**
-* @brief Sets domain (Agent or device type)
-*
-* @param[in] domain available Agent or device type
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpe_set_domain)(const char* domain);
-
-/**
-* @brief Gets essential value from nlu result. This function is available inside vcpe_nlu_result_cb()
-*
-* @param[in] key NLU base info key
-* @parma[out] value NLU base info value
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpe_get_nlu_base_info)(const char* key, char** value);
-
-/**
-* @brief Sets private data between app and engine.
-*
-* @param[in] key Private key
-* @param[in] data Private data
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpe_set_private_data)(const char* key, const char* data);
-
-/**
-* @brief Gets private data between app and engine.
-*
-* @param[in] key Private key
-* @param[out] data Private data
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpe_get_private_data)(const char* key, char** data);
-
-/**
-* @brief Request process text.
-*
-* @param[in] text Requested text
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpe_process_text)(const char* text);
-
-/**
-* @brief Request list event.
-*
-* @param[in] event Requested list event
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpe_process_list_event)(const char* event);
-
-/**
-* @brief Request haptic event.
-*
-* @param[in] event Requested haptic event
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpe_process_haptic_event)(const char* event);
-
-/**
-* Daemon API.
-*/
-
-/**
-* @brief Called to retrieve the commands.
-*
-* @param[in] id command id
-* @param[in] type command type
-* @param[in] format command format
-* @param[in] command command text
-* @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 vcpd_foreach_command() will invoke this callback.
-*
-* @see vcpd_foreach_command()
-*/
-typedef bool (*vcpd_foreach_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] vcp_command The handle to be passed to the vcpe_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 #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failure
-* @retval #VCP_ERROR_INVALID_STATE Invalid state
-*
-* @post This function invokes vcpd_foreach_command_cb() repeatedly for getting commands.
-*
-* @see vcpd_foreach_command_cb()
-* @see vcpe_set_commands()
-*/
-typedef int (*vcpd_foreach_command)(vcp_cmd_h vcp_command, vcpd_foreach_command_cb callback, void* user_data);
-
-/**
-* @brief Gets command length.
-*
-* @param[in] vcp_command The handle to be passed to the vcpe_set_commands() function
-*
-* @return the value greater than 0 on success, otherwise a negative error value
-*
-* @see vcpe_set_commands()
-*/
-typedef int (*vcpd_get_command_count)(vcp_cmd_h vcp_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. #VCP_AUDIO_ID_BLUETOOTH or usb device id)
-*
-* @return the value greater than 0 on success, otherwise a negative error value
-*
-*/
-typedef int (*vcpd_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.
-*
-*/
-typedef int (*vcpd_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.
-*
-*/
-typedef int (*vcpd_get_private_data)(const char* key, char** data);
-
-/**
-* @brief Request start recording.
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpd_start_recording)();
-
-/**
-* @brief Request stop recording.
-*
-* @return 0 on success, otherwise a negative error value.
-*
-*/
-typedef int (*vcpd_stop_recording)();
-
-/**
-* @brief A structure of the engine functions.
-*/
-typedef struct {
- int size; /**< Size of structure */
- int version; /**< Version */
-
- vcpe_initialize initialize; /**< Initialize engine */
- vcpe_deinitialize deinitialize; /**< Shutdown engine */
-
- /* Get engine information */
- vcpe_get_recording_format get_recording_format; /**< Get recording format */
- vcpe_foreach_supported_languages foreach_langs; /**< Foreach language list */
- vcpe_is_language_supported is_lang_supported; /**< Check language */
-
- /* Set info */
- vcpe_set_result_cb set_result_cb; /**< Set result callback */
- vcpe_set_language set_language; /**< Set language */
- vcpe_set_commands set_commands; /**< Request to set current commands */
- vcpe_unset_commands unset_commands; /**< Request to unset current commands */
-
- /* Control recognition */
- vcpe_start start; /**< Start recognition */
- vcpe_set_recording_data set_recording; /**< Set recording data */
- vcpe_stop stop; /**< Stop recording for getting result */
- vcpe_cancel cancel; /**< Cancel recording and processing */
-
- vcpe_set_audio_type set_audio_type; /**< Set audio type */
-
- //vcpe_set_pre_result_cb set_pre_result_cb; /**< Set pre result callback */
- vcpe_set_asr_result_cb set_asr_result_cb; /**< Set asr result callback */
- vcpe_set_nlg_result_cb set_nlg_result_cb; /**< Set nlg result callback */
- vcpe_set_error_cb set_error_cb; /**< Set error callback */
- vcpe_set_domain set_domain; /**< Set domain */
- vcpe_get_nlu_base_info get_nlu_base_info; /**< Get essential info */
- //vcpe_set_nlu_result_cb set_nlu_result_cb; /**< Set nlu result callback */
- vcpe_set_private_data set_private_data; /**< Set private data */
- vcpe_get_private_data get_private_data; /**< Get private data */
- vcpe_process_text process_text; /**< Request to process text */
- vcpe_process_list_event process_list_event; /**< Request to process list event */
- vcpe_process_haptic_event process_haptic_event; /**< Request to process haptic event */
-} vcpe_funcs_s;
-
-/**
-* @brief A structure of the daemon functions.
-*/
-typedef struct {
- int size; /**< Size of structure */
- int version; /**< Version */
-
- vcpd_foreach_command foreach_command; /**< Foreach command */
- vcpd_get_command_count get_command_count; /**< Get command count */
-
- vcpd_get_audio_type get_audio_type; /**< Get audio type */
-
- vcpd_set_private_data set_private_data; /**< Set private data to Manager */
- vcpd_get_private_data get_private_data; /**< Get private data from Manager */
-
- vcpd_start_recording start_recording; /**< Request start recording */
- vcpd_stop_recording stop_recording; /**< Request stop recording */
-} vcpd_funcs_s;
-
-/**
-* @brief Loads the engine.
-*
-* @param[in] pdfuncs The daemon functions
-* @param[out] pefuncs The engine functions
-*
-* @return This function returns zero on success, or negative with error code on failure
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-*
-* @pre The vcp_get_engine_info() should be successful.
-* @post The daemon calls engine functions of vcpe_funcs_s.
-*
-* @see vcp_get_engine_info()
-* @see vcp_unload_engine()
-*/
-int vcp_load_engine(vcpd_funcs_s* pdfuncs, vcpe_funcs_s* pefuncs);
-
-/**
-* @brief Unloads this engine by the daemon.
-*
-* @pre The vcp_load_engine() should be successful.
-*
-* @see vcp_load_engine()
-*/
-void vcp_unload_engine(void);
-
-/**
-* @brief Called to get the engine base information.
-*
-* @param[in] engine_uuid The engine id
-* @param[in] engine_name The engine name
-* @param[in] engine_setting The setting ug name
-* @param[in] use_network @c true to need network @c false not to need network.
-* @param[in] user_data The User data passed from vcp_get_engine_info()
-*
-* @pre vcp_get_engine_info() will invoke this callback.
-*
-* @see vcp_get_engine_info()
-*/
-typedef void (*vcpe_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* engine_setting,
- bool use_network, void* user_data);
-
-/**
-* @brief Gets the engine base information before the engine is loaded by the daemon.
-*
-* @param[in] callback Callback function
-* @param[in] user_data User data to be passed to the callback function
-*
-* @return This function returns zero on success, or negative with error code on failure
-* @retval #VCP_ERROR_NONE Successful
-* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #VCP_ERROR_OPERATION_FAILED Operation failed
-*
-* @post This function invokes vcpe_engine_info_cb() for getting engine information.
-*
-* @see vcpe_engine_info_cb()
-* @see vcp_load_engine()
-*/
-int vcp_get_engine_info(vcpe_engine_info_cb callback, void* user_data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/**
-* @}@}
-*/
-
-#endif /* __VOICE_CONTROL_PLUGIN_ENGINE_H__ */
[D-BUS Service]
Name=org.tizen.voice.vcserver
-Exec=/usr/bin/vc-daemon
+#Exec=/usr/bin/vc-daemon
+Exec=/bin/sh -c "launch_app org.tizen.vc-engine-default"
%{_libdir}/libvc_setting.so
%{_libdir}/libvc_widget.so
%{_libdir}/libvc_manager.so
-%{_bindir}/vc-daemon
+%{_libdir}/libvc_engine.so
%{TZ_SYS_RO_SHARE}/voice/vc/1.0/vc-config.xml
%{TZ_SYS_RO_SHARE}/dbus-1/services/org.tizen.voice*
/etc/dbus-1/session.d/vc-server.conf
%files engine-devel
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/voice-control-engine.pc
-%{_includedir}/voice_control_plugin_engine.h
+%{_includedir}/vce.h
+
vcd_dbus_server.c
vcd_dbus.c
vcd_engine_agent.c
- vcd_main.c
+# vcd_main.c
vcd_recorder.c
vcd_server.c
+ vce.c
)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
## Executable ##
-ADD_EXECUTABLE("${PROJECT_NAME}-daemon" ${SRCS})
-TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon" -ldl -lm ${pkgs_LDFLAGS})
+#ADD_EXECUTABLE("${PROJECT_NAME}-daemon" ${SRCS})
+#TARGET_LINK_LIBRARIES("${PROJECT_NAME}-daemon" -ldl -lm ${pkgs_LDFLAGS})
## Install
-INSTALL(TARGETS "${PROJECT_NAME}-daemon" DESTINATION bin)
+#INSTALL(TARGETS "${PROJECT_NAME}-daemon" DESTINATION bin)
+
+## Executable ##
+ADD_LIBRARY("${PROJECT_NAME}_engine" SHARED ${SRCS})
+TARGET_LINK_LIBRARIES("${PROJECT_NAME}_engine" -ldl ${pkgs_LDFLAGS})
+
+## Install
+INSTALL(TARGETS "${PROJECT_NAME}_engine" DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
/*
-* Copyright (c) 2011-2015 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-2015 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 <dlfcn.h>
#include "vcd_dbus.h"
/*
-* Internal data structure
-*/
+ * Internal data structure
+ */
typedef struct {
/* engine info */
char* engine_uuid;
bool is_command_ready;
void *handle;
- vcpe_funcs_s* pefuncs;
- vcpd_funcs_s* pdfuncs;
-
- int (*vcp_load_engine)(vcpd_funcs_s* pdfuncs, vcpe_funcs_s* pefuncs);
- int (*vcp_unload_engine)();
+ vc_engine_callback_s* callbacks;
} vcengine_s;
typedef struct _vcengine_info {
/*
-* static data
-*/
+ * static data
+ */
/** vc engine agent init */
static bool g_agent_init;
-/** vc engine list */
-static GList *g_engine_list;
-
/** current engine information */
static vcengine_s g_dynamic_engine;
static char* g_default_lang;
-/** callback functions */
-static result_callback g_result_cb = NULL;
-
-static asr_result_callback g_asr_result_cb = NULL;
-static nlg_result_callback g_nlg_result_cb = NULL;
-
-#if 0
-static pre_result_callback g_pre_result_cb = NULL;
-
-static nlu_result_callback g_nlu_result_cb = NULL;
-#endif
-
-static error_callback g_error_cb = NULL;
-
bool __supported_language_cb(const char* language, void* user_data);
-void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* engine_setting, bool use_network, void* user_data);
-
-bool __engine_setting_cb(const char* key, const char* value, void* user_data);
-
-/** Free voice list */
-void __free_language_list(GList* lang_list);
-
-
/*
-* Internal Interfaces
-*/
-
-/** check engine id */
-int __internal_check_engine_id(const char* engine_uuid);
-
-/** update engine list */
-int __internal_update_engine_list();
+ * Internal Interfaces
+ */
/** get engine info */
-int __internal_get_engine_info(const char* filepath, vcengine_info_s** info);
-
-int __log_enginelist();
+int __internal_get_engine_info(vce_request_callback_s* callback);
/*
-* VCS Engine Agent Interfaces
-*/
-//int vcd_engine_agent_init(pre_result_callback pre_result_cb, result_callback result_cb, nlu_result_callback nlu_result_cb, error_callback error_cb)
-int vcd_engine_agent_init(asr_result_callback asr_result_cb, result_callback result_cb, nlg_result_callback nlg_result_cb, error_callback error_cb)
+ * VCS Engine Agent Interfaces
+ */
+int vcd_engine_agent_init()
{
- if (/*NULL == pre_result_cb*/ NULL == asr_result_cb || NULL == result_cb /*|| NULL == nlu_result_cb*/ || NULL == error_cb) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Input parameter is NULL");
- return VCD_ERROR_OPERATION_FAILED;
+ if (true == g_agent_init) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Already initialized");
+ return VCD_ERROR_NONE;
}
/* init dynamic engine */
g_dynamic_engine.is_loaded = false;
g_dynamic_engine.handle = NULL;
g_dynamic_engine.is_command_ready = false;
- g_dynamic_engine.pefuncs = (vcpe_funcs_s*)calloc(1, sizeof(vcpe_funcs_s));
- g_dynamic_engine.pdfuncs = (vcpd_funcs_s*)calloc(1, sizeof(vcpd_funcs_s));
- g_agent_init = true;
+ g_dynamic_engine.callbacks = (vc_engine_callback_s*)calloc(1, sizeof(vc_engine_callback_s));
+ if (NULL == g_dynamic_engine.callbacks) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Fail to allocate memory");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
- //g_pre_result_cb = pre_result_cb;
- g_asr_result_cb = asr_result_cb;
- g_nlg_result_cb = nlg_result_cb;
- g_result_cb = result_cb;
- //g_nlu_result_cb = nlu_result_cb;
- g_error_cb = error_cb;
+ g_agent_init = true;
if (0 != vcd_config_get_default_language(&g_default_lang)) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] There is No default voice in config");
/* unload current engine */
vcd_engine_agent_unload_current_engine();
- /* release engine list */
- GList *iter = NULL;
- vcengine_s *data = NULL;
-
- if (g_list_length(g_engine_list) > 0) {
- /* Get a first item */
- iter = g_list_first(g_engine_list);
-
- while (NULL != iter) {
- /* Get handle data from list */
- data = iter->data;
- iter = g_list_remove(iter, data);
-
- if (NULL != data) {
- if (NULL != data->engine_uuid) {
- g_free(data->engine_uuid);
- data->engine_uuid = NULL;
- }
- if (NULL != data->engine_name) {
- g_free(data->engine_name);
- data->engine_name = NULL;
- }
- if (NULL != data->engine_path) {
- g_free(data->engine_path);
- data->engine_path = NULL;
- }
-
- free(data);
- data = NULL;
- }
- }
- }
-
- g_list_free(iter);
- g_engine_list = NULL;
-
/* release current engine data */
- if (NULL != g_dynamic_engine.pefuncs) {
- free(g_dynamic_engine.pefuncs);
- g_dynamic_engine.pefuncs = NULL;
- }
- if (NULL != g_dynamic_engine.pdfuncs) {
- free(g_dynamic_engine.pdfuncs);
- g_dynamic_engine.pdfuncs = NULL;
+ if (NULL != g_dynamic_engine.callbacks) {
+ free(g_dynamic_engine.callbacks);
+ g_dynamic_engine.callbacks = NULL;
}
g_agent_init = false;
- //g_pre_result_cb = NULL;
- g_asr_result_cb = NULL;
- g_nlg_result_cb = NULL;
- g_result_cb = NULL;
- //g_nlu_result_cb = NULL;
- g_error_cb = NULL;
-
SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent release");
return 0;
return false;
}
-int vcd_engine_agent_initialize_current_engine()
+int __internal_get_engine_info(vce_request_callback_s* callback)
{
- /* check agent init */
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
- return VCD_ERROR_OPERATION_FAILED;
- }
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] inside __internal_get_engine_info");
- /* update engine list */
- if (0 != __internal_update_engine_list()) {
- SLOG(LOG_ERROR, TAG_VCD, "[engine agent] vcd_engine_agent_init : __internal_update_engine_list : no engine error");
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine");
return VCD_ERROR_ENGINE_NOT_FOUND;
}
- /* check whether engine id is valid or not.*/
- GList *iter = NULL;
- vcengine_info_s *dynamic_engine = NULL;
-
- if (g_list_length(g_engine_list) > 0) {
- /*Get a first item*/
- iter = g_list_first(g_engine_list);
-
- while (NULL != iter) {
- /*Get handle data from list*/
- dynamic_engine = iter->data;
- if (NULL != dynamic_engine) {
- break;
- }
-
- /*Get next item*/
- iter = g_list_next(iter);
- }
- } else {
+ if (NULL == callback->get_info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine");
return VCD_ERROR_ENGINE_NOT_FOUND;
}
- if (NULL == dynamic_engine) {
+ if (0 != callback->get_info(&(g_dynamic_engine.engine_uuid), &(g_dynamic_engine.engine_name))) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine info");
return VCD_ERROR_ENGINE_NOT_FOUND;
- } else {
- if (NULL != g_dynamic_engine.engine_uuid) {
- /* set data from g_engine_list */
- if (g_dynamic_engine.engine_uuid != NULL) g_free(g_dynamic_engine.engine_uuid);
- if (g_dynamic_engine.engine_name != NULL) g_free(g_dynamic_engine.engine_name);
- if (g_dynamic_engine.engine_path != NULL) g_free(g_dynamic_engine.engine_path);
- }
-
- g_dynamic_engine.engine_uuid = g_strdup(dynamic_engine->engine_uuid);
- g_dynamic_engine.engine_name = g_strdup(dynamic_engine->engine_name);
- g_dynamic_engine.engine_path = g_strdup(dynamic_engine->engine_path);
-
- g_dynamic_engine.handle = NULL;
- g_dynamic_engine.is_loaded = false;
- g_dynamic_engine.is_set = true;
-
- SLOG(LOG_DEBUG, TAG_VCD, "@@@");
- SLOG(LOG_DEBUG, TAG_VCD, " Dynamic engine uuid : %s", g_dynamic_engine.engine_uuid);
- SLOG(LOG_DEBUG, TAG_VCD, " Dynamic engine name : %s", g_dynamic_engine.engine_name);
- SLOG(LOG_DEBUG, TAG_VCD, " Dynamic engine path : %s", g_dynamic_engine.engine_path);
- SLOG(LOG_DEBUG, TAG_VCD, "@@@");
-
- }
-
- return 0;
-}
-
-int __internal_check_engine_id(const char* engine_uuid)
-{
- if (NULL == engine_uuid) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
- return VCD_ERROR_INVALID_PARAMETER;
- }
-
- GList *iter = NULL;
- vcengine_s *data = NULL;
-
- if (0 < g_list_length(g_engine_list)) {
- /*Get a first item*/
- iter = g_list_first(g_engine_list);
-
- while (NULL != iter) {
- data = iter->data;
-
- if (0 == strncmp(engine_uuid, data->engine_uuid, strlen(data->engine_uuid))) {
- return 0;
- }
-
- iter = g_list_next(iter);
- }
- }
-
- return -1;
-}
-
-void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* engine_setting, bool use_network, void* user_data)
-{
- vcengine_info_s* temp = (vcengine_info_s*)user_data;
-
- temp->engine_uuid = g_strdup(engine_uuid);
- temp->engine_name = g_strdup(engine_name);
-}
-
-
-int __internal_get_engine_info(const char* filepath, vcengine_info_s** info)
-{
- if (NULL == filepath || NULL == info) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid Parameter");
- return VCD_ERROR_INVALID_PARAMETER;
}
- /* load engine */
- char *error;
- void* handle;
-
- handle = dlopen(filepath, RTLD_LAZY);
- if (!handle) {
- SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Invalid engine : %s", filepath);
- if ((error = dlerror()) != NULL) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] %s", error);
- }
- return -1;
+ if (NULL != g_dynamic_engine.callbacks) {
+ free(g_dynamic_engine.callbacks);
+ g_dynamic_engine.callbacks = NULL;
}
-
- /* link engine to daemon */
- dlsym(handle, "vcp_load_engine");
- if ((error = dlerror()) != NULL) {
- SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Invalid engine. Fail to open vcp_load_engine : %s", filepath);
- dlclose(handle);
- return -1;
- }
-
- dlsym(handle, "vcp_unload_engine");
- if ((error = dlerror()) != NULL) {
- SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Invalid engine. Fail to open vcp_unload_engine : %s", filepath);
- dlclose(handle);
- return -1;
- }
-
- int (*get_engine_info)(vcpe_engine_info_cb callback, void* user_data);
-
- get_engine_info = (int (*)(vcpe_engine_info_cb, void*))dlsym(handle, "vcp_get_engine_info");
- if (NULL != (error = dlerror()) || NULL == get_engine_info) {
- SLOG(LOG_WARN, TAG_VCD, "[Engine Agent WARNING] Invalid engine. Fail to open vcp_get_engine_info : %s", filepath);
- dlclose(handle);
- return -1;
- }
-
- vcengine_info_s* temp;
- temp = (vcengine_info_s*)calloc(1, sizeof(vcengine_info_s));
- if (NULL == temp) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
- dlclose(handle);
+ g_dynamic_engine.callbacks = (vc_engine_callback_s*)calloc(1, sizeof(vc_engine_callback_s));
+ if (NULL == g_dynamic_engine.callbacks) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to allocate memory");
return VCD_ERROR_OUT_OF_MEMORY;
}
- /* get engine info */
- if (0 != get_engine_info(__engine_info_cb, (void*)temp)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine info from engine");
- dlclose(handle);
- free(temp);
- return -1;
- }
-
- /* close engine */
- dlclose(handle);
-
- temp->engine_path = g_strdup(filepath);
+ g_dynamic_engine.callbacks->get_info = callback->get_info;
+ g_dynamic_engine.callbacks->get_recording_format = callback->get_recording_format;
+ g_dynamic_engine.callbacks->foreach_langs = callback->foreach_langs;
+ g_dynamic_engine.callbacks->is_lang_supported = callback->is_lang_supported;
+ g_dynamic_engine.callbacks->initialize = callback->initialize;
+ g_dynamic_engine.callbacks->deinitialize = callback->deinitialize;
+ g_dynamic_engine.callbacks->set_language = callback->set_language;
+ g_dynamic_engine.callbacks->set_commands = callback->set_commands;
+ g_dynamic_engine.callbacks->unset_commands = callback->unset_commands;
+
+ g_dynamic_engine.callbacks->start = callback->start;
+ g_dynamic_engine.callbacks->set_recording = callback->set_recording;
+ g_dynamic_engine.callbacks->stop = callback->stop;
+ g_dynamic_engine.callbacks->cancel = callback->cancel;
+ g_dynamic_engine.callbacks->set_domain = callback->set_domain;
+ g_dynamic_engine.callbacks->set_audio_type = callback->set_audio_type;
+ g_dynamic_engine.callbacks->process_text = callback->process_text;
+ g_dynamic_engine.callbacks->process_list_event = callback->process_list_event;
+ g_dynamic_engine.callbacks->process_haptic_event = callback->process_haptic_event;
+
+ g_dynamic_engine.callbacks->private_data_set = NULL;
+ g_dynamic_engine.callbacks->private_data_request = NULL;
+ g_dynamic_engine.callbacks->nlu_base_info_request = NULL;
SLOG(LOG_DEBUG, TAG_VCD, "@@@ Valid Engine");
- SLOG(LOG_DEBUG, TAG_VCD, "Engine uuid : %s", temp->engine_uuid);
- SLOG(LOG_DEBUG, TAG_VCD, "Engine name : %s", temp->engine_name);
- SLOG(LOG_DEBUG, TAG_VCD, "Engine path : %s", temp->engine_path);
+ SLOG(LOG_DEBUG, TAG_VCD, "Engine uuid : %s", g_dynamic_engine.engine_uuid);
+ SLOG(LOG_DEBUG, TAG_VCD, "Engine name : %s", g_dynamic_engine.engine_name);
SLOG(LOG_DEBUG, TAG_VCD, "@@@");
- *info = temp;
-
return 0;
}
-int __internal_update_engine_list()
+int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback)
{
- /* relsease engine list */
- GList *iter = NULL;
- vcengine_info_s *data = NULL;
-
- if (0 < g_list_length(g_engine_list)) {
- /* Get a first item */
- iter = g_list_first(g_engine_list);
-
- while (NULL != iter) {
- /* Get handle data from list */
- data = iter->data;
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] load current engine START");
- if (NULL != data) {
- if (NULL != data->engine_uuid) g_free(data->engine_uuid);
- if (NULL != data->engine_path) g_free(data->engine_path);
- if (NULL != data->engine_name) g_free(data->engine_name);
-
- data->engine_uuid = NULL;
- data->engine_path = NULL;
- data->engine_name = NULL;
-
- free(data);
- }
-
- g_engine_list = g_list_remove_link(g_engine_list, iter);
- iter = g_list_first(g_engine_list);
- }
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
}
- /* Get file name from default engine directory */
- DIR *dp = NULL;
- struct dirent *dirp = NULL;
-
- dp = opendir(VC_DEFAULT_ENGINE);
- if (NULL != dp) {
- do {
- dirp = readdir(dp);
-
- if (NULL != dirp) {
- if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name))
- continue;
-
- vcengine_info_s* info = NULL;
- char* filepath = NULL;
- int filesize = 0;
-
- filesize = strlen(VC_DEFAULT_ENGINE) + strlen(dirp->d_name) + 5;
- filepath = (char*)calloc(filesize, sizeof(char));
-
- if (NULL != filepath) {
- snprintf(filepath, filesize, "%s/%s", VC_DEFAULT_ENGINE, dirp->d_name);
- } else {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Memory not enough!!");
- continue;
- }
-
- /* get its info and update engine list */
- if (0 == __internal_get_engine_info(filepath, &info)) {
- /* add engine info to g_engine_list */
- g_engine_list = g_list_append(g_engine_list, info);
- }
-
- if (NULL != filepath) {
- free(filepath);
- filepath = NULL;
- }
- }
- } while (NULL != dirp);
-
- closedir(dp);
- } else {
- SLOG(LOG_WARN, TAG_VCD, "[Engine Agent WARNING] Fail to open default directory");
+ if (true == g_dynamic_engine.is_loaded) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Engine has already been loaded");
+ return 0;
}
- if (0 >= g_list_length(g_engine_list)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] No Engine");
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine");
return VCD_ERROR_ENGINE_NOT_FOUND;
}
- __log_enginelist();
-
- return 0;
-}
-
-
-int __foreach_command(vcp_cmd_h vc_command, vcpd_foreach_command_cb callback, void* user_data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request foreach command from engine");
- return vcd_client_foreach_command((client_foreach_command_cb)callback, user_data);
-}
-
-int __command_get_length(vcp_cmd_h vc_command)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request command length from engine");
- return vcd_client_get_length();
-}
-
-int __get_audio_type(char** audio_type)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request audio type");
-
- return vcd_recorder_get(audio_type);
-}
-
-int __set_private_data(const char* key, const char* data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request set private data");
- vcdc_send_request_set_private_data(vcd_client_manager_get_pid(), key, data);
-
- return 0;
-}
-
-int __get_private_data(const char* key, char** data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request get private data");
- vcdc_send_request_get_private_data(vcd_client_manager_get_pid(), key, data);
-
- return 0;
-}
-
-int __start_recording()
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request start recording");
-
- int ret = vcd_recorder_start();
+ /* Get current engine info */
+ int ret = __internal_get_engine_info(callback);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recorder : result(%d)", ret);
- vcd_engine_recognize_cancel();
- /* Send error cb to manager */
- vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine info");
return ret;
}
- return 0;
-}
-
-int __stop_recording()
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request stop recording");
-
- return vcd_recorder_stop();
-}
-
-void __result_cb(vcp_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed, const char* nlu_result, const char* msg, void *user_data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine agent] Event(%d), Count(%d) Text(%s) Nonfixed(%s) NLU result(%s) Msg(%s)", event, count, all_result, non_fixed, nlu_result, msg);
-
- if (NULL != g_result_cb) {
- g_result_cb(event, result_id, count, all_result, non_fixed, nlu_result, msg, user_data);
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] Result callback function is NOT valid");
- }
-
- return;
-}
-
-void __asr_result_cb(vcp_asr_result_event_e event, const char* asr_result, void *user_data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] ASR result - Event(%d), Result(%s)", event, asr_result);
-
- if (NULL != g_asr_result_cb) {
- g_asr_result_cb(event, asr_result, user_data);
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] ASR result callback function is NOT valid");
- }
-
- return;
-}
-
-void __nlg_result_cb(const char* nlg_result, void *user_data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] NLG result - Result(%s)", nlg_result);
-
- if (NULL != g_nlg_result_cb) {
- g_nlg_result_cb(nlg_result, user_data);
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] NLG result callback function is NOT valid");
- }
-
- return;
-}
-
-void __error_cb(vcp_error_e error, const char* msg, void *user_data)
-{
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] ERROR(%d)", error);
-
- if (NULL != g_error_cb) {
- g_error_cb(error, msg, user_data);
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] Error callback function is NOT vaild");
- }
-
- return;
-}
-
-int __load_engine(vcengine_s* engine)
-{
- /* check whether current engine is loaded or not */
- if (true == engine->is_loaded) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Engine has already been loaded ");
- return 0;
- }
-
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Current engine path : %s", engine->engine_path);
-
- /* open engine */
- char *error;
- engine->handle = dlopen(engine->engine_path, RTLD_LAZY);
-
- if ((error = dlerror()) != NULL || !engine->handle) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine handle");
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- engine->vcp_unload_engine = (int (*)())dlsym(engine->handle, "vcp_unload_engine");
- if ((error = dlerror()) != NULL) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to link daemon to vcp_unload_engine()");
- dlclose(engine->handle);
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- engine->vcp_load_engine = (int (*)(vcpd_funcs_s*, vcpe_funcs_s*))dlsym(engine->handle, "vcp_load_engine");
- if (NULL != (error = dlerror()) || NULL == engine->vcp_load_engine) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to link daemon to vcp_load_engine()");
- dlclose(engine->handle);
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- /* load engine */
- engine->pdfuncs->version = 1;
- engine->pdfuncs->size = sizeof(vcpd_funcs_s);
-
- engine->pdfuncs->foreach_command = __foreach_command;
- engine->pdfuncs->get_command_count = __command_get_length;
- engine->pdfuncs->get_audio_type = __get_audio_type;
-
- engine->pdfuncs->set_private_data = __set_private_data;
- engine->pdfuncs->get_private_data = __get_private_data;
-
- engine->pdfuncs->start_recording = __start_recording;
- engine->pdfuncs->stop_recording = __stop_recording;
-
- if (0 != engine->vcp_load_engine(engine->pdfuncs, engine->pefuncs)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail vcp_load_engine()");
- dlclose(engine->handle);
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] engine info : version(%d), size(%d)(%d)", engine->pefuncs->version, engine->pefuncs->size, sizeof(vcpe_funcs_s));
-
- /* engine error check */
- if (engine->pefuncs->size != sizeof(vcpe_funcs_s)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not valid");
- return VCD_ERROR_OPERATION_FAILED;
- }
-
/* Check all engine functions */
- if (NULL == engine->pefuncs->initialize ||
- NULL == engine->pefuncs->deinitialize ||
- NULL == engine->pefuncs->get_recording_format ||
- NULL == engine->pefuncs->foreach_langs ||
- NULL == engine->pefuncs->is_lang_supported ||
- NULL == engine->pefuncs->set_result_cb ||
- NULL == engine->pefuncs->set_language ||
- NULL == engine->pefuncs->set_commands ||
- NULL == engine->pefuncs->unset_commands ||
- NULL == engine->pefuncs->start ||
- NULL == engine->pefuncs->set_recording ||
- NULL == engine->pefuncs->stop ||
- NULL == engine->pefuncs->cancel ||
- NULL == engine->pefuncs->set_audio_type ||
- NULL == engine->pefuncs->set_asr_result_cb ||
- NULL == engine->pefuncs->set_nlg_result_cb ||
- //NULL == engine->pefuncs->set_pre_result_cb ||
- NULL == engine->pefuncs->set_error_cb ||
- NULL == engine->pefuncs->set_domain ||
- NULL == engine->pefuncs->get_nlu_base_info ||
- //NULL == engine->pefuncs->set_nlu_result_cb ||
- NULL == engine->pefuncs->set_private_data ||
- NULL == engine->pefuncs->get_private_data ||
- NULL == engine->pefuncs->process_text ||
- NULL == engine->pefuncs->process_list_event ||
- NULL == engine->pefuncs->process_haptic_event) {
+ if (NULL == g_dynamic_engine.callbacks->get_info ||
+ NULL == g_dynamic_engine.callbacks->get_recording_format ||
+ NULL == g_dynamic_engine.callbacks->foreach_langs ||
+ NULL == g_dynamic_engine.callbacks->is_lang_supported ||
+ NULL == g_dynamic_engine.callbacks->initialize ||
+ NULL == g_dynamic_engine.callbacks->deinitialize ||
+ NULL == g_dynamic_engine.callbacks->set_language ||
+ NULL == g_dynamic_engine.callbacks->set_commands ||
+ NULL == g_dynamic_engine.callbacks->unset_commands ||
+ NULL == g_dynamic_engine.callbacks->start ||
+ NULL == g_dynamic_engine.callbacks->set_recording ||
+ NULL == g_dynamic_engine.callbacks->stop ||
+ NULL == g_dynamic_engine.callbacks->cancel ||
+ NULL == g_dynamic_engine.callbacks->set_audio_type ||
+ NULL == g_dynamic_engine.callbacks->set_domain ||
+ NULL == g_dynamic_engine.callbacks->process_text ||
+ NULL == g_dynamic_engine.callbacks->process_list_event ||
+ NULL == g_dynamic_engine.callbacks->process_haptic_event) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] The current engine is NOT valid");
- return VCD_ERROR_OPERATION_FAILED;
+ return VCD_ERROR_ENGINE_NOT_FOUND;
}
/* initalize engine */
- if (0 != engine->pefuncs->initialize()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to initialize vc-engine");
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- if (0 != engine->pefuncs->set_result_cb(__result_cb, NULL)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set result callback of vc-engine");
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- if (0 != engine->pefuncs->set_asr_result_cb(__asr_result_cb, NULL)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set asr result callback of vc-engine");
- return VCD_ERROR_OPERATION_FAILED;
+ ret = g_dynamic_engine.callbacks->initialize();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to initialize vc engine service");
+ return ret;
}
- if (0 != engine->pefuncs->set_nlg_result_cb(__nlg_result_cb, NULL)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set nlg result callback of vc-engine");
- return VCD_ERROR_OPERATION_FAILED;
- }
+ /* set the supported language */
+ if (true == g_dynamic_engine.callbacks->is_lang_supported(g_default_lang)) {
+ ret = g_dynamic_engine.callbacks->set_language(g_default_lang);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set the supported language");
+ return ret;
+ }
- if (0 != engine->pefuncs->set_error_cb(__error_cb, NULL)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set error callback of vc-engine");
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] The %s has been loaded!!!", g_dynamic_engine.engine_name);
+ g_dynamic_engine.is_loaded = true;
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent WARNING] This engine do not support default language : lang(%s)", g_default_lang);
+ g_dynamic_engine.is_loaded = false;
return VCD_ERROR_OPERATION_FAILED;
}
- /* load engine */
- if (true == engine->pefuncs->is_lang_supported(g_default_lang)) {
- if (0 != engine->pefuncs->set_language(g_default_lang)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to load current engine");
- return VCD_ERROR_OPERATION_FAILED;
- }
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] The %s has been loaded !!!", engine->engine_name);
- engine->is_loaded = true;
- } else {
- SLOG(LOG_WARN, TAG_VCD, "[Engine Agent WARNING] This engine do not support default language : lang(%s)", g_default_lang);
- engine->is_loaded = false;
- }
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] load current engine FINISH");
return 0;
}
-int vcd_engine_agent_load_current_engine()
+int vcd_engine_agent_unload_current_engine()
{
if (false == g_agent_init) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
return VCD_ERROR_OPERATION_FAILED;
}
- if (true == g_dynamic_engine.is_set) {
- if (0 != __load_engine(&g_dynamic_engine)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to load dynamic engine");
-
- /* need to initialize dynamic engine data */
- g_dynamic_engine.is_loaded = false;
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Load dynamic engine");
- }
+ if (false == g_dynamic_engine.is_loaded) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Engine has already been unloaded");
+ return VCD_ERROR_NONE;
}
- return 0;
-}
-
-int vcd_engine_agent_unload_current_engine()
-{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized ");
- return VCD_ERROR_OPERATION_FAILED;
+ /* shut down engine */
+ int ret = 0;
+ ret = g_dynamic_engine.callbacks->deinitialize();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to deinitialize");
}
- if (true == g_dynamic_engine.is_set) {
- /* unload dynamic engine */
- if (true == g_dynamic_engine.is_loaded) {
- /* shutdown engine */
- g_dynamic_engine.pefuncs->deinitialize();
- g_dynamic_engine.vcp_unload_engine();
- dlclose(g_dynamic_engine.handle);
- g_dynamic_engine.handle = NULL;
- g_dynamic_engine.is_loaded = false;
- }
- }
+ /* reset current engine data */
+ g_dynamic_engine.is_loaded = false;
+
return 0;
}
/*
-* VCS Engine Interfaces for client
-*/
+ * VCS Engine Interfaces for client
+ */
int vcd_engine_set_commands()
{
if (true == g_dynamic_engine.is_loaded) {
/* Set dynamic command */
- ret = g_dynamic_engine.pefuncs->set_commands((vcp_cmd_h)0);
+ ret = g_dynamic_engine.callbacks->set_commands((vce_cmd_h)0);
if (0 != ret) {
SLOG(LOG_WARN, TAG_VCD, "[Engine Agent ERROR] Fail to set command of dynamic engine : error(%d)", ret);
g_dynamic_engine.is_command_ready = false;
SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] silence is %s", silence ? "true" : "false");
if (true == g_dynamic_engine.is_loaded && true == g_dynamic_engine.is_command_ready) {
- ret = g_dynamic_engine.pefuncs->start(silence);
+ ret = g_dynamic_engine.callbacks->start(silence);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Fail to start engine error(%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
return 0;
}
-int vcd_engine_recognize_audio(const void* data, unsigned int length, vcp_speech_detect_e* speech_detected)
+int vcd_engine_recognize_audio(const void* data, unsigned int length, vce_speech_detect_e* speech_detected)
{
if (false == g_agent_init) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
int ret = -1;
if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->set_recording(data, length, speech_detected);
+ ret = g_dynamic_engine.callbacks->set_recording(data, length, speech_detected);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set recording dynamic engine error(%d)", ret);
- if (VCP_ERROR_OUT_OF_NETWORK == ret) {
+ if (VCE_ERROR_OUT_OF_NETWORK == ret) {
return VCD_ERROR_TIMED_OUT;
}
return VCD_ERROR_OPERATION_FAILED;
if (true == g_dynamic_engine.is_loaded) {
int ret = -1;
- ret = g_dynamic_engine.pefuncs->stop();
+ ret = g_dynamic_engine.callbacks->stop();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to stop dynamic engine error(%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
int ret = -1;
if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->cancel();
+ ret = g_dynamic_engine.callbacks->cancel();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to cancel dynamic engine error(%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
int ret = -1;
if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->set_audio_type(audio);
+ ret = g_dynamic_engine.callbacks->set_audio_type(audio);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set audio type(%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
int ret = -1;
if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->set_domain(domain);
+ ret = g_dynamic_engine.callbacks->set_domain(domain);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set domain (%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
}
int ret = -1;
- if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->get_nlu_base_info(key, value);
+ if (true == g_dynamic_engine.is_loaded && NULL != g_dynamic_engine.callbacks->nlu_base_info_request) {
+ ret = g_dynamic_engine.callbacks->nlu_base_info_request(key, value);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get nlu base info (%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
}
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded or There is no nlu_base_info_request callback");
+ return VCD_ERROR_OPERATION_FAILED;
}
return 0;
}
int ret = -1;
- if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->set_private_data(key, data);
+ if (true == g_dynamic_engine.is_loaded && NULL != g_dynamic_engine.callbacks->private_data_set) {
+ ret = g_dynamic_engine.callbacks->private_data_set(key, data);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set private data (%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
}
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded or There is no private_data_set callback");
+ return VCD_ERROR_OPERATION_FAILED;
}
return 0;
}
int ret = -1;
- if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->get_private_data(key, data);
+ if (true == g_dynamic_engine.is_loaded && NULL != g_dynamic_engine.callbacks->private_data_request) {
+ ret = g_dynamic_engine.callbacks->private_data_request(key, data);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get private data (%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
}
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded or There is no private_data_request callback");
+ return VCD_ERROR_OPERATION_FAILED;
}
return 0;
int ret = -1;
if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->process_text(text);
+ ret = g_dynamic_engine.callbacks->process_text(text);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to process text (%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
int ret = -1;
if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->process_list_event(event);
+ ret = g_dynamic_engine.callbacks->process_list_event(event);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to process list event (%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
int ret = -1;
if (true == g_dynamic_engine.is_loaded) {
- ret = g_dynamic_engine.pefuncs->process_haptic_event(event);
+ ret = g_dynamic_engine.callbacks->process_haptic_event(event);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to process haptic event (%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
}
/*
-* VCS Engine Interfaces for client and setting
-*/
+ * VCS Engine Interfaces for client and setting
+ */
-int vcd_engine_get_audio_format(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels)
+int vcd_engine_get_audio_format(const char* audio_id, vce_audio_type_e* types, int* rate, int* channels)
{
if (false == g_agent_init) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded");
}
- if (NULL == g_dynamic_engine.pefuncs->get_recording_format) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] The function of engine is NULL!!");
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- int ret = g_dynamic_engine.pefuncs->get_recording_format(audio_id, types, rate, channels);
+ int ret = g_dynamic_engine.callbacks->get_recording_format(audio_id, types, rate, channels);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] get recording format(%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded");
}
- if (NULL == g_dynamic_engine.pefuncs->foreach_langs) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] The function of engine is NULL!!");
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- int ret = g_dynamic_engine.pefuncs->foreach_langs(__supported_language_cb, (void*)lang_list);
+ int ret = g_dynamic_engine.callbacks->foreach_langs(__supported_language_cb, (void*)lang_list);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] get language list error(%d)", ret);
return VCD_ERROR_OPERATION_FAILED;
if (true == g_dynamic_engine.is_loaded) {
g_dynamic_engine.is_command_ready = false;
- ret = g_dynamic_engine.pefuncs->set_language(language);
+ ret = g_dynamic_engine.callbacks->set_language(language);
if (0 != ret) {
SLOG(LOG_WARN, TAG_VCD, "[Engine Agent] Fail to set language of dynamic engine error(%d, %s)", ret, language);
}
return 0;
}
-void __free_language_list(GList* lang_list)
+int vcd_engine_agent_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request foreach command from engine");
+ return vcd_client_foreach_command((client_foreach_command_cb)callback, user_data);
+}
+
+int vcd_engine_agent_get_command_count(vce_cmd_h vce_command)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request command length from engine");
+
+ return vcd_client_get_length();
+}
+
+int vcd_engine_agent_get_audio_type(char** audio_type)
{
- GList *iter = NULL;
- char* data = NULL;
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request audio type");
- /* if list have item */
- if (g_list_length(lang_list) > 0) {
- /* Get a first item */
- iter = g_list_first(lang_list);
+ return vcd_recorder_get(audio_type);
+}
- while (NULL != iter) {
- data = iter->data;
+int vcd_engine_agent_set_private_data(const char* key, const char* data)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request set private data");
+ vcdc_send_request_set_private_data(vcd_client_manager_get_pid(), key, data);
- if (NULL != data)
- free(data);
+ return VCD_ERROR_NONE;
+}
- lang_list = g_list_remove_link(lang_list, iter);
+int vcd_engine_agent_get_private_data(const char* key, char** data)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request get private data");
+ vcdc_send_request_get_private_data(vcd_client_manager_get_pid(), key, data);
- iter = g_list_first(lang_list);
- }
+ return VCD_ERROR_NONE;
+}
+
+int vcd_engine_agent_start_recording()
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request start recording");
+
+ int ret = vcd_recorder_start();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recorder : result(%d)", ret);
+ vcd_engine_recognize_cancel();
+ /* Send error cb to manager */
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
+ return ret;
}
+
+ return VCD_ERROR_NONE;
}
-int __log_enginelist()
+int vcd_engine_agent_stop_recording()
{
- GList *iter = NULL;
- vcengine_info_s *data = NULL;
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request stop recording");
- if (0 < g_list_length(g_engine_list)) {
+ return vcd_recorder_stop();
+}
- /* Get a first item */
- iter = g_list_first(g_engine_list);
+int vcd_engine_agent_set_private_data_set_cb(vce_private_data_set_cb callback_func)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ if (false == g_dynamic_engine.is_loaded) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not loaded engine");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
- SLOG(LOG_DEBUG, TAG_VCD, "@ engine list @");
+ g_dynamic_engine.callbacks->private_data_set = callback_func;
- int i = 1;
- while (NULL != iter) {
- /* Get handle data from list */
- data = iter->data;
+ return VCD_ERROR_NONE;
+}
- SLOG(LOG_DEBUG, TAG_VCD, "[%dth]", i);
- SLOG(LOG_DEBUG, TAG_VCD, " engine uuid : %s", data->engine_uuid);
- SLOG(LOG_DEBUG, TAG_VCD, " engine name : %s", data->engine_name);
- SLOG(LOG_DEBUG, TAG_VCD, " engine path : %s", data->engine_path);
- iter = g_list_next(iter);
- i++;
- }
- SLOG(LOG_DEBUG, TAG_VCD, "@@@@");
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "@ engine list @");
- SLOG(LOG_DEBUG, TAG_VCD, " No Engine in engine directory");
- SLOG(LOG_DEBUG, TAG_VCD, "@@@@");
+int vcd_engine_agent_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
}
- return 0;
+ if (false == g_dynamic_engine.is_loaded) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not loaded engine");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ g_dynamic_engine.callbacks->private_data_request = callback_func;
+
+ return VCD_ERROR_NONE;
}
+
+int vcd_engine_agent_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ if (false == g_dynamic_engine.is_loaded) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not loaded engine");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ g_dynamic_engine.callbacks->nlu_base_info_request = callback_func;
+
+ return VCD_ERROR_NONE;
+}
+
#define __VCD_ENGINE_AGENT_H_
#include "vcd_main.h"
-#include "voice_control_plugin_engine.h"
#ifdef __cplusplus
extern "C" {
#define ENGINE_PATH_SIZE 256
-typedef void (*result_callback)(vcp_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, void *user_data);
-
-typedef void (*asr_result_callback)(vcp_asr_result_event_e event, const char* asr_result, void *user_data);
-
-typedef void (*nlg_result_callback)(const char* nlg_result, void *user_data);
-
-#if 0
-typedef void (*pre_result_callback)(vcp_pre_result_event_e event, const char* pre_result, void *user_data);
-
-typedef void (*nlu_result_callback)(vcp_result_event_e event, const char* nlu_result, void *user_data);
-#endif
-
-typedef void (*error_callback)(vcp_error_e error, const char* msg, void *user_data);
-
-typedef void (*silence_dectection_callback)(void *user_data);
-
-
-
/** Init engine agent */
-//int vcd_engine_agent_init(pre_result_callback pre_result_cb, result_callback result_cb, nlu_result_callback nlu_result_cb, error_callback error_cb);
-int vcd_engine_agent_init(asr_result_callback asr_result_cb, result_callback result_cb, nlg_result_callback nlg_result_cb, error_callback error_cb);
+int vcd_engine_agent_init();
/** Release engine agent */
int vcd_engine_agent_release();
bool vcd_engine_is_available_engine();
-/** Set current engine */
-int vcd_engine_agent_initialize_current_engine();
-
/** load current engine */
-int vcd_engine_agent_load_current_engine();
+int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback);
/** Unload current engine */
int vcd_engine_agent_unload_current_engine();
-/** test for language list */
-int vcd_print_enginelist();
-
-int vcd_engine_get_audio_format(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels);
+int vcd_engine_get_audio_format(const char* audio_id, vce_audio_type_e* types, int* rate, int* channels);
int vcd_engine_supported_langs(GList** lang_list);
/* normal recognition */
int vcd_engine_recognize_start(bool silence);
-int vcd_engine_recognize_audio(const void* data, unsigned int length, vcp_speech_detect_e* speech_detected);
+int vcd_engine_recognize_audio(const void* data, unsigned int length, vce_speech_detect_e* speech_detected);
int vcd_engine_recognize_stop();
int vcd_engine_get_nlu_base_info(int pid, const char* key, char** value);
-// int vcd_engine_set_private_data(const char* data);
int vcd_engine_set_private_data(int pid, const char* key, const char* data);
-// int vcd_engine_get_private_data(char** data);
int vcd_engine_get_private_data(int pid, const char* key, char** data);
int vcd_engine_process_text(int pid, const char* text);
int vcd_engine_process_haptic_event(int pid, const char* event);
+/* for engine service */
+int vcd_engine_agent_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data);
+
+int vcd_engine_agent_get_command_count(vce_cmd_h vce_command);
+
+int vcd_engine_agent_get_audio_type(char** audio_type);
+
+int vcd_engine_agent_set_private_data(const char* key, const char* data);
+
+int vcd_engine_agent_get_private_data(const char* key, char** data);
+
+int vcd_engine_agent_start_recording();
+
+int vcd_engine_agent_stop_recording();
+
+int vcd_engine_agent_set_private_data_set_cb(vce_private_data_set_cb callback_func);
+
+int vcd_engine_agent_set_private_data_requested_cb(vce_private_data_requested_cb callback_func);
+
+int vcd_engine_agent_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func);
+
#ifdef __cplusplus
}
+++ /dev/null
-/*
-* Copyright (c) 2011-2015 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 "vcd_dbus.h"
-#include "vcd_main.h"
-#include "vcd_server.h"
-
-#define CLIENT_CLEAN_UP_TIME 500
-
-static Ecore_Timer* g_check_client_timer = NULL;
-
-int main(int argc, char** argv)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC Daemon Initialize");
-
- if (!ecore_init()) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()");
- return -1;
- }
-
- if (0 != vcd_dbus_open_connection()) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection");
- ecore_shutdown();
- return EXIT_FAILURE;
- }
-
- if (0 != vcd_initialize()) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize vc-daemon");
- ecore_shutdown();
- return EXIT_FAILURE;
- }
-
- g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, vcd_cleanup_client_all, NULL);
- if (NULL == g_check_client_timer) {
- SLOG(LOG_WARN, TAG_VCD, "[Main Warning] Fail to create timer of client check");
- }
-
- SLOG(LOG_DEBUG, TAG_VCD, "[Main] vc-daemon start");
-
- SLOG(LOG_DEBUG, TAG_VCD, "@@@");
-
- ecore_main_loop_begin();
-
- SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC Daemon Finalize");
-
- if (NULL != g_check_client_timer) {
- ecore_timer_del(g_check_client_timer);
- }
-
- vcd_finalize();
-
- vcd_dbus_close_connection();
-
- ecore_shutdown();
-
- SLOG(LOG_DEBUG, TAG_VCD, "@@@");
-
- return 0;
-}
-
-
#include "vc_defs.h"
+#include "vce.h"
+
#ifdef __cplusplus
extern "C" {
#endif
VCD_STATE_PROCESSING = 3
} vcd_state_e;
+typedef struct {
+ int version; /**< Version */
+
+ /* Mandatory callbacks */
+ /* Get engine information */
+ vce_get_info_cb get_info; /**< Called when the engine service user requests the basic information of VC engine */
+ vce_get_recording_format_cb get_recording_format; /**< Get recording format */
+ vce_foreach_supported_languages_cb foreach_langs; /**< Foreach language list */
+ vce_is_language_supported_cb is_lang_supported; /**< Check language */
+
+ vce_initialize_cb initialize; /**< Initialize engine */
+ vce_deinitialize_cb deinitialize; /**< Shutdown engine */
+
+ /* Set info */
+ vce_set_language_cb set_language; /**< Set language */
+ vce_set_commands_cb set_commands; /**< Request to set current commands */
+ vce_unset_commands_cb unset_commands; /**< Request to unset current commands */
+
+ /* Control recognition */
+ vce_start_cb start; /**< Start recognition */
+ vce_set_recording_data_cb set_recording; /**< Set recording data */
+ 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_domain_cb set_domain; /**< Set domain */
+ vce_process_text_cb process_text; /**< Request to process text */
+ vce_process_list_event_cb process_list_event; /**< Request to process list event */
+ vce_process_haptic_event_cb process_haptic_event; /**< Request to process haptic event */
+
+ /* Optional callbacks */
+ vce_private_data_set_cb private_data_set;
+ vce_private_data_requested_cb private_data_request;
+ vce_nlu_base_info_requested_cb nlu_base_info_request;
+} vc_engine_callback_s;
+
#ifdef __cplusplus
}
/*
-* Copyright (c) 2011-2015 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-2017 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.
+ */
#ifdef TV_PRODUCT
#define TV_BT_MODE
#include "vcd_engine_agent.h"
#include "vcd_recorder.h"
#include "vcd_main.h"
-#include "voice_control_plugin_engine.h"
#define FRAME_LENGTH 160
#define BUFFER_LENGTH FRAME_LENGTH * 2
#define FOCUS_SERVER_READY "/tmp/.focus_server_ready"
-#define VCP_AUDIO_ID_NONE "VC_AUDIO_ID_NONE" /**< None audio id */
+#define VCE_AUDIO_ID_NONE "VC_AUDIO_ID_NONE" /**< None audio id */
static vcd_recorder_state_e g_recorder_state = VCD_RECORDER_STATE_READY;
static sound_stream_info_h g_stream_info_h;
-static vcp_audio_type_e g_audio_type;
+static vce_audio_type_e g_audio_type;
static int g_audio_rate;
/* Sound buf save */
/*
#define BUF_SAVE_MODE
-*/
+ */
#ifdef BUF_SAVE_MODE
static FILE* g_normal_file;
#ifdef TV_MSF_WIFI_MODE
static void __msf_wifi_audio_data_receive_cb(msf_wifi_voice_data_s *voice_data, void* user_data)
{
- if (0 != strncmp(g_current_audio_type, VCP_AUDIO_ID_MSF, sizeof(VCP_AUDIO_ID_MSF))) {
+ if (0 != strncmp(g_current_audio_type, VCE_AUDIO_ID_WIFI, sizeof(VCE_AUDIO_ID_WIFI))) {
vcd_state_e state = vcd_config_get_service_state();
if (VCD_STATE_READY == state) {
- vcd_recorder_set(VCP_AUDIO_ID_MSF, VCP_AUDIO_TYPE_PCM_S16_LE, 16000, 1);
+ vcd_recorder_set(VCE_AUDIO_ID_WIFI, VCE_AUDIO_TYPE_PCM_S16_LE, 16000, 1);
} else {
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] current audio type is (%s)", g_current_audio_type);
return;
}
if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) {
- SLOG(LOG_WARN, TAG_VCD, "[Recorder] Not start yet, but send audio data vi MSF");
+ SLOG(LOG_WARN, TAG_VCD, "[Recorder] Not start yet, but send audio data vi Wi-Fi");
vcd_recorder_start();
}
static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void *user_data)
{
- if (0 != strncmp(g_current_audio_type, VCP_AUDIO_ID_BLUETOOTH, sizeof(VCP_AUDIO_ID_BLUETOOTH))) {
+ if (0 != strncmp(g_current_audio_type, VCE_AUDIO_ID_BLUETOOTH, sizeof(VCE_AUDIO_ID_BLUETOOTH))) {
vcd_state_e state = vcd_config_get_service_state();
if (VCD_STATE_READY == state) {
- vcd_recorder_set(VCP_AUDIO_ID_BLUETOOTH, VCP_AUDIO_TYPE_PCM_S16_LE, 16000, 1);
+ vcd_recorder_set(VCE_AUDIO_ID_BLUETOOTH, VCE_AUDIO_TYPE_PCM_S16_LE, 16000, 1);
} else {
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] current audio type is (%s)", g_current_audio_type);
return;
if (VCD_RECORDER_STATE_RECORDING != g_recorder_state) {
SLOG(LOG_WARN, TAG_VCD, "[Recorder] Not start yet, but send audio data vi Bluetooth");
-// vcd_recorder_start();
+ // vcd_recorder_start();
}
if (NULL != g_audio_cb) {
}
static void __recorder_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
- sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data)
+ sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data)
{
SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Focus state changed cb");
g_is_valid_bt_in = false;
g_current_audio_type = NULL;
- g_audio_type = VCP_AUDIO_TYPE_PCM_S16_LE;
+ g_audio_type = VCE_AUDIO_TYPE_PCM_S16_LE;
g_audio_rate = 16000;
g_audio_channel = 1;
}
switch (g_audio_type) {
- case VCP_AUDIO_TYPE_PCM_S16_LE: audio_type = AUDIO_SAMPLE_TYPE_S16_LE; break;
- case VCP_AUDIO_TYPE_PCM_U8: audio_type = AUDIO_SAMPLE_TYPE_U8; break;
+ case VCE_AUDIO_TYPE_PCM_S16_LE: audio_type = AUDIO_SAMPLE_TYPE_S16_LE; break;
+ case VCE_AUDIO_TYPE_PCM_U8: audio_type = AUDIO_SAMPLE_TYPE_U8; break;
default:
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Invalid Audio Type");
return VCD_ERROR_OPERATION_FAILED;
#endif
/* Select default audio type */
if (true == g_is_valid_audio_in) {
- g_current_audio_type = strdup(VCP_AUDIO_ID_NONE);
+ g_current_audio_type = strdup(VCE_AUDIO_ID_NONE);
} else {
if (true == g_is_valid_bt_in) {
- g_current_audio_type = strdup(VCP_AUDIO_ID_BLUETOOTH);
+ g_current_audio_type = strdup(VCE_AUDIO_ID_BLUETOOTH);
} else {
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] No valid audio");
return -1;
int vcd_recorder_destroy()
{
if (VCD_RECORDER_STATE_RECORDING == g_recorder_state) {
- if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
#ifdef TV_BT_MODE
bt_hid_unset_audio_data_receive_cb();
#endif
- } else if (0 == strncmp(VCP_AUDIO_ID_MSF, g_current_audio_type, strlen(VCP_AUDIO_ID_MSF))) {
+ } else if (0 == strncmp(VCE_AUDIO_ID_WIFI, g_current_audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
#ifdef TV_MSF_WIFI_MODE
UnRegisterMSFAudioCallback();
#endif
return 0;
}
-int vcd_recorder_set(const char* audio_type, vcp_audio_type_e type, int rate, int channel)
+int vcd_recorder_set(const char* audio_type, vce_audio_type_e type, int rate, int channel)
{
if (NULL == audio_type) {
return VCD_ERROR_INVALID_PARAMETER;
vcd_engine_set_audio_type(audio_type);
if (VCD_RECORDER_STATE_READY != g_recorder_state) {
- if ((!strncmp(g_current_audio_type, VCP_AUDIO_ID_NONE, strlen(g_current_audio_type)) &&
- strncmp(audio_type, VCP_AUDIO_ID_BLUETOOTH, strlen(audio_type)) &&
- strncmp(audio_type, VCP_AUDIO_ID_MSF, strlen(audio_type))) ||
- (strncmp(g_current_audio_type, VCP_AUDIO_ID_BLUETOOTH, strlen(g_current_audio_type)) &&
- strncmp(g_current_audio_type, VCP_AUDIO_ID_MSF, strlen(g_current_audio_type)) &&
- strncmp(g_current_audio_type, VCP_AUDIO_ID_NONE, strlen(g_current_audio_type)) &&
- !strncmp(audio_type, VCP_AUDIO_ID_NONE, strlen(audio_type)))) {
+ if (NULL != g_current_audio_type) {
+ if ((!strncmp(g_current_audio_type, VCE_AUDIO_ID_NONE, strlen(g_current_audio_type)) &&
+ strncmp(audio_type, VCE_AUDIO_ID_BLUETOOTH, strlen(audio_type)) &&
+ strncmp(audio_type, VCE_AUDIO_ID_WIFI, strlen(audio_type))) ||
+ (strncmp(g_current_audio_type, VCE_AUDIO_ID_BLUETOOTH, strlen(g_current_audio_type)) &&
+ strncmp(g_current_audio_type, VCE_AUDIO_ID_WIFI, strlen(g_current_audio_type)) &&
+ strncmp(g_current_audio_type, VCE_AUDIO_ID_NONE, strlen(g_current_audio_type)) &&
+ !strncmp(audio_type, VCE_AUDIO_ID_NONE, strlen(audio_type)))) {
SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Skip stop recording while Recorder is NOT ready");
- } else {
- SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Recorder is NOT ready");
- vcd_recorder_stop();
- //return VCD_ERROR_INVALID_STATE;
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Recorder is NOT ready");
+ vcd_recorder_stop();
+ //return VCD_ERROR_INVALID_STATE;
+ }
}
}
int ret = -1;
/* Check BT audio */
- if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
if (false == g_is_valid_bt_in) {
SLOG(LOG_ERROR, TAG_VCD, "[Recorder] BT audio is NOT valid");
return VCD_ERROR_OPERATION_REJECTED;
}
g_current_audio_type = strdup(audio_type);
- } else if (0 == strncmp(VCP_AUDIO_ID_MSF, audio_type, strlen(VCP_AUDIO_ID_MSF))) {
+ } else if (0 == strncmp(VCE_AUDIO_ID_WIFI, audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
if (NULL != g_current_audio_type) {
free(g_current_audio_type);
g_current_audio_type = NULL;
}
switch (type) {
- case VCP_AUDIO_TYPE_PCM_S16_LE: audio_type = AUDIO_SAMPLE_TYPE_S16_LE; break;
- case VCP_AUDIO_TYPE_PCM_U8: audio_type = AUDIO_SAMPLE_TYPE_U8; break;
+ case VCE_AUDIO_TYPE_PCM_S16_LE: audio_type = AUDIO_SAMPLE_TYPE_S16_LE; break;
+ case VCE_AUDIO_TYPE_PCM_U8: audio_type = AUDIO_SAMPLE_TYPE_U8; break;
default:
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Invalid Audio Type");
return VCD_ERROR_OPERATION_FAILED;
static void __check_audio_format()
{
- vcp_audio_type_e type;
+ vce_audio_type_e type;
int rate;
int channel;
- int ret = vcd_engine_get_audio_format(VCP_AUDIO_ID_NONE, &type, &rate, &channel);
+ int ret = vcd_engine_get_audio_format(VCE_AUDIO_ID_NONE, &type, &rate, &channel);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get audio format : %d", ret);
return;
}
switch (type) {
- case VCP_AUDIO_TYPE_PCM_S16_LE: audio_type = AUDIO_SAMPLE_TYPE_S16_LE; break;
- case VCP_AUDIO_TYPE_PCM_U8: audio_type = AUDIO_SAMPLE_TYPE_U8; break;
+ case VCE_AUDIO_TYPE_PCM_S16_LE: audio_type = AUDIO_SAMPLE_TYPE_S16_LE; break;
+ case VCE_AUDIO_TYPE_PCM_U8: audio_type = AUDIO_SAMPLE_TYPE_U8; break;
default:
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Invalid Audio Type");
return;
SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] audio type : %s", g_current_audio_type);
if (NULL != g_current_audio_type) {
- if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
#ifdef TV_BT_MODE
const unsigned char input_data[2] = {SMART_CONTROL_START_CMD, 0x00};
int bt_retry = 0;
g_bt_extend_count = 0;
#endif
- } else if (0 == strncmp(VCP_AUDIO_ID_MSF, g_current_audio_type, strlen(VCP_AUDIO_ID_MSF))) {
+ } else if (0 == strncmp(VCE_AUDIO_ID_WIFI, g_current_audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] call RegisterMSFAudioCallback() function");
#ifdef TV_MSF_WIFI_MODE
if (MSFResult_OK == ret) {
started = true;
} else {
- SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to start MSF(wifi) audio");
+ SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to start Wi-Fi audio");
return VCD_ERROR_OPERATION_FAILED;
}
#endif
bool stoped = false;
if (NULL != g_current_audio_type) {
- if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
#ifdef TV_BT_MODE
int bt_retry = 0;
while (5 > bt_retry) {
}
}
if (NULL != g_current_audio_type &&
- (!strncmp(g_current_audio_type, VCP_AUDIO_ID_BLUETOOTH, sizeof(VCP_AUDIO_ID_BLUETOOTH)) ||
- !strncmp(g_current_audio_type, VCP_AUDIO_ID_MSF, sizeof(VCP_AUDIO_ID_MSF)))) {
+ (!strncmp(g_current_audio_type, VCE_AUDIO_ID_BLUETOOTH, sizeof(VCE_AUDIO_ID_BLUETOOTH)) ||
+ !strncmp(g_current_audio_type, VCE_AUDIO_ID_WIFI, sizeof(VCE_AUDIO_ID_WIFI)))) {
SLOG(LOG_DEBUG, TAG_VCD, "[DEBUG] Recorder reset to NONE");
- vcd_recorder_set(VCP_AUDIO_ID_NONE, g_audio_type, g_audio_rate, g_audio_channel);
+ vcd_recorder_set(VCE_AUDIO_ID_NONE, g_audio_type, g_audio_rate, g_audio_channel);
}
if (false == stoped) {
return VCD_ERROR_OPERATION_FAILED;
}
#endif
- } else if (0 == strncmp(VCP_AUDIO_ID_MSF, g_current_audio_type, strlen(VCP_AUDIO_ID_MSF))) {
+ } else if (0 == strncmp(VCE_AUDIO_ID_WIFI, g_current_audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
#ifdef TV_MSF_WIFI_MODE
UnRegisterMSFAudioCallback();
if (NULL != g_current_audio_type &&
- (!strncmp(g_current_audio_type, VCP_AUDIO_ID_BLUETOOTH, sizeof(VCP_AUDIO_ID_BLUETOOTH)) ||
- !strncmp(g_current_audio_type, VCP_AUDIO_ID_MSF, sizeof(VCP_AUDIO_ID_MSF)))) {
+ (!strncmp(g_current_audio_type, VCE_AUDIO_ID_BLUETOOTH, sizeof(VCE_AUDIO_ID_BLUETOOTH)) ||
+ !strncmp(g_current_audio_type, VCE_AUDIO_ID_WIFI, sizeof(VCE_AUDIO_ID_WIFI)))) {
SLOG(LOG_DEBUG, TAG_VCD, "[DEBUG] Recorder reset to NONE");
- vcd_recorder_set(VCP_AUDIO_ID_NONE, g_audio_type, g_audio_rate, g_audio_channel);
+ vcd_recorder_set(VCE_AUDIO_ID_NONE, g_audio_type, g_audio_rate, g_audio_channel);
}
stoped = true;
#endif
extern "C" {
#endif
-#include "voice_control_plugin_engine.h"
typedef enum {
VCD_RECORDER_STATE_READY, /**< Recorder is ready to start */
int vcd_recorder_destroy();
-int vcd_recorder_set(const char* audio_type, vcp_audio_type_e type, int rate, int channel);
+int vcd_recorder_set(const char* audio_type, vce_audio_type_e type, int rate, int channel);
int vcd_recorder_get(char** audio_type);
/*
* VC Server static variable
*/
-static bool g_is_engine;
-
static GList *g_proc_list = NULL;
static Ecore_Timer *g_restart_timer = NULL;
return 0;
}
- vcp_speech_detect_e speech_detected = VCP_SPEECH_DETECT_NONE;
+ vce_speech_detect_e speech_detected = VCE_SPEECH_DETECT_NONE;
int ret;
ret = vcd_engine_recognize_audio(data, length, &speech_detected);
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set recording data to engine(%d)", ret);
ecore_timer_add(0, __cancel_by_interrupt, NULL);
/* Send error cb to manager */
- if (VCP_ERROR_OUT_OF_NETWORK == ret) {
+ if (VCE_ERROR_OUT_OF_NETWORK == ret) {
vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_TIMED_OUT, "Engine connection failed");
} else {
vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "Engine recognition failed");
return 0;
}
- if (VCP_SPEECH_DETECT_BEGIN == speech_detected) {
+ if (VCE_SPEECH_DETECT_BEGIN == speech_detected) {
if (-1 != vcd_client_manager_get_pid()) {
/* Manager client is available */
if (0 != vcdc_send_speech_detected(vcd_client_manager_get_pid())) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send speech detected");
}
}
- } else if (VCP_SPEECH_DETECT_END == speech_detected) {
+ } else if (VCE_SPEECH_DETECT_END == speech_detected) {
if (VCD_RECOGNITION_MODE_STOP_BY_SILENCE == vcd_client_get_recognition_mode()) {
/* silence detected */
ecore_timer_add(0, __stop_by_silence, NULL);
return EINA_FALSE;
}
-//static void __vcd_server_pre_result_cb(vcp_pre_result_event_e event, const char* pre_result, void *user_data)
-static void __vcd_server_asr_result_cb(vcp_asr_result_event_e event, const char* asr_result, void *user_data)
+int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
{
if (NULL != asr_result) {
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);
}
- return;
+ return VCD_ERROR_NONE;
}
-static void __vcd_server_nlg_result_cb(const char* nlg_result, void *user_data)
+int vcd_send_nlg_result(const char* nlg_result, void *user_data)
{
int ret = __vcd_server_launch_manager_app();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
- return;
+ return ret;
}
ret = vcdc_send_dialog(vcd_client_manager_get_pid(), -1, nlg_result, NULL, 0); //0: VC_DIALOG_END
if (0 != ret)
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
- return;
+ return ret;
}
static void* __recorder_stop(void *data)
return NULL;
}
-static void __vcd_server_result_cb(vcp_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, void *user_data)
+int vcd_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, void *user_data)
{
+ int ret = 0;
+
+ if (VCD_STATE_PROCESSING != vcd_config_get_service_state()) {
+ if (VCD_RECOGNITION_MODE_RESTART_CONTINUOUSLY != vcd_client_get_recognition_mode()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not 'Processing' and mode is not 'Restart continuously'");
+ return VCD_ERROR_INVALID_STATE;
+ }
+ }
+
vc_info_parser_unset_result(vcd_client_manager_get_exclusive());
vcd_client_manager_set_result_text(all_result);
event, all_result, non_fixed_result, msg, count);
if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) {
- if (VCP_RESULT_EVENT_REJECTED == event) {
+ if (VCE_RESULT_EVENT_REJECTED == event) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart by no or rejected result");
/* If no result and restart option is ON */
/* Send reject message */
bool temp = vcd_client_manager_get_exclusive();
vc_info_parser_set_result(all_result, event, msg, NULL, temp);
- if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+ ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
+ if (0 != ret) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
}
g_restart_timer = ecore_timer_add(0, __restart_engine, NULL);
- return;
+ return ret;
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Stop recorder due to success");
//vcd_recorder_stop();
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart continuously");
/* Restart option is ON */
g_restart_timer = ecore_timer_add(0, __restart_engine, NULL);
- if (VCP_RESULT_EVENT_REJECTED == event) {
+ if (VCE_RESULT_EVENT_REJECTED == event) {
bool temp = vcd_client_manager_get_exclusive();
vc_info_parser_set_result(all_result, event, msg, NULL, temp);
- if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+ ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
+ if (0 != ret) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
}
- return;
+ return ret;
}
}
#if 1
vcd_config_set_service_state(VCD_STATE_READY);
vcdc_send_service_state(VCD_STATE_READY);
- return;
+ return VCD_ERROR_NONE;
}
}
}
/* Normal result */
SLOG(LOG_DEBUG, TAG_VCD, "[Server] @ Get engine result @");
- int ret = -1;
vc_cmd_s* temp_cmd = NULL;
vc_cmd_list_h vc_cmd_list = NULL;
vcd_client_manager_set_exclusive(false);
vcd_config_set_service_state(VCD_STATE_READY);
vcdc_send_service_state(VCD_STATE_READY);
- return;
+ return VCD_ERROR_NONE;
}
/* priority filter */
int* filtered_id = (int*)calloc(count, sizeof(int));
if (!filtered_id) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to allocate memory");
- return;
+ return VCD_ERROR_OUT_OF_MEMORY;
}
int filtered_count = 0;
int top_priority = VC_COMMAND_PRIORITY_BACKGROUND;
vcd_client_manager_set_exclusive(false);
- return;
+ return VCD_ERROR_NONE;
} else {
if (false == vcd_client_manager_get_exclusive()) {
int pid = vcd_client_widget_get_foreground_pid();
vc_cmd_list_destroy(vc_cmd_list, true);
- return;
+ return VCD_ERROR_NONE;
#else
/* No result */
}
#if 0
-static void __vcd_server_nlu_result_cb(vcp_result_event_e event, const char* nlu_result, void *user_data)
+static void __vcd_server_nlu_result_cb(vce_result_event_e event, const char* nlu_result, void *user_data)
{
SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event);
SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result);
}
#endif
-static void __vcd_server_error_cb(vcp_error_e error, const char* msg, void *user_data)
+int vcd_send_error(vce_error_e error, const char* msg, void *user_data)
{
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Engine Error cb - reason(%d), msg(%s)", error, msg);
ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL);
error_msg = NULL;
}
- return;
+ return VCD_ERROR_NONE;
}
/*
return ret;
}
-int vcd_initialize()
+int vcd_initialize(vce_request_callback_s *callback)
{
int ret = 0;
vcd_config_set_service_state(VCD_STATE_NONE);
- //ret = vcd_engine_agent_init(__vcd_server_pre_result_cb, __vcd_server_result_cb, __vcd_server_nlu_result_cb, __vcd_server_error_cb);
- ret = vcd_engine_agent_init(__vcd_server_asr_result_cb, __vcd_server_result_cb, __vcd_server_nlg_result_cb, __vcd_server_error_cb);
+ ret = vcd_engine_agent_init();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to engine agent initialize : result(%d)", ret);
return ret;
return VCD_ERROR_OPERATION_FAILED;
}
- /* Find engine */
- ret = vcd_engine_agent_initialize_current_engine();
- if (0 != ret) {
- if (VCD_ERROR_ENGINE_NOT_FOUND == ret)
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] There is No Voice control engine");
- else
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to init engine");
-
- g_is_engine = false;
- } else {
- g_is_engine = true;
- }
-
/* Load engine */
- if (0 != vcd_engine_agent_load_current_engine()) {
+ if (0 != vcd_engine_agent_load_current_engine(callback)) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to load current engine");
return VCD_ERROR_OPERATION_FAILED;
}
Eina_Bool vcd_cleanup_client_all(void *data)
{
__read_proc();
-
+
__vcd_cleanup_client(VCD_CLIENT_TYPE_NORMAL);
__vcd_cleanup_client(VCD_CLIENT_TYPE_WIDGET);
__vcd_cleanup_client(VCD_CLIENT_TYPE_MANAGER);
*/
int vcd_server_mgr_initialize(int pid)
{
- if (false == g_is_engine) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- g_is_engine = false;
- return VCD_ERROR_ENGINE_NOT_FOUND;
- } else {
- g_is_engine = true;
- }
- }
-
/* check if pid is valid */
if (false == vcd_client_manager_is_valid(pid)) {
SLOG(LOG_ERROR, TAG_VCD, "[Server] old manager pid(%d) be removed", vcd_client_manager_get_pid());
}
int ret = 0;
- vcp_audio_type_e type = VCP_AUDIO_TYPE_PCM_S16_LE;
+ vce_audio_type_e type = VCE_AUDIO_TYPE_PCM_S16_LE;
int rate = 16000;
int channel = 1;
*/
int vcd_server_initialize(int pid)
{
- if (false == g_is_engine) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- g_is_engine = false;
- return VCD_ERROR_ENGINE_NOT_FOUND;
- } else {
- g_is_engine = true;
- }
- }
-
if (false == vcd_engine_is_available_engine()) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- return VCD_ERROR_ENGINE_NOT_FOUND;
- }
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+ return VCD_ERROR_ENGINE_NOT_FOUND;
}
/* check if pid is valid */
*/
int vcd_server_widget_initialize(int pid)
{
- if (false == g_is_engine) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- g_is_engine = false;
- return VCD_ERROR_ENGINE_NOT_FOUND;
- } else {
- g_is_engine = true;
- }
- }
-
if (false == vcd_engine_is_available_engine()) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- return VCD_ERROR_ENGINE_NOT_FOUND;
- }
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+ return VCD_ERROR_ENGINE_NOT_FOUND;
}
/* check if pid is valid */
}
return ret;
-}
\ No newline at end of file
+}
+/*
+* For engine service
+*/
+int vcd_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get foreach command");
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] input parameter is NULL");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = 0;
+ ret = vcd_engine_agent_get_foreach_command(vce_command, callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get foreach command : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_get_command_count(vce_cmd_h vce_command)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get command count");
+
+ int ret = 0;
+ ret = vcd_engine_agent_get_command_count(vce_command);
+ if (0 > ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get command count : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_get_audio_type(char** audio_type)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get audio type");
+
+ int ret = 0;
+ ret = vcd_engine_agent_get_audio_type(audio_type);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get audio type : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_private_data(const char* key, const char* data)
+{
+ vcd_state_e state = vcd_config_get_service_state();
+
+ if (VCD_STATE_READY != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state(%d) is NOT 'READY'", state);
+ return VCD_ERROR_INVALID_STATE;
+ }
+
+ int ret = vcd_engine_agent_set_private_data(key, data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data to the manager client : ret(%d)", ret);
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data to the manager client, key(%s), data(%s)", key, data);
+ }
+
+ return ret;
+}
+
+int vcd_get_private_data(const char* key, char** data)
+{
+ vcd_state_e state = vcd_config_get_service_state();
+
+ if (VCD_STATE_READY != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state(%d) is NOT 'READY'", state);
+ return VCD_ERROR_INVALID_STATE;
+ }
+
+ int ret = vcd_engine_agent_get_private_data(key, data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get private data from the manager client : ret(%d)", ret);
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get private data from the manager client, key(%s), data(%s)", key, data);
+ }
+
+ return ret;
+}
+
+int vcd_start_recording()
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Start recording");
+
+ int ret = 0;
+ ret = vcd_engine_agent_start_recording();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recording : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_stop_recording()
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Stop recording");
+
+ int ret = 0;
+ ret = vcd_engine_agent_stop_recording();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to stop recording : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_private_data_set_cb(vce_private_data_set_cb callback_func)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data set cb");
+
+ int ret = 0;
+ ret = vcd_engine_agent_set_private_data_set_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data set cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data requested cb");
+
+ int ret = 0;
+ ret = vcd_engine_agent_set_private_data_requested_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data requested cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set nlu base info requested cb");
+
+ int ret = 0;
+ ret = vcd_engine_agent_set_nlu_base_info_requested_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set nlu base info requested cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
#include "vcd_main.h"
#include "vcd_client_data.h"
+#include "vce.h"
+
#ifdef __cplusplus
extern "C" {
#endif
/*
* Daemon functions
*/
-int vcd_initialize();
+int vcd_initialize(vce_request_callback_s *callback);
void vcd_finalize();
int vcd_server_set_language(const char* language);
+/*
+* For engine service
+*/
+int vcd_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, void *user_data);
+
+int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data);
+
+int vcd_send_nlg_result(const char* nlg_result, void *user_data);
+
+int vcd_send_error(vce_error_e error, const char* msg, void *user_data);
+
+int vcd_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data);
+
+int vcd_get_command_count(vce_cmd_h vce_command);
+
+int vcd_get_audio_type(char** audio_type);
+
+int vcd_set_private_data(const char* key, const char* data);
+
+int vcd_get_private_data(const char* key, char** data);
+
+int vcd_start_recording();
+
+int vcd_stop_recording();
+
+int vcd_set_private_data_set_cb(vce_private_data_set_cb callback_func);
+
+int vcd_set_private_data_requested_cb(vce_private_data_requested_cb callback_func);
+
+int vcd_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func);
+
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+* Copyright (c) 2011-2017 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 "vcd_dbus.h"
+#include "vcd_main.h"
+#include "vcd_server.h"
+
+#include "vce.h"
+
+
+int vce_main(int argc, char** argv, vce_request_callback_s *callback)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "===== VC Engine Service Initialize");
+
+ int ret = VCE_ERROR_NONE;
+
+ if (!ecore_init()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()");
+ return VCE_ERROR_OPERATION_FAILED;
+ }
+
+ if (0 != vcd_dbus_open_connection()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection");
+ ecore_shutdown();
+ return VCE_ERROR_OPERATION_FAILED;
+ }
+
+ ret = vcd_initialize(callback);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize");
+ vcd_dbus_close_connection();
+ ecore_shutdown();
+ return ret;
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCD, "[Main] VC Engine Service start...");
+
+ SLOG(LOG_DEBUG, TAG_VCD, "=====");
+ SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, " ");
+
+ return 0;
+}
+
+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, void *user_data)
+{
+ int ret = VCE_ERROR_NONE;
+
+ if (NULL == all_result || NULL == non_fixed_result || NULL == nlu_result) {
+ SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
+ }
+
+ ret = vcd_send_result(event, result_id, count, all_result, non_fixed_result, nlu_result, msg, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send result");
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send result");
+ }
+
+ return ret;
+}
+
+
+int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
+{
+ int ret = VCE_ERROR_NONE;
+
+ if (NULL == asr_result) {
+ SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
+ }
+
+ ret = vcd_send_asr_result(event, asr_result, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send ASR result");
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send ASR result");
+ }
+
+ return ret;
+}
+
+int vce_send_nlg_result(const char* nlg_result, void *user_data)
+{
+ int ret = VCE_ERROR_NONE;
+
+ if (NULL == nlg_result) {
+ SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
+ }
+
+ ret = vcd_send_nlg_result(nlg_result, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send NLG result");
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send NLG result");
+ }
+
+ return ret;
+}
+
+int vce_send_error(vce_error_e error, const char* msg, void *user_data)
+{
+ int ret = VCE_ERROR_NONE;
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Input parameter is NULL. (no error message)");
+ }
+
+ ret = vcd_send_error(error, msg, user_data);
+
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send error");
+ }
+
+ return ret;
+}
+
+
+/* Daemon API */
+int vce_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data)
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_get_foreach_command(vce_command, callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get foreach command");
+ }
+
+ return ret;
+}
+
+int vce_get_command_count(vce_cmd_h vce_command)
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_get_command_count(vce_command);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get command count");
+ }
+
+ return ret;
+}
+
+int vce_get_audio_type(char** audio_type)
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_get_audio_type(audio_type);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get audio type");
+ }
+
+ return ret;
+}
+
+int vce_set_private_data(const char* key, const char* data)
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_set_private_data(key, data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data to vc manager");
+ }
+
+ return ret;
+}
+
+int vce_get_private_data(const char* key, char** data)
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_get_private_data(key, data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get private data from vc manager");
+ }
+
+ return ret;
+}
+
+int vce_start_recording()
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_start_recording();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to start recording");
+ }
+
+ return ret;
+}
+
+int vce_stop_recording()
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_stop_recording();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to stop recording");
+ }
+
+ return ret;
+}
+
+int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func)
+{
+ if (NULL == callback_func) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
+ return VCE_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = vcd_set_private_data_set_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data set cb");
+ }
+
+ return ret;
+}
+
+int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
+{
+ if (NULL == callback_func) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
+ return VCE_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = vcd_set_private_data_requested_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data requested cb");
+ }
+
+ return ret;
+}
+
+int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func)
+{
+ if (NULL == callback_func) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
+ return VCE_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = vcd_set_nlu_base_info_requested_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set nlu-base info requested cb");
+ }
+
+ return ret;
+}