2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include "vc_mgr_client.h"
23 #include "vc_mgr_tidl.h"
24 #include "vc_mgr_proxy.h"
25 #include "vc_mgr_stub.h"
26 #include "vc_command.h"
30 bool connection_requesting;
31 bool register_callback_invoked;
32 rpc_port_proxy_vc_mgr_proxy_vc_mgr_h rpc_h;
33 rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_h notify_cb_h;
34 rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_h send_buffer_cb_h;
39 bool register_callback_requesting;
40 } vcd_mgr_tidl_info_s;
42 static vc_mgr_tidl_info_s* g_proxy_tidl_info = NULL;
44 static vcd_mgr_tidl_info_s* g_stub_tidl_info = NULL;
46 static pthread_mutex_t g_tidl_mutex = PTHREAD_MUTEX_INITIALIZER;
48 static rpc_port_stub_vc_mgr_stub_vcd_mgr_callback_s g_mgr_callback;
50 static int g_volume_count = 0;
53 extern void __vc_mgr_cb_all_result(vc_result_type_e type);
55 extern void __vc_mgr_cb_pre_result(int event, const char* pre_result);
57 extern void __vc_mgr_cb_system_result();
59 extern void __vc_mgr_cb_speech_detected();
61 extern int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg);
63 extern int __vc_mgr_cb_set_volume(float volume);
65 extern int __vc_mgr_cb_service_state(int state);
67 extern int __vc_mgr_cb_set_foreground(int pid, bool value);
69 extern int __vc_mgr_cb_private_data_set(const char* key, const char* data);
71 extern int __vc_mgr_cb_private_data_requested(const char* key, char** data);
73 /* for TTS feedback */
74 extern int __vc_mgr_cb_feedback_audio_format(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type);
76 extern int __vc_mgr_cb_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len);
79 extern int __vc_mgr_request_auth_enable(int pid);
81 extern int __vc_mgr_request_auth_disable(int pid);
83 extern int __vc_mgr_request_auth_start(int pid);
85 extern int __vc_mgr_request_auth_stop(int pid);
87 extern int __vc_mgr_request_auth_cancel(int pid);
89 extern int __vc_mgr_cb_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous);
91 extern void __vc_mgr_cb_specific_engine_result(const char* engine_app_id, const char* event, const char* result);
93 static void __notify_cb(void *user_data, bundle *msg)
98 SLOG(LOG_DEBUG, TAG_VCM, "__notify_cb is invoked");
100 bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
102 if (0 == strncmp(VCD_MANAGER_METHOD_SET_VOLUME, method, strlen(VCD_MANAGER_METHOD_SET_VOLUME))) {
103 bundle_get_str(msg, VC_BUNDLE_VOLUME, &val);
109 if (10 == g_volume_count) {
110 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Set volume");
111 SLOG(LOG_DEBUG, TAG_VCM, "@@ vc mgr set volume : volume(%f)", volume);
116 __vc_mgr_cb_set_volume(volume);
119 } /* VCD_MANAGER_METHOD_SET_VOLUME */
121 else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) {
122 bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val);
126 SLOG(LOG_INFO, TAG_VCM, "@@ state changed : %d", state);
127 __vc_mgr_cb_service_state(state);
129 } /* VCD_METHOD_SET_SERVICE_STATE */
131 else if (0 == strncmp(VCD_MANAGER_METHOD_SPEECH_DETECTED, method, strlen(VCD_MANAGER_METHOD_SPEECH_DETECTED))) {
132 SLOG(LOG_INFO, TAG_VCM, "@@@ Get Speech detected");
134 __vc_mgr_cb_speech_detected();
135 } /* VCD_MANAGER_METHOD_SPEECH_DETECTED */
137 else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT))) {
138 SLOG(LOG_INFO, TAG_VCM, "@@@ Get All Result");
140 bundle_get_str(msg, VC_BUNDLE_RESULT, &val);
143 __vc_mgr_cb_all_result((vc_result_type_e)atoi(val));
145 } /* VCD_MANAGER_METHOD_ALL_RESULT */
147 else if (0 == strncmp(VCD_MANAGER_METHOD_PRE_RESULT, method, strlen(VCD_MANAGER_METHOD_PRE_RESULT))) {
148 SLOG(LOG_INFO, TAG_VCM, "@@@ Get Pre Result");
150 char* pre_result = NULL;
152 bundle_get_str(msg, VC_BUNDLE_EVENT, &event);
153 bundle_get_str(msg, VC_BUNDLE_PRE_RESULT, &pre_result);
155 if (NULL != pre_result) {
156 __vc_mgr_cb_pre_result((vc_pre_result_event_e)atoi(event), pre_result);
158 } /* VCD_MANAGER_METHOD_PRE_RESULT */
160 else if (0 == strncmp(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT, method, strlen(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT))) {
161 SLOG(LOG_INFO, TAG_VCM, "@@@ Get specific engine result");
162 char* engine_app_id = NULL;
166 bundle_get_str(msg, VC_BUNDLE_ENGINE_APP_ID, &engine_app_id);
167 bundle_get_str(msg, VC_BUNDLE_EVENT, &event);
168 bundle_get_str(msg, VC_BUNDLE_RESULT, &result);
170 if (NULL != result) {
171 gsize decodingSize=0;
172 gchar *gDecodedResult = (gchar *)g_base64_decode((const gchar *)result, &decodingSize);
175 SLOG(LOG_WARN, TAG_VCM, "@@@ Get specific engine result --> %s", gDecodedResult);
176 __vc_mgr_cb_specific_engine_result(engine_app_id, event, gDecodedResult);
177 g_free(gDecodedResult);
180 } /* VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT */
182 else if (0 == strncmp(VCD_MANAGER_METHOD_RESULT, method, strlen(VCD_MANAGER_METHOD_RESULT))) {
183 SLOG(LOG_INFO, TAG_VCM, "@@@ Get System Result");
185 __vc_mgr_cb_system_result();
186 } /* VCD_MANAGER_METHOD_RESULT */
188 else if (0 == strncmp(VCD_MANAGER_METHOD_DIALOG, method, strlen(VCD_MANAGER_METHOD_DIALOG))) {
189 SLOG(LOG_INFO, TAG_VCM, "@@@ Request Dialog");
191 char* disp_text = NULL;
192 char* utt_text = NULL;
193 char* continous = NULL;
195 bundle_get_str(msg, VC_BUNDLE_PID, &pid);
196 bundle_get_str(msg, VC_BUNDLE_DISP_TEXT, &disp_text);
197 bundle_get_str(msg, VC_BUNDLE_UTT_TEXT, &utt_text);
198 bundle_get_str(msg, VC_BUNDLE_CONTINUOUS, &continous);
200 if (!strncmp(disp_text, "#NULL", strlen("#NULL") + 1))
202 if (!strncmp(utt_text, "#NULL", strlen("#NULL") + 1))
205 __vc_mgr_cb_dialog(atoi(pid), disp_text, utt_text, (bool)atoi(continous));
206 } /* VCD_MANAGER_METHOD_DIALOG */
208 else if (0 == strncmp(VCD_MANAGER_METHOD_ERROR, method, strlen(VCD_MANAGER_METHOD_ERROR))) {
209 SLOG(LOG_INFO, TAG_VCM, "@@@ Get Error");
211 char* daemon_pid = NULL;
212 char* err_msg = NULL;
214 bundle_get_str(msg, VC_BUNDLE_REASON, &reason);
215 bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &daemon_pid);
216 bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg);
218 char* temp_msg = NULL;
219 if (NULL != err_msg && strncmp(err_msg, "#NULL", strlen("#NULL") + 1)) {
220 temp_msg = strdup(err_msg);
222 SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr Get Error message : reason(%d), daemon_pid(%d), msg(%s)", atoi(reason), atoi(daemon_pid), (temp_msg) ? temp_msg : "NULL");
223 __vc_mgr_cb_error(atoi(reason), atoi(daemon_pid), temp_msg);
224 if (NULL != temp_msg) {
228 } /* VCD_MANAGER_METHOD_ERROR */
230 else if (0 == strncmp(VCD_MANAGER_METHOD_SET_PRIVATE_DATA, method, strlen(VCD_MANAGER_METHOD_SET_PRIVATE_DATA))) {
231 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request set private data");
234 char* private_data = NULL;
236 bundle_get_str(msg, VC_BUNDLE_PID, &pid);
237 bundle_get_str(msg, VC_BUNDLE_KEY, &key);
238 bundle_get_str(msg, VC_BUNDLE_PRIVATE_DATA, &private_data);
240 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request set private data : pid(%d) ", atoi(pid));
242 __vc_mgr_cb_private_data_set(key, private_data);
244 SLOG(LOG_ERROR, TAG_VCM, "@@ got invalid pid(%d)", atoi(pid));
246 } /* VCD_MANAGER_METHOD_SET_PRIVATE_DATA */
248 else if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT))) {
249 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request feedback audio format");
250 char* channel = NULL;
251 char* audio_type = NULL;
254 bundle_get_str(msg, VC_BUNDLE_AUDIO_CHANNEL, &channel);
255 bundle_get_str(msg, VC_BUNDLE_AUDIO_TYPE, &audio_type);
256 bundle_get_str(msg, VC_BUNDLE_AUDIO_RATE, &rate);
258 __vc_mgr_cb_feedback_audio_format(atoi(rate), (vc_audio_channel_e)atoi(channel), (vc_audio_type_e)atoi(audio_type));
259 } /* VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT */
261 // TODO: uncomment this line after vcc done
262 // NEED2CHECK: when vcc send 'set_foreground', __vcd_mgr_set_foreground_cb will be invoked...
263 // else if (0 == strncmp(VCC_MANAGER_METHOD_SET_FOREGROUND, method, strlen(VCC_MANAGER_METHOD_SET_FOREGROUND))) {
264 // SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground");
265 // char* temp_pid = NULL;
266 // char* temp_value = NULL;
270 // bundle_get_str(msg, VC_BUNDLE_PID, &temp_pid);
271 // bundle_get_str(msg, VC_BUNDLE_VALUE, &temp_value);
272 // pid = atoi(temp_pid);
273 // value = atoi(temp_value);
275 // SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false");
277 // __vc_mgr_cb_set_foreground(pid, (bool)value);
278 // } /* VCC_MANAGER_METHOD_SET_FOREGROUND */
281 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid msg");
284 SLOG(LOG_DEBUG, TAG_VCM, "@@@ __notify_cb DONE");
287 static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_char_h data_in, bundle *msg)
292 SLOG(LOG_DEBUG, TAG_VCM, "__send_buffer_cb is invoked");
294 bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
296 if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_STREAMING, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_STREAMING))) {
302 bundle_get_str(msg, VC_BUNDLE_PID, &val);
303 bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id);
304 bundle_get_str(msg, VC_BUNDLE_EVENT, &event);
306 rpc_port_proxy_vc_mgr_proxy_array_char_get(data_in, &buffer, &len);
307 __vc_mgr_cb_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len);
310 SLOG(LOG_INFO, TAG_VCM, "@@@ __send_buffer_cb DONE");
311 } /* VCD_MANAGER_METHOD_FEEDBACK_STREAMING */
314 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid msg");
319 static void __on_connected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data)
321 g_proxy_tidl_info->connected = true;
322 g_proxy_tidl_info->connection_requesting = false;
323 g_proxy_tidl_info->register_callback_invoked = false;
325 SLOG(LOG_INFO, TAG_VCM, "Connected to server");
328 static void __on_disconnected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data)
330 g_proxy_tidl_info->connected = false;
331 g_proxy_tidl_info->connection_requesting = false;
332 g_proxy_tidl_info->register_callback_invoked = false;
334 SLOG(LOG_INFO, TAG_VCM, "Disonnected to server");
336 __vc_mgr_cb_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected");
339 static void __on_rejected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data)
341 g_proxy_tidl_info->connection_requesting = false;
342 g_proxy_tidl_info->register_callback_invoked = false;
344 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Rejected from server");
348 static rpc_port_proxy_vc_mgr_proxy_vc_mgr_h __create_rpc_port(const char* engine_app_id)
350 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] __create_rpc_port");
351 rpc_port_proxy_vc_mgr_proxy_vc_mgr_callback_s rpc_callback = {
352 .connected = __on_connected,
353 .disconnected = __on_disconnected,
354 .rejected = __on_rejected
357 rpc_port_proxy_vc_mgr_proxy_vc_mgr_h handle = NULL;
358 if (0 != rpc_port_proxy_vc_mgr_proxy_vc_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) {
359 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create proxy");
366 static void __vcd_mgr_create_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, void *user_data)
368 g_stub_tidl_info->connected = true;
369 g_stub_tidl_info->register_callback_requesting = false;
371 SLOG(LOG_DEBUG, TAG_VCM, "Connected to server");
375 rpc_port_stub_vc_mgr_stub_vcd_mgr_context_get_sender(context, &sender);
377 SLOG(LOG_ERROR, TAG_VCM, "@@@ Sender is NULL");
381 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Server connect. appid(%s)", sender);
385 static void __vcd_mgr_terminate_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, void *user_data)
387 g_stub_tidl_info->connected = false;
388 g_stub_tidl_info->register_callback_requesting = false;
390 rpc_port_stub_vc_mgr_stub_vcd_mgr_context_set_tag(context, NULL);
393 rpc_port_stub_vc_mgr_stub_vcd_mgr_context_get_sender(context, &sender);
397 SLOG(LOG_INFO, TAG_VCM, "@@@ Server disconnect. appid(%s)", sender);
401 static void __vcd_mgr_set_foreground_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, int value, void *user_data)
403 SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground");
404 SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false");
406 __vc_mgr_cb_set_foreground(pid, (bool)value);
408 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Set foreground DONE");
411 static int __vcd_mgr_get_private_data_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, const char *key, char **data, void *user_data)
413 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request get private data");
414 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request get private data : pid(%d) ", pid);
417 char *temp_data = NULL;
419 ret = __vc_mgr_cb_private_data_requested(key, &temp_data);
421 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
424 if (NULL == temp_data) {
425 SLOG(LOG_INFO, TAG_VCM, "data parameter is NULL");
426 temp_data = strdup("#NULL");
429 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request get private data DONE");
434 static int __vcd_mgr_auth_enable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
436 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth enable");
437 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth enable : pid(%d)", pid);
441 ret = __vc_mgr_request_auth_enable(pid);
443 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
446 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth enable DONE");
451 static int __vcd_mgr_auth_disable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
453 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth disable");
454 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth disable : pid(%d)", pid);
458 ret = __vc_mgr_request_auth_disable(pid);
460 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
463 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth disable DONE");
468 static int __vcd_mgr_auth_start_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
470 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth start");
471 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth start : pid(%d)", pid);
475 ret = __vc_mgr_request_auth_start(pid);
477 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
480 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth start DONE");
485 static int __vcd_mgr_auth_stop_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
487 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth stop");
488 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth stop : pid(%d)", pid);
492 ret = __vc_mgr_request_auth_stop(pid);
494 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
497 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth stop DONE");
502 static int __vcd_mgr_auth_cancel_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
504 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth cancel");
505 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth cancel : pid(%d)", pid);
509 ret = __vc_mgr_request_auth_cancel(pid);
511 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
514 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth cancel DONE");
519 static int __register_stub_callback()
521 if (g_stub_tidl_info->register_callback_requesting) {
522 return VC_ERROR_NONE;
525 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] __register_stub_callback");
527 g_mgr_callback.create = __vcd_mgr_create_cb;
528 g_mgr_callback.terminate = __vcd_mgr_terminate_cb;
529 g_mgr_callback.set_foreground = __vcd_mgr_set_foreground_cb;
530 g_mgr_callback.get_private_data = __vcd_mgr_get_private_data_cb;
531 g_mgr_callback.auth_enable = __vcd_mgr_auth_enable_cb;
532 g_mgr_callback.auth_disable = __vcd_mgr_auth_disable_cb;
533 g_mgr_callback.auth_start = __vcd_mgr_auth_start_cb;
534 g_mgr_callback.auth_stop = __vcd_mgr_auth_stop_cb;
535 g_mgr_callback.auth_cancel = __vcd_mgr_auth_cancel_cb;
538 ret = rpc_port_stub_vc_mgr_stub_vcd_mgr_register(&g_mgr_callback, NULL);
540 SLOG(LOG_DEBUG, TAG_VCM, "register callback");
541 g_stub_tidl_info->register_callback_requesting = true;
542 return VC_ERROR_NONE;
545 SLOG(LOG_ERROR, TAG_VCM, "Fail to register callback(%d)", ret);
546 return VC_ERROR_OPERATION_FAILED;
549 int vc_mgr_tidl_open_connection()
551 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_open_connection");
552 pthread_mutex_lock(&g_tidl_mutex);
554 if (NULL != g_proxy_tidl_info) {
555 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] g_proxy_tidl_info already created");
556 pthread_mutex_unlock(&g_tidl_mutex);
557 return VC_ERROR_NONE;
560 g_proxy_tidl_info = (vc_mgr_tidl_info_s*)calloc(1, sizeof(vc_mgr_tidl_info_s));
562 if (NULL == g_proxy_tidl_info) {
563 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create vc_mgr_tidl_info_s");
564 pthread_mutex_unlock(&g_tidl_mutex);
565 return VC_ERROR_OUT_OF_MEMORY;
568 char* engine_app_id = vconf_get_str(VC_ENGINE_DB_DEFAULT);
569 if (NULL == engine_app_id) {
570 SLOG(LOG_ERROR, TAG_VCM, "[TIDL] vconf not found");
571 free(g_proxy_tidl_info);
572 g_proxy_tidl_info = NULL;
573 pthread_mutex_unlock(&g_tidl_mutex);
574 return VC_ERROR_ENGINE_NOT_FOUND;
577 g_proxy_tidl_info->rpc_h = __create_rpc_port(engine_app_id);
578 if (NULL == g_proxy_tidl_info->rpc_h) {
579 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create proxy");
581 free(g_proxy_tidl_info);
582 g_proxy_tidl_info = NULL;
583 pthread_mutex_unlock(&g_tidl_mutex);
584 return VC_ERROR_OPERATION_FAILED;
587 SLOG(LOG_INFO, TAG_VCM, "[TIDL] rpc_h(%p), engine_app_id(%s)", g_proxy_tidl_info->rpc_h, engine_app_id);
590 g_stub_tidl_info = (vcd_mgr_tidl_info_s*)calloc(1, sizeof(vcd_mgr_tidl_info_s));
592 if (NULL == g_stub_tidl_info) {
593 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create vcd_mgr_tidl_info_s");
594 pthread_mutex_unlock(&g_tidl_mutex);
595 return VC_ERROR_OUT_OF_MEMORY;
598 __register_stub_callback();
600 pthread_mutex_unlock(&g_tidl_mutex);
602 return VC_ERROR_NONE;
605 int vc_mgr_tidl_close_connection()
607 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_close_connection");
608 pthread_mutex_lock(&g_tidl_mutex);
610 if (NULL == g_proxy_tidl_info) {
611 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
612 pthread_mutex_unlock(&g_tidl_mutex);
613 return VC_ERROR_OPERATION_FAILED;
616 if (0 != rpc_port_proxy_vc_mgr_proxy_vc_mgr_destroy(g_proxy_tidl_info->rpc_h)) {
617 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to destroy tidl handle");
618 pthread_mutex_unlock(&g_tidl_mutex);
619 return VC_ERROR_OPERATION_FAILED;
622 g_proxy_tidl_info->rpc_h = NULL;
623 g_proxy_tidl_info->notify_cb_h = NULL;
624 g_proxy_tidl_info->send_buffer_cb_h = NULL;
626 free(g_proxy_tidl_info);
627 g_proxy_tidl_info = NULL;
629 free(g_stub_tidl_info);
630 g_stub_tidl_info = NULL;
632 pthread_mutex_unlock(&g_tidl_mutex);
634 return VC_ERROR_NONE;
637 static int __convert_unhandled_error(int ret)
639 if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
640 return VC_ERROR_OPERATION_FAILED;
646 static void __request_tidl_connect()
648 if (g_proxy_tidl_info->connection_requesting) {
652 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_connect(g_proxy_tidl_info->rpc_h);
653 SLOG(LOG_INFO, TAG_VCM, "[INFO] Request connection to stub. ret(%d)", ret);
656 g_proxy_tidl_info->connection_requesting = true;
660 static int __create_callback_handles()
662 if (NULL != g_proxy_tidl_info->notify_cb_h) {
663 rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->notify_cb_h);
664 g_proxy_tidl_info->notify_cb_h = NULL;
667 if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_create(&g_proxy_tidl_info->notify_cb_h)) {
668 return VC_ERROR_OUT_OF_MEMORY;
671 rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_set_callback(g_proxy_tidl_info->notify_cb_h, __notify_cb, NULL);
673 rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_set_once(g_proxy_tidl_info->notify_cb_h, false);
675 if (NULL != g_proxy_tidl_info->send_buffer_cb_h) {
676 rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->send_buffer_cb_h);
677 g_proxy_tidl_info->send_buffer_cb_h = NULL;
680 if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_create(&g_proxy_tidl_info->send_buffer_cb_h)) {
681 return VC_ERROR_OUT_OF_MEMORY;
684 rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_set_callback(g_proxy_tidl_info->send_buffer_cb_h, __send_buffer_cb, NULL);
686 rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_set_once(g_proxy_tidl_info->send_buffer_cb_h, false);
688 return VC_ERROR_NONE;
691 static int __invoke_register_callback()
693 if (g_proxy_tidl_info->register_callback_invoked) {
694 SLOG(LOG_ERROR, TAG_VCM, "[INFO] Already register callback is invoked");
695 return VC_ERROR_NONE;
698 int ret = __create_callback_handles(g_proxy_tidl_info);
699 if (VC_ERROR_NONE != ret) {
700 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create callback handle. ret(%d)", ret);
701 return VC_ERROR_OPERATION_FAILED;
704 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_register_cb(g_proxy_tidl_info->rpc_h, getpid(), g_proxy_tidl_info->notify_cb_h, g_proxy_tidl_info->send_buffer_cb_h);
705 g_proxy_tidl_info->register_callback_invoked = true;
706 return VC_ERROR_NONE;
709 int vc_mgr_tidl_request_hello()
711 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_hello");
713 if (NULL == g_proxy_tidl_info) {
714 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get proxy tidl info");
715 return VC_ERROR_OPERATION_FAILED;
718 if (!g_proxy_tidl_info->connected) {
719 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Proxy Not Connected");
720 __request_tidl_connect();
721 return VC_ERROR_OPERATION_FAILED;
724 if (VC_ERROR_NONE != __invoke_register_callback()) {
725 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to invoke register callback");
726 return VC_ERROR_OPERATION_FAILED;
729 if (NULL == g_stub_tidl_info) {
730 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get stub tidl info");
731 return VC_ERROR_OPERATION_FAILED;
734 if (!g_stub_tidl_info->connected) {
735 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Stub Not Connected");
736 int ret = __register_stub_callback();
740 SLOG(LOG_DEBUG, TAG_VCM, ">>>>> VCM Hello");
742 SLOG(LOG_DEBUG, TAG_VCM, "<<<<");
744 return VC_ERROR_NONE;
747 int vc_mgr_tidl_request_initialize(int pid, int audio_streaming_mode, int* service_state, int* foreground, int* daemon_pid)
749 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_initialize");
751 if (NULL == g_proxy_tidl_info) {
752 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
753 return VC_ERROR_OPERATION_FAILED;
756 int tmp_service_state = 0;
757 int tmp_forground = 0;
758 int tmp_daemon_pid = 0;
760 if (!g_proxy_tidl_info->connected) {
761 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
762 return VC_ERROR_OPERATION_FAILED;
765 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, audio_streaming_mode, &tmp_service_state, &tmp_forground, &tmp_daemon_pid);
766 int exception = get_last_result();
767 if (RPC_PORT_ERROR_NONE != exception) {
768 ret = __convert_unhandled_error(exception);
771 if (VC_ERROR_NONE != ret) {
772 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager initialize : Fail to invoke message, error(%d)", ret);
776 *service_state = tmp_service_state;
777 *foreground = tmp_forground;
778 *daemon_pid = tmp_daemon_pid;
780 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc manager initialize: service_state(%d), foreground(%d), daemon_pid(%d)", *service_state, *foreground, *daemon_pid);
782 return VC_ERROR_NONE;
785 int vc_mgr_tidl_request_finalize(int pid)
787 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_finalize");
789 if (NULL == g_proxy_tidl_info) {
790 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
791 return VC_ERROR_OPERATION_FAILED;
794 if (!g_proxy_tidl_info->connected) {
795 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
796 return VC_ERROR_OPERATION_FAILED;
799 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_finalize(g_proxy_tidl_info->rpc_h, pid);
800 int exception = get_last_result();
801 if (RPC_PORT_ERROR_NONE != exception) {
802 ret = __convert_unhandled_error(exception);
805 if (VC_ERROR_NONE != ret) {
806 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager finalize : Fail to invoke finalize, error(%d)", ret);
810 ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_disconnect(g_proxy_tidl_info->rpc_h);
811 exception = get_last_result();
812 if (RPC_PORT_ERROR_NONE != exception) {
813 ret = __convert_unhandled_error(exception);
816 if (VC_ERROR_NONE != ret) {
817 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager finalize : Fail to disconnect, error(%d)", ret);
821 return VC_ERROR_NONE;
824 int vc_mgr_tidl_request_set_command(int pid)
826 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_command");
828 if (NULL == g_proxy_tidl_info) {
829 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
830 return VC_ERROR_OPERATION_FAILED;
833 if (!g_proxy_tidl_info->connected) {
834 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
835 return VC_ERROR_OPERATION_FAILED;
838 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_command(g_proxy_tidl_info->rpc_h, pid);
839 int exception = get_last_result();
840 if (RPC_PORT_ERROR_NONE != exception) {
841 ret = __convert_unhandled_error(exception);
844 if (VC_ERROR_NONE != ret) {
845 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set command : Fail to invoke message, error(%d)", ret);
849 return VC_ERROR_NONE;
852 int vc_mgr_tidl_request_unset_command(int pid)
854 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_unset_command");
856 if (NULL == g_proxy_tidl_info) {
857 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
858 return VC_ERROR_OPERATION_FAILED;
861 if (!g_proxy_tidl_info->connected) {
862 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
863 return VC_ERROR_OPERATION_FAILED;
866 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_unset_command(g_proxy_tidl_info->rpc_h, pid);
867 int exception = get_last_result();
868 if (RPC_PORT_ERROR_NONE != exception) {
869 ret = __convert_unhandled_error(exception);
872 if (VC_ERROR_NONE != ret) {
873 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager unset command : Fail to invoke message, error(%d)", ret);
877 return VC_ERROR_NONE;
880 int vc_mgr_tidl_request_demandable_client(int pid)
882 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_demandable_client");
884 if (NULL == g_proxy_tidl_info) {
885 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
886 return VC_ERROR_OPERATION_FAILED;
889 if (!g_proxy_tidl_info->connected) {
890 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
891 return VC_ERROR_OPERATION_FAILED;
894 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_demandable_client(g_proxy_tidl_info->rpc_h, pid);
895 int exception = get_last_result();
896 if (RPC_PORT_ERROR_NONE != exception) {
897 ret = __convert_unhandled_error(exception);
900 if (VC_ERROR_NONE != ret) {
901 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager demandable client : Fail to invoke message, error(%d)", ret);
905 return VC_ERROR_NONE;
908 int vc_mgr_tidl_request_set_audio_type(int pid, const char* audio_type)
910 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_audio_type");
912 if (NULL == g_proxy_tidl_info) {
913 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
914 return VC_ERROR_OPERATION_FAILED;
917 if (!g_proxy_tidl_info->connected) {
918 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
919 return VC_ERROR_OPERATION_FAILED;
922 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_audio_type(g_proxy_tidl_info->rpc_h, pid, audio_type);
923 int exception = get_last_result();
924 if (RPC_PORT_ERROR_NONE != exception) {
925 ret = __convert_unhandled_error(exception);
928 if (VC_ERROR_NONE != ret) {
929 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set audio type : Fail to invoke message, error(%d)", ret);
933 return VC_ERROR_NONE;
936 int vc_mgr_tidl_request_get_audio_type(int pid, char** audio_type)
938 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_get_audio_type");
940 if (NULL == g_proxy_tidl_info) {
941 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
942 return VC_ERROR_OPERATION_FAILED;
945 if (!g_proxy_tidl_info->connected) {
946 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
947 return VC_ERROR_OPERATION_FAILED;
951 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_audio_type(g_proxy_tidl_info->rpc_h, pid, &tmp);
952 int exception = get_last_result();
953 if (RPC_PORT_ERROR_NONE != exception) {
954 ret = __convert_unhandled_error(exception);
957 if (VC_ERROR_NONE != ret) {
958 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get audio type : Fail to invoke message, error(%d)", ret);
963 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] Request vc manager get audio type : Success");
967 return VC_ERROR_NONE;
970 int vc_mgr_tidl_request_set_private_data(int pid, const char* key, const char* data)
972 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_private_data");
974 if (NULL == g_proxy_tidl_info) {
975 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
976 return VC_ERROR_OPERATION_FAILED;
979 if (!g_proxy_tidl_info->connected) {
980 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
981 return VC_ERROR_OPERATION_FAILED;
984 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_private_data(g_proxy_tidl_info->rpc_h, pid, key, data);
986 return VC_ERROR_NONE;
989 int vc_mgr_tidl_request_get_private_data(int pid, const char* key, char** data)
991 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_get_private_data");
993 if (NULL == g_proxy_tidl_info) {
994 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
995 return VC_ERROR_OPERATION_FAILED;
998 if (!g_proxy_tidl_info->connected) {
999 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1000 return VC_ERROR_OPERATION_FAILED;
1004 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_private_data(g_proxy_tidl_info->rpc_h, pid, key, &tmp);
1005 int exception = get_last_result();
1006 if (RPC_PORT_ERROR_NONE != exception) {
1007 ret = __convert_unhandled_error(exception);
1010 if (VC_ERROR_NONE != ret) {
1011 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get private data : Fail to invoke message, error(%d)", ret);
1016 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] Request vc manager get private data : Success");
1020 return VC_ERROR_NONE;
1023 int vc_mgr_tidl_request_set_client_info(int pid)
1025 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_client_info");
1027 if (NULL == g_proxy_tidl_info) {
1028 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1029 return VC_ERROR_OPERATION_FAILED;
1032 if (!g_proxy_tidl_info->connected) {
1033 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1034 return VC_ERROR_OPERATION_FAILED;
1037 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_client_info(g_proxy_tidl_info->rpc_h, pid);
1038 int exception = get_last_result();
1039 if (RPC_PORT_ERROR_NONE != exception) {
1040 ret = __convert_unhandled_error(exception);
1043 if (VC_ERROR_NONE != ret) {
1044 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set client info : Fail to invoke message, error(%d)", ret);
1048 return VC_ERROR_NONE;
1051 int vc_mgr_tidl_request_set_domain(int pid, const char* domain)
1053 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_domain");
1055 if (NULL == g_proxy_tidl_info) {
1056 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1057 return VC_ERROR_OPERATION_FAILED;
1060 if (!g_proxy_tidl_info->connected) {
1061 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1062 return VC_ERROR_OPERATION_FAILED;
1065 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_domain(g_proxy_tidl_info->rpc_h, pid, domain);
1066 int exception = get_last_result();
1067 if (RPC_PORT_ERROR_NONE != exception) {
1068 ret = __convert_unhandled_error(exception);
1071 if (VC_ERROR_NONE != ret) {
1072 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set domain : Fail to invoke message, error(%d)", ret);
1076 return VC_ERROR_NONE;
1079 int vc_mgr_tidl_request_do_action(int pid, vc_send_event_type_e type, char* send_event)
1081 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_do_action");
1083 if (NULL == g_proxy_tidl_info) {
1084 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1085 return VC_ERROR_OPERATION_FAILED;
1088 if (!g_proxy_tidl_info->connected) {
1089 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1090 return VC_ERROR_OPERATION_FAILED;
1093 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_do_action(g_proxy_tidl_info->rpc_h, pid, type, send_event);
1095 return VC_ERROR_NONE;
1098 int vc_mgr_tidl_request_start(int pid, int recognition_mode, bool exclusive_command_option, bool start_by_client, int disabled_cmd_type)
1100 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_start");
1102 if (NULL == g_proxy_tidl_info) {
1103 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1104 return VC_ERROR_OPERATION_FAILED;
1107 if (!g_proxy_tidl_info->connected) {
1108 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1109 return VC_ERROR_OPERATION_FAILED;
1112 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_start(g_proxy_tidl_info->rpc_h, pid, recognition_mode, exclusive_command_option, start_by_client, disabled_cmd_type);
1113 int exception = get_last_result();
1114 if (RPC_PORT_ERROR_NONE != exception) {
1115 ret = __convert_unhandled_error(exception);
1118 if (VC_ERROR_NONE != ret) {
1119 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager start : Fail to invoke message, error(%d)", ret);
1123 return VC_ERROR_NONE;
1126 int vc_mgr_tidl_request_stop(int pid)
1128 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_stop");
1130 if (NULL == g_proxy_tidl_info) {
1131 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1132 return VC_ERROR_OPERATION_FAILED;
1135 if (!g_proxy_tidl_info->connected) {
1136 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1137 return VC_ERROR_OPERATION_FAILED;
1140 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_stop(g_proxy_tidl_info->rpc_h, pid);
1141 int exception = get_last_result();
1142 if (RPC_PORT_ERROR_NONE != exception) {
1143 ret = __convert_unhandled_error(exception);
1146 if (VC_ERROR_NONE != ret) {
1147 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager stop : Fail to invoke message, error(%d)", ret);
1151 return VC_ERROR_NONE;
1154 int vc_mgr_tidl_request_cancel(int pid)
1156 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_cancel");
1158 if (NULL == g_proxy_tidl_info) {
1159 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1160 return VC_ERROR_OPERATION_FAILED;
1163 if (!g_proxy_tidl_info->connected) {
1164 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1165 return VC_ERROR_OPERATION_FAILED;
1168 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_cancel(g_proxy_tidl_info->rpc_h, pid);
1169 int exception = get_last_result();
1170 if (RPC_PORT_ERROR_NONE != exception) {
1171 ret = __convert_unhandled_error(exception);
1174 if (VC_ERROR_NONE != ret) {
1175 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager cancel : Fail to invoke message, error(%d)", ret);
1179 return VC_ERROR_NONE;
1182 int vc_mgr_tidl_request_set_audio_streaming_mode(int pid, vc_audio_streaming_mode_e mode)
1184 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_audio_streaming_mode");
1186 if (NULL == g_proxy_tidl_info) {
1187 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1188 return VC_ERROR_OPERATION_FAILED;
1191 if (!g_proxy_tidl_info->connected) {
1192 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1193 return VC_ERROR_OPERATION_FAILED;
1196 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_audio_streaming_mode(g_proxy_tidl_info->rpc_h, pid, mode);
1198 return VC_ERROR_NONE;
1201 int vc_mgr_tidl_send_result_selection(int pid)
1203 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_result_selection");
1205 if (NULL == g_proxy_tidl_info) {
1206 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1207 return VC_ERROR_OPERATION_FAILED;
1210 if (!g_proxy_tidl_info->connected) {
1211 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1212 return VC_ERROR_OPERATION_FAILED;
1215 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_result_selection(g_proxy_tidl_info->rpc_h, pid);
1217 return VC_ERROR_NONE;
1220 int vc_mgr_tidl_send_specific_engine_request(int pid, const char* engine_app_id, const char* event, const char* request)
1222 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_result_selection");
1224 if (NULL == g_proxy_tidl_info) {
1225 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1226 return VC_ERROR_OPERATION_FAILED;
1229 if (!g_proxy_tidl_info->connected) {
1230 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1231 return VC_ERROR_OPERATION_FAILED;
1234 gchar *gEncodedRequest = g_base64_encode((const guchar*)request, strlen(request));
1236 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_specific_engine_request(g_proxy_tidl_info->rpc_h, pid, engine_app_id, event, gEncodedRequest);
1238 if (gEncodedRequest)
1239 g_free(gEncodedRequest);
1241 return VC_ERROR_NONE;
1244 int vc_mgr_tidl_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status)
1246 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_utterance_status");
1248 if (NULL == g_proxy_tidl_info) {
1249 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1250 return VC_ERROR_OPERATION_FAILED;
1253 if (!g_proxy_tidl_info->connected) {
1254 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1255 return VC_ERROR_OPERATION_FAILED;
1258 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_utterance_status(g_proxy_tidl_info->rpc_h, pid, utt_id, utt_status);
1260 return VC_ERROR_NONE;
1263 int vc_mgr_tidl_send_audio_streaming(int pid, vc_audio_streaming_event_e event, unsigned char* buffer, unsigned int len)
1265 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_audio_streaming");
1267 if (NULL == g_proxy_tidl_info) {
1268 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1269 return VC_ERROR_OPERATION_FAILED;
1272 if (!g_proxy_tidl_info->connected) {
1273 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1274 return VC_ERROR_OPERATION_FAILED;
1277 rpc_port_proxy_vc_mgr_proxy_array_char_h data = NULL;
1278 rpc_port_proxy_vc_mgr_proxy_array_char_create(&data);
1280 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create data handle");
1281 return VC_ERROR_OUT_OF_MEMORY;
1284 if (NULL != buffer && 0 < len) {
1285 rpc_port_proxy_vc_mgr_proxy_array_char_set(data, (char*)buffer, len);
1287 SLOG(LOG_ERROR, TAG_VCM, "[TIDL] buffer is empty");
1290 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_audio_streaming(g_proxy_tidl_info->rpc_h, pid, event, data);
1291 rpc_port_proxy_vc_mgr_proxy_array_char_destroy(data);
1293 return VC_ERROR_NONE;