BlueGit

ict rusty-teams

Files

rusty-teams / vendor / webrtc-sys / include / livekit / apm.h

apm.h

apm.h 2.8 KiB Download Raw
1/*
2 * Copyright 2025 LiveKit, Inc.
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 <memory>
20
21#include "api/scoped_refptr.h"
22#include "api/video_codecs/video_decoder_factory.h"
23#include "api/video_codecs/video_encoder_factory.h"
24#include "modules/audio_processing/aec3/echo_canceller3.h"
25#include "modules/audio_processing/audio_buffer.h"
26
27namespace livekit_ffi {
28
29struct AudioProcessingConfig {
30 bool echo_canceller_enabled;
31 bool gain_controller_enabled;
32 bool high_pass_filter_enabled;
33 bool noise_suppression_enabled;
34
35 webrtc::AudioProcessing::Config ToWebrtcConfig() const {
36 webrtc::AudioProcessing::Config config;
37 config.echo_canceller.enabled = echo_canceller_enabled;
38 config.gain_controller2.enabled = gain_controller_enabled;
39 config.gain_controller2.adaptive_digital.enabled = gain_controller_enabled;
40 config.high_pass_filter.enabled = high_pass_filter_enabled;
41 config.noise_suppression.enabled = noise_suppression_enabled;
42 return config;
43 }
44};
45
46class AudioProcessingModule {
47 public:
48 AudioProcessingModule(const AudioProcessingConfig& config);
49 AudioProcessingModule(const webrtc::AudioProcessing::Config& config);
50
51 int process_stream(const int16_t* src,
52 size_t src_len,
53 int16_t* dst,
54 size_t dst_len,
55 int sample_rate,
56 int num_channels);
57
58 int process_reverse_stream(const int16_t* src,
59 size_t src_len,
60 int16_t* dst,
61 size_t dst_len,
62 int sample_rate,
63 int num_channels);
64
65 int set_stream_delay_ms(int delay_ms);
66
67 private:
68 webrtc::scoped_refptr<webrtc::AudioProcessing> apm_;
69};
70
71std::unique_ptr<AudioProcessingModule> create_apm(
72 bool echo_canceller_enabled,
73 bool gain_controller_enabled,
74 bool high_pass_filter_enabled,
75 bool noise_suppression_enabled);
76
77std::unique_ptr<AudioProcessingModule> create_gain_apm(bool adaptive,
78 float initial_gain_db,
79 float fixed_gain_db,
80 float max_gain_change_db_per_second);
81
82} // namespace livekit_ffi