avrcp_test_packets.h revision 10c628697efecba73211998334f1f9acb9b2c9b8
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 Rejected Volume Changed Notification with volume at 0%
138std::vector<uint8_t> rejected_volume_changed_notification = {
139    0x0a, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x0d, 0x00};
140
141// AVRCP Changed Volume Changed Notification with volume at 55% (0x47)
142std::vector<uint8_t> changed_volume_changed_notification = {
143    0x0d, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x0d, 0x47};
144
145// AVRCP Reject List Player Application Settings Response
146std::vector<uint8_t> reject_player_app_settings_response = {
147    0x0a, 0x48, 0x00, 0x00, 0x19, 0x58, 0x11, 0x00, 0x00, 0x01, 0x00};
148
149// AVRCP Browse Get Folder Items Request packet for media players with
150// the following data:
151//    scope = 0x00 (Media Player List)
152//    start_item = 0x00
153//    end_item = 0x03
154//    attributes_requested: all
155std::vector<uint8_t> get_folder_items_request = {0x71, 0x00, 0x0a, 0x00, 0x00,
156                                                 0x00, 0x00, 0x00, 0x00, 0x00,
157                                                 0x00, 0x03, 0x00};
158
159// AVRCP Browse Get Folder Items Request packet for media players with
160// the following data:
161//    scope = 0x01 (VFS)
162//    start_item = 0x00
163//    end_item = 0x09
164//    attributes_requested: none
165std::vector<uint8_t> get_folder_items_request_no_attrs = {
166    0x71, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x00,
167    0x00, 0x00, 0x00, 0x00, 0x09, 0xff};
168
169// AVRCP Browse Get Folder Items Request packet for media players with
170// the following data:
171//    scope = 0x01 (VFS)
172//    start_item = 0x00
173//    end_item = 0x09
174//    attributes_requested: Title
175std::vector<uint8_t> get_folder_items_request_title = {
176    0x71, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
177    0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x1};
178
179// AVRCP Browse Get Folder Items Request packet for vfs with
180// the following data:
181//    scope = 0x01 (VFS)
182//    start_item = 0x00
183//    end_item = 0x05
184//    attributes_requested: TITLE
185std::vector<uint8_t> get_folder_items_request_vfs = {
186    0x71, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
187    0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x01};
188
189// AVRCP Browse Get Folder Items Request packet for now playing with
190// the following data:
191//    scope = 0x03 (Now Playing)
192//    start_item = 0x00
193//    end_item = 0x05
194//    attributes_requested: All Items
195std::vector<uint8_t> get_folder_items_request_now_playing = {
196    0x71, 0x00, 0x0e, 0x03, 0x00, 0x00, 0x00,
197    0x00, 0x00, 0x00, 0x00, 0x05, 0x00};
198
199// AVRCP Browse Get Folder Items Response packet with range out of bounds error
200std::vector<uint8_t> get_folder_items_error_response = {0x71, 0x00, 0x01, 0x0b};
201
202// AVRCP Browse Get Folder Items Response packet for media players
203// Contains one media player with the following fields:
204//    id = 0x0001
205//    name = "com.google.android.music"
206//    browsing_supported = true
207std::vector<uint8_t> get_folder_items_media_player_response = {
208    0x71, 0x00, 0x3c, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x34,
209    0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
210    0x00, 0x00, 0xb7, 0x01, 0x0c, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
211    0x00, 0x00, 0x00, 0x6a, 0x00, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x67,
212    0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f,
213    0x69, 0x64, 0x2e, 0x6d, 0x75, 0x73, 0x69, 0x63};
214
215// AVRCP Browse Get Folder Items Response packet with one folder
216// with the following fields:
217//    uid = 0x0000000000000001
218//    type = 0x00 (Mixed);
219//    name = "Test Folder"
220//    is_playable = true
221std::vector<uint8_t> get_folder_items_folder_response = {
222    0x71, 0x00, 0x21, 0x04, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x19, 0x00,
223    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x6a, 0x00,
224    0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x46, 0x6f, 0x6c, 0x64, 0x65, 0x72};
225
226// AVRCP Browse Get Folder Items Response packet with one song
227// with the following fields:
228//    uid = 0x0000000000000002
229//    name = "Test Title"
230//    attribute[TITLE] = "Test Title"
231std::vector<uint8_t> get_folder_items_song_response = {
232    0x71, 0x00, 0x32, 0x04, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x2a,
233    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x6a,
234    0x00, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 0x54, 0x69, 0x74, 0x6c,
235    0x65, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x6a, 0x00, 0x0a, 0x54,
236    0x65, 0x73, 0x74, 0x20, 0x54, 0x69, 0x74, 0x6c, 0x65};
237
238// AVRCP Browse Change Path Request down to folder with UID 0x0000000000000002
239std::vector<uint8_t> change_path_request = {0x72, 0x00, 0x0b, 0x00, 0x00,
240                                            0x01, 0x00, 0x00, 0x00, 0x00,
241                                            0x00, 0x00, 0x00, 0x02};
242
243// AVRCP Browse Change Path Request up
244std::vector<uint8_t> change_path_up_request = {0x72, 0x00, 0x0b, 0x00, 0x00,
245                                               0x00, 0xFF, 0xFF, 0xFF, 0xFF,
246                                               0xFF, 0xFF, 0xFF, 0xFF};
247
248// AVRCP Browse Change Path Response with two items in current folder
249std::vector<uint8_t> change_path_response = {0x72, 0x00, 0x05, 0x04,
250                                             0x00, 0x00, 0x00, 0x02};
251
252// AVRCP Browse Change Path Response with an error of invalid direction
253std::vector<uint8_t> change_path_error_response = {0x72, 0x00, 0x01, 0x07};
254
255// AVRCP Get Item Attributes request with all attributes requested
256// with the following fields:
257//    scope = 0x03 (Now Playing List)
258//    uid_counter = 0x0000
259//    uid = 0x0000000000000001
260std::vector<uint8_t> get_item_attributes_request_all_attributes = {
261    0x73, 0x00, 0x28, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262    0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
263    0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
264    0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07};
265
266// AVRCP Get Item Attributes Response with the following attributes:
267//    title = "Test Song"
268//    artist = "Test Artist"
269//    album = "Test Album"
270std::vector<uint8_t> get_item_attributes_song_response = {
271    0x73, 0x00, 0x38, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x6a, 0x00,
272    0x09, 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x6f, 0x6e, 0x67, 0x00, 0x00,
273    0x00, 0x02, 0x00, 0x6a, 0x00, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x20, 0x41,
274    0x72, 0x74, 0x69, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x00, 0x6a, 0x00,
275    0x0a, 0x54, 0x65, 0x73, 0x74, 0x20, 0x41, 0x6c, 0x62, 0x75, 0x6d};
276
277// AVRCP Set Addressed Player Request with player_id = 1
278std::vector<uint8_t> set_addressed_player_request = {
279    0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x02, 0x00, 0x01};
280
281// AVRCP Set Addressed Player Response with status success
282std::vector<uint8_t> set_addressed_player_response = {
283    0x09, 0x48, 0x00, 0x00, 0x19, 0x58, 0x60, 0x00, 0x00, 0x01, 0x04};
284
285// AVRCP Set Browsed Player Request with player_id = 2
286std::vector<uint8_t> set_browsed_player_request = {0x70, 0x00, 0x02, 0x00,
287                                                   0x02};
288
289// AVRCP Set Browsed Player Response with num items = 4 and depth = 0
290std::vector<uint8_t> set_browsed_player_response = {
291    0x70, 0x00, 0x0a, 0x04, 0x00, 0x00, 0x00,
292    0x00, 0x00, 0x04, 0x00, 0x6a, 0x00};
293
294// AVRCP Get Total Number of Items Request with Scope = Media Player List
295std::vector<uint8_t> get_total_number_of_items_request_media_players = {
296    0x75, 0x00, 0x01, 0x00};
297
298// AVRCP Get Total Number of Items Request with Scope = VFS
299std::vector<uint8_t> get_total_number_of_items_request_vfs = {0x75, 0x00, 0x01,
300                                                              0x01};
301
302// AVRCP Get Total Number of Items Request with Scope = Now Playing List
303std::vector<uint8_t> get_total_number_of_items_request_now_playing = {
304    0x75, 0x00, 0x01, 0x03};
305
306// AVRCP Get Total number of Items Response with 5 items in folder
307std::vector<uint8_t> get_total_number_of_items_response = {
308    0x75, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05};
309
310// AVRCP Play Item Request with scope = Now Playing and
311// UID = 0x0000000000000003
312std::vector<uint8_t> play_item_request = {
313    0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x74, 0x00, 0x00, 0x0b, 0x03,
314    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00};
315
316// AVRCP Play Item Response
317std::vector<uint8_t> play_item_response = {0x09, 0x48, 0x00, 0x00, 0x19, 0x58,
318                                           0x74, 0x00, 0x00, 0x01, 0x04};
319
320// AVRCP Set Absolute Volume Request with volume at 56% (0x48)
321std::vector<uint8_t> set_absolute_volume_request = {
322    0x00, 0x48, 0x00, 0x00, 0x19, 0x58, 0x50, 0x00, 0x00, 0x01, 0x48};
323
324// AVRCP Set Absolute Volume Response with voume at 52% (0x43)
325std::vector<uint8_t> set_absolute_volume_response = {
326    0x09, 0x48, 0x00, 0x00, 0x19, 0x58, 0x50, 0x00, 0x00, 0x01, 0x43};
327
328}  // namespace
329