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