cc9f73f811e1cd40623a02f939a14d45d5214360
[platform/core/uifw/voice-control.git] / server / vce.c
1 /*
2 * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 #include <cynara-client.h>
19 #include <cynara-error.h>
20 #include <cynara-session.h>
21 #include <system_info.h>
22 #include "vcd_dbus.h"
23 #include "vcd_main.h"
24 #include "vcd_server.h"
25
26 #include "vce.h"
27
28 static int g_feature_enabled = -1;
29 static int g_privilege_allowed = -1;
30 static cynara *p_cynara = NULL;
31
32 static int __vce_get_feature_enabled()
33 {
34         if (0 == g_feature_enabled) {
35                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Voice control feature NOT supported");
36                 return VCE_ERROR_NOT_SUPPORTED;
37         } else if (-1 == g_feature_enabled) {
38                 bool vc_supported = false;
39                 bool mic_supported = false;
40                 if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) {
41                         if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) {
42                                 if (false == vc_supported || false == mic_supported) {
43                                         SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Voice control feature NOT supported");
44                                         g_feature_enabled = 0;
45                                         return VCE_ERROR_NOT_SUPPORTED;
46                                 }
47
48                                 g_feature_enabled = 1;
49                         } else {
50                                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get feature value");
51                                 return VCE_ERROR_NOT_SUPPORTED;
52                         }
53                 } else {
54                         SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get feature value");
55                         return VCE_ERROR_NOT_SUPPORTED;
56                 }
57         }
58
59         return 0;
60 }
61
62 static int __check_privilege_initialize()
63 {
64         int ret = cynara_initialize(&p_cynara, NULL);
65         if (CYNARA_API_SUCCESS != ret)
66                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] fail to initialize");
67
68         return ret == CYNARA_API_SUCCESS;
69 }
70
71 static int __check_privilege(const char* uid, const char * privilege)
72 {
73         FILE *fp = NULL;
74         char label_path[1024] = "/proc/self/attr/current";
75         char smack_label[1024] = {'\0',};
76
77         if (!p_cynara) {
78                 return false;
79         }
80
81         fp = fopen(label_path, "r");
82         if (fp != NULL) {
83                 if (0 >= fread(smack_label, 1, sizeof(smack_label), fp))
84                         SLOG(LOG_ERROR, TAG_VCD, "[ERROR] fail to fread");
85
86                 fclose(fp);
87         }
88
89         pid_t pid = getpid();
90         char *session = cynara_session_from_pid(pid);
91         int ret = cynara_check(p_cynara, smack_label, session, uid, privilege);
92         SLOG(LOG_DEBUG, TAG_VCD, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied");
93         if (session)
94                 free(session);
95
96         if (ret != CYNARA_API_ACCESS_ALLOWED)
97                 return false;
98         return true;
99 }
100
101 static void __check_privilege_deinitialize()
102 {
103         if (p_cynara)
104                 cynara_finish(p_cynara);
105         p_cynara = NULL;
106 }
107
108 static int __vce_check_privilege()
109 {
110         char uid[16];
111
112         if (0 == g_privilege_allowed) {
113                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied");
114                 return VCE_ERROR_PERMISSION_DENIED;
115         } else if (-1 == g_privilege_allowed) {
116                 if (false == __check_privilege_initialize()) {
117                         SLOG(LOG_ERROR, TAG_VCD, "[ERROR] privilege initialize is failed");
118                         return VCE_ERROR_PERMISSION_DENIED;
119                 }
120                 snprintf(uid, 16, "%d", getuid());
121                 if (false == __check_privilege(uid, VC_PRIVILEGE)) {
122                         SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied");
123                         g_privilege_allowed = 0;
124                         __check_privilege_deinitialize();
125                         return VCE_ERROR_PERMISSION_DENIED;
126                 }
127                 __check_privilege_deinitialize();
128         }
129
130         g_privilege_allowed = 1;
131         return VCE_ERROR_NONE;
132 }
133
134 int vce_main(int argc, char** argv, vce_request_callback_s *callback)
135 {
136         if (0 != __vce_get_feature_enabled()) {
137                 return VCE_ERROR_NOT_SUPPORTED;
138         }
139         if (0 != __vce_check_privilege()) {
140                 return VCE_ERROR_PERMISSION_DENIED;
141         }
142
143         SLOG(LOG_DEBUG, TAG_VCD, "  ");
144         SLOG(LOG_DEBUG, TAG_VCD, "  ");
145         SLOG(LOG_DEBUG, TAG_VCD, "===== VC Engine Service Initialize");
146
147         int ret = VCE_ERROR_NONE;
148
149         if (!ecore_init()) {
150                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()");
151                 return VCE_ERROR_OPERATION_FAILED;
152         }
153
154         if (0 != vcd_dbus_open_connection()) {
155                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection");
156                 ecore_shutdown();
157                 return VCE_ERROR_OPERATION_FAILED;
158         }
159
160         ret = vcd_initialize(callback);
161         if (0 != ret) {
162                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize");
163                 vcd_dbus_close_connection();
164                 ecore_shutdown();
165                 return ret;
166         }
167
168         SLOG(LOG_DEBUG, TAG_VCD, "[Main] VC Engine Service start...");
169
170         SLOG(LOG_DEBUG, TAG_VCD, "=====");
171         SLOG(LOG_DEBUG, TAG_VCD, "  ");
172         SLOG(LOG_DEBUG, TAG_VCD, "  ");
173
174         return 0;
175 }
176
177 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)
178 {
179         if (0 != __vce_get_feature_enabled()) {
180                 return VCE_ERROR_NOT_SUPPORTED;
181         }
182
183         int ret = VCE_ERROR_NONE;
184
185         if (event < VCE_RESULT_EVENT_SUCCESS || event > VCE_RESULT_EVENT_ERROR) {
186                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
187                 return VCE_ERROR_INVALID_PARAMETER;
188         }
189
190         if (NULL == all_result || NULL == non_fixed_result || NULL == nlu_result) {
191                 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
192         }
193
194         ret = vcd_send_result(event, result_id, count, all_result, non_fixed_result, nlu_result, msg, user_info, user_data);
195         if (0 != ret) {
196                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send result");
197         } else {
198                 SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send result");
199         }
200
201         return ret;
202 }
203
204
205 int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
206 {
207         if (0 != __vce_get_feature_enabled()) {
208                 return VCE_ERROR_NOT_SUPPORTED;
209         }
210
211         int ret = VCE_ERROR_NONE;
212
213         if (event < VCE_ASR_RESULT_EVENT_FINAL_RESULT || event > VCE_ASR_RESULT_EVENT_ERROR) {
214                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
215                 return VCE_ERROR_INVALID_PARAMETER;
216         }
217
218         if (NULL == asr_result) {
219                 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
220         }
221
222         ret = vcd_send_asr_result(event, asr_result, user_data);
223         if (0 != ret) {
224                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send ASR result");
225         } else {
226                 SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send ASR result");
227         }
228
229         return ret;
230 }
231
232 int vce_send_specific_engine_result(const char* engine_app_id, const char* event, const char* result, void *user_info)
233 {
234         if (0 != __vce_get_feature_enabled()) {
235                 return VCE_ERROR_NOT_SUPPORTED;
236         }
237
238         int ret = VCE_ERROR_NONE;
239
240         if (NULL == engine_app_id || NULL == event) {
241                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
242                 return VCE_ERROR_INVALID_PARAMETER;
243         }
244
245         if (NULL == result) {
246                 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
247         }
248
249         ret = vcd_send_specific_engine_result(engine_app_id, event, result, user_info);
250         if (0 != ret) {
251                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send specific engine result, ret(%d)", ret);
252         } else {
253                 SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send specific engine result, event(%s), result(%s)", event, result);
254         }
255
256         return ret;
257 }
258
259 int vce_send_nlg_result(const char* nlg_result, void *user_data)
260 {
261         if (0 != __vce_get_feature_enabled()) {
262                 return VCE_ERROR_NOT_SUPPORTED;
263         }
264
265         int ret = VCE_ERROR_NONE;
266
267         if (NULL == nlg_result) {
268                 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
269         }
270
271         ret = vcd_send_nlg_result(nlg_result, user_data);
272         if (0 != ret) {
273                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send NLG result");
274         } else {
275                 SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send NLG result");
276         }
277
278         return ret;
279 }
280
281 int vce_send_error(vce_error_e error, const char* msg, void *user_data)
282 {
283         if (0 != __vce_get_feature_enabled()) {
284                 return VCE_ERROR_NOT_SUPPORTED;
285         }
286
287         int ret = VCE_ERROR_NONE;
288
289         if (NULL == msg) {
290                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Input parameter is NULL. (no error message)");
291         }
292
293         ret = vcd_send_error(error, msg, user_data);
294
295         if (0 != ret) {
296                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send error");
297         }
298
299         return ret;
300 }
301
302
303 /* Daemon API */
304 int vce_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data)
305 {
306         if (0 != __vce_get_feature_enabled()) {
307                 return VCE_ERROR_NOT_SUPPORTED;
308         }
309
310         int ret = VCE_ERROR_NONE;
311
312         ret = vcd_get_foreach_command(vce_command, callback, user_data);
313         if (0 != ret) {
314                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get foreach command");
315         }
316
317         return ret;
318 }
319
320 int vce_get_command_count(vce_cmd_h vce_command, int* count)
321 {
322         if (0 != __vce_get_feature_enabled()) {
323                 return VCE_ERROR_NOT_SUPPORTED;
324         }
325
326         int ret = VCE_ERROR_NONE;
327
328         if (NULL == count) {
329                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
330                 return VCE_ERROR_INVALID_PARAMETER;
331         }
332         ret = vcd_get_command_count(vce_command, count);
333         if (0 != ret) {
334                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get command count");
335         }
336
337         return ret;
338 }
339
340 int vce_get_audio_type(char** audio_type)
341 {
342         if (0 != __vce_get_feature_enabled()) {
343                 return VCE_ERROR_NOT_SUPPORTED;
344         }
345         if (0 != __vce_check_privilege()) {
346                 return VCE_ERROR_PERMISSION_DENIED;
347         }
348
349         int ret = VCE_ERROR_NONE;
350
351         ret = vcd_get_audio_type(audio_type);
352         if (0 != ret) {
353                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get audio type");
354         }
355
356         return ret;
357 }
358
359 int vce_set_private_data(const char* key, const char* data)
360 {
361         if (0 != __vce_get_feature_enabled()) {
362                 return VCE_ERROR_NOT_SUPPORTED;
363         }
364         if (0 != __vce_check_privilege()) {
365                 return VCE_ERROR_PERMISSION_DENIED;
366         }
367
368         int ret = VCE_ERROR_NONE;
369
370         if (NULL == key || NULL == data) {
371                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
372                 return VCE_ERROR_INVALID_PARAMETER;
373         }
374
375         if (!strncmp(key, "UpdateEventStart", strlen(key)))
376                 ret = vce_send_update_status(VCE_UPDATE_EVENT_START, NULL);
377         else if (!strncmp(data, "UpdateEventComplete", strlen(key)))
378                 ret = vce_send_update_status(VCE_UPDATE_EVENT_FINISH, NULL);
379         else if (!strncmp(data, "UpdateEventFail", strlen(key)))
380                 ret = vce_send_update_status(VCE_UPDATE_EVENT_FAIL, data);
381         if (0 != ret) {
382                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send update status, event(%s), msg(%s): ret(%d)", key, data, ret);
383                 return ret;
384         }
385
386         ret = vcd_set_private_data(key, data);
387         if (0 != ret) {
388                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data to vc manager");
389         }
390
391         return ret;
392 }
393
394 int vce_get_private_data(const char* key, char** data)
395 {
396         if (0 != __vce_get_feature_enabled()) {
397                 return VCE_ERROR_NOT_SUPPORTED;
398         }
399         if (0 != __vce_check_privilege()) {
400                 return VCE_ERROR_PERMISSION_DENIED;
401         }
402
403         int ret = VCE_ERROR_NONE;
404
405         if (NULL == key || NULL == data) {
406                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
407                 return VCE_ERROR_INVALID_PARAMETER;
408         }
409
410         ret = vcd_get_private_data(key, data);
411         if (0 != ret) {
412                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get private data from vc manager");
413         }
414
415         return ret;
416 }
417
418 int vce_start_recording()
419 {
420         if (0 != __vce_get_feature_enabled()) {
421                 return VCE_ERROR_NOT_SUPPORTED;
422         }
423         if (0 != __vce_check_privilege()) {
424                 return VCE_ERROR_PERMISSION_DENIED;
425         }
426
427         int ret = VCE_ERROR_NONE;
428
429         ret = vcd_start_recording();
430         if (0 != ret) {
431                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to start recording");
432         }
433
434         return ret;
435 }
436
437 int vce_stop_recording()
438 {
439         if (0 != __vce_get_feature_enabled()) {
440                 return VCE_ERROR_NOT_SUPPORTED;
441         }
442         if (0 != __vce_check_privilege()) {
443                 return VCE_ERROR_PERMISSION_DENIED;
444         }
445
446         int ret = VCE_ERROR_NONE;
447
448         ret = vcd_stop_recording();
449         if (0 != ret) {
450                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to stop recording");
451         }
452
453         return ret;
454 }
455
456 int vce_send_update_status(vce_update_event_e update_event, const char* msg)
457 {
458         if (0 != __vce_get_feature_enabled()) {
459                 return VCE_ERROR_NOT_SUPPORTED;
460         }
461         if (0 != __vce_check_privilege()) {
462                 return VCE_ERROR_PERMISSION_DENIED;
463         }
464
465         int ret = vcd_send_update_status(update_event, msg);
466         if (0 != ret) {
467                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send update status");
468         }
469
470         return ret;
471 }
472
473 int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func)
474 {
475         if (0 != __vce_get_feature_enabled()) {
476                 return VCE_ERROR_NOT_SUPPORTED;
477         }
478         if (0 != __vce_check_privilege()) {
479                 return VCE_ERROR_PERMISSION_DENIED;
480         }
481
482         if (NULL == callback_func) {
483                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
484                 return VCE_ERROR_INVALID_PARAMETER;
485         }
486
487         int ret = vcd_set_private_data_set_cb(callback_func);
488         if (0 != ret) {
489                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data set cb");
490         }
491
492         return ret;
493 }
494
495 int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
496 {
497         if (0 != __vce_get_feature_enabled()) {
498                 return VCE_ERROR_NOT_SUPPORTED;
499         }
500         if (0 != __vce_check_privilege()) {
501                 return VCE_ERROR_PERMISSION_DENIED;
502         }
503
504         if (NULL == callback_func) {
505                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
506                 return VCE_ERROR_INVALID_PARAMETER;
507         }
508
509         int ret = vcd_set_private_data_requested_cb(callback_func);
510         if (0 != ret) {
511                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data requested cb");
512         }
513
514         return ret;
515 }
516
517 int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func)
518 {
519         if (0 != __vce_get_feature_enabled()) {
520                 return VCE_ERROR_NOT_SUPPORTED;
521         }
522
523         if (NULL == callback_func) {
524                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
525                 return VCE_ERROR_INVALID_PARAMETER;
526         }
527
528         int ret = vcd_set_nlu_base_info_requested_cb(callback_func);
529         if (0 != ret) {
530                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set nlu-base info requested cb");
531         }
532
533         return ret;
534 }
535
536 int vce_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_func)
537 {
538         if (0 != __vce_get_feature_enabled()) {
539                 return VCE_ERROR_NOT_SUPPORTED;
540         }
541
542         if (NULL == callback_func) {
543                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
544                 return VCE_ERROR_INVALID_PARAMETER;
545         }
546
547         int ret = vcd_set_specific_engine_request_cb(callback_func);
548         if (0 != ret) {
549                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set specific engine request cb");
550         }
551
552         return ret;
553 }
554
555 int vce_unset_specific_engine_request_cb(void)
556 {
557         if (0 != __vce_get_feature_enabled()) {
558                 return VCE_ERROR_NOT_SUPPORTED;
559         }
560
561         int ret = vcd_set_specific_engine_request_cb(NULL);
562         if (0 != ret) {
563                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to unset specific engine request cb");
564         }
565
566         return ret;
567 }
568
569 /* for TTS feedback */
570 int vce_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_audio_type_e audio_type)
571 {
572         if (0 != __vce_get_feature_enabled()) {
573                 return VCE_ERROR_NOT_SUPPORTED;
574         }
575
576         int ret = VCE_ERROR_NONE;
577
578         if (channel < VCE_AUDIO_CHANNEL_MONO || channel > VCE_AUDIO_CHANNEL_STEREO) {
579                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
580                 return VCE_ERROR_INVALID_PARAMETER;
581         }
582
583         if (audio_type < VCE_AUDIO_TYPE_PCM_S16_LE || audio_type > VCE_AUDIO_TYPE_PCM_U8) {
584                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
585                 return VCE_ERROR_INVALID_PARAMETER;
586         }
587
588         ret = vcd_send_feedback_audio_format(rate, channel, audio_type);
589         if (0 != ret) {
590                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send feedback audio format");
591         }
592
593         return ret;
594 }
595
596 int vce_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int len)
597 {
598         if (0 != __vce_get_feature_enabled()) {
599                 return VCE_ERROR_NOT_SUPPORTED;
600         }
601
602         int ret = VCE_ERROR_NONE;
603
604         if (NULL == buffer) {
605                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Input parameter is NULL");
606                 return VCE_ERROR_INVALID_PARAMETER;
607         }
608
609         ret = vcd_send_feedback_streaming(event, buffer, len);
610         if (0 != ret) {
611                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send feedback streaming");
612         }
613
614         return ret;
615 }
616
617 int vce_set_request_tts_cb(vce_request_tts_cb callback_func, void* user_data)
618 {
619         if (NULL == callback_func) {
620                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
621                 return VCE_ERROR_INVALID_PARAMETER;
622         }
623
624         int ret = vcd_set_request_tts_cb(callback_func, user_data);
625         if (0 != ret) {
626                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set request tts cb");
627         }
628
629         return ret;
630 }
631
632 int vce_unset_request_tts_cb(void)
633 {
634         int ret = vcd_set_request_tts_cb(NULL, NULL);
635         if (0 != ret) {
636                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to unset request tts cb");
637         }
638
639         return ret;
640 }
641
642 int vce_set_cancel_tts_cb(vce_cancel_tts_cb callback_func, void* user_data)
643 {
644         if (NULL == callback_func) {
645                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
646                 return VCE_ERROR_INVALID_PARAMETER;
647         }
648
649         int ret = vcd_set_cancel_tts_cb(callback_func, user_data);
650         if (0 != ret) {
651                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set cancel tts cb");
652         }
653
654         return ret;
655 }
656
657 int vce_unset_cancel_tts_cb(void)
658 {
659         int ret = vcd_set_cancel_tts_cb(NULL, NULL);
660         if (0 != ret) {
661                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to unset cancel tts cb");
662         }
663
664         return ret;
665 }
666
667 int vce_set_tts_audio_format_request_cb(vce_tts_audio_format_request_cb callback_func, void* user_data)
668 {
669         if (NULL == callback_func) {
670                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
671                 return VCE_ERROR_INVALID_PARAMETER;
672         }
673
674         int ret = vcd_set_tts_audio_format_request_cb(callback_func, user_data);
675         if (0 != ret) {
676                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set get tts audio format cb");
677         }
678
679         return ret;
680 }
681
682 int vce_unset_get_tts_audio_format_cb(void)
683 {
684         int ret = vcd_set_tts_audio_format_request_cb(NULL, NULL);
685         if (0 != ret) {
686                 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to unset request tts cb");
687         }
688
689         return ret;
690 }