Merge the code from tizen_2.4
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-audio-api.h
1 /*
2  * bluetooth-audio-api
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  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef _BLUETOOTH_AUDIO_API_H_
24 #define _BLUETOOTH_AUDIO_API_H_
25
26 #include <stdint.h>
27 #include <glib.h>
28 #include <dlog.h>
29
30 #include "bluetooth-api.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /*__cplusplus*/
35
36 #define BLUETOOTH_AUDIO_ERROR_BASE ((int)0)
37 #define BLUETOOTH_AUDIO_ERROR_NONE ((int)0)
38 #define BLUETOOTH_AUDIO_ERROR_INTERNAL \
39                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x01)
40 #define BLUETOOTH_AUDIO_ERROR_INVALID_PARAM \
41                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x02)
42 #define BLUETOOTH_AG_ERROR_CONNECTION_ERROR \
43                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x03)
44 #define BLUETOOTH_AV_ERROR_CONNECTION_ERROR \
45                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x04)
46
47 typedef struct {
48         int event;
49         int result;
50         void *param_data;
51         void *user_data;
52 } bt_audio_event_param_t;
53
54 typedef enum {
55         BLUETOOTH_AG_STATE_NONE,
56         BLUETOOTH_AG_STATE_CONNECTING,
57         BLUETOOTH_AG_STATE_CONNECTED,
58         BLUETOOTH_AG_STATE_DISCONNECTED,
59         BLUETOOTH_AG_STATE_PLAYING,
60 } bt_ag_conn_status_t;
61
62 typedef enum {
63         BLUETOOTH_AV_STATE_NONE,
64         BLUETOOTH_AV_STATE_CONNECTING,
65         BLUETOOTH_AV_STATE_CONNECTED,
66         BLUETOOTH_AV_STATE_DISCONNECTED,
67 } bt_av_conn_status_t;
68
69 typedef void (*bt_audio_func_ptr) (int, bt_audio_event_param_t *, void *);
70
71 typedef struct {
72         bt_ag_conn_status_t ag_state;
73         bt_av_conn_status_t av_state;
74         unsigned int ag_audio_flag;
75         unsigned int ag_spkr_gain;
76         bluetooth_device_address_t local_address;
77         bluetooth_device_address_t remote_address;
78         bt_audio_func_ptr audio_cb;
79         void *user_data;
80 } bt_audio_info_t;
81
82 typedef enum {
83                 BLUETOOTH_STATE_NONE = 0x0000,
84                 BLUETOOTH_STATE_HEADSET_CONNECTED = 0x0004,
85                 BLUETOOTH_STATE_A2DP_HEADSET_CONNECTED = 0x0010,
86 } bluetooth_device_state_t;
87
88 /**
89  * @brief       The function bluetooth_audio_init called to initializes the Audio
90  *      service to bluetoothD and Global data related to audio.
91  * @param[in]   cb      Callback function
92  * @param[in]   user_data       Data sent by application, which will be
93  *                              returned in event handler.
94  * @return      int     Zero on Success or reason for error if any.
95  *
96  */
97 int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data);
98
99 /**
100  * @brief       The function bluetooth_audio_deinit is called to free the Audio
101  *      related Global data.
102  *
103  * @return      int     Zero on Success or reason for error if any.
104  *
105  */
106 int bluetooth_audio_deinit(void);
107
108 /**
109  * @brief       The function bluetooth_audio_connect is called to establish an
110  *      AG connection with  the specified device.
111  *
112  * @param[in]   remote_address  Bluetooth device address.
113  * @return      int     Zero on Success or reason for error if any.
114  *
115  */
116 int bluetooth_audio_connect(bluetooth_device_address_t *remote_address);
117
118 /**
119  * @brief       The function bluetooth_audio_disconnect is called to disconnect
120  *      an existing AG connection with the specified device.
121  *
122  * @param[in]   remote_address  Bluetooth device address.
123  * @return      int     Zero on Success or reason for error if any.
124  *
125  */
126 int bluetooth_audio_disconnect(bluetooth_device_address_t *remote_address);
127
128 /**
129  * @brief       The function bluetooth_ag_connect is called to establish an AG
130  *      connection with  the specified device.
131  *
132  * @param[in]   remote_address  Bluetooth device address.
133  * @return      int     Zero on Success or reason for error if any.
134  *
135  */
136 int bluetooth_ag_connect(bluetooth_device_address_t *remote_address);
137
138 /**
139  * @brief       The function bluetooth_ag_disconnect is called to disconnect an
140  *      existing AG connection with the specified device.
141  *
142  * @param[in]   remote_address  Bluetooth device address.
143  * @return      int     Zero on Success or reason for error if any.
144  *
145  */
146 int bluetooth_ag_disconnect(bluetooth_device_address_t *remote_address);
147
148 /**
149  * @brief       The function bluetooth_av_connect is called to establish an AV
150  *      connection with  the specified device.
151  *
152  * @param[in]   remote_address  Bluetooth device address.
153  * @return      int     Zero on Success or reason for error if any.
154  *
155  */
156 int bluetooth_av_connect(bluetooth_device_address_t *remote_address);
157
158 /**
159  * @brief       The function bluetooth_av_source_connect is called to establish an AV Source
160  *      connection with  the specified device.
161  *
162  * @param[in]   remote_address  Bluetooth device address.
163  * @return      int     Zero on Success or reason for error if any.
164  *
165  */
166 int bluetooth_av_source_connect(bluetooth_device_address_t *remote_address);
167
168 /**
169  * @brief       The function bluetooth_av_disconnect is called to disconnect an
170  *      existing AV connection with the specified device.
171  *
172  * @param[in]   remote_address  Bluetooth device address.
173  * @return      int     Zero on Success or reason for error if any.
174  *
175  */
176 int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address);
177
178 /**
179  * @brief       The function bluetooth_av_source_disconnect is called to disconnect an
180  *      existing AV connection with the specified device.
181  *
182  * @param[in]   remote_address  Bluetooth device address.
183  * @return      int     Zero on Success or reason for error if any.
184  *
185  */
186 int bluetooth_av_source_disconnect(bluetooth_device_address_t *remote_address);
187
188 /**
189  * @brief       The function bluetooth_ag_get_headset_volume is called to get
190  *      the changed Volume on AG.
191  *
192  * @param[in]   speaker_gain    Speaker gain/loss.
193  * @return      int     Zero on Success or reason for error if any.
194  *
195  */
196 int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain);
197
198 /**
199  * @brief       The function bluetooth_ag_set_speaker_gain is called to indicate
200  *      that the Volume on AG is changed.
201  *
202  * @param[in]   speaker_gain    Speaker gain/loss.
203  * @return      int     Zero on Success or reason for error if any.
204  *
205  */
206 int bluetooth_ag_set_speaker_gain(unsigned int speaker_gain);
207
208 typedef struct {
209         int event;
210         int result;
211         void *param_data;
212         void *user_data;
213 } bt_hf_event_param_t;
214
215 typedef void (*bt_hf_func_ptr) (int, bt_hf_event_param_t *, void *);
216
217
218 int bluetooth_hf_init(bt_hf_func_ptr cb, void *user_data);
219
220 int bluetooth_hf_deinit(void);
221
222 int bluetooth_hf_connect(bluetooth_device_address_t *remote_address);
223
224 int bluetooth_hf_disconnect(bluetooth_device_address_t *remote_address);
225
226 int bluetooth_hf_answer_call();
227
228 int bluetooth_hf_terminate_call();
229
230 int bluetooth_hf_initiate_call(char *number);
231
232 int bluetooth_hf_voice_recognition(unsigned int status);
233
234 int bluetooth_hf_audio_disconnect(void);
235
236 int bluetooth_hf_set_speaker_gain(unsigned int speaker_gain);
237
238 int bluetooth_hf_send_dtmf(char *dtmf);
239
240 int bluetooth_hf_send_xsat_cmd(int app_id, char *xsat_cmd);
241
242 int bluetooth_hf_swap_call(void);
243
244 int bluetooth_hf_release_all_call(void);
245
246 int bluetooth_hf_release_and_accept(void);
247
248 int bluetooth_hf_join_call(void);
249
250 int bluetooth_hf_get_call_list(void *call_list, bt_hf_call_status_info_t **call_status);
251
252 int bluetooth_hf_free_call_list(bt_hf_call_list_s *call_list);
253
254 int bluetooth_hf_request_call_list(bt_hf_call_list_s **call_list);
255
256 int bluetooth_hf_get_codec(unsigned int *codec_id);
257
258 int bluetooth_hf_get_audio_connected(unsigned int *audio_connected);
259
260 int bluetooth_hf_is_connected(gboolean *hf_connected);
261
262 #ifdef __cplusplus
263 }
264 #endif /*__cplusplus*/
265 #endif/*_BLUETOOTH_AUDIO_API_H_*/