Add parameter to change system volume
[platform/core/uifw/voice-control.git] / include / voice_control_internal.h
1 /**
2  * Copyright (c) 2011-2018 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18 #ifndef __VOICE_CONTROL_INTERNAL_H__
19 #define __VOICE_CONTROL_INTERNAL_H__
20
21 #include <tizen.h>
22
23
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28
29 typedef enum {
30         VC_TTS_EVENT_FAIL = -1,    /**< Failed */
31         VC_TTS_EVENT_START = 1,    /**< Start event */
32         VC_TTS_EVENT_CONTINUE = 2, /**< Continue event */
33         VC_TTS_EVENT_FINISH = 3    /**< Finish event */
34 } vc_tts_event_e;
35
36 typedef enum {
37         VC_TTS_UTTERANCE_NONE = -1,
38         VC_TTS_UTTERANCE_STARTED = 1,
39         VC_TTS_UTTERANCE_COMPLETED = 2,
40         VC_TTS_UTTERANCE_CANCELED = 3
41 } vc_tts_utterance_status_e;
42
43
44 /**
45  * @brief Called when client gets the asr recognition result from vc-daemon.
46  *
47  * @param[in] event The result event
48  * @param[in] result ASR text
49  * @param[in] user_data The user data passed from the callback registration function
50  *
51  * @return @c true when asr result is consumed \n @c false to propagate.
52  *
53  * @pre An application registers callback function using vc_mgr_set_pre_result_cb().
54  *
55  * @see vc_widget_set_asr_result_cb()
56  * @see vc_widget_unset_asr_result_cb()
57  */
58 typedef bool (*vc_asr_result_cb)(vc_result_event_e event, const char* result, void *user_data);
59
60 /**
61  * @brief Called when client gets TTS streaming data from vc engine service.
62  * @since_tizen 4.0
63  *
64  * @param[in] event The TTS event
65  * @param[in] buffer The TTS streaming data
66  * @param[in] len The length of the TTS streaming data
67  * @param[in] utt_id The utterance id
68  * @param[in] user_data The user data passed from the callback registration function
69  *
70  * @pre An application registers callback function using vc_tts_set_streaming_cb().
71  *
72  * @see vc_tts_set_streaming_cb()
73  * @see vc_tts_unset_streaming_cb()
74  */
75 typedef void (*vc_tts_streaming_cb)(vc_tts_event_e event, char* buffer, int len, int utt_id, void *user_data);
76
77 /**
78  * @brief Called when client gets TTS utterance status.
79  * @since_tizen 4.0
80  *
81  * @param[in] utt_id The utterance id
82  * @param[in] status The TTS utterance status (e.g. #VC_TTS_UTTERANCE_STARTED, #VC_TTS_UTTERANCE_COMPLETED, and so on)
83  *
84  * @pre An application registers callback function using vc_tts_set_utterance_status_cb().
85  *
86  * @see vc_tts_set_utterance_status_cb()
87  * @see vc_tts_unset_utterance_status_cb()
88  */
89 typedef void (*vc_tts_utterance_status_cb)(int utt_id, vc_tts_utterance_status_e  status);
90
91 /**
92  * @brief Sets command list from file.
93  * @since_tizen 3.0
94  * @privlevel public
95  * @privilege %http://tizen.org/privilege/recorder
96  *
97  * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND and #VC_COMMAND_TYPE_BACKGROUND.
98  * Therefore, @a type is either #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND.
99  * In the file corresponding to @a file_path, there must be commands and command types.
100  *
101  * @param[in] file_path The command file path (absolute or relative)
102  * @param[in] type Command type
103  *
104  * @return 0 on success, otherwise a negative error value
105  * @retval #VC_ERROR_NONE Successful
106  * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
107  * @retval #VC_ERROR_INVALID_STATE Invalid state
108  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
109  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
110  *
111  * @pre The state should be #VC_STATE_READY.
112  *
113  * @see vc_unset_command_list()
114  */
115 int vc_set_command_list_from_file(const char* file_path, int type);
116
117 /**
118  * @brief Connects the voice control service synchronously.
119  * @since_tizen 4.0
120  * @privlevel public
121  * @privilege %http://tizen.org/privilege/recorder
122  * @return @c 0 on success,
123  *         otherwise a negative error value
124  * @retval #VC_ERROR_NONE Successful
125  * @retval #VC_ERROR_INVALID_STATE Invalid state
126  * @retval #VC_ERROR_OPERATION_FAILED Operation failure
127  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
128  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
129  * @pre The state should be #VC_STATE_INITIALIZED.
130  * @post If this function is called, the state will be #VC_STATE_READY.
131  * @see vc_unprepare()
132  */
133 int vc_prepare_sync(void);
134
135 /**
136  * @brief Requests to send TTS streaming data.
137  * @since_tizen 4.0
138  *
139  * @param[in] text The text to be requested for TTS
140  * @param[in] language The language for TTS
141  * @param[in] to_vcm A value whether the TTS request is from vc client or vc manager
142  * @param[in] utt_id The utterance id
143  *
144  * @return 0 on success, otherwise a negative error value
145  * @retval #VC_ERROR_NONE Successful
146  * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
147  * @retval #VC_ERROR_INVALID_STATE Invalid state
148  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
149  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
150  *
151  * @pre The state should be #VC_STATE_READY.
152  *
153  * @see vc_tts_cancel()
154  */
155 int vc_tts_request(const char* text, const char* language, bool to_vcm, int* utt_id);
156
157 /**
158  * @brief Requests to cancel TTS streaming data.
159  * @since_tizen 4.0
160  *
161  * @param[in] utt_id The utterance id
162  *
163  * @return 0 on success, otherwise a negative error value
164  * @retval #VC_ERROR_NONE Successful
165  * @retval #VC_ERROR_INVALID_STATE Invalid state
166  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
167  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
168  *
169  * @pre The state should be #VC_STATE_READY.
170  *
171  * @see vc_tts_request()
172  */
173 int vc_tts_cancel(int utt_id);
174
175 /**
176  * @brief Gets TTS audio format.
177  * @since_tizen 4.0
178  *
179  * @param[out] rate The audio sampling rate
180  * @param[out] channel The audio channel
181  * @param[out] audio_type The audio type
182  *
183  * @return 0 on success, otherwise a negative error value
184  * @retval #VC_ERROR_NONE Successful
185  * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
186  * @retval #VC_ERROR_INVALID_STATE Invalid state
187  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
188  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
189  *
190  * @pre The state should be #VC_STATE_READY.
191  */
192 int vc_tts_get_audio_format(int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type);
193
194 /**
195  * @brief Sets TTS streaming callback function.
196  * @since_tizen 4.0
197  *
198  * @param[in] callback The callback function
199  * @param[in] user_data The user data to be passed to the callback function
200  *
201  * @return 0 on success, otherwise a negative error value
202  * @retval #VC_ERROR_NONE Successful
203  * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
204  * @retval #VC_ERROR_INVALID_STATE Invalid state
205  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
206  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
207  *
208  * @pre The state should be #VC_STATE_INITIALIZED.
209  */
210 int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data);
211
212 /**
213  * @brief Unsets TTS streaming callback function.
214  * @since_tizen 4.0
215  *
216  * @return 0 on success, otherwise a negative error value
217  * @retval #VC_ERROR_NONE Successful
218  * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
219  * @retval #VC_ERROR_INVALID_STATE Invalid state
220  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
221  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
222  *
223  * @pre The state should be #VC_STATE_INITIALIZED.
224  */
225 int vc_tts_unset_streaming_cb(void);
226
227 /**
228  * @brief Sets TTS utterance status callback function.
229  * @since_tizen 4.0
230  *
231  * @param[in] callback The callback function
232  * @param[in] user_data The user data to be passed to the callback function
233  *
234  * @return 0 on success, otherwise a negative error value
235  * @retval #VC_ERROR_NONE Successful
236  * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
237  * @retval #VC_ERROR_INVALID_STATE Invalid state
238  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
239  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
240  *
241  * @pre The state should be #VC_STATE_INITIALIZED.
242  */
243 int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data);
244
245 /**
246  * @brief Unsets TTS utterance status callback function.
247  * @since_tizen 4.0
248  *
249  * @return 0 on success, otherwise a negative error value
250  * @retval #VC_ERROR_NONE Successful
251  * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
252  * @retval #VC_ERROR_INVALID_STATE Invalid state
253  * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
254  * @retval #VC_ERROR_NOT_SUPPORTED Not supported
255  *
256  * @pre The state should be #VC_STATE_INITIALIZED.
257  */
258 int vc_tts_unset_utterance_status_cb(void);
259
260
261 #ifdef __cplusplus
262 }
263 #endif
264
265 /**
266  * @}
267  */
268
269 #endif /* __VOICE_CONTROL_INTERNAL_H__ */