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 /** 60 * @brief AVDTP Sink service record. 61 * @param service 62 * @param service_record_handle 63 * @param browsing 1 - supported, 0 - not supported 64 * @param supported_features 16-bit bitmap, see AVDTP_SINK_SF_* values in avdtp.h 65 * @param service_name 66 * @param service_provider_name 67 */ 68 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); 69 70 /** 71 * @brief Set up AVDTP Sink device. 72 */ 73 void avrcp_controller_init(void); 74 75 /** 76 * @brief Register callback for the AVRCP Sink client. 77 * @param callback 78 */ 79 void avrcp_controller_register_packet_handler(btstack_packet_handler_t callback); 80 81 /** 82 * @brief Connect to device with a Bluetooth address. 83 * @param bd_addr 84 * @param avrcp_cid 85 * @returns status 86 */ 87 uint8_t avrcp_controller_connect(bd_addr_t bd_addr, uint16_t * avrcp_cid); 88 89 /** 90 * @brief Disconnect from AVRCP target 91 * @param avrcp_cid 92 * @returns status 93 */ 94 uint8_t avrcp_controller_disconnect(uint16_t avrcp_cid); 95 96 /** 97 * @brief Unit info. 98 * @param avrcp_cid 99 * @returns status 100 */ 101 uint8_t avrcp_controller_unit_info(uint16_t avrcp_cid); 102 103 /** 104 * @brief Get capabilities. 105 * @param avrcp_cid 106 * @returns status 107 */ 108 uint8_t avrcp_controller_get_supported_company_ids(uint16_t avrcp_cid); 109 110 /** 111 * @brief Get supported Events. 112 * @param avrcp_cid 113 * @returns status 114 */ 115 uint8_t avrcp_controller_get_supported_events(uint16_t avrcp_cid); 116 117 /** 118 * @brief Play. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 119 * @param avrcp_cid 120 * @returns status 121 */ 122 uint8_t avrcp_controller_play(uint16_t avrcp_cid); 123 124 /** 125 * @brief Stop. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 126 * @param avrcp_cid 127 * @returns status 128 */ 129 uint8_t avrcp_controller_stop(uint16_t avrcp_cid); 130 131 /** 132 * @brief Pause. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 133 * @param avrcp_cid 134 * @returns status 135 */ 136 uint8_t avrcp_controller_pause(uint16_t avrcp_cid); 137 138 /** 139 * @brief Start Fast Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 140 * @param avrcp_cid 141 * @returns status 142 */ 143 uint8_t avrcp_controller_start_fast_forward(uint16_t avrcp_cid); 144 145 /** 146 * @brief Stop Fast Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 147 * @param avrcp_cid 148 * @returns status 149 */ 150 uint8_t avrcp_controller_stop_fast_forward(uint16_t avrcp_cid); 151 152 /** 153 * @brief Single step - fast forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 154 * @param avrcp_cid 155 * @returns status 156 */ 157 uint8_t avrcp_controller_fast_forward(uint16_t avrcp_cid); 158 159 /** 160 * @brief Stop Rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 161 * @param avrcp_cid 162 * @returns status 163 */ 164 uint8_t avrcp_controller_start_rewind(uint16_t avrcp_cid); 165 166 /** 167 * @brief Stop Rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 168 * @param avrcp_cid 169 * @returns status 170 */ 171 uint8_t avrcp_controller_stop_rewind(uint16_t avrcp_cid); 172 173 /** 174 * @brief Single step rewind. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 175 * @param avrcp_cid 176 * @returns status 177 */ 178 uint8_t avrcp_controller_rewind(uint16_t avrcp_cid); 179 180 /** 181 * @brief Forward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 182 * @param avrcp_cid 183 * @returns status 184 */ 185 uint8_t avrcp_controller_forward(uint16_t avrcp_cid); 186 187 /** 188 * @brief Backward. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 189 * @param avrcp_cid 190 * @returns status 191 */ 192 uint8_t avrcp_controller_backward(uint16_t avrcp_cid); 193 194 195 /** 196 * @brief Get play status. Returns event of type AVRCP_SUBEVENT_PLAY_STATUS (length, position, play_status). 197 * If TG does not support SongLength And SongPosition on TG, then TG shall return 0xFFFFFFFF. 198 * @param avrcp_cid 199 * @returns status 200 */ 201 uint8_t avrcp_controller_get_play_status(uint16_t avrcp_cid); 202 203 /** 204 * @brief Enable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE. 205 * @param avrcp_cid 206 * @param event_id 207 * @returns status 208 */ 209 uint8_t avrcp_controller_enable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 210 211 /** 212 * @brief Disable notification. Response via AVRCP_SUBEVENT_ENABLE_NOTIFICATION_COMPLETE. 213 * @param avrcp_cid 214 * @param event_id 215 * @returns status 216 */ 217 uint8_t avrcp_controller_disable_notification(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 218 219 /** 220 * @brief Get info on now playing media. 221 * @param avrcp_cid 222 * @returns status 223 */ 224 uint8_t avrcp_controller_get_now_playing_info(uint16_t avrcp_cid); 225 226 /** 227 * @brief Set absolute volume 0-127 (corresponds to 0-100%). Response via AVRCP_SUBEVENT_SET_ABSOLUTE_VOLUME_RESPONSE 228 * @param avrcp_cid 229 * @returns status 230 */ 231 uint8_t avrcp_controller_set_absolute_volume(uint16_t avrcp_cid, uint8_t volume); 232 233 /** 234 * @brief Turns the volume to high. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 235 * @param avrcp_cid 236 * @returns status 237 */ 238 uint8_t avrcp_controller_volume_up(uint16_t avrcp_cid); 239 240 /** 241 * @brief Turns the volume to low. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 242 * @param avrcp_cid 243 * @returns status 244 */ 245 uint8_t avrcp_controller_volume_down(uint16_t avrcp_cid); 246 247 /** 248 * @brief Puts the sound out. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 249 * @param avrcp_cid 250 * @returns status 251 */ 252 uint8_t avrcp_controller_mute(uint16_t avrcp_cid); 253 254 /** 255 * @brief Skip to next playing media. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 256 * @param avrcp_cid 257 * @returns status 258 */ 259 uint8_t avrcp_controller_skip(uint16_t avrcp_cid); 260 261 /** 262 * @brief Query repeat and shuffle mode. Response via AVRCP_SUBEVENT_SHUFFLE_AND_REPEAT_MODE. 263 * @param avrcp_cid 264 * @returns status 265 */ 266 uint8_t avrcp_controller_query_shuffle_and_repeat_modes(uint16_t avrcp_cid); 267 268 /** 269 * @brief Set shuffle mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 270 * @param avrcp_cid 271 * @returns status 272 */ 273 uint8_t avrcp_controller_set_shuffle_mode(uint16_t avrcp_cid, avrcp_shuffle_mode_t mode); 274 275 /** 276 * @brief Set repeat mode. Event AVRCP_SUBEVENT_OPERATION_COMPLETE returns operation id and status. 277 * @param avrcp_cid 278 * @returns status 279 */ 280 uint8_t avrcp_controller_set_repeat_mode(uint16_t avrcp_cid, avrcp_repeat_mode_t mode); 281 282 /* API_END */ 283 #if defined __cplusplus 284 } 285 #endif 286 287 #endif // __AVRCP_CONTROLLER_H