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 /** 17 * @file avrcp_ct_vendor_continuation.h 18 * 19 * @brief Declares the class of the VENDOR DEPENDENT command related to the continuation PDUS, including attributes and 20 * methods. 21 */ 22 23 #ifndef AVRCP_CT_VENDOR_CONTINUATION_H 24 #define AVRCP_CT_VENDOR_CONTINUATION_H 25 26 #include "avrcp_ct_vendor.h" 27 #include "packet.h" 28 29 namespace OHOS { 30 namespace bluetooth { 31 /****************************************************************** 32 * RequestContinuingResponse * 33 ******************************************************************/ 34 /** 35 * @brief This enumeration declares a set of values of the <b>RequestContinuingResponse</b> command. 36 */ 37 enum AvrcCtRcr { 38 AVRC_CT_RCR_PARAMETER_LENGTH = 0x0001, // The value of the "Parameter Length". 39 }; 40 41 /** 42 * @brief This class provides a set of methods of assemble / disassemble the packet of the 43 * <b>RequestContinuingResponse</b> frame. 44 * @see Audio/Video Remote Control 1.6.2 Section 6.8.1 RequestContinuingResponse. 45 */ 46 class AvrcCtRcrPacket : public AvrcCtVendorPacket { 47 public: 48 /** 49 * @brief A constructor used to create an <b>AvrcCtRcrPacket</b> instance. 50 */ 51 AvrcCtRcrPacket(); 52 53 /** 54 * @brief A constructor used to create an <b>AvrcCtRcrPacket</b> instance. 55 */ 56 explicit AvrcCtRcrPacket(uint8_t pduId); 57 58 /** 59 * @brief A destructor used to delete the <b>AvrcCtRcrPacket</b> instance. 60 */ 61 ~AvrcCtRcrPacket(); 62 63 /** 64 * @brief Assembles the operands behind the "PDU ID" of the frame. 65 * 66 * @retval nullptr Always return nullptr. 67 */ 68 Packet *AssembleParameters(Packet *pkt) override; 69 70 /** 71 * @brief Disassembles the operands behind the "Packet Type" of the frame. 72 * 73 * @details response frame: 74 * msb lsb<br> 75 * 0 0 0 0 | 0 0 0 0 response 4 bits<br> 76 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 77 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 78 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 79 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 80 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 81 * 82 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 83 * @param[in] buffer The buffer of the frame. 84 * @return The result of the method execution. 85 * @retval true The packet is valid. 86 * @retval false The packet is invalid. 87 */ 88 bool DisassembleParameters(uint8_t *buffer) override; 89 90 /** 91 * @brief Gets the "ContinuePDU_ID". 92 * 93 * @return The value of the "ContinuePDU_ID". 94 */ GetRequestContinuingPduId(void)95 uint8_t GetRequestContinuingPduId(void) const 96 { 97 return continuePduId_; 98 } 99 100 private: 101 uint8_t continuePduId_ {AVRC_CT_PDU_ID_INVALID}; // The "PDU ID" in the frame. 102 }; 103 104 /****************************************************************** 105 * AbortContinuingResponse * 106 ******************************************************************/ 107 108 /** 109 * @brief This enumeration declares a set of values associated with the <b>AbortContinuingResponse</b>. 110 */ 111 enum AvrcCtAcr { 112 AVRC_CT_ACR_PARAMETER_LENGTH = 0x0001, // The value of the "Parameter Length". 113 }; 114 115 /** 116 * @brief This class provides a set of methods associated with assemble / disassemble the packet of the 117 * <b>AbortContinuingResponse</b> command. 118 * @see Audio/Video Remote Control 1.6.2 Section 6.8.1 AbortContinuingResponse. 119 */ 120 class AvrcCtAcrPacket : public AvrcCtVendorPacket { 121 public: 122 /** 123 * @brief A constructor used to create an <b>AvrcCtAcrPacket</b> instance. 124 */ 125 AvrcCtAcrPacket(); 126 127 /** 128 * @brief A constructor used to create an <b>AvrcCtAcrPacket</b> instance. 129 */ 130 explicit AvrcCtAcrPacket(uint8_t pduId); 131 132 /** 133 * @brief A constructor used to create an <b>AvrcCtAcrPacket</b> instance. 134 */ 135 explicit AvrcCtAcrPacket(Packet *pkt); 136 137 /** 138 * @brief A destructor used to delete the <b>AvrcCtAcrPacket</b> instance. 139 */ 140 ~AvrcCtAcrPacket(); 141 142 /** 143 * @brief Assembles the operands that behind the "Packet Type" of the frame. 144 * 145 * @details Command frame:<br> 146 * msb lsb<br> 147 * 0 0 0 0 | 0 0 0 0 ctype 4 bits<br> 148 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 149 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 150 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 151 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 152 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 153 * 154 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 155 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 156 * @return The frame packet. 157 */ 158 Packet *AssembleParameters(Packet *pkt) override; 159 160 /** 161 * @brief Disassembles the operands that behind the "Packet Type" of the frame. 162 * 163 * @details response frame: 164 * msb lsb<br> 165 * 0 0 0 0 | 0 0 0 0 response 4 bits<br> 166 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 167 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 168 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 169 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 170 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 171 * 172 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 173 * @param[in] buffer The buffer of the frame. 174 * @return The result of the method execution. 175 * @retval true The packet is valid. 176 * @retval false The packet is invalid. 177 */ 178 bool DisassembleParameters(uint8_t *buffer) override; 179 180 /** 181 * @brief Gets the "ContinuePDU_ID". 182 * 183 * @return The value of the "ContinuePDU_ID". 184 */ GetRequestContinuingPduId(void)185 uint8_t GetRequestContinuingPduId(void) const 186 { 187 return continuePduId_; 188 } 189 190 private: 191 uint8_t continuePduId_ {AVRC_CT_PDU_ID_INVALID}; // The "PDU ID" in the frame. 192 }; 193 } // namespace bluetooth 194 } // namespace OHOS 195 196 #endif // !AVRCP_CT_VENDOR_CONTINUATION_H