| 1 | #include "livekit/noise_hook.h" |
| 2 | |
| 3 | #include <string> |
| 4 | |
| 5 | #include "modules/audio_processing/audio_buffer.h" |
| 6 | #include "rust/cxx.h" |
| 7 | #include "webrtc-sys/src/noise_hook.rs.h" |
| 8 | |
| 9 | namespace livekit_ffi { |
| 10 | |
| 11 | namespace { |
| 12 | |
| 13 | class CapturePostProcessor : public webrtc::CustomProcessing { |
| 14 | public: |
| 15 | void Initialize(int sample_rate_hz, int num_channels) override {} |
| 16 | |
| 17 | void Process(webrtc::AudioBuffer* audio) override { |
| 18 | for (size_t channel = 0; channel < audio->num_channels(); ++channel) { |
| 19 | capture_post_process( |
| 20 | channel, |
| 21 | rust::Slice<float>(audio->channels()[channel], audio->num_frames())); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | std::string ToString() const override { return "livekit_capture_post_processor"; } |
| 26 | |
| 27 | void SetRuntimeSetting(webrtc::AudioProcessing::RuntimeSetting setting) override {} |
| 28 | }; |
| 29 | |
| 30 | } // namespace |
| 31 | |
| 32 | std::unique_ptr<webrtc::CustomProcessing> create_capture_post_processor() { |
| 33 | return std::make_unique<CapturePostProcessor>(); |
| 34 | } |
| 35 | |
| 36 | } // namespace livekit_ffi |