Add feedback and server dialog APIs 31/180831/3 submit/tizen/20180607.000037
authorsooyeon.kim <sooyeon.kim@samsung.com>
Mon, 4 Jun 2018 14:21:49 +0000 (23:21 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Tue, 5 Jun 2018 05:10:38 +0000 (14:10 +0900)
Change-Id: I7a4bfe718206b21f723fe693940185a5e18916c2
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
33 files changed:
client/CMakeLists.txt
client/vc.c
client/vc_dbus.c
client/vc_dbus.h
client/vc_mgr.c
client/vc_mgr_client.c
client/vc_mgr_client.h
client/vc_mgr_data.cpp [new file with mode: 0644]
client/vc_mgr_data.h [new file with mode: 0644]
client/vc_mgr_dbus.c
client/vc_mgr_dbus.h
client/vc_mgr_player.c [new file with mode: 0644]
client/vc_mgr_player.h [new file with mode: 0644]
common/vc_defs.h [changed mode: 0755->0644]
common/vc_info_parser.h
doc/uix_vc_doc.h
doc/uix_vc_engine_main_doc.h
include/vce.h
include/voice_control.h
include/voice_control_common.h
include/voice_control_manager.h
server/vcd_client_data.c
server/vcd_client_data.h
server/vcd_dbus.c [changed mode: 0755->0644]
server/vcd_dbus.h
server/vcd_dbus_server.c [changed mode: 0755->0644]
server/vcd_dbus_server.h
server/vcd_engine_agent.c
server/vcd_engine_agent.h
server/vcd_main.h
server/vcd_server.c
server/vcd_server.h
server/vce.c

index fcc4c433c8ffe68b87366db0fb41ad70d096fb75..0380cc0834b38a3a13741825f9922deb46db3c1b 100644 (file)
@@ -34,6 +34,8 @@ SET(WIDGET_SRCS
 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
@@ -52,6 +54,7 @@ FOREACH(flag ${pkgs_CFLAGS})
        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})
index 9a893f3ae7e80bbe85e725a11f44212f96641f1f..14bdf8b06110c4cf0d94705b91f38878588bce5e 100644 (file)
@@ -2146,6 +2146,187 @@ int vc_set_invocation_name(const char* name)
        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;
@@ -2183,7 +2364,7 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta
        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;
        }
 
index 186d25934c13fc4d3b350df91e951233fec94f9e..dfe02281d5f492e5862af4b186d2c97eeb6dec7f 100644 (file)
@@ -851,6 +851,75 @@ int vc_dbus_set_foreground(int pid, bool value)
        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) {
index b5db90b7d5fe12b7af7fed897c272f7db41a2aad..e7f751253bfa147dc0b8b8eefa3d4b66db43507f 100644 (file)
@@ -42,6 +42,8 @@ int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type);
 
 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);
index e56205e468c3b174b4a83e1d820ba27b6a7747da..ab8d584f1af268c5f99c9a501120432c9a06cdb8 100644 (file)
@@ -28,6 +28,8 @@
 #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"
@@ -61,6 +63,12 @@ static cynara *p_cynara = NULL;
 
 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);
@@ -262,6 +270,12 @@ int vc_mgr_initialize(void)
                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, "@@@");
@@ -339,6 +353,12 @@ int vc_mgr_deinitialize(void)
                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");
        }
@@ -1700,26 +1720,14 @@ int vc_mgr_set_private_data(const char* key, const char* data)
        }
 
        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;
@@ -1910,25 +1918,61 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event)
        }
 
        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, "@@@");
 
@@ -2332,30 +2376,14 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list)
                }
        }
 
