1 /* 2 * Copyright 2020 HIMSA II K/S - www.himsa.com. Represented by EHIMA - 3 * www.ehima.com 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 #pragma once 19 20 #include <vector> 21 22 #include "btm_iso_api.h" 23 #include "btm_iso_api_types.h" 24 #include "device_groups.h" 25 #include "devices.h" 26 #include "hardware/bt_le_audio.h" 27 #include "le_audio_types.h" 28 29 namespace bluetooth::le_audio { 30 31 /* State machine interface */ 32 class LeAudioGroupStateMachine { 33 public: 34 class Callbacks { 35 public: 36 virtual ~Callbacks() = default; 37 38 virtual void StatusReportCb(int group_id, bluetooth::le_audio::GroupStreamStatus status) = 0; 39 virtual void OnStateTransitionTimeout(int group_id) = 0; 40 virtual void OnUpdatedCisConfiguration(int group_id, uint8_t direction) = 0; 41 }; 42 43 virtual ~LeAudioGroupStateMachine() = default; 44 45 static void Initialize(Callbacks* state_machine_callbacks); 46 static void Cleanup(void); 47 static LeAudioGroupStateMachine* Get(void); 48 49 virtual bool AttachToStream(LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice, 50 types::BidirectionalPair<std::vector<uint8_t>> ccids) = 0; 51 virtual bool StartStream( 52 LeAudioDeviceGroup* group, types::LeAudioContextType context_type, 53 const types::BidirectionalPair<types::AudioContexts>& metadata_context_types, 54 types::BidirectionalPair<std::vector<uint8_t>> ccid_lists = {.sink = {}, 55 .source = {}}) = 0; 56 virtual void SuspendStream(LeAudioDeviceGroup* group) = 0; 57 virtual bool ConfigureStream( 58 LeAudioDeviceGroup* group, types::LeAudioContextType context_type, 59 const types::BidirectionalPair<types::AudioContexts>& metadata_context_types, 60 types::BidirectionalPair<std::vector<uint8_t>> ccid_lists = {.sink = {}, .source = {}}, 61 bool configure_qos = false) = 0; 62 virtual void StopStream(LeAudioDeviceGroup* group) = 0; 63 virtual void ProcessGattCtpNotification(LeAudioDeviceGroup* group, uint8_t* value, 64 uint16_t len) = 0; 65 virtual void ProcessGattNotifEvent(uint8_t* value, uint16_t len, struct types::ase* ase, 66 LeAudioDevice* leAudioDevice, LeAudioDeviceGroup* group) = 0; 67 68 virtual void ProcessHciNotifOnCigCreate(LeAudioDeviceGroup* group, uint8_t status, uint8_t cig_id, 69 std::vector<uint16_t> conn_handles) = 0; 70 virtual void ProcessHciNotifOnCigRemove(uint8_t status, LeAudioDeviceGroup* group) = 0; 71 virtual void ProcessHciNotifCisEstablished( 72 LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice, 73 const bluetooth::hci::iso_manager::cis_establish_cmpl_evt* event) = 0; 74 virtual void ProcessHciNotifCisDisconnected( 75 LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice, 76 const bluetooth::hci::iso_manager::cis_disconnected_evt* event) = 0; 77 virtual void ProcessHciNotifSetupIsoDataPath(LeAudioDeviceGroup* group, 78 LeAudioDevice* leAudioDevice, uint8_t status, 79 uint16_t conn_hdl) = 0; 80 virtual void ProcessHciNotifRemoveIsoDataPath(LeAudioDeviceGroup* group, 81 LeAudioDevice* leAudioDevice, uint8_t status, 82 uint16_t conn_hdl) = 0; 83 virtual void ProcessHciNotifIsoLinkQualityRead( 84 LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice, uint8_t conn_handle, 85 uint32_t txUnackedPackets, uint32_t txFlushedPackets, uint32_t txLastSubeventPackets, 86 uint32_t retransmittedPackets, uint32_t crcErrorPackets, uint32_t rxUnreceivedPackets, 87 uint32_t duplicatePackets) = 0; 88 virtual void ProcessHciNotifAclDisconnected(LeAudioDeviceGroup* group, 89 LeAudioDevice* leAudioDevice) = 0; 90 }; 91 } // namespace bluetooth::le_audio 92