• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "devices.h"
25 #include "hardware/bt_le_audio.h"
26 #include "le_audio_types.h"
27 
28 namespace le_audio {
29 
30 /* State machine interface */
31 class LeAudioGroupStateMachine {
32  public:
33   class Callbacks {
34    public:
35     virtual ~Callbacks() = default;
36 
37     virtual void StatusReportCb(
38         int group_id, bluetooth::le_audio::GroupStreamStatus status) = 0;
39     virtual void OnStateTransitionTimeout(int group_id) = 0;
40   };
41 
42   virtual ~LeAudioGroupStateMachine() = default;
43 
44   static void Initialize(Callbacks* state_machine_callbacks);
45   static void Cleanup(void);
46   static LeAudioGroupStateMachine* Get(void);
47 
48   virtual bool AttachToStream(LeAudioDeviceGroup* group,
49                               LeAudioDevice* leAudioDevice) = 0;
50   virtual bool StartStream(
51       LeAudioDeviceGroup* group, types::LeAudioContextType context_type,
52       const types::BidirectionalPair<types::AudioContexts>&
53           metadata_context_types,
54       types::BidirectionalPair<std::vector<uint8_t>> ccid_lists = {
55           .sink = {}, .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>&
60           metadata_context_types,
61       types::BidirectionalPair<std::vector<uint8_t>> ccid_lists = {
62           .sink = {}, .source = {}}) = 0;
63   virtual void StopStream(LeAudioDeviceGroup* group) = 0;
64   virtual void ProcessGattNotifEvent(uint8_t* value, uint16_t len,
65                                      struct types::ase* ase,
66                                      LeAudioDevice* leAudioDevice,
67                                      LeAudioDeviceGroup* group) = 0;
68 
69   virtual void ProcessHciNotifOnCigCreate(
70       LeAudioDeviceGroup* group, uint8_t status, uint8_t cig_id,
71       std::vector<uint16_t> conn_handles) = 0;
72   virtual void ProcessHciNotifOnCigRemove(uint8_t status,
73                                           LeAudioDeviceGroup* group) = 0;
74   virtual void ProcessHciNotifCisEstablished(
75       LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice,
76       const bluetooth::hci::iso_manager::cis_establish_cmpl_evt* event) = 0;
77   virtual void ProcessHciNotifCisDisconnected(
78       LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice,
79       const bluetooth::hci::iso_manager::cis_disconnected_evt* event) = 0;
80   virtual void ProcessHciNotifSetupIsoDataPath(LeAudioDeviceGroup* group,
81                                                LeAudioDevice* leAudioDevice,
82                                                uint8_t status,
83                                                uint16_t conn_hdl) = 0;
84   virtual void ProcessHciNotifRemoveIsoDataPath(LeAudioDeviceGroup* group,
85                                                 LeAudioDevice* leAudioDevice,
86                                                 uint8_t status,
87                                                 uint16_t conn_hdl) = 0;
88   virtual void ProcessHciNotifIsoLinkQualityRead(
89       LeAudioDeviceGroup* group, LeAudioDevice* leAudioDevice,
90       uint8_t conn_handle, uint32_t txUnackedPackets, uint32_t txFlushedPackets,
91       uint32_t txLastSubeventPackets, uint32_t retransmittedPackets,
92       uint32_t crcErrorPackets, uint32_t rxUnreceivedPackets,
93       uint32_t duplicatePackets) = 0;
94   virtual void ProcessHciNotifAclDisconnected(LeAudioDeviceGroup* group,
95                                               LeAudioDevice* leAudioDevice) = 0;
96 };
97 }  // namespace le_audio
98