1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <vector> 20 21 // AVRCP packets pulled from wireshark 22 namespace { 23 24 // AVRCP Get Capabilities Request packet 25 std::vector<uint8_t> get_capabilities_request = { 26 0x01, 0x48, 0x00, 0x00, 0x19, 0x58, 0x10, 0x00, 0x00, 0x01, 0x03}; 27 28 // AVRCP Get Capabilities Request packet with Company ID 29 std::vector<uint8_t> get_capabilities_request_company_id = { 30 0x01, 0x48, 0x00, 0x00, 0x19, 0x58, 0x10, 0x00, 0x00, 0x01, 0x02}; 31 32 // AVRCP Get Capabilities Request packet with Unknown 33 std::vector<uint8_t> get_capabilities_request_unknown = { 34 0x01, 0x48, 0x00, 0x00, 0x19, 0x58, 0x10, 0x00, 0x00, 0x01, 0x7f}; 35 36 // AVRCP Get Capabilities Response to Company ID request 37 std::vector<uint8_t> get_capabilities_response_company_id = { 38 0x0c, 0x48, 0x00, 0x00, 0x19, 0x58, 0x10, 0x00, 0x00, 39 0x08, 0x02, 0x02, 0x00, 0x19, 0x58, 0x00, 0x23, 0x45}; 40 41 // AVRCP Get Capabilities Response to Events Supported request 42 std::vector<uint8_t> get_capabilities_response_events_supported = { 43 0x0c, 0x48, 0x00, 0x00, 0x19, 0x58, 0x10, 0x00, 44 0x00, 0x05, 0x03, 0x03, 0x01, 0x02, 0x05}; 45 46 // AVRCP Get Element Attributes request for current playing song and attribute 47 // Title 48 std::vector<uint8_t> get_element_attributes_request_partial = { 49 0x01, 0x48, 0x00, 0x00, 0x19, 0x58, 0x20, 0x00, 0x00, 0x0d, 0x00, 0x00, 50 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01}; 51 52 // AVRCP Get Element Attributes request for current playing song and attributes 53 // Title, Artist, Album, Media Number, Playing Time, Total Number of Media, and 54 // Genre 55 std::vector<uint8_t> get_element_attributes_request_full = { 56 0x01, 0x48, 0x00, 0x00, 0x19, 0x58, 0x20, 0x00, 0x00, 0x25, 0x00, 0x00, 57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 58 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 59 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06}; 60 61 // AVRCP Get Element Attributes response with attribute values as follows 62 // Title: "Test Song" 63 // Artist: "Test Artist" 64 // Album: "Test Album" 65 // Track Number: "1" 66 // Number of Tracks: "2" 67 // Genre: "Test Genre" 68 // Duration: "1000" 69 std::vector<uint8_t> get_elements_attributes_response_full = { 70 0x0c, 0x48, 0x00, 0x00, 0x19, 0x58, 0x20, 0x00, 0x00, 0x67, 0x07, 0x00, 71 0x00, 0x00, 0x01, 0x00, 0x6a, 0x00, 0x09, 0x54, 0x65, 0x73, 0x74, 0x20, 72 0x53, 0x6f, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x02, 0x00, 0x6a, 0x00, 0x0b, 73 0x54, 0x65, 0x73, 0x74, 0x20, 0x41, 0x72, 0x74, 0x69, 0x73, 0x74, 0x00, 74 0x00, 0x00, 0x03, 0x00, 0x6a, 0x00, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 75 0x41, 0x6c, 0x62, 0x75, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x00, 0x6a, 0x00, 76 0x01, 0x31, 0x00, 0x00, 0x00, 0x05, 0x00, 0x6a, 0x00, 0x01, 0x32, 0x00, 77 0x00, 0x00, 0x06, 0x00, 0x6a, 0x00, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 78 0x47, 0x65, 0x6e, 0x72, 0x65, 0x00, 0x00, 0x00, 0x07, 0x00, 0x6a, 0x00, 79 0x04, 0x31, 0x30, 0x30, 0x30}; 80 81 // AVRCP Get Play Status Request 82 std::vector<uint8_t> get_play_status_request = {0x01, 0x48, 0x00, 0x00, 0x19, 83 0x58, 0x30, 0x00, 0x00, 0x00}; 84 85 // AVRCP Get Play Status Response 86 std::vector<uint8_t> get_play_status_response = { 87 0x0c, 0x48, 0x00, 0x00, 0x19, 0x58, 0x30, 0x00, 0x00, 0x09, 88 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00}; 89 90 // AVRCP Pass Through Command Play Pushed Request 91 std::vector<uint8_t> pass_through_command_play_pushed = {0x00, 0x48, 0x7c, 0x44, 92 0x00}; 93 94 // AVRCP Pass Through Command Play Pushed Response 95 std::vector<uint8_t> pass_through_command_play_released = {0x09, 0x48, 0x7c, 96 0xc4, 0x00}; 97 98 // AVRCP Register Playback Status Notification 99 std::vector<uint8_t> register_play_status_notification = { 100 0x03, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 101 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x05}; 102 103 // AVRCP Register Volume Changed Notification 104 std::vector<uint8_t> register_volume_changed_notification = { 105 0x03, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 106 0x00, 0x05, 0x0d, 0x00, 0x00, 0x00, 0x00}; 107 108 // AVRCP Interim Playback Status Notification 109 std::vector<uint8_t> interim_play_status_notification = { 110 0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x01, 0x00}; 111 112 // AVRCP Interim Track Changed Notification 113 std::vector<uint8_t> interim_track_changed_notification = { 114 0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x09, 115 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 116 117 // AVRCP Changed Playback Position Notification 118 std::vector<uint8_t> changed_play_pos_notification = { 119 0x0d, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 120 0x00, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00}; 121 122 // AVRCP Interim Now Playing Changed Notification 123 std::vector<uint8_t> interim_now_playing_notification = { 124 0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x01, 0x09}; 125 126 // AVRCP Interim Available Players Changed Notification 127 std::vector<uint8_t> interim_available_players_notification = { 128 0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x01, 0x0a}; 129 130 // AVRCP Interim Addressed Player Changed Notification with active 131 // player ID 1 132 std::vector<uint8_t> interim_addressed_player_notification = { 133 0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 134 0x00, 0x05, 0x0b, 0x00, 0x01, 0x00, 0x00}; 135 136 // AVRCP Interim UIDs Changed Notification 137 std::vector<uint8_t> interim_uids_notificaiton = {0x0f, 0x48, 0x00, 0x00, 0x19, 138 0x58, 0x31, 0x00, 0x00, 0x03, 139 0x0c, 0x00, 0x00}; 140 141 // AVRCP Interim Volume Changed Notification with volume at 55% (0x47) 142 std::vector<uint8_t> interim_volume_changed_notification = { 143 0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x0d, 0x47}; 144 145 // AVRCP Rejected Volume Changed Notification with volume at 0% 146 std::vector<uint8_t> rejected_volume_changed_notification = { 147 0x0a, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x0d, 0x00}; 148 149 // AVRCP Changed Volume Changed Notification with volume at 55% (0x47) 150 std::vector<uint8_t> changed_volume_changed_notification = { 151 0x0d, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x0d, 0x47}; 152 153 // AVRCP Reject List Player Application Settings Response 154 std::vector<uint8_t> reject_player_app_settings_response = { 155 0x0a, 0x48, 0x00, 0x00, 0x19, 0x58, 0x11, 0x00, 0x00, 0x01, 0x00}; 156 157 // AVRCP Browse General Reject packet for invalid PDU ID 158 std::vector<uint8_t> general_reject_invalid_command_packet = {0xa0, 0x00, 0x01, 159 0x00}; 160 161 // AVRCP Browse Get Folder Items Request packet for media players with 162 // the following data: 163 // scope = 0x00 (Media Player List) 164 // start_item = 0x00 165 // end_item = 0x03 166 // attributes_requested: all 167 std::vector<uint8_t> get_folder_items_request = {0x71, 0x00, 0x0a, 0x00, 0x00, 168 0x00, 0x00, 0x00, 0x00, 0x00, 169 0x00, 0x03, 0x00}; 170 171 // AVRCP Browse Get Folder Items Request packet for media players with 172 // the following data: 173 // scope = 0x01 (VFS) 174 // start_item = 0x00 175 // end_item = 0x09 176 // attributes_requested: none 177 std::vector<uint8_t> get_folder_items_request_no_attrs = { 178 0x71, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x00, 179 0x00, 0x00, 0x00, 0x00, 0x09, 0xff}; 180 181 // AVRCP Browse Get Folder Items Request packet for media players with 182 // the following data: 183 // scope = 0x01 (VFS) 184 // start_item = 0x00 185 // end_item = 0x09 186 // attributes_requested: Title 187 std::vector<uint8_t> get_folder_items_request_title = { 188 0x71, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 189 0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x1}; 190 191 // AVRCP Browse Get Folder Items Request packet for vfs with 192 // the following data: 193 // scope = 0x01 (VFS) 194 // start_item = 0x00 195 // end_item = 0x05 196 // attributes_requested: TITLE 197 std::vector<uint8_t> get_folder_items_request_vfs = { 198 0x71, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 199 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x01}; 200 201 // AVRCP Browse Get Folder Items Request packet for now playing with 202 // the following data: 203 // scope = 0x03 (Now Playing) 204 // start_item = 0x00 205 // end_item = 0x05 206 // attributes_requested: All Items 207 std::vector<uint8_t> get_folder_items_request_now_playing = { 208 0x71, 0x00, 0x0e, 0x03, 0x00, 0x00, 0x00, 209 0x00, 0x00, 0x00, 0x00, 0x05, 0x00}; 210 211 // AVRCP Browse Get Folder Items Response packet with range out of bounds error 212 std::vector<uint8_t> get_folder_items_error_response = {0x71, 0x00, 0x01, 0x0b}; 213 214 // AVRCP Browse Get Folder Items Response packet for media players 215 // Contains one media player with the following fields: 216 // id = 0x0001 217 // name = "com.google.android.music" 218 // browsing_supported = true 219 std::vector<uint8_t> get_folder_items_media_player_response = { 220 0x71, 0x00, 0x3c, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x34, 221 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 222 0x00, 0x00, 0xb7, 0x01, 0x0c, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 223 0x00, 0x00, 0x00, 0x6a, 0x00, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 224 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 225 0x69, 0x64, 0x2e, 0x6d, 0x75, 0x73, 0x69, 0x63}; 226 227 // AVRCP Browse Get Folder Items Response packet with one folder 228 // with the following fields: 229 // uid = 0x0000000000000001 230 // type = 0x00 (Mixed); 231 // name = "Test Folder" 232 // is_playable = true 233 std::vector<uint8_t> get_folder_items_folder_response = { 234 0x71, 0x00, 0x21, 0x04, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x19, 0x00, 235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x6a, 0x00, 236 0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x46, 0x6f, 0x6c, 0x64, 0x65, 0x72}; 237 238 // AVRCP Browse Get Folder Items Response packet with one song 239 // with the following fields: 240 // uid = 0x0000000000000002 241 // name = "Test Title" 242 // attribute[TITLE] = "Test Title" 243 std::vector<uint8_t> get_folder_items_song_response = { 244 0x71, 0x00, 0x32, 0x04, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x2a, 245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x6a, 246 0x00, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 0x54, 0x69, 0x74, 0x6c, 247 0x65, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x6a, 0x00, 0x0a, 0x54, 248 0x65, 0x73, 0x74, 0x20, 0x54, 0x69, 0x74, 0x6c, 0x65}; 249 250 // AVRCP Browse Change Path Request down to folder with UID 0x0000000000000002 251 std::vector<uint8_t> change_path_request = {0x72, 0x00, 0x0b, 0x00, 0x00, 252 0x01, 0x00, 0x00, 0x00, 0x00, 253 0x00, 0x00, 0x00, 0x02}; 254 255 // AVRCP Browse Change Path Request up 256 std::vector<uint8_t> change_path_up_request = {0x72, 0x00, 0x0b, 0x00, 0x00, 257 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 258 0xFF, 0xFF, 0xFF, 0xFF}; 259 260 // AVRCP Browse Change Path Response with two items in current folder 261 std::vector<uint8_t> change_path_response = {0x72, 0x00, 0x05, 0x04, 262 0x00, 0x00, 0x00, 0x02}; 263 264 // AVRCP Browse Change Path Response with an error of invalid direction 265 std::vector<uint8_t> change_path_error_response = {0x72, 0x00, 0x01, 0x07}; 266 267 // AVRCP Get Item Attributes request with all attributes requested 268 // with the following fields: 269 // scope = 0x03 (Now Playing List) 270 // uid_counter = 0x0000 271 // uid = 0x0000000000000001 272 std::vector<uint8_t> get_item_attributes_request_all_attributes = { 273 0x73, 0x00, 0x28, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 274 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 275 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 276 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07}; 277 278 // AVRCP Get Item Attributes request with all attributes requested 279 // with the following fields: 280 // scope = 0x03 (Now Playing List) 281 // uid_counter = 0x0001 282 // uid = 0x0000000000000001 283 std::vector<uint8_t> get_item_attributes_request_all_attributes_invalid = { 284 0x73, 0x00, 0x28, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 285 0x01, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 286 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 287 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07}; 288 289 // AVRCP Get Item Attributes Response with the following attributes: 290 // title = "Test Song" 291 // artist = "Test Artist" 292 // album = "Test Album" 293 std::vector<uint8_t> get_item_attributes_song_response = { 294 0x73, 0x00, 0x38, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x6a, 0x00, 295 0x09, 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x6f, 0x6e, 0x67, 0x00, 0x00, 296 0x00, 0x02, 0x00, 0x6a, 0x00, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x41, 297 0x72, 0x74, 0x69, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x00, 0x6a, 0x00, 298 0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 0x41, 0x6c, 0x62, 0x75, 0x6d}; 299 300 // AVRCP Set Addressed Player Request with player_id = 1 301 std::vector<uint8_t> set_addressed_player_request = { 302 0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x02, 0x00, 0x01}; 303 304 // AVRCP Set Addressed Player Response with status success 305 std::vector<uint8_t> set_addressed_player_response = { 306 0x09, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x01, 0x04}; 307 308 // AVRCP Set Browsed Player Request with player_id = 2 309 std::vector<uint8_t> set_browsed_player_request = {0x70, 0x00, 0x02, 0x00, 310 0x02}; 311 312 // AVRCP Set Browsed Player Response with num items = 4 and depth = 0 313 std::vector<uint8_t> set_browsed_player_response = { 314 0x70, 0x00, 0x0a, 0x04, 0x00, 0x00, 0x00, 315 0x00, 0x00, 0x04, 0x00, 0x6a, 0x00}; 316 317 // AVRCP Get Total Number of Items Request with Scope = Media Player List 318 std::vector<uint8_t> get_total_number_of_items_request_media_players = { 319 0x75, 0x00, 0x01, 0x00}; 320 321 // AVRCP Get Total Number of Items Request with Scope = VFS 322 std::vector<uint8_t> get_total_number_of_items_request_vfs = {0x75, 0x00, 0x01, 323 0x01}; 324 325 // AVRCP Get Total Number of Items Request with Scope = Now Playing List 326 std::vector<uint8_t> get_total_number_of_items_request_now_playing = { 327 0x75, 0x00, 0x01, 0x03}; 328 329 // AVRCP Get Total number of Items Response with 5 items in folder 330 std::vector<uint8_t> get_total_number_of_items_response = { 331 0x75, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05}; 332 333 // AVRCP Play Item Request with scope = Now Playing and 334 // UID = 0x0000000000000003 335 std::vector<uint8_t> play_item_request = { 336 0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x74, 0x00, 0x00, 0x0b, 0x03, 337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00}; 338 339 // AVRCP Play Item Response 340 std::vector<uint8_t> play_item_response = {0x09, 0x48, 0x00, 0x00, 0x19, 0x58, 341 0x74, 0x00, 0x00, 0x01, 0x04}; 342 343 // AVRCP Set Absolute Volume Request with volume at 56% (0x48) 344 std::vector<uint8_t> set_absolute_volume_request = { 345 0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x50, 0x00, 0x00, 0x01, 0x48}; 346 347 // AVRCP Set Absolute Volume Response with voume at 52% (0x43) 348 std::vector<uint8_t> set_absolute_volume_response = { 349 0x09, 0x48, 0x00, 0x00, 0x19, 0x58, 0x50, 0x00, 0x00, 0x01, 0x43}; 350 351 } // namespace 352