-       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);
@@ -3272,6 +3300,81 @@ int __vc_mgr_cb_private_data_requested(const char* key, char** data)
        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()) {
@@ -3631,3 +3734,297 @@ int __vc_mgr_request_auth_cancel(int pid)
 
        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;
+}
index 985f46068ac700cac7fadc53ffbac7f22581ff9d..18120ed9bebdcd7edb7bde40fd98e531f2146003 100644 (file)
@@ -46,7 +46,15 @@ typedef struct {
        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;
@@ -174,6 +182,13 @@ int vc_mgr_client_create(vc_h* vc)
        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;
 
@@ -645,6 +660,62 @@ int vc_mgr_client_get_private_data_requested_cb(vc_h vc, vc_mgr_private_data_req
        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)
 {
@@ -1191,3 +1262,31 @@ int vc_mgr_client_get_start_by_client(vc_h vc, bool* option)
 
        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;
+}
index 4c913920aeb8970cc7e3d2ba7021c52cdd88b3b2..e8104c0e4b30e90d2d9e9a929f66ca648c40582b 100644 (file)
@@ -95,6 +95,19 @@ int vc_mgr_client_set_private_data_requested_cb(vc_h vc, vc_mgr_private_data_req
 
 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
 */
diff --git a/client/vc_mgr_data.cpp b/client/vc_mgr_data.cpp
new file mode 100644 (file)
index 0000000..fa455cd
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+* 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();
+}
diff --git a/client/vc_mgr_data.h b/client/vc_mgr_data.h
new file mode 100644 (file)
index 0000000..3e2960f
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+* 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__ */
index 093545216b084c706e6c23bfbdff62112e4b540f..040ebcb407fab5519e26433049e8078e56bca3ae 100644 (file)
@@ -51,6 +51,11 @@ extern int __vc_mgr_cb_private_data_set(const char* key, const char* data);
 
 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);
 
@@ -64,6 +69,8 @@ extern int __vc_mgr_request_auth_cancel(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;
@@ -195,7 +202,20 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd
 
                        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");
 
@@ -372,6 +392,40 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd
                        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");
@@ -2200,3 +2254,41 @@ int vc_mgr_dbus_send_result_selection(int pid)
 
        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;
+}
index 267aa05cdffd17bb358d8700945df398b0971529..26789e8796c36aefbd520cbf208a7ea8aa58952e 100644 (file)
@@ -64,10 +64,16 @@ int vc_mgr_dbus_send_result(int pid, int cmd_type, int result_id);
 
 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
