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