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 134 /** 135 * @brief Stops continuous cmd (play, pause, volume up, ...). Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 136 * @param avrcp_cid 137 * @returns status 138 */ 139 uint8_t avrcp_controller_release_press_and_hold_cmd(uint16_t avrcp_cid); 140 141 /** 142 * @brief Play. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 143 * @param avrcp_cid 144 * @returns status 145 */ 146 uint8_t avrcp_controller_play(uint16_t avrcp_cid); 147 uint8_t avrcp_controller_press_and_hold_play(uint16_t avrcp_cid); 148 149 /** 150 * @brief Stop. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 151 * @param avrcp_cid 152 * @returns status 153 */ 154 uint8_t avrcp_controller_stop(uint16_t avrcp_cid); 155 uint8_t avrcp_controller_press_and_hold_stop(uint16_t avrcp_cid); 156 157 /** 158 * @brief Pause. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 159 * @param avrcp_cid 160 * @returns status 161 */ 162 uint8_t avrcp_controller_pause(uint16_t avrcp_cid); 163 uint8_t avrcp_controller_press_and_hold_pause(uint16_t avrcp_cid); 164 165 /** 166 * @brief Single step - fast forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 167 * @param avrcp_cid 168 * @returns status 169 */ 170 uint8_t avrcp_controller_fast_forward(uint16_t avrcp_cid); 171 uint8_t avrcp_controller_press_and_hold_fast_forward(uint16_t avrcp_cid); 172 173 174 /** 175 * @brief Single step rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 176 * @param avrcp_cid 177 * @returns status 178 */ 179 uint8_t avrcp_controller_rewind(uint16_t avrcp_cid); 180 uint8_t avrcp_controller_press_and_hold_rewind(uint16_t avrcp_cid); 181 182 /** 183 * @brief Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 184 * @param avrcp_cid 185 * @returns status 186 */ 187 uint8_t avrcp_controller_forward(uint16_t avrcp_cid); 188 uint8_t avrcp_controller_press_and_hold_forward(uint16_t avrcp_cid); 189 190 /** 191 * @brief Backward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 192 * @param avrcp_cid 193 * @returns status 194 */ 195 uint8_t avrcp_controller_backward(uint16_t avrcp_cid); 196 uint8_t avrcp_controller_press_and_hold_backward(uint16_t avrcp_cid); 197 198 /** 199 * @brief Turns the volume to high. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 200 * @param avrcp_cid 201 * @returns status 202 */ 203 uint8_t avrcp_controller_volume_up(uint16_t avrcp_cid); 204 uint8_t avrcp_controller_press_and_hold_volume_up(uint16_t avrcp_cid); 205 /** 206 * @brief Turns the volume to low. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 207 * @param avrcp_cid 208 * @returns status 209 */ 210 uint8_t avrcp_controller_volume_down(uint16_t avrcp_cid); 211 uint8_t avrcp_controller_press_and_hold_volume_down(uint16_t avrcp_cid); 212 213 /** 214 * @brief Puts the sound out. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 215 * @param avrcp_cid 216 * @returns status 217 */ 218 uint8_t avrcp_controller_mute(uint16_t avrcp_cid); 219 uint8_t avrcp_controller_press_and_hold_mute(uint16_t avrcp_cid); 220 221 /** 222 * @brief Get play status. Returns event of type AVRCP_SUBEVENT_PLAY_STATUS (length, position, play_status). 223 * If TG does not support SongLength And SongPosition on TG, then TG shall return 0xFFFFFFFF. 224 * @param avrcp_cid 225 * @returns status 226 */ 227 uint8_t avrcp_controller_get_play_status(uint16_t avrcp_cid); 228 229 /** 230 * @brief Enable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE. 231 * @param avrcp_cid 232 * @param event_id 233 * @returns status 234 */ 235 uint8_t avrcp_controller_enable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 236 237 /** 238 * @brief Disable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE. 239 * @param avrcp_cid 240 * @param event_id 241 * @returns status 242 */ 243 uint8_t avrcp_controller_disable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 244 245 /** 246 * @brief Get info on now playing media. 247 * @param avrcp_cid 248 * @returns status 249 */ 250 uint8_t avrcp_controller_get_now_playing_info(uint16_t avrcp_cid); 251 252 /** 253 * @brief Set absolute volume 0-127 (corresponds to 0-100%). Response via AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE 254 * @param avrcp_cid 255 * @returns status 256 */ 257 uint8_t avrcp_controller_set_absolute_volume(uint16_t avrcp_cid, uint8_t volume); 258 259 260 /** 261 * @brief Skip to next playing media. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 262 * @param avrcp_cid 263 * @returns status 264 */ 265 uint8_t avrcp_controller_skip(uint16_t avrcp_cid); 266 267 /** 268 * @brief Query repeat and shuffle mode. Response via AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE. 269 * @param avrcp_cid 270 * @returns status 271 */ 272 uint8_t avrcp_controller_query_shuffle_and_repeat_modes(uint16_t avrcp_cid); 273 274 /** 275 * @brief Set shuffle mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 276 * @param avrcp_cid 277 * @returns status 278 */ 279 uint8_t avrcp_controller_set_shuffle_mode(uint16_t avrcp_cid, avrcp_shuffle_mode_t mode); 280 281 /** 282 * @brief Set repeat mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 283 * @param avrcp_cid 284 * @returns status 285 */ 286 uint8_t avrcp_controller_set_repeat_mode(uint16_t avrcp_cid, avrcp_repeat_mode_t mode); 287 288 /** 289 * @brief The PlayItem command starts playing an item indicated by the UID. It is routed to the Addressed Player. 290 * @param avrcp_cid 291 * @param uid 292 * @param uid_counter 293 * @param scope 294 **/ 295 uint8_t avrcp_controller_play_item_for_scope(uint16_t avrcp_cid, uint8_t * uid, uint16_t uid_counter, avrcp_browsing_scope_t scope); 296 297 /** 298 * @brief Adds an item indicated by the UID to the Now Playing queue. 299 * @param avrcp_cid 300 * @param uid 301 * @param uid_counter 302 * @param scope 303 **/ 304 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); 305 306 /** 307 * @brief Set addressed player. 308 * @param avrcp_cid 309 * @param addressed_player_id 310 */ 311 uint8_t avrcp_controller_set_addressed_player(uint16_t avrcp_cid, uint16_t addressed_player_id); 312 313 314 /* API_END */ 315 316 /** 317 * @brief Send custom command 318 * @param avrcp_cid 319 * @param command_type 320 * @param subunit_type 321 * @param subunit ID 322 * @param command_opcode 323 * @param command_buffer 324 * @param command_len 325 */ 326 uint8_t avrcp_controller_send_custom_command(uint16_t avrcp_cid, avrcp_command_type_t command_type, avrcp_subunit_type_t subunit_type, avrcp_subunit_id_t subunit_id, avrcp_command_opcode_t command_opcode, const uint8_t * command_buffer, uint16_t command_len); 327 328 // Used by AVRCP controller and AVRCP browsing controller 329 extern avrcp_context_t avrcp_controller_context; 330 331 #if defined __cplusplus 332 } 333 #endif 334 335 #endif // __AVRCP_CONTROLLER_H 336