SET(MANAGER_SRCS
vc_mgr.c
vc_mgr_client.c
+ vc_mgr_data.cpp
+ vc_mgr_player.c
vc_mgr_dbus.c
../common/vc_cmd_db.c
../common/vc_command.c
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
## voice control library ##
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
return ret;
}
+int vc_set_server_dialog(const char* app_id, const char* credential)
+{
+ vc_state_e state;
+ int ret = -1;
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog, pid(%d), app_id(%s)", getpid(), app_id);
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+ if (0 != __vc_check_privilege()) {
+ return VC_ERROR_PERMISSION_DENIED;
+ }
+
+ if (NULL == credential) {
+ SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Credential is NULL");
+ return VC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (0 != vc_client_get_client_state(g_vc, &state)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid");
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != VC_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state);
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* Check service state */
+ vc_service_state_e service_state = -1;
+ vc_client_get_service_state(g_vc, &service_state);
+ if (service_state != VC_SERVICE_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state);
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ char* tmp_appid = NULL;
+ if (NULL == app_id) {
+ ret = app_manager_get_app_id(getpid(), &tmp_appid);
+ if (0 != ret || NULL == tmp_appid) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] app_id is NULL");
+ if (NULL != tmp_appid)
+ free(tmp_appid);
+ return VC_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ tmp_appid = strdup(app_id);
+ }
+ int pid = getpid();
+
+ SLOG(LOG_DEBUG, TAG_VCC, "Set server dialog : pid(%d), app_id(%s)", pid, tmp_appid);
+
+ int count = 0;
+ bool is_prepared = false;
+ do {
+ ret = vc_dbus_set_server_dialog(pid, tmp_appid, credential);
+ if (0 != ret) {
+ if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
+ if (0 == vc_prepare_sync()) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync");
+ }
+ } else if (VC_ERROR_TIMED_OUT != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set server dialog to vc service : %s", __vc_get_error_code(ret));
+ break;
+ } else {
+ SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set server dialog : %s", __vc_get_error_code(ret));
+ usleep(10000);
+ count++;
+ if (VC_RETRY_COUNT == count) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request");
+ break;
+ }
+ }
+ }
+ } while (0 != ret);
+
+
+ if (NULL != tmp_appid)
+ free(tmp_appid);
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+
+ return ret;
+}
+
+int vc_unset_server_dialog(const char* app_id)
+{
+ vc_state_e state;
+ int ret = -1;
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog, pid(%d), app_id(%s)", getpid(), app_id);
+ if (0 != __vc_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+ if (0 != __vc_check_privilege()) {
+ return VC_ERROR_PERMISSION_DENIED;
+ }
+
+ if (0 != vc_client_get_client_state(g_vc, &state)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid");
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != VC_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state);
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* Check service state */
+ vc_service_state_e service_state = -1;
+ vc_client_get_service_state(g_vc, &service_state);
+ if (service_state != VC_SERVICE_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state);
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ char* tmp_appid = NULL;
+ if (NULL == app_id) {
+ ret = app_manager_get_app_id(getpid(), &tmp_appid);
+ if (0 != ret || NULL == tmp_appid) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] app_id is NULL");
+ if (NULL != tmp_appid)
+ free(tmp_appid);
+ return VC_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ tmp_appid = strdup(app_id);
+ }
+ int pid = getpid();
+
+ SLOG(LOG_DEBUG, TAG_VCC, "Unset server dialog : pid(%d), app_id(%s)", pid, tmp_appid);
+
+ int count = 0;
+ bool is_prepared = false;
+ char* credential = strdup("#NULL");
+ do {
+ ret = vc_dbus_set_server_dialog(pid, tmp_appid, credential);
+ if (0 != ret) {
+ if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
+ vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
+ if (0 == vc_prepare_sync()) {
+ is_prepared = true;
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync");
+ }
+ } else if (VC_ERROR_TIMED_OUT != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request unset server dialog to vc service : %s", __vc_get_error_code(ret));
+ break;
+ } else {
+ SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request unset server dialog : %s", __vc_get_error_code(ret));
+ usleep(10000);
+ count++;
+ if (VC_RETRY_COUNT == count) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request");
+ break;
+ }
+ }
+ }
+ } while (0 != ret);
+
+
+ if (NULL != tmp_appid)
+ free(tmp_appid);
+ if (NULL != credential)
+ free(credential);
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@");
+
+ return ret;
+}
+
+
int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start)
{
vc_state_e state;
SLOG(LOG_DEBUG, TAG_VCC, "Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start);
int ret = vc_dbus_request_dialog(getpid(), disp_text, utt_text, auto_start);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret);
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request dialog, ret(%d)", ret);
return VC_ERROR_OPERATION_FAILED;
}
return 0;
}
+int vc_dbus_set_server_dialog(int pid, const char* app_id, const char* credential)
+{
+ if (NULL == g_conn_sender) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection");
+ if (0 != vc_dbus_reconnect()) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect");
+ }
+ }
+
+ DBusMessage* msg;
+ msg = dbus_message_new_method_call(
+ VC_SERVER_SERVICE_NAME,
+ VC_SERVER_SERVICE_OBJECT_PATH,
+ VC_SERVER_SERVICE_INTERFACE,
+ VC_METHOD_SET_SERVER_DIALOG);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_VCC, "@@ vc set server dialog : Fail to make message");
+ return VC_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s)", pid, app_id);
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_STRING, &app_id,
+ DBUS_TYPE_STRING, &credential,
+ DBUS_TYPE_INVALID);
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg;
+ int result = VC_ERROR_OPERATION_FAILED;
+
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
+ dbus_message_unref(msg);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message);
+ dbus_error_free(&err);
+ }
+
+ if (NULL != result_msg) {
+ dbus_message_get_args(result_msg, &err,
+ DBUS_TYPE_INT32, &result,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ result = VC_ERROR_OPERATION_FAILED;
+ }
+ dbus_message_unref(result_msg);
+
+ if (0 == result) {
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : result = %d", result);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCC, "@@ vc set server dialog : result = %d", result);
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL");
+ vc_dbus_reconnect();
+ result = VC_ERROR_TIMED_OUT;
+ }
+
+ return result;
+}
+
int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous)
{
if (NULL == g_conn_sender) {
int vc_dbus_set_foreground(int pid, bool value);
+int vc_dbus_set_server_dialog(int pid, const char* app_id, const char* credential);
+
int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous);
int vc_dbus_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid);
#include "vc_main.h"
#include "vc_mgr_client.h"
#include "vc_mgr_dbus.h"
+#include "vc_mgr_data.h"
+#include "vc_mgr_player.h"
#include "voice_control.h"
#include "voice_control_command.h"
#include "voice_control_command_expand.h"
static bool g_err_callback_status = false;
+/* for TTS feedback */
+static int g_feedback_rate = 16000;
+static vc_audio_channel_e g_feedback_audio_channel = 0;
+static vc_audio_type_e g_feedback_audio_type = 0;
+
+
static Eina_Bool __vc_mgr_notify_state_changed(void *data);
static void __vc_mgr_notify_error(void *data);
static Eina_Bool __vc_mgr_notify_result(void *data);
return ret;
}
+ /* for TTS feedback */
+/* ret = vc_mgr_player_init();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize VC mgr player : %d", ret);
+ }
+*/
SLOG(LOG_ERROR, TAG_VCM, "[Success] pid(%d)", g_vc_m->handle);
SLOG(LOG_DEBUG, TAG_VCM, "@@@");
SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to finalize DB, ret(%d)", ret);
}
+ /* for TTS feedback */
+/* ret = vc_mgr_player_release();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to release VC mgr player(%d)", ret);
+ }
+*/
if (0 != vc_mgr_dbus_close_connection()) {
SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to close connection");
}
}
int ret = -1;
- int count = 0;
- while (0 != ret) {
- ret = vc_mgr_dbus_request_set_private_data(g_vc_m->handle, key, data);
- if (0 != ret) {
- if (VC_ERROR_TIMED_OUT != ret) {
- SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Fail to set private data request : %s", __vc_mgr_get_error_code(ret));
- break;
- } else {
- SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry set private data request : %s", __vc_mgr_get_error_code(ret));
- usleep(10000);
- count++;
- if (VC_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request");
- break;
- }
- }
- } else {
- SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Set domain");
- }
+ ret = vc_mgr_dbus_request_set_private_data(g_vc_m->handle, key, data);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Fail to set private data : %s", __vc_mgr_get_error_code(ret));
+ return ret;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Set private data");
}
+
SLOG(LOG_DEBUG, TAG_VCM, "@@@");
return 0;
}
int ret = -1;
- int count = 0;
- while (0 != ret) {
- ret = vc_mgr_dbus_request_do_action(g_vc_m->handle, type, send_event);
- if (0 != ret) {
- if (VC_ERROR_TIMED_OUT != ret) {
- SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Fail to do action request : %s", __vc_mgr_get_error_code(ret));
- break;
- } else {
- SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry do action request : %s", __vc_mgr_get_error_code(ret));
- usleep(10000);
- count++;
- if (VC_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request");
- break;
- }
- }
- } else {
- SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] do action");
- }
+ ret = vc_mgr_dbus_request_do_action(g_vc_m->handle, type, send_event);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Fail to do action request : %s", __vc_mgr_get_error_code(ret));
+ return ret;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] do action");
+ }
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@");
+
+ return 0;
+}
+
+int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] specific engine request. engine app id(%s), event(%s), request(%s)", engine_app_id, event, request);
+
+ if (NULL == engine_app_id || NULL == event) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter");
+ return VC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == request) {
+ SLOG(LOG_ERROR, TAG_VCM, "[INFO] Input parameter is NULL. (no request)");
+ }
+
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available");
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != VC_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state);
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* Check service state */
+ vc_service_state_e service_state = -1;
+ vc_mgr_client_get_service_state(g_vc_m, &service_state);
+ if (service_state != VC_SERVICE_STATE_READY) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state);
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ int ret = -1;
+ ret = vc_mgr_dbus_send_specific_engine_request(g_vc_m->handle, engine_app_id, event, request);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Fail to specific engine request : %s", __vc_mgr_get_error_code(ret));
+ return ret;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] specific engine request");
}
SLOG(LOG_DEBUG, TAG_VCM, "@@@");
}
}
- int ret;
- int count = 0;
-
/* Request */
- ret = -1;
- count = 0;
- while (0 != ret) {
- ret = vc_mgr_dbus_send_result_selection(g_vc_m->handle);
- if (0 != ret) {
- if (VC_ERROR_TIMED_OUT != ret) {
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to send result selection : %s", __vc_mgr_get_error_code(ret));
- break;
- } else {
- SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry send result selection : %s", __vc_mgr_get_error_code(ret));
- usleep(10000);
- count++;
- if (VC_RETRY_COUNT == count) {
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request");
- break;
- }
- }
- } else {
- SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] result selection");
- }
+ int ret = -1;
+ ret = vc_mgr_dbus_send_result_selection(g_vc_m->handle);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to send result selection : %s", __vc_mgr_get_error_code(ret));
+ return ret;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] result selection");
}
vc_mgr_client_unset_all_result(g_vc_m);
return ret;
}
+/* for TTS feedback */
+int __vc_mgr_cb_feedback_audio_format(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type)
+{
+ vc_mgr_feedback_audio_format_cb callback = NULL;
+ void* user_data = NULL;
+
+ /* set global audio formats */
+ g_feedback_rate = rate;
+ g_feedback_audio_channel = channel;
+ g_feedback_audio_type = audio_type;
+
+ vc_mgr_client_get_feedback_audio_format_cb(g_vc_m, &callback, &user_data);
+
+ if (NULL != callback) {
+ vc_mgr_client_use_callback(g_vc_m);
+ callback(rate, channel, audio_type, user_data);
+ vc_mgr_client_not_use_callback(g_vc_m);
+ SLOG(LOG_DEBUG, TAG_VCM, "TTS feedback audio format callback is called");
+ } else {
+ SLOG(LOG_WARN, TAG_VCM, "[WARNING] TTS feedback audio format callback is null");
+ }
+
+ return VC_ERROR_NONE;
+}
+
+int __vc_mgr_cb_feedback_streaming(vc_feedback_event_e event, char* buffer, int len)
+{
+ /* add feedback data */
+ vc_feedback_data_s* temp_feedback_data = NULL;
+ temp_feedback_data = (vc_feedback_data_s*)calloc(1, sizeof(vc_feedback_data_s));
+ if (NULL == temp_feedback_data) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Out of memory");
+ return VC_ERROR_OUT_OF_MEMORY;
+ }
+
+ temp_feedback_data->data = NULL;
+ temp_feedback_data->rate = g_feedback_rate;
+ temp_feedback_data->data_size = 0;
+
+ if (0 < len) {
+ temp_feedback_data->data = (char*)calloc(len + 5, sizeof(char));
+ if (NULL != temp_feedback_data->data) {
+ memcpy(temp_feedback_data->data, buffer, len);
+ temp_feedback_data->data_size = len;
+ SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG][memcpy] data(%p) size(%d)",
+ temp_feedback_data->data, temp_feedback_data->data_size);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] fail to allocate memory");
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] feedback data is NULL");
+ }
+
+ temp_feedback_data->event = event;
+ temp_feedback_data->audio_type = g_feedback_audio_type;
+ temp_feedback_data->channel = g_feedback_audio_channel;
+
+ int ret = vc_mgr_data_add_feedback_data(temp_feedback_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to add feedback data");
+ if (NULL != temp_feedback_data->data) {
+ free(temp_feedback_data->data);
+ temp_feedback_data->data = NULL;
+ }
+ if (NULL != temp_feedback_data) {
+ free(temp_feedback_data);
+ temp_feedback_data = NULL;
+ }
+
+ return ret;
+ }
+
+ return VC_ERROR_NONE;
+}
+
int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_data)
{
if (0 != __vc_mgr_get_feature_enabled()) {
return 0;
}
+
+int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callback, void* user_data)
+{
+ if (0 != __vc_mgr_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
+ if (NULL == callback)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set specific engine result callback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != VC_STATE_INITIALIZED) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set specific engine result callback : Current state(%d) is not 'Initialized'", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ vc_mgr_client_set_specific_engine_result_cb(g_vc_m, callback, user_data);
+
+ return 0;
+}
+int vc_mgr_unset_specific_engine_result_cb(void)
+{
+ if (0 != __vc_mgr_get_feature_enabled()) {
+ return VC_ERROR_NOT_SUPPORTED;
+ }
+
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset specific engine result callback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != VC_STATE_INITIALIZED) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset specific engine result callback : Current state(%d) is not 'Initialize'", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ vc_mgr_client_set_specific_engine_result_cb(g_vc_m, NULL, NULL);
+
+ return 0;
+}
+
+void __vc_mgr_cb_specific_engine_result(const char* engine_app_id, const char* event, const char* result)
+{
+ vc_mgr_specific_engine_result_cb callback = NULL;
+ void* user_data = NULL;
+
+ vc_mgr_client_get_specific_engine_result_cb(g_vc_m, &callback, &user_data);
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client specific engine result callback is NULL");
+ return;
+ }
+
+ vc_mgr_client_use_callback(g_vc_m);
+ callback(engine_app_id, event, result, user_data);
+ vc_mgr_client_not_use_callback(g_vc_m);
+ SLOG(LOG_DEBUG, TAG_VCM, "Specific engine result callback is called, engine app id(%s), event(%s), result(%s)", engine_app_id, event, result);
+
+ return;
+}
+
+/* for TTS feedback */
+int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback, void* user_data)
+{
+ if (NULL == callback)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set feedback audio format callback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (VC_STATE_INITIALIZED != state) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set feedback audio format callback : Current state is not 'Initialized' (%d)", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ vc_mgr_client_set_feedback_audio_format_cb(g_vc_m, callback, user_data);
+
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Set feedback audio format callback");
+
+ return 0;
+}
+
+int vc_mgr_unset_feedback_audio_format_cb()
+{
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset feedback audio format callback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (VC_STATE_INITIALIZED != state) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset feedback audio format callback : Current state is not 'Initialized' (%d)", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ vc_mgr_client_set_feedback_audio_format_cb(g_vc_m, NULL, NULL);
+
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Unset feedback audio format callback");
+
+ return 0;
+}
+
+int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void* user_data)
+{
+ if (NULL == callback)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set feedback streaming callback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (VC_STATE_INITIALIZED != state) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set feedback streaming callback : Current state is not 'Initialized' (%d)", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ vc_mgr_client_set_feedback_streaming_cb(g_vc_m, callback, user_data);
+
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Set feedback streaming callback");
+
+ return 0;
+}
+
+int vc_mgr_unset_feedback_streaming_cb()
+{
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset feedback streaming callback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (VC_STATE_INITIALIZED != state) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset feedback streaming callback : Current state is not 'Initialized' (%d)", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ vc_mgr_client_set_feedback_streaming_cb(g_vc_m, NULL, NULL);
+
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Unset feedback streaming callback");
+
+ return 0;
+}
+
+static void __tts_feedback_thread(void* data, Ecore_Thread* thread)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Start thread");
+
+ vc_feedback_data_s* feedback_data = NULL;
+ vc_mgr_feedback_streaming_cb callback = NULL;
+ void* user_data = NULL;
+
+ vc_mgr_client_get_feedback_streaming_cb(g_vc_m, &callback, &user_data);
+ if (NULL == callback) {
+ SLOG(LOG_WARN, TAG_VCM, "[WARNING] TTS feedback streaming callback is null");
+ return;
+ }
+
+ while (1) {
+ int ret = -1;
+ int cnt = 0;
+
+ /* get feedback data */
+ ret = vc_mgr_data_get_feedback_data(&feedback_data);
+ if (0 != ret || NULL == feedback_data) {
+ /* empty queue */
+ SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] No feedback data. Waiting mode");
+
+ /* waiting */
+ while (1) {
+ usleep(10000);
+ if (0 < vc_mgr_data_get_feedback_data_size()) {
+ SLOG(LOG_INFO, TAG_VCM, "[INFO] Resume thread");
+ break;
+ }
+ if (200 < cnt) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Wrong request, there's no pcm data");
+ return;
+ }
+ cnt++;
+ }
+ SLOG(LOG_INFO, TAG_VCM, "[INFO] Finish to wait for new feedback data come");
+
+ /* resume feedback thread */
+ continue;
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCM, "TTS feedback streaming callback is called");
+ vc_mgr_client_use_callback(g_vc_m);
+ callback(feedback_data->event, feedback_data->data, feedback_data->data_size, user_data);
+ vc_mgr_client_not_use_callback(g_vc_m);
+
+ /* If no feedback data and EVENT_FINISH */
+ if (0 >= vc_mgr_data_get_feedback_data_size() && VC_FEEDBACK_EVENT_FINISH == feedback_data->event) {
+ SLOG(LOG_INFO, TAG_VCM, "[INFO] Finish feedback");
+ break;
+ }
+ }
+}
+
+static void __end_tts_feedback_thread(void* data, Ecore_Thread* thread)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] End thread");
+}
+
+int vc_mgr_start_feedback(void)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request start TTS feedback");
+
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Start feedback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (VC_STATE_READY != state) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Start feedback : Current state is not 'Ready' (%d)", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+#if 1
+ ecore_thread_run(__tts_feedback_thread, __end_tts_feedback_thread, NULL, NULL);
+#else
+ /* start playing TTS feedback */
+ int ret = -1;
+ ret = vc_mgr_player_play();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player play, ret(%d)", ret);
+ }
+#endif
+ return 0;
+}
+
+int vc_mgr_stop_feedback(void)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request stop TTS feedback");
+
+ vc_state_e state;
+ if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Stop feedback : A handle is not available");
+ return VC_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (VC_STATE_READY != state) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state);
+ return VC_ERROR_INVALID_STATE;
+ }
+
+#if 1
+ int ret = -1;
+
+ while (1) {
+ vc_feedback_data_s* feedback_data = NULL;
+
+ /* get feedback data */
+ ret = vc_mgr_data_get_feedback_data(&feedback_data);
+ if (0 != ret || NULL == feedback_data) {
+ /* empty queue */
+ SLOG(LOG_INFO, TAG_VCM, "[INFO] No feedback data to stop any more");
+ return 0;
+ }
+ ret = vc_mgr_data_clear_feedback_data(&feedback_data);
+ if (0 != ret) {
+ SLOG(LOG_INFO, TAG_VCM, "[ERROR] Fail to clear data, ret(%d)", ret);
+ break;
+ }
+ }
+#else
+ /* request to stop playing TTS feedback */
+ int ret = -1;
+ ret = vc_mgr_player_stop();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player stop, ret(%d)", ret);
+ }
+#endif
+ return ret;
+}
vc_mgr_private_data_set_cb private_data_set_cb;
void* private_data_set_user_data;
vc_mgr_private_data_requested_cb private_data_requested_cb;
- void* private_data_requested_user_data;
+ void* private_data_requested_user_data;
+ vc_mgr_specific_engine_result_cb specific_engine_result_cb;
+ void* specific_engine_result_user_data;
+
+ /* for TTS feedback */
+ vc_mgr_feedback_audio_format_cb feedback_audio_format_cb;
+ void* feedback_audio_format_user_data;
+ vc_mgr_feedback_streaming_cb feedback_streaming_cb;
+ void* feedback_streaming_user_data;
/* All result */
vc_result_event_e all_result_event;
client->private_data_set_user_data = NULL;
client->private_data_requested_cb = NULL;
client->private_data_requested_user_data = NULL;
+ client->specific_engine_result_cb = NULL;
+ client->specific_engine_result_user_data = NULL;
+
+ client->feedback_audio_format_cb = NULL;
+ client->feedback_audio_format_user_data = NULL;
+ client->feedback_streaming_cb = NULL;
+ client->feedback_streaming_user_data = NULL;
client->exclusive_cmd_option = false;
return 0;
}
+int vc_mgr_client_set_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb callback, void* user_data)
+{
+ vc_mgr_client_s* client = __mgr_client_get(vc);
+
+ /* check handle */
+ if (NULL == client)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ client->feedback_audio_format_cb = callback;
+ client->feedback_audio_format_user_data = user_data;
+
+ return 0;
+}
+
+int vc_mgr_client_get_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb* callback, void** user_data)
+{
+ vc_mgr_client_s* client = __mgr_client_get(vc);
+
+ /* check handle */
+ if (NULL == client)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ *callback = client->feedback_audio_format_cb;
+ *user_data = client->feedback_audio_format_user_data;
+
+ return 0;
+}
+
+int vc_mgr_client_set_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb callback, void* user_data)
+{
+ vc_mgr_client_s* client = __mgr_client_get(vc);
+
+ /* check handle */
+ if (NULL == client)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ client->feedback_streaming_cb = callback;
+ client->feedback_streaming_user_data = user_data;
+
+ return 0;
+}
+
+int vc_mgr_client_get_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb* callback, void** user_data)
+{
+ vc_mgr_client_s* client = __mgr_client_get(vc);
+
+ /* check handle */
+ if (NULL == client)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ *callback = client->feedback_streaming_cb;
+ *user_data = client->feedback_streaming_user_data;
+
+ return 0;
+}
+
/* set/get option */
int vc_mgr_client_set_service_state(vc_h vc, vc_service_state_e state)
{
return 0;
}
+
+int vc_mgr_client_set_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb callback, void* user_data)
+{
+ vc_mgr_client_s* client = __mgr_client_get(vc);
+
+ /* check handle */
+ if (NULL == client)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ client->specific_engine_result_cb = callback;
+ client->specific_engine_result_user_data = user_data;
+
+ return 0;
+}
+
+int vc_mgr_client_get_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb* callback, void** user_data)
+{
+ vc_mgr_client_s* client = __mgr_client_get(vc);
+
+ /* check handle */
+ if (NULL == client)
+ return VC_ERROR_INVALID_PARAMETER;
+
+ *callback = client->specific_engine_result_cb;
+ *user_data = client->specific_engine_result_user_data;
+
+ return 0;
+}
int vc_mgr_client_get_private_data_requested_cb(vc_h vc, vc_mgr_private_data_requested_cb* callback, void** user_data);
+int vc_mgr_client_set_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb callback, void* user_data);
+
+int vc_mgr_client_get_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb* callback, void** user_data);
+
+int vc_mgr_client_set_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb callback, void* user_data);
+
+int vc_mgr_client_get_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb* callback, void** user_data);
+
+int vc_mgr_client_set_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb callback, void* user_data);
+
+int vc_mgr_client_get_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb* callback, void** user_data);
+
+
/*
* set/get option
*/
--- /dev/null
+/*
+* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <list>
+#include <vector>
+#include <pthread.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#include "vc_mgr_data.h"
+
+using namespace std;
+
+std::list<vc_feedback_data_s*> g_feedback_data;
+
+static pthread_mutex_t g_feedback_data_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+int vc_mgr_data_add_feedback_data(vc_feedback_data_s* data)
+{
+ if (NULL == data) {
+ SLOG(LOG_ERROR, TAG_VCM, "[DATA ERROR] feedback data is NULL");
+ return VC_ERROR_INVALID_PARAMETER;
+ }
+
+ pthread_mutex_lock(&g_feedback_data_mutex);
+
+ std::list<vc_feedback_data_s*>::iterator iter;
+
+ try {
+ iter = g_feedback_data.insert(g_feedback_data.end(), data);
+ } catch (const std::bad_alloc&) {
+ SLOG(LOG_ERROR, TAG_VCM, "[DATA ERROR] Fail to insert feedback data (bad alloc)");
+ pthread_mutex_unlock(&g_feedback_data_mutex);
+
+ return VC_ERROR_OUT_OF_MEMORY;
+ }
+
+ pthread_mutex_unlock(&g_feedback_data_mutex);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_mgr_data_get_feedback_data(vc_feedback_data_s** data)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "[DATA] feedback_data : %p", *data);
+
+ pthread_mutex_lock(&g_feedback_data_mutex);
+
+ if (0 == g_feedback_data.size()) {
+ SLOG(LOG_DEBUG, TAG_VCM, "[DATA] There is no feedback data");
+ *data = NULL;
+ pthread_mutex_unlock(&g_feedback_data_mutex);
+
+ return -1;
+ }
+
+ std::list<vc_feedback_data_s*>::iterator iter;
+
+ if (!g_feedback_data.empty()) {
+ iter = g_feedback_data.begin();
+ *data = *iter;
+ g_feedback_data.pop_front();
+ }
+
+ pthread_mutex_unlock(&g_feedback_data_mutex);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_mgr_data_get_feedback_data_size()
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "[DATA] get feedback data size");
+
+ int data_size = 0;
+
+ pthread_mutex_lock(&g_feedback_data_mutex);
+ data_size = g_feedback_data.size();
+
+ pthread_mutex_unlock(&g_feedback_data_mutex);
+
+ return data_size;
+}
+
+int vc_mgr_data_clear_feedback_data(vc_feedback_data_s** data)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "[DATA] clear feedback data");
+
+ pthread_mutex_lock(&g_feedback_data_mutex);
+
+ if (!g_feedback_data.empty()) {
+ SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] data(%p) size(%d) rate(%d)", (*data)->data, (*data)->data_size, (*data)->rate);
+
+ if (NULL != (*data)->data) {
+ free((*data)->data);
+ (*data)->data = NULL;
+ }
+
+ free(*data);
+ *data = NULL;
+ }
+
+ pthread_mutex_unlock(&g_feedback_data_mutex);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_mgr_data_get_pid()
+{
+// SLOG(LOG_DEBUG, TAG_VCM, "[DATA] get VC mgr pid");
+
+ return getpid();
+}
--- /dev/null
+/*
+* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+#ifndef __VC_MGR_DATA_H__
+#define __VC_MGR_DATA_H__
+
+#include <tizen.h>
+#include <voice_control_common.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TAG_VCM "vcm" /* Manager client log tag */
+
+typedef enum {
+ VC_FEEDBACK_STATE_CREATED = 0,
+ VC_FEEDBACK_STATE_READY,
+ VC_FEEDBACK_STATE_PLAYING
+} vc_feedback_state_e;
+
+typedef struct {
+ int utt_id;
+ void* data;
+ unsigned int data_size;
+
+ vc_feedback_event_e event;
+ vc_audio_type_e audio_type;
+ vc_audio_channel_e channel;
+ int rate;
+} vc_feedback_data_s;
+
+
+int vc_mgr_data_add_feedback_data(vc_feedback_data_s* data);
+
+int vc_mgr_data_get_feedback_data(vc_feedback_data_s** data);
+
+int vc_mgr_data_get_feedback_data_size();
+
+int vc_mgr_data_clear_feedback_data(vc_feedback_data_s** data);
+
+int vc_mgr_data_get_pid();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __VC_MGR_DATA_H__ */
extern int __vc_mgr_cb_private_data_requested(const char* key, char** data);
+/* for TTS feedback */
+extern int __vc_mgr_cb_feedback_audio_format(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type);
+
+extern int __vc_mgr_cb_feedback_streaming(vc_feedback_event_e event, char* buffer, int len);
+
/* Authority */
extern int __vc_mgr_request_auth_enable(int pid);
extern int __vc_mgr_cb_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous);
+extern void __vc_mgr_cb_specific_engine_result(const char* engine_app_id, const char* event, const char* result);
+
static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
{
if (NULL == g_m_conn_listener) return ECORE_CALLBACK_RENEW;
SLOG(LOG_DEBUG, TAG_VCM, "@@@");
} /* VCD_MANAGER_METHOD_PRE_RESULT */
+ else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT)) {
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get specific engine result");
+ char* engine_app_id = NULL;
+ char* event = NULL;
+ char* result = NULL;
+
+ dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &engine_app_id, DBUS_TYPE_STRING, &event, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID);
+ if (NULL != result) {
+ __vc_mgr_cb_specific_engine_result(engine_app_id, event, result);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCM, "@@@");
+ } /* VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT */
else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_RESULT)) {
SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get System Result");
SLOG(LOG_DEBUG, TAG_VCM, "@@@");
} /* VCD_MANAGER_METHOD_GET_PRIVATE_DATA */
+ else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT)) {
+ SLOG(LOG_INFO, TAG_VCM, "@@@ Get TTS feedback audio format");
+ int rate;
+ vc_audio_channel_e channel;
+ vc_audio_type_e audio_type;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &rate,
+ DBUS_TYPE_INT32, &channel,
+ DBUS_TYPE_INT32, &audio_type,
+ DBUS_TYPE_INVALID);
+
+ __vc_mgr_cb_feedback_audio_format(rate, channel, audio_type);
+
+ SLOG(LOG_INFO, TAG_VCM, "@@@");
+ } /* VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT */
+
+ else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_FEEDBACK_STREAMING)) {
+ SLOG(LOG_INFO, TAG_VCM, "@@@ Get TTS feedback streaming");
+ vc_feedback_event_e event;
+ char* buffer = NULL;
+ int len;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &event,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+ &buffer, &len,
+ DBUS_TYPE_INVALID);
+
+ __vc_mgr_cb_feedback_streaming(event, buffer, len);
+
+ SLOG(LOG_INFO, TAG_VCM, "@@@");
+ } /* VCD_MANAGER_METHOD_FEEDBACK_STREAMING */
+
/* Authority */
else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_ENABLE)) {
SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth enable");
return 0;
}
+
+int vc_mgr_dbus_send_specific_engine_request(int pid, const char* engine_app_id, const char* event, const char* request)
+{
+ DBusMessage* msg;
+
+ /* create a signal & check for errors */
+ msg = dbus_message_new_method_call(
+ VC_SERVER_SERVICE_NAME,
+ VC_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
+ VC_SERVER_SERVICE_INTERFACE, /* interface name of the signal */
+ VC_MANAGER_METHOD_SPECIFIC_ENGINE_REQUEST); /* name of the signal */
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_VCM, "@@ vc send specific engine : Fail to make message");
+ return VC_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "@@ vc send specific engine : pid(%d), engine_app_id(%s), event(%s), request(%s)", pid, engine_app_id, event, request);
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_STRING, &engine_app_id,
+ DBUS_TYPE_STRING, &event,
+ DBUS_TYPE_STRING, &request,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send");
+ return -1;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[Dbus] SUCCESS Send");
+ dbus_connection_flush(g_m_conn_sender);
+ }
+
+ return 0;
+}
int vc_mgr_dbus_send_result_selection(int pid);
+int vc_mgr_dbus_send_specific_engine_request(int pid, const char* engine_app_id, const char* event, const char* request);
+
int vc_mgr_dbus_request_enable_command_type(int pid, int cmd_type);
int vc_mgr_dbus_request_disable_command_type(int pid, int cmd_type);
+int vc_mgr_dbus_request_start_feedback(int pid);
+
+int vc_mgr_dbus_request_stop_feedback(int pid);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <audio_io.h>
+#include <Ecore.h>
+#include <dlog.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "vc_main.h"
+#include "vc_mgr_player.h"
+#include "vc_mgr_data.h"
+
+typedef enum {
+ AUDIO_STATE_NONE = 0,
+ AUDIO_STATE_READY,
+ AUDIO_STATE_PLAY
+} audio_state_e;
+
+typedef struct {
+ vc_feedback_state_e state;
+
+ vc_feedback_event_e event;
+ int idx;
+} player_s;
+
+#define SOUND_BUFFER_LENGTH 2048
+
+static bool g_player_init = false;
+
+static player_s* g_playing_info;
+
+static audio_state_e g_audio_state;
+
+static vc_audio_type_e g_audio_type;
+
+static vc_audio_channel_e g_audio_channel;
+
+static int g_sampling_rate;
+
+static audio_out_h g_audio_h;
+
+
+static int __create_audio_out(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type)
+{
+ int ret = -1;
+ audio_channel_e sample_channel = 0;
+ audio_sample_type_e sample_type = 0;
+
+ if (VC_AUDIO_CHANNEL_MONO == channel) {
+ sample_channel = AUDIO_CHANNEL_MONO;
+ } else if (VC_AUDIO_CHANNEL_STEREO == channel) {
+ sample_channel = AUDIO_CHANNEL_STEREO;
+ }
+
+ if (VC_AUDIO_TYPE_PCM_S16_LE == audio_type) {
+ sample_type = AUDIO_SAMPLE_TYPE_S16_LE;
+ } else {
+ sample_type = AUDIO_SAMPLE_TYPE_U8;
+ }
+
+ /* create audio_out new */
+ ret = audio_out_create_new(rate, sample_channel, sample_type, &g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ g_audio_state = AUDIO_STATE_NONE;
+ g_audio_h = NULL;
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio");
+ return -1;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Create audio");
+ }
+
+ g_audio_channel = channel;
+ g_audio_type = audio_type;
+ g_sampling_rate = rate;
+
+ g_audio_state = AUDIO_STATE_READY;
+
+ return 0;
+}
+
+static int __destroy_audio_out()
+{
+ if (NULL == g_audio_h) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current handle is not valid");
+ return -1;
+ }
+
+ int ret = -1;
+ ret = audio_out_destroy(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to destroy audio");
+ return -1;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Destroy audio");
+ }
+
+ g_audio_channel = 0;
+ g_audio_type = 0;
+ g_sampling_rate = 0;
+
+ g_audio_state = AUDIO_STATE_NONE;
+ g_audio_h = NULL;
+
+ return 0;
+}
+
+int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type)
+{
+ g_audio_state = AUDIO_STATE_NONE;
+ g_audio_h = NULL;
+
+ ecore_thread_max_set(1);
+
+ int ret = -1;
+
+
+ ret = __create_audio_out(rate, channel, audio_type);
+ if (0 != ret) {
+ return -1;
+ }
+
+ g_player_init = true;
+
+ return 0;
+}
+
+int vc_mgr_player_release()
+{
+ if (false == g_player_init) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized");
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ int ret = -1;
+
+ int thread_count = ecore_thread_active_get();
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Active thread count : %d", thread_count);
+ int count = 0;
+ while (0 < thread_count) {
+ usleep(10000);
+
+ count++;
+ if (20 == count) {
+ SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Thread is blocked. Player release continue");
+ break;
+ }
+
+ thread_count = ecore_thread_active_get();
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Thread is release");
+
+ ret = __destroy_audio_out();
+ if (0 != ret) {
+ return -1;
+ }
+
+ g_player_init = false;
+
+ return 0;
+}
+
+static void __play_feedback_thread(void* data, Ecore_Thread* thread)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Start thread");
+
+ if (NULL == g_playing_info) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] No current player");
+ return;
+ }
+
+ player_s* player = g_playing_info;
+ vc_feedback_data_s* feedback_data = NULL;
+
+ int ret = -1;
+ int len = SOUND_BUFFER_LENGTH;
+ int idx = 0;
+
+ while (1) {
+ /* get feedback data */
+ ret = vc_mgr_data_get_feedback_data(&feedback_data);
+ if (0 != ret || NULL == feedback_data) {
+ /* empty queue */
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No feedback data. Waiting mode");
+
+ /* waiting */
+ while (1) {
+ usleep(10000);
+ if (0 < vc_mgr_data_get_feedback_data_size()) {
+ SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Resume thread");
+ break;
+ }
+
+ if (AUDIO_STATE_PLAY == g_audio_state) {
+ /* release audio & recover session */
+ ret = audio_out_unprepare(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Unprepare audio");
+ }
+ g_audio_state = AUDIO_STATE_READY;
+ }
+ }
+
+ SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Finish to wait for new feedback data come");
+
+ /* resume play thread */
+ player->state = VC_FEEDBACK_STATE_PLAYING;
+ continue;
+ }
+
+ if (VC_FEEDBACK_EVENT_START == feedback_data->event ||
+ (VC_FEEDBACK_EVENT_FINISH == player->event && VC_FEEDBACK_EVENT_FINISH == feedback_data->event)) {
+ int pid = vc_mgr_data_get_pid();
+ SLOG(LOG_INFO, TAG_VCM, "[Player DEBUG] Start utterance (%d)", pid);
+ }
+
+ player->event = feedback_data->event;
+ idx = 0;
+ /* If no feedback data and EVENT_FINISH */
+ if (NULL == feedback_data->data || 0 >= feedback_data->data_size) {
+ if (VC_FEEDBACK_EVENT_FINISH == feedback_data->event) {
+ int pid = vc_mgr_data_get_pid();
+ if (pid <= 0) {
+ return;
+ }
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No sound data");
+ }
+ SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Finish utterance");
+ vc_mgr_data_clear_feedback_data(&feedback_data);
+ continue;
+ }
+
+ if (g_sampling_rate != feedback_data->rate || g_audio_type != feedback_data->audio_type || g_audio_channel != feedback_data->channel) {
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] change audio handle");
+ if (NULL != g_audio_h) {
+ __destroy_audio_out();
+ }
+
+ if (0 > __create_audio_out(feedback_data->rate, feedback_data->channel, feedback_data->audio_type)) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio out");
+ vc_mgr_data_clear_feedback_data(&feedback_data);
+
+ return;
+ }
+ }
+
+ while (VC_FEEDBACK_STATE_PLAYING == player->state) {
+ if ((unsigned int)idx >= feedback_data->data_size)
+ break;
+
+ if ((unsigned int)idx + SOUND_BUFFER_LENGTH > feedback_data->data_size) {
+ len = feedback_data->data_size - idx;
+ } else {
+ len = SOUND_BUFFER_LENGTH;
+ }
+
+ if (AUDIO_STATE_READY == g_audio_state) {
+ /* request prepare */
+ ret = audio_out_prepare(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to prepare audio");
+ vc_mgr_data_clear_feedback_data(&feedback_data);
+ return;
+ }
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Prepare audio");
+ g_audio_state = AUDIO_STATE_PLAY;
+ }
+
+ char* temp_data = feedback_data->data;
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] data(%p), idx(%d), len(%d)", temp_data, idx, len);
+
+ ret = audio_out_write(g_audio_h, &temp_data[idx], len);
+ if (0 > ret) {
+ SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Fail to audio write - %d", ret);
+ } else {
+ idx += len;
+ }
+
+ if (NULL == g_playing_info) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current player is NULL");
+ g_audio_state = AUDIO_STATE_READY;
+ ret = audio_out_unprepare(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
+ }
+
+ vc_mgr_data_clear_feedback_data(&feedback_data);
+
+ return;
+ }
+ }
+
+ if (NULL == g_playing_info && VC_FEEDBACK_STATE_READY == player->state) {
+ /* player stop */
+ g_audio_state = AUDIO_STATE_READY;
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Stop play thread");
+
+ /* request to unprepare audio */
+ ret = audio_out_unprepare(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Unprepare audio");
+ }
+
+ vc_mgr_data_clear_feedback_data(&feedback_data);
+ return;
+ }
+
+ if ((VC_FEEDBACK_STATE_PLAYING == player->state) && (VC_FEEDBACK_EVENT_FINISH == feedback_data->event)) {
+ int pid = vc_mgr_data_get_pid();
+ if (pid <= 0) {
+ return;
+ }
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Finish utterance");
+ }
+
+ vc_mgr_data_clear_feedback_data(&feedback_data);
+
+ if (NULL == g_playing_info) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current player is NULL");
+ g_audio_state = AUDIO_STATE_READY;
+ ret = audio_out_unprepare(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
+ }
+
+ return;
+ }
+
+ }
+
+}
+
+static void __end_play_feedback_thread(void* data, Ecore_Thread* thread)
+{
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] End thread");
+}
+
+int vc_mgr_player_play()
+{
+ if (false == g_player_init) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized");
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ if (NULL != g_playing_info) {
+ SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Stop old player");
+ vc_mgr_player_stop();
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] start play");
+
+ /* check sound queue size */
+ int data_size = vc_mgr_data_get_feedback_data_size();
+ if (0 == data_size) {
+ SLOG(LOG_WARN, TAG_VCM, "[Player WARN] A sound queue of current player is empty");
+ } else if (0 < data_size) {
+ SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Run thread");
+ ecore_thread_run(__play_feedback_thread, __end_play_feedback_thread, NULL, NULL);
+ }
+
+ return 0;
+}
+
+int vc_mgr_player_stop()
+{
+ if (false == g_player_init) {
+ SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized");
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ if (NULL != g_playing_info) {
+ g_playing_info = NULL;
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No more current playing");
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] stop play");
+
+ int thread_count = ecore_thread_active_get();
+ int count = 0;
+
+ while (0 < thread_count) {
+ usleep(10000);
+
+ count++;
+ if (30 == count) {
+ SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Thread is blocked. Player release continue");
+ break;
+ }
+
+ thread_count = ecore_thread_active_get();
+ }
+
+ return 0;
+}
--- /dev/null
+
+#ifndef __VC_MGR_PLAYER_H__
+#define __VC_MGR_PLAYER_H__
+
+#include <tizen.h>
+#include <voice_control_common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type);
+
+int vc_mgr_player_release();
+
+int vc_mgr_player_play();
+
+int vc_mgr_player_stop();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __VC_MGR_PLAYER_H__ */
#define VC_METHOD_SET_COMMAND "vc_method_set_command"
#define VC_METHOD_UNSET_COMMAND "vc_method_unset_command"
#define VC_METHOD_SET_FOREGROUND "vc_method_set_foreground"
+#define VC_METHOD_SET_SERVER_DIALOG "vc_method_set_server_dialog"
#define VC_METHOD_DIALOG "vc_method_dialog"
#define VC_METHOD_IS_SYS_COMMAND_VALID "vc_method_is_system_command_valid"
#define VC_MANAGER_METHOD_RESULT_SELECTION "vc_manager_method_result_selection"
#define VC_MANAGER_METHOD_SET_DOMAIN "vc_manager_method_set_domain"
#define VC_MANAGER_METHOD_DO_ACTION "vc_manager_method_do_action"
+#define VC_MANAGER_METHOD_SPECIFIC_ENGINE_REQUEST "vcd_manager_method_specific_engine_request"
+
+#define VC_MANAGER_METHOD_START_FEEDBACK "vc_manager_method_request_start_feedback"
+#define VC_MANAGER_METHOD_STOP_FEEDBACK "vc_manager_method_request_stop_feedback"
#define VCD_MANAGER_METHOD_HELLO "vcd_manager_method_hello"
#define VCD_MANAGER_METHOD_SPEECH_DETECTED "vcd_manager_method_speech_detected"
#define VCD_MANAGER_METHOD_DIALOG "vcd_manager_method_dialog"
#define VCD_MANAGER_METHOD_SET_PRIVATE_DATA "vcd_manager_set_private_data"
#define VCD_MANAGER_METHOD_GET_PRIVATE_DATA "vcd_manager_get_private_data"
+#define VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT "vcd_manager_method_specific_engine_result"
#define VCD_MANAGER_METHOD_ERROR "vcd_manager_method_error"
+#define VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT "vcd_manager_method_feedback_audio_format"
+#define VCD_MANAGER_METHOD_FEEDBACK_STREAMING "vcd_manager_method_feedback_streaming"
+
#define VCC_MANAGER_METHOD_SET_FOREGROUND "vcd_manager_method_set_foreground"
bool fg_cmd;
bool bg_cmd;
bool exclusive_cmd;
+ bool server_dialog;
} vc_client_info_s;
* <td></td>
* </tr>
* <tr>
+ * <td>vc_set_server_dialog()</td>
+ * <td>Ready</td>
+ * <td></td>
+ * </tr>
+ * <tr>
* <td>vc_request_dialog()</td>
* <td>Ready</td>
* <td></td>
* <td>Called when the engine service user sets audio recording type.</td>
* </tr>
* <tr>
+ * <td>vce_set_server_dialog_cb()</td>
+ * <td>Called when the engine service user sets app id which is want to ask server dialog.</td>
+ * </tr>
+ * <tr>
* <td>vce_set_domain_cb()</td>
* <td>Called when the engine service user sets domain (agent or device type).</td>
* </tr>
#ifndef __VCE_H__
#define __VCE_H__
+#include <tizen.h>
/**
* @addtogroup CAPI_UIX_VOICE_CONTROL_ENGINE_MODULE
VCE_ASR_RESULT_EVENT_ERROR /**< Event when the ASR result is failed */
} vce_asr_result_event_e;
+/**
+ * @brief Enumerations of audio channels
+ * @since_tizen 5.0
+ */
+typedef enum {
+ VCE_AUDIO_CHANNEL_MONO = 0, /**< 1 channel, mono */
+ VCE_AUDIO_CHANNEL_STEREO = 1 /**< 2 channels, stereo */
+} vce_audio_channel_e;
+
+/**
+ * @brief Enumeration for TTS feedback events
+ * @since_tizen 5.0
+ */
+typedef enum {
+ VCE_FEEDBACK_EVENT_FAIL = -1, /**< Failed */
+ VCE_FEEDBACK_EVENT_START = 1, /**< Start event */
+ VCE_FEEDBACK_EVENT_CONTINUE = 2, /**< Continue event */
+ VCE_FEEDBACK_EVENT_FINISH = 3 /**< Finish event */
+} vce_feedback_event_e;
+
+
/**
* @brief A structure of handle for VC command.
* @since_tizen 5.0
*/
typedef int (*vce_set_audio_type_cb)(const char* audio_type);
+/**
+* @brief Called when the engine service user sets app id which is want to ask server dialog.
+* @since_tizen 5.0
+* @remarks The @a app_id and @a credential can be used only in the callback. To use outside, make a copy.
+* @param[in] app_id App id which is to want to ask server dialog.
+* @param[in] credential Credential key.
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful.
+* @retval #VCE_ERROR_NOT_SUPPORTED_FEATURE Not supported feature.
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied.
+*/
+typedef int (*vce_set_server_dialog_cb)(const char* app_id, const char* credential);
+
/**
* @brief Called when the engine service user sets domain (agent or device type).
* @since_tizen 5.0
*/
typedef int (*vce_nlu_base_info_requested_cb)(const char* key, char** value);
+/**
+* @brief Called when client gets the specific engine's request from the engine service user.
+* @since_tizen 5.0
+*
+* @param[in] engine_app_id The specific engine's app id
+* @param[in] event The specific engine event type
+* @param[in] request The specific engine request
+*
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+*
+* @pre An application registers callback function using vce_set_specific_engine_request_cb().
+*
+* @see vce_set_specific_engine_request_cb()
+* @see vce_unset_specific_engine_request_cb()
+*/
+typedef int (*vce_specific_engine_request_cb)(const char* engine_app_id, const char* event, const char* request);
+
/**
* @brief Called when the engine service user sets private data between app and engine.
* @since_tizen 5.0
vce_cancel_cb cancel; /**< Cancel recording and processing */
vce_set_audio_type_cb set_audio_type; /**< Set audio type */
+ vce_set_server_dialog_cb set_server_dialog; /**< Set server dialog */
vce_set_domain_cb set_domain; /**< Set domain */
vce_process_text_cb process_text; /**< Request to process text */
vce_process_list_event_cb process_list_event; /**< Request to process list event */
vce_process_haptic_event_cb process_haptic_event; /**< Request to process haptic event */
+
+ /* Optional callbacks */
+ vce_private_data_set_cb private_data_set;
+ vce_private_data_requested_cb private_data_request;
+ vce_nlu_base_info_requested_cb nlu_base_info_request;
+ vce_specific_engine_request_cb specific_engine_request;
} vce_request_callback_s;
/**
*/
int vce_send_nlg_result(const char* nlg_result, void* user_data);
+/**
+* @brief Sends the specific engine result to the engine service user.
+* @since_tizen 5.0
+*
+* @param[in] engine_app_id A specific engine's app id
+* @param[in] event A specific engine result event
+* @param[in] result A specific engine result text
+* @param[in] user_data The user data passed from the start
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+* @pre The vce_main() function should be invoked before this function is called.
+*/
+int vce_send_specific_engine_result(const char* engine_app_id, const char* event, const char* result, void *user_info);
+
/**
* @brief Sends the error to the engine service user.
* @details The following error codes can be delivered. \n
*/
int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func);
+/**
+* @brief Registers a callback function for getting the engine service request.
+* @since_tizen 5.0
+*
+* @param[in] callback Callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+*
+* @see vce_unset_specific_engine_request_cb()
+*/
+int vce_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_func);
+
+/**
+* @brief Unregisters the engine service request callback function.
+* @since_tizen 5.0
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VC_ERROR_NOT_SUPPORTED Not supported
+*
+* @see vce_set_specific_engine_request_cb()
+*/
+int vce_unset_specific_engine_request_cb(void);
+
/**
* @brief Retrieves all commands using callback function.
* @since_tizen 5.0
*/
int vce_stop_recording(void);
+/* for TTS feeadback */
+/**
+* @brief Sends audio formats necessary for playing TTS feedback.
+* @since_tizen 5.0
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+*/
+int vce_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_audio_type_e audio_type);
+
+/**
+* @brief Sends audio streaming necessary for playing TTS feedback.
+* @since_tizen 5.0
+* @return 0 on success, otherwise a negative error value.
+* @retval #VCE_ERROR_NONE Successful
+* @retval #VCE_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VCE_ERROR_NOT_SUPPORTED Not supported
+* @retval #VCE_ERROR_OPERATION_FAILED Operation failure
+* @retval #VCE_ERROR_OUT_OF_MEMORY Out of Memory
+*/
+int vce_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int len);
+
+
#ifdef __cplusplus
}
#endif
int vc_set_invocation_name(const char* name);
+/**
+ * @brief Requests to set app id which is to want to ask the server dialogue.
+ * @details Using this function, the developer can request registering the application on vc framework.
+ * If developer requests to register @a app_id with @a credential which is valid, the application will be set on vc framework.
+ * and then, when the developer requests the dialogue using vc_request_dialog(), dialog from specific engine server will be played by vc framework.
+ * @since_tizen 5.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ * @param[in] app_id App id which is to want to ask server dialog.
+ * @param[in] credential Credential key.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #VC_ERROR_NONE Successful
+ * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #VC_ERROR_INVALID_STATE Invalid state
+ * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #VC_ERROR_NOT_SUPPORTED Not supported
+ * @pre The service state should be #VC_SERVICE_STATE_READY.
+ * @see vc_unset_server_dialog()
+ */
+int vc_set_server_dialog(const char* app_id, const char* credential);
+
+
+/**
+ * @brief Requests to unset app id which is to not want to ask the server dialogue.
+ * @details Using this function, the developer can disable function to ask dialog based on server.
+ * @since_tizen 5.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/recorder
+ * @param[in] app_id App id which is to not want to ask server dialog.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #VC_ERROR_NONE Successful
+ * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #VC_ERROR_INVALID_STATE Invalid state
+ * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #VC_ERROR_NOT_SUPPORTED Not supported
+ * @pre The service state should be #VC_SERVICE_STATE_READY.
+ * @see vc_set_server_dialog()
+ */
+int vc_unset_server_dialog(const char* app_id);
+
+
/**
* @brief Requests to start the dialogue.
* @details Using this function, the developer can request starting the dialogue to the framework.
VC_STATE_READY = 2 /**< 'Ready' state */
} vc_state_e;
+/**
+* @brief Enumerations of audio types.
+* @since_tizen 5.0
+*/
+typedef enum {
+ VC_AUDIO_TYPE_PCM_S16_LE = 0, /**< Signed 16bit audio type, Little endian */
+ VC_AUDIO_TYPE_PCM_U8 /**< Unsigned 8bit audio type */
+} vc_audio_type_e;
+
+/**
+ * @brief Enumerations for audio channels
+ * @since_tizen 5.0
+ */
+typedef enum {
+ VC_AUDIO_CHANNEL_MONO = 0, /**< 1 channel, mono */
+ VC_AUDIO_CHANNEL_STEREO = 1 /**< 2 channels, stereo */
+} vc_audio_channel_e;
+
+/**
+ * @brief Enumeration for TTS feedback events
+ * @since_tizen 5.0
+ */
+typedef enum {
+ VC_FEEDBACK_EVENT_FAIL = -1, /**< Failed */
+ VC_FEEDBACK_EVENT_START = 1, /**< Start event */
+ VC_FEEDBACK_EVENT_CONTINUE = 2, /**< Continue event */
+ VC_FEEDBACK_EVENT_FINISH = 3 /**< Finish event */
+} vc_feedback_event_e;
+
/**
* @brief Called when client gets the recognition result.
*/
typedef void (*vc_mgr_pre_result_cb)(vc_pre_result_event_e event, const char *result, void *user_data);
+/**
+* @brief Called when client gets the specific engine's result from vc-service.
+* @since_tizen 5.0
+*
+* @param[in] engine_app_id The specific engine's app id
+* @param[in] event The specific engine event type
+* @param[in] result The specific engine result
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre An application registers callback function using vc_mgr_set_specific_engine_result_cb().
+*
+* @see vc_mgr_set_specific_engine_result_cb()
+* @see vc_mgr_unset_specific_engine_result_cb()
+*/
+typedef void (*vc_mgr_specific_engine_result_cb)(const char* engine_app_id, const char* event, const char* result, void *user_data);
+
/**
* @brief Called when user speaking is detected.
* @since_tizen 5.0
*/
typedef int (*vc_mgr_private_data_requested_cb)(const char *key, char **data, void *user_data);
+/* for TTS feedback */
+/**
+* @brief Called when engine sends audio formats necessary for playing TTS feedback
+*
+* @param[in] rate Audio sampling rate
+* @param[in] channel Audio channel (e.g. #VC_AUDIO_CHANNEL_MONO, #VC_AUDIO_CHANNEL_STEREO)
+* @param[in] audio_type Audio type (e.g. #VC_AUDIO_TYPE_PCM_S16_LE, #VC_AUDIO_TYPE_PCM_U8)
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre An application registers callback function using vc_mgr_set_feedback_audio_format_cb().
+*
+* @see vc_mgr_set_feedback_audio_format_cb()
+* @see vc_mgr_unset_feedback_audio_format_cb()
+*/
+typedef void (*vc_mgr_feedback_audio_format_cb)(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type, void *user_data);
+
+/**
+* @brief Called when engine sends audio streaming for TTS feedback
+*
+* @param[in] event TTS feedback event (e.g. #VC_FEEDBACK_EVENT_START, #VC_FEEDBACK_EVENT_CONTINUE)
+* @param[in] buffer Audio streaming data
+* @param[in] len Length of the audio streaming data
+* @param[in] user_data The user data passed from the callback registration function
+*
+* @pre An application registers callback function using vc_mgr_set_feedback_streaming_cb().
+*
+* @see vc_mgr_set_feedback_streaming_cb()
+* @see vc_mgr_unset_feedback_streaming_cb()
+*/
+typedef void (*vc_mgr_feedback_streaming_cb)(vc_feedback_event_e event, char* buffer, int len, void *user_data);
+
+
/**
* @platform
* @brief Initializes the voice control manager.
*/
int vc_mgr_do_action(vc_send_event_type_e type, char *send_event);
+/**
+* @brief Sends the specific engine request to the vc-service.
+* @since_tizen 5.0
+*
+* @param[in] engine_app_id A specific engine's app id
+* @param[in] event A engine service user request event
+* @param[in] request A engine service user request text
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_OUT_OF_MEMORY Not enough memory
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VC_ERROR_OPERATION_FAILED Operation failure
+*/
+int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request);
+
/**
* @platform
* @brief Starts recognition.
*/
int vc_mgr_unset_pre_result_cb(void);
+/**
+* @brief Registers a callback function for getting specific engine result.
+* @since_tizen 5.0
+*
+* @param[in] callback Callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+* @retval #VC_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VC_ERROR_NOT_SUPPORTED Not supported
+*
+* @pre The state should be #VC_STATE_INITIALIZED.
+*
+* @see vc_mgr_unset_specific_engine_result_cb()
+*/
+int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callback, void* user_data);
+
+/**
+* @brief Unregisters the specific engine result callback function.
+* @since_tizen 5.0
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+* @retval #VC_ERROR_PERMISSION_DENIED Permission denied
+* @retval #VC_ERROR_NOT_SUPPORTED Not supported
+*
+* @pre The state should be #VC_STATE_INITIALIZED.
+*
+* @see vc_mgr_set_specific_engine_result_cb()
+*/
+int vc_mgr_unset_specific_engine_result_cb(void);
+
/**
* @platform
* @brief Sets a callback function for getting all types of recognition results.
*/
int vc_mgr_unset_private_data_requested_cb(void);
+/* for TTS feedback */
+/**
+* @brief Sets a callback function to be called when engine sends audio formats necessary for playing TTS feedback.
+*
+* @param[in] callback Callback function to set
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_INITIALIZED.
+*
+* @see vc_mgr_feedback_audio_format_cb()
+* @see vc_mgr_unset_feedback_audio_format_cb()
+*/
+int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback, void* user_data);
+
+/**
+* @brief Unsets a callback function to be called when engine sends audio formats necessary for playing TTS feedback.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_INITIALIZED.
+*
+* @see vc_mgr_feedback_audio_format_cb()
+* @see vc_mgr_set_feedback_audio_format_cb()
+*/
+int vc_mgr_unset_feedback_audio_format_cb(void);
+
+/**
+* @brief Sets a callback function to be called when engine sends audio streaming for TTS feedback.
+*
+* @param[in] callback Callback function to set
+* @param[in] user_data The user data to be passed to the callback function
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_INITIALIZED.
+*
+* @see vc_mgr_feedback_streaming_cb()
+* @see vc_mgr_unset_feedback_streaming_cb()
+*/
+int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void* user_data);
+
+/**
+* @brief Unsets a callback function to be called when engine sends audio streaming for TTS feedback.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_INITIALIZED.
+*
+* @see vc_mgr_feedback_streaming_cb()
+* @see vc_mgr_set_feedback_streaming_cb()
+*/
+int vc_mgr_unset_feedback_streaming_cb(void);
+
+/**
+* @brief Starts getting TTS feedback streaming data from the buffer.
+*
+* @remarks In order to get TTS feedback streaming data, the application should set 'vc_mgr_feedback_streaming_cb()' using vc_mgr_set_feedback_streaming_cb().
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_READY. \n
+* 'vc_mgr_feedback_streaming_cb()' should be registered.
+*
+* @see vc_mgr_feedback_streaming_cb()
+* @see vc_mgr_set_feedback_streaming_cb()
+* @see vc_mgr_unset_feedback_streaming_cb()
+* @see vc_mgr_stop_feedback()
+*/
+int vc_mgr_start_feedback(void);
+
+/**
+* @brief Stops getting and removes TTS feedback streaming data from the buffer.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_READY.
+*
+* @see vc_mgr_feedback_streaming_cb()
+* @see vc_mgr_set_feedback_streaming_cb()
+* @see vc_mgr_unset_feedback_streaming_cb()
+* @see vc_mgr_start_feedback()
+*/
+int vc_mgr_stop_feedback(void);
+
+
#ifdef __cplusplus
}
#endif
return g_recognition_mode;
}
+int vcd_client_set_server_dialog(int pid, bool is_server_dialog)
+{
+ vc_client_info_s* client_info = NULL;
+
+ client_info = __client_get_element(pid);
+ if (NULL == client_info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] vcd_client_get_pid : pid(%d) is not found", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ client_info->server_dialog = is_server_dialog;
+
+ SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Set server dialog, client pid(%d), server_dialog(%d)", pid, client_info->server_dialog);
+ return 0;
+}
+
+int vcd_client_get_server_dialog(int pid, bool* is_server_dialog)
+{
+ vc_client_info_s* client_info = NULL;
+
+ client_info = __client_get_element(pid);
+ if (NULL == client_info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] vcd_client_get_pid : pid(%d) is not found", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ *is_server_dialog = client_info->server_dialog;
+
+ SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Get server dialog, client pid(%d), server_dialog(%d)", pid, *is_server_dialog);
+ return 0;
+}
+
int vcd_client_append_cmd_from_type(int type, vc_cmd_list_h list)
{
GSList *item = NULL;
info->fg_cmd = false;
info->bg_cmd = false;
info->exclusive_cmd = false;
+ info->server_dialog = false;
/* Add item to global list */
g_client_list = g_slist_append(g_client_list, info);
int vcd_client_save_client_info();
void vcd_client_update_foreground_pid();
+
+int vcd_client_set_server_dialog(int pid, bool is_server_dialog);
+
+int vcd_client_get_server_dialog(int pid, bool* is_server_dialog);
+
/*
* widget API
*/
return 0;
}
+int vcdc_send_specific_engine_result_to_manager(int manager_pid, const char* engine_app_id, const char* event, const char* result)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[VCDC] send specific engine result to manager, mgr pid(%d), engine app id(%s), event(%s), result(%s),",
+ manager_pid, engine_app_id, event, result);
+
+ if (0 != __dbus_check()) {
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* msg = NULL;
+
+ msg = __get_message(manager_pid, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT, VCD_CLIENT_TYPE_MANAGER);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &engine_app_id, DBUS_TYPE_STRING, &event, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send");
+ return VCD_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] SUCCESS Send");
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ return 0;
+}
+
int vcdc_send_result_to_manager(int manger_pid, int result_type)
{
if (0 != __dbus_check()) {
return result;
}
+int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_audio_channel_e channel, vce_audio_type_e audio_type)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[Dbus] Send TTS feedback audio format : manager_pid(%d), rate(%d), audio channel(%d), audio type(%d)", manager_pid, rate, channel, audio_type);
+
+ if (0 != __dbus_check()) {
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ /* make dbus message */
+ DBusMessage* msg = NULL;
+ msg = __get_message(manager_pid, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT, VCD_CLIENT_TYPE_MANAGER);
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &rate,
+ DBUS_TYPE_INT32, &channel,
+ DBUS_TYPE_INT32, &audio_type,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ int ret = VCD_ERROR_NONE;
+
+ if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send");
+ ret = VCD_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[Dbus] SUCCESS Send");
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ dbus_message_unref(msg);
+
+ return ret;
+}
+
+int vcdc_send_feedback_streaming_to_manager(int manager_pid, vc_feedback_event_e event, char* buffer, int len)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[Dbus] Send TTS feedback streaming : manager_pid(%d), feedback event(%d), buffer(%p), length(%d)", manager_pid, event, buffer, len);
+
+ if (0 != __dbus_check()) {
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ /* make dbus message */
+ DBusMessage* msg = NULL;
+ msg = __get_message(manager_pid, VCD_MANAGER_METHOD_FEEDBACK_STREAMING, VCD_CLIENT_TYPE_MANAGER);
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &event,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+ &buffer, len,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ int ret = VCD_ERROR_NONE;
+
+ if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send");
+ ret = VCD_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[Dbus] SUCCESS Send");
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ dbus_message_unref(msg);
+
+ return ret;
+}
+
static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
{
if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW;
else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_DO_ACTION))
vcd_dbus_server_mgr_do_action(g_conn_listener, msg);
+ else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_SPECIFIC_ENGINE_REQUEST))
+ vcd_dbus_server_mgr_send_specific_engine_request(g_conn_listener, msg);
+
else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_ENABLE_COMMAND_TYPE))
vcd_dbus_server_mgr_enable_command_type(g_conn_listener, msg);
else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_DISABLE_COMMAND_TYPE))
vcd_dbus_server_mgr_disable_command_type(g_conn_listener, msg);
+ else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_START_FEEDBACK))
+ vcd_dbus_server_mgr_start_feedback(g_conn_listener, msg);
+
+ else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_STOP_FEEDBACK))
+ vcd_dbus_server_mgr_stop_feedback(g_conn_listener, msg);
+
/* client event */
else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_INITIALIZE))
vcd_dbus_server_initialize(g_conn_listener, msg);
else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_FOREGROUND))
vcd_dbus_server_set_foreground(g_conn_listener, msg);
+ else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_SERVER_DIALOG))
+ vcd_dbus_server_set_server_dialog(g_conn_listener, msg);
+
else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_DIALOG))
vcd_dbus_server_dialog(g_conn_listener, msg);
int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_result);
+int vcdc_send_specific_engine_result_to_manager(int manager_pid, const char* engine_app_id, const char* event, const char* result);
+
int vcdc_send_result_to_manager(int manger_pid, int result_type);
int vcdc_send_speech_detected(int manger_pid);
int vcdc_send_request_get_private_data(int pid, const char* key, char** data);
+/* for TTS feedback */
+int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_audio_channel_e channel, vce_audio_type_e audio_type);
+
+int vcdc_send_feedback_streaming_to_manager(int manager_pid, vc_feedback_event_e event, char* buffer, int len);
+
+
#ifdef __cplusplus
}
#endif
return 0;
}
+int vcd_dbus_server_mgr_send_specific_engine_request(DBusConnection* conn, DBusMessage* msg)
+{
+ DBusError err;
+ dbus_error_init(&err);
+
+ int pid = 0;
+ char* engine_app_id = NULL;
+ char* event = NULL;
+ char* request = NULL;
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager specific engine request");
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_STRING, &engine_app_id,
+ DBUS_TYPE_STRING, &event,
+ DBUS_TYPE_STRING, &request,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr specific engine request : get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ ret = VCD_ERROR_OPERATION_FAILED;
+ } else {
+ ret = vcd_server_mgr_send_specific_engine_request(pid, engine_app_id, event, request);
+ SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr specific engine request : pid(%d), engine_app_id(%s), event(%s), request(%s), ret(%d)", pid, engine_app_id, event, request, ret);
+ }
+
+ return 0;
+}
+
int vcd_dbus_server_mgr_set_domain(DBusConnection* conn, DBusMessage* msg)
{
DBusError err;
int ret = VCD_ERROR_OPERATION_FAILED;
- SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set audio type");
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set domain type");
dbus_message_get_args(msg, &err,
DBUS_TYPE_INT32, &pid,
*/
}
+/* for TTS feedback */
+int vcd_dbus_server_mgr_start_feedback(DBusConnection* conn, DBusMessage* msg)
+{
+ DBusError err;
+ dbus_error_init(&err);
+
+ int pid = 0;
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager start TTS feedback");
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] vcd mgr start TTS feedback : get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ ret = VCD_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[DEBUG] vcd mgr start TTS feedback : pid(%d)", pid);
+ ret = vcd_server_mgr_start_feedback();
+ }
+
+ DBusMessage* reply;
+ reply = dbus_message_new_method_return(msg);
+
+ if (NULL != reply) {
+ dbus_message_append_args(reply,
+ DBUS_TYPE_INT32, &ret,
+ DBUS_TYPE_INVALID);
+
+ if (0 == ret) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[SUCCESS] Result(%d)", ret);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Result(%d)", ret);
+ }
+
+ if (!dbus_connection_send(conn, reply, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Out of Memory");
+ }
+
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create reply message");
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
+
+ return 0;
+}
+
+int vcd_dbus_server_mgr_stop_feedback(DBusConnection* conn, DBusMessage* msg)
+{
+ DBusError err;
+ dbus_error_init(&err);
+
+ int pid = 0;
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager stop TTS feedback");
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] vcd mgr stop TTS feedback : get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ ret = VCD_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[DEBUG] vcd mgr stop TTS feedback : pid(%d)", pid);
+ ret = vcd_server_mgr_stop_feedback();
+ }
+
+ DBusMessage* reply;
+ reply = dbus_message_new_method_return(msg);
+
+ if (NULL != reply) {
+ dbus_message_append_args(reply,
+ DBUS_TYPE_INT32, &ret,
+ DBUS_TYPE_INVALID);
+
+ if (0 == ret) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[SUCCESS] Result(%d)", ret);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Result(%d)", ret);
+ }
+
+ if (!dbus_connection_send(conn, reply, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Out of Memory");
+ }
+
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create reply message");
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
+
+ return 0;
+}
+
+
/*
* Dbus Server functions for client
*/
return 0;
}
+int vcd_dbus_server_set_server_dialog(DBusConnection* conn, DBusMessage* msg)
+{
+ DBusError err;
+ dbus_error_init(&err);
+
+ int pid = -1;
+ char* app_id = NULL;
+ char* credential = NULL;
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_STRING, &app_id,
+ DBUS_TYPE_STRING, &credential,
+ DBUS_TYPE_INVALID);
+
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set server dialog");
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd set server dialog : get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ ret = VCD_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd set server dialog : pid(%d), app_id(%s)", pid, app_id);
+ ret = vcd_server_set_server_dialog(pid, app_id, credential);
+ }
+
+ DBusMessage* reply;
+ reply = dbus_message_new_method_return(msg);
+
+ if (NULL != reply) {
+ if (0 == ret) {
+ /* Append result and language */
+ dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+
+ SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret);
+ } else {
+ dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+
+ SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret);
+ }
+
+ if (!dbus_connection_send(conn, reply, NULL)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!");
+ }
+
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!");
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCD, "@@@");
+
+ return 0;
+
+}
+
int vcd_dbus_server_dialog(DBusConnection* conn, DBusMessage* msg)
{
DBusError err;
int vcd_dbus_server_mgr_disable_command_type(DBusConnection* conn, DBusMessage* msg);
+int vcd_dbus_server_mgr_send_specific_engine_request(DBusConnection* conn, DBusMessage* msg);
+
+/* for TTS feedback */
+int vcd_dbus_server_mgr_start_feedback(DBusConnection* conn, DBusMessage* msg);
+
+int vcd_dbus_server_mgr_stop_feedback(DBusConnection* conn, DBusMessage* msg);
+
+
/*
* Dbus Server functions for client
*/
int vcd_dbus_server_set_foreground(DBusConnection* conn, DBusMessage* msg);
+int vcd_dbus_server_set_server_dialog(DBusConnection* conn, DBusMessage* msg);
+
int vcd_dbus_server_dialog(DBusConnection* conn, DBusMessage* msg);
int vcd_dbus_server_is_system_command_valid(DBusConnection* conn, DBusMessage* msg);
bool use_network;
void *handle;
- vc_engine_callback_s* callbacks;
+ vce_request_callback_s* callbacks;
} vcengine_s;
typedef struct _vcengine_info {
g_dynamic_engine.handle = NULL;
g_dynamic_engine.is_command_ready = false;
- g_dynamic_engine.callbacks = (vc_engine_callback_s*)calloc(1, sizeof(vc_engine_callback_s));
+ g_dynamic_engine.callbacks = (vce_request_callback_s*)calloc(1, sizeof(vce_request_callback_s));
if (NULL == g_dynamic_engine.callbacks) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Fail to allocate memory");
return VCD_ERROR_OUT_OF_MEMORY;
free(g_dynamic_engine.callbacks);
g_dynamic_engine.callbacks = NULL;
}
- g_dynamic_engine.callbacks = (vc_engine_callback_s*)calloc(1, sizeof(vc_engine_callback_s));
+ g_dynamic_engine.callbacks = (vce_request_callback_s*)calloc(1, sizeof(vce_request_callback_s));
if (NULL == g_dynamic_engine.callbacks) {
SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to allocate memory");
return VCD_ERROR_OUT_OF_MEMORY;
g_dynamic_engine.callbacks->cancel = callback->cancel;
g_dynamic_engine.callbacks->set_domain = callback->set_domain;
g_dynamic_engine.callbacks->set_audio_type = callback->set_audio_type;
+ g_dynamic_engine.callbacks->set_server_dialog = callback->set_server_dialog;
g_dynamic_engine.callbacks->process_text = callback->process_text;
g_dynamic_engine.callbacks->process_list_event = callback->process_list_event;
g_dynamic_engine.callbacks->process_haptic_event = callback->process_haptic_event;
g_dynamic_engine.callbacks->private_data_set = NULL;
g_dynamic_engine.callbacks->private_data_request = NULL;
g_dynamic_engine.callbacks->nlu_base_info_request = NULL;
+ g_dynamic_engine.callbacks->specific_engine_request = NULL;
SLOG(LOG_DEBUG, TAG_VCD, "@@@ Valid Engine");
SLOG(LOG_DEBUG, TAG_VCD, "Engine uuid : %s", g_dynamic_engine.engine_uuid);
NULL == g_dynamic_engine.callbacks->stop ||
NULL == g_dynamic_engine.callbacks->cancel ||
NULL == g_dynamic_engine.callbacks->set_audio_type ||
+ NULL == g_dynamic_engine.callbacks->set_server_dialog ||
NULL == g_dynamic_engine.callbacks->set_domain ||
NULL == g_dynamic_engine.callbacks->process_text ||
NULL == g_dynamic_engine.callbacks->process_list_event ||
return 0;
}
+int vcd_engine_set_server_dialog(const char* app_id, const char* credential)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ int ret = -1;
+ if (true == g_dynamic_engine.is_loaded) {
+ ret = g_dynamic_engine.callbacks->set_server_dialog(app_id, credential);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set server dialog (%d)", ret);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
int vcd_engine_set_domain(int pid, const char* domain)
{
if (false == g_agent_init) {
return 0;
}
+int vcd_engine_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ int ret = -1;
+ if (true == g_dynamic_engine.is_loaded && NULL != g_dynamic_engine.callbacks->specific_engine_request) {
+ ret = g_dynamic_engine.callbacks->specific_engine_request(engine_app_id, event, request);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to set specific engine request (%d)", ret);
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Engine is not loaded or There is no specific_engine_request callback");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ return 0;
+}
+
int vcd_engine_process_text(int pid, const char* text)
{
if (false == g_agent_init) {
return VCD_ERROR_NONE;
}
+int vcd_engine_agent_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_func)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not Initialized");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ if (false == g_dynamic_engine.is_loaded) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Not loaded engine");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ g_dynamic_engine.callbacks->specific_engine_request = callback_func;
+
+ return VCD_ERROR_NONE;
+}
int vcd_engine_set_audio_type(const char* audio);
+int vcd_engine_set_server_dialog(const char* app_id, const char* credential);
+
int vcd_engine_set_domain(int pid, const char* domain);
int vcd_engine_get_nlu_base_info(int pid, const char* key, char** value);
int vcd_engine_get_private_data(int pid, const char* key, char** data);
+int vcd_engine_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request);
+
int vcd_engine_process_text(int pid, const char* text);
int vcd_engine_process_list_event(int pid, const char* event);
int vcd_engine_agent_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func);
+int vcd_engine_agent_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_func);
#ifdef __cplusplus
}
#include "vc_defs.h"
#include "vce.h"
+#include "voice_control_common.h"
+
#ifdef __cplusplus
extern "C" {
int index;
} vce_cmd_s;
-typedef struct {
- int version; /**< Version */
-
- /* Mandatory callbacks */
- /* Get engine information */
- vce_get_info_cb get_info; /**< Called when the engine service user requests the basic information of VC engine */
- vce_get_recording_format_cb get_recording_format; /**< Get recording format */
- vce_foreach_supported_languages_cb foreach_langs; /**< Foreach language list */
- vce_is_language_supported_cb is_lang_supported; /**< Check language */
-
- vce_initialize_cb initialize; /**< Initialize engine */
- vce_deinitialize_cb deinitialize; /**< Shutdown engine */
-
- /* Set info */
- vce_set_language_cb set_language; /**< Set language */
- vce_set_commands_cb set_commands; /**< Request to set current commands */
- vce_unset_commands_cb unset_commands; /**< Request to unset current commands */
-
- /* Control recognition */
- vce_start_cb start; /**< Start recognition */
- vce_set_recording_data_cb set_recording; /**< Set recording data */
- vce_stop_cb stop; /**< Stop recording for getting result */
- vce_cancel_cb cancel; /**< Cancel recording and processing */
-
- vce_set_audio_type_cb set_audio_type; /**< Set audio type */
-
- vce_set_domain_cb set_domain; /**< Set domain */
- vce_process_text_cb process_text; /**< Request to process text */
- vce_process_list_event_cb process_list_event; /**< Request to process list event */
- vce_process_haptic_event_cb process_haptic_event; /**< Request to process haptic event */
-
- /* Optional callbacks */
- vce_private_data_set_cb private_data_set;
- vce_private_data_requested_cb private_data_request;
- vce_nlu_base_info_requested_cb nlu_base_info_request;
-} vc_engine_callback_s;
-
#ifdef __cplusplus
}
return ret;
}
+int vcd_send_specific_engine_result(const char* engine_app_id, const char* event, const char* result, void *user_info)
+{
+ if (NULL != result) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] specific engine result - Event(%s), Text(%s)", event, result);
+ vcdc_send_specific_engine_result_to_manager(vcd_client_manager_get_pid(), engine_app_id, event, result);
+ }
+
+ if (VCD_RECOGNITION_MODE_RESTART_CONTINUOUSLY != vcd_client_get_recognition_mode()) {
+ vcd_config_set_service_state(VCD_STATE_READY);
+ vcdc_send_service_state(VCD_STATE_READY);
+ }
+
+ return VCD_ERROR_NONE;
+}
+
int vcd_send_nlg_result(const char* nlg_result, void *user_data)
{
int ret = __vcd_server_launch_manager_app();
return ret;
}
+/* for TTS feedback */
+int vcd_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_audio_type_e audio_type)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback audio format");
+
+ /* send TTS feedback audio format to VC manager */
+ int ret = VCD_ERROR_NONE;
+ ret = vcdc_send_feedback_audio_format_to_manager(vcd_client_manager_get_pid(), rate, channel, audio_type);
+ if (VCD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send TTS feedback audio format to VC manager");
+ }
+
+ return ret;
+}
+
+int vcd_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int len)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback streaming");
+
+ /* send TTS feedback streaming to VC manager */
+ int ret = VCD_ERROR_NONE;
+ ret = vcdc_send_feedback_streaming_to_manager(vcd_client_manager_get_pid(), event, buffer, len);
+ if (VCD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send TTS feedback streaming to VC manager");
+ }
+
+ return ret;
+}
+
+
/*
* vcd server Interfaces
*/
return ret;
}
+int vcd_server_mgr_send_specific_engine_request(int pid, const char* engine_app_id, const char* event, const char* request)
+{
+ /* check if pid is valid */
+ if (false == vcd_client_manager_is_valid(pid)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] The manager pid(%d) is NOT valid", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+ vcd_state_e state = vcd_config_get_service_state();
+ if (VCD_STATE_READY != state) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready");
+ return VCD_ERROR_INVALID_STATE;
+ }
+
+ /* Get private data to engine */
+ int ret = vcd_engine_send_specific_engine_request(engine_app_id, event, request);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set specific engine request : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server SUCCESS] Set specific engine request ");
+ }
+
+ return ret;
+}
+
int vcd_server_mgr_do_action(int pid, int type, const char* action)
{
int ret = -1;
return ret;
}
+/* for TTS feedback */
+int vcd_server_mgr_start_feedback(void)
+{
+ /* check current state */
+ /* not Recording??? */
+
+ if (-1 == vcd_client_manager_get_pid()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Manager is NOT available");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] start TTS feedback");
+
+ /* check there is TTS buffer to be spoken */
+
+ return VCD_ERROR_NONE;
+}
+
+int vcd_server_mgr_stop_feedback(void)
+{
+ /* check current state */
+ /* not Recording??? */
+
+ if (-1 == vcd_client_manager_get_pid()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Manager is NOT available");
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] stop TTS feedback");
+
+ return VCD_ERROR_NONE;
+}
+
+
/*
* VC Server Functions for Client
*/
return VCD_ERROR_NONE;
}
-int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int continuous)
+int vcd_server_set_server_dialog(int pid, const char* app_id, const char* credential)
{
/* check if pid is valid */
- if (false == vcd_client_is_available(pid) && false == vcd_client_widget_is_available(pid)) {
+ if (false == vcd_client_is_available(pid)) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] pid is NOT valid ");
return VCD_ERROR_INVALID_PARAMETER;
}
- int ret = __vcd_server_launch_manager_app();
+ int ret = vcd_engine_set_server_dialog(app_id, credential);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), pid(%d), disp_text(%s), utt_text(%s), continue(%d)", vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set server dialog, pid(%d), app_id(%s), ret(%d)", pid, app_id, ret);
+ vcd_client_set_server_dialog(pid, false);
return ret;
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Success] Set server dialog, pid(%d), app_id(%s)", pid, app_id);
+
+ if (0 != strncmp(credential, "#NULL", strlen(credential))) {
+ ret = vcd_client_set_server_dialog(pid, true);
+ if (0 != ret)
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set to true for server dialog, app_id(%s)", app_id);
+ } else {
+ ret = vcd_client_set_server_dialog(pid, false);
+ if (0 != ret)
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set to false for server dialog, app_id(%s)", app_id);
+ }
+
+ return 0;
+}
+
+int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int continuous)
+{
+ /* check if pid is valid */
+ if (false == vcd_client_is_available(pid) && false == vcd_client_widget_is_available(pid)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] pid is NOT valid ");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
- ret = vcdc_send_dialog(vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous);
+ bool is_server_dialog = false;
+ int ret = vcd_client_get_server_dialog(pid, &is_server_dialog);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), pid(%d), disp_text(%s), utt_text(%s), continue(%d)", vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous);
- return ret;
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get server dialog, pid(%d), ret(%d)", pid, ret);
}
+ if (true == is_server_dialog) {
+ /* ++ Request tts event to engine */
+
+ /* -- Request tts event to engine */
+ } else {
+ ret = __vcd_server_launch_manager_app();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), pid(%d), disp_text(%s), utt_text(%s), continue(%d)", vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous);
+ return ret;
+ }
+
+ ret = vcdc_send_dialog(vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), pid(%d), disp_text(%s), utt_text(%s), continue(%d)", vcd_client_manager_get_pid(), pid, disp_text, utt_text, continuous);
+ return ret;
+ }
+ }
return 0;
}
return ret;
}
+
+int vcd_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_func)
+{
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set specific engine request cb");
+ int ret = 0;
+ ret = vcd_engine_agent_set_specific_engine_request_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set specific engine request cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
int vcd_server_mgr_disable_command_type(int pid, int cmd_type);
+/* for TTS feedback */
+int vcd_server_mgr_start_feedback(void);
+
+int vcd_server_mgr_stop_feedback(void);
+
+
/*
* For client
*/
int vcd_server_set_foreground(int pid, bool value);
+int vcd_server_set_server_dialog(int pid, const char* app_id, const char* credential);
+
int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int continuous);
int vcd_server_is_system_command_valid(int pid, int* is_sys_cmd_valid);
int vcd_server_set_language(const char* language);
+int vcd_server_mgr_send_specific_engine_request(int pid, const char* engine_app_id, const char* event, const char* request);
+
/*
* For engine service
*/
int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data);
+int vcd_send_specific_engine_result(const char* engine_app_id, const char* event, const char* result, void *user_info);
+
int vcd_send_nlg_result(const char* nlg_result, void *user_data);
int vcd_send_error(vce_error_e error, const char* msg, void *user_data);
int vcd_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func);
+int vcd_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_func);
+
+int vcd_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_audio_type_e audio_type);
+
+int vcd_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int len);
+
#ifdef __cplusplus
}
return ret;
}
+int vce_send_specific_engine_result(const char* engine_app_id, const char* event, const char* result, void *user_info)
+{
+ int ret = VCE_ERROR_NONE;
+
+ if (NULL == engine_app_id || NULL == event) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
+ return VCE_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == result) {
+ SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
+ }
+
+ ret = vcd_send_specific_engine_result(engine_app_id, event, result, user_info);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send specific engine result, ret(%d)", ret);
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send specific engine result, event(%s), result(%s)", event, result);
+ }
+
+ return ret;
+}
+
int vce_send_nlg_result(const char* nlg_result, void *user_data)
{
int ret = VCE_ERROR_NONE;
return ret;
}
+
+int vce_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_func)
+{
+ if (NULL == callback_func) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
+ return VCE_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = vcd_set_specific_engine_request_cb(callback_func);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set specific engine request cb");
+ }
+
+ return ret;
+}
+
+int vce_unset_specific_engine_request_cb(void)
+{
+ int ret = vcd_set_specific_engine_request_cb(NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set specific engine request cb");
+ }
+
+ return ret;
+}
+
+/* for TTS feedback */
+int vce_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_audio_type_e audio_type)
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_send_feedback_audio_format(rate, channel, audio_type);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send feedback audio format");
+ }
+
+ return ret;
+}
+
+int vce_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int len)
+{
+ int ret = VCE_ERROR_NONE;
+
+ ret = vcd_send_feedback_streaming(event, buffer, len);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send feedback streaming");
+ }
+
+ return ret;
+}