get_play_status_packet.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #pragma once
  17. #include "vendor_packet.h"
  18. namespace bluetooth {
  19. namespace avrcp {
  20. // TODO (apanicke): This packet doesn't really need to exist as it provides
  21. // zero extra information other than it is a strong type and provides a
  22. // validator
  23. class GetPlayStatusRequest : public VendorPacket {
  24. public:
  25. virtual ~GetPlayStatusRequest() = default;
  26. /**
  27. * Get Capabilities Response Packet Layout
  28. * AvrcpPacket:
  29. * CType c_type_;
  30. * uint8_t subunit_type_ : 5;
  31. * uint8_t subunit_id_ : 3;
  32. * Opcode opcode_;
  33. * VendorPacket:
  34. * uint8_t company_id[3];
  35. * uint8_t command_pdu;
  36. * uint8_t packet_type;
  37. * uint16_t param_length = 0;
  38. */
  39. static constexpr size_t kMinSize() { return Packet::kMinSize() + 7; }
  40. // Overloaded Functions
  41. virtual bool IsValid() const override;
  42. virtual std::string ToString() const override;
  43. protected:
  44. using VendorPacket::VendorPacket;
  45. };
  46. class GetPlayStatusResponseBuilder : public VendorPacketBuilder {
  47. public:
  48. virtual ~GetPlayStatusResponseBuilder() = default;
  49. static std::unique_ptr<GetPlayStatusResponseBuilder> MakeBuilder(
  50. uint32_t song_length, uint32_t song_position, uint8_t play_status);
  51. virtual size_t size() const override;
  52. virtual bool Serialize(
  53. const std::shared_ptr<::bluetooth::Packet>& pkt) override;
  54. protected:
  55. uint32_t song_length_;
  56. uint32_t song_position_;
  57. uint8_t play_status_;
  58. GetPlayStatusResponseBuilder(uint32_t song_length, uint32_t song_position,
  59. uint8_t play_status)
  60. : VendorPacketBuilder(CType::STABLE, CommandPdu::GET_PLAY_STATUS,
  61. PacketType::SINGLE),
  62. song_length_(song_length),
  63. song_position_(song_position),
  64. play_status_(play_status){};
  65. };
  66. } // namespace avrcp
  67. } // namespace bluetooth