blob: 0a1f7081e5126b91baac0c562e9f34ea81bb15be [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
Bao Do2fa1ab42024-01-29 17:50:34 +080060 static std::vector<CodecInfo> GetHfpOffloadCodecInfo();
61
Josh Wu20bac522021-12-29 23:52:39 -080062 private:
63 template <typename T>
64 struct identity {
65 typedef T type;
66 };
67 template <class T>
68 static bool ContainedInVector(const std::vector<T>& vector,
69 const typename identity<T>::type& target);
70 template <class T>
71 static bool ContainedInBitmask(const T& bitmask, const T& target);
72 static bool IsSingleBit(uint32_t bitmasks, uint32_t bitfield);
73 static bool IsOffloadSbcConfigurationValid(
74 const CodecConfiguration::CodecSpecific& codec_specific);
75 static bool IsOffloadAacConfigurationValid(
76 const CodecConfiguration::CodecSpecific& codec_specific);
77 static bool IsOffloadLdacConfigurationValid(
78 const CodecConfiguration::CodecSpecific& codec_specific);
79 static bool IsOffloadAptxConfigurationValid(
80 const CodecConfiguration::CodecSpecific& codec_specific);
81 static bool IsOffloadAptxHdConfigurationValid(
82 const CodecConfiguration::CodecSpecific& codec_specific);
Omer Osmana2587da2022-05-01 03:54:11 +000083 static bool IsOffloadOpusConfigurationValid(
Josh Wu20bac522021-12-29 23:52:39 -080084 const CodecConfiguration::CodecSpecific& codec_specific);
Josh Wu20bac522021-12-29 23:52:39 -080085};
86
87} // namespace audio
88} // namespace bluetooth
89} // namespace hardware
90} // namespace android
91} // namespace aidl