2 * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "vcd_server.h"
25 int vce_main(int argc, char** argv, vce_request_callback_s *callback)
27 SLOG(LOG_DEBUG, TAG_VCD, " ");
28 SLOG(LOG_DEBUG, TAG_VCD, " ");
29 SLOG(LOG_DEBUG, TAG_VCD, "===== VC Engine Service Initialize");
31 int ret = VCE_ERROR_NONE;
34 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()");
35 return VCE_ERROR_OPERATION_FAILED;
38 if (0 != vcd_dbus_open_connection()) {
39 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection");
41 return VCE_ERROR_OPERATION_FAILED;
44 ret = vcd_initialize(callback);
46 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize");
47 vcd_dbus_close_connection();
52 SLOG(LOG_DEBUG, TAG_VCD, "[Main] VC Engine Service start...");
54 SLOG(LOG_DEBUG, TAG_VCD, "=====");
55 SLOG(LOG_DEBUG, TAG_VCD, " ");
56 SLOG(LOG_DEBUG, TAG_VCD, " ");
61 int vce_send_result(vce_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, void *user_data)
63 int ret = VCE_ERROR_NONE;
65 if (NULL == all_result || NULL == non_fixed_result || NULL == nlu_result) {
66 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
69 ret = vcd_send_result(event, result_id, count, all_result, non_fixed_result, nlu_result, msg, user_data);
71 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send result");
73 SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send result");
80 int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
82 int ret = VCE_ERROR_NONE;
84 if (NULL == asr_result) {
85 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
88 ret = vcd_send_asr_result(event, asr_result, user_data);
90 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send ASR result");
92 SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send ASR result");
98 int vce_send_nlg_result(const char* nlg_result, void *user_data)
100 int ret = VCE_ERROR_NONE;
102 if (NULL == nlg_result) {
103 SLOG(LOG_ERROR, TAG_VCD, "[INFO] Input parameter is NULL. (no result)");
106 ret = vcd_send_nlg_result(nlg_result, user_data);
108 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send NLG result");
110 SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to send NLG result");
116 int vce_send_error(vce_error_e error, const char* msg, void *user_data)
118 int ret = VCE_ERROR_NONE;
121 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Input parameter is NULL. (no error message)");
124 ret = vcd_send_error(error, msg, user_data);
127 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send error");
135 int vce_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data)
137 int ret = VCE_ERROR_NONE;
139 ret = vcd_get_foreach_command(vce_command, callback, user_data);
141 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get foreach command");
147 int vce_get_command_count(vce_cmd_h vce_command)
149 int ret = VCE_ERROR_NONE;
151 ret = vcd_get_command_count(vce_command);
153 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get command count");
159 int vce_get_audio_type(char** audio_type)
161 int ret = VCE_ERROR_NONE;
163 ret = vcd_get_audio_type(audio_type);
165 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get audio type");
171 int vce_set_private_data(const char* key, const char* data)
173 int ret = VCE_ERROR_NONE;
175 ret = vcd_set_private_data(key, data);
177 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data to vc manager");
183 int vce_get_private_data(const char* key, char** data)
185 int ret = VCE_ERROR_NONE;
187 ret = vcd_get_private_data(key, data);
189 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get private data from vc manager");
195 int vce_start_recording()
197 int ret = VCE_ERROR_NONE;
199 ret = vcd_start_recording();
201 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to start recording");
207 int vce_stop_recording()
209 int ret = VCE_ERROR_NONE;
211 ret = vcd_stop_recording();
213 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to stop recording");
219 int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func)
221 if (NULL == callback_func) {
222 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
223 return VCE_ERROR_INVALID_PARAMETER;
226 int ret = vcd_set_private_data_set_cb(callback_func);
228 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data set cb");
234 int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
236 if (NULL == callback_func) {
237 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
238 return VCE_ERROR_INVALID_PARAMETER;
241 int ret = vcd_set_private_data_requested_cb(callback_func);
243 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data requested cb");
249 int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func)
251 if (NULL == callback_func) {
252 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter");
253 return VCE_ERROR_INVALID_PARAMETER;
256 int ret = vcd_set_nlu_base_info_requested_cb(callback_func);
258 SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set nlu-base info requested cb");