blob: 057b9a72c8c37c687b0a73f556bc3d33d90da8bb [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>
Bao Dofbc99e02023-11-15 03:21:03 +000022#include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h>
Josh Wu20bac522021-12-29 23:52:39 -080023#include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h>
24#include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h>
Omer Osmana2587da2022-05-01 03:54:11 +000025#include <aidl/android/hardware/bluetooth/audio/OpusConfiguration.h>
Josh Wu20bac522021-12-29 23:52:39 -080026#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
32namespace aidl {
33namespace android {
34namespace hardware {
35namespace bluetooth {
36namespace audio {
37
Bao Dofbc99e02023-11-15 03:21:03 +000038using LeAudioAseConfigurationSetting =
39 IBluetoothAudioProvider::LeAudioAseConfigurationSetting;
40
Josh Wu20bac522021-12-29 23:52:39 -080041class 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
Josh Wu20bac522021-12-29 23:52:39 -080052 static std::vector<LeAudioCodecCapabilitiesSetting>
53 GetLeAudioOffloadCodecCapabilities(const SessionType& session_type);
Bao Do6aeb5d72023-12-11 10:53:18 +000054 static std::vector<CodecInfo> GetLeAudioOffloadCodecInfo(
55 const SessionType& session_type);
Josh Wu20bac522021-12-29 23:52:39 -080056
Bao Dofbc99e02023-11-15 03:21:03 +000057 static std::vector<LeAudioAseConfigurationSetting>
58 GetLeAudioAseConfigurationSettings();
59
Josh Wu20bac522021-12-29 23:52:39 -080060 private:
61 template <typename T>
62 struct identity {
63 typedef T type;
64 };
65 template <class T>
66 static bool ContainedInVector(const std::vector<T>& vector,
67 const typename identity<T>::type& target);
68 template <class T>
69 static bool ContainedInBitmask(const T& bitmask, const T& target);
70 static bool IsSingleBit(uint32_t bitmasks, uint32_t bitfield);
71 static bool IsOffloadSbcConfigurationValid(
72 const CodecConfiguration::CodecSpecific& codec_specific);
73 static bool IsOffloadAacConfigurationValid(
74 const CodecConfiguration::CodecSpecific& codec_specific);
75 static bool IsOffloadLdacConfigurationValid(
76 const CodecConfiguration::CodecSpecific& codec_specific);
77 static bool IsOffloadAptxConfigurationValid(
78 const CodecConfiguration::CodecSpecific& codec_specific);
79 static bool IsOffloadAptxHdConfigurationValid(
80 const CodecConfiguration::CodecSpecific& codec_specific);
Omer Osmana2587da2022-05-01 03:54:11 +000081 static bool IsOffloadOpusConfigurationValid(
Josh Wu20bac522021-12-29 23:52:39 -080082 const CodecConfiguration::CodecSpecific& codec_specific);
Josh Wu20bac522021-12-29 23:52:39 -080083};
84
85} // namespace audio
86} // namespace bluetooth
87} // namespace hardware
88} // namespace android
89} // namespace aidl