summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp69
-rw-r--r--indra/llwebrtc/llwebrtc.h3
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h5
3 files changed, 60 insertions, 17 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 0daa767766..e02bf5919b 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -45,6 +45,10 @@ static int16_t PLAYOUT_DEVICE_BAD = -2;
static int16_t RECORD_DEVICE_DEFAULT = -1;
static int16_t RECORD_DEVICE_BAD = -2;
+static const std::string DEFAULT_DEVICE_NAME = "Default";
+static const std::string NO_DEVICE_NAME = "No Device";
+static const std::string NO_DEVICE_GUID;
+
LLAudioDeviceObserver::LLAudioDeviceObserver() : mSumVector {0}, mMicrophoneEnergy(0.0) {}
float LLAudioDeviceObserver::getMicrophoneEnergy() { return mMicrophoneEnergy; }
@@ -242,10 +246,10 @@ void LLWebRTCImpl::init()
apm_config.gain_controller1.enabled = false;
apm_config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog;
apm_config.gain_controller2.enabled = false;
- apm_config.high_pass_filter.enabled = true;
+ apm_config.high_pass_filter.enabled = false;
apm_config.noise_suppression.enabled = true;
apm_config.noise_suppression.level = webrtc::AudioProcessing::Config::NoiseSuppression::kVeryHigh;
- apm_config.transient_suppression.enabled = true;
+ apm_config.transient_suppression.enabled = false;
apm_config.pipeline.multi_channel_render = true;
apm_config.pipeline.multi_channel_capture = false;
@@ -358,14 +362,13 @@ 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.echo_canceller.mobile_mode = false; // don't use mobile hardware echo cancellation.
apm_config.gain_controller1.enabled = config.mAGC;
apm_config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog;
- 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;
- apm_config.pipeline.multi_channel_capture = true;
+ apm_config.gain_controller2.enabled = false; // use the main gain controller.
+ apm_config.high_pass_filter.enabled = false; // don't filter, to improve quality for music and other pure sources.
+ apm_config.transient_suppression.enabled = false; // transient suppression may increase latency.
+ apm_config.pipeline.multi_channel_render = true; // stereo
apm_config.pipeline.multi_channel_capture = true;
switch (config.mNoiseSuppressionLevel)
@@ -438,7 +441,7 @@ void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceM
void LLWebRTCImpl::setCaptureDevice(const std::string &id)
{
int16_t recordingDevice = RECORD_DEVICE_DEFAULT;
- if (id != "Default")
+ if (id != DEFAULT_DEVICE_NAME)
{
for (int16_t i = 0; i < mRecordingDeviceList.size(); i++)
{
@@ -502,7 +505,7 @@ void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceMo
void LLWebRTCImpl::setRenderDevice(const std::string &id)
{
int16_t playoutDevice = PLAYOUT_DEVICE_DEFAULT;
- if (id != "Default")
+ if (id != DEFAULT_DEVICE_NAME)
{
for (int16_t i = 0; i < mPlayoutDeviceList.size(); i++)
{
@@ -546,6 +549,16 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
}
}
+bool LLWebRTCImpl::isCaptureNoDevice()
+{
+ return mRecordingDevice == mRecordingNoDevice;
+}
+
+bool LLWebRTCImpl::isRenderNoDevice()
+{
+ return mPlayoutDevice == mPlayoutNoDevice;
+}
+
// updateDevices needs to happen on the worker thread.
void LLWebRTCImpl::updateDevices()
{
@@ -566,6 +579,11 @@ void LLWebRTCImpl::updateDevices()
mTuningDeviceModule->PlayoutDeviceName(index, name, guid);
mPlayoutDeviceList.emplace_back(name, guid);
}
+ mPlayoutNoDevice = (int32_t)mPlayoutDeviceList.size();
+ if (mPlayoutNoDevice)
+ {
+ mPlayoutDeviceList.emplace_back(NO_DEVICE_NAME, NO_DEVICE_GUID);
+ }
int16_t captureDeviceCount = mTuningDeviceModule->RecordingDevices();
@@ -584,6 +602,11 @@ void LLWebRTCImpl::updateDevices()
mTuningDeviceModule->RecordingDeviceName(index, name, guid);
mRecordingDeviceList.emplace_back(name, guid);
}
+ mRecordingNoDevice = (int32_t)mRecordingDeviceList.size();
+ if (mRecordingNoDevice)
+ {
+ mRecordingDeviceList.emplace_back(NO_DEVICE_NAME, NO_DEVICE_GUID);
+ }
for (auto &observer : mVoiceDevicesObserverList)
{
@@ -726,7 +749,7 @@ void LLWebRTCPeerConnectionImpl::init(LLWebRTCImpl * webrtc_impl)
}
void LLWebRTCPeerConnectionImpl::terminate()
{
- mWebRTCImpl->SignalingBlockingCall(
+ mWebRTCImpl->PostSignalingTask(
[this]()
{
if (mPeerConnection)
@@ -851,6 +874,13 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti
codecparam.parameters["stereo"] = "1";
codecparam.parameters["sprop-stereo"] = "1";
params.codecs.push_back(codecparam);
+
+ // Fixed bitrates result in lower CPU cost
+ for (auto&& encoding : params.encodings)
+ {
+ encoding.max_bitrate_bps = 64000;
+ encoding.min_bitrate_bps = 64000;
+ }
sender->SetParameters(params);
}
@@ -933,20 +963,20 @@ void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp)
void LLWebRTCPeerConnectionImpl::setMute(bool mute)
{
mMute = mute;
+ mute |= mWebRTCImpl->isCaptureNoDevice();
mWebRTCImpl->PostSignalingTask(
- [this]()
+ [this, mute]()
{
if (mPeerConnection)
{
auto senders = mPeerConnection->GetSenders();
- RTC_LOG(LS_INFO) << __FUNCTION__ << (mMute ? "disabling" : "enabling") << " streams count " << senders.size();
+ RTC_LOG(LS_INFO) << __FUNCTION__ << (mute ? "disabling" : "enabling") << " streams count " << senders.size();
for (auto &sender : senders)
{
- auto track = sender->track();
- if (track)
+ if (auto track = sender->track())
{
- track->set_enabled(!mMute);
+ track->set_enabled(!mute);
}
}
}
@@ -960,6 +990,11 @@ void LLWebRTCPeerConnectionImpl::resetMute()
void LLWebRTCPeerConnectionImpl::setReceiveVolume(float volume)
{
+ if (mWebRTCImpl->isRenderNoDevice())
+ {
+ volume = 0;
+ }
+
mWebRTCImpl->PostSignalingTask(
[this, volume]()
{
@@ -1202,7 +1237,7 @@ void LLWebRTCPeerConnectionImpl::OnSuccess(webrtc::SessionDescriptionInterface *
else if (sdp_line.find("a=fmtp:" + opus_payload) == 0)
{
sdp_mangled_stream << sdp_line << "a=fmtp:" << opus_payload
- << " minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1;maxplaybackrate=48000;sprop-maxplaybackrate=48000;sprop-maxcapturerate=48000\n";
+ << " minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1;maxplaybackrate=48000;sprop-maxplaybackrate=48000;sprop-maxcapturerate=48000;complexity=4\n";
}
else
{
diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h
index c6fdb909dd..2deaba9e58 100644
--- a/indra/llwebrtc/llwebrtc.h
+++ b/indra/llwebrtc/llwebrtc.h
@@ -151,6 +151,9 @@ class LLWebRTCDeviceInterface
virtual void setCaptureDevice(const std::string& id) = 0;
virtual void setRenderDevice(const std::string& id) = 0;
+ virtual bool isCaptureNoDevice() = 0;
+ virtual bool isRenderNoDevice() = 0;
+
// Device observers for device change callbacks.
virtual void setDevicesObserver(LLWebRTCDevicesObserver *observer) = 0;
virtual void unsetDevicesObserver(LLWebRTCDevicesObserver *observer) = 0;
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index b93a1fdb01..27b7eae8e7 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -210,6 +210,9 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
void setCaptureDevice(const std::string& id) override;
void setRenderDevice(const std::string& id) override;
+ bool isCaptureNoDevice() override;
+ bool isRenderNoDevice() override;
+
void setTuningMode(bool enable) override;
float getTuningAudioLevel() override;
float getPeerConnectionAudioLevel() override;
@@ -306,9 +309,11 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
// accessors in native webrtc for devices aren't apparently implemented yet.
bool mTuningMode;
int32_t mRecordingDevice;
+ int32_t mRecordingNoDevice;
LLWebRTCVoiceDeviceList mRecordingDeviceList;
int32_t mPlayoutDevice;
+ int32_t mPlayoutNoDevice;
LLWebRTCVoiceDeviceList mPlayoutDeviceList;
bool mMute;