blob: c380850cbb74983bd54f80d81ceb5e0b6b481bdf [file] [log] [blame]
Antoine SOULIER4e34d052023-09-29 19:10:07 +00001/*
2 * Copyright (C) 2023 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 "A2dpOffloadCodec.h"
20
21namespace aidl::android::hardware::bluetooth::audio {
22
23struct SbcParameters : public CodecParameters {
24 enum class AllocationMethod { SNR, LOUDNESS };
25
26 AllocationMethod allocation_method;
27 int block_length;
28 int subbands;
29 int min_bitpool;
30 int max_bitpool;
31};
32
33class A2dpOffloadCodecSbc : public A2dpOffloadCodec {
34 CodecInfo info_;
35
36 A2dpOffloadCodecSbc();
37
38 A2dpStatus ParseConfiguration(const std::vector<uint8_t>& configuration,
39 CodecParameters* codec_parameters,
40 SbcParameters* sbc_parameters) const;
41
42 public:
43 static const A2dpOffloadCodecSbc* GetInstance();
44
45 A2dpStatus ParseConfiguration(
46 const std::vector<uint8_t>& configuration,
47 CodecParameters* codec_parameters) const override {
48 return ParseConfiguration(configuration, codec_parameters, nullptr);
49 }
50
51 A2dpStatus ParseConfiguration(const std::vector<uint8_t>& configuration,
52 SbcParameters* sbc_parameters) const {
53 return ParseConfiguration(configuration, sbc_parameters, sbc_parameters);
54 }
55
56 bool BuildConfiguration(const std::vector<uint8_t>& remote_capabilities,
57 const std::optional<CodecParameters>& hint,
58 std::vector<uint8_t>* configuration) const override;
59};
60
61} // namespace aidl::android::hardware::bluetooth::audio