diff options
Diffstat (limited to 'indra/llwebrtc')
| -rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 20 | ||||
| -rw-r--r-- | indra/llwebrtc/llwebrtc.h | 1 | ||||
| -rw-r--r-- | indra/llwebrtc/llwebrtc_impl.h | 5 | 
3 files changed, 20 insertions, 6 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 14fb63ec2a..d5bd913315 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -35,6 +35,7 @@  #include "api/media_stream_interface.h"  #include "api/media_stream_track.h"  #include "modules/audio_processing/audio_buffer.h" +#include "modules/audio_mixer/audio_mixer_impl.h"  namespace llwebrtc  { @@ -88,7 +89,7 @@ void LLAudioDeviceObserver::OnRenderData(const void    *audio_samples,  {  } -LLCustomProcessor::LLCustomProcessor() : mSampleRateHz(0), mNumChannels(0), mMicrophoneEnergy(0.0) +LLCustomProcessor::LLCustomProcessor() : mSampleRateHz(0), mNumChannels(0), mMicrophoneEnergy(0.0), mGain(1.0)  {      memset(mSumVector, 0, sizeof(mSumVector));  } @@ -128,9 +129,13 @@ void LLCustomProcessor::Process(webrtc::AudioBuffer *audio_in)      for (size_t index = 0; index < stream_config.num_samples(); index++)      {          float sample = frame_samples[index]; +        sample       = sample * mGain; // apply gain +        frame_samples[index] = sample; // write processed sample back to buffer.          energy += sample * sample;      } +    audio_in->CopyFrom(&frame[0], stream_config); +      // smooth it.      size_t buffer_size = sizeof(mSumVector) / sizeof(mSumVector[0]);      float  totalSum    = 0; @@ -236,9 +241,9 @@ void LLWebRTCImpl::init()      webrtc::AudioProcessing::Config apm_config;      apm_config.echo_canceller.enabled         = false;      apm_config.echo_canceller.mobile_mode     = false; -    apm_config.gain_controller1.enabled       = true; +    apm_config.gain_controller1.enabled       = false;      apm_config.gain_controller1.mode          = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog; -    apm_config.gain_controller2.enabled       = true; +    apm_config.gain_controller2.enabled       = false;      apm_config.high_pass_filter.enabled       = true;      apm_config.noise_suppression.enabled      = true;      apm_config.noise_suppression.level        = webrtc::AudioProcessing::Config::NoiseSuppression::kVeryHigh; @@ -260,6 +265,7 @@ void LLWebRTCImpl::init()      mAudioProcessingModule->ApplyConfig(apm_config);      mAudioProcessingModule->Initialize(processing_config); +      mPeerConnectionFactory = webrtc::CreatePeerConnectionFactory(mNetworkThread.get(),                                                                   mWorkerThread.get(),                                                                   mSignalingThread.get(), @@ -336,9 +342,9 @@ void LLWebRTCImpl::setAudioConfig(LLWebRTCDeviceInterface::AudioConfig config)      webrtc::AudioProcessing::Config apm_config;      apm_config.echo_canceller.enabled         = config.mEchoCancellation;      apm_config.echo_canceller.mobile_mode     = false; -    apm_config.gain_controller1.enabled       = true; +    apm_config.gain_controller1.enabled       = config.mAGC;      apm_config.gain_controller1.mode          = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog; -    apm_config.gain_controller2.enabled       = true; +    apm_config.gain_controller2.enabled       = false;      apm_config.high_pass_filter.enabled       = true;      apm_config.transient_suppression.enabled  = true;      apm_config.pipeline.multi_channel_render  = true; @@ -612,6 +618,8 @@ float LLWebRTCImpl::getTuningAudioLevel() { return -20 * log10f(mTuningAudioDevi  float LLWebRTCImpl::getPeerConnectionAudioLevel() { return -20 * log10f(mPeerCustomProcessor->getMicrophoneEnergy()); } +void LLWebRTCImpl::setPeerConnectionGain(float gain) { mPeerCustomProcessor->setGain(gain); } +  //  // Peer Connection Helpers @@ -937,7 +945,7 @@ void LLWebRTCPeerConnectionImpl::setSendVolume(float volume)              {                  for (auto &track : mLocalStream->GetAudioTracks())                  { -                    track->GetSource()->SetVolume(volume); +                    track->GetSource()->SetVolume(volume*5.0);                  }              }          }); diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h index ecbab81538..f447ea990a 100644 --- a/indra/llwebrtc/llwebrtc.h +++ b/indra/llwebrtc/llwebrtc.h @@ -145,6 +145,7 @@ class LLWebRTCDeviceInterface      virtual void setTuningMode(bool enable) = 0;      virtual float getTuningAudioLevel() = 0; // for use during tuning      virtual float getPeerConnectionAudioLevel() = 0; // for use when not tuning +    virtual void setPeerConnectionGain(float gain) = 0;  };  // LLWebRTCAudioInterface provides the viewer with a way diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index 448d36e3ea..6672f8ce90 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -121,6 +121,8 @@ class LLCustomProcessor : public webrtc::CustomProcessing      float getMicrophoneEnergy() { return mMicrophoneEnergy; } +    void setGain(float gain) { mGain = gain; } +    protected:      static const int NUM_PACKETS_TO_FILTER = 30;  // 300 ms of smoothing      int              mSampleRateHz; @@ -128,6 +130,7 @@ class LLCustomProcessor : public webrtc::CustomProcessing      float mSumVector[NUM_PACKETS_TO_FILTER];      float mMicrophoneEnergy; +    float mGain;  }; @@ -160,6 +163,8 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS      float getTuningAudioLevel() override;      float getPeerConnectionAudioLevel() override; +    void setPeerConnectionGain(float gain) override; +      //      // AudioDeviceSink      //  | 
