1 /*
2  * Copyright 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <vector>
20 
21 #include "vendor_packet.h"
22 
23 namespace bluetooth {
24 namespace avrcp {
25 
26 class SetPlayerApplicationSettingValueResponseBuilder
27     : public VendorPacketBuilder {
28  public:
29   virtual ~SetPlayerApplicationSettingValueResponseBuilder() = default;
30 
31   static std::unique_ptr<SetPlayerApplicationSettingValueResponseBuilder>
32   MakeBuilder();
33 
34   virtual size_t size() const override;
35   virtual bool Serialize(
36       const std::shared_ptr<::bluetooth::Packet>& pkt) override;
37 
38  protected:
SetPlayerApplicationSettingValueResponseBuilder()39   SetPlayerApplicationSettingValueResponseBuilder()
40       : VendorPacketBuilder(CType::ACCEPTED,
41                             CommandPdu::SET_PLAYER_APPLICATION_SETTING_VALUE,
42                             PacketType::SINGLE){};
43 };
44 
45 class SetPlayerApplicationSettingValueRequest : public VendorPacket {
46  public:
47   virtual ~SetPlayerApplicationSettingValueRequest() = default;
48 
49   /**
50    *  Set Player Application Setting Value
51    *   AvrcpPacket:
52    *     CType c_type_;
53    *     uint8_t subunit_type_ : 5;
54    *     uint8_t subunit_id_ : 3;
55    *     Opcode opcode_;
56    *   VendorPacket:
57    *     uint8_t company_id[3];
58    *     uint8_t command_pdu;
59    *     uint8_t packet_type;
60    *     uint16_t param_length;
61    *   SetPlayerApplicationSettingValueRequest:
62    *     uint8_t number_of_attributes;
63    *     std::vector<PlayerAttribute> attributes;
64    *     std::vector<uint8_t> values;
65    */
kMinSize()66   static constexpr size_t kMinSize() {
67     return VendorPacket::kMinSize() + sizeof(uint8_t);
68   }
69 
70   uint8_t GetNumberOfRequestedAttributes() const;
71   std::vector<PlayerAttribute> GetRequestedAttributes() const;
72   std::vector<uint8_t> GetRequestedValues() const;
73 
74   virtual bool IsValid() const override;
75   virtual std::string ToString() const override;
76 
77  protected:
78   using VendorPacket::VendorPacket;
79 };
80 
81 }  // namespace avrcp
82 }  // namespace bluetooth