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/LeAudioCodecCapabilitiesSetting.h> 22 #include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h> 23 #include <aidl/android/hardware/bluetooth/audio/OpusConfiguration.h> 24 #include <aidl/android/hardware/bluetooth/audio/PcmCapabilities.h> 25 #include <aidl/android/hardware/bluetooth/audio/PcmConfiguration.h> 26 #include <aidl/android/hardware/bluetooth/audio/SessionType.h> 27 28 #include <vector> 29 30 namespace aidl { 31 namespace android { 32 namespace hardware { 33 namespace bluetooth { 34 namespace audio { 35 36 class BluetoothAudioCodecs { 37 public: 38 static std::vector<PcmCapabilities> GetSoftwarePcmCapabilities(); 39 static std::vector<CodecCapabilities> GetA2dpOffloadCodecCapabilities( 40 const SessionType& session_type); 41 42 static bool IsSoftwarePcmConfigurationValid( 43 const PcmConfiguration& pcm_config); 44 static bool IsOffloadCodecConfigurationValid( 45 const SessionType& session_type, const CodecConfiguration& codec_config); 46 47 static std::vector<LeAudioCodecCapabilitiesSetting> 48 GetLeAudioOffloadCodecCapabilities(const SessionType& session_type); 49 50 private: 51 template <typename T> 52 struct identity { 53 typedef T type; 54 }; 55 template <class T> 56 static bool ContainedInVector(const std::vector<T>& vector, 57 const typename identity<T>::type& target); 58 template <class T> 59 static bool ContainedInBitmask(const T& bitmask, const T& target); 60 static bool IsSingleBit(uint32_t bitmasks, uint32_t bitfield); 61 static bool IsOffloadSbcConfigurationValid( 62 const CodecConfiguration::CodecSpecific& codec_specific); 63 static bool IsOffloadAacConfigurationValid( 64 const CodecConfiguration::CodecSpecific& codec_specific); 65 static bool IsOffloadLdacConfigurationValid( 66 const CodecConfiguration::CodecSpecific& codec_specific); 67 static bool IsOffloadAptxConfigurationValid( 68 const CodecConfiguration::CodecSpecific& codec_specific); 69 static bool IsOffloadAptxHdConfigurationValid( 70 const CodecConfiguration::CodecSpecific& codec_specific); 71 static bool IsOffloadOpusConfigurationValid( 72 const CodecConfiguration::CodecSpecific& codec_specific); 73 }; 74 75 } // namespace audio 76 } // namespace bluetooth 77 } // namespace hardware 78 } // namespace android 79 } // namespace aidl 80