blob: c542ce5be7878696a8734377d995e69ffdf8c744 [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>
21#include <aidl/android/hardware/bluetooth/audio/Lc3Configuration.h>
22#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h>
23#include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.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
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
47 static bool IsOffloadLeAudioConfigurationValid(
48 const SessionType& session_type, const Lc3Configuration& codec_config);
49
50 static bool IsOffloadLeAudioConfigurationValid(
51 const SessionType& session_type,
52 const LeAudioConfiguration& codec_config);
53
54 static std::vector<LeAudioCodecCapabilitiesSetting>
55 GetLeAudioOffloadCodecCapabilities(const SessionType& session_type);
56
57 private:
58 template <typename T>
59 struct identity {
60 typedef T type;
61 };
62 template <class T>
63 static bool ContainedInVector(const std::vector<T>& vector,
64 const typename identity<T>::type& target);
65 template <class T>
66 static bool ContainedInBitmask(const T& bitmask, const T& target);
67 static bool IsSingleBit(uint32_t bitmasks, uint32_t bitfield);
68 static bool IsOffloadSbcConfigurationValid(
69 const CodecConfiguration::CodecSpecific& codec_specific);
70 static bool IsOffloadAacConfigurationValid(
71 const CodecConfiguration::CodecSpecific& codec_specific);
72 static bool IsOffloadLdacConfigurationValid(
73 const CodecConfiguration::CodecSpecific& codec_specific);
74 static bool IsOffloadAptxConfigurationValid(
75 const CodecConfiguration::CodecSpecific& codec_specific);
76 static bool IsOffloadAptxHdConfigurationValid(
77 const CodecConfiguration::CodecSpecific& codec_specific);
78 static bool IsOffloadLc3ConfigurationValid(
79 const CodecConfiguration::CodecSpecific& codec_specific);
80 static bool IsOffloadLeAudioConfigurationValid(
81 const SessionType& session_type, const LeAudioCodecConfiguration&);
82};
83
84} // namespace audio
85} // namespace bluetooth
86} // namespace hardware
87} // namespace android
88} // namespace aidl