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