Change a logic for changing system volume using ducking APIs
[platform/core/uifw/stt.git] / include / stt_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 #ifndef __STT_INTERNAL_H__
18 #define __STT_INTERNAL_H__
19
20 #include <tizen.h>
21 #include <stt.h>
22
23 /**
24  * @file stt_internal.h
25  */
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32
33 /**
34 * @brief Enumerations of audio type.
35 */
36 typedef enum {
37         STT_AUDIO_TYPE_RAW_S16 = 0,     /**< Signed 16-bit audio sample */
38         STT_AUDIO_TYPE_RAW_U8,          /**< Unsigned 8-bit audio sample */
39 } stt_audio_type_e;
40
41 /**
42 * @brief Enumerations of system volume event.
43 */
44 typedef enum {
45         STT_SYSTEM_VOLUME_EVENT_CHANGE_FOR_NEARFIELD,   /**< Change system volume event for nearfield */
46         STT_SYSTEM_VOLUME_EVENT_CHANGE_FOR_FARFIELD,    /**< Change system volume event for farfield */
47         STT_SYSTEM_VOLUME_EVENT_RECOVER                                 /**< Recover system volume event */
48 } stt_system_volume_event_e;
49
50 /**
51  * @brief Sets server STT.
52  * @details Using this API, the application can set server STT with a @a key as a @a user_data
53  *      The key is a private data to set STT server.
54  *      There are 3 types of keys; "server", "rampcode" and "epd".
55  *              "server": STT server address
56  *              "rampcode": ASR ramp code
57  *              "epd": A threshold for end-point detection
58  *
59  *      The application can input the @a user_data corresponding to the @a key.
60  *              "server": "qa", "sbx"
61  *              "rampcode": "dash_dict", "dash_da"
62  *              "epd": "100", "750", etc
63  *
64  *  If the application sets those keys, it will be able to use corresponding STT engines and options.
65  *
66  * @since_tizen 3.0
67  * @privilege %http://tizen.org/privilege/recorder
68  *
69  * @param[in] stt The STT handle
70  * @param[in] key The key
71  * @param[in] user_data The user data corresponding to the key
72  *
73  * @return 0 on success, otherwise a negative error value
74  * @retval #STT_ERROR_NONE Successful
75  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
76  * @retval #STT_ERROR_INVALID_STATE Invalid state
77  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
78  * @retval #STT_ERROR_OUT_OF_MEMORY STT Out of memory
79  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
80  *
81  * @pre The state should be #STT_STATE_READY.
82  */
83 int stt_set_server_stt(stt_h stt, const char* key, char* user_data);
84
85 /**
86  * @brief Starts file recognition asynchronously.
87  * @privlevel public
88  * @privilege %http://tizen.org/privilege/recorder
89  * @remarks This function starts sending recorded data from file to engine.
90  * @param[in] stt The STT handle
91  * @param[in] language The language selected from stt_foreach_supported_languages()
92  * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
93  * @param[in] filepath PCM filepath for recognition
94  * @param[in] audio_type audio type of file
95  * @param[in] sample_rate sample rate of file
96  * @return @c 0 on success,
97  *         otherwise a negative error value
98  * @retval #STT_ERROR_NONE Successful
99  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
100  * @retval #STT_ERROR_INVALID_STATE Invalid state
101  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
102  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
103  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
104  * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
105  * @pre The state should be #STT_STATE_READY.
106  * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
107  *       If this function succeeds, the STT state will be #STT_STATE_RECORDING.
108  *       If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_RECORDING.
109  * @see stt_cancel_file()
110  * @see stt_state_changed_cb()
111 */
112 int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath, stt_audio_type_e audio_type, int sample_rate);
113
114 /**
115  * @brief Cancels processing file recognition asynchronously.
116  * @privlevel public
117  * @privilege %http://tizen.org/privilege/recorder
118  * @remarks This function cancels recording and engine cancels recognition processing.
119  *          After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
120  * @param[in] stt The STT handle
121  * @return @c 0 on success,
122  *         otherwise a negative error value
123  * @retval #STT_ERROR_NONE Successful
124  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
125  * @retval #STT_ERROR_INVALID_STATE Invalid state
126  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
127  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
128  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
129  * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished
130  * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
131  * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished
132  * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
133  * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
134  *       If this function succeeds, the STT state will be #STT_STATE_READY.
135  *       If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_READY.
136  * @see stt_start_file()
137  * @see stt_state_changed_cb()
138 */
139 int stt_cancel_file(stt_h stt);
140
141 /**
142  * @brief Changes system volume with event.
143  * @since_tizen 5.5
144  * @privlevel public
145  * @privilege %http://tizen.org/privilege/recorder
146  * @privilege %http://tizen.org/privilege/volume.set
147  * @remarks If @a volume_event is STT_SYSTEM_VOLUME_EVENT_CHANGE_FOR_NEARFIELD, the background volume will be reduced by 70 percentage.
148  *          And, if @a volume_event is STT_SYSTEM_VOLUME_EVENT_CHANGE_FOR_FARFIELD, the background volume will be mute.
149  * @param[in] stt The STT handle
150  * @param[in] volume_event System volume event
151  * @return @c 0 on success,
152  *         otherwise a negative error value
153  * @retval #STT_ERROR_NONE Successful
154  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
155  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
156  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
157  * @retval #STT_ERROR_INVALID_STATE Invalid state
158  * @retval #STT_ERROR_OPERATION_FAILED STT Operation failure
159  * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY.
160  * @see stt_recover_system_volume()
161 */
162 int stt_change_system_volume(stt_h stt, stt_system_volume_event_e volume_event);
163
164 /**
165  * @brief Recovers system volume.
166  * @since_tizen 5.5
167  * @privlevel public
168  * @privilege %http://tizen.org/privilege/recorder
169  * @privilege %http://tizen.org/privilege/volume.set
170  * @param[in] stt The STT handle
171  * @param[in] volume_event System volume event
172  * @return @c 0 on success,
173  *         otherwise a negative error value
174  * @retval #STT_ERROR_NONE Successful
175  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
176  * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
177  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
178  * @retval #STT_ERROR_INVALID_STATE Invalid state
179  * @retval #STT_ERROR_OPERATION_FAILED STT Operation failure
180  * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY.
181  * @see stt_recover_system_volume()
182 */
183 int stt_recover_system_volume(stt_h stt);
184
185 #ifdef __cplusplus
186 }
187 #endif
188
189 /**
190  * @}
191  */
192
193 #endif /* __STT_INTERNAL_H__ */
194