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 IsoManager(const IsoManager&) = delete; 41 IsoManager& operator=(const IsoManager&) = delete; 42 43 friend class IsoModule; 44 45 void RegisterIsoEstablishedCallback(CisEstablishedCallback cb); 46 void RegisterIsoDataCallback(IsoDataCallback cb); 47 48 void SetCigParameters( 49 uint8_t cig_id, 50 uint32_t sdu_interval_m_to_s, 51 uint32_t sdu_interval_s_to_m, 52 hci::ClockAccuracy peripherals_clock_accuracy, 53 hci::Packing packing, 54 hci::Enable framing, 55 uint16_t max_transport_latency_m_to_s, 56 uint16_t max_transport_latency_s_to_m, 57 std::vector<hci::CisParametersConfig> cis_config, 58 SetCigParametersCallback command_complete_callback); 59 void SetCigParametersTest( 60 uint8_t cig_id, 61 uint32_t sdu_interval_m_to_s, 62 uint32_t sdu_interval_s_to_m, 63 uint8_t ft_m_to_s, 64 uint8_t ft_s_to_m, 65 uint16_t iso_interval, 66 hci::ClockAccuracy peripherals_clock_accuracy, 67 hci::Packing packing, 68 hci::Enable framing, 69 uint16_t max_transport_latency_m_to_s, 70 uint16_t max_transport_latency_s_to_m, 71 std::vector<hci::LeCisParametersTestConfig> cis_config, 72 SetCigParametersCallback command_complete_callback); 73 74 void LeCreateCis(std::vector<std::pair<uint16_t, uint16_t>> cis_and_acl_handles); 75 void RemoveCig(uint8_t cig_id); 76 77 void SendIsoPacket(uint16_t cis_handle, std::vector<uint8_t> packet); 78 79 protected: IsoManager(os::Handler * iso_handler,internal::IsoManagerImpl * iso_manager_impl)80 IsoManager(os::Handler* iso_handler, internal::IsoManagerImpl* iso_manager_impl) 81 : iso_handler_(iso_handler), iso_manager_impl_(iso_manager_impl) {} 82 83 private: 84 os::Handler* iso_handler_ = nullptr; 85 internal::IsoManagerImpl* iso_manager_impl_; 86 }; 87 88 } // namespace iso 89 } // namespace bluetooth 90