summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-08-20 08:37:10 +0800
committerErik Kundiman <erik@megapahit.org>2024-08-20 08:37:10 +0800
commit6f5e0c4174a8cc263397bfac51e6130c39b728b4 (patch)
tree9dfbd3ef1cec73bd68975a6febfc360f5b68318e /indra/llwebrtc
parentb7afbe59c42a3e6e92f712153172364f4ebaa5e2 (diff)
parent75a5cd62d7f63f642d4d88fafc955aaf22f471e7 (diff)
Merge remote-tracking branch 'secondlife/release/2024.06-atlasaurus' into 2024.06-atlasaurus
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/CMakeLists.txt6
-rw-r--r--indra/llwebrtc/llwebrtc.cpp86
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h2
3 files changed, 71 insertions, 23 deletions
diff --git a/indra/llwebrtc/CMakeLists.txt b/indra/llwebrtc/CMakeLists.txt
index d6217ff3a4..425376d248 100644
--- a/indra/llwebrtc/CMakeLists.txt
+++ b/indra/llwebrtc/CMakeLists.txt
@@ -33,6 +33,7 @@ set_target_properties(llwebrtc PROPERTIES PUBLIC_HEADER llwebrtc.h)
endif ()
if (WINDOWS)
+ cmake_policy(SET CMP0091 NEW)
set_target_properties(llwebrtc
PROPERTIES
LINK_FLAGS "/debug /LARGEADDRESSAWARE"
@@ -44,7 +45,10 @@ if (WINDOWS)
wmcodecdspuuid
msdmo
strmiids
- iphlpapi)
+ iphlpapi
+ libcmt)
+ # as the webrtc libraries are release, build this binary as release as well.
+ target_compile_options(llwebrtc PRIVATE "/MT")
if (USE_BUGSPLAT)
set_target_properties(llwebrtc PROPERTIES PDB_OUTPUT_DIRECTORY "${SYMBOLS_STAGING_DIR}")
endif (USE_BUGSPLAT)
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index e533783d33..83350dd457 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -208,10 +208,10 @@ void LLWebRTCImpl::init()
#endif
mTuningDeviceModule->InitMicrophone();
mTuningDeviceModule->InitSpeaker();
+ mTuningDeviceModule->SetStereoRecording(false);
+ mTuningDeviceModule->SetStereoPlayout(true);
mTuningDeviceModule->InitRecording();
mTuningDeviceModule->InitPlayout();
- mTuningDeviceModule->SetStereoRecording(true);
- mTuningDeviceModule->SetStereoPlayout(true);
updateDevices();
});
@@ -229,10 +229,6 @@ void LLWebRTCImpl::init()
mPeerDeviceModule->EnableBuiltInAEC(false);
mPeerDeviceModule->InitMicrophone();
mPeerDeviceModule->InitSpeaker();
- mPeerDeviceModule->InitRecording();
- mPeerDeviceModule->InitPlayout();
- mPeerDeviceModule->SetStereoRecording(true);
- mPeerDeviceModule->SetStereoPlayout(true);
});
// The custom processor allows us to retrieve audio data (and levels)
@@ -253,8 +249,9 @@ 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;
+
+ mAudioProcessingModule->ApplyConfig(apm_config);
webrtc::ProcessingConfig processing_config;
processing_config.input_stream().set_num_channels(2);
@@ -266,10 +263,8 @@ void LLWebRTCImpl::init()
processing_config.reverse_output_stream().set_num_channels(2);
processing_config.reverse_output_stream().set_sample_rate_hz(48000);
- mAudioProcessingModule->ApplyConfig(apm_config);
mAudioProcessingModule->Initialize(processing_config);
-
mPeerConnectionFactory = webrtc::CreatePeerConnectionFactory(mNetworkThread.get(),
mWorkerThread.get(),
mSignalingThread.get(),
@@ -281,7 +276,6 @@ void LLWebRTCImpl::init()
nullptr /* audio_mixer */,
mAudioProcessingModule);
- mWorkerThread->BlockingCall([this]() { mPeerDeviceModule->StartPlayout(); });
}
void LLWebRTCImpl::terminate()
@@ -333,6 +327,8 @@ void LLWebRTCImpl::setRecording(bool recording)
{
if (recording)
{
+ mPeerDeviceModule->SetStereoRecording(false);
+ mPeerDeviceModule->InitRecording();
mPeerDeviceModule->StartRecording();
}
else
@@ -342,6 +338,24 @@ void LLWebRTCImpl::setRecording(bool recording)
});
}
+void LLWebRTCImpl::setPlayout(bool playing)
+{
+ mWorkerThread->PostTask(
+ [this, playing]()
+ {
+ if (playing)
+ {
+ mPeerDeviceModule->SetStereoPlayout(true);
+ mPeerDeviceModule->InitPlayout();
+ mPeerDeviceModule->StartPlayout();
+ }
+ else
+ {
+ mPeerDeviceModule->StopPlayout();
+ }
+ });
+}
+
void LLWebRTCImpl::setAudioConfig(LLWebRTCDeviceInterface::AudioConfig config)
{
webrtc::AudioProcessing::Config apm_config;
@@ -404,7 +418,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)
{
@@ -419,10 +432,9 @@ void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceM
// has it at 0
device_module->SetRecordingDevice(device + 1);
#endif
+ device_module->SetStereoRecording(false);
device_module->InitMicrophone();
device_module->InitRecording();
- device_module->SetStereoRecording(false);
- device_module->StartRecording();
}
void LLWebRTCImpl::setCaptureDevice(const std::string &id)
@@ -446,18 +458,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)
{
@@ -470,9 +496,9 @@ void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceMo
#else
device_module->SetPlayoutDevice(device + 1);
#endif
+ device_module->SetStereoPlayout(true);
device_module->InitSpeaker();
device_module->InitPlayout();
- device_module->SetStereoPlayout(true);
}
void LLWebRTCImpl::setRenderDevice(const std::string &id)
@@ -508,8 +534,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();
+ }
});
}
}
@@ -594,6 +628,8 @@ void LLWebRTCImpl::setTuningMode(bool enable)
//mTuningDeviceModule->StopPlayout();
ll_set_device_module_render_device(mPeerDeviceModule, mPlayoutDevice);
ll_set_device_module_capture_device(mPeerDeviceModule, mRecordingDevice);
+ mPeerDeviceModule->SetStereoPlayout(true);
+ mPeerDeviceModule->SetStereoRecording(false);
mPeerDeviceModule->InitPlayout();
mPeerDeviceModule->InitRecording();
mPeerDeviceModule->StartPlayout();
@@ -637,6 +673,11 @@ LLWebRTCPeerConnectionInterface *LLWebRTCImpl::newPeerConnection()
mPeerConnections.emplace_back(peerConnection);
peerConnection->enableSenderTracks(!mMute);
+ if (mPeerConnections.empty())
+ {
+ setRecording(true);
+ setPlayout(true);
+ }
return peerConnection.get();
}
@@ -651,6 +692,7 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn
if (mPeerConnections.empty())
{
setRecording(false);
+ setPlayout(false);
}
}
@@ -664,7 +706,7 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn
LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() :
mWebRTCImpl(nullptr),
mPeerConnection(nullptr),
- mMute(false),
+ mMute(true),
mAnswerReceived(false)
{
}
@@ -686,8 +728,8 @@ void LLWebRTCPeerConnectionImpl::init(LLWebRTCImpl * webrtc_impl)
}
void LLWebRTCPeerConnectionImpl::terminate()
{
- mWebRTCImpl->PostSignalingTask(
- [=]()
+ mWebRTCImpl->SignalingBlockingCall(
+ [this]()
{
if (mPeerConnection)
{
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index bc9b7762dd..6543b2718c 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -285,6 +285,8 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface
// enables/disables capture via the capture device
void setRecording(bool recording);
+ void setPlayout(bool playing);
+
protected:
LLWebRTCLogSink* mLogSink;