diff --git a/client/vc_mgr_player.c b/client/vc_mgr_player.c
new file mode 100644 (file)
index 0000000..06915f9
--- /dev/null
@@ -0,0 +1,413 @@
+/*
+* 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;
+}
diff --git a/client/vc_mgr_player.h b/client/vc_mgr_player.h
new file mode 100644 (file)
index 0000000..6cf550c
--- /dev/null
@@ -0,0 +1,25 @@
+
+#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__ */
old mode 100755 (executable)
new mode 100644 (file)
index 0299485..096aa4f
@@ -66,6 +66,7 @@ extern "C" {
 #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"
 
@@ -139,6 +140,10 @@ extern "C" {
 #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"
@@ -150,9 +155,13 @@ extern "C" {
 #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"
 
 
index d1532a62aa7fd84e62bfa35762f82ac0c94312bb..45b7a1eb12505349b2a4cc94676cb330e0f9db1b 100644 (file)
@@ -37,6 +37,7 @@ typedef struct _client_s {
        bool    fg_cmd;
        bool    bg_cmd;
        bool    exclusive_cmd;
+       bool    server_dialog;
 } vc_client_info_s;
 
 
index 771f32693d27158451b2826c927c504efb9e6992..d9c6fc9e8a1e29846155dd540858fe36a3e2edf3 100644 (file)
  * <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>
index 6c01165dcfef3c4f9215fa1e46c2f7e84ed06ac0..e81a1fd53f6204c9e998b2b9cc71b9fd9239a679 100644 (file)
  * <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>
index d37ffbecfaaf8d90740d7c15711e2cd61be5d015..c735acdb7373b94d9c2ae7cddf77b3ae84d9b017 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef __VCE_H__
 #define __VCE_H__
 
+#include <tizen.h>
 
 /**
 * @addtogroup CAPI_UIX_VOICE_CONTROL_ENGINE_MODULE
@@ -100,6 +101,27 @@ typedef enum {
     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
@@ -372,6 +394,19 @@ typedef int (*vce_cancel_cb)(void);
 */
 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
@@ -395,6 +430,26 @@ typedef int (*vce_set_domain_cb)(const char* domain);
 */
 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
@@ -519,11 +574,18 @@ typedef struct {
        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;
 
 /**
@@ -692,6 +754,24 @@ int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, vo
 */
 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
@@ -770,6 +850,36 @@ int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_fun
 */
 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
@@ -879,6 +989,32 @@ int vce_start_recording(void);
 */
 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
index 9dfe6e00aa1d0b6d7e29fa1192f5dbdc573a533f..f46b5c06d9a6b60519b319677d49ffd8a2ca55df 100644 (file)
@@ -288,6 +288,49 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list);
 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.
index b979562373c2a4cbdac1251c3440ecdf071983cb..5ae1ffa712e64477934e7f36894adbe1f6433efb 100644 (file)
@@ -93,6 +93,35 @@ typedef enum {
        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.
index cdd8af306a878624ec4b47af452bef3fd25cba41..a1aab2bcc04c1b9ea18597a5d27733371c68ad24 100644 (file)
@@ -163,6 +163,22 @@ typedef bool (*vc_mgr_all_result_cb)(vc_result_event_e event, vc_cmd_list_h vc_c
  */
 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
@@ -230,6 +246,38 @@ typedef int (*vc_mgr_private_data_set_cb)(const char *key, const char *data, voi
  */
 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.
@@ -744,6 +792,23 @@ int vc_mgr_get_private_data(const char *key, char **data);
  */
 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.
@@ -974,6 +1039,42 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void *user_data);
  */
 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.
@@ -1451,6 +1552,107 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba
  */
 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
index 4ae7bb33f8068fbec8690efe08986b8619f61cf3..6953e17cdb223c9f6809a031434d816b7558b804 100644 (file)
@@ -769,6 +769,38 @@ vcd_recognition_mode_e vcd_client_get_recognition_mode()
        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;
@@ -998,6 +1030,7 @@ int vcd_client_add(int pid)
        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);
index 3ee5f0d2a8029f7169c52677105a22c3c9f7a796..6060c818549c53697f43d2c68ca368de2c5f0324 100644 (file)
@@ -155,6 +155,11 @@ int vcd_client_unset_exclusive_command(int pid);
 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
 */
old mode 100755 (executable)
new mode 100644 (file)
index 250e5a0..5b3d4ee
@@ -405,6 +405,42 @@ int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_
        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()) {
@@ -902,6 +938,90 @@ int vcdc_send_request_get_private_data(int pid, const char* key, char** data)
        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;
@@ -970,12 +1090,21 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                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);
@@ -995,6 +1124,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                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);
 
index d4674ecd88f018428d2a128c9742de5e7fd857c6..0dbe18876220ea4320f408d010325497ed1fef6f 100644 (file)
@@ -48,6 +48,8 @@ int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_typ
 
 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);
@@ -66,6 +68,12 @@ int vcdc_send_request_set_private_data(int pid, const char* key, const char* dat
 
 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
old mode 100755 (executable)
new mode 100644 (file)
index 6a6a15d..297ef13
@@ -620,6 +620,39 @@ int vcd_dbus_server_mgr_get_private_data(DBusConnection* conn, DBusMessage* msg)
        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;
@@ -630,7 +663,7 @@ int vcd_dbus_server_mgr_set_domain(DBusConnection* conn, DBusMessage* msg)
 
        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,
@@ -1033,6 +1066,114 @@ int vcd_dbus_server_mgr_result_selection(DBusConnection* conn, DBusMessage* msg)
        */
 }
 
+/* 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
 */
@@ -1330,6 +1471,64 @@ int vcd_dbus_server_set_foreground(DBusConnection* conn, DBusMessage* msg)
        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;
index caa87dff99ef5459d40f04b8f03d1f5550f816fe..145653636ad200d2d6dcaf6c491c773426248133 100644 (file)
@@ -67,6 +67,14 @@ int vcd_dbus_server_mgr_enable_command_type(DBusConnection* conn, DBusMessage* m
 
 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
 */
@@ -85,6 +93,8 @@ int vcd_dbus_server_unset_command(DBusConnection* conn, DBusMessage* msg);
 
 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);
index bd3eceaf8cdbcc1f16477a1295a55976eab667ae..da793464e3795ce2129257741755c3070a6f7121 100644 (file)
@@ -42,7 +42,7 @@ typedef struct {
        bool    use_network;
        void    *handle;
 
-       vc_engine_callback_s* callbacks;
+       vce_request_callback_s* callbacks;
 } vcengine_s;
 
 typedef struct _vcengine_info {
@@ -94,7 +94,7 @@ int vcd_engine_agent_init()
        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;
@@ -186,7 +186,7 @@ int __internal_get_engine_info(vce_request_callback_s* callback)
                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;
@@ -208,6 +208,7 @@ int __internal_get_engine_info(vce_request_callback_s* callback)
        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;
@@ -215,6 +216,7 @@ int __internal_get_engine_info(vce_request_callback_s* callback)
        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);
@@ -266,6 +268,7 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback)
                        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 ||
