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_browsing_controller.h 40 * 41 * Audio/Video Remote Control Profile Browsing 42 * 43 */ 44 45 #ifndef AVRCP_BROWSING_CONTROLLER_H 46 #define AVRCP_BROWSING_CONTROLLER_H 47 48 #include <stdint.h> 49 #include "classic/avrcp.h" 50 51 #if defined __cplusplus 52 extern "C" { 53 #endif 54 55 56 /* API_START */ 57 typedef enum { 58 AVRCP_BROWSING_MEDIA_PLAYER_ITEM = 0x01, 59 AVRCP_BROWSING_FOLDER_ITEM, 60 AVRCP_BROWSING_MEDIA_ELEMENT_ITEM, 61 AVRCP_BROWSING_MEDIA_ROOT_FOLDER, 62 AVRCP_BROWSING_MEDIA_ELEMENT_ITEM_ATTRIBUTE 63 } avrcp_browsing_item_type_t; 64 65 typedef enum { 66 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_AUDIO = 1, 67 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_VIDEO = 2, 68 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_BROADCASTING_AUDIO = 4, 69 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_BROADCASTING_VIDEO = 8 70 } avrcp_browsing_media_player_major_type_t; 71 72 typedef enum { 73 AVRCP_BROWSING_MEDIA_PLAYER_SUBTYPE_AUDIO_BOOK = 1, 74 AVRCP_BROWSING_MEDIA_PLAYER_SUBTYPE_POADCAST = 2 75 } avrcp_browsing_media_player_subtype_t; 76 77 typedef enum { 78 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_STOPPED = 0, 79 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_PLAYING, 80 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_PAUSED, 81 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_FWD_SEEK, 82 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_REV_SEEK, 83 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_ERROR = 0xFF 84 } avrcp_browsing_media_player_status_t; 85 86 typedef enum { 87 AVRCP_BROWSING_FOLDER_TYPE_MIXED = 0x00, 88 AVRCP_BROWSING_FOLDER_TYPE_TITLES, 89 AVRCP_BROWSING_FOLDER_TYPE_ALBUMS, 90 AVRCP_BROWSING_FOLDER_TYPE_ARTISTS, 91 AVRCP_BROWSING_FOLDER_TYPE_GENRES, 92 AVRCP_BROWSING_FOLDER_TYPE_PLAYLISTS, 93 AVRCP_BROWSING_FOLDER_TYPE_YEARS 94 } avrcp_browsing_folder_type_t; 95 96 typedef enum { 97 AVRCP_BROWSING_MEDIA_TYPE_AUDIO = 0x00, 98 AVRCP_BROWSING_MEDIA_TYPE_VIDEO 99 } avrcp_browsing_media_type_t; 100 101 /** 102 * @brief Set up AVRCP Browsing Controller device. 103 */ 104 void avrcp_browsing_controller_init(void); 105 106 /** 107 * @brief Register callback for the AVRCP Browsing Controller client. 108 * @param callback 109 */ 110 void avrcp_browsing_controller_register_packet_handler(btstack_packet_handler_t callback); 111 112 /** 113 * @brief Connect to device with a Bluetooth address. 114 * @param bd_addr 115 * @param ertm_buffer 116 * @param ertm_buffer_size 117 * @param ertm_config 118 * @param avrcp_browsing_cid 119 * @returns status 120 */ 121 uint8_t avrcp_browsing_controller_connect(bd_addr_t bd_addr, uint8_t * ertm_buffer, uint32_t size, l2cap_ertm_config_t * ertm_config, uint16_t * avrcp_browsing_cid); 122 123 /** 124 * @brief Configure incoming connection. 125 * @param avrcp_browsing_cid 126 * @param ertm_buffer 127 * @param ertm_buffer_size 128 * @param ertm_config 129 * @returns status 130 */ 131 uint8_t avrcp_browsing_controller_configure_incoming_connection(uint16_t avrcp_browsing_cid, uint8_t * ertm_buffer, uint32_t size, l2cap_ertm_config_t * ertm_config); 132 133 /** 134 * @brief Decline incoming connection. 135 * @param avrcp_browsing_cid 136 * @returns status 137 */ 138 uint8_t avrcp_browsing_controller_decline_incoming_connection(uint16_t avrcp_browsing_cid); 139 140 141 /** 142 * @brief Disconnect from AVRCP target 143 * @param avrcp_browsing_cid 144 * @returns status 145 */ 146 uint8_t avrcp_browsing_controller_disconnect(uint16_t avrcp_browsing_cid); 147 148 /** 149 * @brief Retrieve a list of media players. 150 * @param avrcp_browsing_cid 151 * @param start_item 152 * @param end_item 153 * @param attr_bitmap Use AVRCP_MEDIA_ATTR_ALL for all, and AVRCP_MEDIA_ATTR_NONE for none. Otherwise, see avrcp_media_attribute_id_t for the bitmap position of attrs. 154 **/ 155 uint8_t avrcp_browsing_controller_get_media_players(uint16_t avrcp_browsing_cid, uint32_t start_item, uint32_t end_item, uint32_t attr_bitmap); 156 157 /** 158 * @brief Retrieve a list of folders and media items of the browsed player. 159 * @param avrcp_browsing_cid 160 * @param start_item 161 * @param end_item 162 * @param attr_bitmap Use AVRCP_MEDIA_ATTR_ALL for all, and AVRCP_MEDIA_ATTR_NONE for none. Otherwise, see avrcp_media_attribute_id_t for the bitmap position of attrs. 163 **/ 164 uint8_t avrcp_browsing_controller_browse_file_system(uint16_t avrcp_browsing_cid, uint32_t start_item, uint32_t end_item, uint32_t attr_bitmap); 165 166 /** 167 * @brief Retrieve a list of media items of the browsed player. 168 * @param avrcp_browsing_cid 169 * @param start_item 170 * @param end_item 171 * @param attr_bitmap Use AVRCP_MEDIA_ATTR_ALL for all, and AVRCP_MEDIA_ATTR_NONE for none. Otherwise, see avrcp_media_attribute_id_t for the bitmap position of attrs. 172 **/ 173 uint8_t avrcp_browsing_controller_browse_media(uint16_t avrcp_browsing_cid, uint32_t start_item, uint32_t end_item, uint32_t attr_bitmap); 174 175 /** 176 * @brief Retrieve a list of folders and media items of the addressed player. 177 * @param avrcp_browsing_cid 178 * @param start_item 179 * @param end_item 180 * @param attr_bitmap Use AVRCP_MEDIA_ATTR_ALL for all, and AVRCP_MEDIA_ATTR_NONE for none. Otherwise, see avrcp_media_attribute_id_t for the bitmap position of attrs. 181 **/ 182 uint8_t avrcp_browsing_controller_browse_now_playing_list(uint16_t avrcp_browsing_cid, uint32_t start_item, uint32_t end_item, uint32_t attr_bitmap); 183 184 /** 185 * @brief Set browsed player. Calling this command is required prior to browsing the player's file system. Some players may support browsing only when set as the Addressed Player. 186 * @param avrcp_browsing_cid 187 * @param browsed_player_id 188 */ 189 uint8_t avrcp_browsing_controller_set_browsed_player(uint16_t avrcp_browsing_cid, uint16_t browsed_player_id); 190 191 /** 192 * @brief Get total num attributes 193 * @param avrcp_browsing_cid 194 * @param scope 195 */ 196 uint8_t avrcp_browsing_controller_get_total_nr_items_for_scope(uint16_t avrcp_browsing_cid, avrcp_browsing_scope_t scope); 197 198 /** 199 * @brief Navigate one level up or down in thhe virtual filesystem. Requires that s browsed player is set. 200 * @param avrcp_browsing_cid 201 * @param direction 0-folder up, 1-folder down 202 * @param folder_uid 8 bytes long 203 **/ 204 uint8_t avrcp_browsing_controller_change_path(uint16_t avrcp_browsing_cid, uint8_t direction, uint8_t * folder_uid); 205 uint8_t avrcp_browsing_controller_go_up_one_level(uint16_t avrcp_browsing_cid); 206 uint8_t avrcp_browsing_controller_go_down_one_level(uint16_t avrcp_browsing_cid, uint8_t * folder_uid); 207 208 209 /** 210 * @brief Retrives metadata information (title, artist, album, ...) about a media element with given uid. 211 * @param avrcp_browsing_cid 212 * @param uid media element uid 213 * @param uid_counter Used to detect change to the media database on target device. A TG device that supports the UID Counter shall update the value of the counter on each change to the media database. 214 * @param attr_bitmap 0x00000000 - retrieve all, chek avrcp_media_attribute_id_t in avrcp.h for detailed bit position description. 215 * @param scope check avrcp_browsing_scope_t in avrcp.h 216 **/ 217 uint8_t avrcp_browsing_controller_get_item_attributes_for_scope(uint16_t avrcp_browsing_cid, uint8_t * uid, uint16_t uid_counter, uint32_t attr_bitmap, avrcp_browsing_scope_t scope); 218 219 /** 220 * @brief Searches are performed from the current folder in the Browsed Players virtual filesystem. The search applies to the current folder and all folders below that. 221 * @param avrcp_browsing_cid 222 * @param search_str_len 223 * @param search_str 224 * @return status 225 **/ 226 uint8_t avrcp_browsing_controller_search(uint16_t avrcp_browsing_cid, uint16_t search_str_len, char * search_str); 227 228 /* API_END */ 229 230 #if defined __cplusplus 231 } 232 #endif 233 234 #endif // AVRCP_BROWSING_CONTROLLER_H 235