summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llwebrtc/llwebrtc.cpp58
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h2
2 files changed, 51 insertions, 9 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 2c890acbdb..d154bfb8eb 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -251,8 +251,7 @@ void LLWebRTCImpl::init()
apm_config.noise_suppression.level = webrtc::AudioProcessing::Config::NoiseSuppression::kVeryHigh;
apm_config.transient_suppression.enabled = true;
apm_config.pipeline.multi_channel_render = true;
- apm_config.pipeline.multi_channel_capture = true;
- apm_config.pipeline.multi_channel_capture = true;
+ apm_config.pipeline.multi_channel_capture = false;
webrtc::ProcessingConfig processing_config;
processing_config.input_stream().set_num_channels(2);
@@ -279,7 +278,6 @@ void LLWebRTCImpl::init()
nullptr /* audio_mixer */,
mAudioProcessingModule);
- mWorkerThread->BlockingCall([this]() { mPeerDeviceModule->StartPlayout(); });
}
void LLWebRTCImpl::terminate()
@@ -340,6 +338,22 @@ void LLWebRTCImpl::setRecording(bool recording)
});
}
+void LLWebRTCImpl::setPlayout(bool playing)
+{
+ mWorkerThread->PostTask(
+ [this, playing]()
+ {
+ if (playing)
+ {
+ mPeerDeviceModule->StartPlayout();
+ }
+ else
+ {
+ mPeerDeviceModule->StopPlayout();
+ }
+ });
+}
+
void LLWebRTCImpl::setAudioConfig(LLWebRTCDeviceInterface::AudioConfig config)
{
webrtc::AudioProcessing::Config apm_config;
@@ -402,7 +416,6 @@ void LLWebRTCImpl::unsetDevicesObserver(LLWebRTCDevicesObserver *observer)
void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device)
{
- device_module->StopRecording();
#if WEBRTC_WIN
if (device < 0)
{
@@ -420,7 +433,6 @@ void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceM
device_module->InitMicrophone();
device_module->InitRecording();
device_module->SetStereoRecording(false);
- device_module->StartRecording();
}
void LLWebRTCImpl::setCaptureDevice(const std::string &id)
@@ -444,18 +456,32 @@ void LLWebRTCImpl::setCaptureDevice(const std::string &id)
mRecordingDevice = recordingDevice;
if (mTuningMode)
{
- mWorkerThread->PostTask([this, recordingDevice]() { ll_set_device_module_capture_device(mTuningDeviceModule, recordingDevice); });
+ mWorkerThread->PostTask([this, recordingDevice]()
+ {
+ ll_set_device_module_capture_device(mTuningDeviceModule, recordingDevice);
+ });
}
else
{
- mWorkerThread->PostTask([this, recordingDevice]() { ll_set_device_module_capture_device(mPeerDeviceModule, recordingDevice); });
+ mWorkerThread->PostTask([this, recordingDevice]()
+ {
+ bool recording = mPeerDeviceModule->Recording();
+ if (recording)
+ {
+ mPeerDeviceModule->StopRecording();
+ }
+ ll_set_device_module_capture_device(mPeerDeviceModule, recordingDevice);
+ if (recording)
+ {
+ mPeerDeviceModule->StartRecording();
+ }
+ });
}
}
void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device)
{
- device_module->StopPlayout();
#if WEBRTC_WIN
if (device < 0)
{
@@ -506,8 +532,16 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
mWorkerThread->PostTask(
[this, playoutDevice]()
{
+ bool playing = mPeerDeviceModule->Playing();
+ if (playing)
+ {
+ mPeerDeviceModule->StopPlayout();
+ }
ll_set_device_module_render_device(mPeerDeviceModule, playoutDevice);
- mPeerDeviceModule->StartPlayout();
+ if (playing)
+ {
+ mPeerDeviceModule->StartPlayout();
+ }
});
}
}
@@ -633,6 +667,11 @@ LLWebRTCPeerConnectionInterface *LLWebRTCImpl::newPeerConnection()
rtc::scoped_refptr<LLWebRTCPeerConnectionImpl> peerConnection = rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>(new rtc::RefCountedObject<LLWebRTCPeerConnectionImpl>());
peerConnection->init(this);
+ if (mPeerConnections.empty())
+ {
+ setRecording(true);
+ setPlayout(true);
+ }
mPeerConnections.emplace_back(peerConnection);
peerConnection->enableSenderTracks(!mMute);
return peerConnection.get();
@@ -649,6 +688,7 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn
if (mPeerConnections.empty())
{
setRecording(false);
+ setPlayout(false);
}
}
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index c5b32123eb..f8a7873af8 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -278,6 +278,8 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
// enables/disables capture via the capture device
void setRecording(bool recording);
+ void setPlayout(bool playing);
+
protected:
LLWebRTCLogSink* mLogSink;