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