1 /* 2 * Copyright (C) 2021 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_VENDOR_PLAYER_APPLICATION_SETTINGS_H 17 #define AVRCP_CT_VENDOR_PLAYER_APPLICATION_SETTINGS_H 18 19 #include "avrcp_ct_vendor.h" 20 #include "packet.h" 21 namespace OHOS { 22 namespace bluetooth { 23 /****************************************************************** 24 * ListPlayerApplicationSettingAttribute * 25 ******************************************************************/ 26 27 /** 28 * @brief This enumeration declares a set of values associated with the <b>ListPlayerApplicationSettingAttributes<b> 29 */ 30 enum AvrcCtLpasa { 31 AVRC_CT_LPASA_PARAMETER_LENGTH = 0x00, 32 AVRC_CT_LPASA_PARAMETER_LENGTH_SIZE = 0x0002, // The Length of the "Parameter Length". 33 AVRC_CT_LPASA_NUM_OF_ATTRIBUTE = 0x00, // The Number of attribute 34 AVRC_CT_LPASA_NUM_OF_ATTRIBUTES_OFFSET = 0x0A, // The Offset of attribute 35 }; 36 37 /** 38 * @brief This class provides a set of methods associated with assemble / disassemble the packet of the 39 * <b>ListPlayerApplicationSettingAttributes<b> command. 40 * @see Audio/Video Remote Control 1.6.2 Section 6.5.1 ListPlayerApplicationSettingAttributes. 41 */ 42 class AvrcCtLpasaPacket : public AvrcCtVendorPacket { 43 public: 44 /** 45 * @brief A constructor used to create an <b>AvrcCtLpasaPacket</b> instance. 46 */ 47 AvrcCtLpasaPacket(); 48 49 /** 50 * @brief A constructor used to create an <b>AvrcCtLpasaPacket</b> instance. 51 */ 52 explicit AvrcCtLpasaPacket(Packet *pkt); 53 54 /** 55 * @brief A destructor used to delete the <b>AvrcCtLpasaPacket</b> instance. 56 */ 57 ~AvrcCtLpasaPacket(); 58 59 /** 60 * @brief Assembles the operands behind the "Packet Type" of the frame. 61 * 62 * @details Command frame: 63 * msb lsb 64 * 0 0 0 0 | 0 0 0 0 ctype 4 bits 65 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits 66 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets 67 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets 68 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets 69 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits 70 * 71 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets 72 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 octets 73 * @return The packet of the frame. 74 */ 75 Packet *AssembleParameters(Packet *pkt) override; 76 77 /** 78 * @brief Disassembles the operands behind the "Parameter Length" of the frame. 79 * 80 * @details Response frame: 81 * msb lsb 82 * 0 0 0 0 | 0 0 0 0 response 4 bits 83 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits 84 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets 85 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets 86 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets 87 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits 88 * 89 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets 90 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingAttributes 1 octets 91 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 1 octets 92 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttribtueID N 1 octets 93 * @param[in] buffer The buffer of the frame. 94 * @return @c true : The packet is valid. 95 * @c false : The packet is invalid. 96 */ 97 bool DisassembleParameters(uint8_t *buffer) override; 98 99 /** 100 * @brief Gets the values of the "PlayerApplicationSettingAttribtueID". 101 * 102 * @return The values of the "PlayerApplicationSettingAttribtueID". 103 */ GetAttributes(void)104 std::vector<uint8_t> GetAttributes(void) const 105 { 106 return attributes_; 107 } 108 109 private: 110 // The value of the "NumPlayerApplicationSettingAttributes". 111 uint16_t numOfAttributes_ {AVRC_CT_LPASA_NUM_OF_ATTRIBUTE}; 112 std::vector<uint8_t> attributes_ {}; // A set of values of the "PlayerApplicationSettingAttributeID". 113 }; 114 115 /****************************************************************** 116 * ListPlayerApplicationSettingValues * 117 ******************************************************************/ 118 119 /** 120 * @brief This enumeration declares a set of values associated with the <b>ListPlayerApplicationSettingValues<b> frame. 121 */ 122 enum AvrcCtLpasv { 123 AVRC_CT_LPASV_PARAMETER_LENGTH = 0x0001, // The value of the "Parameter Length". 124 AVRC_CT_LPASV_NUM_OF_VALUES = 0x0000, // The default value of the "NumPlayerApplicationSettingValues". 125 }; 126 127 /** 128 * @brief This class provides a set of methods of assemble / disassemble the packet of the 129 * <b>ListPlayerApplicationSettingValues</b> command. 130 * @see Audio/Video Remote Control 1.6.2 Section 6.5.2 ListPlayerApplicationSettingValues. 131 */ 132 class AvrcCtLpasvPacket : public AvrcCtVendorPacket { 133 public: 134 /** 135 * @brief A constructor used to create an <b>AvrcCtLpasvPacket</b> instance. 136 */ 137 explicit AvrcCtLpasvPacket(uint8_t attributes); 138 139 /** 140 * @brief A constructor used to create an <b>AvrcCtLpasvPacket</b> instance. 141 * 142 * @details You can use this constructor when wants to disassemble the packet. 143 */ 144 explicit AvrcCtLpasvPacket(Packet *pkt); 145 146 /** 147 * @brief A destructor used to delete the <b>AvrcCtLpasvPacket</b> instance. 148 */ 149 ~AvrcCtLpasvPacket(); 150 151 /** 152 * @brief Assembles the operands behind the "Packet Type" of the frame. 153 * 154 * @details Command frame:<br> 155 * msb lsb<br> 156 * 0 0 0 0 | 0 0 0 0 ctype 4 bits<br> 157 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 158 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 159 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 160 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 161 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 162 * 163 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 164 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 octets<br> 165 * @return The frame packet. 166 */ 167 Packet *AssembleParameters(Packet *pkt) override; 168 169 /** 170 * @brief Disassembles the operands behind the "Packet Type" of the frame. 171 * 172 * @details Response frame:<br> 173 * msb lsb<br> 174 * 0 0 0 0 | 0 0 0 0 response 4 bits<br> 175 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 176 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 177 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 178 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 179 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 180 * 181 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 182 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingValues 1 octets<br> 183 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID 1 1 octets<br> 184 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID n 1 octets<br> 185 * @param[in] buffer The buffer of the frame. 186 * @return The result of the method execution. 187 * @retval true The packet is valid. 188 * @retval false The packet is invalid. 189 */ 190 bool DisassembleParameters(uint8_t *buffer) override; 191 192 /** 193 * @brief Gets the "Packet Type". 194 * 195 * @return The value of the "Packet Type". 196 */ GetPacketType(void)197 uint8_t GetPacketType(void) const 198 { 199 return packetType_; 200 } 201 202 /** 203 * @brief Gets the "PlayerApplicationSettingAttributeID". 204 * 205 * @return The values of the "PlayerApplicationSettingValueID". 206 */ GetAttribute(void)207 uint8_t GetAttribute(void) const 208 { 209 return attribute_; 210 } 211 212 /** 213 * @brief Gets the "PlayerApplicationSettingValueID". 214 * 215 * @return The values of the "PlayerApplicationSettingValueID". 216 */ GetValues(void)217 const std::vector<uint8_t> &GetValues(void) const 218 { 219 return values_; 220 } 221 222 /** 223 * @brief Checks the attribute of the player application setting is valid or not. 224 * 225 * @return The result of the method execution. 226 * @retval true The attribute is valid. 227 * @retval false The attribute is invalid. 228 */ 229 bool IsValidAttribute(void) const; 230 231 private: 232 uint8_t attribute_ {AVRC_PLAYER_ATTRIBUTE_ILLEGAL}; // The value of the "PlayerApplicationSettingAttributeID". 233 uint16_t numOfValues_ {AVRC_CT_LPASV_NUM_OF_VALUES}; // The value of the "NumPlayerApplicationSettingValues". 234 std::vector<uint8_t> values_ {}; // A set of values of the "PlayerApplicationSettingValueID". 235 236 /** 237 * @brief A constructor used to create an <b>AvrcCtLpasvPacket</b> instance. 238 */ 239 AvrcCtLpasvPacket() = delete; 240 }; 241 242 /****************************************************************** 243 * GetCurrentPlayerApplicationSettingValue * 244 ******************************************************************/ 245 246 /** 247 * @brief This enumeration declares a set of values associated with the <b>GetCurrentPlayerApplicationSettingValue<b> 248 * frame. 249 */ 250 enum AvrcCtGcpasv { 251 AVRC_CT_GCPASV_NUM_OF_ATTRIBUTES = 0x0000, // The value of the "NumPlayerApplicationSettingAttributeID". 252 AVRC_CT_GCPASV_NUM_OF_VALUES = 0x0000, // The value of the "NumPlayerApplicationSettingValues". 253 AVRC_CT_GCPASV_NUM_OF_ATTRIBUTES_SIZE = 0x01, // The size of the "NumPlayerApplicationSettingAttributeID". 254 }; 255 256 /** 257 * @brief This class provides a set of methods of assemble / disassemble the packet of the 258 * <b>GetCurrentPlayerApplicationSettingValue</b> command. 259 * @see Audio/Video Remote Control 1.6.2 Section 6.5.3 GetCurrentPlayerApplicationSettingValue. 260 */ 261 class AvrcCtGcpasvPacket : public AvrcCtVendorPacket { 262 public: 263 /** 264 * @brief A constructor used to create an <b>AvrcCtGcpasvPacket</b> instance. 265 */ 266 explicit AvrcCtGcpasvPacket(const std::vector<uint8_t> &attributes); 267 268 /** 269 * @brief A constructor used to create an <b>AvrcCtGcpasvPacket</b> instance. 270 * 271 * @details You can use this constructor when wants to disassemble the packet. 272 */ 273 explicit AvrcCtGcpasvPacket(Packet *pkt); 274 275 /** 276 * @brief A destructor used to delete the <b>AvrcCtGcpasvPacket</b> instance. 277 */ 278 ~AvrcCtGcpasvPacket(); 279 280 /** 281 * @brief Assembles the operands behind the "Packet Type" of the frame. 282 * 283 * @details Command frame:<br> 284 * msb lsb<br> 285 * 0 0 0 0 | 0 0 0 0 ctype 4 bits<br> 286 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 287 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 288 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 289 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 290 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 291 * 292 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 293 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingAttributeID 1 octets<br> 294 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 1 octets<br> 295 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID n 1 octets<br> 296 * @return The frame packet. 297 */ 298 Packet *AssembleParameters(Packet *pkt) override; 299 300 /** 301 * @brief Disassembles the operands behind the "Packet Type" of the frame. 302 * 303 * @details Response frame:<br> 304 * msb lsb<br> 305 * 0 0 0 0 | 0 0 0 0 response 4 bits<br> 306 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 307 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 308 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 309 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 310 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 311 * 312 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 313 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingValues 1 octets<br> 314 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 1 octets<br> 315 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID 1 1 octets<br> 316 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID n 1 octets<br> 317 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID n 1 octets<br> 318 * @param[in] buffer The buffer of the frame. 319 * @return The result of the method execution. 320 * @retval true The packet is valid. 321 * @retval false The packet is invalid. 322 */ 323 bool DisassembleParameters(uint8_t *buffer) override; 324 325 /** 326 * @brief Gets the "Packet Type". 327 * 328 * @return The value of the "Packet Type". 329 */ GetPacketType(void)330 uint8_t GetPacketType(void) const 331 { 332 return packetType_; 333 } 334 335 /** 336 * @brief Gets the "PlayerApplicationSettingAttributeID". 337 * 338 * @return The values of the "PlayerApplicationSettingValueID". 339 */ GetAttributes(void)340 const std::vector<uint8_t> &GetAttributes(void) const 341 { 342 return attributes_; 343 } 344 345 /** 346 * @brief Clears the "PlayerApplicationSettingAttributeID". 347 * 348 * @return The values of the "PlayerApplicationSettingValueID". 349 */ ClearAttributes(void)350 void ClearAttributes(void) 351 { 352 attributes_.clear(); 353 } 354 355 /** 356 * @brief Gets the "PlayerApplicationSettingValueID". 357 * 358 * @return The values of the "PlayerApplicationSettingValueID". 359 */ GetValues(void)360 const std::vector<uint8_t> &GetValues(void) const 361 { 362 return values_; 363 } 364 365 /** 366 * @brief Checks the attribute of the player application setting is valid or not. 367 * 368 * @return The result of the method execution. 369 * @retval true The attribute is valid. 370 * @retval false The attribute is invalid. 371 */ 372 bool IsValidAttribute(void) const; 373 374 private: 375 // The value of the "NumPlayerApplicationSettingAttributeID". Allowed Values: 1-255. 376 uint8_t numOfAttributes_ {AVRC_CT_GCPASV_NUM_OF_ATTRIBUTES}; 377 std::vector<uint8_t> attributes_ {}; // The value of the "PlayerApplicationSettingAttributeID". 378 // The value of the "NumPlayerApplicationSettingValues". Allowed Values: 1-255. 379 uint8_t numOfValues_ {AVRC_CT_GCPASV_NUM_OF_VALUES}; 380 std::vector<uint8_t> values_ {}; // A set of values of the "PlayerApplicationSettingValueID". 381 382 /** 383 * @brief A constructor used to create an <b>AvrcCtGcpasvPacket</b> instance. 384 */ 385 AvrcCtGcpasvPacket() = delete; 386 }; 387 388 /****************************************************************** 389 * SetPlayerApplicationSettingValue * 390 ******************************************************************/ 391 392 /** 393 * @brief This enumeration declares a set of values associated with the <b>SetPlayerApplicationSettingValue<b> 394 * frame. 395 */ 396 enum AvrcCtSpasv { 397 AVRC_CT_SPASV_NUM_OF_ATTRIBUTES = 0x0000, // The value of the "NumPlayerApplicationSettingAttributeID". 398 AVRC_CT_SPASV_NUM_OF_VALUES = 0x0000, // The value of the "NumPlayerApplicationSettingValues". 399 AVRC_CT_SPASV_NUM_OF_ATTRIBUTES_SIZE = 0x01, // The size of the "NumPlayerApplicationSettingAttributeID". 400 }; 401 402 /** 403 * @brief This class provides a set of methods of assemble / disassemble the packet of the 404 * <b>SetPlayerApplicationSettingValue</b> command. 405 * @see Audio/Video Remote Control 1.6.2 Section 6.5.4 SetPlayerApplicationSettingValue. 406 */ 407 class AvrcCtSpasvPacket : public AvrcCtVendorPacket { 408 public: 409 /** 410 * @brief A constructor used to create an <b>AvrcCtSpasvPacket</b> instance. 411 */ 412 AvrcCtSpasvPacket(const std::vector<uint8_t> &attributes, const std::vector<uint8_t> &values); 413 414 /** 415 * @brief A constructor used to create an <b>AvrcCtSpasvPacket</b> instance. 416 */ 417 explicit AvrcCtSpasvPacket(Packet *pkt); 418 419 /** 420 * @brief A destructor used to delete the <b>AvrcCtSpasvPacket</b> instance. 421 */ 422 ~AvrcCtSpasvPacket(); 423 424 /** 425 * @brief Assembles the operands behind the "Packet Type" of the frame. 426 * 427 * @details Command frame:<br> 428 * msb lsb<br> 429 * 0 0 0 0 | 0 0 0 0 ctype 4 bits<br> 430 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 431 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 432 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 433 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 434 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 435 * 436 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 437 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingAttributeID 1 octets<br> 438 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 1 octets<br> 439 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID 1 1 octets<br> 440 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID n 1 octets<br> 441 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID n 1 octets<br> 442 * @return The frame packet. 443 */ 444 Packet *AssembleParameters(Packet *pkt) override; 445 446 /** 447 * @brief Disassembles the operands behind the "Packet Type" of the frame. 448 * 449 * @details Response frame:<br> 450 * msb lsb<br> 451 * 0 0 0 0 | 0 0 0 0 response 4 bits<br> 452 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 453 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 454 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 455 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 456 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 457 * 458 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 459 * @param[in] buffer The buffer of the frame. 460 * @return The result of the method execution. 461 * @retval true The packet is valid. 462 * @retval false The packet is invalid. 463 */ 464 bool DisassembleParameters(uint8_t *buffer) override; 465 466 /** 467 * @brief Gets the "Packet Type". 468 * 469 * @return The value of the "Packet Type". 470 */ GetPacketType(void)471 uint8_t GetPacketType(void) const 472 { 473 return packetType_; 474 } 475 476 /** 477 * @brief Gets the "PlayerApplicationSettingAttributeID". 478 * 479 * @return The values of the "PlayerApplicationSettingValueID". 480 */ GetAttributes(void)481 const std::vector<uint8_t> &GetAttributes(void) const 482 { 483 return attributes_; 484 } 485 486 /** 487 * @brief Gets the "PlayerApplicationSettingValueID". 488 * 489 * @return The values of the "PlayerApplicationSettingValueID". 490 */ GetValues(void)491 const std::vector<uint8_t> &GetValues(void) const 492 { 493 return values_; 494 } 495 496 /** 497 * @brief Checks the attribute of the player application setting is valid or not. 498 * 499 * @return The result of the method execution. 500 * @retval true The attribute is valid. 501 * @retval false The attribute is invalid. 502 */ 503 bool IsValidAttribute(void) const; 504 505 private: 506 // The value of the "NumPlayerApplicationSettingAttributeID". Allowed Values: 1-255. 507 uint8_t numOfAttributes_ {AVRC_CT_SPASV_NUM_OF_ATTRIBUTES}; 508 std::vector<uint8_t> attributes_ {}; // The value of the "PlayerApplicationSettingAttributeID". 509 std::vector<uint8_t> values_ {}; // A set of values of the "PlayerApplicationSettingValueID". 510 511 /** 512 * @brief A constructor used to create an <b>AvrcCtSpasvPacket</b> instance. 513 */ 514 AvrcCtSpasvPacket() = delete; 515 }; 516 517 /****************************************************************** 518 * GetPlayerApplicationSettingAttributeText * 519 ******************************************************************/ 520 521 /** 522 * @brief This enumeration declares a set of values associated with the <b>GetPlayerApplicationSettingAttributeText<b> 523 * frame. 524 */ 525 enum AvrcCtGpasat { 526 AVRC_CT_GPASAT_ATTRIBUTE_NUM_LENGTH = 0x01, // The Length of "AttributeNum". 527 AVRC_CT_GPASAT_NUM_OF_ATTRIBUTE = 0x00, // The Number of "Attribute". 528 AVRC_CT_GPASAT_VALUE_LENGTH = 0x00, // The Length of "Attribute Name". 529 }; 530 531 /** 532 * @brief This class provides a set of methods associated with assemble / disassemble the packet of the 533 * <b>GetPlayerApplicationSettingAttributeText<b> command. 534 * @see Audio/Video Remote Control 1.6.2 Section 6.5.5 GetPlayerApplicationSettingAttributeText. 535 */ 536 class AvrcCtGpasatPacket : public AvrcCtVendorPacket { 537 public: 538 /** 539 * @brief A constructor used to create an <b>AvrcCtGpasatPacket</b> instance. 540 */ 541 explicit AvrcCtGpasatPacket(std::vector<uint8_t> attributes); 542 543 /** 544 * @brief A constructor used to create an <b>AvrcCtGpasatPacket</b> instance. 545 */ 546 explicit AvrcCtGpasatPacket(Packet *pkt); 547 548 /** 549 * @brief A destructor used to delete the <b>AvrcCtGpasatPacket</b> instance. 550 */ 551 ~AvrcCtGpasatPacket(); 552 553 /** 554 * @brief Assembles the operands behind the "Packet Type" of the frame. 555 * 556 * @details Command frame: 557 * msb lsb 558 * 0 0 0 0 | 0 0 0 0 ctype 4 bits 559 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits 560 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets 561 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets 562 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets 563 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits 564 * 565 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets 566 * 0 0 0 0 | 0 0 0 0 AttributeNum 1 octets 567 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID N octets 568 * @return The packet of the frame. 569 */ 570 Packet *AssembleParameters(Packet *pkt) override; 571 572 /** 573 * @brief Disassembles the operands behind the "Parameter Length" of the frame. 574 * 575 * @details Response frame: 576 * msb lsb 577 * 0 0 0 0 | 0 0 0 0 response 4 bits 578 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits 579 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets 580 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets 581 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets 582 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits 583 * 584 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets 585 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingAttributes 1 octets 586 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 1 octets 587 * 0 0 0 0 | 0 0 0 0 CharacterSetID1 1 octets 588 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttribtueID N 1 octets 589 * @param[in] buffer The buffer of the frame. 590 * @return @c true : The packet is valid. 591 * @c false : The packet is invalid. 592 */ 593 bool DisassembleParameters(uint8_t *buffer) override; 594 595 /** 596 * @brief Gets the "Packet Type". 597 * 598 * @return The value of the "Packet Type". 599 */ GetPacketType(void)600 uint8_t GetPacketType(void) const 601 { 602 return packetType_; 603 } 604 605 /** 606 * @brief Gets the values of the "PlayerApplicationSettingAttribtueID". 607 * 608 * @return The values of the "PlayerApplicationSettingAttribtueID". 609 */ GetAttributes(void)610 const std::vector<uint8_t> &GetAttributes(void) const 611 { 612 return attributes_; 613 } 614 615 /** 616 * @brief Clears the "PlayerApplicationSettingAttribtueID". 617 * 618 * @return The ID of the "PlayerApplicationSettingAttribtueID". 619 */ ClearAttributes(void)620 void ClearAttributes(void) 621 { 622 attributes_.clear(); 623 } 624 625 /** 626 * @brief Clears the "PlayerApplicationSettingAttributeString". 627 * 628 * @return The values of the "PlayerApplicationSettingAttributeString". 629 */ ClearValueName(void)630 void ClearValueName(void) 631 { 632 attributeName_.clear(); 633 } 634 635 /** 636 * @brief Gets the "Attributes". 637 * 638 * @return The values of the "AttributesNameString". 639 */ GetAttributeName(void)640 const std::vector<std::string> &GetAttributeName(void) const 641 { 642 return attributeName_; 643 } 644 645 private: 646 uint16_t numOfAttributes_ {AVRC_CT_GPASAT_NUM_OF_ATTRIBUTE}; 647 // The value of the "NumPlayerApplicationSettingAttributes". 648 std::vector<uint8_t> attributes_ {}; 649 // A set of values of the "PlayerApplicationSettingAttributeID". 650 std::vector<std::string> attributeName_ {}; // Specifies the player application setting attribute name. 651 uint8_t AttributeValueLength_ {AVRC_CT_GPASAT_VALUE_LENGTH}; 652 // Length of the player application setting value string. 653 654 /** 655 * @brief A constructor used to create an <b>AvrcCtGpasatPacket</b> instance. 656 */ 657 AvrcCtGpasatPacket() = delete; 658 }; 659 660 /****************************************************************** 661 * GetPlayerApplicationSettingValueText * 662 ******************************************************************/ 663 664 /** 665 * @brief This enumeration declares a set of values associated with the <b>GetPlayerApplicationSettingValueText<b> 666 * frame. 667 */ 668 enum AvrcCtGpasvt { 669 AVRC_CT_GPASVT_PARAMETER_LENGTH_SIZE = 0x0002, // The Length of the "Parameter Length". 670 AVRC_CT_GPASVT_NUM_OF_VALUE = 0x00, // The Number of value. 671 AVRC_CT_GPASVT_VALUE_LENGTH = 0x00, // The Length of value. 672 }; 673 674 /** 675 * @brief This class provides a set of methods associated with assemble / disassemble the packet of the 676 * <b>GetPlayerApplicationSettingValueText<b> command. 677 * @see Audio/Video Remote Control 1.6.2 Section 6.5.6 GetPlayerApplicationSettingValueText. 678 */ 679 class AvrcCtGpasvtPacket : public AvrcCtVendorPacket { 680 public: 681 /** 682 * @brief A constructor used to create an <b>AvrcCtGpasvtPacket</b> instance. 683 */ 684 AvrcCtGpasvtPacket(uint8_t attribtueId, std::vector<uint8_t> values); 685 686 /** 687 * @brief A constructor used to create an <b>AvrcCtGpasvtPacket</b> instance. 688 * 689 * @details You can use this constructor when wants to disassemble the packet. 690 */ 691 explicit AvrcCtGpasvtPacket(Packet *pkt); 692 693 /** 694 * @brief A destructor used to delete the <b>AvrcCtGpasvtPacket</b> instance. 695 */ 696 ~AvrcCtGpasvtPacket(); 697 698 /** 699 * @brief Assembles the operands behind the "Packet Type" of the frame. 700 * 701 * @details Command frame: 702 * msb lsb 703 * 0 0 0 0 | 0 0 0 0 ctype 4 bits 704 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits 705 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets 706 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets 707 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets 708 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits 709 * 710 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets 711 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingAttributeID 1 octets 712 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingValue 1 octets 713 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID N octets 714 * @return The packet of the frame. 715 */ 716 Packet *AssembleParameters(Packet *pkt) override; 717 718 /** 719 * @brief Disassembles the operands behind the "Parameter Length" of the frame. 720 * 721 * @details Response frame: 722 * msb lsb 723 * 0 0 0 0 | 0 0 0 0 response 4 bits 724 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits 725 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets 726 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets 727 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets 728 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits 729 * 730 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets 731 * 0 0 0 0 | 0 0 0 0 NumPlayerApplicationSettingAttributes 1 octets 732 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueID 1 1 octets 733 * 0 0 0 0 | 0 0 0 0 CharacterSetID1 2 octets 734 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueStringLength 1 1 octets 735 * 0 0 0 0 | 0 0 0 0 PlayerApplicationSettingValueString1 1 octets 736 * @param[in] buffer The buffer of the frame. 737 * @return @c true : The packet is valid. 738 * @c false : The packet is invalid. 739 */ 740 bool DisassembleParameters(uint8_t *buffer) override; 741 742 /** 743 * @brief Gets the "Packet Type". 744 * 745 * @return The value of the "Packet Type". 746 */ GetPacketType(void)747 uint8_t GetPacketType(void) const 748 { 749 return packetType_; 750 } 751 752 /** 753 * @brief Gets the values of the "PlayerApplicationSettingAttribtueID". 754 * 755 * @return The values of the "PlayerApplicationSettingAttribtueID". 756 */ GetValues(void)757 const std::vector<uint8_t> &GetValues(void) const 758 { 759 return values_; 760 } 761 762 /** 763 * @brief Clears the "PlayerApplicationSettingValueID". 764 * 765 * @return The values of the "PlayerApplicationSettingValueID". 766 */ ClearValues(void)767 void ClearValues(void) 768 { 769 values_.clear(); 770 } 771 772 /** 773 * @brief Clears the "PlayerApplicationSettingValueString". 774 * 775 * @return The values of the "PlayerApplicationSettingValueString". 776 */ ClearValueName(void)777 void ClearValueName(void) 778 { 779 valueName_.clear(); 780 } 781 782 /** 783 * @brief Gets the "PlayerApplicationSettingValueString". 784 * 785 * @return The values of the "PlayerApplicationSettingValueString". 786 */ GetValueName(void)787 const std::vector<std::string> &GetValueName(void) const 788 { 789 return valueName_; 790 } 791 792 /** 793 * @brief Checks the attribute of the player application setting is valid or not. 794 * 795 * @return The result of the method execution. 796 * @retval true The attribute is valid. 797 * @retval false The attribute is invalid. 798 */ 799 bool IsValidAttribute(void) const; 800 801 private: 802 uint8_t attributeId_ {AVRC_PLAYER_ATTRIBUTE_ILLEGAL}; // Player application setting attribute ID. 803 uint16_t numOfValues_ {AVRC_CT_GPASVT_NUM_OF_VALUE}; 804 // The value of the "NumPlayerApplicationSettingValues". Allowed Values: 1-255. 805 std::vector<uint8_t> values_ {}; // Player application setting value ID. 806 std::vector<std::string> valueName_ {}; // Specifies the value string of player application setting value. 807 uint8_t AttributeValueLength_ {AVRC_CT_GPASVT_VALUE_LENGTH}; 808 // Length of the player application setting value string. 809 810 /** 811 * @brief A constructor used to create an <b>AvrcCtGpasvtPacket</b> instance. 812 */ 813 AvrcCtGpasvtPacket() = delete; 814 }; 815 } // namespace bluetooth 816 } // namespace OHOS 817 818 #endif // !AVRCP_CT_VENDOR_PLAYER_APPLICATION_SETTINGS_H