Revert 'Change to support VC downloadable engine (hybrid)' temporarily
[platform/core/uifw/voice-control.git] / include / voice_control_plugin_engine.h
1 /*\r
2 * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved\r
3 *\r
4 * Licensed under the Apache License, Version 2.0 (the License);\r
5 * you may not use this file except in compliance with the License.\r
6 * You may obtain a copy of the License at\r
7 *\r
8 * http://www.apache.org/licenses/LICENSE-2.0\r
9 *\r
10 * Unless required by applicable law or agreed to in writing, software\r
11 * distributed under the License is distributed on an AS IS BASIS,\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13 * See the License for the specific language governing permissions and\r
14 * limitations under the License.\r
15 */\r
16 \r
17 \r
18 #ifndef __VOICE_CONTROL_PLUGIN_ENGINE_H__\r
19 #define __VOICE_CONTROL_PLUGIN_ENGINE_H__\r
20 \r
21 #include <tizen.h>\r
22 \r
23 /**\r
24 * @addtogroup VOICE_CONTROL_PLUGIN_ENGINE\r
25 * @{\r
26 */\r
27 \r
28 #ifdef __cplusplus\r
29 extern "C" {\r
30 #endif\r
31 \r
32 /**\r
33 * @brief Enumerations of error codes.\r
34 */\r
35 typedef enum {\r
36         VCP_ERROR_NONE                  = TIZEN_ERROR_NONE,             /**< Successful */\r
37         VCP_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */\r
38         VCP_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,         /**< I/O error */\r
39         VCP_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */\r
40         VCP_ERROR_OUT_OF_NETWORK        = TIZEN_ERROR_NETWORK_DOWN,     /**< Out of network */\r
41         VCP_ERROR_INVALID_STATE         = -0x0100031,                   /**< Invalid state */\r
42         VCP_ERROR_INVALID_LANGUAGE      = -0x0100032,                   /**< Invalid language */\r
43         VCP_ERROR_OPERATION_FAILED      = -0x0100034,                   /**< Operation failed */\r
44         VCP_ERROR_NOT_SUPPORTED_FEATURE = -0x0100035                    /**< Not supported feature */\r
45 } vcp_error_e;\r
46 \r
47 /**\r
48 * @brief Enumerations of audio type.\r
49 */\r
50 typedef enum {\r
51         VCP_AUDIO_TYPE_PCM_S16_LE = 0,  /**< Signed 16bit audio type, Little endian */\r
52         VCP_AUDIO_TYPE_PCM_U8           /**< Unsigned 8bit audio type */\r
53 } vcp_audio_type_e;\r
54 \r
55 /**\r
56 * @brief Enumerations of callback event.\r
57 */\r
58 typedef enum {\r
59         VCP_RESULT_EVENT_SUCCESS = 0,           /**< Event when the recognition full result is ready  */\r
60         VCP_RESULT_EVENT_REJECTED,              /**< Event when the recognition result is rejected */\r
61         VCP_RESULT_EVENT_ERROR                  /**< Event when the recognition has failed */\r
62 } vcp_result_event_e;\r
63 \r
64 /**\r
65 * @brief Enumerations of command type.\r
66 */\r
67 typedef enum {\r
68         VCP_COMMAND_FORMAT_FIXED = 0,           /**< Fixed command */\r
69         VCP_COMMAND_FORMAT_FIXED_AND_VFIXED, /**< Fixed command + variable-fixed command */\r
70         VCP_COMMAND_FORMAT_VFIXED_AND_FIXED, /**< variable-fixed command + Fixed command */\r
71         VCP_COMMAND_FORMAT_FIXED_AND_NONFIXED,  /**< Fixed command + Non-fixed command */\r
72         VCP_COMMAND_FORMAT_NONFIXED_AND_FIXED,  /**< Non-fixed command + Fixed command */\r
73         VCP_COMMAND_FORMAT_ACTION,\r
74         VCP_COMMAND_FORMAT_PARTIAL\r
75 } vcp_command_format_e;\r
76 \r
77 /**\r
78 * @brief Definition for foreground command type.\r
79 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
80 */\r
81 #define VCP_COMMAND_TYPE_FOREGROUND     1\r
82 \r
83 /**\r
84 * @brief Definition for background command type.\r
85 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
86 */\r
87 #define VCP_COMMAND_TYPE_BACKGROUND     2\r
88 \r
89 /**\r
90 * @brief Definition for widget command type.\r
91 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
92 */\r
93 #define VCP_COMMAND_TYPE_WIDGET         3\r
94 \r
95 /**\r
96 * @brief Definition for system command type.\r
97 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
98 */\r
99 #define VCP_COMMAND_TYPE_SYSTEM         4\r
100 \r
101 /**\r
102 * @brief Definition for exclusive command type.\r
103 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif\r
104 */\r
105 #define VCP_COMMAND_TYPE_SYSTEM_BACKGROUND      5\r
106 \r
107 /**\r
108 * @brief Definitions for exclusive command type.\r
109 * @since_tizen 2.4\r
110 */\r
111 #define VCP_COMMAND_TYPE_EXCLUSIVE      6\r
112 \r
113 \r
114 /**\r
115 * @brief Enumerations of speech detect.\r
116 */\r
117 typedef enum {\r
118         VCP_SPEECH_DETECT_NONE = 0,     /**< No event */\r
119         VCP_SPEECH_DETECT_BEGIN,        /**< Begin of speech detected */\r
120         VCP_SPEECH_DETECT_END,          /**< End of speech detected */\r
121 } vcp_speech_detect_e;\r
122 \r
123 typedef enum {\r
124         VCP_ASR_RESULT_EVENT_FINAL_RESULT = 0,\r
125         VCP_ASR_RESULT_EVENT_PARTIAL_RESULT,\r
126         VCP_ASR_RESULT_EVENT_ERROR\r
127 } vcp_asr_result_event_e;\r
128 \r
129 /**\r
130 * @brief A structure of handle for VC command\r
131 */\r
132 typedef int vcp_cmd_h;\r
133 \r
134 /**\r
135  * @brief Definition of bluetooth audio id.\r
136 */\r
137 #define VCP_AUDIO_ID_BLUETOOTH          "VC_AUDIO_ID_BLUETOOTH"         /**< Bluetooth audio id */\r
138 \r
139 /**\r
140  * @brief Definition of MSF(wifi) audio id.\r
141 */\r
142 #define VCP_AUDIO_ID_MSF                "VC_AUDIO_ID_MSF"               /**< MSF (wifi) audio id */\r
143 \r
144 /**\r
145 * @brief Definition for none message.\r
146 */\r
147 #define VC_RESULT_MESSAGE_NONE                  "vc.result.message.none"\r
148 \r
149 /**\r
150 * @brief Definition for failed recognition because the speech is too loud to listen.\r
151 */\r
152 #define VC_RESULT_MESSAGE_ERROR_TOO_LOUD        "vc.result.message.error.too.loud"\r
153 \r
154 \r
155 /**\r
156 * @brief Called when the daemon gets synthesized result.\r
157 *\r
158 * @param[in] event A result event\r
159 * @param[in] result_id Result ids\r
160 * @param[in] count Result count\r
161 * @param[in] all_result All result text\r
162 * @param[in] non_fixed_result Non-fixed command result text\r
163 * @param[in] nlu_result NLU result text\r
164 * @param[in] msg Engine message (e.g. #VC_RESULT_MESSAGE_NONE, #VC_RESULT_MESSAGE_ERROR_TOO_LOUD)\r
165 * @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
166 * @param[in] user_data The user data passed from set callback function\r
167 *\r
168 * @pre vcpe_stop() will invoke this callback.\r
169 *\r
170 * @see vcpe_stop()\r
171 */\r
172 typedef void (*vcpe_result_cb)(vcp_result_event_e event, int* result_id, int count,\r
173                                const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, void *user_data);\r
174 \r
175 \r
176 /**\r
177 * @brief Called when the daemon gets ASR result.\r
178 *\r
179 * @param[in] event A asr result event\r
180 * @param[in] pre_result result text\r
181 * @param[in] user_data The user data passed from the start\r
182 */\r
183 typedef void (*vcpe_asr_result_cb)(vcp_asr_result_event_e event, const char* asr_result, void *user_data);\r
184 \r
185 /**\r
186 * @brief Called when the daemon gets nlg result.\r
187 *\r
188 * @param[in] nlg_result Nlg result\r
189 * @param[in] user_data The user data passed from the start\r
190 */\r
191 typedef void (*vcpe_nlg_result_cb)(const char* nlg_result, void *user_data);\r
192 \r
193 /**\r
194 * @brief Called when the daemon gets error.\r
195 *\r
196 * @param[in] error Error type\r
197 * @param[in] msg Error message\r
198 * @param[in] user_data The user data passed from set callback function\r
199 *\r
200 */\r
201 typedef void (*vcpe_error_cb)(vcp_error_e error, const char* msg, void *user_data);\r
202 \r
203 /**\r
204 * @brief Called to retrieve the supported languages.\r
205 *\r
206 * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code\r
207 *               followed by ISO 639-1 for the two-letter language code \n\r
208 *               For example, "ko_KR" for Korean, "en_US" for American English\r
209 * @param[in] user_data The user data passed from the foreach function\r
210 *\r
211 * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop\r
212 *\r
213 * @pre vcpe_foreach_supported_languages() will invoke this callback.\r
214 *\r
215 * @see vcpe_foreach_supported_languages()\r
216 */\r
217 typedef bool (*vcpe_supported_language_cb)(const char* language, void* user_data);\r
218 \r
219 /**\r
220 * @brief Initializes the engine.\r
221 *\r
222 * @param[in] result_cb A callback function for recognition result\r
223 * @param[in] silence_cb A callback function for silence detection\r
224 *\r
225 * @return 0 on success, otherwise a negative error value\r
226 * @retval #VCP_ERROR_NONE Successful\r
227 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
228 * @retval #VCP_ERROR_INVALID_STATE Already initialized\r
229 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
230 *\r
231 * @see vcpe_deinitialize()\r
232 */\r
233 typedef int (*vcpe_initialize)(void);\r
234 \r
235 /**\r
236 * @brief Deinitializes the engine\r
237 *\r
238 * @return 0 on success, otherwise a negative error value\r
239 * @retval #VCP_ERROR_NONE Successful\r
240 * @retval #VCP_ERROR_INVALID_STATE Not initialized\r
241 *\r
242 * @see vcpe_initialize()\r
243 */\r
244 typedef void (*vcpe_deinitialize)(void);\r
245 \r
246 /**\r
247 * @brief Registers a callback function for getting recognition result.\r
248 *\r
249 * @param[in] callback Callback function to register\r
250 * @param[in] user_data The user data to be passed to the callback function\r
251 *\r
252 * @return 0 on success, otherwise a negative error value\r
253 * @retval #VCP_ERROR_NONE Successful\r
254 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
255 *\r
256 * @see vcpe_result_cb()\r
257 */\r
258 typedef int (*vcpe_set_result_cb)(vcpe_result_cb callback, void* user_data);\r
259 \r
260 /**\r
261 * @brief Registers a callback function for getting ASR recognition result.\r
262 *\r
263 * @param[in] callback Callback function to register\r
264 * @param[in] user_data The user data to be passed to the callback function\r
265 *\r
266 * @return 0 on success, otherwise a negative error value\r
267 *\r
268 * @see vcpe_asr_result_cb()\r
269 */\r
270 typedef int (*vcpe_set_asr_result_cb)(vcpe_asr_result_cb callback, void* user_data);\r
271 \r
272 /**\r
273 * @brief Registers a callback function for getting nlg result.\r
274 *\r
275 * @param[in] callback Callback function to register\r
276 * @param[in] user_data The user data to be passed to the callback function\r
277 *\r
278 * @return 0 on success, otherwise a negative error value\r
279 *\r
280 */\r
281 typedef int (*vcpe_set_nlg_result_cb)(vcpe_nlg_result_cb, void* user_data);\r
282 \r
283 #if 0\r
284 /**\r
285 * @brief Registers a callback function for getting partial recognition result.\r
286 *\r
287 * @param[in] callback Callback function to register\r
288 * @param[in] user_data The user data to be passed to the callback function\r
289 *\r
290 * @return 0 on success, otherwise a negative error value\r
291 *\r
292 * @see vcpe_pre_result_cb()\r
293 */\r
294 typedef int (*vcpe_set_pre_result_cb)(vcpe_pre_result_cb callback, void* user_data);\r
295 #endif\r
296 \r
297 /**\r
298 * @brief Registers a callback function for error.\r
299 *\r
300 * @param[in] callback Callback function to register\r
301 * @param[in] user_data The user data to be passed to the callback function\r
302 *\r
303 * @return 0 on success, otherwise a negative error value\r
304 *\r
305 */\r
306 typedef int (*vcpe_set_error_cb)(vcpe_error_cb callback, void* user_data);\r
307 \r
308 #if 0\r
309 /**\r
310 * @brief Registers a callback function for getting NLU result.\r
311 *\r
312 * @param[in] callback Callback function to register\r
313 * @param[in] user_data The user data to be passed to the callback function\r
314 *\r
315 * @return 0 on success, otherwise a negative error value\r
316 *\r
317 */\r
318 typedef int (*vcpe_set_nlu_result_cb)(vcpe_nlu_result_cb, void* user_data);\r
319 #endif\r
320 \r
321 /**\r
322 * @brief Gets recording format of the engine.\r
323 *\r
324 * @param[in] audio_id The audio device id.\r
325 * @param[out] types The format used by the recorder.\r
326 * @param[out] rate The sample rate used by the recorder.\r
327 * @param[out] channels The number of channels used by the recorder.\r
328 *\r
329 * @return 0 on success, otherwise a negative error value\r
330 * @retval #VCP_ERROR_NONE Successful\r
331 * @retval #VCP_ERROR_INVALID_PARAMETER Not initialized\r
332 */\r
333 typedef int (*vcpe_get_recording_format)(const char* audio_id, vcp_audio_type_e* types, int* rate, int* channels);\r
334 \r
335 /**\r
336 * @brief Retrieves all supported languages of the engine.\r
337 *\r
338 * @param[in] callback a callback function\r
339 * @param[in] user_data The user data to be passed to the callback function\r
340 *\r
341 * @return 0 on success, otherwise a negative error value\r
342 * @retval #VCP_ERROR_NONE Successful\r
343 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
344 * @retval #VCP_ERROR_INVALID_STATE Not initialized\r
345 *\r
346 * @post This function invokes vcpe_supported_language_cb() repeatedly for getting supported languages.\r
347 *\r
348 * @see vcpe_supported_language_cb()\r
349 */\r
350 typedef int (*vcpe_foreach_supported_languages)(vcpe_supported_language_cb callback, void* user_data);\r
351 \r
352 /**\r
353 * @brief Checks whether a language is supported or not.\r
354 *\r
355 * @param[in] language A language\r
356 *\r
357 * @return @c true = supported, \n @c false = not supported.\r
358 */\r
359 typedef bool (*vcpe_is_language_supported)(const char* language);\r
360 \r
361 /**\r
362 * @brief Sets language.\r
363 *\r
364 * @param[in] language language.\r
365 *\r
366 * @return 0 on success, otherwise a negative error value\r
367 * @retval #VCP_ERROR_NONE Successful\r
368 * @retval #VCP_ERROR_INVALID_LANGUAGE Invalid language\r
369 * @retval #VCP_ERROR_INVALID_STATE Not initialized\r
370 */\r
371 typedef int (*vcpe_set_language)(const char* language);\r
372 \r
373 /**\r
374 * @brief Sets command list before recognition.\r
375 *\r
376 * @remark This function should set commands via vcpd_foreach_command().\r
377 *\r
378 * @param[in] vcp_command command handle.\r
379 *\r
380 * @return 0 on success, otherwise a negative error value\r
381 * @retval #VCP_ERROR_NONE Successful\r
382 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
383 * @retval #VCP_ERROR_INVALID_STATE Invalid state\r
384 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
385 * @retval #VCP_ERROR_NOT_SUPPORTED_FEATURE Not supported command type\r
386 *\r
387 * @post vcpe_start() is called after this function is successful.\r
388 *\r
389 * @see vcpe_start()\r
390 * @see vcpd_foreach_command()\r
391 * @see vcpe_unset_commands()\r
392 */\r
393 typedef int (*vcpe_set_commands)(vcp_cmd_h vcp_command);\r
394 \r
395 /**\r
396 * @brief Unset command list for reset.\r
397 *\r
398 * @return 0 on success, otherwise a negative error value\r
399 * @retval #VCP_ERROR_NONE Successful\r
400 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
401 * @retval #VCP_ERROR_INVALID_STATE Invalid state\r
402 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
403 *\r
404 * @see vcpe_set_commands()\r
405 */\r
406 typedef int (*vcpe_unset_commands)();\r
407 \r
408 /**\r
409 * @brief Start recognition.\r
410 *\r
411 * @return 0 on success, otherwise a negative error value\r
412 * @retval #VCP_ERROR_NONE Successful\r
413 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
414 * @retval #VCP_ERROR_INVALID_STATE Invalid state\r
415 * @retval #VCP_ERROR_INVALID_LANGUAGE Invalid language\r
416 * @retval #VCP_ERROR_OUT_OF_NETWORK Out of network\r
417 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
418 *\r
419 * @pre vcpd_foreach_command() is successful.\r
420 *\r
421 * @see vcpe_set_recording_data()\r
422 * @see vcpe_stop()\r
423 * @see vcpe_cancel()\r
424 */\r
425 typedef int (*vcpe_start)(bool stop_by_silence);\r
426 \r
427 /**\r
428 * @brief Sets recording data for speech recognition from recorder.\r
429 *\r
430 * @remark This function should be returned immediately after recording data copy.\r
431 *\r
432 * @param[in] data A recording data\r
433 * @param[in] length A length of recording data\r
434 * @param[out] silence_detected @c true Silence detected \n @c false No silence detected\r
435 *\r
436 * @return 0 on success, otherwise a negative error value\r
437 * @retval #VCP_ERROR_NONE Successful\r
438 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
439 * @retval #VCP_ERROR_INVALID_STATE Invalid state\r
440 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
441 *\r
442 * @pre vcpe_start() is successful.\r
443 *\r
444 * @see vcpe_start()\r
445 * @see vcpe_cancel()\r
446 * @see vcpe_stop()\r
447 */\r
448 typedef int(*vcpe_set_recording_data)(const void* data, unsigned int length, vcp_speech_detect_e* speech_detected);\r
449 \r
450 /**\r
451 * @brief Stops to get the result of recognition.\r
452 *\r
453 * @return 0 on success, otherwise a negative error value\r
454 * @retval #VCP_ERROR_NONE Successful\r
455 * @retval #VCP_ERROR_INVALID_STATE Invalid state\r
456 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
457 * @retval #VCP_ERROR_OUT_OF_NETWORK Out of network\r
458 *\r
459 * @pre vcpe_set_recording_data() is successful.\r
460 *\r
461 * @see vcpe_start()\r
462 * @see vcpe_set_recording_data()\r
463 * @see vcpe_result_cb()\r
464 * @see vcpe_cancel()\r
465 */\r
466 typedef int (*vcpe_stop)(void);\r
467 \r
468 /**\r
469 * @brief Cancels the recognition process.\r
470 *\r
471 * @return 0 on success, otherwise a negative error value.\r
472 * @retval #VCP_ERROR_NONE Successful.\r
473 * @retval #VCP_ERROR_INVALID_STATE Invalid state.\r
474 *\r
475 * @pre vcpe_start() is successful.\r
476 *\r
477 * @see vcpe_start()\r
478 * @see vcpe_stop()\r
479 */\r
480 typedef int (*vcpe_cancel)(void);\r
481 \r
482 /**\r
483 * @brief Set audio recording type.\r
484 *\r
485 * @return 0 on success, otherwise a negative error value.\r
486 * @retval #VCP_ERROR_NONE Successful.\r
487 *\r
488 */\r
489 typedef int (*vcpe_set_audio_type)(const char* audio);\r
490 \r
491 /**\r
492 * @brief Sets domain (Agent or device type)\r
493 *\r
494 * @param[in] domain available Agent or device type\r
495 *\r
496 * @return 0 on success, otherwise a negative error value.\r
497 *\r
498 */\r
499 typedef int (*vcpe_set_domain)(const char* domain);\r
500 \r
501 /**\r
502 * @brief Gets essential value from nlu result. This function is available inside vcpe_nlu_result_cb()\r
503 *\r
504 * @param[in] key NLU base info key\r
505 * @parma[out] value NLU base info value\r
506 *\r
507 * @return 0 on success, otherwise a negative error value.\r
508 *\r
509 */\r
510 typedef int (*vcpe_get_nlu_base_info)(const char* key, char** value);\r
511 \r
512 /**\r
513 * @brief Sets private data between app and engine.\r
514 *\r
515 * @param[in] key Private key\r
516 * @param[in] data Private data\r
517 *\r
518 * @return 0 on success, otherwise a negative error value.\r
519 *\r
520 */\r
521 typedef int (*vcpe_set_private_data)(const char* key, const char* data);\r
522 \r
523 /**\r
524 * @brief Gets private data between app and engine.\r
525 *\r
526 * @param[in] key Private key\r
527 * @param[out] data Private data\r
528 *\r
529 * @return 0 on success, otherwise a negative error value.\r
530 *\r
531 */\r
532 typedef int (*vcpe_get_private_data)(const char* key, char** data);\r
533 \r
534 /**\r
535 * @brief Request process text.\r
536 *\r
537 * @param[in] text Requested text\r
538 *\r
539 * @return 0 on success, otherwise a negative error value.\r
540 *\r
541 */\r
542 typedef int (*vcpe_process_text)(const char* text);\r
543 \r
544 /**\r
545 * @brief Request list event.\r
546 *\r
547 * @param[in] event Requested list event\r
548 *\r
549 * @return 0 on success, otherwise a negative error value.\r
550 *\r
551 */\r
552 typedef int (*vcpe_process_list_event)(const char* event);\r
553 \r
554 /**\r
555 * @brief Request haptic event.\r
556 *\r
557 * @param[in] event Requested haptic event\r
558 *\r
559 * @return 0 on success, otherwise a negative error value.\r
560 *\r
561 */\r
562 typedef int (*vcpe_process_haptic_event)(const char* event);\r
563 \r
564 /**\r
565 * Daemon API.\r
566 */\r
567 \r
568 /**\r
569 * @brief Called to retrieve the commands.\r
570 *\r
571 * @param[in] id command id\r
572 * @param[in] type command type\r
573 * @param[in] format command format\r
574 * @param[in] command command text\r
575 * @param[in] param parameter text\r
576 * @param[in] domain command domain\r
577 * @param[in] user_data The user data passed from the foreach function\r
578 *\r
579 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.\r
580 * @pre vcpd_foreach_command() will invoke this callback.\r
581 *\r
582 * @see vcpd_foreach_command()\r
583 */\r
584 typedef bool (*vcpd_foreach_command_cb)(int id, int type, int format, const char* command, const char* param, int domain, void* user_data);\r
585 \r
586 /**\r
587 * @brief Retrieves all commands using callback function.\r
588 *\r
589 * @param[in] vcp_command The handle to be passed to the vcpe_set_commands() function\r
590 * @param[in] callback The callback function to invoke\r
591 * @param[in] user_data The user data to be passed to the callback function\r
592 *\r
593 * @return 0 on success, otherwise a negative error value\r
594 * @retval #VCP_ERROR_NONE Successful\r
595 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
596 * @retval #VCP_ERROR_OPERATION_FAILED Operation failure\r
597 * @retval #VCP_ERROR_INVALID_STATE Invalid state\r
598 *\r
599 * @post This function invokes vcpd_foreach_command_cb() repeatedly for getting commands.\r
600 *\r
601 * @see vcpd_foreach_command_cb()\r
602 * @see vcpe_set_commands()\r
603 */\r
604 typedef int (*vcpd_foreach_command)(vcp_cmd_h vcp_command, vcpd_foreach_command_cb callback, void* user_data);\r
605 \r
606 /**\r
607 * @brief Gets command length.\r
608 *\r
609 * @param[in] vcp_command The handle to be passed to the vcpe_set_commands() function\r
610 *\r
611 * @return the value greater than 0 on success, otherwise a negative error value\r
612 *\r
613 * @see vcpe_set_commands()\r
614 */\r
615 typedef int (*vcpd_get_command_count)(vcp_cmd_h vcp_command);\r
616 \r
617 /**\r
618 * @brief Gets current audio type.\r
619 *\r
620 * @remarks audio_type must be released using free() when it is no longer required.\r
621 *\r
622 * @param[in] audio_type Current audio type  (e.g. #VCP_AUDIO_ID_BLUETOOTH or usb device id)\r
623 *\r
624 * @return the value greater than 0 on success, otherwise a negative error value\r
625 *\r
626 */\r
627 typedef int (*vcpd_get_audio_type)(char** audio_type);\r
628 \r
629 /**\r
630 * @brief Sets private data to Manager client.\r
631 *\r
632 * @param[in] key Private key\r
633 * @param[in] data Private data\r
634 *\r
635 * @return 0 on success, otherwise a negative error value.\r
636 *\r
637 */\r
638 typedef int (*vcpd_set_private_data)(const char* key, const char* data);\r
639 \r
640 /**\r
641 * @brief Gets private data from Manager client.\r
642 *\r
643 * @param[in] key Private key\r
644 * @param[out] data Private data\r
645 *\r
646 * @return 0 on success, otherwise a negative error value.\r
647 *\r
648 */\r
649 typedef int (*vcpd_get_private_data)(const char* key, char** data);\r
650 \r
651 /**\r
652 * @brief Request start recording.\r
653 *\r
654 * @return 0 on success, otherwise a negative error value.\r
655 *\r
656 */\r
657 typedef int (*vcpd_start_recording)();\r
658 \r
659 /**\r
660 * @brief Request stop recording.\r
661 *\r
662 * @return 0 on success, otherwise a negative error value.\r
663 *\r
664 */\r
665 typedef int (*vcpd_stop_recording)();\r
666 \r
667 /**\r
668 * @brief A structure of the engine functions.\r
669 */\r
670 typedef struct {\r
671         int size;                                               /**< Size of structure */\r
672         int version;                                            /**< Version */\r
673 \r
674         vcpe_initialize                 initialize;             /**< Initialize engine */\r
675         vcpe_deinitialize               deinitialize;           /**< Shutdown engine */\r
676 \r
677         /* Get engine information */\r
678         vcpe_get_recording_format       get_recording_format;   /**< Get recording format */\r
679         vcpe_foreach_supported_languages foreach_langs;         /**< Foreach language list */\r
680         vcpe_is_language_supported      is_lang_supported;      /**< Check language */\r
681 \r
682         /* Set info */\r
683         vcpe_set_result_cb              set_result_cb;          /**< Set result callback */\r
684         vcpe_set_language               set_language;           /**< Set language */\r
685         vcpe_set_commands               set_commands;           /**< Request to set current commands */\r
686         vcpe_unset_commands             unset_commands;         /**< Request to unset current commands */\r
687 \r
688         /* Control recognition */\r
689         vcpe_start                      start;                  /**< Start recognition */\r
690         vcpe_set_recording_data         set_recording;          /**< Set recording data */\r
691         vcpe_stop                       stop;                   /**< Stop recording for getting result */\r
692         vcpe_cancel                     cancel;                 /**< Cancel recording and processing */\r
693 \r
694         vcpe_set_audio_type             set_audio_type;         /**< Set audio type */\r
695 \r
696         //vcpe_set_pre_result_cb                set_pre_result_cb;      /**< Set pre result callback */\r
697         vcpe_set_asr_result_cb          set_asr_result_cb;      /**< Set asr result callback */\r
698         vcpe_set_nlg_result_cb          set_nlg_result_cb;      /**< Set nlg result callback */\r
699         vcpe_set_error_cb               set_error_cb;           /**< Set error callback */\r
700         vcpe_set_domain                 set_domain;             /**< Set domain */\r
701         vcpe_get_nlu_base_info          get_nlu_base_info;      /**< Get essential info */\r
702         //vcpe_set_nlu_result_cb                set_nlu_result_cb;      /**< Set nlu result callback */\r
703         vcpe_set_private_data           set_private_data;       /**< Set private data */\r
704         vcpe_get_private_data           get_private_data;       /**< Get private data */\r
705         vcpe_process_text               process_text;           /**< Request to process text */\r
706         vcpe_process_list_event         process_list_event;     /**< Request to process list event */\r
707         vcpe_process_haptic_event       process_haptic_event;   /**< Request to process haptic event */\r
708 } vcpe_funcs_s;\r
709 \r
710 /**\r
711 * @brief A structure of the daemon functions.\r
712 */\r
713 typedef struct {\r
714         int size;                                               /**< Size of structure */\r
715         int version;                                            /**< Version */\r
716 \r
717         vcpd_foreach_command            foreach_command;        /**< Foreach command */\r
718         vcpd_get_command_count          get_command_count;      /**< Get command count */\r
719 \r
720         vcpd_get_audio_type             get_audio_type;         /**< Get audio type */\r
721 \r
722         vcpd_set_private_data           set_private_data;       /**< Set private data to Manager */\r
723         vcpd_get_private_data           get_private_data;       /**< Get private data from Manager */\r
724 \r
725         vcpd_start_recording            start_recording;        /**< Request start recording */\r
726         vcpd_stop_recording             stop_recording;         /**< Request stop recording */\r
727 } vcpd_funcs_s;\r
728 \r
729 /**\r
730 * @brief Loads the engine.\r
731 *\r
732 * @param[in] pdfuncs The daemon functions\r
733 * @param[out] pefuncs The engine functions\r
734 *\r
735 * @return This function returns zero on success, or negative with error code on failure\r
736 * @retval #VCP_ERROR_NONE Successful\r
737 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
738 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
739 *\r
740 * @pre The vcp_get_engine_info() should be successful.\r
741 * @post The daemon calls engine functions of vcpe_funcs_s.\r
742 *\r
743 * @see vcp_get_engine_info()\r
744 * @see vcp_unload_engine()\r
745 */\r
746 int vcp_load_engine(vcpd_funcs_s* pdfuncs, vcpe_funcs_s* pefuncs);\r
747 \r
748 /**\r
749 * @brief Unloads this engine by the daemon.\r
750 *\r
751 * @pre The vcp_load_engine() should be successful.\r
752 *\r
753 * @see vcp_load_engine()\r
754 */\r
755 void vcp_unload_engine(void);\r
756 \r
757 /**\r
758 * @brief Called to get the engine base information.\r
759 *\r
760 * @param[in] engine_uuid The engine id\r
761 * @param[in] engine_name The engine name\r
762 * @param[in] engine_setting The setting ug name\r
763 * @param[in] use_network @c true to need network @c false not to need network.\r
764 * @param[in] user_data The User data passed from vcp_get_engine_info()\r
765 *\r
766 * @pre vcp_get_engine_info() will invoke this callback.\r
767 *\r
768 * @see vcp_get_engine_info()\r
769 */\r
770 typedef void (*vcpe_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* engine_setting,\r
771                                                                         bool use_network, void* user_data);\r
772 \r
773 /**\r
774 * @brief Gets the engine base information before the engine is loaded by the daemon.\r
775 *\r
776 * @param[in] callback Callback function\r
777 * @param[in] user_data User data to be passed to the callback function\r
778 *\r
779 * @return This function returns zero on success, or negative with error code on failure\r
780 * @retval #VCP_ERROR_NONE Successful\r
781 * @retval #VCP_ERROR_INVALID_PARAMETER Invalid parameter\r
782 * @retval #VCP_ERROR_OPERATION_FAILED Operation failed\r
783 *\r
784 * @post This function invokes vcpe_engine_info_cb() for getting engine information.\r
785 *\r
786 * @see vcpe_engine_info_cb()\r
787 * @see vcp_load_engine()\r
788 */\r
789 int vcp_get_engine_info(vcpe_engine_info_cb callback, void* user_data);\r
790 \r
791 \r
792 #ifdef __cplusplus\r
793 }\r
794 #endif\r
795 \r
796 /**\r
797 * @}@}\r
798 */\r
799 \r
800 #endif /* __VOICE_CONTROL_PLUGIN_ENGINE_H__ */\r