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_TG_VENDOR_CONTINUATION_H 24 #define AVRCP_TG_VENDOR_CONTINUATION_H 25 26 #include "avrcp_tg_vendor.h" 27 #include "packet.h" 28 29 namespace OHOS { 30 namespace bluetooth { 31 /****************************************************************** 32 * RequestContinuingResponse * 33 ******************************************************************/ 34 35 /** 36 * @brief This enumeration declares a set of values of the <b>RequestContinuingResponse</b> command. 37 */ 38 enum AvrcTgRcr { 39 AVRC_TG_RCR_REQUEST_CONTINUING_PDU_ID_OFFSET = 0x000A, // The offset of the "ContinuePDU_ID". 40 AVRC_TG_RCR_NUM_OF_PACKETS = 0x0000, // The number of the packets. 41 }; 42 43 /** 44 * @brief This class provides a set of methods of assemble / disassemble the packet of the 45 * <b>RequestContinuingResponse</b> frame. 46 * @see Audio/Video Remote Control 1.6.2 Section 6.8.1 RequestContinuingResponse. 47 */ 48 class AvrcTgRcrPacket : public AvrcTgVendorPacket { 49 public: 50 /** 51 * @brief A constructor used to create an <b>AvrcTgRcrPacket</b> instance. 52 */ 53 AvrcTgRcrPacket(); 54 55 /** 56 * @brief A constructor used to create an <b>AvrcTgRcrPacket</b> instance. 57 */ 58 AvrcTgRcrPacket(Packet *pkt, uint8_t label); 59 60 /** 61 * @brief A destructor used to delete the <b>AvrcTgRcrPacket</b> instance. 62 */ 63 ~AvrcTgRcrPacket(); 64 65 /** 66 * @brief Assembles the operands behind the "PDU ID" of the frame. 67 * 68 * @retval nullptr Always return nullptr. 69 */ 70 Packet *AssembleParameters(Packet *pkt) override; 71 72 /** 73 * @brief Disassembles the operands behind the "Packet Type" of the frame. 74 * 75 * @details Command frame:<br> 76 * msb lsb<br> 77 * 0 0 0 0 | 0 0 0 0 ctype 4 bits<br> 78 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 79 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 80 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 81 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 82 * 83 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 84 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 85 * 0 0 0 0 | 0 0 0 0 ContinuePDU_ID 1 octets<br> 86 * @param[in] buffer The buffer of the frame. 87 * @return The result of the method execution. 88 * @retval true The packet is valid. 89 * @retval false The packet is invalid. 90 */ 91 bool DisassembleParameters(uint8_t *buffer) override; 92 93 /** 94 * @brief Gets the number of the packets. 95 * 96 * @return The number of the packets. 97 */ 98 uint16_t GetNumberOfPackets(void) override; 99 100 /** 101 * @brief Gets the "ContinuePDU_ID". 102 * 103 * @return The value of the "ContinuePDU_ID". 104 */ GetRequestContinuingPduId(void)105 uint8_t GetRequestContinuingPduId(void) const 106 { 107 return continuePduId_; 108 } 109 110 private: 111 uint8_t continuePduId_ {AVRC_TG_PDU_ID_INVALID}; // The value of the "ContinuePDU_ID". 112 }; 113 114 /****************************************************************** 115 * AbortContinuingResponse * 116 ******************************************************************/ 117 118 /** 119 * @brief This enumeration declares a set of values of the <b>AbortContinuingResponse</b> command. 120 */ 121 enum AvrcTgAcr { 122 AVRC_TG_ACR_PARAMETER_LENGTH = 0x0000, // The value of the "Parameter Length". 123 AVRC_TG_ACR_REQUEST_CONTINUING_PDU_ID_OFFSET = 0x000A, // The offset of the "ContinueAbort PDU_ID". 124 AVRC_TG_ACR_NUM_OF_PACKETS = 0x0001, // The number of the packets. 125 }; 126 127 /** 128 * @brief This class provides a set of methods of assemble / disassemble the packet of the 129 * <b>AbortContinuingResponse</b> command. 130 * @see Audio/Video Remote Control 1.6.2 Section 6.8.2 AbortContinuingResponse. 131 */ 132 class AvrcTgAcrPacket : public AvrcTgVendorPacket { 133 public: 134 /** 135 * @brief A constructor used to create an <b>AvrcTgAcrPacket</b> instance. 136 */ 137 AvrcTgAcrPacket(); 138 139 /** 140 * @brief A constructor used to create an <b>AvrcTgAcrPacket</b> instance. 141 */ 142 AvrcTgAcrPacket(uint8_t pduId, uint8_t label); 143 144 /** 145 * @brief A constructor used to create an <b>AvrcTgAcrPacket</b> instance. 146 */ 147 AvrcTgAcrPacket(Packet *pkt, uint8_t label); 148 149 /** 150 * @brief A destructor used to delete the <b>AvrcTgAcrPacket</b> instance. 151 */ 152 ~AvrcTgAcrPacket(); 153 154 /** 155 * @brief Assembles the operands behind the "PDU ID" of the frame. 156 * 157 * @details Response frame:<br> 158 * msb lsb<br> 159 * 0 0 0 0 | 0 0 0 0 response 4 bits<br> 160 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 161 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 162 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 163 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 164 * 165 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 166 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 167 * @return The frame packet. 168 */ 169 Packet *AssembleParameters(Packet *pkt) override; 170 171 /** 172 * @brief Disassembles the operands behind the "Packet Type" of the frame. 173 * 174 * @details Command frame:<br> 175 * msb lsb<br> 176 * 0 0 0 0 | 0 0 0 0 ctype 4 bits<br> 177 * Subunit type 5 bits 0 0 0 0 0 | 0 0 0 Subunit ID 3 bits<br> 178 * 0 0 0 0 | 0 0 0 0 Opcode 1 octets<br> 179 * 0 0 0 0 | 0 0 0 0 Company ID : Bluetooth SIG registered CompanyID 3 octets<br> 180 * 0 0 0 0 | 0 0 0 0 PDU ID 1 octets<br> 181 * Reserved 7 bits 0 0 0 0 0 0 0 | 0 Packet Type 1 bits<br> 182 * 183 * 0 0 0 0 | 0 0 0 0 Parameter Length 2 octets<br> 184 * 0 0 0 0 | 0 0 0 0 ContinuePDU_ID 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 number of the packets. 194 * 195 * @return The number of the packets. 196 */ 197 uint16_t GetNumberOfPackets(void) override; 198 199 /** 200 * @brief Gets the "ContinuePDU_ID". 201 * 202 * @return The value of the "ContinuePDU_ID". 203 */ GetRequestContinuingPduId(void)204 uint8_t GetRequestContinuingPduId(void) const 205 { 206 return continuePduId_; 207 } 208 209 private: 210 uint8_t continuePduId_ {AVRC_TG_PDU_ID_INVALID}; // The value of the "ContinuePDU_ID". 211 }; 212 } // namespace bluetooth 213 } // namespace OHOS 214 215 #endif // !AVRCP_TG_VENDOR_CONTINUATION_H