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 codec {
28 
29 using ::aidl::android::hardware::bluetooth::audio::ChannelMode;
30 using ::aidl::android::hardware::bluetooth::audio::CodecConfiguration;
31 
32 extern const CodecConfiguration kInvalidCodecConfiguration;
33 
34 int32_t A2dpCodecToHalSampleRate(
35     const btav_a2dp_codec_config_t& a2dp_codec_config);
36 int8_t A2dpCodecToHalBitsPerSample(
37     const btav_a2dp_codec_config_t& a2dp_codec_config);
38 ChannelMode A2dpCodecToHalChannelMode(
39     const btav_a2dp_codec_config_t& a2dp_codec_config);
40 
41 bool A2dpSbcToHalConfig(CodecConfiguration* codec_config,
42                         A2dpCodecConfig* a2dp_config);
43 bool A2dpAacToHalConfig(CodecConfiguration* codec_config,
44                         A2dpCodecConfig* a2dp_config);
45 bool A2dpAptxToHalConfig(CodecConfiguration* codec_config,
46                          A2dpCodecConfig* a2dp_config);
47 bool A2dpLdacToHalConfig(CodecConfiguration* codec_config,
48                          A2dpCodecConfig* a2dp_config);
49 bool A2dpOpusToHalConfig(CodecConfiguration* codec_config,
50                          A2dpCodecConfig* a2dp_config);
51 
52 bool UpdateOffloadingCapabilities(
53     const std::vector<btav_a2dp_codec_config_t>& framework_preference);
54 
55 /***
56  * Check whether this codec is supported by the audio HAL and is allowed to use
57  * by prefernece of framework / Bluetooth SoC / runtime property.
58  ***/
59 bool IsCodecOffloadingEnabled(const CodecConfiguration& codec_config);
60 
61 }  // namespace codec
62 }  // namespace aidl
63 }  // namespace audio
64 }  // namespace bluetooth
65