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 PlayItemResponseBuilder : public VendorPacketBuilder { 25 public: 26 virtual ~PlayItemResponseBuilder() = default; 27 28 static std::unique_ptr<PlayItemResponseBuilder> 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 PlayItemResponseBuilder(Status status)36 PlayItemResponseBuilder(Status status) 37 : VendorPacketBuilder(CType::ACCEPTED, CommandPdu::PLAY_ITEM, PacketType::SINGLE), 38 status_(status) {} 39 }; 40 41 class PlayItemRequest : public VendorPacket { 42 public: 43 virtual ~PlayItemRequest() = default; 44 45 /** 46 * AVRCP Play Item 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 parameter_length; 57 * PlayItemRequest: 58 * uint8_t scope_; 59 * uint64_t uid_; 60 * uint16_t uid_counter_; 61 */ kMinSize()62 static constexpr size_t kMinSize() { return VendorPacket::kMinSize() + 11; } 63 64 Scope GetScope() const; 65 uint64_t GetUid() const; 66 uint16_t GetUidCounter() const; 67 68 virtual bool IsValid() const override; 69 virtual std::string ToString() const override; 70 71 protected: 72 using VendorPacket::VendorPacket; 73 }; 74 75 } // namespace avrcp 76 } // namespace bluetooth 77