blob: e8799843eff61b283bb7c6161d2d65f0975f6f8a [file] [log] [blame]
shihchienc8ed901a2022-09-06 08:44:44 +00001/*
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
24#include "aidl_android_hardware_bluetooth_audio_setting.h"
25
26namespace aidl {
27namespace android {
28namespace hardware {
29namespace bluetooth {
30namespace audio {
31
32class BluetoothLeAudioCodecsProvider {
33 public:
shihchiencd7f565a2022-10-14 13:45:37 +000034 static std::optional<setting::LeAudioOffloadSetting>
35 ParseFromLeAudioOffloadSettingFile();
shihchienc8ed901a2022-09-06 08:44:44 +000036 static std::vector<LeAudioCodecCapabilitiesSetting>
shihchiencd7f565a2022-10-14 13:45:37 +000037 GetLeAudioCodecCapabilities(
38 const std::optional<setting::LeAudioOffloadSetting>&
39 le_audio_offload_setting);
40 static void ClearLeAudioCodecCapabilities();
shihchienc8ed901a2022-09-06 08:44:44 +000041
42 private:
43 static inline std::unordered_map<std::string, setting::Configuration>
44 configuration_map_;
45 static inline std::unordered_map<std::string, setting::CodecConfiguration>
46 codec_configuration_map_;
47 static inline std::unordered_map<std::string, setting::StrategyConfiguration>
48 strategy_configuration_map_;
49
50 static std::vector<setting::Scenario> GetScenarios(
51 const std::optional<setting::LeAudioOffloadSetting>&
52 le_audio_offload_setting);
53 static void UpdateConfigurationsToMap(
54 const std::optional<setting::LeAudioOffloadSetting>&
55 le_audio_offload_setting);
56 static void UpdateCodecConfigurationsToMap(
57 const std::optional<setting::LeAudioOffloadSetting>&
58 le_audio_offload_setting);
59 static void UpdateStrategyConfigurationsToMap(
60 const std::optional<setting::LeAudioOffloadSetting>&
61 le_audio_offload_setting);
62
63 static std::vector<LeAudioCodecCapabilitiesSetting>
64 ComposeLeAudioCodecCapabilities(
65 const std::vector<setting::Scenario>& supported_scenarios);
66
67 static UnicastCapability GetUnicastCapability(
68 const std::string& coding_direction);
69 template <class T>
70 static inline UnicastCapability ComposeUnicastCapability(
71 const CodecType& codec_type, const AudioLocation& audio_location,
72 const uint8_t& device_cnt, const uint8_t& channel_count,
73 const T& capability);
74
75 static inline Lc3Capabilities ComposeLc3Capability(
76 const setting::CodecConfiguration& codec_configuration);
77
78 static inline AudioLocation GetAudioLocation(
79 const setting::AudioLocation& audio_location);
80 static inline CodecType GetCodecType(const setting::CodecType& codec_type);
81
82 static inline bool IsValidCodecConfiguration(
83 const setting::CodecConfiguration& codec_configuration);
84 static inline bool IsValidStrategyConfiguration(
85 const setting::StrategyConfiguration& strategy_configuration);
86};
87
88} // namespace audio
89} // namespace bluetooth
90} // namespace hardware
91} // namespace android
92} // namespace aidl