DPM: Add Error code for device policy restriction.
[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 void (*bt_audio_func_ptr) (int, bt_audio_event_param_t *, void *);
65
66 typedef struct {
67         bt_ag_conn_status_t ag_state;
68         bt_av_conn_status_t av_state;
69         unsigned int ag_audio_flag;
70         unsigned int ag_spkr_gain;
71         bluetooth_device_address_t local_address;
72         bluetooth_device_address_t remote_address;
73         bt_audio_func_ptr audio_cb;
74         void *user_data;
75 } bt_audio_info_t;
76
77 typedef enum {
78                 BLUETOOTH_STATE_NONE = 0x0000,
79                 BLUETOOTH_STATE_HEADSET_CONNECTED = 0x0004,
80                 BLUETOOTH_STATE_A2DP_HEADSET_CONNECTED = 0x0010,
81 } bluetooth_device_state_t;
82
83 /**
84  * @brief       The function bluetooth_audio_init called to initializes the Audio
85  *      service to bluetoothD and Global data related to audio.
86  * @param[in]   cb      Callback function
87  * @param[in]   user_data       Data sent by application, which will be
88  *                              returned in event handler.
89  * @return      int     Zero on Success or reason for error if any.
90  *
91  */
92 int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data);
93
94 /**
95  * @brief       The function bluetooth_audio_deinit is called to free the Audio
96  *      related Global data.
97  *
98  * @return      int     Zero on Success or reason for error if any.
99  *
100  */
101 int bluetooth_audio_deinit(void);
102
103 /**
104  * @brief       The function bluetooth_audio_connect is called to establish an
105  *      AG connection with  the specified device.
106  *
107  * @param[in]   remote_address  Bluetooth device address.
108  * @return      int     Zero on Success or reason for error if any.
109  *
110  */
111 int bluetooth_audio_connect(bluetooth_device_address_t *remote_address);
112
113 /**
114  * @brief       The function bluetooth_audio_disconnect is called to disconnect
115  *      an existing AG connection with the specified device.
116  *
117  * @param[in]   remote_address  Bluetooth device address.
118  * @return      int     Zero on Success or reason for error if any.
119  *
120  */
121 int bluetooth_audio_disconnect(bluetooth_device_address_t *remote_address);
122
123 /**
124  * @brief       The function bluetooth_ag_connect is called to establish an AG
125  *      connection with  the specified device.
126  *
127  * @param[in]   remote_address  Bluetooth device address.
128  * @return      int     Zero on Success or reason for error if any.
129  *
130  */
131 int bluetooth_ag_connect(bluetooth_device_address_t *remote_address);
132
133 /**
134  * @brief       The function bluetooth_ag_disconnect is called to disconnect an
135  *      existing AG connection with the specified device.
136  *
137  * @param[in]   remote_address  Bluetooth device address.
138  * @return      int     Zero on Success or reason for error if any.
139  *
140  */
141 int bluetooth_ag_disconnect(bluetooth_device_address_t *remote_address);
142
143 /**
144  * @brief       The function bluetooth_av_connect is called to establish an AV
145  *      connection with  the specified device.
146  *
147  * @param[in]   remote_address  Bluetooth device address.
148  * @return      int     Zero on Success or reason for error if any.
149  *
150  */
151 int bluetooth_av_connect(bluetooth_device_address_t *remote_address);
152
153 /**
154  * @brief       The function bluetooth_av_source_connect is called to establish an AV Source
155  *      connection with  the specified device.
156  *
157  * @param[in]   remote_address  Bluetooth device address.
158  * @return      int     Zero on Success or reason for error if any.
159  *
160  */
161 int bluetooth_av_source_connect(bluetooth_device_address_t *remote_address);
162
163 /**
164  * @brief       The function bluetooth_av_disconnect is called to disconnect an
165  *      existing AV connection with the specified device.
166  *
167  * @param[in]   remote_address  Bluetooth device address.
168  * @return      int     Zero on Success or reason for error if any.
169  *
170  */
171 int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address);
172
173 /**
174  * @brief       The function bluetooth_av_source_disconnect is called to disconnect an
175  *      existing AV connection with the specified device.
176  *
177  * @param[in]   remote_address  Bluetooth device address.
178  * @return      int     Zero on Success or reason for error if any.
179  *
180  */
181 int bluetooth_av_source_disconnect(bluetooth_device_address_t *remote_address);
182
183 /**
184  * @brief       The function bluetooth_ag_get_headset_volume is called to get
185  *      the changed Volume on AG.
186  *
187  * @param[in]   speaker_gain    Speaker gain/loss.
188  * @return      int     Zero on Success or reason for error if any.
189  *
190  */
191 int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain);
192
193 /**
194  * @brief       The function bluetooth_ag_set_speaker_gain is called to indicate
195  *      that the Volume on AG is changed.
196  *
197  * @param[in]   speaker_gain    Speaker gain/loss.
198  * @return      int     Zero on Success or reason for error if any.
199  *
200  */
201 int bluetooth_ag_set_speaker_gain(unsigned int speaker_gain);
202
203 typedef struct {
204         int event;
205         int result;
206         void *param_data;
207         void *user_data;
208 } bt_hf_event_param_t;
209
210 typedef void (*bt_hf_func_ptr) (int, bt_hf_event_param_t *, void *);
211
212
213 int bluetooth_hf_init(bt_hf_func_ptr cb, void *user_data);
214
215 int bluetooth_hf_deinit(void);
216
217 int bluetooth_hf_connect(bluetooth_device_address_t *remote_address);
218
219 int bluetooth_hf_disconnect(bluetooth_device_address_t *remote_address);
220
221 int bluetooth_hf_answer_call();
222
223 int bluetooth_hf_terminate_call();
224
225 int bluetooth_hf_initiate_call(char *number);
226
227 int bluetooth_hf_voice_recognition(unsigned int status);
228
229 int bluetooth_hf_audio_disconnect(void);
230
231 int bluetooth_hf_set_speaker_gain(unsigned int speaker_gain);
232
233 int bluetooth_hf_send_dtmf(char *dtmf);
234
235 int bluetooth_hf_send_xsat_cmd(int app_id, char *xsat_cmd);
236
237 int bluetooth_hf_swap_call(void);
238
239 int bluetooth_hf_release_all_call(void);
240
241 int bluetooth_hf_release_and_accept(void);
242
243 int bluetooth_hf_join_call(void);
244
245 int bluetooth_hf_get_call_list(void *call_list, bt_hf_call_status_info_t **call_status);
246
247 int bluetooth_hf_free_call_list(bt_hf_call_list_s *call_list);
248
249 int bluetooth_hf_request_call_list(bt_hf_call_list_s **call_list);
250
251 int bluetooth_hf_get_codec(unsigned int *codec_id);
252
253 int bluetooth_hf_get_audio_connected(unsigned int *audio_connected);
254
255 int bluetooth_hf_is_connected(gboolean *hf_connected);
256
257 #ifdef __cplusplus
258 }
259 #endif /*__cplusplus*/
260 #endif/*_BLUETOOTH_AUDIO_API_H_*/