• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 <base/bind.h>
21 #include <base/callback.h>
22 #include <base/callback_forward.h>
23 #include <hardware/bt_le_audio.h>
24 
25 #include <vector>
26 
27 class LeAudioHalVerifier {
28  public:
29   static bool SupportsLeAudio();
30   static bool SupportsLeAudioHardwareOffload();
31   static bool SupportsLeAudioBroadcast();
32 };
33 
34 /* Interface class */
35 class LeAudioClient {
36  public:
37   virtual ~LeAudioClient(void) = default;
38 
39   static void Initialize(
40       bluetooth::le_audio::LeAudioClientCallbacks* callbacks,
41       base::Closure initCb, base::Callback<bool()> hal_2_1_verifier,
42       const std::vector<bluetooth::le_audio::btle_audio_codec_config_t>&
43           offloading_preference);
44   static void Cleanup(base::Callback<void()> cleanupCb);
45   static LeAudioClient* Get(void);
46   static void DebugDump(int fd);
47 
48   virtual void RemoveDevice(const RawAddress& address) = 0;
49   virtual void Connect(const RawAddress& address) = 0;
50   virtual void Disconnect(const RawAddress& address) = 0;
51   virtual void GroupAddNode(const int group_id, const RawAddress& addr) = 0;
52   virtual void GroupRemoveNode(const int group_id, const RawAddress& addr) = 0;
53   virtual void GroupStream(const int group_id, const uint16_t content_type) = 0;
54   virtual void GroupSuspend(const int group_id) = 0;
55   virtual void GroupStop(const int group_id) = 0;
56   virtual void GroupDestroy(const int group_id) = 0;
57   virtual void GroupSetActive(const int group_id) = 0;
58   virtual void SetCodecConfigPreference(
59       int group_id,
60       bluetooth::le_audio::btle_audio_codec_config_t input_codec_config,
61       bluetooth::le_audio::btle_audio_codec_config_t output_codec_config) = 0;
62   virtual void SetCcidInformation(int ccid, int context_type) = 0;
63   virtual void SetInCall(bool in_call) = 0;
64 
65   virtual std::vector<RawAddress> GetGroupDevices(const int group_id) = 0;
66   static void AddFromStorage(const RawAddress& addr, bool autoconnect,
67                              int sink_audio_location, int source_audio_location,
68                              int sink_supported_context_types,
69                              int source_supported_context_types,
70                              const std::vector<uint8_t>& handles,
71                              const std::vector<uint8_t>& sink_pacs,
72                              const std::vector<uint8_t>& source_pacs,
73                              const std::vector<uint8_t>& ases);
74   static bool GetHandlesForStorage(const RawAddress& addr,
75                                    std::vector<uint8_t>& out);
76   static bool GetSinkPacsForStorage(const RawAddress& addr,
77                                     std::vector<uint8_t>& out);
78   static bool GetSourcePacsForStorage(const RawAddress& addr,
79                                       std::vector<uint8_t>& out);
80   static bool GetAsesForStorage(const RawAddress& addr,
81                                 std::vector<uint8_t>& out);
82   static bool IsLeAudioClientRunning();
83 
84   static void InitializeAudioSetConfigurationProvider(void);
85   static void CleanupAudioSetConfigurationProvider(void);
86 };
87