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 Unit info. 97 * @param avrcp_cid 98 * @returns status 99 */ 100 uint8_t avrcp_controller_unit_info(uint16_t avrcp_cid); 101 102 /** 103 * @brief Subunit info. 104 * @param avrcp_cid 105 * @returns status 106 */ 107 uint8_t avrcp_controller_subunit_info(uint16_t avrcp_cid); 108 109 /** 110 * @brief Get capabilities. 111 * @param avrcp_cid 112 * @returns status 113 */ 114 uint8_t avrcp_controller_get_supported_company_ids(uint16_t avrcp_cid); 115 116 /** 117 * @brief Get supported Events. 118 * @param avrcp_cid 119 * @returns status 120 */ 121 uint8_t avrcp_controller_get_supported_events(uint16_t avrcp_cid); 122 123 /** 124 * @brief Play. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 125 * @param avrcp_cid 126 * @returns status 127 */ 128 uint8_t avrcp_controller_play(uint16_t avrcp_cid); 129 130 /** 131 * @brief Stop. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 132 * @param avrcp_cid 133 * @returns status 134 */ 135 uint8_t avrcp_controller_stop(uint16_t avrcp_cid); 136 137 /** 138 * @brief Pause. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 139 * @param avrcp_cid 140 * @returns status 141 */ 142 uint8_t avrcp_controller_pause(uint16_t avrcp_cid); 143 144 /** 145 * @brief Start Fast Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 146 * @param avrcp_cid 147 * @returns status 148 */ 149 uint8_t avrcp_controller_start_fast_forward(uint16_t avrcp_cid); 150 151 /** 152 * @brief Stop Fast Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 153 * @param avrcp_cid 154 * @returns status 155 */ 156 uint8_t avrcp_controller_stop_fast_forward(uint16_t avrcp_cid); 157 158 /** 159 * @brief Single step - fast forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 160 * @param avrcp_cid 161 * @returns status 162 */ 163 uint8_t avrcp_controller_fast_forward(uint16_t avrcp_cid); 164 165 /** 166 * @brief Stop Rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 167 * @param avrcp_cid 168 * @returns status 169 */ 170 uint8_t avrcp_controller_start_rewind(uint16_t avrcp_cid); 171 172 /** 173 * @brief Stop Rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 174 * @param avrcp_cid 175 * @returns status 176 */ 177 uint8_t avrcp_controller_stop_rewind(uint16_t avrcp_cid); 178 179 /** 180 * @brief Single step rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 181 * @param avrcp_cid 182 * @returns status 183 */ 184 uint8_t avrcp_controller_rewind(uint16_t avrcp_cid); 185 186 /** 187 * @brief Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 188 * @param avrcp_cid 189 * @returns status 190 */ 191 uint8_t avrcp_controller_forward(uint16_t avrcp_cid); 192 193 /** 194 * @brief Backward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 195 * @param avrcp_cid 196 * @returns status 197 */ 198 uint8_t avrcp_controller_backward(uint16_t avrcp_cid); 199 200 201 /** 202 * @brief Get play status. Returns event of type AVRCP_SUBEVENT_PLAY_STATUS (length, position, play_status). 203 * If TG does not support SongLength And SongPosition on TG, then TG shall return 0xFFFFFFFF. 204 * @param avrcp_cid 205 * @returns status 206 */ 207 uint8_t avrcp_controller_get_play_status(uint16_t avrcp_cid); 208 209 /** 210 * @brief Enable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE. 211 * @param avrcp_cid 212 * @param event_id 213 * @returns status 214 */ 215 uint8_t avrcp_controller_enable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 216 217 /** 218 * @brief Disable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE. 219 * @param avrcp_cid 220 * @param event_id 221 * @returns status 222 */ 223 uint8_t avrcp_controller_disable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 224 225 /** 226 * @brief Get info on now playing media. 227 * @param avrcp_cid 228 * @returns status 229 */ 230 uint8_t avrcp_controller_get_now_playing_info(uint16_t avrcp_cid); 231 232 /** 233 * @brief Set absolute volume 0-127 (corresponds to 0-100%). Response via AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE 234 * @param avrcp_cid 235 * @returns status 236 */ 237 uint8_t avrcp_controller_set_absolute_volume(uint16_t avrcp_cid, uint8_t volume); 238 239 /** 240 * @brief Turns the volume to high. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 241 * @param avrcp_cid 242 * @returns status 243 */ 244 uint8_t avrcp_controller_volume_up(uint16_t avrcp_cid); 245 246 /** 247 * @brief Turns the volume to low. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 248 * @param avrcp_cid 249 * @returns status 250 */ 251 uint8_t avrcp_controller_volume_down(uint16_t avrcp_cid); 252 253 /** 254 * @brief Puts the sound out. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 255 * @param avrcp_cid 256 * @returns status 257 */ 258 uint8_t avrcp_controller_mute(uint16_t avrcp_cid); 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 /* API_END */ 288 289 // Used by AVRCP controller and AVRCP browsing controller 290 extern avrcp_context_t avrcp_controller_context; 291 292 #if defined __cplusplus 293 } 294 #endif 295 296 #endif // __AVRCP_CONTROLLER_H 297