1 /*
2  * Copyright 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 <vector>
20 
21 #include "a2dp_codec_api.h"
22 #include "audio_aidl_interfaces.h"
23 
24 namespace bluetooth {
25 namespace audio {
26 namespace aidl {
27 namespace a2dp {
28 namespace codec {
29 
30 using ::aidl::android::hardware::bluetooth::audio::ChannelMode;
31 using ::aidl::android::hardware::bluetooth::audio::CodecConfiguration;
32 
33 extern const CodecConfiguration kInvalidCodecConfiguration;
34 
35 int32_t A2dpCodecToHalSampleRate(const btav_a2dp_codec_config_t& a2dp_codec_config);
36 int8_t A2dpCodecToHalBitsPerSample(const btav_a2dp_codec_config_t& a2dp_codec_config);
37 ChannelMode A2dpCodecToHalChannelMode(const btav_a2dp_codec_config_t& a2dp_codec_config);
38 
39 bool A2dpSbcToHalConfig(CodecConfiguration* codec_config, A2dpCodecConfig* a2dp_config);
40 bool A2dpAacToHalConfig(CodecConfiguration* codec_config, A2dpCodecConfig* a2dp_config);
41 bool A2dpAptxToHalConfig(CodecConfiguration* codec_config, A2dpCodecConfig* a2dp_config);
42 bool A2dpLdacToHalConfig(CodecConfiguration* codec_config, A2dpCodecConfig* a2dp_config);
43 bool A2dpOpusToHalConfig(CodecConfiguration* codec_config, A2dpCodecConfig* a2dp_config);
44 
45 bool UpdateOffloadingCapabilities(
46         const std::vector<btav_a2dp_codec_config_t>& framework_preference);
47 
48 /***
49  * Check whether this codec is supported by the audio HAL and is allowed to use
50  * by preference of framework / Bluetooth SoC / runtime property.
51  ***/
52 bool IsCodecOffloadingEnabled(const CodecConfiguration& codec_config);
53 
54 }  // namespace codec
55 }  // namespace a2dp
56 }  // namespace aidl
57 }  // namespace audio
58 }  // namespace bluetooth
59