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 GetCurrentPlayerApplicationSettingValueResponseBuilder
27     : public VendorPacketBuilder {
28  public:
29   virtual ~GetCurrentPlayerApplicationSettingValueResponseBuilder() = default;
30 
31   static std::unique_ptr<GetCurrentPlayerApplicationSettingValueResponseBuilder>
32   MakeBuilder(std::vector<PlayerAttribute> attributes,
33               std::vector<uint8_t> values);
34 
35   virtual size_t size() const override;
36   virtual bool Serialize(
37       const std::shared_ptr<::bluetooth::Packet>& pkt) override;
38 
39  protected:
40   std::vector<PlayerAttribute> attributes_;
41   std::vector<uint8_t> values_;
42 
GetCurrentPlayerApplicationSettingValueResponseBuilder(std::vector<PlayerAttribute> attributes,std::vector<uint8_t> values)43   GetCurrentPlayerApplicationSettingValueResponseBuilder(
44       std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values)
45       : VendorPacketBuilder(
46             CType::STABLE,
47             CommandPdu::GET_CURRENT_PLAYER_APPLICATION_SETTING_VALUE,
48             PacketType::SINGLE),
49         attributes_(std::move(attributes)),
50         values_(std::move(values)){};
51 };
52 
53 class GetCurrentPlayerApplicationSettingValueRequest : public VendorPacket {
54  public:
55   virtual ~GetCurrentPlayerApplicationSettingValueRequest() = default;
56 
57   /**
58    *  Get Current Player Application Setting Value
59    *   AvrcpPacket:
60    *     CType c_type_;
61    *     uint8_t subunit_type_ : 5;
62    *     uint8_t subunit_id_ : 3;
63    *     Opcode opcode_;
64    *   VendorPacket:
65    *     uint8_t company_id[3];
66    *     uint8_t command_pdu;
67    *     uint8_t packet_type;
68    *     uint16_t param_length;
69    *   GetCurrentPlayerApplicationSettingValueRequest:
70    *     uint8_t number_of_attributes;
71    *     std::vector<PlayerAttribute> attributes;
72    */
kMinSize()73   static constexpr size_t kMinSize() {
74     return VendorPacket::kMinSize() + sizeof(uint8_t);
75   }
76 
77   uint8_t GetNumberOfRequestedAttributes() const;
78   std::vector<PlayerAttribute> GetRequestedAttributes() const;
79 
80   virtual bool IsValid() const override;
81   virtual std::string ToString() const override;
82 
83  protected:
84   using VendorPacket::VendorPacket;
85 };
86 
87 }  // namespace avrcp
88 }  // namespace bluetooth