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 <set> 20 21 #include "avrcp_browse_packet.h" 22 23 namespace bluetooth { 24 namespace avrcp { 25 26 class GetItemAttributesResponseBuilder : public BrowsePacketBuilder { 27 public: 28 virtual ~GetItemAttributesResponseBuilder() = default; 29 30 static std::unique_ptr<GetItemAttributesResponseBuilder> MakeBuilder( 31 Status status, size_t mtu); 32 33 bool AddAttributeEntry(AttributeEntry entry); 34 bool AddAttributeEntry(Attribute, std::string); 35 36 virtual size_t size() const override; 37 virtual bool Serialize( 38 const std::shared_ptr<::bluetooth::Packet>& pkt) override; 39 40 private: 41 Status status_; 42 size_t mtu_; 43 std::set<AttributeEntry> entries_; 44 GetItemAttributesResponseBuilder(Status status,size_t mtu)45 GetItemAttributesResponseBuilder(Status status, size_t mtu) 46 : BrowsePacketBuilder(BrowsePdu::GET_ITEM_ATTRIBUTES), 47 status_(status), 48 mtu_(mtu) {} 49 }; 50 51 class GetItemAttributesRequest : public BrowsePacket { 52 public: 53 virtual ~GetItemAttributesRequest() = default; 54 55 /** 56 * Avrcp Change Path Packet Layout 57 * BrowsePacket: 58 * uint8_t pdu_; 59 * uint16_t length_; 60 * GetItemAttributesRequest: 61 * uint8_t scope_; 62 * uint64_t uid_; 63 * uint16_t uid_counter_; 64 * uint8_t attr_count_; 65 * uint32_t[] attr_requested_; 66 */ kMinSize()67 static constexpr size_t kMinSize() { return BrowsePacket::kMinSize() + 12; } 68 69 Scope GetScope() const; 70 uint64_t GetUid() const; 71 uint16_t GetUidCounter() const; 72 uint8_t GetNumAttributes() 73 const; // If this value is zero, then all attributes are requested 74 std::vector<Attribute> GetAttributesRequested() const; 75 76 virtual bool IsValid() const override; 77 virtual std::string ToString() const override; 78 79 protected: 80 using BrowsePacket::BrowsePacket; 81 }; 82 83 } // namespace avrcp 84 } // namespace bluetooth