Fix tizen version description (7.5 -> 8.0)
[platform/core/uifw/tts.git] / include / tts_internal.h
1 /*
2    * Copyright (c) 2011-2016 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 __TTS_INTERNAL_H__
19 #define __TTS_INTERNAL_H__
20
21 #include <tizen.h>
22 #include <tts.h>
23
24
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29
30
31 /**
32  * @brief Enumration for playing mode of TTS.
33  * @since_tizen 8.0
34 */
35 typedef enum {
36         TTS_PLAYING_MODE_BY_SERVICE = 0, /**< Mode for TTS playing on TTS service */
37         TTS_PLAYING_MODE_BY_CLIENT = 1, /**< Mode for TTS playing on TTS client */
38 } tts_playing_mode_e;
39
40
41 /**
42  * @brief Enumeration for synthesized pcm event.
43  * @since_tizen 8.0
44 */
45 typedef enum {
46         TTS_SYNTHESIZED_PCM_EVENT_FAIL = -1, /**< 'Error' event */
47         TTS_SYNTHESIZED_PCM_EVENT_START, /**< 'Started' event */
48         TTS_SYNTHESIZED_PCM_EVENT_CONTINUE, /**< 'Finished' event */
49         TTS_SYNTHESIZED_PCM_EVENT_FINISH, /**< 'Finished' event */
50 } tts_synthesized_pcm_event_e;
51
52
53 /**
54  * @brief Definition for TTS interrupt mode
55  */
56 #define TTS_MODE_INTERRUPT              3
57
58
59 /**
60  * @brief Called when the synthesized pcm data is come from the engine.
61  * @since_tizen 8.0
62  * @remarks The @a tts handle should not be destroyed in the callback.
63  * @param[in] tts The TTS handle, the same handle for which the callback was set.
64  * @param[in] event The event type
65  * @param[in] buffer The synthesized pcm data
66  * @param[in] buffer_size The size of the buffer
67  * @param[in] user_data The user data passed from the callback registration function
68  * @pre An application registers this callback using tts_set_synthesized_pcm_cb() to get pcm data.
69  * @see tts_set_synthesized_pcm_cb()
70  * @see tts_unset_synthesized_pcm_cb()
71  */
72 typedef void (*tts_synthesized_pcm_cb)(tts_h tts, tts_synthesized_pcm_event_e event, char* buffer, int buffer_size, void *user_data);
73
74
75 /**
76  * @brief Sets server tts.
77  * @details Using this API, the application can ask server tts with a credential.
78  *  The credential is a key to verify the authorization about using the engine based on server, not embedded engine.
79  *  If the application sets the credential, it will be able to use functions of the server engine entirely.
80  * @since_tizen @if MOBILE 3.0
81  *
82  * @remarks The necessity of the credential depends on the engine. In case of the engine which is basically embedded in Tizen, the credential is not necessary so far.
83  *  However, if the user wants to apply the 3rd party's engine, the credential may be necessary. In that case, please follow the policy provided by the corresponding engine.
84  *
85  * @param[in] tts The TTS handle
86  * @param[in] credential The credential
87  *
88  * @return 0 on success, otherwise a negative error value
89  * @retval #TTS_ERROR_NONE Success
90  * @retval #TTS_ERROR_INVALID_STATE Invalid state
91  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
92  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
93  * @retval #TTS_ERROR_OUT_OF_MEMORY TTS Out of memory
94  *
95  * @pre The state should be #TTS_STATE_CREATED or #TTS_STATE_READY.
96  *
97  * @see tts_play()
98 */
99 int tts_set_server_tts(tts_h tts, const char* credential);
100
101 /**
102  * @brief Adds a sound stream to the queue.
103  * @since_tizen 4.0
104  *
105  * @param[in] tts The TTS handle
106  * @param[in] event An event about pcm buffer (-1: error, 1: start, 2: continue, 3: finish)
107  * @param[in] data The pcm data buffer
108  * @param[in] data_size The data size of pcm data buffer
109  * @param[in] audio_type The audio type of pcm (0: signed 16-bit, 1: unsigned 8-bit)
110  * @param[in] rate The sampling rate of pcm
111  * @return @c 0 on success,
112  *         otherwise a negative error value
113  * @retval #TTS_ERROR_NONE Successful
114  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
115  * @retval #TTS_ERROR_INVALID_STATE Invalid state
116  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
117  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
118  * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
119  * @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING, or #TTS_STATE_PAUSED.
120  * @see tts_play_pcm()
121  * @see tts_stop_pcm()
122 */
123 int tts_add_pcm(tts_h tts, int event, const void* data, unsigned int data_size, int audio_type, int rate);
124
125 /**
126  * @brief Request to play pcm.
127  * @since_tizen 4.0
128  *
129  * @param[in] tts The TTS handle
130  * @return @c 0 on success,
131  *         otherwise a negative error value
132  * @retval #TTS_ERROR_NONE Successful
133  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
134  * @retval #TTS_ERROR_INVALID_STATE Invalid state
135  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
136  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
137  * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
138  * @pre The state should be #TTS_STATE_READY or #TTS_STATE_PAUSED.
139  * @see tts_add_pcm()
140  * @see tts_stop_pcm()
141 */
142 int tts_play_pcm(tts_h tts);
143
144 /**
145  * @brief Request to stop pcm.
146  * @since_tizen 4.0
147  *
148  * @param[in] tts The TTS handle
149  * @return @c 0 on success,
150  *         otherwise a negative error value
151  * @retval #TTS_ERROR_NONE Successful
152  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
153  * @retval #TTS_ERROR_INVALID_STATE Invalid state
154  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
155  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
156  * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
157  * @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING, or #TTS_STATE_PAUSED.
158  * @see tts_play_pcm()
159  * @see tts_add_pcm()
160 */
161 int tts_stop_pcm(tts_h tts);
162
163
164 /**
165  * @brief Sets the TTS playing mode.
166  * @since_tizen 8.0
167  * @param[in] tts The TTS handle
168  * @param[in] mode The mode
169  * @return @c 0 on success,
170  *         otherwise a negative error value
171  * @retval #TTS_ERROR_NONE Successful
172  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
173  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
174  * @retval #TTS_ERROR_INVALID_STATE Invalid state
175  * @pre The state should be #TTS_STATE_CREATED.
176  * @see tts_get_playing_mode()
177  * @see tts_play()
178  */
179 int tts_set_playing_mode(tts_h tts, tts_playing_mode_e mode);
180
181
182 /**
183  * @brief Sets the default to be called when the synthesized pcm data is recieved.
184  * @since_tizen 8.0
185  * @param[in] tts The TTS handle
186  * @param callback The callback function to register
187  * @param user_data The user data to be passed to the callback function
188  * @return @c 0 on success,
189  *                 otherwise a negative error value
190  * @retval #TTS_ERROR_NONE Successful
191  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
192  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
193  * @retval #TTS_ERROR_INVALID_STATE Invalid state
194  * @pre The TTS state should be #TTS_STATE_CREATED.
195  * @see tts_synthesized_pcm_cb()
196  * @see tts_unset_synthesized_pcm_cb()
197  */
198 int tts_set_synthesized_pcm_cb(tts_h tts, tts_synthesized_pcm_cb callback, void* user_data);
199
200
201 /**
202  * @brief Unsets the callback function.
203  * @since_tizen 8.0
204  * @param tts The TTS handle
205  * @return @c 0 on success,
206  *                 otherwise a negative error value
207  * @retval #TTS_ERROR_NONE Successful
208  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
209  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
210  * @retval #TTS_ERROR_INVALID_STATE Invalid state
211  * @pre The TTS state should be #TTS_STATE_CREATED.
212  * @see tts_set_synthesized_pcm_cb()
213   */
214 int tts_unset_synthesized_pcm_cb(tts_h tts);
215
216
217
218 #ifdef __cplusplus
219 }
220 #endif
221
222 /**
223  * @}
224  */
225
226 #endif /* __TTS_INTERNAL_H__ */