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