fork/rust-sdks
git clone https://git.julia.blue/fork/rust-sdks
7cbdddf
main
1/* 2* Copyright 2023 LiveKit 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 { 28 29struct AudioProcessingConfig { 30bool echo_canceller_enabled ; 31bool gain_controller_enabled ; 32bool high_pass_filter_enabled ; 33bool noise_suppression_enabled ; 34 35webrtc ::AudioProcessing ::Config ToWebrtcConfig ()const { 36webrtc ::AudioProcessing ::Config config ; 37config .echo_canceller .enabled = echo_canceller_enabled ; 38config .gain_controller2 .enabled = gain_controller_enabled ; 39config .high_pass_filter .enabled = high_pass_filter_enabled ; 40config .noise_suppression .enabled = noise_suppression_enabled ; 41return config ; 42 } 43}; 44 45class AudioProcessingModule { 46public : 47AudioProcessingModule (const AudioProcessingConfig & config ); 48 49int process_stream ( const int16_t * src, 50size_t src_len, 51int16_t * dst, 52size_t dst_len, 53int sample_rate, 54int num_channels); 55 56int process_reverse_stream ( const int16_t * src, 57size_t src_len, 58int16_t * dst, 59size_t dst_len, 60int sample_rate, 61int num_channels); 62 63int set_stream_delay_ms ( int delay_ms); 64 65private : 66rtc ::scoped_refptr < webrtc::AudioProcessing > apm_; 67}; 68 69std ::unique_ptr < AudioProcessingModule > create_apm ( 70bool echo_canceller_enabled, 71bool gain_controller_enabled, 72bool high_pass_filter_enabled, 73bool noise_suppression_enabled); 74 75} // namespace livekit