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#include "get_play_status_packet.h" 18 19namespace bluetooth { 20namespace avrcp { 21 22std::string GetPlayStatusRequest::ToString() const { 23 return "GetPlayStatusRequest"; 24} 25 26std::unique_ptr<GetPlayStatusResponseBuilder> 27GetPlayStatusResponseBuilder::MakeBuilder(uint32_t song_length, 28 uint32_t song_position, 29 uint8_t play_status) { 30 std::unique_ptr<GetPlayStatusResponseBuilder> builder( 31 new GetPlayStatusResponseBuilder(song_length, song_position, 32 play_status)); 33 34 return builder; 35} 36 37size_t GetPlayStatusResponseBuilder::size() const { 38 return VendorPacket::kMinSize() + 4 + 4 + 1; 39} 40 41bool GetPlayStatusResponseBuilder::Serialize( 42 const std::shared_ptr<::bluetooth::Packet>& pkt) { 43 ReserveSpace(pkt, size()); 44 45 // Push the standard avrcp headers 46 PacketBuilder::PushHeader(pkt); 47 48 // Push the avrcp vendor command headers 49 uint16_t parameter_count = size() - VendorPacket::kMinSize(); 50 VendorPacketBuilder::PushHeader(pkt, parameter_count); 51 52 AddPayloadOctets4(pkt, base::ByteSwap(song_length_)); 53 AddPayloadOctets4(pkt, base::ByteSwap(song_position_)); 54 AddPayloadOctets1(pkt, play_status_); 55 56 return true; 57} 58 59} // namespace avrcp 60} // namespace bluetooth