blob: 01afb7a30a1c5bb4354badc2c7d6e7e690b629d9 [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>
Bao Do6aeb5d72023-12-11 10:53:18 +000021#include <aidl/android/hardware/bluetooth/audio/CodecInfo.h>
Josh Wu20bac522021-12-29 23:52:39 -080022#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h>
23#include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h>
Omer Osmana2587da2022-05-01 03:54:11 +000024#include <aidl/android/hardware/bluetooth/audio/OpusConfiguration.h>
Josh Wu20bac522021-12-29 23:52:39 -080025#include <aidl/android/hardware/bluetooth/audio/PcmCapabilities.h>
26#include <aidl/android/hardware/bluetooth/audio/PcmConfiguration.h>
27#include <aidl/android/hardware/bluetooth/audio/SessionType.h>
28
29#include <vector>
30
31namespace aidl {
32namespace android {
33namespace hardware {
34namespace bluetooth {
35namespace audio {
36
37class BluetoothAudioCodecs {
38 public:
39 static std::vector<PcmCapabilities> GetSoftwarePcmCapabilities();
40 static std::vector<CodecCapabilities> GetA2dpOffloadCodecCapabilities(
41 const SessionType& session_type);
42
43 static bool IsSoftwarePcmConfigurationValid(
44 const PcmConfiguration& pcm_config);
45 static bool IsOffloadCodecConfigurationValid(
46 const SessionType& session_type, const CodecConfiguration& codec_config);
47
Josh Wu20bac522021-12-29 23:52:39 -080048 static std::vector<LeAudioCodecCapabilitiesSetting>
49 GetLeAudioOffloadCodecCapabilities(const SessionType& session_type);
Bao Do6aeb5d72023-12-11 10:53:18 +000050 static std::vector<CodecInfo> GetLeAudioOffloadCodecInfo(
51 const SessionType& session_type);
Josh Wu20bac522021-12-29 23:52:39 -080052
53 private:
54 template <typename T>
55 struct identity {
56 typedef T type;
57 };
58 template <class T>
59 static bool ContainedInVector(const std::vector<T>& vector,
60 const typename identity<T>::type& target);
61 template <class T>
62 static bool ContainedInBitmask(const T& bitmask, const T& target);
63 static bool IsSingleBit(uint32_t bitmasks, uint32_t bitfield);
64 static bool IsOffloadSbcConfigurationValid(
65 const CodecConfiguration::CodecSpecific& codec_specific);
66 static bool IsOffloadAacConfigurationValid(
67 const CodecConfiguration::CodecSpecific& codec_specific);
68 static bool IsOffloadLdacConfigurationValid(
69 const CodecConfiguration::CodecSpecific& codec_specific);
70 static bool IsOffloadAptxConfigurationValid(
71 const CodecConfiguration::CodecSpecific& codec_specific);
72 static bool IsOffloadAptxHdConfigurationValid(
73 const CodecConfiguration::CodecSpecific& codec_specific);
Omer Osmana2587da2022-05-01 03:54:11 +000074 static bool IsOffloadOpusConfigurationValid(
Josh Wu20bac522021-12-29 23:52:39 -080075 const CodecConfiguration::CodecSpecific& codec_specific);
Josh Wu20bac522021-12-29 23:52:39 -080076};
77
78} // namespace audio
79} // namespace bluetooth
80} // namespace hardware
81} // namespace android
82} // namespace aidl