78394850babc6e7ffdb378e5d4d485d3f6934416
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / include / oal-avrcp-ct.h
1 /*
2  * Open Adaptation Layer (OAL)
3  *
4  * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
5  *
6  * Contact: Nilesh Trimbake <t.shripati@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef _OAL_AVRCP_CT_H_
23 #define _OAL_AVRCP_CT_H_
24
25 #include <glib.h>
26 #include <sys/types.h>
27 #include <oal-manager.h>
28 #include "oal-event.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 typedef enum {
35         OAL_RC_PASS_CMD_PLAY = 0x01,
36         OAL_RC_PASS_CMD_PAUSE,
37         OAL_RC_PASS_CMD_STOP,
38         OAL_RC_PASS_CMD_NEXT,
39         OAL_RC_PASS_CMD_PREVIOUS,
40         OAL_RC_PASS_CMD_PRESS_FAST_FORWARD,
41         OAL_RC_PASS_CMD_RELEASE_FAST_FORWARD,
42         OAL_RC_PASS_CMD_PRESS_REWIND,
43         OAL_RC_PASS_CMD_RELEASE_REWIND,
44         OAL_RC_PASS_CMD_VOLUME_UP,
45         OAL_RC_PASS_CMD_VOLUME_DOWN
46 } avrcp_ct_pass_cmd_key_code_t;
47
48 /**
49  * @brief Current State of remote key(pressed/released)
50  *
51  * @see  avrcp_ct_fforward
52  * @see  avrcp_ct_rewind
53  */
54 typedef enum {
55         PRESS_STATE = 0x00,
56         RELEASE_STATE = 0x01
57 } avrcp_ct_pass_state_t;
58
59 typedef struct {
60         avrcp_ct_pass_cmd_key_code_t key_code;
61         avrcp_ct_pass_state_t key_state;
62 } avrcp_ct_pass_cmd_t;
63
64 typedef struct {
65         uint8_t accepted;
66 } avrcp_ct_playersetting_t;
67
68 typedef enum {
69         OAL_EQUALIZER = 0x01,
70         OAL_REPEAT,
71         OAL_SHUFFLE,
72         OAL_SCAN,
73         OAL_PLAY_STATUS,
74         OAL_PLAY_POSITION,
75 } avrcp_ct_player_property_type_t;
76
77 typedef struct {
78         avrcp_ct_player_property_type_t type;
79         unsigned int value;
80 } avrcp_ct_property_value_t;
81
82 typedef struct {
83         uint32_t song_len;
84         uint32_t song_pos;
85 } avrcp_ct_play_position_t;
86
87 /**
88  * @brief Enable AVRCP Controller Feature
89  *
90  * @remarks  Devices supporting AVRCP Target will be able to connect.
91  * @remarks  Used in conjunction with a2dp_sink_enable.
92  *
93  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
94  * @retval #OAL_STATUS_SUCCESS  Successful
95  *
96  * @pre OAL API must be initialized with oal_bt_init().
97  *
98  * @see  avrcp_ct_disable
99  * @see  a2dp_sink_enable
100  */
101 oal_status_t avrcp_ct_enable(void);
102
103 /**
104  * @brief Disable AVRCP Controller Feature
105  *
106  * @remarks  Devices supporting AVRCP Target will not be able to connect.
107  * @remarks  Used in conjunction with a2dp_sink_disable.
108  *
109  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
110  * @retval #OAL_STATUS_SUCCESS  Successful
111  *
112  * @pre AVRCP Controller should be enabled with avrcp_ct_enable().
113  *
114  * @see  avrcp_ct_enable
115  * @see  a2dp_sink_disable
116  */
117 oal_status_t avrcp_ct_disable(void);
118
119 /**
120  * @brief Initiate a connection with a BT Sound device
121  *
122  * @details  Result will be notified through an OAL event
123  *
124  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
125  * @retval #OAL_STATUS_SUCCESS  Successful
126  *
127  * @pre BT Audio should be enabled with avrcp_ct_enable().
128  *
129  * @see  OAL_EVENT_AVRCP_CT_CONNECTED
130  */
131
132 oal_status_t avrcp_ct_connect(bt_address_t *device_address);
133
134
135 /**
136  * @brief Remove a connection with a BT Sound device
137  *
138  * @details  Result will be notified through an OAL event
139  *
140  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
141  * @retval #OAL_STATUS_SUCCESS  Successful
142  *
143  * @pre BT Audio should be connected with a BT Sound device.
144  *
145  * @see  OAL_EVENT_AVRCP_CT_DISCONNECTED
146  */
147
148 oal_status_t avrcp_ct_disconnect(bt_address_t *device_address);
149
150 /**
151  * @brief Play audio on the connected remote device.
152  *
153  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
154  * @retval #OAL_STATUS_SUCCESS  Successful
155  *
156  * @pre A2DP Sink should be connected with a device.
157  * @pre AVRCP connection should exist with the device.
158  */
159 oal_status_t avrcp_ct_play(bt_address_t *device_address);
160
161 /**
162  * @brief Stop audio on the connected remote device.
163  *
164  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
165  * @retval #OAL_STATUS_SUCCESS  Successful
166  *
167  * @pre A2DP Sink should be connected with a device.
168  * @pre AVRCP connection should exist with the device.
169  */
170 oal_status_t avrcp_ct_stop(bt_address_t *device_address);
171
172 /**
173  * @brief Pause audio on the connected remote device.
174  *
175  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
176  * @retval #OAL_STATUS_SUCCESS  Successful
177  *
178  * @pre A2DP Sink should be connected with a device.
179  * @pre AVRCP connection should exist with the device.
180  */
181 oal_status_t avrcp_ct_pause(bt_address_t *device_address);
182
183 /**
184  * @brief Fast Forward audio on the connected remote device.
185  *
186  * @remarks  PRESS_STATE   - Start Fast Forward
187  *           RELEASE_STATE - Stop Fast Forward
188  *
189  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
190  * @retval #OAL_STATUS_SUCCESS  Successful
191  *
192  * @pre A2DP Sink should be connected with a device.
193  * @pre AVRCP connection should exist with the device.
194  */
195 oal_status_t avrcp_ct_fforward(bt_address_t *device_address, avrcp_ct_pass_state_t press_state);
196
197 /**
198  * @brief Rewind audio on the connected remote device.
199  *
200  * @remarks  PRESS_STATE   - Start Rewind
201  *           RELEASE_STATE - Stop Rewind
202  *
203  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
204  * @retval #OAL_STATUS_SUCCESS  Successful
205  *
206  * @pre A2DP Sink should be connected with a device.
207  * @pre AVRCP connection should exist with the device.
208  */
209 oal_status_t avrcp_ct_rewind(bt_address_t *device_address, avrcp_ct_pass_state_t press_state);
210
211 /**
212  * @brief Play next track on the connected remote device.
213  *
214  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
215  * @retval #OAL_STATUS_SUCCESS  Successful
216  *
217  * @pre A2DP Sink should be connected with a device.
218  * @pre AVRCP connection should exist with the device.
219  */
220 oal_status_t avrcp_ct_next_track(bt_address_t *device_address);
221
222
223 /**
224  * @brief Play prev track on the connected remote device.
225  *
226  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
227  * @retval #OAL_STATUS_SUCCESS  Successful
228  *
229  * @pre A2DP Sink should be connected with a device.
230  * @pre AVRCP connection should exist with the device.
231  */
232 oal_status_t avrcp_ct_prev_track(bt_address_t *device_address);
233
234 /**
235  * @brief Set media player properties to target device
236  *
237  * @remarks Target device will receive media player properties.
238  *
239  * @return OAL_STATUS_SUCCESS on success, otherwise non-zero error value.
240  * @retval #OAL_STATUS_SUCCESS  Successful
241  *
242  * @pre OAL API must be initialize with avrcp_ct_enable().
243  *
244  */
245 oal_status_t avrcp_ct_set_property(bt_address_t *device_address, avrcp_ct_player_property_type_t type, uint32_t value);
246
247 /**
248  * @brief Set media transport properties to target device
249  *
250  * @remarks Target device will receive media player properties.
251  *
252  * @return OAL_STATUS_SUCCESS on success, otherwise non-zero error value.
253  * @retval #OAL_STATUS_SUCCESS  Successful
254  *
255  * @pre OAL API must be initialize with avrcp_ct_enable().
256  *
257  */
258 oal_status_t avrcp_transport_set_property(bt_address_t *device_address, int type, unsigned int value);
259
260 /**
261  * @brief Get media player properties to target device
262  *
263  * @remarks Target device will send media player properties.
264  *
265  * @return OAL_STATUS_SUCCESS on success, otherwise non-zero error value.
266  * @retval #OAL_STATUS_SUCCESS  Successful
267  *
268  * @pre OAL API must be initialize with avrcp_ct_enable().
269  *
270  */
271 oal_status_t avrcp_ct_get_property(bt_address_t *device_address, avrcp_ct_player_property_type_t type);
272
273 /**
274  * @brief Set media player properties to target device
275  *
276  * @remarks Target device will receive media player properties.
277  *
278  * @return OAL_STATUS_SUCCESS on success, otherwise non-zero error value.
279  * @retval #OAL_STATUS_SUCCESS  Successful
280  *
281  * @pre OAL API must be initialize with avrcp_ct_enable().
282  *
283  */
284 oal_status_t avrcp_ct_get_media_attribute(bt_address_t *device_address);
285
286 /**
287  * @brief Request current status of the media playing on connected Audio source.
288  *
289  * @details Result containing - Song Length, Song Position and current status(Stopped/Playing/Paused) will be notified through an OAL event
290  *
291  * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
292  * @retval #OAL_STATUS_SUCCESS  Successful
293  *
294  * @pre A2DP Sink should be connected with a device.
295  * @pre AVRCP connection should exist with the device.
296  *
297  * @see  OAL_EVENT_AVRCP_CT_PLAY_STATUS
298  * @see  event_avrcp_ct_play_status_t
299  */
300 oal_status_t avrcp_ct_get_play_status(bt_address_t *device_address);
301
302 #ifdef __cplusplus
303 }
304 #endif /* __cplusplus */
305 #endif /*_OAL_AVRCP_CT_H_*/