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[out] engine_uuid The engine id
-* @param[out] engine_name The engine name
-* @param[out] engine_setting The setting path name
-* @param[out] use_network @c true to need network @c false not to need network.
-*/
-typedef int (*vce_get_info_cb)(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network);
-
-
-/**
-* Daemon API.
-*/
-
-/**
-* @brief Called to retrieve the commands.
-*
-* @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[out] user_info A user info (e.g. If ASR result is consumed, the value is 0x01. If not, the value is 0x00.)
-* @param[in] user_data The user data passed from set callback function
-*
-* @pre The vce_main() function should be invoked before this function is called.
-* vce_stop_cb() will invoke this callback.
-*
-* @see vce_stop_cb()
-*/
-int vce_send_result(vce_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, void *user_data);
-
-/**
-* @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}
/**
* @brief Definition of Wi-Fi audio-in type.
*/
-#define VC_AUDIO_TYPE_WIFI "VC_AUDIO_ID_WIFI" /**< Wi-Fi audio type */
+#define VC_AUDIO_TYPE_MSF "VC_AUDIO_ID_MSF" /**< MSF (wifi) audio type */
/**
* @brief Definition for foreground command type.
--- /dev/null
+/*\r
+* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the License);\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an AS IS BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*/\r
+\r
+\r
+#ifndef __VOICE_CONTROL_PLUGIN_ENGINE_H__\r
+#define __VOICE_CONTROL_PLUGIN_ENGINE_H__\r
+\r
+#include <tizen.h>\r
+\r
+/**\r
+* @addtogroup VOICE_CONTROL_PLUGIN_ENGINE\r
+* @{\r
+*/\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+* @brief Enumerations of error codes.\r
+*/\r
+typedef enum {\r
+ VCP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */\r
+ VCP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */\r
+ VCP_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */\r
+ VCP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */\r
+ VCP_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Out of network */\r
+ VCP_ERROR_INVALID_STATE = -0x0100031, /**< Invalid state */\r
+ VCP_ERROR_INVALID_LANGUAGE = -0x0100032, /**< Invalid language */\r
+ VCP_ERROR_OPERATION_FAILED = -0x0100034, /**< Operation failed */\r
+ VCP_ERROR_NOT_SUPPORTED_FEATURE = -0x0100035 /**< Not supported feature */\r
+} vcp_error_e;\r
+\r
+/**\r
+* @brief Enumerations of audio type.\r
+*/\r
+typedef enum {\r
+ VCP_AUDIO_TYPE_PCM_S16_LE = 0, /**< Signed 16bit audio type, Little endian */\r
+ VCP_AUDIO_TYPE_PCM_U8 /**< Unsigned 8bit audio type */\r
+} vcp_audio_type_e;\r
+\r
+/**\r
+* @brief Enumerations of callback event.\r
+*/\r
+typedef enum {\r
+ VCP_RESULT_EVENT_SUCCESS = 0, /**< Event when the recognition full result is ready */\r
+ VCP_RESULT_EVENT_REJECTED, /**< Event when the recognition result is rejected */\r
+ VCP_RESULT_EVENT_ERROR /**< Event when the recognition has failed */\r
+} vcp_result_event_e;\r
+\r
+/**\r
+* @brief Enumerations of command type.\r
+*/\r
+typedef enum {\r
+ VCP_COMMAND_FORMAT_FIXED = 0, /**< Fixed command */\r
+ VCP_COMMAND_FORMAT_FIXED_AND_VFIXED, /**< Fixed command + variable-fixed command */\r
+ VCP_COMMAND_FORMAT_VFIXED_AND_FIXED, /**< variable-fixed command + Fixed command */\r
+ VCP_COMMAND_FORMAT_FIXED_AND_NONFIXED, /**< Fixed command + Non-fixed command */\r
+ VCP_COMMAND_FORMAT_NONFIXED_AND_FIXED, /**< Non-fixed command + Fixed command */\r
+ VCP_COMMAND_FORMAT_ACTION,\r
+ VCP_COMMAND_FORMAT_PARTIAL\r
+} vcp_command_format_e;\r
+\r
+/**\r
+* @brief Definition for foreground command type.\r
+* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
+*/\r
+#define VCP_COMMAND_TYPE_FOREGROUND 1\r
+\r
+/**\r
+* @brief Definition for background command type.\r
+* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
+*/\r
+#define VCP_COMMAND_TYPE_BACKGROUND 2\r
+\r
+/**\r
+* @brief Definition for widget command type.\r
+* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
+*/\r
+#define VCP_COMMAND_TYPE_WIDGET 3\r
+\r
+/**\r
+* @brief Definition for system command type.\r
+* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
+*/\r
+#define VCP_COMMAND_TYPE_SYSTEM 4\r
+\r
+/**\r
+* @brief Definition for exclusive command type.\r
+* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
+*/\r
+#define VCP_COMMAND_TYPE_SYSTEM_BACKGROUND 5\r
+\r
+/**\r
+* @brief Definitions for exclusive command type.\r
+* @since_tizen 2.4\r
+*/\r
+#define VCP_COMMAND_TYPE_EXCLUSIVE 6\r
+\r
+\r
+/**\r
+* @brief Enumerations of speech detect.\r
+*/\r
+typedef enum {\r
+ VCP_SPEECH_DETECT_NONE = 0, /**< No event */\r
+ VCP_SPEECH_DETECT_BEGIN, /**< Begin of speech detected */\r
+ VCP_SPEECH_DETECT_END, /**< End of speech detected */\r
+} vcp_speech_detect_e;\r
+\r
+typedef enum {\r
+ VCP_ASR_RESULT_EVENT_FINAL_RESULT = 0,\r
+ VCP_ASR_RESULT_EVENT_PARTIAL_RESULT,\r
+ VCP_ASR_RESULT_EVENT_ERROR\r
+} vcp_asr_result_event_e;\r
+\r
+/**\r
+* @brief A structure of handle for VC command\r
+*/\r
+typedef int vcp_cmd_h;\r
+\r
+/**\r
+ * @brief Definition of bluetooth audio id.\r
+*/\r
+#define VCP_AUDIO_ID_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio id */\r
+\r
+/**\r
+ * @brief Definition of MSF(wifi) audio id.\r
+*/\r
+#define VCP_AUDIO_ID_MSF "VC_AUDIO_ID_MSF" /**< MSF (wifi) audio id */\r
+\r
+/**\r
+* @brief Definition for none message.\r
+*/\r
+#define VC_RESULT_MESSAGE_NONE "vc.result.message.none"\r
+\r
+/**\r
+* @brief Definition for failed recognition because the speech is too loud to listen.\r
+*/\r
+#define VC_RESULT_MESSAGE_ERROR_TOO_LOUD "vc.result.message.error.too.loud"\r
+\r
+\r
+/**\r
+* @brief Called when the daemon gets synthesized result.\r
+*\r
+* @param[in] event A result event\r
+* @param[in] result_id Result ids\r
+* @param[in] count Result count\r
+* @param[in] all_result All result text\r
+* @param[in] non_fixed_result Non-fixed command result text\r
+* @param[in] nlu_result NLU result text\r
+* @param[in] msg Engine message (e.g. #VC_RESULT_MESSAGE_NONE, #VC_RESULT_MESSAGE_ERROR_TOO_LOUD)\r
+* @param[out] user_info A user info (e.g. If ASR result is consumed, the value is 0x01. If not, the value is 0x00.)\r
+* @param[in] user_data The user data passed from set callback function\r
+*\r
+* @pre vcpe_stop() will invoke this callback.\r
+*\r
+* @see vcpe_stop()\r
+*/\r
+typedef void (*vcpe_result_cb)(vcp_result_event_e event, int* result_id, int count,\r
+ const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, void *user_data);\r
+\r
+\r
+/**\r
+* @brief Called when the daemon gets ASR result.\r
+*\r
+* @param[in] event A asr result event\r
+* @param[in] pre_result result text\r
+* @param[in] user_data The user data passed from the start\r
+*/\r
+typedef void (*vcpe_asr_result_cb)(vcp_asr_result_event_e event, const char* asr_result, void *user_data);\r
+\r
+/**\r
+* @brief Called when the daemon gets nlg result.\r
+*\r
+* @param[in] nlg_result Nlg result\r
+* @param[in] user_data The user data passed from the start\r
+*/\r
+typedef void (*vcpe_nlg_result_cb)(const char* nlg_result, void *user_data);\r
+\r
+/**\r
+* @brief Called when the daemon gets error.\r
+*\r
+* @param[in] error Error type\r
+* @param[in] msg Error message\r
+* @param[in] user_data The user data passed from set callback function\r
+*\r
+*/\r
+typedef void (*vcpe_error_cb)(vcp_error_e error, const char* msg, void *user_data);\r
+\r
+/**\r
+* @brief Called to retrieve the supported languages.\r
+*\r
+* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code\r
+* followed by ISO 639-1 for the two-letter language code \n\r
+* For example, "ko_KR" for Korean, "en_US" for American English\r
+* @param[in] user_data The user data passed from the foreach function\r
+*\r
+* @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop\r
+*\r
+* @pre vcpe_foreach_supported_languages() will invoke this callback.\r
+*\r
+* @see vcpe_foreach_supported_languages()\r
+*/\r
+typedef bool (*vcpe_supported_language_cb)(const char* language, void* user_data);\r
+\r
+/**\r
+* @brief Initializes the engine.\r
+*\r
+* @param[in] result_cb A callback function for recognition result\r
+* @param[in] silence_cb A callback function for silence detection\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_INVALID_STATE Already initialized\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+*\r
+* @see vcpe_deinitialize()\r
+*/\r
+typedef int (*vcpe_initialize)(void);\r
+\r
+/**\r
+* @brief Deinitializes the engine\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_STATE Not initialized\r
+*\r
+* @see vcpe_initialize()\r
+*/\r
+typedef void (*vcpe_deinitialize)(void);\r
+\r
+/**\r
+* @brief Registers a callback function for getting recognition result.\r
+*\r
+* @param[in] callback Callback function to register\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+*\r
+* @see vcpe_result_cb()\r
+*/\r
+typedef int (*vcpe_set_result_cb)(vcpe_result_cb callback, void* user_data);\r
+\r
+/**\r
+* @brief Registers a callback function for getting ASR recognition result.\r
+*\r
+* @param[in] callback Callback function to register\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+*\r
+* @see vcpe_asr_result_cb()\r
+*/\r
+typedef int (*vcpe_set_asr_result_cb)(vcpe_asr_result_cb callback, void* user_data);\r
+\r
+/**\r
+* @brief Registers a callback function for getting nlg result.\r
+*\r
+* @param[in] callback Callback function to register\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+*\r
+*/\r
+typedef int (*vcpe_set_nlg_result_cb)(vcpe_nlg_result_cb, void* user_data);\r
+\r
+#if 0\r
+/**\r
+* @brief Registers a callback function for getting partial recognition result.\r
+*\r
+* @param[in] callback Callback function to register\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+*\r
+* @see vcpe_pre_result_cb()\r
+*/\r
+typedef int (*vcpe_set_pre_result_cb)(vcpe_pre_result_cb callback, void* user_data);\r
+#endif\r
+\r
+/**\r
+* @brief Registers a callback function for error.\r
+*\r
+* @param[in] callback Callback function to register\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+*\r
+*/\r
+typedef int (*vcpe_set_error_cb)(vcpe_error_cb callback, void* user_data);\r
+\r
+#if 0\r
+/**\r
+* @brief Registers a callback function for getting NLU result.\r
+*\r
+* @param[in] callback Callback function to register\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+*\r
+*/\r
+typedef int (*vcpe_set_nlu_result_cb)(vcpe_nlu_result_cb, void* user_data);\r
+#endif\r
+\r
+/**\r
+* @brief Gets recording format of the engine.\r
+*\r
+* @param[in] audio_id The audio device id.\r
+* @param[out] types The format used by the recorder.\r
+* @param[out] rate The sample rate used by the recorder.\r
+* @param[out] channels The number of channels used by the recorder.\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Not initialized\r
+*/\r
+typedef int (*vcpe_get_recording_format)(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels);\r
+\r
+/**\r
+* @brief Retrieves all supported languages of the engine.\r
+*\r
+* @param[in] callback a callback function\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_INVALID_STATE Not initialized\r
+*\r
+* @post This function invokes vcpe_supported_language_cb() repeatedly for getting supported languages.\r
+*\r
+* @see vcpe_supported_language_cb()\r
+*/\r
+typedef int (*vcpe_foreach_supported_languages)(vcpe_supported_language_cb callback, void* user_data);\r
+\r
+/**\r
+* @brief Checks whether a language is supported or not.\r
+*\r
+* @param[in] language A language\r
+*\r
+* @return @c true = supported, \n @c false = not supported.\r
+*/\r
+typedef bool (*vcpe_is_language_supported)(const char* language);\r
+\r
+/**\r
+* @brief Sets language.\r
+*\r
+* @param[in] language language.\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_LANGUAGE Invalid language\r
+* @retval #VCP_ERROR_INVALID_STATE Not initialized\r
+*/\r
+typedef int (*vcpe_set_language)(const char* language);\r
+\r
+/**\r
+* @brief Sets command list before recognition.\r
+*\r
+* @remark This function should set commands via vcpd_foreach_command().\r
+*\r
+* @param[in] vcp_command command handle.\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_INVALID_STATE Invalid state\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+* @retval #VCP_ERROR_NOT_SUPPORTED_FEATURE Not supported command type\r
+*\r
+* @post vcpe_start() is called after this function is successful.\r
+*\r
+* @see vcpe_start()\r
+* @see vcpd_foreach_command()\r
+* @see vcpe_unset_commands()\r
+*/\r
+typedef int (*vcpe_set_commands)(vcp_cmd_h vcp_command);\r
+\r
+/**\r
+* @brief Unset command list for reset.\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_INVALID_STATE Invalid state\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+*\r
+* @see vcpe_set_commands()\r
+*/\r
+typedef int (*vcpe_unset_commands)();\r
+\r
+/**\r
+* @brief Start recognition.\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_INVALID_STATE Invalid state\r
+* @retval #VCP_ERROR_INVALID_LANGUAGE Invalid language\r
+* @retval #VCP_ERROR_OUT_OF_NETWORK Out of network\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+*\r
+* @pre vcpd_foreach_command() is successful.\r
+*\r
+* @see vcpe_set_recording_data()\r
+* @see vcpe_stop()\r
+* @see vcpe_cancel()\r
+*/\r
+typedef int (*vcpe_start)(bool stop_by_silence);\r
+\r
+/**\r
+* @brief Sets recording data for speech recognition from recorder.\r
+*\r
+* @remark This function should be returned immediately after recording data copy.\r
+*\r
+* @param[in] data A recording data\r
+* @param[in] length A length of recording data\r
+* @param[out] silence_detected @c true Silence detected \n @c false No silence detected\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_INVALID_STATE Invalid state\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+*\r
+* @pre vcpe_start() is successful.\r
+*\r
+* @see vcpe_start()\r
+* @see vcpe_cancel()\r
+* @see vcpe_stop()\r
+*/\r
+typedef int(*vcpe_set_recording_data)(const void* data, unsigned int length, vcp_speech_detect_e* speech_detected);\r
+\r
+/**\r
+* @brief Stops to get the result of recognition.\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_STATE Invalid state\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+* @retval #VCP_ERROR_OUT_OF_NETWORK Out of network\r
+*\r
+* @pre vcpe_set_recording_data() is successful.\r
+*\r
+* @see vcpe_start()\r
+* @see vcpe_set_recording_data()\r
+* @see vcpe_result_cb()\r
+* @see vcpe_cancel()\r
+*/\r
+typedef int (*vcpe_stop)(void);\r
+\r
+/**\r
+* @brief Cancels the recognition process.\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+* @retval #VCP_ERROR_NONE Successful.\r
+* @retval #VCP_ERROR_INVALID_STATE Invalid state.\r
+*\r
+* @pre vcpe_start() is successful.\r
+*\r
+* @see vcpe_start()\r
+* @see vcpe_stop()\r
+*/\r
+typedef int (*vcpe_cancel)(void);\r
+\r
+/**\r
+* @brief Set audio recording type.\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+* @retval #VCP_ERROR_NONE Successful.\r
+*\r
+*/\r
+typedef int (*vcpe_set_audio_type)(const char* audio);\r
+\r
+/**\r
+* @brief Sets domain (Agent or device type)\r
+*\r
+* @param[in] domain available Agent or device type\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpe_set_domain)(const char* domain);\r
+\r
+/**\r
+* @brief Gets essential value from nlu result. This function is available inside vcpe_nlu_result_cb()\r
+*\r
+* @param[in] key NLU base info key\r
+* @parma[out] value NLU base info value\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpe_get_nlu_base_info)(const char* key, char** value);\r
+\r
+/**\r
+* @brief Sets private data between app and engine.\r
+*\r
+* @param[in] key Private key\r
+* @param[in] data Private data\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpe_set_private_data)(const char* key, const char* data);\r
+\r
+/**\r
+* @brief Gets private data between app and engine.\r
+*\r
+* @param[in] key Private key\r
+* @param[out] data Private data\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpe_get_private_data)(const char* key, char** data);\r
+\r
+/**\r
+* @brief Request process text.\r
+*\r
+* @param[in] text Requested text\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpe_process_text)(const char* text);\r
+\r
+/**\r
+* @brief Request list event.\r
+*\r
+* @param[in] event Requested list event\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpe_process_list_event)(const char* event);\r
+\r
+/**\r
+* @brief Request haptic event.\r
+*\r
+* @param[in] event Requested haptic event\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpe_process_haptic_event)(const char* event);\r
+\r
+/**\r
+* Daemon API.\r
+*/\r
+\r
+/**\r
+* @brief Called to retrieve the commands.\r
+*\r
+* @param[in] id command id\r
+* @param[in] type command type\r
+* @param[in] format command format\r
+* @param[in] command command text\r
+* @param[in] param parameter text\r
+* @param[in] domain command domain\r
+* @param[in] user_data The user data passed from the foreach function\r
+*\r
+* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.\r
+* @pre vcpd_foreach_command() will invoke this callback.\r
+*\r
+* @see vcpd_foreach_command()\r
+*/\r
+typedef bool (*vcpd_foreach_command_cb)(int id, int type, int format, const char* command, const char* param, int domain, void* user_data);\r
+\r
+/**\r
+* @brief Retrieves all commands using callback function.\r
+*\r
+* @param[in] vcp_command The handle to be passed to the vcpe_set_commands() function\r
+* @param[in] callback The callback function to invoke\r
+* @param[in] user_data The user data to be passed to the callback function\r
+*\r
+* @return 0 on success, otherwise a negative error value\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failure\r
+* @retval #VCP_ERROR_INVALID_STATE Invalid state\r
+*\r
+* @post This function invokes vcpd_foreach_command_cb() repeatedly for getting commands.\r
+*\r
+* @see vcpd_foreach_command_cb()\r
+* @see vcpe_set_commands()\r
+*/\r
+typedef int (*vcpd_foreach_command)(vcp_cmd_h vcp_command, vcpd_foreach_command_cb callback, void* user_data);\r
+\r
+/**\r
+* @brief Gets command length.\r
+*\r
+* @param[in] vcp_command The handle to be passed to the vcpe_set_commands() function\r
+*\r
+* @return the value greater than 0 on success, otherwise a negative error value\r
+*\r
+* @see vcpe_set_commands()\r
+*/\r
+typedef int (*vcpd_get_command_count)(vcp_cmd_h vcp_command);\r
+\r
+/**\r
+* @brief Gets current audio type.\r
+*\r
+* @remarks audio_type must be released using free() when it is no longer required.\r
+*\r
+* @param[in] audio_type Current audio type (e.g. #VCP_AUDIO_ID_BLUETOOTH or usb device id)\r
+*\r
+* @return the value greater than 0 on success, otherwise a negative error value\r
+*\r
+*/\r
+typedef int (*vcpd_get_audio_type)(char** audio_type);\r
+\r
+/**\r
+* @brief Sets private data to Manager client.\r
+*\r
+* @param[in] key Private key\r
+* @param[in] data Private data\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpd_set_private_data)(const char* key, const char* data);\r
+\r
+/**\r
+* @brief Gets private data from Manager client.\r
+*\r
+* @param[in] key Private key\r
+* @param[out] data Private data\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpd_get_private_data)(const char* key, char** data);\r
+\r
+/**\r
+* @brief Request start recording.\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpd_start_recording)();\r
+\r
+/**\r
+* @brief Request stop recording.\r
+*\r
+* @return 0 on success, otherwise a negative error value.\r
+*\r
+*/\r
+typedef int (*vcpd_stop_recording)();\r
+\r
+/**\r
+* @brief A structure of the engine functions.\r
+*/\r
+typedef struct {\r
+ int size; /**< Size of structure */\r
+ int version; /**< Version */\r
+\r
+ vcpe_initialize initialize; /**< Initialize engine */\r
+ vcpe_deinitialize deinitialize; /**< Shutdown engine */\r
+\r
+ /* Get engine information */\r
+ vcpe_get_recording_format get_recording_format; /**< Get recording format */\r
+ vcpe_foreach_supported_languages foreach_langs; /**< Foreach language list */\r
+ vcpe_is_language_supported is_lang_supported; /**< Check language */\r
+\r
+ /* Set info */\r
+ vcpe_set_result_cb set_result_cb; /**< Set result callback */\r
+ vcpe_set_language set_language; /**< Set language */\r
+ vcpe_set_commands set_commands; /**< Request to set current commands */\r
+ vcpe_unset_commands unset_commands; /**< Request to unset current commands */\r
+\r
+ /* Control recognition */\r
+ vcpe_start start; /**< Start recognition */\r
+ vcpe_set_recording_data set_recording; /**< Set recording data */\r
+ vcpe_stop stop; /**< Stop recording for getting result */\r
+ vcpe_cancel cancel; /**< Cancel recording and processing */\r
+\r
+ vcpe_set_audio_type set_audio_type; /**< Set audio type */\r
+\r
+ //vcpe_set_pre_result_cb set_pre_result_cb; /**< Set pre result callback */\r
+ vcpe_set_asr_result_cb set_asr_result_cb; /**< Set asr result callback */\r
+ vcpe_set_nlg_result_cb set_nlg_result_cb; /**< Set nlg result callback */\r
+ vcpe_set_error_cb set_error_cb; /**< Set error callback */\r
+ vcpe_set_domain set_domain; /**< Set domain */\r
+ vcpe_get_nlu_base_info get_nlu_base_info; /**< Get essential info */\r
+ //vcpe_set_nlu_result_cb set_nlu_result_cb; /**< Set nlu result callback */\r
+ vcpe_set_private_data set_private_data; /**< Set private data */\r
+ vcpe_get_private_data get_private_data; /**< Get private data */\r
+ vcpe_process_text process_text; /**< Request to process text */\r
+ vcpe_process_list_event process_list_event; /**< Request to process list event */\r
+ vcpe_process_haptic_event process_haptic_event; /**< Request to process haptic event */\r
+} vcpe_funcs_s;\r
+\r
+/**\r
+* @brief A structure of the daemon functions.\r
+*/\r
+typedef struct {\r
+ int size; /**< Size of structure */\r
+ int version; /**< Version */\r
+\r
+ vcpd_foreach_command foreach_command; /**< Foreach command */\r
+ vcpd_get_command_count get_command_count; /**< Get command count */\r
+\r
+ vcpd_get_audio_type get_audio_type; /**< Get audio type */\r
+\r
+ vcpd_set_private_data set_private_data; /**< Set private data to Manager */\r
+ vcpd_get_private_data get_private_data; /**< Get private data from Manager */\r
+\r
+ vcpd_start_recording start_recording; /**< Request start recording */\r
+ vcpd_stop_recording stop_recording; /**< Request stop recording */\r
+} vcpd_funcs_s;\r
+\r
+/**\r
+* @brief Loads the engine.\r
+*\r
+* @param[in] pdfuncs The daemon functions\r
+* @param[out] pefuncs The engine functions\r
+*\r
+* @return This function returns zero on success, or negative with error code on failure\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+*\r
+* @pre The vcp_get_engine_info() should be successful.\r
+* @post The daemon calls engine functions of vcpe_funcs_s.\r
+*\r
+* @see vcp_get_engine_info()\r
+* @see vcp_unload_engine()\r
+*/\r
+int vcp_load_engine(vcpd_funcs_s* pdfuncs, vcpe_funcs_s* pefuncs);\r
+\r
+/**\r
+* @brief Unloads this engine by the daemon.\r
+*\r
+* @pre The vcp_load_engine() should be successful.\r
+*\r
+* @see vcp_load_engine()\r
+*/\r
+void vcp_unload_engine(void);\r
+\r
+/**\r
+* @brief Called to get the engine base information.\r
+*\r
+* @param[in] engine_uuid The engine id\r
+* @param[in] engine_name The engine name\r
+* @param[in] engine_setting The setting ug name\r
+* @param[in] use_network @c true to need network @c false not to need network.\r
+* @param[in] user_data The User data passed from vcp_get_engine_info()\r
+*\r
+* @pre vcp_get_engine_info() will invoke this callback.\r
+*\r
+* @see vcp_get_engine_info()\r
+*/\r
+typedef void (*vcpe_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* engine_setting,\r
+ bool use_network, void* user_data);\r
+\r
+/**\r
+* @brief Gets the engine base information before the engine is loaded by the daemon.\r
+*\r
+* @param[in] callback Callback function\r
+* @param[in] user_data User data to be passed to the callback function\r
+*\r
+* @return This function returns zero on success, or negative with error code on failure\r
+* @retval #VCP_ERROR_NONE Successful\r
+* @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
+* @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
+*\r
+* @post This function invokes vcpe_engine_info_cb() for getting engine information.\r
+*\r
+* @see vcpe_engine_info_cb()\r
+* @see vcp_load_engine()\r
+*/\r
+int vcp_get_engine_info(vcpe_engine_info_cb callback, void* user_data);\r
+\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+/**\r
+* @}@}\r
+*/\r
+\r
+#endif /* __VOICE_CONTROL_PLUGIN_ENGINE_H__ */\r
[D-BUS Service]
Name=org.tizen.voice.vcserver
-#Exec=/usr/bin/vc-daemon
-Exec=/bin/sh -c "launch_app org.tizen.vc-engine-default"
+Exec=/usr/bin/vc-daemon
%{_libdir}/libvc_setting.so
%{_libdir}/libvc_widget.so
%{_libdir}/libvc_manager.so
-%{_libdir}/libvc_engine.so
+%{_bindir}/vc-daemon
%{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}/vce.h
-
+%{_includedir}/voice_control_plugin_engine.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)
-
-## 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)
+INSTALL(TARGETS "${PROJECT_NAME}-daemon" DESTINATION bin)
return VCD_ERROR_OPERATION_FAILED;
}
-// int id_count = 1;
+ // int id_count = 1;
GSList *iter = NULL;
vc_cmd_s* temp_cmd;
temp_cmd = iter->data;
SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Widget : id(%d) type(%d) format(%d) command(%s) domain(%d)"
- , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->domain);
+ , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->domain);
callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
temp_cmd = iter->data;
SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Fore : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d) fixed(%s)"
- , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, temp_cmd->fixed);
+ , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, temp_cmd->fixed);
callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
temp_cmd = iter->data;
SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] System : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d)"
- , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
+ , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
temp_cmd = iter->data;
SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] System background : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d)"
- , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
+ , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
temp_cmd = iter->data;
SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Exclusive system : id(%d) type(%d) format(%d) command(%s) param(%s) domain(%d)"
- , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
+ , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain);
callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
temp_cmd = iter->data;
SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Back : id(%d) format(%d) type(%d) command(%s) param(%s) domain(%d) appid(%s) invocation(%s) fixed(%s)"
- , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, temp_cmd->appid, temp_cmd->invocation_name, temp_cmd->fixed);
+ , temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, temp_cmd->appid, temp_cmd->invocation_name, temp_cmd->fixed);
callback(temp_cmd->id, temp_cmd->type, temp_cmd->format, temp_cmd->command, temp_cmd->parameter, temp_cmd->domain, user_data);
bool use_network;
void *handle;
- vc_engine_callback_s* callbacks;
+ vcpe_funcs_s* pefuncs;
+ vcpd_funcs_s* pdfuncs;
+
+ int (*vcp_load_engine)(vcpd_funcs_s* pdfuncs, vcpe_funcs_s* pefuncs);
+ int (*vcp_unload_engine)();
} vcengine_s;
typedef struct _vcengine_info {
/** 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();
+
/** get engine info */
-int __internal_get_engine_info(vce_request_callback_s* callback);
+int __internal_get_engine_info(const char* filepath, vcengine_info_s** info);
+
+int __log_enginelist();
/*
* VCS Engine Agent Interfaces
*/
-int vcd_engine_agent_init()
+//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)
{
- if (true == g_agent_init) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Already initialized");
- return VCD_ERROR_NONE;
+ 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;
}
/* init dynamic engine */
g_dynamic_engine.is_loaded = false;
g_dynamic_engine.handle = NULL;
g_dynamic_engine.is_command_ready = false;
-
- 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_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_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;
+
if (0 != vcd_config_get_default_language(&g_default_lang)) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] There is No default voice in config");
/* Set default voice */
/* 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.callbacks) {
- free(g_dynamic_engine.callbacks);
- g_dynamic_engine.callbacks = NULL;
+ 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;
}
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 __internal_get_engine_info(vce_request_callback_s* callback)
+int vcd_engine_agent_initialize_current_engine()
{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] inside __internal_get_engine_info");
+ /* check agent init */
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
- if (NULL == callback) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine");
+ /* 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");
return VCD_ERROR_ENGINE_NOT_FOUND;
}
- if (NULL == callback->get_info) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine");
+ /* 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 {
return VCD_ERROR_ENGINE_NOT_FOUND;
}
- if (0 != callback->get_info(&(g_dynamic_engine.engine_uuid), &(g_dynamic_engine.engine_name), &(g_dynamic_engine.engine_setting_path), &(g_dynamic_engine.use_network))) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine info");
+ if (NULL == dynamic_engine) {
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, "@@@");
+
}
- if (NULL != g_dynamic_engine.callbacks) {
- free(g_dynamic_engine.callbacks);
- g_dynamic_engine.callbacks = NULL;
+ 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);
+ }
}
- 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 -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;
+
+ if (0 != access(filepath, F_OK)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to access file (%s)", filepath);
+ return -1;
+ } else {
+ handle = dlopen(filepath, RTLD_LAZY);
+ if (!handle) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine : %s", filepath);
+ if ((error = dlerror()) != NULL) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] %s", error);
+ }
+ return -1;
+ }
+ }
+
+ /* 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);
return VCD_ERROR_OUT_OF_MEMORY;
}
- 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;
+ /* 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);
SLOG(LOG_DEBUG, TAG_VCD, "@@@ Valid Engine");
- 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, "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, "@@@");
+ *info = temp;
+
return 0;
}
-int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback)
+int __internal_update_engine_list()
{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] load current engine START");
+ /* relsease engine list */
+ GList *iter = NULL;
+ vcengine_info_s *data = NULL;
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
- return VCD_ERROR_OPERATION_FAILED;
+ 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;
+
+ 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 (true == g_dynamic_engine.is_loaded) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Engine has already been loaded");
- return 0;
+ /* 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 (NULL == callback) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine");
+ if (0 >= g_list_length(g_engine_list)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] No Engine");
return VCD_ERROR_ENGINE_NOT_FOUND;
}
- /* Get current engine info */
- int ret = __internal_get_engine_info(callback);
+ __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, key(%s), data(%s)", key, 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, key(%s)", key);
+ 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();
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to get engine info");
+ 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;
}
- /* Check all engine functions */
- 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_ENGINE_NOT_FOUND;
+ 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, int* user_info, void *user_data)
+{
+ SECURE_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_info, user_data);
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent ERROR] Result callback function is NOT valid");
}
- /* initalize engine */
- 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;
+ return;
+}
+
+void __asr_result_cb(vcp_asr_result_event_e event, const char* asr_result, void *user_data)
+{
+ SECURE_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");
}
- /* 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;
- }
+ return;
+}
+
+void __nlg_result_cb(const char* nlg_result, void *user_data)
+{
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] NLG result - Result(%s)", nlg_result);
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] The %s has been loaded!!!", g_dynamic_engine.engine_name);
- g_dynamic_engine.is_loaded = true;
+ if (NULL != g_nlg_result_cb) {
+ g_nlg_result_cb(nlg_result, user_data);
} 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;
+ 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 engine is NULL or not */
+ if (NULL == engine) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] engine is NULL");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ /* 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;
+ if (0 != access(engine->engine_path, F_OK)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to access file (%s)", engine->engine_path);
+ return VCD_ERROR_OPERATION_FAILED;
+ } else {
+ 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] load current engine FINISH");
+ 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) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] The current engine is NOT valid");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ /* 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;
+ }
+
+ 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;
+ }
+
+ 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");
+ 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;
+ }
return 0;
}
-int vcd_engine_agent_unload_current_engine()
+int vcd_engine_agent_load_current_engine()
{
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_DEBUG, TAG_VCD, "[Engine Agent] Engine has already been unloaded");
- return VCD_ERROR_NONE;
- }
+ 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");
- /* 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");
+ /* need to initialize dynamic engine data */
+ g_dynamic_engine.is_loaded = false;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent SUCCESS] Load dynamic engine");
+ }
}
- /* reset current engine data */
- g_dynamic_engine.is_loaded = false;
+ 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;
+ }
+ 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;
+ }
+ }
return 0;
}
if (true == g_dynamic_engine.is_loaded) {
/* Set dynamic command */
- ret = g_dynamic_engine.callbacks->set_commands((vce_cmd_h)0);
+ ret = g_dynamic_engine.pefuncs->set_commands((vcp_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.callbacks->start(silence);
+ ret = g_dynamic_engine.pefuncs->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, vce_speech_detect_e* speech_detected)
+int vcd_engine_recognize_audio(const void* data, unsigned int length, vcp_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.callbacks->set_recording(data, length, speech_detected);
+ ret = g_dynamic_engine.pefuncs->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 (VCE_ERROR_OUT_OF_NETWORK == ret) {
+ if (VCP_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.callbacks->stop();
+ ret = g_dynamic_engine.pefuncs->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.callbacks->cancel();
+ ret = g_dynamic_engine.pefuncs->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.callbacks->set_audio_type(audio);
+ ret = g_dynamic_engine.pefuncs->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.callbacks->set_domain(domain);
+ ret = g_dynamic_engine.pefuncs->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 && NULL != g_dynamic_engine.callbacks->nlu_base_info_request) {
- ret = g_dynamic_engine.callbacks->nlu_base_info_request(key, value);
+ if (true == g_dynamic_engine.is_loaded) {
+ ret = g_dynamic_engine.pefuncs->get_nlu_base_info(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 && NULL != g_dynamic_engine.callbacks->private_data_set) {
- ret = g_dynamic_engine.callbacks->private_data_set(key, data);
+ if (true == g_dynamic_engine.is_loaded) {
+ ret = g_dynamic_engine.pefuncs->set_private_data(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 && NULL != g_dynamic_engine.callbacks->private_data_request) {
- ret = g_dynamic_engine.callbacks->private_data_request(key, data);
+ if (true == g_dynamic_engine.is_loaded) {
+ ret = g_dynamic_engine.pefuncs->get_private_data(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.callbacks->process_text(text);
+ ret = g_dynamic_engine.pefuncs->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.callbacks->process_list_event(event);
+ ret = g_dynamic_engine.pefuncs->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.callbacks->process_haptic_event(event);
+ ret = g_dynamic_engine.pefuncs->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
*/
-int vcd_engine_get_audio_format(const char* audio_id, vce_audio_type_e* types, int* rate, int* channels)
+int vcd_engine_get_audio_format(const char* audio_id, vcp_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");
}
- int ret = g_dynamic_engine.callbacks->get_recording_format(audio_id, types, rate, channels);
+ 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);
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");
}
- int ret = g_dynamic_engine.callbacks->foreach_langs(__supported_language_cb, (void*)lang_list);
+ 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);
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.callbacks->set_language(language);
+ ret = g_dynamic_engine.pefuncs->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;
}
-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)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request audio type");
-
- return vcd_recorder_get(audio_type);
-}
-
-int vcd_engine_agent_set_private_data(const char* key, const char* data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request set private data, key(%s), data(%s)", key, data);
- vcdc_send_request_set_private_data(vcd_client_manager_get_pid(), key, data);
-
- return VCD_ERROR_NONE;
-}
-
-int vcd_engine_agent_get_private_data(const char* key, char** data)
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request get private data, key(%s)", key);
- vcdc_send_request_get_private_data(vcd_client_manager_get_pid(), key, data);
-
- return VCD_ERROR_NONE;
-}
-
-int vcd_engine_agent_start_recording()
+void __free_language_list(GList* lang_list)
{
- 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;
- }
+ GList *iter = NULL;
+ char* data = NULL;
- return VCD_ERROR_NONE;
-}
+ /* if list have item */
+ if (g_list_length(lang_list) > 0) {
+ /* Get a first item */
+ iter = g_list_first(lang_list);
-int vcd_engine_agent_stop_recording()
-{
- SLOG(LOG_DEBUG, TAG_VCD, "[Engine Agent] Request stop recording");
+ while (NULL != iter) {
+ data = iter->data;
- return vcd_recorder_stop();
-}
+ if (NULL != data)
+ free(data);
-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;
- }
+ lang_list = g_list_remove_link(lang_list, iter);
- if (false == g_dynamic_engine.is_loaded) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not loaded engine");
- return VCD_ERROR_OPERATION_FAILED;
+ iter = g_list_first(lang_list);
+ }
}
-
- g_dynamic_engine.callbacks->private_data_set = callback_func;
-
- return VCD_ERROR_NONE;
}
-int vcd_engine_agent_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
+int __log_enginelist()
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
- return VCD_ERROR_OPERATION_FAILED;
- }
+ GList *iter = NULL;
+ vcengine_info_s *data = NULL;
- if (false == g_dynamic_engine.is_loaded) {
- SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not loaded engine");
- return VCD_ERROR_OPERATION_FAILED;
- }
+ if (0 < g_list_length(g_engine_list)) {
- g_dynamic_engine.callbacks->private_data_request = callback_func;
+ /* Get a first item */
+ iter = g_list_first(g_engine_list);
- return VCD_ERROR_NONE;
-}
+ SLOG(LOG_DEBUG, TAG_VCD, "@ engine list @");
-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;
- }
+ int i = 1;
+ while (NULL != iter) {
+ /* Get handle data from list */
+ data = iter->data;
- 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, "[%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, "@@@@");
}
- g_dynamic_engine.callbacks->nlu_base_info_request = callback_func;
-
- return VCD_ERROR_NONE;
+ return 0;
}
-
#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, int* user_info, 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();
+//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);
/** 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(vce_request_callback_s* callback);
+int vcd_engine_agent_load_current_engine();
/** 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, vce_audio_type_e* types, int* rate, int* channels);
+
+int vcd_engine_get_audio_format(const char* audio_id, vcp_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, vce_speech_detect_e* speech_detected);
+int vcd_engine_recognize_audio(const void* data, unsigned int length, vcp_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
+/*\r
+* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the License);\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an AS IS BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*/\r
+\r
+\r
+#include "vcd_dbus.h"\r
+#include "vcd_main.h"\r
+#include "vcd_server.h"\r
+\r
+#define CLIENT_CLEAN_UP_TIME 500\r
+\r
+static Ecore_Timer* g_check_client_timer = NULL;\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC Daemon Initialize");\r
+\r
+ if (!ecore_init()) {\r
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()");\r
+ return -1;\r
+ }\r
+\r
+ if (0 != vcd_dbus_open_connection()) {\r
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection");\r
+ ecore_shutdown();\r
+ return EXIT_FAILURE;\r
+ }\r
+\r
+ if (0 != vcd_initialize()) {\r
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize vc-daemon");\r
+ ecore_shutdown();\r
+ return EXIT_FAILURE;\r
+ }\r
+\r
+ g_check_client_timer = ecore_timer_add(CLIENT_CLEAN_UP_TIME, vcd_cleanup_client_all, NULL);\r
+ if (NULL == g_check_client_timer) {\r
+ SLOG(LOG_WARN, TAG_VCD, "[Main Warning] Fail to create timer of client check");\r
+ }\r
+\r
+ SLOG(LOG_DEBUG, TAG_VCD, "[Main] vc-daemon start");\r
+\r
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");\r
+\r
+ ecore_main_loop_begin();\r
+\r
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC Daemon Finalize");\r
+\r
+ if (NULL != g_check_client_timer) {\r
+ ecore_timer_del(g_check_client_timer);\r
+ }\r
+\r
+ vcd_finalize();\r
+\r
+ vcd_dbus_close_connection();\r
+\r
+ ecore_shutdown();\r
+\r
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");\r
+\r
+ return 0;\r
+}\r
+\r
+\r
#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
}
#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 VCE_AUDIO_ID_NONE "VC_AUDIO_ID_NONE" /**< None audio id */
+#define VCP_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 vce_audio_type_e g_audio_type;
+static vcp_audio_type_e g_audio_type;
static int g_audio_rate;
#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, VCE_AUDIO_ID_WIFI, sizeof(VCE_AUDIO_ID_WIFI))) {
+ if (0 != strncmp(g_current_audio_type, VCP_AUDIO_ID_MSF, sizeof(VCP_AUDIO_ID_MSF))) {
vcd_state_e state = vcd_config_get_service_state();
if (VCD_STATE_READY == state) {
- vcd_recorder_set(VCE_AUDIO_ID_WIFI, VCE_AUDIO_TYPE_PCM_S16_LE, 16000, 1);
+ vcd_recorder_set(VCP_AUDIO_ID_MSF, VCP_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 Wi-Fi");
+ SLOG(LOG_WARN, TAG_VCD, "[Recorder] Not start yet, but send audio data vi MSF");
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, VCE_AUDIO_ID_BLUETOOTH, sizeof(VCE_AUDIO_ID_BLUETOOTH))) {
+ if (0 != strncmp(g_current_audio_type, VCP_AUDIO_ID_BLUETOOTH, sizeof(VCP_AUDIO_ID_BLUETOOTH))) {
vcd_state_e state = vcd_config_get_service_state();
if (VCD_STATE_READY == state) {
- vcd_recorder_set(VCE_AUDIO_ID_BLUETOOTH, VCE_AUDIO_TYPE_PCM_S16_LE, 16000, 1);
+ vcd_recorder_set(VCP_AUDIO_ID_BLUETOOTH, VCP_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;
g_is_valid_bt_in = false;
g_current_audio_type = NULL;
- g_audio_type = VCE_AUDIO_TYPE_PCM_S16_LE;
+ g_audio_type = VCP_AUDIO_TYPE_PCM_S16_LE;
g_audio_rate = 16000;
g_audio_channel = 1;
}
switch (g_audio_type) {
- 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;
+ 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;
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(VCE_AUDIO_ID_NONE);
+ g_current_audio_type = strdup(VCP_AUDIO_ID_NONE);
} else {
if (true == g_is_valid_bt_in) {
- g_current_audio_type = strdup(VCE_AUDIO_ID_BLUETOOTH);
+ g_current_audio_type = strdup(VCP_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(VCE_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) {
#ifdef TV_BT_MODE
bt_hid_unset_audio_data_receive_cb();
#endif
- } else if (0 == strncmp(VCE_AUDIO_ID_WIFI, g_current_audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
+ } else if (0 == strncmp(VCP_AUDIO_ID_MSF, g_current_audio_type, strlen(VCP_AUDIO_ID_MSF))) {
#ifdef TV_MSF_WIFI_MODE
UnRegisterMSFAudioCallback();
#endif
return 0;
}
-int vcd_recorder_set(const char* audio_type, vce_audio_type_e type, int rate, int channel)
+int vcd_recorder_set(const char* audio_type, vcp_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 (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;
- }
+ 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)))) {
+ 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;
}
}
int ret = -1;
/* Check BT audio */
- if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, audio_type, strlen(VCP_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(VCE_AUDIO_ID_WIFI, audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
+ } else if (0 == strncmp(VCP_AUDIO_ID_MSF, audio_type, strlen(VCP_AUDIO_ID_MSF))) {
if (NULL != g_current_audio_type) {
free(g_current_audio_type);
g_current_audio_type = NULL;
}
switch (type) {
- 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;
+ 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;
default:
SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Invalid Audio Type");
return VCD_ERROR_OPERATION_FAILED;
static void __check_audio_format()
{
- vce_audio_type_e type;
+ vcp_audio_type_e type;
int rate;
int channel;
- int ret = vcd_engine_get_audio_format(VCE_AUDIO_ID_NONE, &type, &rate, &channel);
+ int ret = vcd_engine_get_audio_format(VCP_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 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;
+ 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;
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(VCE_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_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(VCE_AUDIO_ID_WIFI, g_current_audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
+ } else if (0 == strncmp(VCP_AUDIO_ID_MSF, g_current_audio_type, strlen(VCP_AUDIO_ID_MSF))) {
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 Wi-Fi audio");
+ SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to start MSF(wifi) audio");
return VCD_ERROR_OPERATION_FAILED;
}
#endif
bool stoped = false;
if (NULL != g_current_audio_type) {
- if (0 == strncmp(VCE_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCE_AUDIO_ID_BLUETOOTH))) {
+ if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_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, VCE_AUDIO_ID_BLUETOOTH, sizeof(VCE_AUDIO_ID_BLUETOOTH)) ||
- !strncmp(g_current_audio_type, VCE_AUDIO_ID_WIFI, sizeof(VCE_AUDIO_ID_WIFI)))) {
+ (!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)))) {
SLOG(LOG_DEBUG, TAG_VCD, "[DEBUG] Recorder reset to NONE");
- vcd_recorder_set(VCE_AUDIO_ID_NONE, g_audio_type, g_audio_rate, g_audio_channel);
+ vcd_recorder_set(VCP_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(VCE_AUDIO_ID_WIFI, g_current_audio_type, strlen(VCE_AUDIO_ID_WIFI))) {
+ } else if (0 == strncmp(VCP_AUDIO_ID_MSF, g_current_audio_type, strlen(VCP_AUDIO_ID_MSF))) {
#ifdef TV_MSF_WIFI_MODE
UnRegisterMSFAudioCallback();
if (NULL != g_current_audio_type &&
- (!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)))) {
+ (!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)))) {
SLOG(LOG_DEBUG, TAG_VCD, "[DEBUG] Recorder reset to NONE");
- vcd_recorder_set(VCE_AUDIO_ID_NONE, g_audio_type, g_audio_rate, g_audio_channel);
+ vcd_recorder_set(VCP_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, vce_audio_type_e type, int rate, int channel);
+int vcd_recorder_set(const char* audio_type, vcp_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;
}
- vce_speech_detect_e speech_detected = VCE_SPEECH_DETECT_NONE;
+ vcp_speech_detect_e speech_detected = VCP_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 (VCE_ERROR_OUT_OF_NETWORK == ret) {
+ if (VCP_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 (VCE_SPEECH_DETECT_BEGIN == speech_detected) {
+ if (VCP_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 (VCE_SPEECH_DETECT_END == speech_detected) {
+ } else if (VCP_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;
}
-int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
+//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)
{
if (NULL != asr_result) {
SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
}
- return VCD_ERROR_NONE;
+ return;
}
-int vcd_send_nlg_result(const char* nlg_result, void *user_data)
+static void __vcd_server_nlg_result_cb(const char* nlg_result, void *user_data)
{
int ret = __vcd_server_launch_manager_app();
if (0 != ret) {
SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
- return ret;
+ return;
}
- SLOG(LOG_ERROR, TAG_VCD, "[Server] send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server] send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
ret = vcdc_send_dialog(vcd_client_manager_get_pid(), -1, nlg_result, NULL, 0); //0: VC_DIALOG_END
if (0 != ret)
SECURE_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 ret;
+ return;
}
static void* __recorder_stop(void *data)
return NULL;
}
-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, int* user_info, void *user_data)
+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, int* user_info, 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);
- SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)",
- event, all_result, non_fixed_result, msg, count);
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)",
+ event, all_result, non_fixed_result, msg, count);
- SLOG(LOG_ERROR, TAG_VCD, "[Server] NLU result(%s)", nlu_result);
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server] NLU result(%s)", nlu_result);
if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) {
- if (VCE_RESULT_EVENT_REJECTED == event) {
+ if (VCP_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);
- ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
- if (0 != ret) {
+ if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
}
g_restart_timer = ecore_timer_add(0, __restart_engine, NULL);
- return ret;
+ return;
}
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 (VCE_RESULT_EVENT_REJECTED == event) {
+ if (VCP_RESULT_EVENT_REJECTED == event) {
bool temp = vcd_client_manager_get_exclusive();
vc_info_parser_set_result(all_result, event, msg, NULL, temp);
- ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
- if (0 != ret) {
+ if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
}
- return ret;
+ return;
}
}
#if 1
/* 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 VCD_ERROR_NONE;
+ return;
}
/* 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 VCD_ERROR_OUT_OF_MEMORY;
+ return;
}
int filtered_count = 0;
int top_priority = VC_COMMAND_PRIORITY_BACKGROUND;
free(filtered_id);
filtered_id = NULL;
}
- return VCD_ERROR_NONE;
+ return;
}
}
}
vcd_client_manager_set_exclusive(false);
- return VCD_ERROR_NONE;
+ return;
} 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 VCD_ERROR_NONE;
+ return;
#else
/* No result */
}
#if 0
-static void __vcd_server_nlu_result_cb(vce_result_event_e event, const char* nlu_result, void *user_data)
+static void __vcd_server_nlu_result_cb(vcp_result_event_e event, const char* nlu_result, void *user_data)
{
SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event);
SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result);
}
#endif
-int vcd_send_error(vce_error_e error, const char* msg, void *user_data)
+static void __vcd_server_error_cb(vcp_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 VCD_ERROR_NONE;
+ return;
}
/*
-* vcd server Interfaces
-*/
+ * vcd server Interfaces
+ */
static void __vcd_file_clean_up()
{
SLOG(LOG_DEBUG, TAG_VCD, "== Old file clean up == ");
return ret;
}
-int vcd_initialize(vce_request_callback_s *callback)
+int vcd_initialize()
{
int ret = 0;
vcd_config_set_service_state(VCD_STATE_NONE);
- ret = vcd_engine_agent_init();
+ //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);
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(callback)) {
+ if (0 != vcd_engine_agent_load_current_engine()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to load current engine");
return VCD_ERROR_OPERATION_FAILED;
}
/*
-* API for manager
-*/
+ * API for 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;
- vce_audio_type_e type = VCE_AUDIO_TYPE_PCM_S16_LE;
+ vcp_audio_type_e type = VCP_AUDIO_TYPE_PCM_S16_LE;
int rate = 16000;
int channel = 1;
}
/*
-* VC Server Functions for Client
-*/
+ * VC Server Functions for Client
+ */
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()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- return VCD_ERROR_ENGINE_NOT_FOUND;
+ if (0 != vcd_engine_agent_initialize_current_engine()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+ return VCD_ERROR_ENGINE_NOT_FOUND;
+ }
}
/* check if pid is valid */
#endif
/*
-* VC Server Functions for Widget lib
-*/
+ * VC Server Functions for Widget lib
+ */
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()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- return VCD_ERROR_ENGINE_NOT_FOUND;
+ if (0 != vcd_engine_agent_initialize_current_engine()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+ return VCD_ERROR_ENGINE_NOT_FOUND;
+ }
}
/* check if pid is valid */
return ret;
}
-/*
-* 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(vce_request_callback_s *callback);
+int vcd_initialize();
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, int* user_info, 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, int* user_info, 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_info, 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;
-}