blob: ed0598b975dbbe221a40c1b9608db49607a14631 [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
47 static bool IsOffloadLeAudioConfigurationValid(
Josh Wu75462aa2022-01-21 21:51:21 -080048 const SessionType& session_type, const LeAudioConfiguration&);
Josh Wu20bac522021-12-29 23:52:39 -080049
50 static std::vector<LeAudioCodecCapabilitiesSetting>
51 GetLeAudioOffloadCodecCapabilities(const SessionType& session_type);
52
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