1 /*
2  * Copyright 2020 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 <cstdint>
20 #include <map>
21 #include <set>
22 
23 #include "hci/hci_packets.h"
24 #include "model/controller/connected_isochronous_group.h"
25 #include "model/controller/connected_isochronous_stream.h"
26 
27 namespace test_vendor_lib {
28 
29 class IsochronousConnectionHandler {
30  public:
31   IsochronousConnectionHandler() = default;
32   virtual ~IsochronousConnectionHandler() = default;
33 
34   std::unique_ptr<bluetooth::hci::LeSetCigParametersCompleteBuilder>
35   SetCigParameters(GroupParameters parameters,
36                    std::vector<StreamParameters>& streams,
37                    std::vector<uint16_t> handles);
38 
39   bluetooth::hci::ErrorCode RemoveCig(uint8_t cig_id);
40 
41   bool HasHandle(uint16_t handle) const;
42 
43   uint8_t GetGroupId(uint16_t) const;
44 
45   StreamParameters GetStreamParameters(uint16_t handle) const;
46   GroupParameters GetGroupParameters(uint8_t id) const;
47 
48   bool GetStreamIsConnected(uint16_t handle) const;
49 
50   std::vector<uint16_t> GetCigHandles(uint8_t id) const;
51 
52  private:
53   std::map<uint8_t, ConnectedIsochronousGroup> groups_;
54   std::map<uint16_t, uint8_t> cis_to_group_;
55 };
56 
57 }  // namespace test_vendor_lib
58