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 BLUEKITCHEN 24 * GMBH 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 * @title AVRCP Browsing Controller 40 * 41 */ 42 43 #ifndef AVRCP_BROWSING_CONTROLLER_H 44 #define AVRCP_BROWSING_CONTROLLER_H 45 46 #include <stdint.h> 47 #include "classic/avrcp.h" 48 49 #if defined __cplusplus 50 extern "C" { 51 #endif 52 53 54 /* API_START */ 55 typedef enum { 56 AVRCP_BROWSING_MEDIA_PLAYER_ITEM = 0x01, 57 AVRCP_BROWSING_FOLDER_ITEM, 58 AVRCP_BROWSING_MEDIA_ELEMENT_ITEM, 59 AVRCP_BROWSING_MEDIA_ROOT_FOLDER, 60 AVRCP_BROWSING_MEDIA_ELEMENT_ITEM_ATTRIBUTE 61 } avrcp_browsing_item_type_t; 62 63 typedef enum { 64 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_AUDIO = 1, 65 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_VIDEO = 2, 66 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_BROADCASTING_AUDIO = 4, 67 AVRCP_BROWSING_MEDIA_PLAYER_MAJOR_TYPE_BROADCASTING_VIDEO = 8 68 } avrcp_browsing_media_player_major_type_t; 69 70 typedef enum { 71 AVRCP_BROWSING_MEDIA_PLAYER_SUBTYPE_AUDIO_BOOK = 1, 72 AVRCP_BROWSING_MEDIA_PLAYER_SUBTYPE_POADCAST = 2 73 } avrcp_browsing_media_player_subtype_t; 74 75 typedef enum { 76 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_STOPPED = 0, 77 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_PLAYING, 78 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_PAUSED, 79 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_FWD_SEEK, 80 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_REV_SEEK, 81 AVRCP_BROWSING_MEDIA_PLAYER_STATUS_ERROR = 0xFF 82 } avrcp_browsing_media_player_status_t; 83 84 typedef enum { 85 AVRCP_BROWSING_FOLDER_TYPE_MIXED = 0x00, 86 AVRCP_BROWSING_FOLDER_TYPE_TITLES, 87 AVRCP_BROWSING_FOLDER_TYPE_ALBUMS, 88 AVRCP_BROWSING_FOLDER_TYPE_ARTISTS, 89 AVRCP_BROWSING_FOLDER_TYPE_GENRES, 90 AVRCP_BROWSING_FOLDER_TYPE_PLAYLISTS, 91 AVRCP_BROWSING_FOLDER_TYPE_YEARS 92 } avrcp_browsing_folder_type_t; 93 94 typedef enum { 95 AVRCP_BROWSING_MEDIA_TYPE_AUDIO = 0x00, 96 AVRCP_BROWSING_MEDIA_TYPE_VIDEO 97 } avrcp_browsing_media_type_t; 98 99 /** 100 * @brief Set up AVRCP Browsing Controller device. 101 */ 102 void avrcp_browsing_controller_init(void); 103 104 /** 105 * @brief Register callback for the AVRCP Browsing Controller client. 106 * @param callback 107 */ 108 void avrcp_browsing_controller_register_packet_handler(btstack_packet_handler_t callback); 109 110 /** 111 * @brief Retrieve a list of media players. 112 * @param avrcp_browsing_cid 113 * @param start_item 114 * @param end_item 115 * @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. 116 **/ 117 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); 118 119 /** 120 * @brief Retrieve a list of folders and media items of the browsed player. 121 * @param avrcp_browsing_cid 122 * @param start_item 123 * @param end_item 124 * @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. 125 **/ 126 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); 127 128 /** 129 * @brief Retrieve a list of media items of the browsed player. 130 * @param avrcp_browsing_cid 131 * @param start_item 132 * @param end_item 133 * @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. 134 **/ 135 uint8_t avrcp_browsing_controller_browse_media(uint16_t avrcp_browsing_cid, uint32_t start_item, uint32_t end_item, uint32_t attr_bitmap); 136 137 /** 138 * @brief Retrieve a list of folders and media items of the addressed player. 139 * @param avrcp_browsing_cid 140 * @param start_item 141 * @param end_item 142 * @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. 143 **/ 144 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); 145 146 /** 147 * @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. 148 * @param avrcp_browsing_cid 149 * @param browsed_player_id 150 */ 151 uint8_t avrcp_browsing_controller_set_browsed_player(uint16_t avrcp_browsing_cid, uint16_t browsed_player_id); 152 153 /** 154 * @brief Get total num attributes 155 * @param avrcp_browsing_cid 156 * @param scope 157 */ 158 uint8_t avrcp_browsing_controller_get_total_nr_items_for_scope(uint16_t avrcp_browsing_cid, avrcp_browsing_scope_t scope); 159 160 /** 161 * @brief Navigate one level up or down in thhe virtual filesystem. Requires that s browsed player is set. 162 * @param avrcp_browsing_cid 163 * @param direction 0-folder up, 1-folder down 164 * @param folder_uid 8 bytes long 165 **/ 166 uint8_t avrcp_browsing_controller_change_path(uint16_t avrcp_browsing_cid, uint8_t direction, uint8_t * folder_uid); 167 uint8_t avrcp_browsing_controller_go_up_one_level(uint16_t avrcp_browsing_cid); 168 uint8_t avrcp_browsing_controller_go_down_one_level(uint16_t avrcp_browsing_cid, uint8_t * folder_uid); 169 170 171 /** 172 * @brief Retrives metadata information (title, artist, album, ...) about a media element with given uid. 173 * @param avrcp_browsing_cid 174 * @param uid media element uid 175 * @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. 176 * @param attr_bitmap 0x00000000 - retrieve all, chek avrcp_media_attribute_id_t in avrcp.h for detailed bit position description. 177 * @param scope check avrcp_browsing_scope_t in avrcp.h 178 **/ 179 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); 180 181 /** 182 * @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. 183 * @param avrcp_browsing_cid 184 * @param search_str_len 185 * @param search_str 186 * @return status 187 **/ 188 uint8_t avrcp_browsing_controller_search(uint16_t avrcp_browsing_cid, uint16_t search_str_len, char * search_str); 189 190 /** 191 * @brief De-Init AVRCP Browsing Controller 192 */ 193 void avrcp_browsing_controller_deinit(void); 194 195 /* API_END */ 196 197 #if defined __cplusplus 198 } 199 #endif 200 201 #endif // AVRCP_BROWSING_CONTROLLER_H 202