diff options
Diffstat (limited to 'indra/llwebrtc/llwebrtc.cpp')
-rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 0daa767766..a73962f3d6 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; } @@ -438,7 +442,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 +506,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 +550,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 +580,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 +603,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) { @@ -933,20 +957,20 @@ void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp) void LLWebRTCPeerConnectionImpl::setMute(bool mute) { mMute = mute; + mute |= mWebRTCImpl->isCaptureNoDevice(); mWebRTCImpl->PostSignalingTask( - [this]() + [&]() { 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 +984,11 @@ void LLWebRTCPeerConnectionImpl::resetMute() void LLWebRTCPeerConnectionImpl::setReceiveVolume(float volume) { + if (mWebRTCImpl->isRenderNoDevice()) + { + volume = 0; + } + mWebRTCImpl->PostSignalingTask( [this, volume]() { |