Loading system/packet/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ cc_test { "tests/avrcp/play_item_packet_test.cc", "tests/avrcp/play_item_packet_test.cc", "tests/avrcp/register_notification_packet_test.cc", "tests/avrcp/register_notification_packet_test.cc", "tests/avrcp/set_absolute_volume_packet_test.cc", "tests/avrcp/set_absolute_volume_packet_test.cc", "tests/avrcp/set_addressed_player_packet_test.cc", "tests/avrcp/set_browsed_player_packet_test.cc", "tests/avrcp/set_browsed_player_packet_test.cc", "tests/avrcp/vendor_packet_test.cc", "tests/avrcp/vendor_packet_test.cc", "tests/base/iterator_test.cc", "tests/base/iterator_test.cc", Loading system/packet/avrcp/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ cc_library_static { "play_item.cc", "play_item.cc", "register_notification_packet.cc", "register_notification_packet.cc", "set_absolute_volume.cc", "set_absolute_volume.cc", "set_addressed_player.cc", "set_browsed_player.cc", "set_browsed_player.cc", "vendor_packet.cc", "vendor_packet.cc", ], ], Loading system/packet/avrcp/avrcp_browse_packet.h +2 −3 Original line number Original line Diff line number Diff line Loading @@ -20,13 +20,12 @@ #include <base/macros.h> #include <base/macros.h> #include <iostream> #include <iostream> #include "avrcp_common.h" #include "avrcp_logging_helper.h" #include "iterator.h" #include "iterator.h" #include "packet.h" #include "packet.h" #include "packet_builder.h" #include "packet_builder.h" #include "avrcp_common.h" #include "avrcp_logging_helper.h" namespace bluetooth { namespace bluetooth { namespace avrcp { namespace avrcp { Loading system/packet/avrcp/set_addressed_player.cc 0 → 100644 +77 −0 Original line number Original line Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "set_addressed_player.h" namespace bluetooth { namespace avrcp { std::unique_ptr<SetAddressedPlayerResponseBuilder> SetAddressedPlayerResponseBuilder::MakeBuilder(Status status) { std::unique_ptr<SetAddressedPlayerResponseBuilder> builder( new SetAddressedPlayerResponseBuilder(status)); return builder; } size_t SetAddressedPlayerResponseBuilder::size() const { size_t len = VendorPacket::kMinSize(); len += 1; // Status return len; } bool SetAddressedPlayerResponseBuilder::Serialize( const std::shared_ptr<::bluetooth::Packet>& pkt) { ReserveSpace(pkt, size()); PacketBuilder::PushHeader(pkt); VendorPacketBuilder::PushHeader(pkt, size() - VendorPacket::kMinSize()); AddPayloadOctets1(pkt, (uint8_t)status_); return true; } uint16_t SetAddressedPlayerRequest::GetPlayerId() const { auto it = begin() + VendorPacket::kMinSize(); return base::ByteSwap(it.extract<uint16_t>()); } bool SetAddressedPlayerRequest::IsValid() const { if (!VendorPacket::IsValid()) return false; return size() == kMinSize(); } std::string SetAddressedPlayerRequest::ToString() const { std::stringstream ss; ss << "SetAddressedPlayerRequest: " << std::endl; ss << " └ cType = " << GetCType() << std::endl; ss << " └ Subunit Type = " << loghex(GetSubunitType()) << std::endl; ss << " └ Subunit ID = " << loghex(GetSubunitId()) << std::endl; ss << " └ OpCode = " << GetOpcode() << std::endl; ss << " └ Company ID = " << loghex(GetCompanyId()) << std::endl; ss << " └ Command PDU = " << GetCommandPdu() << std::endl; ss << " └ PacketType = " << GetPacketType() << std::endl; ss << " └ Parameter Length = " << loghex(GetParameterLength()) << std::endl; ss << " └ Player ID = " << loghex(GetPlayerId()) << std::endl; ss << std::endl; return ss.str(); } } // namespace avrcp } // namespace bluetooth No newline at end of file system/packet/avrcp/set_addressed_player.h 0 → 100644 +75 −0 Original line number Original line Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "vendor_packet.h" namespace bluetooth { namespace avrcp { class SetAddressedPlayerResponseBuilder : public VendorPacketBuilder { public: virtual ~SetAddressedPlayerResponseBuilder() = default; static std::unique_ptr<SetAddressedPlayerResponseBuilder> MakeBuilder( Status status); virtual size_t size() const override; virtual bool Serialize( const std::shared_ptr<::bluetooth::Packet>& pkt) override; protected: Status status_; SetAddressedPlayerResponseBuilder(Status status) : VendorPacketBuilder(CType::ACCEPTED, CommandPdu::SET_ADDRESSED_PLAYER, PacketType::SINGLE), status_(status){}; }; class SetAddressedPlayerRequest : public VendorPacket { public: virtual ~SetAddressedPlayerRequest() = default; /** * Register Notificaiton Request Packet Layout * AvrcpPacket: * CType c_type_; * uint8_t subunit_type_ : 5; * uint8_t subunit_id_ : 3; * Opcode opcode_; * VendorPacket: * uint8_t company_id[3]; * uint8_t command_pdu; * uint8_t packet_type; * uint16_t param_length; * SetAddressedPlayerRequest: * uint16_t player_id; */ static constexpr size_t kMinSize() { return VendorPacket::kMinSize() + 2; } uint16_t GetPlayerId() const; virtual bool IsValid() const override; virtual std::string ToString() const override; protected: using VendorPacket::VendorPacket; }; } // namespace avrcp } // namespace bluetooth No newline at end of file Loading
system/packet/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ cc_test { "tests/avrcp/play_item_packet_test.cc", "tests/avrcp/play_item_packet_test.cc", "tests/avrcp/register_notification_packet_test.cc", "tests/avrcp/register_notification_packet_test.cc", "tests/avrcp/set_absolute_volume_packet_test.cc", "tests/avrcp/set_absolute_volume_packet_test.cc", "tests/avrcp/set_addressed_player_packet_test.cc", "tests/avrcp/set_browsed_player_packet_test.cc", "tests/avrcp/set_browsed_player_packet_test.cc", "tests/avrcp/vendor_packet_test.cc", "tests/avrcp/vendor_packet_test.cc", "tests/base/iterator_test.cc", "tests/base/iterator_test.cc", Loading
system/packet/avrcp/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ cc_library_static { "play_item.cc", "play_item.cc", "register_notification_packet.cc", "register_notification_packet.cc", "set_absolute_volume.cc", "set_absolute_volume.cc", "set_addressed_player.cc", "set_browsed_player.cc", "set_browsed_player.cc", "vendor_packet.cc", "vendor_packet.cc", ], ], Loading
system/packet/avrcp/avrcp_browse_packet.h +2 −3 Original line number Original line Diff line number Diff line Loading @@ -20,13 +20,12 @@ #include <base/macros.h> #include <base/macros.h> #include <iostream> #include <iostream> #include "avrcp_common.h" #include "avrcp_logging_helper.h" #include "iterator.h" #include "iterator.h" #include "packet.h" #include "packet.h" #include "packet_builder.h" #include "packet_builder.h" #include "avrcp_common.h" #include "avrcp_logging_helper.h" namespace bluetooth { namespace bluetooth { namespace avrcp { namespace avrcp { Loading
system/packet/avrcp/set_addressed_player.cc 0 → 100644 +77 −0 Original line number Original line Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "set_addressed_player.h" namespace bluetooth { namespace avrcp { std::unique_ptr<SetAddressedPlayerResponseBuilder> SetAddressedPlayerResponseBuilder::MakeBuilder(Status status) { std::unique_ptr<SetAddressedPlayerResponseBuilder> builder( new SetAddressedPlayerResponseBuilder(status)); return builder; } size_t SetAddressedPlayerResponseBuilder::size() const { size_t len = VendorPacket::kMinSize(); len += 1; // Status return len; } bool SetAddressedPlayerResponseBuilder::Serialize( const std::shared_ptr<::bluetooth::Packet>& pkt) { ReserveSpace(pkt, size()); PacketBuilder::PushHeader(pkt); VendorPacketBuilder::PushHeader(pkt, size() - VendorPacket::kMinSize()); AddPayloadOctets1(pkt, (uint8_t)status_); return true; } uint16_t SetAddressedPlayerRequest::GetPlayerId() const { auto it = begin() + VendorPacket::kMinSize(); return base::ByteSwap(it.extract<uint16_t>()); } bool SetAddressedPlayerRequest::IsValid() const { if (!VendorPacket::IsValid()) return false; return size() == kMinSize(); } std::string SetAddressedPlayerRequest::ToString() const { std::stringstream ss; ss << "SetAddressedPlayerRequest: " << std::endl; ss << " └ cType = " << GetCType() << std::endl; ss << " └ Subunit Type = " << loghex(GetSubunitType()) << std::endl; ss << " └ Subunit ID = " << loghex(GetSubunitId()) << std::endl; ss << " └ OpCode = " << GetOpcode() << std::endl; ss << " └ Company ID = " << loghex(GetCompanyId()) << std::endl; ss << " └ Command PDU = " << GetCommandPdu() << std::endl; ss << " └ PacketType = " << GetPacketType() << std::endl; ss << " └ Parameter Length = " << loghex(GetParameterLength()) << std::endl; ss << " └ Player ID = " << loghex(GetPlayerId()) << std::endl; ss << std::endl; return ss.str(); } } // namespace avrcp } // namespace bluetooth No newline at end of file
system/packet/avrcp/set_addressed_player.h 0 → 100644 +75 −0 Original line number Original line Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "vendor_packet.h" namespace bluetooth { namespace avrcp { class SetAddressedPlayerResponseBuilder : public VendorPacketBuilder { public: virtual ~SetAddressedPlayerResponseBuilder() = default; static std::unique_ptr<SetAddressedPlayerResponseBuilder> MakeBuilder( Status status); virtual size_t size() const override; virtual bool Serialize( const std::shared_ptr<::bluetooth::Packet>& pkt) override; protected: Status status_; SetAddressedPlayerResponseBuilder(Status status) : VendorPacketBuilder(CType::ACCEPTED, CommandPdu::SET_ADDRESSED_PLAYER, PacketType::SINGLE), status_(status){}; }; class SetAddressedPlayerRequest : public VendorPacket { public: virtual ~SetAddressedPlayerRequest() = default; /** * Register Notificaiton Request Packet Layout * AvrcpPacket: * CType c_type_; * uint8_t subunit_type_ : 5; * uint8_t subunit_id_ : 3; * Opcode opcode_; * VendorPacket: * uint8_t company_id[3]; * uint8_t command_pdu; * uint8_t packet_type; * uint16_t param_length; * SetAddressedPlayerRequest: * uint16_t player_id; */ static constexpr size_t kMinSize() { return VendorPacket::kMinSize() + 2; } uint16_t GetPlayerId() const; virtual bool IsValid() const override; virtual std::string ToString() const override; protected: using VendorPacket::VendorPacket; }; } // namespace avrcp } // namespace bluetooth No newline at end of file