@@ -472,6 +475,25 @@ int vcd_engine_set_audio_type(const char* audio)
        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) {
@@ -567,6 +589,28 @@ int vcd_engine_get_private_data(int pid, const char* key, char** data)
        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) {
@@ -844,3 +888,19 @@ int vcd_engine_agent_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_
        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;
+}
index a327584aff9de021ff1cef6b57ef44aca23b42d3..4dc5e25fb42c37040eacf909de1f873917cacc86 100644 (file)
@@ -66,6 +66,8 @@ int vcd_engine_recognize_cancel();
 
 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);
@@ -74,6 +76,8 @@ int vcd_engine_set_private_data(int pid, const char* key, const char* data);
 
 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);
@@ -101,6 +105,7 @@ int vcd_engine_agent_set_private_data_requested_cb(vce_private_data_requested_cb
 
 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
 }
index 72e105c68ac971f0e07f643862e3437b10ddc601..a9f794389057a294c61dc564035773835a3bafcd 100644 (file)
@@ -32,6 +32,8 @@
 #include "vc_defs.h"
 
 #include "vce.h"
+#include "voice_control_common.h"
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -76,43 +78,6 @@ typedef struct {
        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
 }
index ef9dc764b5728c0fd3e66c870c13cf427dc42a0e..d5bf69b52ad408dace0cb74617ee43e7988afc1f 100644 (file)
@@ -445,6 +445,21 @@ int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, vo
        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();
@@ -1078,6 +1093,36 @@ int vcd_send_error(vce_error_e error, const char* msg, void *user_data)
        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
 */
@@ -1991,6 +2036,30 @@ int vcd_server_mgr_get_private_data(int pid, const char* key, char** data)
        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;
@@ -2078,6 +2147,40 @@ int vcd_server_mgr_disable_command_type(int pid, int cmd_type)
        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
 */
@@ -2225,26 +2328,66 @@ static int __vcd_server_launch_manager_app()
        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;
 }
 
@@ -2742,3 +2885,15 @@ int vcd_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_f
 
        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;
+}
index 70bc3d9c21316b7c0c3aace02c87021c683cdce7..e11108f91fb9a733869fe3dcdb14feb28af3590d 100644 (file)
@@ -80,6 +80,12 @@ int vcd_server_mgr_enable_command_type(int pid, int cmd_type);
 
 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
 */
@@ -93,6 +99,8 @@ int vcd_server_unset_command(int pid, vc_cmd_type_e cmd_type);
 
 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);
@@ -126,6 +134,8 @@ int vcd_server_widget_enable_asr_result(int pid, bool enable);
 
 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
 */
@@ -133,6 +143,8 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c
 
 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);
@@ -157,6 +169,12 @@ int vcd_set_private_data_requested_cb(vce_private_data_requested_cb callback_fun
 
 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
 }
index cbb21fa5b27675e78ef100b42849e46a1737ef4b..087cee8fb8476a839e8aca1cafc88342dbb2dfb7 100644 (file)
@@ -221,6 +221,29 @@ int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, vo
        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;
@@ -449,3 +472,53 @@ int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_f
 
        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;
+}