2 * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
15 #include "ttsd_main.h"
16 #include "ttsd_server.h"
17 #include "ttsd_dbus.h"
18 #include "ttsd_network.h"
21 #include <bundle_internal.h>
27 static ttsd_mode_e g_tts_mode = TTSD_MODE_DEFAULT;
31 if (TTSD_MODE_NOTIFICATION == g_tts_mode) {
33 } else if (TTSD_MODE_SCREEN_READER == g_tts_mode) {
40 ttsd_mode_e ttsd_get_mode()
45 void ttsd_set_mode(ttsd_mode_e mode)
51 int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
54 ttsd_mode_e mode = TTSD_MODE_DEFAULT;
55 int ret = TTSE_ERROR_NONE;
57 b = bundle_import_from_argv(argc, argv);
60 if (0 == bundle_get_str(b, "mode", &val)) {
62 if (!strcmp("noti", val)) {
63 mode = TTSD_MODE_NOTIFICATION;
64 } else if (!strcmp("sr", val)) {
65 mode = TTSD_MODE_SCREEN_READER;
67 SLOG(LOG_WARN, tts_tag(), "[WARNING] mode (%s)", val);
70 SLOG(LOG_ERROR, tts_tag(), "[ERROR] NULL data");
73 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get data from bundle");
78 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get bundle");
83 SLOG(LOG_DEBUG, tts_tag(), "Start engine as [%d] mode", mode);
86 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to initialize Ecore");
87 return TTSE_ERROR_OPERATION_FAILED;
90 if (0 != ttsd_dbus_open_connection()) {
91 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open dbus connection");
93 return TTSE_ERROR_OPERATION_FAILED;
96 ret = ttsd_initialize(callback);
98 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to initialize");
99 ttsd_dbus_close_connection();
104 if (0 != ttsd_network_initialize()) {
105 SLOG(LOG_WARN, tts_tag(), "[WARNING] Fail to initialize network");
108 SLOG(LOG_DEBUG, tts_tag(), "@@@");
110 return TTSE_ERROR_NONE;
113 int ttse_get_speed_range(int* min, int* normal, int* max)
115 if (NULL == min || NULL == normal || NULL == max) {
116 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
117 return TTSE_ERROR_INVALID_PARAMETER;
120 *min = TTS_SPEED_MIN;
121 *normal = TTS_SPEED_NORMAL;
122 *max = TTS_SPEED_MAX;
127 int ttse_get_pitch_range(int* min, int* normal, int* max)
129 if (NULL == min || NULL == normal || NULL == max) {
130 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
131 return TTSE_ERROR_INVALID_PARAMETER;
134 *min = TTS_PITCH_MIN;
135 *normal = TTS_PITCH_NORMAL;
136 *max = TTS_PITCH_MAX;
141 int ttse_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data)
146 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Input parameter is null");
149 ret = ttsd_send_result(event, data, data_size, audio_type, rate, user_data);
152 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to send result");
158 int ttse_send_error(ttse_error_e error, const char* msg)
162 ret = ttsd_send_error(error, msg);
165 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to send error");
171 int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func)
173 if (NULL == callback_func) {
174 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
175 return TTSE_ERROR_INVALID_PARAMETER;
178 int ret = ttsd_set_private_data_set_cb(callback_func);
181 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set private data set cb");
187 int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_func)
189 if (NULL == callback_func) {
190 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
191 return TTSE_ERROR_INVALID_PARAMETER;
194 int ret = ttsd_set_private_data_requested_cb(callback_func);
197 SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set private data requested cb");