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