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> 21 #include <aidl/android/hardware/bluetooth/audio/CodecInfo.h> 22 #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h> 23 #include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h> 24 #include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h> 25 #include <aidl/android/hardware/bluetooth/audio/OpusConfiguration.h> 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 38 using LeAudioAseConfigurationSetting = 39 IBluetoothAudioProvider::LeAudioAseConfigurationSetting; 40 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 52 static std::vector<LeAudioCodecCapabilitiesSetting> 53 GetLeAudioOffloadCodecCapabilities(const SessionType& session_type); 54 static std::vector<CodecInfo> GetLeAudioOffloadCodecInfo( 55 const SessionType& session_type); 56 57 static std::vector<LeAudioAseConfigurationSetting> 58 GetLeAudioAseConfigurationSettings(); 59 60 static std::vector<CodecInfo> GetHfpOffloadCodecInfo(); 61 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); 83 static bool IsOffloadOpusConfigurationValid( 84 const CodecConfiguration::CodecSpecific& codec_specific); 85 }; 86 87 } // namespace audio 88 } // namespace bluetooth 89 } // namespace hardware 90 } // namespace android 91 } // namespace aidl 92