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