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 <base/logging.h> 20 #include <cstdint> 21 #include <memory> 22 #include <vector> 23 24 #include "include/sco.h" 25 #include "packets/hci/hci_packet_builder.h" 26 #include "packets/packet_builder.h" 27 28 namespace test_vendor_lib { 29 namespace packets { 30 31 // SCO data packets are specified in the Bluetooth Core Specification Version 32 // 4.2, Volume 2, Part E, Section 5.4.3 33 class ScoPacketBuilder : public HciPacketBuilder { 34 public: 35 virtual ~ScoPacketBuilder() override = default; 36 37 static std::unique_ptr<ScoPacketBuilder> Create(uint16_t handle, sco::PacketStatusFlagsType packet_status_flags, 38 std::unique_ptr<BasePacketBuilder> payload); 39 40 virtual size_t size() const override; 41 42 virtual void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override; 43 44 private: 45 ScoPacketBuilder(uint16_t handle, sco::PacketStatusFlagsType packet_status_flags, 46 std::unique_ptr<BasePacketBuilder> payload); 47 ScoPacketBuilder() = delete; 48 uint16_t handle_; 49 sco::PacketStatusFlagsType packet_status_flags_; 50 std::unique_ptr<BasePacketBuilder> payload_; 51 }; 52 53 } // namespace packets 54 } // namespace test_vendor_lib 55