• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "le_audio_types.h"
20 
21 namespace le_audio {
22 
23 struct offload_config {
24   std::vector<std::pair<uint16_t, uint32_t>> stream_map;
25   uint8_t bits_per_sample;
26   uint32_t sampling_rate;
27   uint32_t frame_duration;
28   uint16_t octets_per_frame;
29   uint8_t blocks_per_sdu;
30   uint16_t peer_delay_ms;
31 };
32 
33 struct broadcast_offload_config {
34   std::vector<std::pair<uint16_t, uint32_t>> stream_map;
35   uint8_t bits_per_sample;
36   uint32_t sampling_rate;
37   uint32_t frame_duration;
38   uint16_t octets_per_frame;
39   uint8_t blocks_per_sdu;
40   uint32_t codec_bitrate;
41   uint8_t retransmission_number;
42   uint16_t max_transport_latency;
43 };
44 
45 class CodecManager {
46  public:
47   CodecManager();
48   virtual ~CodecManager() = default;
GetInstance(void)49   static CodecManager* GetInstance(void) {
50     static CodecManager* instance = new CodecManager();
51     return instance;
52   }
53   void Start(const std::vector<bluetooth::le_audio::btle_audio_codec_config_t>&
54                  offloading_preference);
55   void Stop(void);
56   virtual types::CodecLocation GetCodecLocation(void) const;
57   virtual void UpdateActiveSourceAudioConfig(
58       const stream_configuration& stream_conf, uint16_t delay_ms,
59       std::function<void(const ::le_audio::offload_config& config)>
60           update_receiver);
61   virtual void UpdateActiveSinkAudioConfig(
62       const stream_configuration& stream_conf, uint16_t delay_ms,
63       std::function<void(const ::le_audio::offload_config& config)>
64           update_receiver);
65   virtual const ::le_audio::set_configurations::AudioSetConfigurations*
66   GetOffloadCodecConfig(::le_audio::types::LeAudioContextType ctx_type);
67   virtual const ::le_audio::broadcast_offload_config*
68   GetBroadcastOffloadConfig();
69   virtual void UpdateBroadcastConnHandle(
70       const std::vector<uint16_t>& conn_handle,
71       std::function<void(const ::le_audio::broadcast_offload_config& config)>
72           update_receiver);
73 
74  private:
75   struct impl;
76   std::unique_ptr<impl> pimpl_;
77 };
78 }  // namespace le_audio
79