summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2024-10-21 19:17:06 +0200
committerGuru <alexandrgproductengine@lindenlab.com>2024-10-22 18:55:06 +0200
commitede5af1b18b47acea039e91c48dceb136dfbb337 (patch)
treebf2644f69c880c79f21300bcda24337a84caabdf /indra/llwebrtc
parenta86c53c212f9c80f710477816dccda9abce576ef (diff)
#2007 The 'No device' option isn't displayed in the 'Input/Output' drop-down boxes
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp43
-rw-r--r--indra/llwebrtc/llwebrtc.h3
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h5
3 files changed, 44 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]()
{
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;