Rollback changes to submit TIZEN:COMMON project
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-telephony-api.h
1 /*
2  * bluetooth-frwk
3  *
4  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *              http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef _BLUETOOTH_TELEPHONY_API_H_
21 #define _BLUETOOTH_TELEPHONY_API_H_
22
23 #include <stdint.h>
24 #include <glib.h>
25 #include <dbus/dbus-glib.h>
26 #include <dbus/dbus-glib-lowlevel.h>
27 #include <dlog.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /*__cplusplus*/
32
33 typedef void (*bt_telephony_func_ptr)(int, void *, void *);
34
35 #define BLUETOOTH_TELEPHONY_ERROR_NONE ((int)0)
36 #define BLUETOOTH_TELEPHONY_ERROR_INTERNAL \
37                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x01)
38 #define BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM \
39                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x02)
40 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_INITIALIZED \
41                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x03)
42 #define BLUETOOTH_TELEPHONY_ERROR_NOT_INITIALIZED \
43                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x04)
44 #define BLUETOOTH_TELEPHONY_ERROR_AUDIO_NOT_CONNECTED \
45                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x05)
46 #define BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED \
47                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x06)
48 #define BLUETOOTH_TELEPHONY_ERROR_NOT_AVAILABLE \
49                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x07)
50 #define BLUETOOTH_TELEPHONY_ERROR_NOT_CONNECTED \
51                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x08)
52 #define BLUETOOTH_TELEPHONY_ERROR_BUSY \
53                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x09)
54 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_EXSIST \
55                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0A)
56 #define BLUETOOTH_TELEPHONY_ERROR_NO_MEMORY \
57                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0B)
58 #define BLUETOOTH_TELEPHONY_ERROR_I_O_ERROR \
59                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0C)
60 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_CONNECTED \
61                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0D)
62 #define BLUETOOTH_TELEPHONY_ERROR_OPERATION_NOT_AVAILABLE \
63                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0E)
64
65 #define BT_ADDRESS_STR_LEN 18
66 #define BT_ADAPTER_PATH_LEN 50
67 #define BT_AUDIO_CALL_PATH_LEN 50
68
69 typedef struct {
70         int event;
71         int result;
72         void *param_data;
73 } telephony_event_param_t;
74
75 typedef struct {
76          int callid;
77 } telephony_event_callid_t;
78
79 typedef struct {
80         gchar *dtmf;
81 } telephony_event_dtmf_t;
82
83 typedef enum {
84         BLUETOOTH_STATE_CONNECTED,
85         BLUETOOTH_STATE_PLAYING,
86         BLUETOOTH_STATE_DISCONNETED,
87 } bluetooth_headset_state_t;
88
89 typedef enum {
90         BLUETOOTH_TELEPHONY_ERROR_INVALID_CHLD_INDEX,
91         BLUETOOTH_TELEPHONY_ERROR_BATTERY_STATUS,
92         BLUETOOTH_TELEPHONY_ERROR_SIGNAL_STATUS,
93         BLUETOOTH_TELEPHONY_ERROR_NOT_SUPPORTED,
94         BLUETOOTH_TELEPHONY_ERROR_APPLICATION,
95         BLUETOOTH_TELEPHONY_ERROR_INVALID_DTMF,
96 } bluetooth_telephony_error_t;
97
98 typedef enum {
99         CSD_CALL_STATUS_IDLE,
100         CSD_CALL_STATUS_CREATE,
101         CSD_CALL_STATUS_COMING,
102         CSD_CALL_STATUS_PROCEEDING,
103         CSD_CALL_STATUS_MO_ALERTING,
104         CSD_CALL_STATUS_MT_ALERTING,
105         CSD_CALL_STATUS_WAITING,
106         CSD_CALL_STATUS_ANSWERED,
107         CSD_CALL_STATUS_ACTIVE,
108         CSD_CALL_STATUS_MO_RELEASE,
109         CSD_CALL_STATUS_MT_RELEASE,
110         CSD_CALL_STATUS_HOLD_INITIATED,
111         CSD_CALL_STATUS_HOLD,
112         CSD_CALL_STATUS_RETRIEVE_INITIATED,
113         CSD_CALL_STATUS_RECONNECT_PENDING,
114         CSD_CALL_STATUS_TERMINATED,
115         CSD_CALL_STATUS_SWAP_INITIATED,
116 } bt_telephony_call_status_t;
117
118 #define BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE     (unsigned int)(0x00100)
119
120 typedef enum {
121         BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL = BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE,
122         BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL,
123         BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL,
124         BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL,
125         BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL,
126         BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL,
127         BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL,
128         BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER,
129         BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF,
130         BLUETOOTH_EVENT_TELEPHONY_HFP_CONNECTED,
131         BLUETOOTH_EVENT_TELEPHONY_HFP_DISCONNECTED,
132         BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED,
133         BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED,
134         BLUETOOTH_EVENT_TELEPHONY_SET_SPEAKER_GAIN,
135         BLUETOOTH_EVENT_TELEPHONY_SET_MIC_GAIN,
136         BLUETOOTH_EVENT_TELEPHONY_NREC_CHANGED,
137 } bluetooth_telephony_event_type;
138
139 typedef enum {
140         BLUETOOTH_CALL_STATE_NONE,
141         BLUETOOTH_CALL_STATE_CONNECTED,
142         BLUETOOTH_CALL_STATE_HELD,
143         BLUETOOTH_CALL_STATE_DIALLING,
144         BLUETOOTH_CALL_STATE_ALERTING,
145         BLUETOOTH_CALL_STATE_INCOMING,
146         BLUETOOTH_CALL_STATE_WAITING,
147         BLUETOOTH_CALL_STATE_ERROR,
148 } bt_telephony_call_state_t;
149
150 typedef struct {
151         unsigned int call_id;
152         bt_telephony_call_state_t call_status;
153 } bt_telephony_call_status_info_t;
154
155 /**
156  * @brief       The function bluetooth_telephony_init is initialize telephony calls.
157  *
158  * @param[in]   cb      Callback function
159  * @param[in]   user_data       Data sent by application, which will be
160  *                              returned in event handler.
161  * @return      int     Zero on Success or reason for error if any.
162  *
163  */
164 int bluetooth_telephony_init(bt_telephony_func_ptr cb, void  *user_data);
165
166 /**
167  * @brief       The function bluetooth_telephony_deinit is deinitialize telephony calls.
168  *
169  * @return      int     Zero on Success or reason for error if any.
170  *
171  */
172 int bluetooth_telephony_deinit(void);
173
174 /**
175  * @brief       The function bluetooth_telephony_audio_open is to open SCO channel
176  *
177  * @return      int     Zero on Success or reason for error if any.
178  *
179  */
180 int bluetooth_telephony_audio_open(void);
181
182 /**
183  * @brief       The function bluetooth_telephony_audio_close is to close SCO channel.
184  *      that the Volume on AG is changed.
185  *
186  * @return      int     Zero on Success or reason for error if any.
187  *
188  */
189 int bluetooth_telephony_audio_close(void);
190
191 /**
192   * @brief      The function bluetooth_telephony_call_remote_ringing is send
193   *     call status.
194  *
195  * @param[in]   call_id Call Id.
196  * @return      int     Zero on Success or reason for error if any.
197  *
198  */
199 int bluetooth_telephony_call_remote_ringing(unsigned int call_id);
200
201 /**
202  * @brief       The function bluetooth_telephony_call_answered is called to
203  *      answer calls.
204  *
205  * @param[in]   call_id Call Id.
206   * @param[in]  bt_audio        flag
207  * @return      int     Zero on Success or reason for error if any.
208  *
209  */
210 int bluetooth_telephony_call_answered(unsigned int call_id,
211                                                 unsigned int bt_audio);
212
213 /**
214  * @brief       The function bluetooth_telephony_call_end to end call
215  *
216  * @param[in]   call_id Call Id.
217  * @return      int     Zero on Success or reason for error if any.
218  *
219  */
220 int bluetooth_telephony_call_end(unsigned int call_id);
221
222 /**
223  * @brief       The function bluetooth_telephony_call_held to hold call
224  *
225  * @param[in]   call_id Call Id.
226  * @return      int     Zero on Success or reason for error if any.
227  *
228  */
229 int bluetooth_telephony_call_held(unsigned int call_id);
230
231 /**
232  * @brief       The function bluetooth_telephony_call_retrieved to retrieve call
233  *
234  * @param[in]   call_id Call Id.
235  * @return      int     Zero on Success or reason for error if any.
236  *
237  */
238 int bluetooth_telephony_call_retrieved(unsigned int call_id);
239
240 /**
241  * @brief       The function bluetooth_telephony_call_swapped to swap call
242  *
243  * @param[in]   call_list       Call info such as id and status.
244  * @param[in]   call_count      Call count.
245  * @return      int     Zero on Success or reason for error if any.
246  *
247  */
248 int bluetooth_telephony_call_swapped(void *call_list,
249                                 unsigned int call_count);
250
251 /**
252  * @brief       The function bluetooth_telephony_set_call_status to set call status
253  *
254  * @param[in]   call_list       Call info such as id and status.
255  * @param[in]   call_count      Call count.
256  * @return      int     Zero on Success or reason for error if any.
257  *
258  */
259 int bluetooth_telephony_set_call_status(void *call_list,
260                                 unsigned int call_count);
261
262 /**
263  * @brief       The function bluetooth_telephony_indicate_outgoing_call toindicate
264  *      outgoing call.
265  *
266  * @param[in]   ph_number       Phone number of the outgoing call.
267  * @param[in]   call_id         Call ID.
268  * @param[in]   bt_audio                Flag.
269  * @return      int     Zero on Success or reason for error if any.
270  *
271  */
272 int bluetooth_telephony_indicate_outgoing_call(
273                 const char *ph_number, unsigned int call_id,
274                 unsigned int bt_audio);
275
276 /**
277  * @brief       The function bluetooth_telephony_indicate_incoming_call  to indicate
278  *      incoming call.
279  *
280  * @param[in]   call_info       Call info such as id and status.
281  * @param[in]   call_count      Call count.
282  * @return      int     Zero on Success or reason for error if any.
283  *
284  */
285 int bluetooth_telephony_indicate_incoming_call(
286                 const char *ph_number, unsigned int call_id);
287
288 /**
289  * @brief       The function bluetooth_telephony_is_sco_connected  to check
290  *              if SCO channel is connected.
291  *
292  * @return      gboolean        TRUE if headset playing else FALSE.
293  *
294  */
295 gboolean bluetooth_telephony_is_sco_connected(void);
296
297 /**
298  * @brief       The function bluetooth_telephony_is_nrec_enabled  to check
299  *              for noise reduction and echo cancelation(nrec) status
300  *
301  * @return      int     Zero on Success or reason for error if any.
302  *
303  */
304  int bluetooth_telephony_is_nrec_enabled(gboolean *status);
305
306 /**
307  * @brief This function sends request to enable voice recognition feature
308  *
309  * @return      int     Zero on Success or reason for error if any.
310  */
311  int bluetooth_telephony_start_voice_recognition(void);
312
313 /**
314  * @brief This function sends request to disable voice recognition feature
315  *
316  * @return      int     Zero on Success or reason for error if any.
317  */
318  int bluetooth_telephony_stop_voice_recognition(void);
319
320
321 /**
322  * @brief       The function bluetooth_telephony_get_headset_volume is called to get
323  *      the changed Volume on AG.
324  *
325  * @param[out]  speaker_gain            Speaker gain.
326  * @return      int     Zero on Success or reason for error if any.
327  *
328  */
329 int bluetooth_telephony_get_headset_volume(unsigned int *speaker_gain);
330
331 /**
332  * @brief       The function bluetooth_telephony_set_speaker_gain is called to indicate
333  *      that the Volume on AG is changed.
334  *
335  * @param[in]   speaker_gain            Speaker gain.
336  * @return      int     Zero on Success or reason for error if any.
337  *
338  */
339 int bluetooth_telephony_set_speaker_gain(unsigned short speaker_gain);
340
341
342 #ifdef __cplusplus
343 }
344 #endif /*__cplusplus*/
345 #endif/*_BLUETOOTH_TELEPHONY_API_H_*/