xref: /btstack/src/classic/avrcp_controller.h (revision 4931e24a4e38c450fc9f7aa14b9fea1c3ab0b574)
1 /*
2  * Copyright (C) 2016 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 /*
39  * avrcp.h
40  *
41  * Audio/Video Remote Control Profile
42  *
43  */
44 
45 #ifndef __AVRCP_CONTROLLER_H
46 #define __AVRCP_CONTROLLER_H
47 
48 #include <stdint.h>
49 #include "btstack_run_loop.h"
50 #include "btstack_linked_list.h"
51 #include "avrcp.h"
52 
53 #if defined __cplusplus
54 extern "C" {
55 #endif
56 
57 /* API_START */
58 /**
59  * @brief AVRCP Controller service record.
60  * @param service
61  * @param service_record_handle
62  * @param browsing  1 - supported, 0 - not supported
63  * @param supported_features 16-bit bitmap, see AVDTP_SINK_SF_* values in avdtp.h
64  * @param service_name
65  * @param service_provider_name
66  */
67 void avrcp_controller_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint8_t browsing, uint16_t supported_features, const char * service_name, const char * service_provider_name);
68 
69 /**
70  * @brief Set up AVRCP Controller device.
71  */
72 void avrcp_controller_init(void);
73 
74 /**
75  * @brief Register callback for the AVRCP Controller client.
76  * @param callback
77  */
78 void avrcp_controller_register_packet_handler(btstack_packet_handler_t callback);
79 
80 /**
81  * @brief Connect to device with a Bluetooth address.
82  * @param bd_addr
83  * @param avrcp_cid
84  * @returns status
85  */
86 uint8_t avrcp_controller_connect(bd_addr_t bd_addr, uint16_t * avrcp_cid);
87 
88 /**
89  * @brief Disconnect from AVRCP target
90  * @param avrcp_cid
91  * @returns status
92  */
93 uint8_t avrcp_controller_disconnect(uint16_t avrcp_cid);
94 
95 /**
96  * @brief Set max num fragments in whuch message can be transmited.
97  * @param avrcp_cid
98  * @param max_num_fragments
99  * @returns status
100  */
101 uint8_t avrcp_controller_set_max_num_fragments(uint16_t avrcp_cid, uint8_t max_num_fragments);
102 
103 
104 /**
105  * @brief Unit info.
106  * @param avrcp_cid
107  * @returns status
108  */
109 uint8_t avrcp_controller_unit_info(uint16_t avrcp_cid);
110 
111 /**
112  * @brief Subunit info.
113  * @param avrcp_cid
114  * @returns status
115  */
116 uint8_t avrcp_controller_subunit_info(uint16_t avrcp_cid);
117 
118 /**
119  * @brief Get capabilities.
120  * @param avrcp_cid
121  * @returns status
122  */
123 uint8_t avrcp_controller_get_supported_company_ids(uint16_t avrcp_cid);
124 
125 /**
126  * @brief Get supported Events.
127  * @param avrcp_cid
128  * @returns status
129  */
130 uint8_t avrcp_controller_get_supported_events(uint16_t avrcp_cid);
131 
132 /**
133  * @brief Play. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
134  * @param avrcp_cid
135  * @returns status
136  */
137 uint8_t avrcp_controller_play(uint16_t avrcp_cid);
138 
139 /**
140  * @brief Stop. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
141  * @param avrcp_cid
142  * @returns status
143  */
144 uint8_t avrcp_controller_stop(uint16_t avrcp_cid);
145 
146 /**
147  * @brief Pause. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
148  * @param avrcp_cid
149  * @returns status
150  */
151 uint8_t avrcp_controller_pause(uint16_t avrcp_cid);
152 
153 /**
154  * @brief Start Fast Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
155  * @param avrcp_cid
156  * @returns status
157  */
158 uint8_t avrcp_controller_start_fast_forward(uint16_t avrcp_cid);
159 
160 /**
161  * @brief Stop Fast Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
162  * @param avrcp_cid
163  * @returns status
164  */
165 uint8_t avrcp_controller_stop_fast_forward(uint16_t avrcp_cid);
166 
167 /**
168  * @brief Single step - fast forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
169  * @param avrcp_cid
170  * @returns status
171  */
172 uint8_t avrcp_controller_fast_forward(uint16_t avrcp_cid);
173 
174 /**
175  * @brief Stop Rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
176  * @param avrcp_cid
177  * @returns status
178  */
179 uint8_t avrcp_controller_start_rewind(uint16_t avrcp_cid);
180 
181 /**
182  * @brief Stop Rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
183  * @param avrcp_cid
184  * @returns status
185  */
186 uint8_t avrcp_controller_stop_rewind(uint16_t avrcp_cid);
187 
188 /**
189  * @brief Single step rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
190  * @param avrcp_cid
191  * @returns status
192  */
193 uint8_t avrcp_controller_rewind(uint16_t avrcp_cid);
194 
195 /**
196  * @brief Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
197  * @param avrcp_cid
198  * @returns status
199  */
200 uint8_t avrcp_controller_forward(uint16_t avrcp_cid);
201 
202 /**
203  * @brief Backward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
204  * @param avrcp_cid
205  * @returns status
206  */
207 uint8_t avrcp_controller_backward(uint16_t avrcp_cid);
208 
209 
210 /**
211  * @brief Get play status. Returns event of type AVRCP_SUBEVENT_PLAY_STATUS (length, position, play_status).
212  * If TG does not support SongLength And SongPosition on TG, then TG shall return 0xFFFFFFFF.
213  * @param avrcp_cid
214  * @returns status
215  */
216 uint8_t avrcp_controller_get_play_status(uint16_t avrcp_cid);
217 
218 /**
219  * @brief Enable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE.
220  * @param avrcp_cid
221  * @param event_id
222  * @returns status
223  */
224 uint8_t avrcp_controller_enable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id);
225 
226 /**
227  * @brief Disable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE.
228  * @param avrcp_cid
229  * @param event_id
230  * @returns status
231  */
232 uint8_t avrcp_controller_disable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id);
233 
234 /**
235  * @brief Get info on now playing media.
236  * @param avrcp_cid
237  * @returns status
238  */
239 uint8_t avrcp_controller_get_now_playing_info(uint16_t avrcp_cid);
240 
241 /**
242  * @brief Set absolute volume 0-127 (corresponds to 0-100%). Response via AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE
243  * @param avrcp_cid
244  * @returns status
245  */
246 uint8_t avrcp_controller_set_absolute_volume(uint16_t avrcp_cid, uint8_t volume);
247 
248 /**
249  * @brief Turns the volume to high. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
250  * @param avrcp_cid
251  * @returns status
252  */
253 uint8_t avrcp_controller_volume_up(uint16_t avrcp_cid);
254 
255 /**
256  * @brief Turns the volume to low. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
257  * @param avrcp_cid
258  * @returns status
259  */
260 uint8_t avrcp_controller_volume_down(uint16_t avrcp_cid);
261 
262 /**
263  * @brief Puts the sound out. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
264  * @param avrcp_cid
265  * @returns status
266  */
267 uint8_t avrcp_controller_mute(uint16_t avrcp_cid);
268 
269 /**
270  * @brief Skip to next playing media. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
271  * @param avrcp_cid
272  * @returns status
273  */
274 uint8_t avrcp_controller_skip(uint16_t avrcp_cid);
275 
276 /**
277  * @brief Query repeat and shuffle mode. Response via AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE.
278  * @param avrcp_cid
279  * @returns status
280  */
281 uint8_t avrcp_controller_query_shuffle_and_repeat_modes(uint16_t avrcp_cid);
282 
283 /**
284  * @brief Set shuffle mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
285  * @param avrcp_cid
286  * @returns status
287  */
288 uint8_t avrcp_controller_set_shuffle_mode(uint16_t avrcp_cid, avrcp_shuffle_mode_t mode);
289 
290 /**
291  * @brief Set repeat mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status.
292  * @param avrcp_cid
293  * @returns status
294  */
295 uint8_t avrcp_controller_set_repeat_mode(uint16_t avrcp_cid, avrcp_repeat_mode_t mode);
296 
297 /**
298  * @brief The PlayItem command starts playing an item indicated by the UID. It is routed to the Addressed Player.
299  * @param avrcp_cid
300  * @param uid
301  * @param uid_counter
302  * @param scope
303  **/
304 uint8_t avrcp_controller_play_item_for_scope(uint16_t avrcp_cid, uint8_t * uid, uint16_t uid_counter, avrcp_browsing_scope_t scope);
305 
306 /**
307  * @brief Adds an item indicated by the UID to the Now Playing queue.
308  * @param avrcp_cid
309  * @param uid
310  * @param uid_counter
311  * @param scope
312  **/
313 uint8_t avrcp_controller_add_item_from_scope_to_now_playing_list(uint16_t avrcp_cid, uint8_t * uid, uint16_t uid_counter, avrcp_browsing_scope_t scope);
314 
315 /**
316  * @brief Set addressed player.
317  * @param avrcp_cid
318  * @param addressed_player_id
319  */
320 uint8_t avrcp_controller_set_addressed_player(uint16_t avrcp_cid, uint16_t addressed_player_id);
321 
322 
323 /* API_END */
324 
325 // Used by AVRCP controller and AVRCP browsing controller
326 extern avrcp_context_t avrcp_controller_context;
327 
328 #if defined __cplusplus
329 }
330 #endif
331 
332 #endif // __AVRCP_CONTROLLER_H
333