1 /*
2  * Copyright 2018 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 "vendor_packet.h"
20 
21 namespace bluetooth {
22 namespace avrcp {
23 
24 class SetAddressedPlayerResponseBuilder : public VendorPacketBuilder {
25 public:
26   virtual ~SetAddressedPlayerResponseBuilder() = default;
27 
28   static std::unique_ptr<SetAddressedPlayerResponseBuilder> MakeBuilder(Status status);
29 
30   virtual size_t size() const override;
31   virtual bool Serialize(const std::shared_ptr<::bluetooth::Packet>& pkt) override;
32 
33 protected:
34   Status status_;
35 
SetAddressedPlayerResponseBuilder(Status status)36   SetAddressedPlayerResponseBuilder(Status status)
37       : VendorPacketBuilder(CType::ACCEPTED, CommandPdu::SET_ADDRESSED_PLAYER, PacketType::SINGLE),
38         status_(status) {}
39 };
40 
41 class SetAddressedPlayerRequest : public VendorPacket {
42 public:
43   virtual ~SetAddressedPlayerRequest() = default;
44 
45   /**
46    *  Register Notificaiton Request Packet Layout
47    *   AvrcpPacket:
48    *     CType c_type_;
49    *     uint8_t subunit_type_ : 5;
50    *     uint8_t subunit_id_ : 3;
51    *     Opcode opcode_;
52    *   VendorPacket:
53    *     uint8_t company_id[3];
54    *     uint8_t command_pdu;
55    *     uint8_t packet_type;
56    *     uint16_t param_length;
57    *   SetAddressedPlayerRequest:
58    *     uint16_t player_id;
59    */
kMinSize()60   static constexpr size_t kMinSize() { return VendorPacket::kMinSize() + 2; }
61 
62   uint16_t GetPlayerId() const;
63 
64   virtual bool IsValid() const override;
65   virtual std::string ToString() const override;
66 
67 protected:
68   using VendorPacket::VendorPacket;
69 };
70 
71 }  // namespace avrcp
72 }  // namespace bluetooth
73