Line data Source code
1 : /*
2 : * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 : *
4 : * This program is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 3 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * This program is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 : */
17 : #pragma once
18 :
19 : #include "audio_processor.h"
20 :
21 : #include <api/audio/audio_processing.h>
22 : #include <api/scoped_refptr.h>
23 :
24 : #include <vector>
25 :
26 : typedef struct WebRtcVadInst VadInst;
27 :
28 : namespace jami {
29 :
30 : class WebRTCAudioProcessor final : public AudioProcessor
31 : {
32 : public:
33 : WebRTCAudioProcessor(AudioFormat format, unsigned frameSize);
34 0 : ~WebRTCAudioProcessor() = default;
35 :
36 : // Inherited via AudioProcessor
37 : std::shared_ptr<AudioFrame> getProcessed() override;
38 :
39 : void enableEchoCancel(bool enabled) override;
40 : void enableNoiseSuppression(bool enabled) override;
41 : void enableAutomaticGainControl(bool enabled) override;
42 : void enableVoiceActivityDetection(bool enabled) override;
43 :
44 : private:
45 : void applyConfig();
46 :
47 : rtc::scoped_refptr<webrtc::AudioProcessing> apm;
48 : webrtc::AudioProcessing::Config config_;
49 : struct VadDeleter
50 : {
51 : void operator()(VadInst*) const;
52 : };
53 : std::unique_ptr<VadInst, VadDeleter> vad_;
54 : std::vector<int16_t> vadBuffer_;
55 : bool detectVoice_ {false};
56 : int analogLevel_ {0};
57 : };
58 : } // namespace jami
|