Code Sync [Tizen3.0]: Merged the tizen_2.4 Spin code to tizen.org
[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 <dbus/dbus-glib.h>
29 #include <dbus/dbus-glib-lowlevel.h>
30 #include <dlog.h>
31
32 #include "bluetooth-api.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /*__cplusplus*/
37
38 #define BLUETOOTH_AUDIO_ERROR_BASE ((int)0)
39 #define BLUETOOTH_AUDIO_ERROR_NONE ((int)0)
40 #define BLUETOOTH_AUDIO_ERROR_INTERNAL \
41                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x01)
42 #define BLUETOOTH_AUDIO_ERROR_INVALID_PARAM \
43                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x02)
44 #define BLUETOOTH_AG_ERROR_CONNECTION_ERROR \
45                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x03)
46 #define BLUETOOTH_AV_ERROR_CONNECTION_ERROR \
47                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x04)
48
49 typedef struct {
50         int event;
51         int result;
52         void *param_data;
53         void *user_data;
54 } bt_audio_event_param_t;
55
56 typedef enum {
57         BLUETOOTH_AG_STATE_NONE,
58         BLUETOOTH_AG_STATE_CONNECTING,
59         BLUETOOTH_AG_STATE_CONNECTED,
60         BLUETOOTH_AG_STATE_DISCONNECTED,
61         BLUETOOTH_AG_STATE_PLAYING,
62 } bt_ag_conn_status_t;
63
64 typedef enum {
65         BLUETOOTH_AV_STATE_NONE,
66         BLUETOOTH_AV_STATE_CONNECTING,
67         BLUETOOTH_AV_STATE_CONNECTED,
68         BLUETOOTH_AV_STATE_DISCONNECTED,
69 } bt_av_conn_status_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 /**
91  * @brief       The function bluetooth_audio_init called to initializes the Audio
92  *      service to bluetoothD and Global data related to audio.
93  * @param[in]   cb      Callback function
94  * @param[in]   user_data       Data sent by application, which will be
95  *                              returned in event handler.
96  * @return      int     Zero on Success or reason for error if any.
97  *
98  */
99 int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data);
100
101 /**
102  * @brief       The function bluetooth_audio_deinit is called to free the Audio
103  *      related Global data.
104  *
105  * @return      int     Zero on Success or reason for error if any.
106  *
107  */
108 int bluetooth_audio_deinit(void);
109
110 /**
111  * @brief       The function bluetooth_audio_connect is called to establish an
112  *      AG connection with  the specified device.
113  *
114  * @param[in]   remote_address  Bluetooth device address.
115  * @return      int     Zero on Success or reason for error if any.
116  *
117  */
118 int bluetooth_audio_connect(bluetooth_device_address_t *remote_address);
119
120 /**
121  * @brief       The function bluetooth_audio_disconnect is called to disconnect
122  *      an existing AG connection with the specified device.
123  *
124  * @param[in]   remote_address  Bluetooth device address.
125  * @return      int     Zero on Success or reason for error if any.
126  *
127  */
128 int bluetooth_audio_disconnect(bluetooth_device_address_t *remote_address);
129
130 /**
131  * @brief       The function bluetooth_ag_connect is called to establish an AG
132  *      connection with  the specified device.
133  *
134  * @param[in]   remote_address  Bluetooth device address.
135  * @return      int     Zero on Success or reason for error if any.
136  *
137  */
138 int bluetooth_ag_connect(bluetooth_device_address_t *remote_address);
139
140 /**
141  * @brief       The function bluetooth_ag_disconnect is called to disconnect an
142  *      existing AG connection with the specified device.
143  *
144  * @param[in]   remote_address  Bluetooth device address.
145  * @return      int     Zero on Success or reason for error if any.
146  *
147  */
148 int bluetooth_ag_disconnect(bluetooth_device_address_t *remote_address);
149
150 /**
151  * @brief       The function bluetooth_av_connect is called to establish an AV
152  *      connection with  the specified device.
153  *
154  * @param[in]   remote_address  Bluetooth device address.
155  * @return      int     Zero on Success or reason for error if any.
156  *
157  */
158 int bluetooth_av_connect(bluetooth_device_address_t *remote_address);
159
160 /**
161  * @brief       The function bluetooth_av_disconnect is called to disconnect an
162  *      existing AV connection with the specified device.
163  *
164  * @param[in]   remote_address  Bluetooth device address.
165  * @return      int     Zero on Success or reason for error if any.
166  *
167  */
168 int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address);
169
170 /**
171  * @brief       The function bluetooth_ag_get_headset_volume is called to get
172  *      the changed Volume on AG.
173  *
174  * @param[in]   speaker_gain    Speaker gain/loss.
175  * @return      int     Zero on Success or reason for error if any.
176  *
177  */
178 int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain);
179
180 /**
181  * @brief       The function bluetooth_ag_set_speaker_gain is called to indicate
182  *      that the Volume on AG is changed.
183  *
184  * @param[in]   speaker_gain    Speaker gain/loss.
185  * @return      int     Zero on Success or reason for error if any.
186  *
187  */
188 int bluetooth_ag_set_speaker_gain(unsigned int speaker_gain);
189
190 typedef struct {
191         int event;
192         int result;
193         void *param_data;
194         void *user_data;
195 } bt_hf_event_param_t;
196
197 typedef void (*bt_hf_func_ptr) (int, bt_hf_event_param_t *, void *);
198
199
200 int bluetooth_hf_init(bt_hf_func_ptr cb, void *user_data);
201
202 int bluetooth_hf_deinit(void);
203
204 int bluetooth_hf_connect(bluetooth_device_address_t *remote_address);
205
206 int bluetooth_hf_disconnect(bluetooth_device_address_t *remote_address);
207
208 int bluetooth_hf_answer_call();
209
210 int bluetooth_hf_terminate_call();
211
212 int bluetooth_hf_initiate_call(char *number);
213
214 int bluetooth_hf_voice_recognition(unsigned int status);
215
216 int bluetooth_hf_audio_disconnect(void);
217
218 int bluetooth_hf_set_speaker_gain(unsigned int speaker_gain);
219
220 int bluetooth_hf_send_dtmf(char *dtmf);
221
222 int bluetooth_hf_send_xsat_cmd(int app_id, char *xsat_cmd);
223
224 int bluetooth_hf_swap_call(void);
225
226 int bluetooth_hf_release_all_call(void);
227
228 int bluetooth_hf_release_and_accept(void);
229
230 int bluetooth_hf_join_call(void);
231
232 int bluetooth_hf_get_call_list(void *call_list, bt_hf_call_status_info_t **call_status);
233
234 int bluetooth_hf_free_call_list(bt_hf_call_list_s *call_list);
235
236 int bluetooth_hf_request_call_list(bt_hf_call_list_s **call_list);
237
238 int bluetooth_hf_get_codec(unsigned int *codec_id);
239
240 int bluetooth_hf_get_audio_connected(unsigned int *audio_connected);
241
242 int bluetooth_hf_is_hf_connected(gboolean *hf_connected);
243
244 #ifdef __cplusplus
245 }
246 #endif /*__cplusplus*/
247 #endif/*_BLUETOOTH_AUDIO_API_H_*/