1 /* 2 * 3 * Copyright 2020 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #pragma once 20 21 #include <memory> 22 #include <vector> 23 24 #include "hci/address_with_type.h" 25 #include "iso/internal/iso_manager_impl.h" 26 #include "os/handler.h" 27 28 namespace bluetooth { 29 namespace iso { 30 using SetCigParametersCallback = common::ContextualOnceCallback<void(std::vector<uint16_t> /* connectino handles*/)>; 31 using CisEstablishedCallback = common::ContextualCallback<void(uint16_t)>; 32 using IsoDataCallback = common::ContextualCallback<void(std::unique_ptr<hci::IsoView>)>; 33 34 /** 35 * Manages the iso attributes, pairing, bonding of devices, and the 36 * encryption/decryption of communications. 37 */ 38 class IsoManager { 39 public: 40 friend class IsoModule; 41 42 void RegisterIsoEstablishedCallback(CisEstablishedCallback cb); 43 void RegisterIsoDataCallback(IsoDataCallback cb); 44 45 void SetCigParameters( 46 uint8_t cig_id, 47 uint32_t sdu_interval_m_to_s, 48 uint32_t sdu_interval_s_to_m, 49 hci::ClockAccuracy peripherals_clock_accuracy, 50 hci::Packing packing, 51 hci::Enable framing, 52 uint16_t max_transport_latency_m_to_s, 53 uint16_t max_transport_latency_s_to_m, 54 std::vector<hci::CisParametersConfig> cis_config, 55 SetCigParametersCallback command_complete_callback); 56 void SetCigParametersTest( 57 uint8_t cig_id, 58 uint32_t sdu_interval_m_to_s, 59 uint32_t sdu_interval_s_to_m, 60 uint8_t ft_m_to_s, 61 uint8_t ft_s_to_m, 62 uint16_t iso_interval, 63 hci::ClockAccuracy peripherals_clock_accuracy, 64 hci::Packing packing, 65 hci::Enable framing, 66 uint16_t max_transport_latency_m_to_s, 67 uint16_t max_transport_latency_s_to_m, 68 std::vector<hci::LeCisParametersTestConfig> cis_config, 69 SetCigParametersCallback command_complete_callback); 70 71 void LeCreateCis(std::vector<std::pair<uint16_t, uint16_t>> cis_and_acl_handles); 72 void RemoveCig(uint8_t cig_id); 73 74 void SendIsoPacket(uint16_t cis_handle, std::vector<uint8_t> packet); 75 76 protected: IsoManager(os::Handler * iso_handler,internal::IsoManagerImpl * iso_manager_impl)77 IsoManager(os::Handler* iso_handler, internal::IsoManagerImpl* iso_manager_impl) 78 : iso_handler_(iso_handler), iso_manager_impl_(iso_manager_impl) {} 79 80 private: 81 os::Handler* iso_handler_ = nullptr; 82 internal::IsoManagerImpl* iso_manager_impl_; 83 DISALLOW_COPY_AND_ASSIGN(IsoManager); 84 }; 85 86 } // namespace iso 87 } // namespace bluetooth 88