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_mgr_core.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;
52 static void __notify_cb(void *user_data, bundle *msg)
57 SLOG(LOG_DEBUG, TAG_VCM, "__notify_cb is invoked");
59 bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
61 if (0 == strncmp(VCD_MANAGER_METHOD_SET_VOLUME, method, strlen(VCD_MANAGER_METHOD_SET_VOLUME))) {
62 bundle_get_str(msg, VC_BUNDLE_VOLUME, &val);
68 if (10 == g_volume_count) {
69 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Set volume");
70 SLOG(LOG_DEBUG, TAG_VCM, "@@ vc mgr set volume : volume(%f)", volume);
75 vc_mgr_core_send_set_volume(volume);
78 } /* VCD_MANAGER_METHOD_SET_VOLUME */
80 else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) {
81 bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val);
85 SLOG(LOG_INFO, TAG_VCM, "@@ state changed : %d", state);
86 vc_mgr_core_send_service_state(state);
88 } /* VCD_METHOD_SET_SERVICE_STATE */
90 else if (0 == strncmp(VCD_MANAGER_METHOD_SPEECH_DETECTED, method, strlen(VCD_MANAGER_METHOD_SPEECH_DETECTED))) {
91 SLOG(LOG_INFO, TAG_VCM, "@@@ Get Speech detected");
93 vc_mgr_core_send_speech_detected();
94 } /* VCD_MANAGER_METHOD_SPEECH_DETECTED */
96 else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT))) {
97 SLOG(LOG_INFO, TAG_VCM, "@@@ Get All Result");
99 bundle_get_str(msg, VC_BUNDLE_RESULT, &val);
102 vc_mgr_core_send_all_result((vc_result_type_e)atoi(val));
104 } /* VCD_MANAGER_METHOD_ALL_RESULT */
106 else if (0 == strncmp(VCD_MANAGER_METHOD_PRE_RESULT, method, strlen(VCD_MANAGER_METHOD_PRE_RESULT))) {
107 SLOG(LOG_INFO, TAG_VCM, "@@@ Get Pre Result");
109 char* pre_result = NULL;
111 bundle_get_str(msg, VC_BUNDLE_EVENT, &event);
112 bundle_get_str(msg, VC_BUNDLE_PRE_RESULT, &pre_result);
114 if (NULL != pre_result) {
115 vc_mgr_core_send_pre_result((vc_pre_result_event_e)atoi(event), pre_result);
117 } /* VCD_MANAGER_METHOD_PRE_RESULT */
119 else if (0 == strncmp(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT, method, strlen(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT))) {
120 SLOG(LOG_INFO, TAG_VCM, "@@@ Get specific engine result");
121 char* engine_app_id = NULL;
125 bundle_get_str(msg, VC_BUNDLE_ENGINE_APP_ID, &engine_app_id);
126 bundle_get_str(msg, VC_BUNDLE_EVENT, &event);
127 bundle_get_str(msg, VC_BUNDLE_RESULT, &result);
129 if (NULL != result) {
130 gsize decodingSize=0;
131 gchar *gDecodedResult = (gchar *)g_base64_decode((const gchar *)result, &decodingSize);
134 SLOG(LOG_WARN, TAG_VCM, "@@@ Get specific engine result --> %s", gDecodedResult);
135 vc_mgr_core_send_specific_engine_result(engine_app_id, event, gDecodedResult);
136 g_free(gDecodedResult);
139 } /* VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT */
141 else if (0 == strncmp(VCD_MANAGER_METHOD_RESULT, method, strlen(VCD_MANAGER_METHOD_RESULT))) {
142 SLOG(LOG_INFO, TAG_VCM, "@@@ Get System Result");
144 vc_mgr_core_send_system_result();
145 } /* VCD_MANAGER_METHOD_RESULT */
147 else if (0 == strncmp(VCD_MANAGER_METHOD_DIALOG, method, strlen(VCD_MANAGER_METHOD_DIALOG))) {
148 SLOG(LOG_INFO, TAG_VCM, "@@@ Request Dialog");
150 char* disp_text = NULL;
151 char* utt_text = NULL;
152 char* continuous = NULL;
154 bundle_get_str(msg, VC_BUNDLE_PID, &pid);
155 bundle_get_str(msg, VC_BUNDLE_DISP_TEXT, &disp_text);
156 bundle_get_str(msg, VC_BUNDLE_UTT_TEXT, &utt_text);
157 bundle_get_str(msg, VC_BUNDLE_CONTINUOUS, &continuous);
159 if (!strncmp(disp_text, "#NULL", strlen("#NULL") + 1))
161 if (!strncmp(utt_text, "#NULL", strlen("#NULL") + 1))
164 vc_mgr_core_send_dialog(atoi(pid), disp_text, utt_text, (bool)atoi(continuous));
165 } /* VCD_MANAGER_METHOD_DIALOG */
167 else if (0 == strncmp(VCD_MANAGER_METHOD_ERROR, method, strlen(VCD_MANAGER_METHOD_ERROR))) {
168 SLOG(LOG_INFO, TAG_VCM, "@@@ Get Error");
170 char* daemon_pid = NULL;
171 char* err_msg = NULL;
173 bundle_get_str(msg, VC_BUNDLE_REASON, &reason);
174 bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &daemon_pid);
175 bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg);
177 char* temp_msg = NULL;
178 if (NULL != err_msg && strncmp(err_msg, "#NULL", strlen("#NULL") + 1)) {
179 temp_msg = strdup(err_msg);
181 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");
182 vc_mgr_core_send_error(atoi(reason), atoi(daemon_pid), temp_msg);
183 if (NULL != temp_msg) {
187 } /* VCD_MANAGER_METHOD_ERROR */
189 else if (0 == strncmp(VCD_MANAGER_METHOD_SET_PRIVATE_DATA, method, strlen(VCD_MANAGER_METHOD_SET_PRIVATE_DATA))) {
190 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request set private data");
191 char* tmp_pid = NULL;
193 char* private_data = NULL;
195 bundle_get_str(msg, VC_BUNDLE_PID, &tmp_pid);
196 bundle_get_str(msg, VC_BUNDLE_KEY, &key);
197 bundle_get_str(msg, VC_BUNDLE_PRIVATE_DATA, &private_data);
199 int pid = atoi(tmp_pid);
200 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request set private data : pid(%d) ", pid);
202 vc_mgr_core_send_private_data_set(key, private_data);
204 SLOG(LOG_ERROR, TAG_VCM, "@@ got invalid pid(%d)", pid);
206 } /* VCD_MANAGER_METHOD_SET_PRIVATE_DATA */
208 else if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT))) {
209 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request feedback audio format");
210 char* channel = NULL;
211 char* audio_type = NULL;
214 bundle_get_str(msg, VC_BUNDLE_AUDIO_CHANNEL, &channel);
215 bundle_get_str(msg, VC_BUNDLE_AUDIO_TYPE, &audio_type);
216 bundle_get_str(msg, VC_BUNDLE_AUDIO_RATE, &rate);
218 vc_mgr_core_send_feedback_audio_format(atoi(rate), (vc_audio_channel_e)atoi(channel), (vc_audio_type_e)atoi(audio_type));
219 } /* VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT */
221 // TODO: uncomment this line after vcc done
222 // NEED2CHECK: when vcc send 'set_foreground', __vcd_mgr_set_foreground_cb will be invoked...
223 // else if (0 == strncmp(VCC_MANAGER_METHOD_SET_FOREGROUND, method, strlen(VCC_MANAGER_METHOD_SET_FOREGROUND))) {
224 // SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground");
225 // char* temp_pid = NULL;
226 // char* temp_value = NULL;
230 // bundle_get_str(msg, VC_BUNDLE_PID, &temp_pid);
231 // bundle_get_str(msg, VC_BUNDLE_VALUE, &temp_value);
232 // pid = atoi(temp_pid);
233 // value = atoi(temp_value);
235 // SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false");
237 // vc_mgr_core_send_set_foreground(pid, (bool)value);
238 // } /* VCC_MANAGER_METHOD_SET_FOREGROUND */
241 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid msg");
244 SLOG(LOG_DEBUG, TAG_VCM, "@@@ __notify_cb DONE");
247 static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_char_h data_in, bundle *msg)
252 SLOG(LOG_DEBUG, TAG_VCM, "__send_buffer_cb is invoked");
254 bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
256 if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_STREAMING, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_STREAMING))) {
262 bundle_get_str(msg, VC_BUNDLE_PID, &val);
263 bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id);
264 bundle_get_str(msg, VC_BUNDLE_EVENT, &event);
266 rpc_port_proxy_vc_mgr_proxy_array_char_get(data_in, &buffer, &len);
267 vc_mgr_core_send_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len);
270 SLOG(LOG_INFO, TAG_VCM, "@@@ __send_buffer_cb DONE");
271 } /* VCD_MANAGER_METHOD_FEEDBACK_STREAMING */
274 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid msg");
279 static void __on_connected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data)
281 RETM_IF(NULL == g_proxy_tidl_info, TAG_VCM, "[ERROR] Fail to get tidl info");
283 g_proxy_tidl_info->connected = true;
284 g_proxy_tidl_info->connection_requesting = false;
285 g_proxy_tidl_info->register_callback_invoked = false;
287 SLOG(LOG_INFO, TAG_VCM, "Connected to server");
290 static void __on_disconnected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data)
292 RETM_IF(NULL == g_proxy_tidl_info, TAG_VCM, "[ERROR] Fail to get tidl info");
294 g_proxy_tidl_info->connected = false;
295 g_proxy_tidl_info->connection_requesting = false;
296 g_proxy_tidl_info->register_callback_invoked = false;
298 SLOG(LOG_INFO, TAG_VCM, "Disonnected to server");
300 vc_mgr_core_send_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected");
303 static void __on_rejected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data)
305 RETM_IF(NULL == g_proxy_tidl_info, TAG_VCM, "[ERROR] Fail to get tidl info");
307 g_proxy_tidl_info->connection_requesting = false;
308 g_proxy_tidl_info->register_callback_invoked = false;
310 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Rejected from server");
314 static rpc_port_proxy_vc_mgr_proxy_vc_mgr_h __create_rpc_port(const char* engine_app_id)
316 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] __create_rpc_port");
317 rpc_port_proxy_vc_mgr_proxy_vc_mgr_callback_s rpc_callback = {
318 .connected = __on_connected,
319 .disconnected = __on_disconnected,
320 .rejected = __on_rejected
323 rpc_port_proxy_vc_mgr_proxy_vc_mgr_h handle = NULL;
324 if (0 != rpc_port_proxy_vc_mgr_proxy_vc_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) {
325 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create proxy");
332 static void __vcd_mgr_create_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, void *user_data)
334 g_stub_tidl_info->connected = true;
335 g_stub_tidl_info->register_callback_requesting = false;
337 SLOG(LOG_DEBUG, TAG_VCM, "Connected to server");
341 rpc_port_stub_vc_mgr_stub_vcd_mgr_context_get_sender(context, &sender);
343 SLOG(LOG_ERROR, TAG_VCM, "@@@ Sender is NULL");
347 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Server connect. appid(%s)", sender);
351 static void __vcd_mgr_terminate_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, void *user_data)
353 if (NULL != g_stub_tidl_info) {
354 g_stub_tidl_info->connected = false;
355 g_stub_tidl_info->register_callback_requesting = false;
358 rpc_port_stub_vc_mgr_stub_vcd_mgr_context_set_tag(context, NULL);
361 rpc_port_stub_vc_mgr_stub_vcd_mgr_context_get_sender(context, &sender);
365 SLOG(LOG_INFO, TAG_VCM, "@@@ Server disconnect. appid(%s)", sender);
369 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)
371 SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground");
372 SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false");
374 vc_mgr_core_send_set_foreground(pid, (bool)value);
376 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Set foreground DONE");
379 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)
381 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request get private data");
382 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request get private data : pid(%d) ", pid);
385 char *temp_data = NULL;
387 ret = vc_mgr_core_send_private_data_requested(key, &temp_data);
389 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
392 if (NULL == temp_data) {
393 SLOG(LOG_INFO, TAG_VCM, "data parameter is NULL");
394 temp_data = strdup("#NULL");
397 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request get private data DONE");
402 static int __vcd_mgr_auth_enable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
404 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth enable");
405 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth enable : pid(%d)", pid);
409 ret = vc_mgr_core_request_auth_enable(pid);
411 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
414 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth enable DONE");
419 static int __vcd_mgr_auth_disable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
421 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth disable");
422 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth disable : pid(%d)", pid);
426 ret = vc_mgr_core_request_auth_disable(pid);
428 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
431 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth disable DONE");
436 static int __vcd_mgr_auth_start_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
438 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth start");
439 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth start : pid(%d)", pid);
443 ret = vc_mgr_core_request_auth_start(pid);
445 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
448 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth start DONE");
453 static int __vcd_mgr_auth_stop_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
455 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth stop");
456 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth stop : pid(%d)", pid);
460 ret = vc_mgr_core_request_auth_stop(pid);
462 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
465 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth stop DONE");
470 static int __vcd_mgr_auth_cancel_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data)
472 SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth cancel");
473 SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth cancel : pid(%d)", pid);
477 ret = vc_mgr_core_request_auth_cancel(pid);
479 SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret);
482 SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth cancel DONE");
487 static int __register_stub_callback()
489 if (g_stub_tidl_info->register_callback_requesting) {
490 return VC_ERROR_NONE;
493 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] __register_stub_callback");
495 g_mgr_callback.create = __vcd_mgr_create_cb;
496 g_mgr_callback.terminate = __vcd_mgr_terminate_cb;
497 g_mgr_callback.set_foreground = __vcd_mgr_set_foreground_cb;
498 g_mgr_callback.get_private_data = __vcd_mgr_get_private_data_cb;
499 g_mgr_callback.auth_enable = __vcd_mgr_auth_enable_cb;
500 g_mgr_callback.auth_disable = __vcd_mgr_auth_disable_cb;
501 g_mgr_callback.auth_start = __vcd_mgr_auth_start_cb;
502 g_mgr_callback.auth_stop = __vcd_mgr_auth_stop_cb;
503 g_mgr_callback.auth_cancel = __vcd_mgr_auth_cancel_cb;
506 ret = rpc_port_stub_vc_mgr_stub_vcd_mgr_register(&g_mgr_callback, NULL);
508 SLOG(LOG_DEBUG, TAG_VCM, "register callback");
509 g_stub_tidl_info->register_callback_requesting = true;
510 return VC_ERROR_NONE;
513 SLOG(LOG_ERROR, TAG_VCM, "Fail to register callback(%d)", ret);
514 return VC_ERROR_OPERATION_FAILED;
517 int vc_mgr_tidl_open_connection()
519 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_open_connection");
520 pthread_mutex_lock(&g_tidl_mutex);
522 if (NULL != g_proxy_tidl_info) {
523 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] g_proxy_tidl_info already created");
524 pthread_mutex_unlock(&g_tidl_mutex);
525 return VC_ERROR_NONE;
528 g_proxy_tidl_info = (vc_mgr_tidl_info_s*)calloc(1, sizeof(vc_mgr_tidl_info_s));
530 if (NULL == g_proxy_tidl_info) {
531 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create vc_mgr_tidl_info_s");
532 pthread_mutex_unlock(&g_tidl_mutex);
533 return VC_ERROR_OUT_OF_MEMORY;
536 char* engine_app_id = vconf_get_str(VC_ENGINE_DB_DEFAULT);
537 if (NULL == engine_app_id) {
538 SLOG(LOG_ERROR, TAG_VCM, "[TIDL] vconf not found");
539 free(g_proxy_tidl_info);
540 g_proxy_tidl_info = NULL;
541 pthread_mutex_unlock(&g_tidl_mutex);
542 return VC_ERROR_ENGINE_NOT_FOUND;
545 g_proxy_tidl_info->rpc_h = __create_rpc_port(engine_app_id);
546 if (NULL == g_proxy_tidl_info->rpc_h) {
547 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create proxy");
549 free(g_proxy_tidl_info);
550 g_proxy_tidl_info = NULL;
551 pthread_mutex_unlock(&g_tidl_mutex);
552 return VC_ERROR_OPERATION_FAILED;
555 SLOG(LOG_INFO, TAG_VCM, "[TIDL] rpc_h(%p), engine_app_id(%s)", g_proxy_tidl_info->rpc_h, engine_app_id);
558 g_stub_tidl_info = (vcd_mgr_tidl_info_s*)calloc(1, sizeof(vcd_mgr_tidl_info_s));
560 if (NULL == g_stub_tidl_info) {
561 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create vcd_mgr_tidl_info_s");
562 pthread_mutex_unlock(&g_tidl_mutex);
563 return VC_ERROR_OUT_OF_MEMORY;
566 __register_stub_callback();
568 pthread_mutex_unlock(&g_tidl_mutex);
570 return VC_ERROR_NONE;
573 int vc_mgr_tidl_close_connection()
575 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_close_connection");
576 pthread_mutex_lock(&g_tidl_mutex);
578 if (NULL == g_proxy_tidl_info) {
579 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
580 pthread_mutex_unlock(&g_tidl_mutex);
581 return VC_ERROR_OPERATION_FAILED;
584 if (0 != rpc_port_proxy_vc_mgr_proxy_vc_mgr_destroy(g_proxy_tidl_info->rpc_h)) {
585 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to destroy tidl handle");
586 pthread_mutex_unlock(&g_tidl_mutex);
587 return VC_ERROR_OPERATION_FAILED;
590 g_proxy_tidl_info->rpc_h = NULL;
591 g_proxy_tidl_info->notify_cb_h = NULL;
592 g_proxy_tidl_info->send_buffer_cb_h = NULL;
594 free(g_proxy_tidl_info);
595 g_proxy_tidl_info = NULL;
597 free(g_stub_tidl_info);
598 g_stub_tidl_info = NULL;
600 pthread_mutex_unlock(&g_tidl_mutex);
602 return VC_ERROR_NONE;
605 static int __convert_unhandled_error(int ret)
607 if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
608 return VC_ERROR_OPERATION_FAILED;
614 static void __request_tidl_connect()
616 if (g_proxy_tidl_info->connection_requesting) {
620 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_connect(g_proxy_tidl_info->rpc_h);
621 SLOG(LOG_INFO, TAG_VCM, "[INFO] Request connection to stub. ret(%d)", ret);
624 g_proxy_tidl_info->connection_requesting = true;
628 static int __create_callback_handles()
630 if (NULL != g_proxy_tidl_info->notify_cb_h) {
631 rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->notify_cb_h);
632 g_proxy_tidl_info->notify_cb_h = NULL;
635 if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_create(&g_proxy_tidl_info->notify_cb_h)) {
636 return VC_ERROR_OUT_OF_MEMORY;
639 rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_set_callback(g_proxy_tidl_info->notify_cb_h, __notify_cb, NULL);
641 rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_set_once(g_proxy_tidl_info->notify_cb_h, false);
643 if (NULL != g_proxy_tidl_info->send_buffer_cb_h) {
644 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);
645 g_proxy_tidl_info->send_buffer_cb_h = NULL;
648 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)) {
649 return VC_ERROR_OUT_OF_MEMORY;
652 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);
654 rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_set_once(g_proxy_tidl_info->send_buffer_cb_h, false);
656 return VC_ERROR_NONE;
659 static int __invoke_register_callback()
661 if (g_proxy_tidl_info->register_callback_invoked) {
662 SLOG(LOG_ERROR, TAG_VCM, "[INFO] Already register callback is invoked");
663 return VC_ERROR_NONE;
666 int ret = __create_callback_handles(g_proxy_tidl_info);
667 if (VC_ERROR_NONE != ret) {
668 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create callback handle. ret(%d)", ret);
669 return VC_ERROR_OPERATION_FAILED;
672 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);
673 g_proxy_tidl_info->register_callback_invoked = true;
674 return VC_ERROR_NONE;
677 int vc_mgr_tidl_request_hello()
679 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_hello");
681 if (NULL == g_proxy_tidl_info) {
682 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get proxy tidl info");
683 return VC_ERROR_OPERATION_FAILED;
686 if (!g_proxy_tidl_info->connected) {
687 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Proxy Not Connected");
688 __request_tidl_connect();
689 return VC_ERROR_OPERATION_FAILED;
692 if (VC_ERROR_NONE != __invoke_register_callback()) {
693 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to invoke register callback");
694 return VC_ERROR_OPERATION_FAILED;
697 if (NULL == g_stub_tidl_info) {
698 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get stub tidl info");
699 return VC_ERROR_OPERATION_FAILED;
702 if (!g_stub_tidl_info->connected) {
703 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Stub Not Connected");
704 int ret = __register_stub_callback();
708 SLOG(LOG_DEBUG, TAG_VCM, ">>>>> VCM Hello");
710 SLOG(LOG_DEBUG, TAG_VCM, "<<<<");
712 return VC_ERROR_NONE;
715 int vc_mgr_tidl_request_initialize(int pid, int audio_streaming_mode, int* service_state, int* foreground, int* daemon_pid)
717 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_initialize");
719 if (NULL == g_proxy_tidl_info) {
720 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
721 return VC_ERROR_OPERATION_FAILED;
724 int tmp_service_state = 0;
725 int tmp_forground = 0;
726 int tmp_daemon_pid = 0;
728 if (!g_proxy_tidl_info->connected) {
729 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
730 return VC_ERROR_OPERATION_FAILED;
733 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);
734 int exception = get_last_result();
735 if (RPC_PORT_ERROR_NONE != exception) {
736 ret = __convert_unhandled_error(exception);
739 if (VC_ERROR_NONE != ret) {
740 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager initialize : Fail to invoke message, error(%d)", ret);
744 *service_state = tmp_service_state;
745 *foreground = tmp_forground;
746 *daemon_pid = tmp_daemon_pid;
748 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc manager initialize: service_state(%d), foreground(%d), daemon_pid(%d)", *service_state, *foreground, *daemon_pid);
750 return VC_ERROR_NONE;
753 int vc_mgr_tidl_request_finalize(int pid)
755 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_finalize");
757 if (NULL == g_proxy_tidl_info) {
758 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
759 return VC_ERROR_OPERATION_FAILED;
762 if (!g_proxy_tidl_info->connected) {
763 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
764 return VC_ERROR_OPERATION_FAILED;
767 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_finalize(g_proxy_tidl_info->rpc_h, pid);
768 int exception = get_last_result();
769 if (RPC_PORT_ERROR_NONE != exception) {
770 ret = __convert_unhandled_error(exception);
773 if (VC_ERROR_NONE != ret) {
774 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager finalize : Fail to invoke finalize, error(%d)", ret);
778 ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_disconnect(g_proxy_tidl_info->rpc_h);
779 exception = get_last_result();
780 if (RPC_PORT_ERROR_NONE != exception) {
781 ret = __convert_unhandled_error(exception);
784 if (VC_ERROR_NONE != ret) {
785 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager finalize : Fail to disconnect, error(%d)", ret);
789 return VC_ERROR_NONE;
792 int vc_mgr_tidl_request_set_command(int pid)
794 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_command");
796 if (NULL == g_proxy_tidl_info) {
797 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
798 return VC_ERROR_OPERATION_FAILED;
801 if (!g_proxy_tidl_info->connected) {
802 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
803 return VC_ERROR_OPERATION_FAILED;
806 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_command(g_proxy_tidl_info->rpc_h, pid);
807 int exception = get_last_result();
808 if (RPC_PORT_ERROR_NONE != exception) {
809 ret = __convert_unhandled_error(exception);
812 if (VC_ERROR_NONE != ret) {
813 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set command : Fail to invoke message, error(%d)", ret);
817 return VC_ERROR_NONE;
820 int vc_mgr_tidl_request_unset_command(int pid)
822 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_unset_command");
824 if (NULL == g_proxy_tidl_info) {
825 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
826 return VC_ERROR_OPERATION_FAILED;
829 if (!g_proxy_tidl_info->connected) {
830 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
831 return VC_ERROR_OPERATION_FAILED;
834 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_unset_command(g_proxy_tidl_info->rpc_h, pid);
835 int exception = get_last_result();
836 if (RPC_PORT_ERROR_NONE != exception) {
837 ret = __convert_unhandled_error(exception);
840 if (VC_ERROR_NONE != ret) {
841 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager unset command : Fail to invoke message, error(%d)", ret);
845 return VC_ERROR_NONE;
848 int vc_mgr_tidl_request_demandable_client(int pid)
850 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_demandable_client");
852 if (NULL == g_proxy_tidl_info) {
853 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
854 return VC_ERROR_OPERATION_FAILED;
857 if (!g_proxy_tidl_info->connected) {
858 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
859 return VC_ERROR_OPERATION_FAILED;
862 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_demandable_client(g_proxy_tidl_info->rpc_h, pid);
863 int exception = get_last_result();
864 if (RPC_PORT_ERROR_NONE != exception) {
865 ret = __convert_unhandled_error(exception);
868 if (VC_ERROR_NONE != ret) {
869 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager demandable client : Fail to invoke message, error(%d)", ret);
873 return VC_ERROR_NONE;
876 int vc_mgr_tidl_request_set_audio_type(int pid, const char* audio_type)
878 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_audio_type");
880 if (NULL == g_proxy_tidl_info) {
881 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
882 return VC_ERROR_OPERATION_FAILED;
885 if (!g_proxy_tidl_info->connected) {
886 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
887 return VC_ERROR_OPERATION_FAILED;
890 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_audio_type(g_proxy_tidl_info->rpc_h, pid, audio_type);
891 int exception = get_last_result();
892 if (RPC_PORT_ERROR_NONE != exception) {
893 ret = __convert_unhandled_error(exception);
896 if (VC_ERROR_NONE != ret) {
897 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set audio type : Fail to invoke message, error(%d)", ret);
901 return VC_ERROR_NONE;
904 int vc_mgr_tidl_request_get_audio_type(int pid, char** audio_type)
906 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_get_audio_type");
908 if (NULL == g_proxy_tidl_info) {
909 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
910 return VC_ERROR_OPERATION_FAILED;
913 if (!g_proxy_tidl_info->connected) {
914 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
915 return VC_ERROR_OPERATION_FAILED;
919 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_audio_type(g_proxy_tidl_info->rpc_h, pid, &tmp);
920 int exception = get_last_result();
921 if (RPC_PORT_ERROR_NONE != exception) {
922 ret = __convert_unhandled_error(exception);
925 if (VC_ERROR_NONE != ret) {
926 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get audio type : Fail to invoke message, error(%d)", ret);
931 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] Request vc manager get audio type : Success");
935 return VC_ERROR_NONE;
938 int vc_mgr_tidl_request_set_private_data(int pid, const char* key, const char* data)
940 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_private_data");
942 if (NULL == g_proxy_tidl_info) {
943 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
944 return VC_ERROR_OPERATION_FAILED;
947 if (!g_proxy_tidl_info->connected) {
948 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
949 return VC_ERROR_OPERATION_FAILED;
952 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_private_data(g_proxy_tidl_info->rpc_h, pid, key, data);
954 return VC_ERROR_NONE;
957 int vc_mgr_tidl_request_get_private_data(int pid, const char* key, char** data)
959 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_get_private_data");
961 if (NULL == g_proxy_tidl_info) {
962 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
963 return VC_ERROR_OPERATION_FAILED;
966 if (!g_proxy_tidl_info->connected) {
967 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
968 return VC_ERROR_OPERATION_FAILED;
972 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_private_data(g_proxy_tidl_info->rpc_h, pid, key, &tmp);
973 int exception = get_last_result();
974 if (RPC_PORT_ERROR_NONE != exception) {
975 ret = __convert_unhandled_error(exception);
978 if (VC_ERROR_NONE != ret) {
979 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get private data : Fail to invoke message, error(%d)", ret);
984 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] Request vc manager get private data : Success");
988 return VC_ERROR_NONE;
991 int vc_mgr_tidl_request_set_client_info(int pid)
993 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_client_info");
995 if (NULL == g_proxy_tidl_info) {
996 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
997 return VC_ERROR_OPERATION_FAILED;
1000 if (!g_proxy_tidl_info->connected) {
1001 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1002 return VC_ERROR_OPERATION_FAILED;
1005 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_client_info(g_proxy_tidl_info->rpc_h, pid);
1006 int exception = get_last_result();
1007 if (RPC_PORT_ERROR_NONE != exception) {
1008 ret = __convert_unhandled_error(exception);
1011 if (VC_ERROR_NONE != ret) {
1012 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set client info : Fail to invoke message, error(%d)", ret);
1016 return VC_ERROR_NONE;
1019 int vc_mgr_tidl_request_set_domain(int pid, const char* domain)
1021 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_domain");
1023 if (NULL == g_proxy_tidl_info) {
1024 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1025 return VC_ERROR_OPERATION_FAILED;
1028 if (!g_proxy_tidl_info->connected) {
1029 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1030 return VC_ERROR_OPERATION_FAILED;
1033 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_domain(g_proxy_tidl_info->rpc_h, pid, domain);
1034 int exception = get_last_result();
1035 if (RPC_PORT_ERROR_NONE != exception) {
1036 ret = __convert_unhandled_error(exception);
1039 if (VC_ERROR_NONE != ret) {
1040 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set domain : Fail to invoke message, error(%d)", ret);
1044 return VC_ERROR_NONE;
1047 int vc_mgr_tidl_request_do_action(int pid, vc_send_event_type_e type, char* send_event)
1049 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_do_action");
1051 if (NULL == g_proxy_tidl_info) {
1052 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1053 return VC_ERROR_OPERATION_FAILED;
1056 if (!g_proxy_tidl_info->connected) {
1057 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1058 return VC_ERROR_OPERATION_FAILED;
1061 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_do_action(g_proxy_tidl_info->rpc_h, pid, type, send_event);
1063 return VC_ERROR_NONE;
1066 int vc_mgr_tidl_request_start(int pid, int recognition_mode, bool exclusive_command_option, bool start_by_client, int disabled_cmd_type)
1068 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_start");
1070 if (NULL == g_proxy_tidl_info) {
1071 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1072 return VC_ERROR_OPERATION_FAILED;
1075 if (!g_proxy_tidl_info->connected) {
1076 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1077 return VC_ERROR_OPERATION_FAILED;
1080 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);
1081 int exception = get_last_result();
1082 if (RPC_PORT_ERROR_NONE != exception) {
1083 ret = __convert_unhandled_error(exception);
1086 if (VC_ERROR_NONE != ret) {
1087 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager start : Fail to invoke message, error(%d)", ret);
1091 return VC_ERROR_NONE;
1094 int vc_mgr_tidl_request_stop(int pid)
1096 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_stop");
1098 if (NULL == g_proxy_tidl_info) {
1099 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1100 return VC_ERROR_OPERATION_FAILED;
1103 if (!g_proxy_tidl_info->connected) {
1104 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1105 return VC_ERROR_OPERATION_FAILED;
1108 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_stop(g_proxy_tidl_info->rpc_h, pid);
1109 int exception = get_last_result();
1110 if (RPC_PORT_ERROR_NONE != exception) {
1111 ret = __convert_unhandled_error(exception);
1114 if (VC_ERROR_NONE != ret) {
1115 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager stop : Fail to invoke message, error(%d)", ret);
1119 return VC_ERROR_NONE;
1122 int vc_mgr_tidl_request_cancel(int pid)
1124 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_cancel");
1126 if (NULL == g_proxy_tidl_info) {
1127 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1128 return VC_ERROR_OPERATION_FAILED;
1131 if (!g_proxy_tidl_info->connected) {
1132 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1133 return VC_ERROR_OPERATION_FAILED;
1136 int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_cancel(g_proxy_tidl_info->rpc_h, pid);
1137 int exception = get_last_result();
1138 if (RPC_PORT_ERROR_NONE != exception) {
1139 ret = __convert_unhandled_error(exception);
1142 if (VC_ERROR_NONE != ret) {
1143 SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager cancel : Fail to invoke message, error(%d)", ret);
1147 return VC_ERROR_NONE;
1150 int vc_mgr_tidl_request_set_audio_streaming_mode(int pid, vc_audio_streaming_mode_e mode)
1152 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_request_set_audio_streaming_mode");
1154 if (NULL == g_proxy_tidl_info) {
1155 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1156 return VC_ERROR_OPERATION_FAILED;
1159 if (!g_proxy_tidl_info->connected) {
1160 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1161 return VC_ERROR_OPERATION_FAILED;
1164 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_audio_streaming_mode(g_proxy_tidl_info->rpc_h, pid, mode);
1166 return VC_ERROR_NONE;
1169 int vc_mgr_tidl_send_result_selection(int pid)
1171 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_result_selection");
1173 if (NULL == g_proxy_tidl_info) {
1174 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1175 return VC_ERROR_OPERATION_FAILED;
1178 if (!g_proxy_tidl_info->connected) {
1179 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1180 return VC_ERROR_OPERATION_FAILED;
1183 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_result_selection(g_proxy_tidl_info->rpc_h, pid);
1185 return VC_ERROR_NONE;
1188 int vc_mgr_tidl_send_specific_engine_request(int pid, const char* engine_app_id, const char* event, const char* request)
1190 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_result_selection");
1192 if (NULL == g_proxy_tidl_info) {
1193 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1194 return VC_ERROR_OPERATION_FAILED;
1197 if (!g_proxy_tidl_info->connected) {
1198 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1199 return VC_ERROR_OPERATION_FAILED;
1202 gchar *gEncodedRequest = g_base64_encode((const guchar*)request, strlen(request));
1204 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);
1206 if (gEncodedRequest)
1207 g_free(gEncodedRequest);
1209 return VC_ERROR_NONE;
1212 int vc_mgr_tidl_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status)
1214 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_utterance_status");
1216 if (NULL == g_proxy_tidl_info) {
1217 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1218 return VC_ERROR_OPERATION_FAILED;
1221 if (!g_proxy_tidl_info->connected) {
1222 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1223 return VC_ERROR_OPERATION_FAILED;
1226 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_utterance_status(g_proxy_tidl_info->rpc_h, pid, utt_id, utt_status);
1228 return VC_ERROR_NONE;
1231 int vc_mgr_tidl_send_audio_streaming(int pid, vc_audio_streaming_event_e event, unsigned char* buffer, unsigned int len)
1233 SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] vc_mgr_tidl_send_audio_streaming");
1235 if (NULL == g_proxy_tidl_info) {
1236 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get tidl info");
1237 return VC_ERROR_OPERATION_FAILED;
1240 if (!g_proxy_tidl_info->connected) {
1241 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not Connected");
1242 return VC_ERROR_OPERATION_FAILED;
1245 rpc_port_proxy_vc_mgr_proxy_array_char_h data = NULL;
1246 rpc_port_proxy_vc_mgr_proxy_array_char_create(&data);
1248 SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create data handle");
1249 return VC_ERROR_OUT_OF_MEMORY;
1252 if (NULL != buffer && 0 < len) {
1253 rpc_port_proxy_vc_mgr_proxy_array_char_set(data, (char*)buffer, len);
1255 SLOG(LOG_ERROR, TAG_VCM, "[TIDL] buffer is empty");
1258 rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_audio_streaming(g_proxy_tidl_info->rpc_h, pid, event, data);
1259 rpc_port_proxy_vc_mgr_proxy_array_char_destroy(data);
1261 return VC_ERROR_NONE;