Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [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/CodecCapabilities.h> |
| 20 | #include <aidl/android/hardware/bluetooth/audio/CodecConfiguration.h> |
Bao Do | 6aeb5d7 | 2023-12-11 10:53:18 +0000 | [diff] [blame] | 21 | #include <aidl/android/hardware/bluetooth/audio/CodecInfo.h> |
Bao Do | fbc99e0 | 2023-11-15 03:21:03 +0000 | [diff] [blame] | 22 | #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h> |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 23 | #include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h> |
| 24 | #include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h> |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame] | 25 | #include <aidl/android/hardware/bluetooth/audio/OpusConfiguration.h> |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 26 | #include <aidl/android/hardware/bluetooth/audio/PcmCapabilities.h> |
| 27 | #include <aidl/android/hardware/bluetooth/audio/PcmConfiguration.h> |
| 28 | #include <aidl/android/hardware/bluetooth/audio/SessionType.h> |
| 29 | |
| 30 | #include <vector> |
| 31 | |
| 32 | namespace aidl { |
| 33 | namespace android { |
| 34 | namespace hardware { |
| 35 | namespace bluetooth { |
| 36 | namespace audio { |
| 37 | |
Bao Do | fbc99e0 | 2023-11-15 03:21:03 +0000 | [diff] [blame] | 38 | using LeAudioAseConfigurationSetting = |
| 39 | IBluetoothAudioProvider::LeAudioAseConfigurationSetting; |
| 40 | |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 41 | class BluetoothAudioCodecs { |
| 42 | public: |
| 43 | static std::vector<PcmCapabilities> GetSoftwarePcmCapabilities(); |
| 44 | static std::vector<CodecCapabilities> GetA2dpOffloadCodecCapabilities( |
| 45 | const SessionType& session_type); |
| 46 | |
| 47 | static bool IsSoftwarePcmConfigurationValid( |
| 48 | const PcmConfiguration& pcm_config); |
| 49 | static bool IsOffloadCodecConfigurationValid( |
| 50 | const SessionType& session_type, const CodecConfiguration& codec_config); |
| 51 | |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 52 | static std::vector<LeAudioCodecCapabilitiesSetting> |
| 53 | GetLeAudioOffloadCodecCapabilities(const SessionType& session_type); |
Bao Do | 6aeb5d7 | 2023-12-11 10:53:18 +0000 | [diff] [blame] | 54 | static std::vector<CodecInfo> GetLeAudioOffloadCodecInfo( |
| 55 | const SessionType& session_type); |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 56 | |
Bao Do | fbc99e0 | 2023-11-15 03:21:03 +0000 | [diff] [blame] | 57 | static std::vector<LeAudioAseConfigurationSetting> |
| 58 | GetLeAudioAseConfigurationSettings(); |
| 59 | |
Bao Do | 2fa1ab4 | 2024-01-29 17:50:34 +0800 | [diff] [blame] | 60 | static std::vector<CodecInfo> GetHfpOffloadCodecInfo(); |
| 61 | |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 62 | private: |
| 63 | template <typename T> |
| 64 | struct identity { |
| 65 | typedef T type; |
| 66 | }; |
| 67 | template <class T> |
| 68 | static bool ContainedInVector(const std::vector<T>& vector, |
| 69 | const typename identity<T>::type& target); |
| 70 | template <class T> |
| 71 | static bool ContainedInBitmask(const T& bitmask, const T& target); |
| 72 | static bool IsSingleBit(uint32_t bitmasks, uint32_t bitfield); |
| 73 | static bool IsOffloadSbcConfigurationValid( |
| 74 | const CodecConfiguration::CodecSpecific& codec_specific); |
| 75 | static bool IsOffloadAacConfigurationValid( |
| 76 | const CodecConfiguration::CodecSpecific& codec_specific); |
| 77 | static bool IsOffloadLdacConfigurationValid( |
| 78 | const CodecConfiguration::CodecSpecific& codec_specific); |
| 79 | static bool IsOffloadAptxConfigurationValid( |
| 80 | const CodecConfiguration::CodecSpecific& codec_specific); |
| 81 | static bool IsOffloadAptxHdConfigurationValid( |
| 82 | const CodecConfiguration::CodecSpecific& codec_specific); |
Omer Osman | a2587da | 2022-05-01 03:54:11 +0000 | [diff] [blame] | 83 | static bool IsOffloadOpusConfigurationValid( |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 84 | const CodecConfiguration::CodecSpecific& codec_specific); |
Josh Wu | 20bac52 | 2021-12-29 23:52:39 -0800 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // namespace audio |
| 88 | } // namespace bluetooth |
| 89 | } // namespace hardware |
| 90 | } // namespace android |
| 91 | } // namespace aidl |