* limitations under the License.
*/
-#include <app.h>
+#include <app_control.h>
#include <app_manager.h>
#include <dirent.h>
#include <sound_manager.h>
#include "vcd_dbus.h"
#include "voice_control_command_expand.h"
+#include "voice_control_common.h"
/*
* VC Server static variable
*/
-static bool g_is_engine;
-
static GList *g_proc_list = NULL;
static Ecore_Timer *g_restart_timer = NULL;
+static Ecore_Timer *g_check_widget_client_timer = NULL;
/**
* @brief Enumerations of send event type.
VCD_SEND_EVENT_TYPE_HAPTIC_EVENT /**< send haptic event to vc engine */
} vcd_send_event_type_e;
+static int __vcd_server_launch_manager_app();
+
/*
* VC Server Internal Functions
*/
static Eina_Bool __stop_by_silence(void *data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "===== Silence Detected ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Silence Detected ");
vcd_server_mgr_stop();
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
return EINA_FALSE;
}
static Eina_Bool __cancel_by_interrupt(void *data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "===== Cancel by interrupt");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by interrupt");
vcd_server_mgr_cancel();
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
return EINA_FALSE;
}
static void __cancel_by_error(void *data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "===== Cancel by error");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by error");
vcd_server_mgr_cancel();
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
return;
}
static Eina_Bool __restart_engine(void *data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "===== Restart by no result");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Restart by no result");
g_restart_timer = NULL;
SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Restart recognition");
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
return EINA_FALSE;
}
return 0;
}
- vcp_speech_detect_e speech_detected = VCP_SPEECH_DETECT_NONE;
+ vce_speech_detect_e speech_detected = VCE_SPEECH_DETECT_NONE;
int ret;
ret = vcd_engine_recognize_audio(data, length, &speech_detected);
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set recording data to engine(%d)", ret);
ecore_timer_add(0, __cancel_by_interrupt, NULL);
/* Send error cb to manager */
- if (VCP_ERROR_OUT_OF_NETWORK == ret) {
+ if (VCE_ERROR_OUT_OF_NETWORK == ret) {
vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_TIMED_OUT, "Engine connection failed");
} else {
vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "Engine recognition failed");
return 0;
}
- if (VCP_SPEECH_DETECT_BEGIN == speech_detected) {
+ if (VCE_SPEECH_DETECT_BEGIN == speech_detected) {
if (-1 != vcd_client_manager_get_pid()) {
/* Manager client is available */
if (0 != vcdc_send_speech_detected(vcd_client_manager_get_pid())) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send speech detected");
}
}
- } else if (VCP_SPEECH_DETECT_END == speech_detected) {
+ } else if (VCE_SPEECH_DETECT_END == speech_detected) {
if (VCD_RECOGNITION_MODE_STOP_BY_SILENCE == vcd_client_get_recognition_mode()) {
/* silence detected */
ecore_timer_add(0, __stop_by_silence, NULL);
void __server_recorder_interrupt_callback()
{
- SLOG(LOG_DEBUG, TAG_VCD, "===== Cancel by sound interrupt");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by sound interrupt");
ecore_timer_add(0, __cancel_by_interrupt, NULL);
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
}
static void __config_lang_changed_cb(const char* current_lang, void* user_data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "===== Change language ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Change language ");
/* Current state is recording */
vcd_state_e state = vcd_config_get_service_state();
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set language of engine : %d", ret);
}
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
return;
}
static void __config_foreground_changed_cb(int previous, int current, void* user_data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "===== Change foreground");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Change foreground");
SLOG(LOG_DEBUG, TAG_VCD, "Foreground pid(%d)", current);
}
}
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
return;
}
GSList* iter = NULL;
vc_cmd_s* temp_cmd = NULL;
int ret = 0;
+ int pre_pid = -1;
+ int pre_type = -1;
iter = g_slist_nth(pid_list, 0);
while (NULL != iter) {
temp_cmd = iter->data;
- if (NULL != temp_cmd) {
+ if (NULL != temp_cmd && (pre_pid != temp_cmd->pid || pre_type == VC_COMMAND_TYPE_WIDGET || temp_cmd->type == VC_COMMAND_TYPE_WIDGET)) {
/* Launch deactivated several apps that is matched with result */
ret = __vcd_launch_app(result);
if (0 != ret) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result, ret(%d)", ret);
break;
} else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type);
+ pre_pid = temp_cmd->pid;
+ pre_type = temp_cmd->type;
}
}
free(temp_cmd);
return EINA_FALSE;
}
-//static void __vcd_server_pre_result_cb(vcp_pre_result_event_e event, const char* pre_result, void *user_data)
-static void __vcd_server_asr_result_cb(vcp_asr_result_event_e event, const char* asr_result, void *user_data)
+int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
{
+ int ret = __vcd_server_launch_manager_app();
+ if (0 != ret) {
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+ return ret;
+ }
+
if (NULL != asr_result) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
- vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
+ ret = vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+ if (0 != ret) {
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+ }
}
- return;
+ return ret;
+}
+
+int vcd_send_nlg_result(const char* nlg_result, void *user_data)
+{
+ int ret = __vcd_server_launch_manager_app();
+ if (0 != ret) {
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
+ return ret;
+ }
+
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
+ ret = vcdc_send_dialog(vcd_client_manager_get_pid(), -1, nlg_result, NULL, 0); //0: VC_DIALOG_END
+ if (0 != ret)
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
+ return ret;
}
static void* __recorder_stop(void *data)
return NULL;
}
-static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int count, const char* all_result,
- const char* non_fixed_result, const char* nlu_result, const char* msg, void *user_data)
+int vcd_send_result(vce_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, void *user_data)
{
+ int ret = 0;
+
if (VCD_STATE_PROCESSING != vcd_config_get_service_state()) {
if (VCD_RECOGNITION_MODE_RESTART_CONTINUOUSLY != vcd_client_get_recognition_mode()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not 'Processing' and mode is not 'Restart continuously'");
- return;
+ return VCD_ERROR_INVALID_STATE;
}
}
vc_info_parser_unset_result(vcd_client_manager_get_exclusive());
vcd_client_manager_set_result_text(all_result);
- SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)",
+ SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)",
event, all_result, non_fixed_result, msg, count);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] NLU result(%s)", nlu_result);
+
if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) {
- if (VCP_RESULT_EVENT_REJECTED == event) {
+ if (VCE_RESULT_EVENT_REJECTED == event) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart by no or rejected result");
/* If no result and restart option is ON */
/* Send reject message */
bool temp = vcd_client_manager_get_exclusive();
vc_info_parser_set_result(all_result, event, msg, NULL, temp);
- if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+ ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
+ if (0 != ret) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
}
g_restart_timer = ecore_timer_add(0, __restart_engine, NULL);
- return;
+ return ret;
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Stop recorder due to success");
//vcd_recorder_stop();
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart continuously");
/* Restart option is ON */
g_restart_timer = ecore_timer_add(0, __restart_engine, NULL);
- if (VCP_RESULT_EVENT_REJECTED == event) {
+ if (VCE_RESULT_EVENT_REJECTED == event) {
bool temp = vcd_client_manager_get_exclusive();
vc_info_parser_set_result(all_result, event, msg, NULL, temp);
- if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+ ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
+ if (0 != ret) {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
}
- return;
+ return ret;
}
}
#if 1
-
- int pid = vcd_client_widget_get_foreground_pid();
- if (-1 != pid) {
- if (NULL != all_result) {
- vc_info_parser_set_result(all_result, event, msg, NULL, false);
- bool enable = false;
- vcd_client_widget_get_asr_result_enabled(pid, &enable);
- if (true == enable) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client");
- bool is_consumed = false;
- if (0 != vcdc_send_asr_result(pid, VC_COMMAND_TYPE_WIDGET, &is_consumed)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result");
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed);
- if (true == is_consumed) {
- vcdc_send_show_tooltip(pid, false);
- if (-1 != vcd_client_manager_get_pid()) {
- /* Manager client is available */
- if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
- SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
- }
- }
-
- vcd_client_manager_set_exclusive(false);
- return;
- }
- }
- }
- }
- }
-
/* if nlu_result is exist, Add command handle(is_action) into result list */
/* Normal result */
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] === Get engine result ===");
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] @ Get engine result @");
- int ret = -1;
vc_cmd_s* temp_cmd = NULL;
vc_cmd_list_h vc_cmd_list = NULL;
vcd_client_manager_set_exclusive(false);
vcd_config_set_service_state(VCD_STATE_READY);
vcdc_send_service_state(VCD_STATE_READY);
- return;
+ return VCD_ERROR_NONE;
}
/* priority filter */
- /* system > exclusive > foreground = widget > system_background > background */
+ /* system > exclusive > widget > foreground > system_background > background */
int i = 0;
int* filtered_id = (int*)calloc(count, sizeof(int));
+ if (!filtered_id) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to allocate memory");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
int filtered_count = 0;
int top_priority = VC_COMMAND_PRIORITY_BACKGROUND;
for (i = 0; i < count; i++) {
if (top_priority == temp_cmd->priority) {
filtered_id[filtered_count] = result_id[i];
filtered_count++;
- } else if (top_priority < temp_cmd->priority) {
- continue;
- } else {
+ } else if (top_priority > temp_cmd->priority) {
filtered_id[0] = result_id[i];
filtered_count = 1;
top_priority = temp_cmd->priority;
}
+
+ vc_cmd_destroy((vc_cmd_h)temp_cmd);
+ temp_cmd = NULL;
+ }
+ }
+
+ // ASR consume
+ if (top_priority >= VC_COMMAND_PRIORITY_WIDGET) {
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid) {
+ if (NULL != all_result) {
+ vc_info_parser_set_result(all_result, event, msg, NULL, false);
+ bool enable = false;
+ vcd_client_widget_get_asr_result_enabled(pid, &enable);
+ if (true == enable) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client");
+ bool is_consumed = false;
+ if (NULL != user_info) {
+ *user_info = 0x00;
+ }
+ if (0 != vcdc_send_asr_result(pid, event, all_result, VC_COMMAND_TYPE_WIDGET, &is_consumed)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result");
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed);
+ if (true == is_consumed) {
+ if (NULL != user_info) {
+ *user_info = 0x01;
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Send whether ASR result is consumed or not (%d)", *user_info);
+ }
+ vcdc_send_show_tooltip(pid, false);
+ if (-1 != vcd_client_manager_get_pid()) {
+ /* Manager client is available */
+ vc_info_parser_unset_result(false);
+ vc_info_parser_set_result(all_result, VC_RESULT_EVENT_RESULT_SUCCESS, msg, NULL, false);
+ if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+ SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
+ }
+ }
+
+ vcd_client_manager_set_exclusive(false);
+
+ vcd_config_set_service_state(VCD_STATE_READY);
+ vcdc_send_service_state(VCD_STATE_READY);
+ vc_cmd_list_destroy(vc_cmd_list, true);
+ if (NULL != filtered_id) {
+ free(filtered_id);
+ filtered_id = NULL;
+ }
+ return VCD_ERROR_NONE;
+ }
+ }
+ }
+ }
}
}
if (0 != vc_cmd_list_add(vc_cmd_list, (vc_cmd_h)temp_cmd)) {
SLOG(LOG_DEBUG, TAG_VCD, "Fail to add command to list");
vc_cmd_destroy((vc_cmd_h)temp_cmd);
+ temp_cmd = NULL;
}
} else {
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] NOT found matached result(%d)", filtered_id[i]);
}
if (NULL != nlu_result) {
- SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result);
+ SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result);
vc_info_parser_set_nlu_result(nlu_result);
if (0 == is_action) {
vc_cmd_h nlu_cmd;
vc_cmd_print_list(vc_cmd_list);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] =========================");
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] @@@@");
int result_count = 0;
vc_cmd_list_get_count(vc_cmd_list, &result_count);
if (0 == result_count) {
/* No result */
if (NULL != all_result) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result);
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is NULL");
}
vcd_client_manager_set_exclusive(false);
- return;
+ return VCD_ERROR_NONE;
} else {
if (false == vcd_client_manager_get_exclusive()) {
int pid = vcd_client_widget_get_foreground_pid();
vc_cmd_list_destroy(vc_cmd_list, true);
- return;
+ return VCD_ERROR_NONE;
#else
/* No result */
}
/* Normal result */
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] === Get engine result ===");
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] @ Get engine result @");
int ret = -1;
vc_cmd_s* temp_cmd = NULL;
vc_cmd_print_list(vc_cmd_list);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] =========================");
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] @@@@");
int result_count = 0;
vc_cmd_list_get_count(vc_cmd_list, &result_count);
}
#if 0
-static void __vcd_server_nlu_result_cb(vcp_result_event_e event, const char* nlu_result, void *user_data)
+static void __vcd_server_nlu_result_cb(vce_result_event_e event, const char* nlu_result, void *user_data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result);
int ret = vc_info_parser_set_nlu_result(nlu_result);
if (0 != ret) {
}
#endif
-static void __vcd_server_error_cb(vcp_error_e error, const char* msg, void *user_data)
+int vcd_send_error(vce_error_e error, const char* msg, void *user_data)
{
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Engine Error cb - reason(%d), msg(%s)", error, msg);
ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL);
char* error_msg = NULL;
- error_msg = strdup(msg);
+ if (NULL != msg) {
+ error_msg = strdup(msg);
+ if (NULL == error_msg) {
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+ }
- if (0 != vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg)) {
+ int ret = VCD_ERROR_NONE;
+ ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg);
+ if (VCD_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send error signal");
}
error_msg = NULL;
}
- return;
+ return ret;
}
/*
return ret;
}
-int vcd_initialize()
+int vcd_initialize(vce_request_callback_s *callback)
{
int ret = 0;
vcd_config_set_service_state(VCD_STATE_NONE);
- //ret = vcd_engine_agent_init(__vcd_server_pre_result_cb, __vcd_server_result_cb, __vcd_server_nlu_result_cb, __vcd_server_error_cb);
- ret = vcd_engine_agent_init(__vcd_server_asr_result_cb, __vcd_server_result_cb, __vcd_server_error_cb);
+ ret = vcd_engine_agent_init();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to engine agent initialize : result(%d)", ret);
return ret;
return VCD_ERROR_OPERATION_FAILED;
}
- /* Find engine */
- ret = vcd_engine_agent_initialize_current_engine();
- if (0 != ret) {
- if (VCD_ERROR_ENGINE_NOT_FOUND == ret)
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] There is No Voice control engine");
- else
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to init engine");
-
- g_is_engine = false;
- } else {
- g_is_engine = true;
- }
-
/* Load engine */
- if (0 != vcd_engine_agent_load_current_engine()) {
+ if (0 != vcd_engine_agent_load_current_engine(callback)) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to load current engine");
return VCD_ERROR_OPERATION_FAILED;
}
vcd_config_set_service_state(VCD_STATE_READY);
vcdc_send_service_state(VCD_STATE_READY);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server SUCCESS] initialize");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server SUCCESS] initialize");
return 0;
}
-void vcd_finalize()
+bool vcd_finalize()
{
GList *iter = NULL;
if (0 < g_list_length(g_proc_list)) {
}
vcd_engine_recognize_cancel();
}
+
if (0 != vcd_recorder_destroy()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to destroy recorder");
+ return false;
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] destroy recorder");
}
if (0 != vcd_engine_agent_release()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to release engine");
+ return false;
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] release engine");
}
vcd_config_set_service_state(VCD_STATE_NONE);
vcdc_send_service_state(VCD_STATE_NONE);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] mode finalize");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] mode finalize");
- return;
+ return true;
}
static Eina_Bool __finalize_quit_ecore_loop(void *data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] quit ecore main loop");
- ecore_main_loop_quit();
- return EINA_FALSE;
+ bool ret = vcd_finalize();
+ if (false == ret) {
+ return EINA_TRUE;
+ } else {
+ ecore_main_loop_quit();
+ return EINA_FALSE;
+ }
}
static void __read_proc()
}
if (0 == ret || mgr_pid > 0) {
- SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up %s client ", type ? (type == 1) ? "Widget" : "Manager" : "Normal");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Clean up %s client ", type ? (type == 1) ? "Widget" : "Manager" : "Normal");
if (NULL != client_list && client_count > 0) {
for (i = 0; i < client_count; i++) {
exist = false;
for (j = 0; j < g_list_length(g_proc_list); j++) {
iter = g_list_nth(g_proc_list, j);
if (NULL != iter) {
- if (client_list[i] == GPOINTER_TO_INT(iter->data)) {
- SLOG(LOG_DEBUG, TAG_VCD, "%s pid(%d) is running", type ? (type == 1) ? "Widget" : "Manager" : "Normal", client_list[i]);
+ if (*(client_list + i) == GPOINTER_TO_INT(iter->data)) {
+ SLOG(LOG_DEBUG, TAG_VCD, "%s pid(%d) is running", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i));
exist = true;
break;
}
}
if (false == exist) {
- SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == 1) ? "Widget" : "Manager" : "Normal", client_list[i]);
+ SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i));
if (VCD_CLIENT_TYPE_NORMAL == type)
- vcd_server_finalize(client_list[i]);
+ vcd_server_finalize(*(client_list + i));
else if (VCD_CLIENT_TYPE_WIDGET == type)
- vcd_server_widget_finalize(client_list[i]);
+ vcd_server_widget_finalize(*(client_list + i));
else
vcd_server_mgr_finalize(mgr_pid);
}
}
}
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
}
if (NULL != client_list && -1 == mgr_pid) {
free(client_list);
Eina_Bool vcd_cleanup_client_all(void *data)
{
__read_proc();
-
+
__vcd_cleanup_client(VCD_CLIENT_TYPE_NORMAL);
__vcd_cleanup_client(VCD_CLIENT_TYPE_WIDGET);
__vcd_cleanup_client(VCD_CLIENT_TYPE_MANAGER);
#if 0
if (0 == vcd_client_get_list(&client_list, &client_count)) {
- SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up client ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Clean up client ");
if (NULL != client_list && client_count > 0) {
for (i = 0; i < client_count; i++) {
exist = false;
#endif
}
}
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
}
if (NULL != client_list) {
free(client_list);
/* If app is in background state, app cannot response message. */
if (0 == vcd_client_widget_get_list(&client_list, &client_count)) {
- SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up widget");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ Clean up widget");
if (NULL != client_list && client_count > 0) {
for (i = 0; i < client_count; i++) {
exist = false;
#endif
}
}
- SLOG(LOG_DEBUG, TAG_VCD, "=====");
- SLOG(LOG_DEBUG, TAG_VCD, " ");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
}
if (NULL != client_list) {
*/
int vcd_server_mgr_initialize(int pid)
{
- if (false == g_is_engine) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- g_is_engine = false;
- return VCD_ERROR_ENGINE_NOT_FOUND;
- } else {
- g_is_engine = true;
- }
- }
-
/* check if pid is valid */
if (false == vcd_client_manager_is_valid(pid)) {
SLOG(LOG_ERROR, TAG_VCD, "[Server] old manager pid(%d) be removed", vcd_client_manager_get_pid());
if (0 != vcdc_send_manager_pid(pid))
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send manager pid");
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid);
return VCD_ERROR_NONE;
}
if (0 == vcd_client_get_ref_count()) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
}
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid);
return VCD_ERROR_NONE;
}
}
int ret = 0;
- vcp_audio_type_e type = VCP_AUDIO_TYPE_PCM_S16_LE;
+ vce_audio_type_e type = VCE_AUDIO_TYPE_PCM_S16_LE;
int rate = 16000;
int channel = 1;
return VCD_ERROR_NONE;
}
+static int __reset_waiting_for_widget_recording(void)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Reet waiting for widget recording");
+ // Delete timer to check that widget client is terminated
+ if (g_check_widget_client_timer) {
+ ecore_timer_del(g_check_widget_client_timer);
+ g_check_widget_client_timer = NULL;
+ }
+ // Reset flag to wait for recording from widget client
+ vcd_client_widget_set_waiting_for_recording(-1, false);
+ return 0;
+}
+
+static Eina_Bool __send_waiting_timeout_error_to_manager(void* data)
+{
+ intptr_t ppid = (intptr_t)data;
+ int pid = (int)ppid;
+ SLOG(LOG_ERROR, TAG_VCD, "Widget client didn't send to start recording, pid(%d)", pid);
+ __reset_waiting_for_widget_recording();
+
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
+ return EINA_FALSE;
+}
+
+static int __set_waiting_for_widget_recording(int pid)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Set waiting for widget recording, pid(%d)", pid);
+
+ // Check if the app included widget client is terminated or not. If it is terminated, vcd_server_widget_finalize() function will be called
+ // In that function, it will start recording
+ intptr_t ppid = (intptr_t)pid;
+ g_check_widget_client_timer = ecore_timer_add(2.0, __send_waiting_timeout_error_to_manager, (void*)ppid);
+
+ // Set flag to wait for recording from widget client
+ vcd_client_widget_set_waiting_for_recording(pid, true);
+ return 0;
+}
+
static int __start_internal_recognition()
{
int ret;
+ __reset_waiting_for_widget_recording();
if (0 != vcd_client_command_collect_command()) {
SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command");
+ /* Send error cb to manager */
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid)
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
return VCD_ERROR_OPERATION_FAILED;
}
/* 3. Set command to engine */
ret = vcd_engine_set_commands();
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to collect command : %d", ret);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set commands : %d", ret);
+ /* Send error cb to manager */
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid)
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
return VCD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Set command");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Set command");
bool stop_by_silence = true;
if (VCD_RECOGNITION_MODE_MANUAL == vcd_client_get_recognition_mode()) {
ret = vcd_engine_recognize_start(stop_by_silence);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recognition : result(%d)", ret);
+ /* Send error cb to manager */
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid)
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
return VCD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start engine");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start engine");
+#if 1
/* 5. recorder start */
ret = vcd_recorder_start();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recorder : result(%d)", ret);
vcd_engine_recognize_cancel();
+ /* Send error cb to manager */
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid)
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
return ret;
}
+#endif
vcd_config_set_service_state(VCD_STATE_RECORDING);
vcdc_send_service_state(VCD_STATE_RECORDING);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence);
return 0;
}
{
int pid = vcd_client_widget_get_foreground_pid();
if (-1 != pid) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Request tooltip show and widget command, show(%d)", (bool)data);
vcdc_send_show_tooltip(pid, (bool)data);
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
return VCD_ERROR_OPERATION_FAILED;
}
+ __reset_waiting_for_widget_recording();
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode);
vcd_client_set_recognition_mode(recognition_mode);
if (false == exclusive_cmd) {
if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
int pid = vcd_client_widget_get_foreground_pid();
if (-1 != pid) {
- SLOG(LOG_INFO, TAG_VCD, "[Server] Request tooltip show and widget command");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Request tooltip show and widget command");
ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true);
+
+ __set_waiting_for_widget_recording(pid);
return 0;
}
}
}
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] start internal recognition");
+
int ret = __start_internal_recognition();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition : %d", ret);
vcd_client_unset_exclusive_command(fg_pid);
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] start internal recognition");
return VCD_ERROR_NONE;
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
return VCD_ERROR_OPERATION_FAILED;
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] stop internal recognition");
+#if 1
/* 2. Stop recorder */
vcd_recorder_stop();
+#endif
/* 3. Stop engine recognition */
int ret = vcd_engine_recognize_stop();
vcd_config_set_service_state(VCD_STATE_PROCESSING);
vcdc_send_service_state(VCD_STATE_PROCESSING);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] stop internal recognition");
return VCD_ERROR_NONE;
}
int vcd_server_mgr_cancel()
{
- /* 1. Check current state */
- vcd_state_e state = vcd_config_get_service_state();
- if (VCD_STATE_RECORDING != state && VCD_STATE_PROCESSING != state) {
- SLOG(LOG_WARN, TAG_VCD, "[Server ERROR] Current state is not recording or processing");
- return VCD_ERROR_INVALID_STATE;
- }
if (-1 == vcd_client_manager_get_pid()) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
return VCD_ERROR_OPERATION_FAILED;
g_restart_timer = NULL;
}
+ /* 1. Check current state */
+ vcd_state_e state = vcd_config_get_service_state();
+ if (VCD_STATE_READY == state) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Current state is READY");
+ vcd_recorder_stop();
+
+ if (false == vcd_client_manager_get_exclusive()) {
+ if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip hide");
+ ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false);
+ }
+ }
+ }
+
+ vcdc_send_service_state(VCD_STATE_READY);
+ return VCD_ERROR_NONE;
+ }
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] cancel internal recognition");
+
+#if 1
/* 2. Stop recorder */
vcd_recorder_stop();
+#endif
+
/* 3. Cancel engine */
int ret = vcd_engine_recognize_cancel();
if (0 != ret) {
vcd_config_set_service_state(VCD_STATE_READY);
vcdc_send_service_state(VCD_STATE_READY);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] cancel internal recognition");
return VCD_ERROR_NONE;
}
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to process do action : %d", ret);
} else {
+ vcd_config_set_service_state(VCD_STATE_PROCESSING);
+ vcdc_send_service_state(VCD_STATE_PROCESSING);
SLOG(LOG_DEBUG, TAG_VCD, "[Server SUCCESS] Process do action");
}
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to enable command type");
} else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Enable command type(%d)", cmd_type);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Enable command type(%d)", cmd_type);
}
return ret;
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to disable command type");
} else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Disable command type(%d)", cmd_type);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Disable command type(%d)", cmd_type);
}
return ret;
*/
int vcd_server_initialize(int pid)
{
- if (false == g_is_engine) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- g_is_engine = false;
- return VCD_ERROR_ENGINE_NOT_FOUND;
- } else {
- g_is_engine = true;
- }
- }
-
if (false == vcd_engine_is_available_engine()) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- return VCD_ERROR_ENGINE_NOT_FOUND;
- }
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+ return VCD_ERROR_ENGINE_NOT_FOUND;
}
/* check if pid is valid */
if (0 == vcd_client_get_ref_count()) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Client Finalize : pid(%d)", pid);
*/
int vcd_server_widget_initialize(int pid)
{
- if (false == g_is_engine) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- g_is_engine = false;
- return VCD_ERROR_ENGINE_NOT_FOUND;
- } else {
- g_is_engine = true;
- }
- }
-
if (false == vcd_engine_is_available_engine()) {
- if (0 != vcd_engine_agent_initialize_current_engine()) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
- return VCD_ERROR_ENGINE_NOT_FOUND;
- }
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+ return VCD_ERROR_ENGINE_NOT_FOUND;
}
/* check if pid is valid */
return VCD_ERROR_NONE;
}
+static void __vcd_server_widget_start_recording(void *data)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server INFO] start recording");
+
+ if (0 != __start_internal_recognition()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition");
+ }
+}
+
int vcd_server_widget_finalize(int pid)
{
/* check if pid is valid */
}
if (0 == vcd_client_get_ref_count()) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty");
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
+ return 0;
}
+ bool is_waiting = false;
+ if (0 != vcd_client_widget_get_waiting_for_recording(pid, &is_waiting)) {
+ SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to get waiting to recording");
+ }
+
+ if (true == is_waiting) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server INFO] invoke to start recording");
+ ecore_main_loop_thread_safe_call_async(__vcd_server_widget_start_recording, NULL);
+ }
return VCD_ERROR_NONE;
}
return VCD_ERROR_INVALID_PARAMETER;
}
+ bool waiting;
+ if (0 != vcd_client_widget_get_waiting_for_recording(pid, &waiting) || false == waiting) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Server is not waiting for recording, pid(%d), waiting(%d)", pid, waiting);
+ return 0;
+ }
+
if (true == widget_command) {
vcd_client_widget_set_command(pid);
SLOG(LOG_DEBUG, TAG_VCD, "[Server] widget command is available");
SLOG(LOG_WARN, TAG_VCD, "[Server] widget command is NOT available");
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] start internal recongition : %d", widget_command);
int ret = __start_internal_recognition();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition : %d", ret);
return ret;
}
+
+int vcd_server_set_language(const char* language)
+{
+ int ret = VCD_ERROR_NONE;
+
+ ret = vcd_config_set_default_language(language);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Fail to set language : %d", ret);
+ return ret;
+ }
+
+ ret = vcd_engine_set_current_language(language);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Fail to set language : %d", ret);
+ return ret;
+ }
+
+ return ret;
+}
+/*
+* For engine service
+*/
+int vcd_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get foreach command");
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] input parameter is NULL");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = 0;
+ ret = vcd_engine_agent_get_foreach_command(vce_command, callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get foreach command : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_get_command_count(vce_cmd_h vce_command)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get command count");
+
+ int ret = 0;
+ ret = vcd_engine_agent_get_command_count(vce_command);
+ if (0 > ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get command count : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_get_audio_type(char** audio_type)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get audio type");
+
+ int ret = 0;
+ ret = vcd_engine_agent_get_audio_type(audio_type);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get audio type : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_private_data(const char* key, const char* data)
+{
+ vcd_state_e state = vcd_config_get_service_state();
+
+ if (VCD_STATE_READY != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state(%d) is NOT 'READY'", state);
+ return VCD_ERROR_INVALID_STATE;
+ }
+
+ int ret = vcd_engine_agent_set_private_data(key, data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data to the manager client : ret(%d)", ret);
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data to the manager client, key(%s), data(%s)", key, data);
+ }
+
+ return ret;
+}
+
+int vcd_get_private_data(const char* key, char** data)
+{
+ vcd_state_e state = vcd_config_get_service_state();
+
+ if (VCD_STATE_READY != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state(%d) is NOT 'READY'", state);
+ return VCD_ERROR_INVALID_STATE;
+ }
+
+ int ret = vcd_engine_agent_get_private_data(key, data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get private data from the manager client : ret(%d)", ret);
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get private data from the manager client, key(%s), data(%s)", key, data);
+ }
+
+ return ret;
+}
+
+int vcd_start_recording()
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Start recording");
+
+ int ret = 0;
+ ret = vcd_engine_agent_start_recording();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recording : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_stop_recording()
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Stop recording");
+
+ int ret = 0;
+ ret = vcd_engine_agent_stop_recording();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to stop recording : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_private_data_set_cb(vce_private_data_set_cb callback_func)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data set cb");
+
+ int ret = 0;
+ ret = vcd_engine_agent_set_private_data_set_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data set cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data requested cb");
+
+ int ret = 0;
+ ret = vcd_engine_agent_set_private_data_requested_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data requested cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
+int vcd_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set nlu base info requested cb");
+
+ int ret = 0;
+ ret = vcd_engine_agent_set_nlu_base_info_requested_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set nlu base info requested cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+