1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef AVRCP_TG_BROWSE_H
17 #define AVRCP_TG_BROWSE_H
18 
19 #include "avrcp_media.h"
20 
21 #include "avrcp_tg_packet.h"
22 
23 namespace OHOS {
24 namespace bluetooth {
25 /**
26  * @brief This enumeration declares the values of the <b>BROWSING</b> commands.
27  */
28 enum AvrcTgBrowse {
29     AVRC_TG_BROWSE_MIN_SIZE = 0x03,                  // The size of the "PDU ID" + The size of the "Parameter Length".
30     AVRC_TG_BROWSE_PARAMETER_LENGTH = 0x0000,        // The default value of the "Parameter Length".
31     AVRC_TG_BROWSE_UID = 0x0000000000000000,         // The default value of the "UID".
32     AVRC_TG_BROWSE_UID_COUNTER = 0x0000,             // The default value of the "UID Counter".
33     AVRC_TG_BROWSE_FOLDER_UID = 0x0000000000000000,  // The default value of the "Folder UID".
34     AVRC_TG_BROWSE_PARAMETER_LENGTH_OFFSET = 0x01,   // The offset of the "Parameter Length".
35     AVRC_TG_BROWSE_PDU_ID_SIZE = 0x01,               // The size of the "PDU ID".
36     AVRC_TG_BROWSE_PARAMETER_LENGTH_SIZE = 0x02,     // The size of the "Parameter Length".
37     AVRC_TG_BROWSE_STATUS_SIZE = 0x01,               // The size of the "Status".
38 };
39 
40 /**
41  * @brief This class provides a set of methods of assemble / disassemble the packet of the <b>BROWSING</b>
42  * command.
43  * @see Audio/Video Remote Control 1.6.2 Section 5.1.2 Browsing commands.
44  */
45 class AvrcTgBrowsePacket : public AvrcTgPacket {
46 public:
47     /**
48      * @brief A constructor used to create an <b>AvrcTgBrowsePacket</b> instance.
49      */
50     AvrcTgBrowsePacket();
51 
52     /**
53      * @brief A constructor used to create an <b>AvrcTgBrowsePacket</b> instance.
54      */
55     AvrcTgBrowsePacket(uint8_t pduId, uint8_t status, uint8_t label);
56 
57     /**
58      * @brief A destructor used to delete the <b>AvrcTgBrowsePacket</b> instance.
59      */
60     virtual ~AvrcTgBrowsePacket();
61 
62     /**
63      * @brief Assembles the frame packet.
64      *
65      * @details Response frame:<br>
66      *                        msb(7)     lsb(0)<br>
67      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
68      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
69      *                        0 0 0 0 | 0 0 0 0     Other operands                                      n octets<br>
70      * @return The frame packet.
71      */
72     const Packet *AssemblePacket(void) override;
73 
74     /**
75      * @brief Disassembles the frame packet.
76      *
77      * @details Command frame:<br>
78      *                        msb(7)     lsb(0)<br>
79      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
80      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
81      *                        0 0 0 0 | 0 0 0 0     Other operands                                      n octets<br>
82      * @param[in] pkt The frame packet.
83      * @return The result of the method execution.
84      * @retval true  The packet is valid.
85      * @retval false The packet is invalid.
86      */
87     bool DisassemblePacket(Packet *pkt) override;
88 
89     /**
90      * @brief Gets the "PDU ID".
91      *
92      * @return The value of the "PDU ID".
93      */
GetPduId(void)94     uint8_t GetPduId(void) const
95     {
96         return pduId_;
97     }
98 
99     /**
100      * @brief Gets the label.
101      *
102      * @return The value of the label.
103      */
GetLabel(void)104     uint8_t GetLabel(void) const
105     {
106         return label_;
107     }
108 
109     /**
110      * @brief Checks the frame packet is valid or not.
111      *
112      * @return The result of the method execution.
113      * @retval true  The packet is valid.
114      * @retval false The packet is invalid.
115      */
IsValid(void)116     bool IsValid(void) const
117     {
118         return isValid_;
119     }
120 
121 protected:
122     uint8_t pduId_ {AVRC_TG_PDU_ID_INVALID};                      // The value of the "PDU ID".
123     uint16_t parameterLength_ {AVRC_TG_BROWSE_PARAMETER_LENGTH};  // The value of the "Parameter Length".
124     uint8_t status_ {AVRC_ES_CODE_NO_ERROR};                      // The value of the "Status".
125     uint16_t mtu_ {AVRC_TG_DEFAULT_BROWSE_MTU_SIZE};              // The value of the maximum transmission unit.
126     Packet *pkt_ {nullptr};                                       // The frame packet.
127     uint8_t label_ {AVRC_INVALID_LABEL};  // The label which is used to distinguish different call.
128     bool isValid_ {false};                // The packet is valid or not.
129 
130     /**
131      * @brief Checks the "Parameter Length" is valid or not.
132      *
133      * @param[in] pkt The frame packet.
134      * @return The result of the method execution.
135      * @retval true  The "Parameter Length" is valid.
136      * @retval false The "Parameter Length" is invalid.
137      */
138     bool IsValidParameterLength(Packet *pkt);
139 
140     BT_DISALLOW_COPY_AND_ASSIGN(AvrcTgBrowsePacket);
141 };
142 
143 /******************************************************************
144  * SetBrowsedPlayer                                               *
145  ******************************************************************/
146 
147 /**
148  * @brief This enumeration declares the values of the <b>SetBrowsedPlayer</b> command.
149  */
150 enum AvrcTgSbp {
151     AVRC_TG_SBP_FIXED_CMD_PARAMETER_LENGTH = 0x0002,  // The fixed "Parameter Length" of the command frame.
152     AVRC_TG_SBP_FIXED_RSP_PARAMETER_LENGTH = 0x000A,  // The fixed "Parameter Length" of the response frame.
153     AVRC_TG_SBP_PLAYER_ID = 0xFFFF,                   // The default value of the "Player Id".
154     AVRC_TG_SBP_NUMBER_OF_ITEMS = 0x0000,             // The default value of the "Number of Items".
155     AVRC_TG_SBP_FOLDER_DEPTH = 0x03,                  // The default value of the "Folder Depth".
156     AVRC_TG_SBP_FIXED_CMD_FRAME_SIZE = 0x05,          // The fixed size of the command frame.
157     AVRC_TG_SBP_MIN_RSP_FRAME_SIZE = 0x0D,       // The min size of the response frame.(exclude behind "Folder Depth")
158     AVRC_TG_SBP_FOLDER_NAME_LENGTH_SIZE = 0x02,  // The size of the "Folder Name Length".
159 };
160 
161 /**
162  * @brief This class provides a set of methods of assemble / disassemble the packet of the
163  * <b>SetBrowsedPlayer</b> command.
164  * @see Audio/Video Remote Control 1.6.2 Section 6.9.3 SetBrowsedPlayer.
165  */
166 class AvrcTgSbpPacket : public AvrcTgBrowsePacket {
167 public:
168     /**
169      * @brief A constructor used to create an <b>AvrcTgSbpPacket</b> instance.
170      *
171      * @details You can use this constructor when wants to initialize the attributes [mtu], [status], [uidCounter],
172      * [numOfItems], [folderNames] and [label].
173      */
174     AvrcTgSbpPacket(uint16_t mtu, uint8_t status, uint16_t uidCounter, uint32_t numOfItems,
175         const std::vector<std::string> &folderNames, uint8_t label);
176 
177     /**
178      * @brief A constructor used to create an <b>AvrcTgSbpPacket</b> instance.
179      *
180      * @details You can use this constructor when wants to disassemble the packet.
181      */
182     AvrcTgSbpPacket(Packet *pkt, uint8_t label);
183 
184     /**
185      * @brief A destructor used to delete the <b>AvrcTgSbpPacket</b> instance.
186      */
187     ~AvrcTgSbpPacket();
188 
189     /**
190      * @brief Assembles the packet of the frame.
191      *
192      * @details Response frame:<br>
193      *                        msb(7)     lsb(0)<br>
194      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
195      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
196      *                        0 0 0 0 | 0 0 0 0     Status                                              1 octets<br>
197      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
198      *                        0 0 0 0 | 0 0 0 0     Number of Items                                     4 octets<br>
199      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    2 octets<br>
200      *                        0 0 0 0 | 0 0 0 0     Folder Depth                                        1 octets<br>
201      *                        0 0 0 0 | 0 0 0 0     Folder Name Length 1                                2 octets<br>
202      *                        0 0 0 0 | 0 0 0 0     Folder Name 1                                       n octets<br>
203      *                        0 0 0 0 | 0 0 0 0     Folder Name Length n                                2 octets<br>
204      *                        0 0 0 0 | 0 0 0 0     Folder Name n                                       n octets<br>
205      * @return The frame packet.
206      */
207     const Packet *AssemblePacket(void) override;
208 
209     /**
210      * @brief Disassembles the packet of the frame.
211      *
212      * @details Command frame:<br>
213      *                        msb(7)     lsb(0)<br>
214      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
215      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
216      *                        0 0 0 0 | 0 0 0 0     Player Id                                           2 octets<br>
217      * @param[in] pkt The frame packet.
218      * @return The result of the method execution.
219      * @retval true  The packet is valid.
220      * @retval false The packet is invalid.
221      */
222     virtual bool DisassemblePacket(Packet *pkt) override;
223 
224     /**
225      * @brief Gets the unique media player id.
226      *
227      * @return The value of the "Player Id".
228      */
GetPlayerId(void)229     uint16_t GetPlayerId(void) const
230     {
231         return playerId_;
232     }
233 
234 private:
235     uint16_t playerId_ {AVRC_TG_SBP_PLAYER_ID};          // The unique media player id.
236     uint16_t uidCounter_ {AVRC_TG_BROWSE_UID_COUNTER};   // The value of the "UID Counter".
237     uint32_t numOfItems_ {AVRC_TG_SBP_NUMBER_OF_ITEMS};  // The value of the "Number of items".
238     // The value of the "Folder Depth".The root folder has no name and its folder depth is 0.
239     uint8_t folderDepth_ {AVRC_TG_SBP_FOLDER_DEPTH};
240     std::vector<std::string> folderNames_ {};  // The value of the "Folder Name".
241 
242     /**
243      * @brief A constructor used to create an <b>AvrcTgSbpPacket</b> instance.
244      */
245     AvrcTgSbpPacket() = delete;
246 };
247 
248 /******************************************************************
249  * ChangePath                                                     *
250  ******************************************************************/
251 
252 /**
253  * @brief This enumeration declares the values of the <b>ChangePath</b> command.
254  */
255 enum AvrcTgCp {
256     AVRC_TG_CP_FIXED_CMD_PARAMETER_LENGTH = 0x000B,  // The fixed "Parameter Length" of the command frame.
257     AVRC_TG_CP_FIXED_RSP_PARAMETER_LENGTH = 0x0005,  // The fixed "Parameter Length" of the response frame.
258     AVRC_TG_CP_NUMBER_OF_ITEMS = 0x0000,             // The default value of the "Number of Items".
259     AVRC_TG_CP_NUMBER_OF_ITEMS_SIZE = 0x04,          // The size of the "Number of Items".
260     AVRC_TG_CP_FIXED_CMD_FRAME_SIZE = 0x0E,          // The fixed size of the command frame.
261     AVRC_TG_CP_FIXED_RSP_FRAME_SIZE = 0x08,          // The fixed size of the response frame.
262 };
263 
264 /**
265  * @brief This class provides a set of methods of assemble / disassemble the packet of the
266  * <b>ChangePath</b> command.
267  * @see Audio/Video Remote Control 1.6.2 Section 6.10.4.1 ChangePath.
268  */
269 class AvrcTgCpPacket : public AvrcTgBrowsePacket {
270 public:
271     /**
272      * @brief A constructor used to create an <b>AvrcTgCpPacket</b> instance.
273      *
274      * @details You can use this constructor when wants to initialize the attributes [status], [numOfItems] and
275      * [label].
276      */
277     AvrcTgCpPacket(uint8_t status, uint32_t numOfItems, uint8_t label);
278 
279     /**
280      * @brief A constructor used to create an <b>AvrcTgCpPacket</b> instance.
281      *
282      * @details You can use this constructor when wants to disassemble the packet.
283      */
284     AvrcTgCpPacket(Packet *pkt, uint32_t uidCounter, uint8_t label);
285 
286     /**
287      * @brief A destructor used to delete the <b>AvrcTgCpPacket</b> instance.
288      */
289     ~AvrcTgCpPacket();
290 
291     /**
292      * @brief Assembles the packet of the frame.
293      *
294      * @details Response frame:<br>
295      *                        msb(7)     lsb(0)<br>
296      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
297      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
298      *                        0 0 0 0 | 0 0 0 0     Status                                              1 octets<br>
299      *                        0 0 0 0 | 0 0 0 0     Number of Items                                     4 octets<br>
300      * @return The frame packet.
301      */
302     const Packet *AssemblePacket(void) override;
303 
304     /**
305      * @brief Disassembles the packet of the frame.
306      *
307      * @details Command frame:<br>
308      *                        msb(7)     lsb(0)<br>
309      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
310      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
311      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
312      *                        0 0 0 0 | 0 0 0 0     Direction                                           1 octets<br>
313      *                        0 0 0 0 | 0 0 0 0     Folder UID                                          8 octets<br>
314      * @param[in] pkt The frame packet.
315      * @return The result of the method execution.
316      * @retval true  The packet is valid.
317      * @retval false The packet is invalid.
318      */
319     virtual bool DisassemblePacket(Packet *pkt) override;
320 
321     /**
322      * @brief Gets the "UID Counter".
323      *
324      * @return The value of the "UID Counter".
325      */
GetUidCounter(void)326     uint16_t GetUidCounter(void) const
327     {
328         return uidCounter_;
329     }
330 
331     /**
332      * @brief Gets the "Direction".
333      *
334      * @return The value of the "Direction".
335      */
GetDirection(void)336     uint8_t GetDirection(void) const
337     {
338         return direction_;
339     }
340 
341     /**
342      * @brief Gets the "Folder UID".
343      *
344      * @return The value of the "Folder UID".
345      */
GetFolderUid(void)346     uint64_t GetFolderUid(void) const
347     {
348         return folderUid_;
349     }
350 
351 private:
352     uint16_t uidCounter_ {AVRC_TG_BROWSE_UID_COUNTER};   // The value of the "UID Counter".
353     uint8_t direction_ {AVRC_FOLDER_DIRECTION_INVALID};  // The value of the "Direction".
354     uint64_t folderUid_ {AVRC_TG_BROWSE_FOLDER_UID};     // The value of the "Folder UID".
355     uint32_t numOfItems_ {AVRC_TG_CP_NUMBER_OF_ITEMS};   // The value of the "Number of items".
356 
357     /**
358      * @brief A constructor used to create an <b>AvrcTgCpPacket</b> instance.
359      */
360     AvrcTgCpPacket() = delete;
361 };
362 
363 /******************************************************************
364  * GetFolderItems                                                 *
365  ******************************************************************/
366 
367 /**
368  * @brief This enumeration declares the values of the <b>GetFolderItems</b> command.
369  */
370 enum AvrcTgGfi {
371     AVRC_TG_GFI_VALID_FEATURE_OCTETS = 0x10,          // The valid octets of the "Feature Bit Mask".
372     AVRC_TG_GFI_FIXED_CMD_PARAMETER_LENGTH = 0x000A,  // The fixed "Parameter Length" of the command frame.
373     AVRC_TG_GFI_FIXED_RSP_PARAMETER_LENGTH = 0x0005,  // The fixed "Parameter Length" of the response frame.
374     AVRC_TG_GFI_START_ITEM = 0x00000000,              // The default value of the "Start Item".
375     AVRC_TG_GFI_END_ITEM = 0x00000000,                // The default value of the "End Item".
376     AVRC_TG_GFI_ATTRIBUTE_COUNT = 0x00,               // The default value of the "AttributeCount".
377     AVRC_TG_GFI_NUMBER_OF_ITEMS = 0x00,               // The default value of the "Number of Items".
378     AVRC_TG_GFI_ITEM_TYPE_SIZE = 0x01,                // The size of the "Item Type".
379     AVRC_TG_GFI_ITEM_LENGTH_SIZE = 0x02,              // The size of the "Item Length".
380     AVRC_TG_GFI_PLAYER_ID_SIZE = 0x02,                // The size of the "Player Id".
381     AVRC_TG_GFI_MAJOR_PLAYER_TYPE_SIZE = 0x01,        // The size of the "Major Player Type".
382     AVRC_TG_GFI_PLAYER_SUB_TYPE_SIZE = 0x04,          // The size of the "Player Sub Type".
383     AVRC_TG_GFI_PLAY_STATUS_SIZE = 0x01,              // The size of the "Play Status".
384     AVRC_TG_GFI_FEATURE_BIT_MASK = 0x10,              // The size of the "Feature Bit Mask".
385     AVRC_TG_GFI_UID_SIZE = 0x08,                      // The size of the "Folder UID" and the "Media Element UID".
386     AVRC_TG_GFI_TYPE_SIZE = 0x01,                     // The size of the "Folder Type" and the "Media Type".
387     AVRC_TG_GFI_IS_PLAYABLE_SIZE = 0x01,              // The size of the "Is Playable".
388     AVRC_TG_GFI_NUMBER_OF_ATTRIBUTES_SIZE = 0x01,     // The size of the "Number of Attributes".
389     AVRC_TG_GFI_ATTRIBUTE_ID_SIZE = 0x04,             // The size of the "Attribute ID".
390     AVRC_TG_GFI_ATTRIBUTE_VALUE_LENGTH_SIZE = 0x02,   // The size of the "Attribute Value Length".
391     AVRC_TG_GFI_CHARACTER_SET_ID_SIZE = 0x02,         // The size of the "Character Set Id".
392     AVRC_TG_GFI_NAME_LENGTH_SIZE = 0x02,              // The size of the "Displayable Name Length".
393     AVRC_TG_GFI_MIN_CMD_FRAME_SIZE = 0x0D,            // The fixed size of the command frame.
394     AVRC_TG_GFI_MIN_RSP_FRAME_SIZE = 0x03,  // The minimum size of the response frame.(exclude operand behind "Status")
395 };
396 
397 /**
398  * @brief This class provides a set of methods of assemble / disassemble the packet of the
399  * <b>GetFolderItems</b> command.
400  * @see Audio/Video Remote Control 1.6.2 Section 6.10.4.2 GetFolderItems.
401  */
402 class AvrcTgGfiPacket : public AvrcTgBrowsePacket {
403 public:
404     /**
405      * @brief A constructor used to create an <b>AvrcTgGfiPacket</b> instance.
406      *
407      * @details You can use this constructor when wants to initialize the attributes [mtu], [status], [uidCounter],
408      * [status], [items] and [label].
409      */
410     AvrcTgGfiPacket(
411         uint16_t mtu, uint8_t status, uint32_t uidCounter, const std::vector<AvrcMpItem> &items, uint8_t label);
412 
413     /**
414      * @brief A constructor used to create an <b>AvrcTgGfiPacket</b> instance.
415      *
416      * @details You can use this constructor when wants to initialize the attributes [mtu], [status], [uidCounter],
417      * [status], [items] and [label].
418      */
419     AvrcTgGfiPacket(
420         uint16_t mtu, uint8_t status, uint32_t uidCounter, const std::vector<AvrcMeItem> &items, uint8_t label);
421 
422     /**
423      * @brief A constructor used to create an <b>AvrcTgGfiPacket</b> instance.
424      */
425     AvrcTgGfiPacket(Packet *pkt, uint8_t label);
426 
427     /**
428      * @brief A destructor used to delete the <b>AvrcTgGfiPacket</b> instance.
429      */
430     ~AvrcTgGfiPacket();
431 
432     /**
433      * @brief Assembles the packet of the frame.
434      *
435      * @details Response frame:<br>
436      *                        msb(7)     lsb(0)<br>
437      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
438      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
439      *                        0 0 0 0 | 0 0 0 0     Status                                              1 octets<br>
440      *                        0 0 0 0 | 0 0 0 0     Number of Items                                     4 octets<br>
441      * @return The frame packet.
442      */
443     const Packet *AssemblePacket(void) override;
444 
445     /**
446      * @brief Disassembles the packet of the frame.
447      *
448      * @details Command frame:<br>
449      *                        msb(7)     lsb(0)<br>
450      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
451      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
452      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
453      *                        0 0 0 0 | 0 0 0 0     Direction                                           1 octets<br>
454      *                        0 0 0 0 | 0 0 0 0     Folder UID                                          8 octets<br>
455      * @param[in] pkt The frame packet.
456      * @return The result of the method execution.
457      * @retval true  The packet is valid.
458      * @retval false The packet is invalid.
459      */
460     virtual bool DisassemblePacket(Packet *pkt) override;
461 
462     /**
463      * @brief Gets the "Scope".
464      *
465      * @return The value of the "Scope".
466      */
GetScope(void)467     uint8_t GetScope(void) const
468     {
469         return scope_;
470     }
471 
472     /**
473      * @brief Gets the "Start Item".
474      *
475      * @return The value of the "Start Item".
476      */
GetStartItem(void)477     uint32_t GetStartItem(void) const
478     {
479         return startItem_;
480     }
481 
482     /**
483      * @brief Gets the "End Item".
484      *
485      * @return The value of the "End Item".
486      */
GetEndItem(void)487     uint32_t GetEndItem(void) const
488     {
489         return endItem_;
490     }
491 
492     /**
493      * @brief Gets the "Attribute ID".
494      *
495      * @return The value of the "Attribute ID".
496      */
GetAttributes(void)497     const std::vector<uint32_t> &GetAttributes(void) const
498     {
499         return attributes_;
500     }
501 
502 private:
503     uint8_t scope_ {AVRC_MEDIA_SCOPE_INVALID};              // The value of the "Scope".
504     uint32_t startItem_ {AVRC_TG_GFI_START_ITEM};           // The value of the "Start Item".
505     uint32_t endItem_ {AVRC_TG_GFI_END_ITEM};               // The value of the "End Item".
506     uint8_t attributeCount_ {AVRC_TG_GFI_ATTRIBUTE_COUNT};  // The value of the "AttributeCount".
507     std::vector<uint32_t> attributes_ {};                   // The value of the "Attribute ID".
508     uint16_t uidCounter_ {AVRC_TG_BROWSE_UID_COUNTER};      // The value of the "UID Counter".
509     uint16_t numOfItems_ {AVRC_TG_GFI_NUMBER_OF_ITEMS};     // The value of the "Number of Items".
510     std::vector<AvrcMpItem> mpItems_ {};                    // The list of the <b>AvrcCtMpItem</b> class.
511     std::vector<AvrcMeItem> meItems_ {};                    // The list of the <b>AvrcCtMeItem</b> class.
512 
513     /**
514      * @brief A constructor used to create an <b>AvrcTgGfiPacket</b> instance.
515      */
516     AvrcTgGfiPacket() = delete;
517 
518     uint16_t CountMpFrameSize(void);
519 
520     /**
521      * @brief Assembles the packet of the frame.
522      *
523      * @details Response frame:<br>
524      *                        msb(7)     lsb(0)<br>
525      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
526      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
527      *                        0 0 0 0 | 0 0 0 0     Status                                              1 octets<br>
528      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
529      *                        0 0 0 0 | 0 0 0 0     Number of Items                                     1 octets<br>
530      *                        0 0 0 0 | 0 0 0 0     Item Type (Media Element Item)                      1 octets<br>
531      *                        0 0 0 0 | 0 0 0 0     Item Length                                         2 octets<br>
532      *                        0 0 0 0 | 0 0 0 0     Folder UID                                          8 octets<br>
533      *                        0 0 0 0 | 0 0 0 0     Folder Type                                         1 octets<br>
534      *                        0 0 0 0 | 0 0 0 0     Is Playable                                         1 octets<br>
535      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    2 octets<br>
536      *                        0 0 0 0 | 0 0 0 0     Displayable Name Length                             2 octets<br>
537      *                        0 0 0 0 | 0 0 0 0     Displayable Name                                    n octets<br>
538      * @return The frame packet.
539      */
540     Packet *AssembleMpPacket(void);
541 
542     /**
543      * @brief Assembles informations of the media player into the packet.
544      */
545     void AssembleMpItem(uint8_t *buffer, uint16_t offset);
546 
547     uint16_t CountMeFrameSize(void);
548 
549     /**
550      * @brief Assembles the packet of the frame.
551      *
552      * @details Response frame:<br>
553      *                        msb(7)     lsb(0)<br>
554      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
555      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
556      *                        0 0 0 0 | 0 0 0 0     Status                                              1 octets<br>
557      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
558      *
559      *                        0 0 0 0 | 0 0 0 0     Item Type (Media Element Item)                      1 octets<br>
560      *                        0 0 0 0 | 0 0 0 0     Item Length                                         2 octets<br>
561      *
562      *                        0 0 0 0 | 0 0 0 0     Folder UID                                          8 octets<br>
563      *                        0 0 0 0 | 0 0 0 0     Folder Type                                         1 octets<br>
564      *                        0 0 0 0 | 0 0 0 0     Is Playable                                         1 octets<br>
565      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    2 octets<br>
566      *                        0 0 0 0 | 0 0 0 0     Displayable Name Length                             2 octets<br>
567      *                        0 0 0 0 | 0 0 0 0     Displayable Name                                    n octets<br>
568      *
569      *                        0 0 0 0 | 0 0 0 0     Number of Items                                     1 octets<br>
570      *                        0 0 0 0 | 0 0 0 0     Media Element UID                                   8 octets<br>
571      *                        0 0 0 0 | 0 0 0 0     Media Type                                          1 octets<br>
572      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    2 octets<br>
573      *                        0 0 0 0 | 0 0 0 0     Displayable Name Length                             2 octets<br>
574      *                        0 0 0 0 | 0 0 0 0     Displayable Name                                    n octets<br>
575      *                        0 0 0 0 | 0 0 0 0     Number of Attributes                                1 octets<br>
576      *                        0 0 0 0 | 0 0 0 0     Attribute ID 1                                      4 octets<br>
577      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    2 octets<br>
578      *                        0 0 0 0 | 0 0 0 0     Attribute Value Length                              2 octets<br>
579      *                        0 0 0 0 | 0 0 0 0     Attribute Value                                     n octets<br>
580      *                        0 0 0 0 | 0 0 0 0     Attribute ID n                                      n octets<br>
581      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    n octets<br>
582      *                        0 0 0 0 | 0 0 0 0     Attribute Value Length                              n octets<br>
583      *                        0 0 0 0 | 0 0 0 0     Attribute Value                                     n octets<br>
584      * @return The frame packet.
585      */
586     Packet *AssembleMePacket(void);
587 
588     /**
589      * @brief Assembles informations of the media Item into the packet.
590      */
591     void AssembleMeItem(uint8_t *buffer, uint16_t offset);
592 
593     void DisassemblePacketAttributes(Packet *pkt, uint8_t offset);
594 };
595 
596 /******************************************************************
597  * GetItemAttributes                                              *
598  ******************************************************************/
599 
600 /**
601  * @brief This enumeration declares the values of the <b>GetItemAttributes</b> command.
602  */
603 enum AvrcTgGia {
604     AVRC_TG_GIA_FIXED_CMD_PARAMETER_LENGTH = 0x000C,  // The fixed "Parameter Length" of the command frame.
605     AVRC_TG_GIA_FIXED_RSP_PARAMETER_LENGTH = 0x0002,  // The fixed "Parameter Length" of the response frame.
606     AVRC_TG_GIA_NUMBER_OF_ATTRIBUTES = 0x00,          // The default value of the "Number of Attributes".
607     AVRC_TG_GIA_NUMBER_OF_ATTRIBUTES_SIZE = 0x01,     // The size of the "Number of Attributes".
608     AVRC_TG_GIA_ATTRIBUTE_ID_SIZE = 0x04,             // The size of the "Attribute ID".
609     AVRC_TG_GIA_CHARACTER_SET_ID_SIZE = 0x02,         // The size of the "Character Set Id".
610     AVRC_TG_GIA_ATTRIBUTE_VALUE_LENGTH_SIZE = 0x02,   // The size of the "Attribute Value Length".
611     AVRC_TG_GIA_MIN_CMD_FRAME_SIZE = 0x0F,            // The fixed size of the command frame.
612     AVRC_TG_GIA_MIN_RSP_FRAME_SIZE = 0x03,  // The minimum size of the response frame.(exclude operand behind "Status")
613 };
614 
615 /**
616  * @brief This class provides a set of methods of assemble / disassemble the packet of the
617  * <b>GetItemAttributes</b> command.
618  * @see Audio/Video Remote Control 1.6.2 Section 6.10.4.3 GetItemAttributes.
619  */
620 class AvrcTgGiaPacket : public AvrcTgBrowsePacket {
621 public:
622     /**
623      * @brief A constructor used to create an <b>AvrcTgGtnoiPacket</b> instance.
624      *
625      * @details You can use this constructor when wants to initialize the attributes [uidCounter], [status],
626      * [numOfItems] and [label].
627      */
628     AvrcTgGiaPacket(uint16_t mtu, uint8_t status, const std::vector<uint32_t> &attributes,
629         const std::vector<std::string> &values, uint8_t label);
630 
631     /**
632      * @brief A constructor used to create an <b>AvrcTgGtnoiPacket</b> instance.
633      *
634      * @details You can use this constructor when wants to disassemble the packet.
635      */
636     AvrcTgGiaPacket(Packet *pkt, uint32_t uidCounter, uint8_t label);
637 
638     /**
639      * @brief A destructor used to delete the <b>AvrcTgGtnoiPacket</b> instance.
640      */
641     ~AvrcTgGiaPacket();
642 
643     /**
644      * @brief Assembles the packet of the frame.
645      *
646      * @details Response frame:<br>
647      *                        msb(7)     lsb(0)<br>
648      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
649      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
650      *                        0 0 0 0 | 0 0 0 0     Status                                              1 octets<br>
651      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
652      *                        0 0 0 0 | 0 0 0 0     Number of Attributes                                1 octets<br>
653      *                        0 0 0 0 | 0 0 0 0     Attribute ID 1                                      4 octets<br>
654      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    2 octets<br>
655      *                        0 0 0 0 | 0 0 0 0     Attribute Value Length                              2 octets<br>
656      *                        0 0 0 0 | 0 0 0 0     Attribute Value                                     n octets<br>
657      *                        0 0 0 0 | 0 0 0 0     Attribute ID n                                      n octets<br>
658      *                        0 0 0 0 | 0 0 0 0     Character Set Id                                    n octets<br>
659      *                        0 0 0 0 | 0 0 0 0     Attribute Value Length                              n octets<br>
660      *                        0 0 0 0 | 0 0 0 0     Attribute Value                                     n octets<br>
661      * @return The frame packet.
662      */
663     const Packet *AssemblePacket(void) override;
664 
665     /**
666      * @brief Disassembles the packet of the frame.
667      *
668      * @details Command frame:<br>
669      *                        msb(7)     lsb(0)<br>
670      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
671      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
672      *                        0 0 0 0 | 0 0 0 0     Scope                                               1 octets<br>
673      *                        0 0 0 0 | 0 0 0 0     UID                                                 8 octets<br>
674      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
675      *                        0 0 0 0 | 0 0 0 0     Number of Attributes                                1 octets<br>
676      *                        0 0 0 0 | 0 0 0 0     Attribute ID 1                                      4 octets<br>
677      *                        0 0 0 0 | 0 0 0 0     Attribute ID n                                      n octets<br>
678      * @param[in] pkt The frame packet.
679      * @return The result of the method execution.
680      * @retval true  The packet is valid.
681      * @retval false The packet is invalid.
682      */
683     virtual bool DisassemblePacket(Packet *pkt) override;
684 
685     /**
686      * @brief Gets the "Scope".
687      *
688      * @return The value of the "Scope".
689      */
GetScope(void)690     uint8_t GetScope(void) const
691     {
692         return scope_;
693     }
694 
695     /**
696      * @brief Gets the "UID".
697      *
698      * @return The value of the "UID".
699      */
GetUid(void)700     uint16_t GetUid(void) const
701     {
702         return uid_;
703     }
704 
705     /**
706      * @brief Gets the "UID Counter".
707      *
708      * @return The value of the "UID Counter".
709      */
GetUidCounter(void)710     uint16_t GetUidCounter(void) const
711     {
712         return uidCounter_;
713     }
714 
715     /**
716      * @brief Gets the "Attribute ID".
717      *
718      * @return The value of the "Attribute ID".
719      */
GetAttributes(void)720     const std::vector<uint32_t> &GetAttributes(void) const
721     {
722         return attributes_;
723     }
724 
725 private:
726     uint8_t scope_ {AVRC_MEDIA_SCOPE_INVALID};                    // The value of the "Scope".
727     uint64_t uid_ {AVRC_TG_BROWSE_UID};                           // The value of the "UID".
728     uint16_t uidCounter_ {AVRC_TG_BROWSE_UID_COUNTER};            // The value of the "UID Counter".
729     uint8_t numOfAttributes_ {AVRC_TG_GIA_NUMBER_OF_ATTRIBUTES};  // The value of the "Number of Attributes".
730     std::vector<uint32_t> attributes_ {};                         // The value of the "Attribute ID".
731     std::vector<std::string> values_ {};                          // The value of the "Attribute Value".
732 
733     /**
734      * @brief A constructor used to create an <b>AvrcTgGiaPacket</b> instance.
735      */
736     AvrcTgGiaPacket() = delete;
737 
738     void DisassemblePacketAttributes(Packet *pkt, uint8_t offset);
739 };
740 
741 /******************************************************************
742  * GetTotalNumberOfItems                                          *
743  ******************************************************************/
744 
745 /**
746  * @brief This enumeration declares the values of the <b>GetTotalNumberOfItems</b> command.
747  */
748 enum AvrcTgGtnoi {
749     AVRC_TG_GTNOI_FIXED_RSP_PARAMETER_LENGTH = 0x0007,  // The fixed "Parameter Length" of the response frame.
750     AVRC_TG_GTNOI_NUMBER_OF_ITEMS = 0x0000,             // The default value of the "Number of Items".
751     AVRC_TG_GTNOI_FIXED_CMD_FRAME_SIZE = 0x03,          // The fixed size of the command frame.
752     AVRC_TG_GTNOI_FIXED_RSP_FRAME_SIZE = 0x0A,          // The fixed size of the response frame.
753 };
754 
755 /**
756  * @brief This class provides a set of methods of assemble / disassemble the packet of the
757  * <b>GetTotalNumberOfItems</b> command.
758  * @see Audio/Video Remote Control 1.6.2 Section 6.10.4.4 GetTotalNumberOfItems.
759  */
760 class AvrcTgGtnoiPacket : public AvrcTgBrowsePacket {
761 public:
762     /**
763      * @brief A constructor used to create an <b>AvrcTgGtnoiPacket</b> instance.
764      *
765      * @details You can use this constructor when wants to initialize the attributes [uidCounter], [status],
766      * [numOfItems] and [label].
767      */
768     AvrcTgGtnoiPacket(uint8_t status, uint16_t uidCounter, uint32_t numOfItems, uint8_t label);
769 
770     /**
771      * @brief A constructor used to create an <b>AvrcTgGtnoiPacket</b> instance.
772      *
773      * @details You can use this constructor when wants to disassemble the packet.
774      */
775     AvrcTgGtnoiPacket(Packet *pkt, uint8_t label);
776 
777     /**
778      * @brief A destructor used to delete the <b>AvrcTgGtnoiPacket</b> instance.
779      */
780     ~AvrcTgGtnoiPacket();
781 
782     /**
783      * @brief Assembles the packet of the frame.
784      *
785      * @details Response frame:<br>
786      *                        msb(7)     lsb(0)<br>
787      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
788      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
789      *                        0 0 0 0 | 0 0 0 0     Status                                              1 octets<br>
790      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
791      *                        0 0 0 0 | 0 0 0 0     Number of Items                                     4 octets<br>
792      * @return The frame packet.
793      */
794     const Packet *AssemblePacket(void) override;
795 
796     /**
797      * @brief Disassembles the packet of the frame.
798      *
799      * @details Command frame:<br>
800      *                        msb(7)     lsb(0)<br>
801      *                        0 0 0 0 | 0 0 0 0     PDU ID                                              1 octets<br>
802      *                        0 0 0 0 | 0 0 0 0     Parameter Length                                    2 octets<br>
803      *                        0 0 0 0 | 0 0 0 0     UID Counter                                         2 octets<br>
804      *                        0 0 0 0 | 0 0 0 0     Scope                                               1 octets<br>
805      * @param[in] pkt The frame packet.
806      * @return The result of the method execution.
807      * @retval true  The packet is valid.
808      * @retval false The packet is invalid.
809      */
810     virtual bool DisassemblePacket(Packet *pkt) override;
811 
812     /**
813      * @brief Gets the "Scope".
814      *
815      * @return The value of the "Scope".
816      */
GetScope(void)817     uint8_t GetScope(void) const
818     {
819         return scope_;
820     }
821 
822 private:
823     uint8_t scope_ {AVRC_MEDIA_SCOPE_INVALID};             // The value of the "Scope".
824     uint16_t uidCounter_ {AVRC_TG_BROWSE_UID_COUNTER};     // The value of the "UID Counter".
825     uint32_t numOfItems_ {AVRC_TG_GTNOI_NUMBER_OF_ITEMS};  // The value of the "Number of items".
826 
827     /**
828      * @brief A constructor used to create an <b>AvrcTgGtnoiPacket</b> instance.
829      */
830     AvrcTgGtnoiPacket() = delete;
831 };
832 }  // namespace bluetooth
833 }  // namespace OHOS
834 
835 #endif  // !AVRCP_TG_BROWSE_H