From b59ff9edc085f74add1b228fe849ad7e7c31f65f Mon Sep 17 00:00:00 2001
From: Roxie Linden <roxie@lindenlab.com>
Date: Fri, 19 Apr 2024 18:52:32 -0700
Subject: For p2p/adhoc/group calls, prefer voice server type based on what's
 running on the region

---
 indra/newview/app_settings/settings.xml |  4 ++--
 indra/newview/llimview.cpp              | 18 ++++++++++++++++--
 indra/newview/llvoicechannel.cpp        |  9 ++++++++-
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 0de6db0d65..3ac1844f8e 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -15155,13 +15155,13 @@
     <key>VoiceServerType</key>
     <map>
       <key>Comment</key>
-      <string>The type of voice server to connect to.</string>
+      <string>The type of voice server to use for group, conference, and p2p calls.</string>
       <key>Persist</key>
       <integer>0</integer>
       <key>Type</key>
       <string>String</string>
       <key>Value</key>
-      <string>webrtc</string>
+      <string/>
     </map>
     <key>WLSkyDetail</key>
     <map>
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 9c8fcd3283..b590c462fa 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -425,7 +425,14 @@ void startConferenceCoro(std::string url,
     postData["session-id"] = tempSessionId;
     postData["params"] = agents;
     LLSD altParams;
-    altParams["voice_server_type"] = gSavedSettings.getString("VoiceServerType");
+    std::string voice_server_type = gSavedSettings.getString("VoiceServerType");
+    if (voice_server_type.empty())
+    {
+        // default to the server type associated with the region we're on.
+        LLVoiceVersionInfo versionInfo = LLVoiceClient::getInstance()->getVersion();
+        voice_server_type              = versionInfo.internalVoiceServerType;
+    }
+    altParams["voice_server_type"] = voice_server_type;
     postData["alt_params"]         = altParams;
 
     LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData);
@@ -467,7 +474,14 @@ void startP2PVoiceCoro(std::string url, LLUUID sessionID, LLUUID creatorId, LLUU
     postData["session-id"] = sessionID;
     postData["params"]     = otherParticipantId;
     LLSD altParams;
-    altParams["voice_server_type"] = gSavedSettings.getString("VoiceServerType");
+    std::string voice_server_type = gSavedSettings.getString("VoiceServerType");
+    if (voice_server_type.empty())
+    {
+        // default to the server type associated with the region we're on.
+        LLVoiceVersionInfo versionInfo = LLVoiceClient::getInstance()->getVersion();
+        voice_server_type              = versionInfo.internalVoiceServerType;
+    }
+    altParams["voice_server_type"] = voice_server_type;
     postData["alt_params"]         = altParams;
 
     LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData);
diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp
index f6658bbaab..92b00fe854 100644
--- a/indra/newview/llvoicechannel.cpp
+++ b/indra/newview/llvoicechannel.cpp
@@ -594,7 +594,14 @@ void LLVoiceChannelGroup::voiceCallCapCoro(std::string url)
 	postData["method"] = "call";
 	postData["session-id"] = mSessionID;
 	LLSD altParams;
-	altParams["preferred_voice_server_type"] = gSavedSettings.getString("VoiceServerType");
+	std::string  preferred_voice_server_type = gSavedSettings.getString("VoiceServerType");
+	if (preferred_voice_server_type.empty())
+	{
+		// default to the server type associated with the region we're on.
+		LLVoiceVersionInfo versionInfo = LLVoiceClient::getInstance()->getVersion();
+		preferred_voice_server_type = versionInfo.internalVoiceServerType;
+	}
+	altParams["preferred_voice_server_type"] = preferred_voice_server_type;
 	postData["alt_params"] = altParams;
 
 	LL_INFOS("Voice", "voiceCallCapCoro") << "Generic POST for " << url << LL_ENDL;
-- 
cgit v1.2.3