88c318ef4735e65a8e5fc421ef92d1785edae68c
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-audio-api.h
1 /*
2  * bluetooth-frwk
3  *
4  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *              http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef _BLUETOOTH_AUDIO_API_H_
21 #define _BLUETOOTH_AUDIO_API_H_
22
23 #include <stdint.h>
24 #include <glib.h>
25 #include <dbus/dbus-glib.h>
26 #include <dbus/dbus-glib-lowlevel.h>
27 #include <dlog.h>
28
29 #include "bluetooth-api.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /*__cplusplus*/
34
35 #define BLUETOOTH_AUDIO_ERROR_BASE ((int)0)
36 #define BLUETOOTH_AUDIO_ERROR_NONE ((int)0)
37 #define BLUETOOTH_AUDIO_ERROR_INTERNAL \
38                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x01)
39 #define BLUETOOTH_AUDIO_ERROR_INVALID_PARAM \
40                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x02)
41 #define BLUETOOTH_AG_ERROR_CONNECTION_ERROR \
42                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x03)
43 #define BLUETOOTH_AV_ERROR_CONNECTION_ERROR \
44                                 ((int)BLUETOOTH_AUDIO_ERROR_BASE - 0x04)
45
46 typedef struct {
47         int event;
48         int result;
49         void *param_data;
50         void *user_data;
51 } bt_audio_event_param_t;
52
53 typedef enum {
54         BLUETOOTH_AG_STATE_NONE,
55         BLUETOOTH_AG_STATE_CONNECTING,
56         BLUETOOTH_AG_STATE_CONNECTED,
57         BLUETOOTH_AG_STATE_DISCONNECTED,
58         BLUETOOTH_AG_STATE_PLAYING,
59 } bt_ag_conn_status_t;
60
61 typedef enum {
62         BLUETOOTH_AV_STATE_NONE,
63         BLUETOOTH_AV_STATE_CONNECTING,
64         BLUETOOTH_AV_STATE_CONNECTED,
65         BLUETOOTH_AV_STATE_DISCONNECTED,
66 } bt_av_conn_status_t;
67
68 typedef void (*bt_audio_func_ptr) (int, bt_audio_event_param_t *, void *);
69
70 typedef struct {
71         bt_ag_conn_status_t ag_state;
72         bt_av_conn_status_t av_state;
73         unsigned int ag_audio_flag;
74         unsigned int ag_spkr_gain;
75         bluetooth_device_address_t local_address;
76         bluetooth_device_address_t remote_address;
77         bt_audio_func_ptr audio_cb;
78         void *user_data;
79 } bt_audio_info_t;
80
81 typedef enum {
82                 BLUETOOTH_STATE_NONE = 0x0000,
83                 BLUETOOTH_STATE_HEADSET_CONNECTED = 0x0004,
84                 BLUETOOTH_STATE_A2DP_HEADSET_CONNECTED = 0x0010,
85 } bluetooth_device_state_t;
86
87 /**
88  * @brief       The function bluetooth_audio_init called to initializes the Audio
89  *      service to bluetoothD and Global data related to audio.
90  * @param[in]   cb      Callback function
91  * @param[in]   user_data       Data sent by application, which will be
92  *                              returned in event handler.
93  * @return      int     Zero on Success or reason for error if any.
94  *
95  */
96 int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data);
97
98 /**
99  * @brief       The function bluetooth_audio_deinit is called to free the Audio
100  *      related Global data.
101  *
102  * @return      int     Zero on Success or reason for error if any.
103  *
104  */
105 int bluetooth_audio_deinit(void);
106
107 /**
108  * @brief       The function bluetooth_audio_connect is called to establish an
109  *      AG connection with  the specified device.
110  *
111  * @param[in]   remote_address  Bluetooth device address.
112  * @return      int     Zero on Success or reason for error if any.
113  *
114  */
115 int bluetooth_audio_connect(bluetooth_device_address_t *remote_address);
116
117 /**
118  * @brief       The function bluetooth_audio_disconnect is called to disconnect
119  *      an existing AG connection with the specified device.
120  *
121  * @param[in]   remote_address  Bluetooth device address.
122  * @return      int     Zero on Success or reason for error if any.
123  *
124  */
125 int bluetooth_audio_disconnect(bluetooth_device_address_t *remote_address);
126
127 /**
128  * @brief       The function bluetooth_ag_connect is called to establish an AG
129  *      connection with  the specified device.
130  *
131  * @param[in]   remote_address  Bluetooth device address.
132  * @return      int     Zero on Success or reason for error if any.
133  *
134  */
135 int bluetooth_ag_connect(bluetooth_device_address_t *remote_address);
136
137 /**
138  * @brief       The function bluetooth_ag_disconnect is called to disconnect an
139  *      existing AG connection with the specified device.
140  *
141  * @param[in]   remote_address  Bluetooth device address.
142  * @return      int     Zero on Success or reason for error if any.
143  *
144  */
145 int bluetooth_ag_disconnect(bluetooth_device_address_t *remote_address);
146
147 /**
148  * @brief       The function bluetooth_av_connect is called to establish an AV
149  *      connection with  the specified device.
150  *
151  * @param[in]   remote_address  Bluetooth device address.
152  * @return      int     Zero on Success or reason for error if any.
153  *
154  */
155 int bluetooth_av_connect(bluetooth_device_address_t *remote_address);
156
157 /**
158  * @brief       The function bluetooth_av_disconnect is called to disconnect an
159  *      existing AV connection with the specified device.
160  *
161  * @param[in]   remote_address  Bluetooth device address.
162  * @return      int     Zero on Success or reason for error if any.
163  *
164  */
165 int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address);
166
167 /**
168  * @brief       The function bluetooth_ag_get_headset_volume is called to get
169  *      the changed Volume on AG.
170  *
171  * @param[in]   speaker_gain    Speaker gain/loss.
172  * @return      int     Zero on Success or reason for error if any.
173  *
174  */
175 int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain);
176
177 /**
178  * @brief       The function bluetooth_ag_set_speaker_gain is called to indicate
179  *      that the Volume on AG is changed.
180  *
181  * @param[in]   speaker_gain    Speaker gain/loss.
182  * @return      int     Zero on Success or reason for error if any.
183  *
184  */
185 int bluetooth_ag_set_speaker_gain(unsigned int speaker_gain);
186
187 #ifdef __cplusplus
188 }
189 #endif /*__cplusplus*/
190 #endif/*_BLUETOOTH_AUDIO_API_H_*/