summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorRoxanne Skelly <roxie@lindenlab.com>2024-04-01 09:13:32 -0700
committerGitHub <noreply@github.com>2024-04-01 09:13:32 -0700
commitd59d0c98fe491feb9f8479f399ccb30667f98e85 (patch)
tree1f743fdb9b737a2b59f0a5c2bf14ebf43b72ceeb /indra/newview
parent07ac9ac5874b88d46735d48dcccb196b65332329 (diff)
parentc6e673cda139f5faaa52ccd03a372e7ffa9f5716 (diff)
Merge pull request #1100 from secondlife/roxie/webrtc-voice
[WebRTC] Add UI for AGC, Echo Cancellation, and Noise Reduction; use Linden STUN servers.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/settings.xml33
-rw-r--r--indra/newview/llviewercontrol.cpp3
-rw-r--r--indra/newview/llvoicevivox.cpp4
-rw-r--r--indra/newview/llvoicewebrtc.cpp39
-rw-r--r--indra/newview/llvoicewebrtc.h2
-rw-r--r--indra/newview/skins/default/xui/en/panel_preferences_sound.xml69
6 files changed, 139 insertions, 11 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 5f7d1d8a21..0de6db0d65 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -15108,6 +15108,39 @@
<key>Value</key>
<integer>44125</integer>
</map>
+ <key>VoiceEchoCancellation</key>
+ <map>
+ <key>Comment</key>
+ <string>Voice Echo Cancellation</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>1</integer>
+ </map>
+ <key>VoiceAutomaticGainControl</key>
+ <map>
+ <key>Comment</key>
+ <string>Voice Automatic Gain Control</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>1</integer>
+ </map>
+ <key>VoiceNoiseSuppressionLevel</key>
+ <map>
+ <key>Comment</key>
+ <string>Voice Noise Suppression Level</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>U32</string>
+ <key>Value</key>
+ <integer>4</integer>
+ </map>
<key>WarningsAsChat</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 7738cb904e..44173a8043 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -803,6 +803,9 @@ void settings_setup_listeners()
setting_setup_signal_listener(gSavedSettings, "PushToTalkButton", handleVoiceClientPrefsChanged);
setting_setup_signal_listener(gSavedSettings, "PushToTalkToggle", handleVoiceClientPrefsChanged);
setting_setup_signal_listener(gSavedSettings, "VoiceEarLocation", handleVoiceClientPrefsChanged);
+ setting_setup_signal_listener(gSavedSettings, "VoiceEchoCancellation", handleVoiceClientPrefsChanged);
+ setting_setup_signal_listener(gSavedSettings, "VoiceAutomaticGainControl", handleVoiceClientPrefsChanged);
+ setting_setup_signal_listener(gSavedSettings, "VoiceNoiseSuppressionLevel", handleVoiceClientPrefsChanged);
setting_setup_signal_listener(gSavedSettings, "VoiceInputAudioDevice", handleVoiceClientPrefsChanged);
setting_setup_signal_listener(gSavedSettings, "VoiceOutputAudioDevice", handleVoiceClientPrefsChanged);
setting_setup_signal_listener(gSavedSettings, "AudioLevelMic", handleVoiceClientPrefsChanged);
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 29aba8ecba..f5c9e3aa98 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -1154,7 +1154,9 @@ bool LLVivoxVoiceClient::provisionVoiceAccount()
do
{
LLVoiceVivoxStats::getInstance()->provisionAttemptStart();
- result = httpAdapter->postAndSuspend(httpRequest, url, LLSD(), httpOpts);
+ LLSD body;
+ body["voice_server_type"] = "vivox";
+ result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts);
if (sShuttingDown)
{
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp
index 72d343598b..f3d3460022 100644
--- a/indra/newview/llvoicewebrtc.cpp
+++ b/indra/newview/llvoicewebrtc.cpp
@@ -24,6 +24,7 @@
* $/LicenseInfo$
*/
#include <algorithm>
+#include <format>
#include "llvoicewebrtc.h"
#include "llsdutil.h"
@@ -279,7 +280,7 @@ void LLWebRTCVoiceClient::cleanUp()
LL_DEBUGS("Voice") << "Exiting" << LL_ENDL;
}
-//---------------------------------------------------
+// --------------------------------------------------
const LLVoiceVersionInfo& LLWebRTCVoiceClient::getVersion()
{
@@ -301,6 +302,13 @@ void LLWebRTCVoiceClient::updateSettings()
setRenderDevice(outputDevice);
F32 mic_level = gSavedSettings.getF32("AudioLevelMic");
setMicGain(mic_level);
+
+ llwebrtc::LLWebRTCDeviceInterface::AudioConfig config;
+ config.mEchoCancellation = gSavedSettings.getBOOL("VoiceEchoCancellation");
+ config.mAGC = gSavedSettings.getBOOL("VoiceAutomaticGainControl");
+ config.mNoiseSuppressionLevel = (llwebrtc::LLWebRTCDeviceInterface::AudioConfig::ENoiseSuppressionLevel)gSavedSettings.getU32("VoiceNoiseSuppressionLevel");
+ mWebRTCDeviceInterface->setAudioConfig(config);
+
}
// Observers
@@ -2515,6 +2523,28 @@ void LLVoiceWebRTCConnection::OnVoiceConnectionRequestSuccess(const LLSD &result
mWebRTCPeerConnectionInterface->AnswerAvailable(mRemoteChannelSDP);
}
+static llwebrtc::LLWebRTCPeerConnectionInterface::InitOptions getConnectionOptions()
+{
+ llwebrtc::LLWebRTCPeerConnectionInterface::InitOptions options;
+ llwebrtc::LLWebRTCPeerConnectionInterface::InitOptions::IceServers servers;
+
+ // TODO: Pull these from login
+ std::string grid = LLGridManager::getInstance()->getGridLoginID();
+ std::transform(grid.begin(), grid.end(), grid.begin(), [](unsigned char c){ return std::tolower(c); });
+ int num_servers = 2;
+ if (grid == "agni")
+ {
+ num_servers = 3;
+ }
+ for (int i=1; i <= num_servers; i++)
+ {
+ servers.mUrls.push_back(llformat("stun:stun%d.%s.secondlife.io:3478", i, grid.c_str()));
+ }
+ options.mServers.push_back(servers);
+ return options;
+}
+
+
// Primary state machine for negotiating a single voice connection to the
// Secondlife WebRTC server.
bool LLVoiceWebRTCConnection::connectionStateMachine()
@@ -2535,10 +2565,11 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
}
mIceCompleted = false;
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_SESSION_START);
+
// tell the webrtc library that we want a connection. The library will
// respond with an offer on a separate thread, which will cause
// the session state to change.
- if (!mWebRTCPeerConnectionInterface->initializeConnection())
+ if (!mWebRTCPeerConnectionInterface->initializeConnection(getConnectionOptions()))
{
setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
}
@@ -2733,8 +2764,8 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
LLUUID agent_id(participant_id);
if (agent_id.isNull())
{
- LL_WARNS("Voice") << "Bad participant ID from data channel (" << participant_id << "):" << data << LL_ENDL;
- continue;
+ // probably a test client.
+ continue;
}
LLWebRTCVoiceClient::participantStatePtr_t participant =
diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h
index 4fe0e756a7..aa3298ec1b 100644
--- a/indra/newview/llvoicewebrtc.h
+++ b/indra/newview/llvoicewebrtc.h
@@ -274,7 +274,7 @@ public:
participantStatePtr_t findParticipantByID(const LLUUID& id);
static ptr_t matchSessionByChannelID(const std::string& channel_id);
-
+
void shutdownAllConnections();
void revive();
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml
index ab2e9c72f3..3dba5d060b 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml
@@ -340,7 +340,7 @@
follows="left|top"
top_delta="-6"
layout="topleft"
- left_pad="20"
+ left_pad="10"
width="360"
height="40"
name="media_ear_location">
@@ -422,7 +422,7 @@
control_name="VoiceEarLocation"
follows="left|top"
layout="topleft"
- left_pad="20"
+ left_pad="10"
top_delta="-6"
width="360"
height="40"
@@ -455,11 +455,21 @@
top_pad="10"
width="237"/>
<check_box
+ control_name="VoiceEchoCancellation"
+ height="15"
+ tool_tip="Check to enable voice echo cancellation"
+ label="Echo Cancellation"
+ layout="topleft"
+ left="260"
+ name="enable_echo_cancellation"
+ top_pad="-15"
+ width="200"/>
+ <check_box
follows="top|left"
enabled_control="EnableVoiceChat"
control_name="PushToTalkToggle"
height="15"
- label="Toggle speak on/off when I press button in toolbar"
+ label="Toggle speak on/off with toolbar button"
layout="topleft"
left="20"
name="push_to_talk_toggle_check"
@@ -467,6 +477,16 @@
tool_tip="When in toggle mode, press and release the trigger key ONCE to switch your microphone on or off. When not in toggle mode, the microphone broadcasts your voice only while the trigger is being held down."
top_pad="5"/>
<check_box
+ control_name="VoiceAutomaticGainControl"
+ height="15"
+ tool_tip="Check to enable automatic gain control"
+ label="Automatic Gain Control"
+ layout="topleft"
+ name="voice_automatic_gain_control"
+ left="260"
+ top_pad="-15"
+ width="200"/>
+ <check_box
name="gesture_audio_play_btn"
control_name="EnableGestureSounds"
disabled_control="MuteAudio"
@@ -477,6 +497,45 @@
label="Play sounds from gestures"
top_pad="5"
left="20"/>
+ <text
+ layout="topleft"
+ height="15"
+ left="260"
+ top_pad="-12"
+ width="100"
+ name="noise_suppression_label">
+ Noise Suppression
+ </text>
+ <combo_box
+ control_name="VoiceNoiseSuppressionLevel"
+ enabled_control="AudioStreamingMedia"
+ layout="topleft"
+ height="23"
+ left_pad="10"
+ top_pad="-18"
+ name="noise_suppression_combo"
+ width="80">
+ <item
+ label="Off"
+ name="noise_suppression_none"
+ value="0"/>
+ <item
+ label="Low"
+ name="noise_suppression_low"
+ value="1"/>
+ <item
+ label="Moderate"
+ name="noise_suppression_moderate"
+ value="2"/>
+ <item
+ label="High"
+ name="noise_suppression_high"
+ value="3"/>
+ <item
+ label="Max"
+ name="noise_suppression_max"
+ value="4"/>
+ </combo_box>
<button
control_name="ShowDeviceSettings"
follows="left|top"
@@ -485,9 +544,9 @@
label="Voice Input/Output devices"
layout="topleft"
left="20"
- top_pad="9"
+ top_pad="0"
name="device_settings_btn"
- width="230">
+ width="200">
</button>
<panel
layout="topleft"