6fadb5c2c00082e0708c7be1909a144fdd99f816
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-audio-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_AUDIO_API_H_
19 #define _BLUETOOTH_AUDIO_API_H_
20
21 #include <stdint.h>
22 #include <glib.h>
23 #include <dlog.h>
24
25 #include "bluetooth-api.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /*__cplusplus*/
30
31 #define BLUETOOTH_AUDIO_ERROR_BASE ((int)0)
32 #define BLUETOOTH_AUDIO_ERROR_NONE ((int)0)
33 #define BLUETOOTH_AUDIO_ERROR_INTERNAL \
34                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x01)
35 #define BLUETOOTH_AUDIO_ERROR_INVALID_PARAM \
36                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x02)
37 #define BLUETOOTH_AG_ERROR_CONNECTION_ERROR \
38                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x03)
39 #define BLUETOOTH_AV_ERROR_CONNECTION_ERROR \
40                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x04)
41
42 typedef struct {
43         int event;
44         int result;
45         void *param_data;
46         void *user_data;
47 } bt_audio_event_param_t;
48
49 typedef enum {
50         BLUETOOTH_AG_STATE_NONE,
51         BLUETOOTH_AG_STATE_CONNECTING,
52         BLUETOOTH_AG_STATE_CONNECTED,
53         BLUETOOTH_AG_STATE_DISCONNECTED,
54         BLUETOOTH_AG_STATE_PLAYING,
55 } bt_ag_conn_status_t;
56
57 typedef enum {
58         BLUETOOTH_AV_STATE_NONE,
59         BLUETOOTH_AV_STATE_CONNECTING,
60         BLUETOOTH_AV_STATE_CONNECTED,
61         BLUETOOTH_AV_STATE_DISCONNECTED,
62 } bt_av_conn_status_t;
63
64 typedef enum {
65         BLUETOOTH_HF_CIEV_BATTCHG,  /* BT_HF_REMOTE_DEVICE_STATE_BATTERY_LEVEL */
66         BLUETOOTH_HF_CIEV_SIGNAL,  /* BT_HF_REMOTE_DEVICE_STATE_SIGNAL_STRENGTH */
67         BLUETOOTH_HF_CIEV_SERVICE,  /* BT_HF_REMOTE_DEVICE_STATE_NETWORK_SERVICE */
68         BLUETOOTH_HF_VR_STATUS, /* BT_HF_REMOTE_DEVICE_STATE_VOICE_RECOGNITON */
69 } bt_hf_ciev_device_state_t;
70
71 typedef void (*bt_audio_func_ptr) (int, bt_audio_event_param_t *, void *);
72
73 typedef struct {
74         bt_ag_conn_status_t ag_state;
75         bt_av_conn_status_t av_state;
76         unsigned int ag_audio_flag;
77         unsigned int ag_spkr_gain;
78         bluetooth_device_address_t local_address;
79         bluetooth_device_address_t remote_address;
80         bt_audio_func_ptr audio_cb;
81         void *user_data;
82 } bt_audio_info_t;
83
84 typedef enum {
85         BLUETOOTH_STATE_NONE = 0x0000,
86         BLUETOOTH_STATE_HEADSET_CONNECTED = 0x0004,
87         BLUETOOTH_STATE_A2DP_HEADSET_CONNECTED = 0x0010,
88 } bluetooth_device_state_t;
89
90 typedef enum {
91         BLUETOOTH_A2DP_SOURCE,
92         BLUETOOTH_A2DP_SINK,
93 } bluetooth_audio_role_t;
94
95 /**
96  * @brief       The function bluetooth_audio_init called to initializes the Audio
97  *      service to bluetoothD and Global data related to audio.
98  * @param[in]   cb      Callback function
99  * @param[in]   user_data       Data sent by application, which will be
100  *                              returned in event handler.
101  * @return      int     Zero on Success or reason for error if any.
102  *
103  */
104 int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data);
105
106 /**
107  * @brief       The function bluetooth_audio_deinit is called to free the Audio
108  *      related Global data.
109  *
110  * @return      int     Zero on Success or reason for error if any.
111  *
112  */
113 int bluetooth_audio_deinit(void);
114
115 /**
116  * @brief       The function bluetooth_audio_connect is called to establish an
117  *      AG connection with  the specified device.
118  *
119  * @param[in]   remote_address  Bluetooth device address.
120  * @return      int     Zero on Success or reason for error if any.
121  *
122  */
123 int bluetooth_audio_connect(bluetooth_device_address_t *remote_address);
124
125 /**
126  * @brief       The function bluetooth_audio_disconnect is called to disconnect
127  *      an existing AG connection with the specified device.
128  *
129  * @param[in]   remote_address  Bluetooth device address.
130  * @return      int     Zero on Success or reason for error if any.
131  *
132  */
133 int bluetooth_audio_disconnect(bluetooth_device_address_t *remote_address);
134
135 /**
136  * @brief       The function bluetooth_ag_connect is called to establish an AG
137  *      connection with  the specified device.
138  *
139  * @param[in]   remote_address  Bluetooth device address.
140  * @return      int     Zero on Success or reason for error if any.
141  *
142  */
143 int bluetooth_ag_connect(bluetooth_device_address_t *remote_address);
144
145 /**
146  * @brief       The function bluetooth_ag_disconnect is called to disconnect an
147  *      existing AG connection with the specified device.
148  *
149  * @param[in]   remote_address  Bluetooth device address.
150  * @return      int     Zero on Success or reason for error if any.
151  *
152  */
153 int bluetooth_ag_disconnect(bluetooth_device_address_t *remote_address);
154
155 /**
156  * @brief       The function bluetooth_av_connect is called to establish an AV
157  *      connection with  the specified device.
158  *
159  * @param[in]   remote_address  Bluetooth device address.
160  * @return      int     Zero on Success or reason for error if any.
161  *
162  */
163 int bluetooth_av_connect(bluetooth_device_address_t *remote_address);
164
165 /**
166  * @brief       The function bluetooth_av_source_connect is called to establish an AV Source
167  *      connection with  the specified device.
168  *
169  * @param[in]   remote_address  Bluetooth device address.
170  * @return      int     Zero on Success or reason for error if any.
171  *
172  */
173 int bluetooth_av_source_connect(bluetooth_device_address_t *remote_address);
174
175 /**
176  * @brief       The function bluetooth_av_disconnect is called to disconnect an
177  *      existing AV connection with the specified device.
178  *
179  * @param[in]   remote_address  Bluetooth device address.
180  * @return      int     Zero on Success or reason for error if any.
181  *
182  */
183 int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address);
184
185 /**
186  * @brief       The function bluetooth_av_source_disconnect is called to disconnect an
187  *      existing AV connection with the specified device.
188  *
189  * @param[in]   remote_address  Bluetooth device address.
190  * @return      int     Zero on Success or reason for error if any.
191  *
192  */
193 int bluetooth_av_source_disconnect(bluetooth_device_address_t *remote_address);
194
195 /**
196  * @brief       The function bluetooth_ag_get_headset_volume is called to get
197  *      the changed Volume on AG.
198  *
199  * @param[in]   speaker_gain    Speaker gain/loss.
200  * @return      int     Zero on Success or reason for error if any.
201  *
202  */
203 int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain);
204
205 /**
206  * @brief       The function bluetooth_ag_set_speaker_gain is called to indicate
207  *      that the Volume on AG is changed.
208  *
209  * @param[in]   speaker_gain    Speaker gain/loss.
210  * @return      int     Zero on Success or reason for error if any.
211  *
212  */
213 int bluetooth_ag_set_speaker_gain(unsigned int speaker_gain);
214
215 /**
216  * @brief       The function bluetooth_audio_select_role is called to set
217  *      A2DP to Source or Sink.
218  *
219  * @param[in]   role SINK/SOURCE.
220  * @return      int     Zero on Success or reason for error if any.
221  *
222  */
223 int bluetooth_audio_select_role(bluetooth_audio_role_t role);
224
225 typedef struct {
226         int event;
227         int result;
228         void *param_data;
229         void *user_data;
230 } bt_hf_event_param_t;
231
232 typedef void (*bt_hf_func_ptr) (int, bt_hf_event_param_t *, void *);
233
234
235 int bluetooth_hf_init(bt_hf_func_ptr cb, void *user_data);
236
237 int bluetooth_hf_deinit(void);
238
239 int bluetooth_hf_connect(bluetooth_device_address_t *remote_address);
240
241 int bluetooth_hf_disconnect(bluetooth_device_address_t *remote_address);
242
243 int bluetooth_hf_answer_call();
244
245 int bluetooth_hf_terminate_call();
246
247 int bluetooth_hf_initiate_call(char *number);
248
249 int bluetooth_hf_voice_recognition(unsigned int status);
250
251 int bluetooth_hf_audio_disconnect(void);
252
253 int bluetooth_hf_set_speaker_gain(unsigned int speaker_gain);
254
255 int bluetooth_hf_send_dtmf(char *dtmf);
256
257 int bluetooth_hf_send_xsat_cmd(int app_id, char *xsat_cmd);
258
259 int bluetooth_hf_swap_call(void);
260
261 int bluetooth_hf_release_all_call(void);
262
263 int bluetooth_hf_release_and_accept(void);
264
265 int bluetooth_hf_join_call(void);
266
267 int bluetooth_hf_get_call_list(void *call_list, bt_hf_call_status_info_t **call_status);
268
269 int bluetooth_hf_free_call_list(bt_hf_call_list_s *call_list);
270
271 int bluetooth_hf_request_call_list(bt_hf_call_list_s **call_list);
272
273 int bluetooth_hf_request_call_list_async(void);
274
275 int bluetooth_hf_get_codec(unsigned int *codec_id);
276
277 int bluetooth_hf_get_audio_connected(unsigned int *audio_connected);
278
279 int bluetooth_hf_is_connected(gboolean *hf_connected);
280
281 int bluetooth_hf_is_ibr_supported(gboolean*ibr_supported);
282
283 #ifdef __cplusplus
284 }
285 #endif /*__cplusplus*/
286 #endif/*_BLUETOOTH_AUDIO_API_H_*/