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_CT_BROWSE_H 17 #define AVRCP_CT_BROWSE_H 18 19 #include "avrcp_ct_internal.h" 20 #include "avrcp_ct_packet.h" 21 #include "avrcp_media.h" 22 #include "packet.h" 23 24 namespace OHOS { 25 namespace bluetooth { 26 /** 27 * @brief This enumeration declares the values of the <b>BROWSING</b> commands. 28 */ 29 enum AvrcCtBrowse { 30 AVRC_CT_BROWSE_MIN_SIZE = 0x03, // The size of the "PDU ID" + The size of the "Parameter Length". 31 AVRC_CT_BROWSE_PARAMETER_LENGTH = 0x0000, // The default value of the "Parameter Length". 32 AVRC_CT_BROWSE_UID = 0x0000000000000000, // The default value of the "UID". 33 AVRC_CT_BROWSE_UID_COUNTER = 0x0000, // The default value of the "UID Counter". 34 AVRC_CT_BROWSE_FOLDER_UID = 0xFFFFFFFFFFFFFFFF, // The default value of the "Folder UID". 35 }; 36 37 /** 38 * @brief This class provides a set of methods of assemble / disassemble the packet of the <b>BROWSING</b> 39 * command. 40 * @see Audio/Video Remote Control 1.6.2 Section 5.1.2 Browsing commands. 41 */ 42 class AvrcCtBrowsePacket : public AvrcCtPacket { 43 public: 44 /** 45 * @brief A constructor used to create an <b>AvrcCtBrowsePacket</b> instance. 46 */ 47 AvrcCtBrowsePacket(); 48 49 /** 50 * @brief A destructor used to delete the <b>AvrcCtBrowsePacket</b> instance. 51 */ 52 virtual ~AvrcCtBrowsePacket(); 53 54 /** 55 * @brief Assembles the frame packet. 56 * 57 * @details Command frame:<br> 58 * msb(7) lsb(0)<br> 59 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 60 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 61 * 0 0 0 0 | 0 0 0 0 Other operands n octets<br> 62 * @return The frame packet. 63 */ 64 virtual const Packet *AssemblePacket(void) override; 65 66 /** 67 * @brief Disassembles the frame packet. 68 * 69 * @details Response frame:<br> 70 * msb(7) lsb(0)<br> 71 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 72 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 73 * 0 0 0 0 | 0 0 0 0 Other operands n octets<br> 74 * @param[in] pkt The frame packet. 75 * @return The result of the method execution. 76 * @retval true The packet is valid. 77 * @retval false The packet is invalid. 78 */ 79 bool DisassemblePacket(Packet *pkt) override; 80 81 /** 82 * @brief Gets the "PDU ID". 83 * 84 * @return The value of the "PDU ID". 85 */ GetPduId(void)86 uint8_t GetPduId(void) const 87 { 88 return pduId_; 89 } 90 91 /** 92 * @brief Checks the frame packet is valid or not. 93 * 94 * @return The result of the method execution. 95 * @retval true The packet is valid. 96 * @retval false The packet is invalid. 97 */ IsValid(void)98 bool IsValid(void) const 99 { 100 return isValid_; 101 } 102 103 protected: 104 uint8_t pduId_; // The value of the "PDU ID". 105 uint16_t parameterLength_; // The value of the "Parameter Length". 106 uint16_t mtu_; // The value of the maximum transmission unit. 107 Packet *pkt_; // The frame packet. 108 bool isValid_; // The packet is valid or not. 109 110 BT_DISALLOW_COPY_AND_ASSIGN(AvrcCtBrowsePacket); 111 }; 112 113 /****************************************************************** 114 * SetBrowsedPlayer * 115 ******************************************************************/ 116 117 /** 118 * @brief This enumeration declares the values of the <b>SetBrowsedPlayer</b> command. 119 */ 120 enum AvrcCtSbp { 121 AVRC_CT_SBP_FIXED_CMD_PARAMETER_LENGTH = 0x0002, // The fixed "Parameter Length" of the command frame. 122 AVRC_CT_SBP_FIXED_RSP_PARAMETER_LENGTH = 0x000A, // The fixed "Parameter Length" of the response frame. 123 AVRC_CT_SBP_PLAYER_ID = 0xFFFF, // The default value of the "Player Id". 124 AVRC_CT_SBP_NUMBER_OF_ITEMS = 0x0000, // The default value of the "Number of Items". 125 AVRC_CT_SBP_FOLDER_DEPTH = 0x03, // The default value of the "Folder Depth". 126 AVRC_CT_SBP_FIXED_CMD_FRAME_SIZE = 0x05, // The fixed size of the command frame. 127 AVRC_CT_SBP_MIN_RSP_FRAME_SIZE = 0x0D, // The minimum size of the response frame.(exclude operand behind "Status") 128 }; 129 130 /** 131 * @brief This class provides a set of methods of assemble / disassemble the packet of the 132 * <b>SetBrowsedPlayer</b> command. 133 * @see Audio/Video Remote Control 1.6.2 Section 6.9.3 SetBrowsedPlayer. 134 */ 135 class AvrcCtSbpPacket : public AvrcCtBrowsePacket { 136 public: 137 /** 138 * @brief A constructor used to create an <b>AvrcCtSbpPacket</b> instance. 139 */ 140 explicit AvrcCtSbpPacket(uint16_t playerId); 141 142 /** 143 * @brief A constructor used to create an <b>AvrcCtSbpPacket</b> instance. 144 */ 145 explicit AvrcCtSbpPacket(Packet *pkt); 146 147 /** 148 * @brief A destructor used to delete the <b>AvrcCtSbpPacket</b> instance. 149 */ 150 ~AvrcCtSbpPacket(); 151 152 /** 153 * @brief Assembles the packet of the frame. 154 * 155 * @details Command frame:<br> 156 * msb(7) lsb(0)<br> 157 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 158 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 159 * 0 0 0 0 | 0 0 0 0 Player Id 2 octets<br> 160 * @return The frame packet. 161 */ 162 const Packet *AssemblePacket(void) override; 163 164 /** 165 * @brief Disassembles the packet of the frame. 166 * 167 * @details Response frame:<br> 168 * msb(7) lsb(0)<br> 169 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 170 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 171 * 0 0 0 0 | 0 0 0 0 Status 1 octets<br> 172 * 0 0 0 0 | 0 0 0 0 UID Counter 2 octets<br> 173 * 0 0 0 0 | 0 0 0 0 Number of Items 4 octets<br> 174 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 175 * 0 0 0 0 | 0 0 0 0 Folder Depth 1 octets<br> 176 * 0 0 0 0 | 0 0 0 0 Folder Name Length 1 2 octets<br> 177 * 0 0 0 0 | 0 0 0 0 Folder Name 1 n octets<br> 178 * 0 0 0 0 | 0 0 0 0 Folder Name Length n 2 octets<br> 179 * 0 0 0 0 | 0 0 0 0 Folder Name n n octets<br> 180 * @param[in] pkt The frame packet. 181 * @return The result of the method execution. 182 * @retval true The packet is valid. 183 * @retval false The packet is invalid. 184 */ 185 virtual bool DisassemblePacket(Packet *pkt) override; 186 187 /** 188 * @brief Gets the "Status". 189 * 190 * @return The value of the "Status". 191 */ GetStatus(void)192 uint8_t GetStatus(void) const 193 { 194 return status_; 195 } 196 197 /** 198 * @brief Gets the "UID Counter". 199 * 200 * @return The value of the "UID Counter". 201 */ GetUidCounter(void)202 uint16_t GetUidCounter(void) const 203 { 204 return uidCounter_; 205 } 206 207 /** 208 * @brief Gets the "Number of items". 209 * 210 * @return The value of the "Number of items". 211 */ GetNumOfItems(void)212 uint32_t GetNumOfItems(void) const 213 { 214 return numOfItems_; 215 } 216 217 /** 218 * @brief Gets the "Folder Name". 219 * 220 * @return The list of the "Folder Name". 221 */ GetFolderNames(void)222 const std::vector<std::string> &GetFolderNames(void) const 223 { 224 return folderNames_; 225 } 226 227 private: 228 uint16_t playerId_ {AVRC_CT_SBP_PLAYER_ID}; // The value of the "Player Id". 229 uint8_t status_ {AVRC_ES_CODE_INVALID}; // The value of the "Status". 230 uint16_t uidCounter_ {AVRC_CT_BROWSE_UID_COUNTER}; // The value of the "UID Counter". 231 uint32_t numOfItems_ {AVRC_CT_SBP_NUMBER_OF_ITEMS}; // The value of the "Number of items". 232 // The value of the "Folder Depth".The root folder has no name and its folder depth is 0. 233 uint8_t folderDepth_ {AVRC_CT_SBP_FOLDER_DEPTH}; 234 std::vector<std::string> folderNames_ {}; // The value of the "Folder Name". 235 236 /** 237 * @brief Disassembles the folder name of the packet of the frame. 238 * @param[in] buffer The frame packet. 239 * @param[in] offset The offset of the disassemble packet. 240 */ 241 void DisassemblePacketName(uint8_t *buffer, uint16_t offset); 242 }; 243 244 /****************************************************************** 245 * ChangePath * 246 ******************************************************************/ 247 248 /** 249 * @brief This enumeration declares the values of the <b>ChangePath</b> command. 250 */ 251 enum AvrcCtCp { 252 AVRC_CT_CP_FIXED_CMD_PARAMETER_LENGTH = 0x000B, // The fixed "Parameter Length" of the command frame. 253 AVRC_CT_CP_FIXED_RSP_PARAMETER_LENGTH = 0x0005, // The fixed "Parameter Length" of the response frame. 254 AVRC_CT_CP_NUMBER_OF_ITEMS = 0x0000, // The default value of the "Number of Items". 255 AVRC_CT_CP_FIXED_CMD_FRAME_SIZE = 0x0E, // The fixed size of the command frame. 256 AVRC_CT_CP_FIXED_RSP_FRAME_SIZE = 0x08, // The fixed size of the response frame. 257 }; 258 259 /** 260 * @brief This class provides a set of methods of assemble / disassemble the packet of the 261 * <b>ChangePath</b> command. 262 * @see Audio/Video Remote Control 1.6.2 Section 6.10.4.1 ChangePath. 263 */ 264 class AvrcCtCpPacket : public AvrcCtBrowsePacket { 265 public: 266 /** 267 * @brief A constructor used to create an <b>AvrcCtCpPacket</b> instance. 268 */ 269 AvrcCtCpPacket(uint16_t uidCounter, uint8_t direction, uint64_t folderUid); 270 271 /** 272 * @brief A constructor used to create an <b>AvrcCtCpPacket</b> instance. 273 * 274 * @details You can use this constructor when wants to disassemble the packet. 275 */ 276 explicit AvrcCtCpPacket(Packet *pkt); 277 278 /** 279 * @brief A destructor used to delete the <b>AvrcCtCpPacket</b> instance. 280 */ 281 ~AvrcCtCpPacket(); 282 283 /** 284 * @brief Assembles the packet of the frame. 285 * 286 * @details Command frame:<br> 287 * msb(7) lsb(0)<br> 288 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 289 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 290 * 0 0 0 0 | 0 0 0 0 UID Counter 2 octets<br> 291 * 0 0 0 0 | 0 0 0 0 Direction 1 octets<br> 292 * 0 0 0 0 | 0 0 0 0 Folder UID 8 octets<br> 293 * @return The frame packet. 294 */ 295 const Packet *AssemblePacket(void) override; 296 297 /** 298 * @brief Disassembles the packet of the frame. 299 * 300 * @details Response frame:<br> 301 * msb(7) lsb(0)<br> 302 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 303 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 304 * 0 0 0 0 | 0 0 0 0 Status 1 octets<br> 305 * 0 0 0 0 | 0 0 0 0 Number of Items 4 octets<br> 306 * @param[in] pkt The frame packet. 307 * @return The result of the method execution. 308 * @retval true The packet is valid. 309 * @retval false The packet is invalid. 310 */ 311 bool DisassemblePacket(Packet *pkt) override; 312 313 /** 314 * @brief Gets the "Status". 315 * 316 * @return The value of the "Status". 317 */ GetStatus(void)318 uint8_t GetStatus(void) const 319 { 320 return status_; 321 } 322 323 /** 324 * @brief Gets the "Number of items". 325 * 326 * @return The value of the "Number of items". 327 */ GetNumOfItems(void)328 uint32_t GetNumOfItems(void) const 329 { 330 return numOfItems_; 331 } 332 333 private: 334 uint16_t uidCounter_ {AVRC_CT_BROWSE_UID_COUNTER}; // The value of the "UID Counter". 335 uint8_t direction_ {AVRC_FOLDER_DIRECTION_INVALID}; // The value of the "Direction". 336 uint64_t folderUid_ {AVRC_CT_BROWSE_FOLDER_UID}; // The value of the "Folder UID". 337 uint8_t status_ {AVRC_ES_CODE_INVALID}; // The value of the "Status". 338 uint32_t numOfItems_ {AVRC_CT_CP_NUMBER_OF_ITEMS}; // The value of the "Number of items". 339 }; 340 341 /****************************************************************** 342 * GetFolderItems * 343 ******************************************************************/ 344 345 /** 346 * @brief This enumeration declares the values of the <b>GetFolderItems</b> command. 347 */ 348 enum AvrcCtGfi { 349 AVRC_CT_GFI_VALID_FEATURE_OCTETS = 0x10, // The valid octets of the "Feature Bit Mask". 350 AVRC_CT_GFI_FIXED_CMD_PARAMETER_LENGTH = 0x000A, // The fixed "Parameter Length" of the command frame. 351 AVRC_CT_GFI_START_ITEM = 0x00000000, // The default value of the "Start Item". 352 AVRC_CT_GFI_END_ITEM = 0x00000000, // The default value of the "End Item". 353 AVRC_CT_GFI_ATTRIBUTE_COUNT = 0x00, // The default value of the "AttributeCount". 354 AVRC_CT_GFI_NUMBER_OF_ITEMS = 0x00, // The default value of the "Number of Items". 355 AVRC_CT_GFI_ATTRIBUTE_ID_SIZE = 0x04, // The size of the "Attribute ID". 356 AVRC_CT_GFI_MIN_CMD_FRAME_SIZE = 0x0D, // The fixed size of the command frame. 357 AVRC_CT_GFI_MIN_RSP_FRAME_SIZE = 0x08, // The minimum size of the response frame.(exclude operand behind "Status") 358 }; 359 360 /** 361 * @brief This class provides a set of methods of assemble / disassemble the packet of the 362 * <b>GetFolderItems</b> command. 363 * @see Audio/Video Remote Control 1.6.2 Section 6.10.4.2 GetFolderItems. 364 */ 365 class AvrcCtGfiPacket : public AvrcCtBrowsePacket { 366 public: 367 /** 368 * @brief A constructor used to create an <b>AvrcCtGfiPacket</b> instance. 369 */ 370 AvrcCtGfiPacket(uint8_t scope, uint32_t startItem, uint32_t endItem, const std::vector<uint32_t> &attributes); 371 372 /** 373 * @brief A constructor used to create an <b>AvrcCtGfiPacket</b> instance. 374 * 375 * @details You can use this constructor when wants to disassemble the packet. 376 */ 377 explicit AvrcCtGfiPacket(Packet *pkt); 378 379 /** 380 * @brief A destructor used to delete the <b>AvrcCtGfiPacket</b> instance. 381 */ 382 ~AvrcCtGfiPacket(); 383 384 /** 385 * @brief Assembles the packet of the frame. 386 * 387 * @details Command frame:<br> 388 * msb(7) lsb(0)<br> 389 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 390 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 391 * 0 0 0 0 | 0 0 0 0 Scope 1 octets<br> 392 * 0 0 0 0 | 0 0 0 0 Start Item 4 octets<br> 393 * 0 0 0 0 | 0 0 0 0 End Item 4 octets<br> 394 * 0 0 0 0 | 0 0 0 0 AttributeCount 1 octets<br> 395 * 0 0 0 0 | 0 0 0 0 Attribute ID 1 4 octets<br> 396 * 0 0 0 0 | 0 0 0 0 Attribute ID n n octets<br> 397 * @return The frame packet. 398 */ 399 const Packet *AssemblePacket(void) override; 400 401 /** 402 * @brief Disassembles the packet of the frame. 403 * 404 * @details Response frame:<br> 405 * msb(7) lsb(0)<br> 406 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 407 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 408 * 0 0 0 0 | 0 0 0 0 Status 1 octets<br> 409 * 0 0 0 0 | 0 0 0 0 UID Counter 2 octets<br> 410 * 0 0 0 0 | 0 0 0 0 Number of Items 2 octets<br> 411 * 412 * 0 0 0 0 | 0 0 0 0 Item Type (Media Player Item) 1 octets<br> 413 * 0 0 0 0 | 0 0 0 0 Item Length 2 octets<br> 414 * 0 0 0 0 | 0 0 0 0 Player Id 2 octets<br> 415 * 0 0 0 0 | 0 0 0 0 Major Player Type 1 octets<br> 416 * 0 0 0 0 | 0 0 0 0 Player Sub Type 4 octets<br> 417 * 0 0 0 0 | 0 0 0 0 Play Status 1 octets<br> 418 * 0 0 0 0 | 0 0 0 0 Feature Bit Mask 16 octets<br> 419 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 420 * 0 0 0 0 | 0 0 0 0 Displayable Name Length 2 octets<br> 421 * 0 0 0 0 | 0 0 0 0 Displayable Name n octets<br> 422 * 423 * 0 0 0 0 | 0 0 0 0 Item Type (Folder Item) 1 octets<br> 424 * 0 0 0 0 | 0 0 0 0 Item Length 2 octets<br> 425 * 0 0 0 0 | 0 0 0 0 Folder UID 8 octets<br> 426 * 0 0 0 0 | 0 0 0 0 Folder Type 1 octets<br> 427 * 0 0 0 0 | 0 0 0 0 Is Playable 1 octets<br> 428 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 429 * 0 0 0 0 | 0 0 0 0 Displayable Name Length 2 octets<br> 430 * 0 0 0 0 | 0 0 0 0 Displayable Name n octets<br> 431 * 432 * 0 0 0 0 | 0 0 0 0 Item Type (Media Element Item) 1 octets<br> 433 * 0 0 0 0 | 0 0 0 0 Item Length 2 octets<br> 434 * 0 0 0 0 | 0 0 0 0 Media Element UID 8 octets<br> 435 * 0 0 0 0 | 0 0 0 0 Media Type 1 octets<br> 436 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 437 * 0 0 0 0 | 0 0 0 0 Displayable Name Length 2 octets<br> 438 * 0 0 0 0 | 0 0 0 0 Displayable Name n octets<br> 439 * 0 0 0 0 | 0 0 0 0 Number of Attributes 1 octets<br> 440 * 0 0 0 0 | 0 0 0 0 Attribute ID 1 4 octets<br> 441 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 442 * 0 0 0 0 | 0 0 0 0 Attribute Value Length 2 octets<br> 443 * 0 0 0 0 | 0 0 0 0 Attribute Value n octets<br> 444 * 0 0 0 0 | 0 0 0 0 Attribute ID n n octets<br> 445 * 0 0 0 0 | 0 0 0 0 Character Set Id n octets<br> 446 * 0 0 0 0 | 0 0 0 0 Attribute Value Length n octets<br> 447 * 0 0 0 0 | 0 0 0 0 Attribute Value n octets<br> 448 * @param[in] pkt The frame packet. 449 * @return The result of the method execution. 450 * @retval true The packet is valid. 451 * @retval false The packet is invalid. 452 */ 453 bool DisassemblePacket(Packet *pkt) override; 454 455 /** 456 * @brief Gets the "Scope". 457 * 458 * @return The value of the "Scope". 459 */ GetScope(void)460 uint8_t GetScope(void) const 461 { 462 return scope_; 463 } 464 465 /** 466 * @brief Gets the "Status". 467 * 468 * @return The value of the "Status". 469 */ GetStatus(void)470 uint8_t GetStatus(void) const 471 { 472 return status_; 473 } 474 475 /** 476 * @brief Gets the "UID Counter". 477 * 478 * @return The value of the "UID Counter". 479 */ GetUidCounter(void)480 uint16_t GetUidCounter(void) const 481 { 482 return uidCounter_; 483 } 484 485 /** 486 * @brief Gets the media player list. 487 * 488 * @return The reference of the list of the <b>AvrcMpItem</b> class. 489 */ GetMediaPlayers(void)490 const std::vector<AvrcMpItem> &GetMediaPlayers(void) const 491 { 492 return mpItems_; 493 } 494 495 /** 496 * @brief Gets the folder and media element list. 497 * 498 * @return The reference of the list of the <b>AvrcMpItem</b> class. 499 */ GetMediaItems(void)500 const std::vector<AvrcMeItem> &GetMediaItems(void) const 501 { 502 return meItems_; 503 } 504 505 private: 506 uint8_t scope_ {AVRC_MEDIA_SCOPE_INVALID}; // The value of the "Scope". 507 uint32_t startItem_ {AVRC_CT_GFI_START_ITEM}; // The value of the "Start Item". 508 uint32_t endItem_ {AVRC_CT_GFI_END_ITEM}; // The value of the "End Item". 509 uint8_t attributeCount_ {AVRC_CT_GFI_ATTRIBUTE_COUNT}; // The value of the "AttributeCount". 510 std::vector<uint32_t> attributes_ {}; // The value of the "Attribute ID". 511 uint8_t status_ {AVRC_ES_CODE_INVALID}; // The value of the "Status". 512 uint16_t uidCounter_ {AVRC_CT_BROWSE_UID_COUNTER}; // The value of the "UID Counter". 513 uint16_t numOfItems_ {AVRC_CT_GFI_NUMBER_OF_ITEMS}; // The value of the "Number of Items". 514 std::vector<AvrcMpItem> mpItems_ {}; // The list of the <b>AvrcMpItem</b> class. 515 std::vector<AvrcMeItem> meItems_ {}; // The list of the <b>AvrcMeItem</b> class. 516 517 /** 518 * @brief Disassembles the packet of the frame. 519 * 520 * @details Response frame:<br> 521 * msb(7) lsb(0)<br> 522 * 0 0 0 0 | 0 0 0 0 Item Type (Media Player Item) 1 octets<br> 523 * 0 0 0 0 | 0 0 0 0 Item Length 2 octets<br> 524 * 0 0 0 0 | 0 0 0 0 Player Id 2 octets<br> 525 * 0 0 0 0 | 0 0 0 0 Major Player Type 1 octets<br> 526 * 0 0 0 0 | 0 0 0 0 Player Sub Type 4 octets<br> 527 * 0 0 0 0 | 0 0 0 0 Play Status 1 octets<br> 528 * 0 0 0 0 | 0 0 0 0 Feature Bit Mask 16 octets<br> 529 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 530 * 0 0 0 0 | 0 0 0 0 Displayable Name Length 2 octets<br> 531 * 0 0 0 0 | 0 0 0 0 Displayable Name n octets<br> 532 * @param[in] buffer The frame packet. 533 * @return The read offset of the frame packet. 534 */ 535 uint16_t DisassembleMpParameter(uint8_t *buffer); 536 537 /** 538 * @brief Disassembles the folder name of the packet of the frame. 539 * @param[in] buffer The frame packet. 540 * @param[in] offset The offset of the disassemble packet. 541 * @param[out] name The name disassembled. 542 * @return The read offset of the frame packet. 543 */ 544 uint16_t DisassembleMpParameterName(uint8_t *buffer, uint16_t offset, std::string &name); 545 546 /** 547 * @brief Disassembles the packet of the frame. 548 * 549 * @details Response frame:<br> 550 * msb(7) lsb(0)<br> 551 * 0 0 0 0 | 0 0 0 0 Item Type (Media Element Item) 1 octets<br> 552 * 0 0 0 0 | 0 0 0 0 Item Length 2 octets<br> 553 * 554 * 0 0 0 0 | 0 0 0 0 Folder UID 8 octets<br> 555 * 0 0 0 0 | 0 0 0 0 Folder Type 1 octets<br> 556 * 0 0 0 0 | 0 0 0 0 Is Playable 1 octets<br> 557 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 558 * 0 0 0 0 | 0 0 0 0 Displayable Name Length 2 octets<br> 559 * 0 0 0 0 | 0 0 0 0 Displayable Name n octets<br> 560 * 561 * 0 0 0 0 | 0 0 0 0 Media Element UID 8 octets<br> 562 * 0 0 0 0 | 0 0 0 0 Media Type 1 octets<br> 563 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 564 * 0 0 0 0 | 0 0 0 0 Displayable Name Length 2 octets<br> 565 * 0 0 0 0 | 0 0 0 0 Displayable Name n octets<br> 566 * 0 0 0 0 | 0 0 0 0 Number of Attributes 1 octets<br> 567 * 0 0 0 0 | 0 0 0 0 Attribute ID 1 4 octets<br> 568 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 569 * 0 0 0 0 | 0 0 0 0 Attribute Value Length 2 octets<br> 570 * 0 0 0 0 | 0 0 0 0 Attribute Value n octets<br> 571 * 0 0 0 0 | 0 0 0 0 Attribute ID n n octets<br> 572 * 0 0 0 0 | 0 0 0 0 Character Set Id n octets<br> 573 * 0 0 0 0 | 0 0 0 0 Attribute Value Length n octets<br> 574 * 0 0 0 0 | 0 0 0 0 Attribute Value n octets<br> 575 * @param[in] buffer The frame packet. 576 * @return The read offset of the frame packet. 577 */ 578 uint16_t DisassembleMeParameter(uint8_t *buffer); 579 580 /** 581 * @brief Disassembles the folder name of the packet of the frame. 582 * @param[in] buffer The frame packet. 583 * @param[in] offset The offset of the disassemble packet. 584 * @param[out] name The name disassembled. 585 * @return The read offset of the frame packet. 586 */ 587 uint16_t DisassembleMeParameterName(uint8_t *buffer, uint16_t offset, std::string &name); 588 589 /** 590 * @brief Disassembles the folder name of the packet of the frame. 591 * @param[in] buffer The frame packet. 592 * @param[in] offset The offset of the disassemble packet. 593 * @param[out] name The name disassembled. 594 * @return The read offset of the frame packet. 595 */ 596 uint16_t DisassembleMeParameterAttributesAndValues(uint8_t *buffer, uint16_t offset, uint8_t itemType, 597 std::vector<uint32_t> &attributes, std::vector<std::string> &values); 598 }; 599 600 /****************************************************************** 601 * GetItemAttributes * 602 ******************************************************************/ 603 604 /** 605 * @brief This enumeration declares the values of the <b>GetItemAttributes</b> command. 606 */ 607 enum AvrcCtGia { 608 AVRC_CT_GIA_FIXED_CMD_PARAMETER_LENGTH = 0x000C, // The fixed "Parameter Length" of the command frame. 609 AVRC_CT_GIA_NUMBER_OF_ATTRIBUTES = 0x00, // The default value of the "Number of Attributes". 610 AVRC_CT_GIA_ATTRIBUTE_ID_SIZE = 0x04, // The size of the "Attribute ID". 611 AVRC_CT_GIA_MIN_CMD_FRAME_SIZE = 0x0F, // The fixed size of the command frame. 612 AVRC_CT_GIA_MIN_RSP_FRAME_SIZE = 0x05, // 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 AvrcCtGiaPacket : public AvrcCtBrowsePacket { 621 public: 622 /** 623 * @brief A constructor used to create an <b>AvrcCtGiaPacket</b> instance. 624 */ 625 AvrcCtGiaPacket(uint8_t scope, uint64_t uid, uint16_t uidCounter, const std::vector<uint32_t> &attributes); 626 627 /** 628 * @brief A constructor used to create an <b>AvrcCtGiaPacket</b> instance. 629 * 630 * @details You can use this constructor when wants to disassemble the packet. 631 */ 632 explicit AvrcCtGiaPacket(Packet *pkt); 633 634 /** 635 * @brief A destructor used to delete the <b>AvrcCtGiaPacket</b> instance. 636 */ 637 ~AvrcCtGiaPacket(); 638 639 /** 640 * @brief Assembles the packet of the frame. 641 * 642 * @details Command frame:<br> 643 * msb(7) lsb(0)<br> 644 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 645 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 646 * 0 0 0 0 | 0 0 0 0 Scope 1 octets<br> 647 * 0 0 0 0 | 0 0 0 0 UID 8 octets<br> 648 * 0 0 0 0 | 0 0 0 0 UID Counter 2 octets<br> 649 * 0 0 0 0 | 0 0 0 0 Number of Attributes 1 octets<br> 650 * 0 0 0 0 | 0 0 0 0 Attribute ID 1 4 octets<br> 651 * 0 0 0 0 | 0 0 0 0 Attribute ID n n octets<br> 652 * @return The frame packet. 653 */ 654 const Packet *AssemblePacket(void) override; 655 656 /** 657 * @brief Disassembles the packet of the frame. 658 * 659 * @details Response frame:<br> 660 * msb(7) lsb(0)<br> 661 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 662 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 663 * 0 0 0 0 | 0 0 0 0 Status 1 octets<br> 664 * 0 0 0 0 | 0 0 0 0 UID Counter 2 octets<br> 665 * 0 0 0 0 | 0 0 0 0 Number of Attributes 1 octets<br> 666 * 0 0 0 0 | 0 0 0 0 Attribute ID 1 4 octets<br> 667 * 0 0 0 0 | 0 0 0 0 Character Set Id 2 octets<br> 668 * 0 0 0 0 | 0 0 0 0 Attribute Value Length 2 octets<br> 669 * 0 0 0 0 | 0 0 0 0 Attribute Value n octets<br> 670 * 0 0 0 0 | 0 0 0 0 Attribute ID n n octets<br> 671 * 0 0 0 0 | 0 0 0 0 Character Set Id n octets<br> 672 * 0 0 0 0 | 0 0 0 0 Attribute Value Length n octets<br> 673 * 0 0 0 0 | 0 0 0 0 Attribute Value n octets<br> 674 * @param[in] pkt The frame packet. 675 * @return The result of the method execution. 676 * @retval true The packet is valid. 677 * @retval false The packet is invalid. 678 */ 679 bool DisassemblePacket(Packet *pkt) override; 680 681 /** 682 * @brief Gets the "Status". 683 * 684 * @return The value of the "Status". 685 */ GetStatus(void)686 uint8_t GetStatus(void) const 687 { 688 return status_; 689 } 690 691 /** 692 * @brief Gets the "Attribute ID". 693 * 694 * @return The value of the "Attribute ID". 695 */ GetAttributes(void)696 const std::vector<uint32_t> &GetAttributes(void) const 697 { 698 return attributes_; 699 } 700 701 /** 702 * @brief Gets the "Folder Name". 703 * 704 * @return The list of the "Folder Name". 705 */ GetValues(void)706 const std::vector<std::string> &GetValues(void) const 707 { 708 return values_; 709 } 710 711 private: 712 uint8_t scope_ {AVRC_MEDIA_SCOPE_INVALID}; // The value of the "Scope". 713 uint64_t uid_ {AVRC_CT_BROWSE_UID}; // The value of the "UID". 714 uint16_t uidCounter_ {AVRC_CT_BROWSE_UID_COUNTER}; // The value of the "UID Counter". 715 uint8_t numOfAttributes_ {AVRC_CT_GIA_NUMBER_OF_ATTRIBUTES}; // The value of the "Number of Attributes". 716 std::vector<uint32_t> attributes_ {}; // The value of the "Attribute ID". 717 uint8_t status_ {AVRC_ES_CODE_INVALID}; // The value of the "Status". 718 std::vector<std::string> values_ {}; // The value of the "Attribute Value". 719 720 /** 721 * @brief Disassembles the folder name of the packet of the frame. 722 * @param[in] buffer The frame packet. 723 * @param[in] offset The offset of the disassemble packet. 724 */ 725 void DisassemblePacketName(uint8_t *buffer, uint16_t &offset); 726 }; 727 728 /****************************************************************** 729 * GetTotalNumberOfItems * 730 ******************************************************************/ 731 732 /** 733 * @brief This enumeration declares the values of the <b>GetTotalNumberOfItems</b> command. 734 */ 735 enum AvrcCtGtnoi { 736 AVRC_CT_GTNOI_FIXED_CMD_PARAMETER_LENGTH = 0x0001, // The fixed "Parameter Length" of the command frame. 737 AVRC_CT_GTNOI_FIXED_RSP_PARAMETER_LENGTH = 0x0007, // The fixed "Parameter Length" of the response frame. 738 AVRC_CT_GTNOI_NUMBER_OF_ITEMS = 0x0000, // The default value of the "Number of Items". 739 AVRC_CT_GTNOI_FIXED_CMD_FRAME_SIZE = 0x04, // The fixed size of the command frame. 740 AVRC_CT_GTNOI_FIXED_RSP_FRAME_SIZE = 0x0A, // The fixed size of the response frame. 741 }; 742 743 /** 744 * @brief This class provides a set of methods of assemble / disassemble the packet of the 745 * <b>GetTotalNumberOfItems</b> command. 746 * @see Audio/Video Remote Control 1.6.2 Section 6.10.4.4 GetTotalNumberOfItems. 747 */ 748 class AvrcCtGtnoiPacket : public AvrcCtBrowsePacket { 749 public: 750 /** 751 * @brief A constructor used to create an <b>AvrcCtGtnoiPacket</b> instance. 752 */ 753 explicit AvrcCtGtnoiPacket(uint8_t scope); 754 755 /** 756 * @brief A constructor used to create an <b>AvrcCtGtnoiPacket</b> instance. 757 */ 758 explicit AvrcCtGtnoiPacket(Packet *pkt); 759 760 /** 761 * @brief A destructor used to delete the <b>AvrcCtGtnoiPacket</b> instance. 762 */ 763 ~AvrcCtGtnoiPacket(); 764 765 /** 766 * @brief Disassembles the packet of the frame. 767 * 768 * @details Command frame:<br> 769 * msb(7) lsb(0)<br> 770 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 771 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 772 * 0 0 0 0 | 0 0 0 0 UID Counter 2 octets<br> 773 * 0 0 0 0 | 0 0 0 0 Scope 1 octets<br> 774 * @return The frame packet. 775 */ 776 const Packet *AssemblePacket(void) override; 777 778 /** 779 * @brief Assembles the packet of the frame. 780 * 781 * @details Response frame:<br> 782 * msb(7) lsb(0)<br> 783 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 784 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 785 * 0 0 0 0 | 0 0 0 0 Status 1 octets<br> 786 * 0 0 0 0 | 0 0 0 0 UID Counter 2 octets<br> 787 * 0 0 0 0 | 0 0 0 0 Number of Items 4 octets<br> 788 * @param[in] pkt The frame packet. 789 * @return The result of the method execution. 790 * @retval true The packet is valid. 791 * @retval false The packet is invalid. 792 */ 793 virtual bool DisassemblePacket(Packet *pkt) override; 794 795 /** 796 * @brief Gets the "Status". 797 * 798 * @return The value of the "Status". 799 */ GetStatus(void)800 uint8_t GetStatus(void) const 801 { 802 return status_; 803 } 804 805 /** 806 * @brief Gets the "UID Counter". 807 * 808 * @return The value of the "UID Counter". 809 */ GetUidCounter(void)810 uint16_t GetUidCounter(void) const 811 { 812 return uidCounter_; 813 } 814 815 /** 816 * @brief Gets the "Number of items". 817 * 818 * @return The value of the "Number of items". 819 */ GetNumOfItems(void)820 uint32_t GetNumOfItems(void) const 821 { 822 return numOfItems_; 823 } 824 825 private: 826 uint8_t scope_ {AVRC_MEDIA_SCOPE_INVALID}; // The value of the "Scope". 827 uint16_t uidCounter_ {AVRC_CT_BROWSE_UID_COUNTER}; // The value of the "UID Counter". 828 uint8_t status_ {AVRC_ES_CODE_INVALID}; // The value of the "Status". 829 uint32_t numOfItems_ {AVRC_CT_GTNOI_NUMBER_OF_ITEMS}; // The value of the "Number of items". 830 }; 831 } // namespace bluetooth 832 } // namespace OHOS 833 834 #endif // !AVRCP_CT_BROWSE_H