blob: e3d657b49730dc7522078967d3d11ce114245125 [file] [log] [blame]
Josh Wu20bac522021-12-29 23:52:39 -08001/*
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>
Josh Wu20bac522021-12-29 23:52:39 -080021#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h>
22#include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h>
Omer Osmana2587da2022-05-01 03:54:11 +000023#include <aidl/android/hardware/bluetooth/audio/OpusConfiguration.h>
Josh Wu20bac522021-12-29 23:52:39 -080024#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
30namespace aidl {
31namespace android {
32namespace hardware {
33namespace bluetooth {
34namespace audio {
35
36class 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
Josh Wu20bac522021-12-29 23:52:39 -080047 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);
Omer Osmana2587da2022-05-01 03:54:11 +000071 static bool IsOffloadOpusConfigurationValid(
Josh Wu20bac522021-12-29 23:52:39 -080072 const CodecConfiguration::CodecSpecific& codec_specific);
Josh Wu20bac522021-12-29 23:52:39 -080073};
74
75} // namespace audio
76} // namespace bluetooth
77} // namespace hardware
78} // namespace android
79} // namespace aidl