• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h>
20 #include <android-base/logging.h>
21 
22 #include <unordered_map>
23 #include <vector>
24 
25 #include "aidl_android_hardware_bluetooth_audio_setting.h"
26 
27 namespace aidl {
28 namespace android {
29 namespace hardware {
30 namespace bluetooth {
31 namespace audio {
32 
33 class BluetoothLeAudioCodecsProvider {
34  public:
35   static std::optional<setting::LeAudioOffloadSetting>
36   ParseFromLeAudioOffloadSettingFile();
37   static std::vector<LeAudioCodecCapabilitiesSetting>
38   GetLeAudioCodecCapabilities(
39       const std::optional<setting::LeAudioOffloadSetting>&
40           le_audio_offload_setting);
41   static void ClearLeAudioCodecCapabilities();
42 
43  private:
44   static inline std::unordered_map<std::string, setting::Configuration>
45       configuration_map_;
46   static inline std::unordered_map<std::string, setting::CodecConfiguration>
47       codec_configuration_map_;
48   static inline std::unordered_map<std::string, setting::StrategyConfiguration>
49       strategy_configuration_map_;
50 
51   static std::vector<setting::Scenario> GetScenarios(
52       const std::optional<setting::LeAudioOffloadSetting>&
53           le_audio_offload_setting);
54   static void UpdateConfigurationsToMap(
55       const std::optional<setting::LeAudioOffloadSetting>&
56           le_audio_offload_setting);
57   static void UpdateCodecConfigurationsToMap(
58       const std::optional<setting::LeAudioOffloadSetting>&
59           le_audio_offload_setting);
60   static void UpdateStrategyConfigurationsToMap(
61       const std::optional<setting::LeAudioOffloadSetting>&
62           le_audio_offload_setting);
63 
64   static std::vector<LeAudioCodecCapabilitiesSetting>
65   ComposeLeAudioCodecCapabilities(
66       const std::vector<setting::Scenario>& supported_scenarios);
67 
68   static UnicastCapability GetUnicastCapability(
69       const std::string& coding_direction);
70   static BroadcastCapability GetBroadcastCapability(
71       const std::string& coding_direction);
72 
73   template <class T>
74   static inline UnicastCapability ComposeUnicastCapability(
75       const CodecType& codec_type, const AudioLocation& audio_location,
76       const uint8_t& device_cnt, const uint8_t& channel_count,
77       const T& capability);
78 
79   template <class T>
80   static inline BroadcastCapability ComposeBroadcastCapability(
81       const CodecType& codec_type, const AudioLocation& audio_location,
82       const uint8_t& channel_count, const std::vector<T>& capability);
83 
84   static inline Lc3Capabilities ComposeLc3Capability(
85       const setting::CodecConfiguration& codec_configuration);
86 
87   static inline AudioLocation GetAudioLocation(
88       const setting::AudioLocation& audio_location);
89   static inline CodecType GetCodecType(const setting::CodecType& codec_type);
90 
91   static inline bool IsValidCodecConfiguration(
92       const setting::CodecConfiguration& codec_configuration);
93   static inline bool IsValidStrategyConfiguration(
94       const setting::StrategyConfiguration& strategy_configuration);
95 };
96 
97 }  // namespace audio
98 }  // namespace bluetooth
99 }  // namespace hardware
100 }  // namespace android
101 }  // namespace aidl
102