summaryrefslogtreecommitdiff
path: root/indra/newview/llvoiceclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoiceclient.cpp')
-rw-r--r--indra/newview/llvoiceclient.cpp725
1 files changed, 352 insertions, 373 deletions
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 68d9f4ffab..6eadc3892e 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -1,36 +1,36 @@
- /**
+ /**
* @file llvoiceclient.cpp
* @brief Voice client delegation class implementation.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-#include "llviewerprecompiledheaders.h"
#include "llvoiceclient.h"
-#include "llviewercontrol.h"
-#include "llviewerwindow.h"
#include "llvoicevivox.h"
+#include "llvoicewebrtc.h"
#include "llviewernetwork.h"
+#include "llviewercontrol.h"
#include "llcommandhandler.h"
+#include "lldir.h"
#include "llhttpnode.h"
#include "llnotificationsutil.h"
#include "llsdserialize.h"
@@ -81,10 +81,10 @@ LLVoiceHandler gVoiceHandler;
std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserver::EStatusType inStatus)
{
std::string result = "UNTRANSLATED";
-
+
// Prevent copy-paste errors when updating this list...
#define CASE(x) case x: result = #x; break
-
+
switch(inStatus)
{
CASE(STATUS_LOGIN_RETRY);
@@ -107,19 +107,35 @@ std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserv
}
break;
}
-
+
#undef CASE
-
+
return result;
}
-
+LLVoiceModuleInterface *getVoiceModule(const std::string &voice_server_type)
+{
+ if (voice_server_type == VIVOX_VOICE_SERVER_TYPE || voice_server_type.empty())
+ {
+ return (LLVoiceModuleInterface *) LLVivoxVoiceClient::getInstance();
+ }
+ else if (voice_server_type == WEBRTC_VOICE_SERVER_TYPE)
+ {
+ return (LLVoiceModuleInterface *) LLWebRTCVoiceClient::getInstance();
+ }
+ else
+ {
+ LLNotificationsUtil::add("VoiceVersionMismatch");
+ return nullptr;
+ }
+}
///////////////////////////////////////////////////////////////////////////////////////////////
LLVoiceClient::LLVoiceClient(LLPumpIO *pump)
:
- mVoiceModule(NULL),
+ mSpatialVoiceModule(NULL),
+ mNonSpatialVoiceModule(NULL),
m_servicePump(NULL),
mVoiceEffectEnabled(LLCachedControl<bool>(gSavedSettings, "VoiceMorphingEnabled", true)),
mVoiceEffectDefault(LLCachedControl<std::string>(gSavedPerAccountSettings, "VoiceEffectDefault", "00000000-0000-0000-0000-000000000000")),
@@ -133,7 +149,6 @@ LLVoiceClient::LLVoiceClient(LLPumpIO *pump)
mMuteMic(false),
mDisableMic(false)
{
- updateSettings();
init(pump);
}
@@ -142,46 +157,139 @@ LLVoiceClient::LLVoiceClient(LLPumpIO *pump)
LLVoiceClient::~LLVoiceClient()
{
- llassert(!mVoiceModule);
+ llassert(!mSpatialVoiceModule);
}
void LLVoiceClient::init(LLPumpIO *pump)
{
// Initialize all of the voice modules
m_servicePump = pump;
+ LLWebRTCVoiceClient::getInstance()->init(pump);
+ LLVivoxVoiceClient::getInstance()->init(pump);
}
void LLVoiceClient::userAuthorized(const std::string& user_id, const LLUUID &agentID)
{
- // In the future, we should change this to allow voice module registration
- // with a table lookup of sorts.
- std::string voice_server = gSavedSettings.getString("VoiceServerType");
- LL_DEBUGS("Voice") << "voice server type " << voice_server << LL_ENDL;
- if(voice_server == "vivox")
+ gAgent.addRegionChangedCallback(boost::bind(&LLVoiceClient::onRegionChanged, this));
+ LLWebRTCVoiceClient::getInstance()->userAuthorized(user_id, agentID);
+ LLVivoxVoiceClient::getInstance()->userAuthorized(user_id, agentID);
+}
+
+void LLVoiceClient::handleSimulatorFeaturesReceived(const LLSD &simulatorFeatures)
+{
+ std::string voiceServerType = simulatorFeatures["VoiceServerType"].asString();
+ if (voiceServerType.empty())
{
- mVoiceModule = (LLVoiceModuleInterface *)LLVivoxVoiceClient::getInstance();
+ voiceServerType = VIVOX_VOICE_SERVER_TYPE;
}
- else
+
+ if (mSpatialVoiceModule && !mNonSpatialVoiceModule)
{
- mVoiceModule = NULL;
- return;
+ // stop processing if we're going to change voice modules
+ // and we're not currently in non-spatial.
+ LLVoiceVersionInfo version = mSpatialVoiceModule->getVersion();
+ if (version.internalVoiceServerType != voiceServerType)
+ {
+ mSpatialVoiceModule->processChannels(false);
+ }
+ }
+ setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
+
+ // if we should be in spatial voice, switch to it and set the creds
+ if (mSpatialVoiceModule && !mNonSpatialVoiceModule)
+ {
+ if (!mSpatialCredentials.isUndefined())
+ {
+ mSpatialVoiceModule->setSpatialChannel(mSpatialCredentials);
+ }
+ mSpatialVoiceModule->processChannels(true);
}
- mVoiceModule->init(m_servicePump);
- mVoiceModule->userAuthorized(user_id, agentID);
+}
+
+static void simulator_features_received_callback(const LLUUID& region_id)
+{
+ LLViewerRegion *region = gAgent.getRegion();
+ if (region && (region->getRegionID() == region_id))
+ {
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ if (LLVoiceClient::getInstance())
+ {
+ LLVoiceClient::getInstance()->handleSimulatorFeaturesReceived(simulatorFeatures);
+ }
+ }
+}
+
+void LLVoiceClient::onRegionChanged()
+{
+ LLViewerRegion *region = gAgent.getRegion();
+ if (region && region->simulatorFeaturesReceived())
+ {
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ if (LLVoiceClient::getInstance())
+ {
+ LLVoiceClient::getInstance()->handleSimulatorFeaturesReceived(simulatorFeatures);
+ }
+ }
+ else if (region)
+ {
+ if (mSimulatorFeaturesReceivedSlot.connected())
+ {
+ mSimulatorFeaturesReceivedSlot.disconnect();
+ }
+ mSimulatorFeaturesReceivedSlot =
+ region->setSimulatorFeaturesReceivedCallback(boost::bind(&simulator_features_received_callback, _1));
+ }
+}
+
+void LLVoiceClient::setSpatialVoiceModule(const std::string &voice_server_type)
+{
+ LLVoiceModuleInterface *module = getVoiceModule(voice_server_type);
+ if (!module)
+ {
+ return;
+ }
+ if (module != mSpatialVoiceModule)
+ {
+ if (inProximalChannel())
+ {
+ mSpatialVoiceModule->processChannels(false);
+ }
+ module->processChannels(true);
+ mSpatialVoiceModule = module;
+ mSpatialVoiceModule->updateSettings();
+ }
+}
+
+void LLVoiceClient::setNonSpatialVoiceModule(const std::string &voice_server_type)
+{
+ mNonSpatialVoiceModule = getVoiceModule(voice_server_type);
+ if (!mNonSpatialVoiceModule)
+ {
+ // we don't have a non-spatial voice module,
+ // so revert to spatial.
+ if (mSpatialVoiceModule)
+ {
+ mSpatialVoiceModule->processChannels(true);
+ }
+ return;
+ }
+ mNonSpatialVoiceModule->updateSettings();
}
void LLVoiceClient::setHidden(bool hidden)
{
- if (mVoiceModule)
+ if (mSpatialVoiceModule)
{
- mVoiceModule->setHidden(hidden);
+ mSpatialVoiceModule->setHidden(hidden);
}
}
void LLVoiceClient::terminate()
{
- if (mVoiceModule) mVoiceModule->terminate();
- mVoiceModule = NULL;
+ if (mSpatialVoiceModule) mSpatialVoiceModule->terminate();
+ mSpatialVoiceModule = NULL;
m_servicePump = NULL;
// Shutdown speaker volume storage before LLSingletonBase::deleteAll() does it
@@ -193,15 +301,15 @@ void LLVoiceClient::terminate()
const LLVoiceVersionInfo LLVoiceClient::getVersion()
{
- if (mVoiceModule)
+ if (mSpatialVoiceModule)
{
- return mVoiceModule->getVersion();
+ return mSpatialVoiceModule->getVersion();
}
else
{
LLVoiceVersionInfo result;
result.serverVersion = std::string();
- result.serverType = std::string();
+ result.voiceServerType = std::string();
result.mBuildVersion = std::string();
return result;
}
@@ -215,10 +323,8 @@ void LLVoiceClient::updateSettings()
updateMicMuteLogic();
- if (mVoiceModule)
- {
- mVoiceModule->updateSettings();
- }
+ LLWebRTCVoiceClient::getInstance()->updateSettings();
+ LLVivoxVoiceClient::getInstance()->updateSettings();
}
//--------------------------------------------------
@@ -226,117 +332,75 @@ void LLVoiceClient::updateSettings()
void LLVoiceClient::tuningStart()
{
- if (mVoiceModule) mVoiceModule->tuningStart();
+ LLWebRTCVoiceClient::getInstance()->tuningStart();
+ LLVivoxVoiceClient::getInstance()->tuningStart();
}
void LLVoiceClient::tuningStop()
{
- if (mVoiceModule) mVoiceModule->tuningStop();
+ LLWebRTCVoiceClient::getInstance()->tuningStop();
+ LLVivoxVoiceClient::getInstance()->tuningStop();
}
bool LLVoiceClient::inTuningMode()
{
- if (mVoiceModule)
- {
- return mVoiceModule->inTuningMode();
- }
- else
- {
- return false;
- }
+ return LLWebRTCVoiceClient::getInstance()->inTuningMode();
}
void LLVoiceClient::tuningSetMicVolume(float volume)
{
- if (mVoiceModule) mVoiceModule->tuningSetMicVolume(volume);
+ LLWebRTCVoiceClient::getInstance()->tuningSetMicVolume(volume);
}
void LLVoiceClient::tuningSetSpeakerVolume(float volume)
{
- if (mVoiceModule) mVoiceModule->tuningSetSpeakerVolume(volume);
+ LLWebRTCVoiceClient::getInstance()->tuningSetSpeakerVolume(volume);
}
float LLVoiceClient::tuningGetEnergy(void)
{
- if (mVoiceModule)
- {
- return mVoiceModule->tuningGetEnergy();
- }
- else
- {
- return 0.0;
- }
+ return LLWebRTCVoiceClient::getInstance()->tuningGetEnergy();
}
-
//------------------------------------------------
// devices
bool LLVoiceClient::deviceSettingsAvailable()
{
- if (mVoiceModule)
- {
- return mVoiceModule->deviceSettingsAvailable();
- }
- else
- {
- return false;
- }
+ return LLWebRTCVoiceClient::getInstance()->deviceSettingsAvailable();
}
bool LLVoiceClient::deviceSettingsUpdated()
{
- if (mVoiceModule)
- {
- return mVoiceModule->deviceSettingsUpdated();
- }
- else
- {
- return false;
- }
+ return LLWebRTCVoiceClient::getInstance()->deviceSettingsUpdated();
}
void LLVoiceClient::refreshDeviceLists(bool clearCurrentList)
{
- if (mVoiceModule) mVoiceModule->refreshDeviceLists(clearCurrentList);
+ LLWebRTCVoiceClient::getInstance()->refreshDeviceLists(clearCurrentList);
}
void LLVoiceClient::setCaptureDevice(const std::string& name)
{
- if (mVoiceModule) mVoiceModule->setCaptureDevice(name);
-
+ LLVivoxVoiceClient::getInstance()->setCaptureDevice(name);
+ LLWebRTCVoiceClient::getInstance()->setCaptureDevice(name);
}
void LLVoiceClient::setRenderDevice(const std::string& name)
{
- if (mVoiceModule) mVoiceModule->setRenderDevice(name);
+ LLVivoxVoiceClient::getInstance()->setRenderDevice(name);
+ LLWebRTCVoiceClient::getInstance()->setRenderDevice(name);
}
const LLVoiceDeviceList& LLVoiceClient::getCaptureDevices()
{
- static LLVoiceDeviceList nullCaptureDevices;
- if (mVoiceModule)
- {
- return mVoiceModule->getCaptureDevices();
- }
- else
- {
- return nullCaptureDevices;
- }
+ return LLWebRTCVoiceClient::getInstance()->getCaptureDevices();
}
const LLVoiceDeviceList& LLVoiceClient::getRenderDevices()
{
- static LLVoiceDeviceList nullRenderDevices;
- if (mVoiceModule)
- {
- return mVoiceModule->getRenderDevices();
- }
- else
- {
- return nullRenderDevices;
- }
+ return LLWebRTCVoiceClient::getInstance()->getRenderDevices();
}
@@ -345,190 +409,164 @@ const LLVoiceDeviceList& LLVoiceClient::getRenderDevices()
void LLVoiceClient::getParticipantList(std::set<LLUUID> &participants)
{
- if (mVoiceModule)
- {
- mVoiceModule->getParticipantList(participants);
- }
- else
- {
- participants = std::set<LLUUID>();
- }
+ LLWebRTCVoiceClient::getInstance()->getParticipantList(participants);
+ LLVivoxVoiceClient::getInstance()->getParticipantList(participants);
}
bool LLVoiceClient::isParticipant(const LLUUID &speaker_id)
{
- if(mVoiceModule)
- {
- return mVoiceModule->isParticipant(speaker_id);
- }
- return false;
+ return LLWebRTCVoiceClient::getInstance()->isParticipant(speaker_id) ||
+ LLVivoxVoiceClient::getInstance()->isParticipant(speaker_id);
}
//--------------------------------------------------
// text chat
-
BOOL LLVoiceClient::isSessionTextIMPossible(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->isSessionTextIMPossible(id);
- }
- else
- {
- return FALSE;
- }
+ // all sessions can do TextIM, as we no longer support PSTN
+ return TRUE;
}
BOOL LLVoiceClient::isSessionCallBackPossible(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->isSessionCallBackPossible(id);
- }
- else
- {
- return FALSE;
- }
+ // we don't support PSTN calls anymore. (did we ever?)
+ return TRUE;
}
-/* obsolete
-BOOL LLVoiceClient::sendTextMessage(const LLUUID& participant_id, const std::string& message)
+//----------------------------------------------
+// channels
+
+bool LLVoiceClient::inProximalChannel()
{
- if (mVoiceModule)
+ if (mSpatialVoiceModule)
{
- return mVoiceModule->sendTextMessage(participant_id, message);
+ return mSpatialVoiceModule->inProximalChannel();
}
else
{
- return FALSE;
- }
+ return false;
+ }
}
-*/
-void LLVoiceClient::endUserIMSession(const LLUUID& participant_id)
+void LLVoiceClient::setNonSpatialChannel(
+ const LLSD& channelInfo,
+ bool notify_on_first_join,
+ bool hangup_on_last_leave)
{
- if (mVoiceModule)
+ setNonSpatialVoiceModule(channelInfo["voice_server_type"].asString());
+ if (mSpatialVoiceModule && mSpatialVoiceModule != mNonSpatialVoiceModule)
+ {
+ mSpatialVoiceModule->processChannels(false);
+ }
+ if (mNonSpatialVoiceModule)
{
- // mVoiceModule->endUserIMSession(participant_id); // A SLim leftover
+ mNonSpatialVoiceModule->processChannels(true);
+ mNonSpatialVoiceModule->setNonSpatialChannel(channelInfo, notify_on_first_join, hangup_on_last_leave);
}
}
-//----------------------------------------------
-// channels
-
-bool LLVoiceClient::inProximalChannel()
+void LLVoiceClient::setSpatialChannel(const LLSD &channelInfo)
{
- if (mVoiceModule)
+ mSpatialCredentials = channelInfo;
+ LLViewerRegion *region = gAgent.getRegion();
+ if (region && region->simulatorFeaturesReceived())
{
- return mVoiceModule->inProximalChannel();
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
}
else
{
- return false;
+ return;
}
-}
-
-void LLVoiceClient::setNonSpatialChannel(
- const std::string &uri,
- const std::string &credentials)
-{
- if (mVoiceModule)
- {
- mVoiceModule->setNonSpatialChannel(uri, credentials);
- }
-}
-void LLVoiceClient::setSpatialChannel(
- const std::string &uri,
- const std::string &credentials)
-{
- if (mVoiceModule)
- {
- mVoiceModule->setSpatialChannel(uri, credentials);
- }
+ if (mSpatialVoiceModule)
+ {
+ mSpatialVoiceModule->setSpatialChannel(channelInfo);
+ }
}
void LLVoiceClient::leaveNonSpatialChannel()
{
- if (mVoiceModule)
+ if (mNonSpatialVoiceModule)
{
- mVoiceModule->leaveNonSpatialChannel();
+ mNonSpatialVoiceModule->leaveNonSpatialChannel();
+ mNonSpatialVoiceModule->processChannels(false);
+ mNonSpatialVoiceModule = nullptr;
}
+ if (mSpatialVoiceModule)
+ {
+ mSpatialVoiceModule->processChannels(true);
+ ;
+ }
}
-void LLVoiceClient::leaveChannel(void)
+void LLVoiceClient::activateSpatialChannel(bool activate)
{
- if (mVoiceModule)
+ if (mSpatialVoiceModule)
{
- mVoiceModule->leaveChannel();
+ mSpatialVoiceModule->processChannels(activate);
}
}
-std::string LLVoiceClient::getCurrentChannel()
+bool LLVoiceClient::isCurrentChannel(const LLSD& channelInfo)
{
- if (mVoiceModule)
- {
- return mVoiceModule->getCurrentChannel();
- }
- else
- {
- return std::string();
- }
+ return LLWebRTCVoiceClient::getInstance()->isCurrentChannel(channelInfo) ||
+ LLVivoxVoiceClient::getInstance()->isCurrentChannel(channelInfo);
}
-
-//---------------------------------------
-// invitations
-
-void LLVoiceClient::callUser(const LLUUID &uuid)
+bool LLVoiceClient::compareChannels(const LLSD &channelInfo1, const LLSD &channelInfo2)
{
- if (mVoiceModule) mVoiceModule->callUser(uuid);
+ return LLWebRTCVoiceClient::getInstance()->compareChannels(channelInfo1, channelInfo2) ||
+ LLVivoxVoiceClient::getInstance()->compareChannels(channelInfo1, channelInfo2);
}
-bool LLVoiceClient::isValidChannel(std::string &session_handle)
+LLVoiceP2PIncomingCallInterfacePtr LLVoiceClient::getIncomingCallInterface(const LLSD& voice_call_info)
{
- if (mVoiceModule)
+ LLVoiceModuleInterface *module = getVoiceModule(voice_call_info["voice_server_type"]);
+ if (module)
{
- return mVoiceModule->isValidChannel(session_handle);
+ return module->getIncomingCallInterface(voice_call_info);
}
- else
- {
- return false;
- }
-}
+ return nullptr;
-bool LLVoiceClient::answerInvite(std::string &channelHandle)
-{
- if (mVoiceModule)
- {
- return mVoiceModule->answerInvite(channelHandle);
- }
- else
- {
- return false;
- }
}
-void LLVoiceClient::declineInvite(std::string &channelHandle)
+//---------------------------------------
+// outgoing calls
+LLVoiceP2POutgoingCallInterface *LLVoiceClient::getOutgoingCallInterface(const LLSD& voiceChannelInfo)
{
- if (mVoiceModule) mVoiceModule->declineInvite(channelHandle);
+ 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;
+ }
+ if (voiceChannelInfo.has("voice_server_type"))
+ {
+ voice_server_type = voiceChannelInfo["voice_server_type"].asString();
+ }
+ LLVoiceModuleInterface *module = getVoiceModule(voice_server_type);
+ return dynamic_cast<LLVoiceP2POutgoingCallInterface *>(module);
}
-
//------------------------------------------
// Volume/gain
void LLVoiceClient::setVoiceVolume(F32 volume)
{
- if (mVoiceModule) mVoiceModule->setVoiceVolume(volume);
+ LLWebRTCVoiceClient::getInstance()->setVoiceVolume(volume);
+ LLVivoxVoiceClient::getInstance()->setVoiceVolume(volume);
}
-void LLVoiceClient::setMicGain(F32 volume)
+void LLVoiceClient::setMicGain(F32 gain)
{
- if (mVoiceModule) mVoiceModule->setMicGain(volume);
+ LLWebRTCVoiceClient::getInstance()->setMicGain(gain);
+ LLVivoxVoiceClient::getInstance()->setMicGain(gain);
}
@@ -537,29 +575,22 @@ void LLVoiceClient::setMicGain(F32 volume)
bool LLVoiceClient::voiceEnabled()
{
- if (mVoiceModule)
- {
- return mVoiceModule->voiceEnabled();
- }
- else
- {
- return false;
- }
+ static LLCachedControl<bool> enable_voice_chat(gSavedSettings, "EnableVoiceChat");
+ static LLCachedControl<bool> cmd_line_disable_voice(gSavedSettings, "CmdLineDisableVoice");
+ return enable_voice_chat && !cmd_line_disable_voice && !gNonInteractive;
}
void LLVoiceClient::setVoiceEnabled(bool enabled)
{
- if (mVoiceModule)
- {
- mVoiceModule->setVoiceEnabled(enabled);
- }
+ LLWebRTCVoiceClient::getInstance()->setVoiceEnabled(enabled);
+ LLVivoxVoiceClient::getInstance()->setVoiceEnabled(enabled);
}
void LLVoiceClient::updateMicMuteLogic()
{
// If not configured to use PTT, the mic should be open (otherwise the user will be unable to speak).
bool new_mic_mute = false;
-
+
if(mUsePTT)
{
// If configured to use PTT, track the user state.
@@ -571,34 +602,20 @@ void LLVoiceClient::updateMicMuteLogic()
// Either of these always overrides any other PTT setting.
new_mic_mute = true;
}
-
- if (mVoiceModule) mVoiceModule->setMuteMic(new_mic_mute);
-}
-
-void LLVoiceClient::setLipSyncEnabled(BOOL enabled)
-{
- if (mVoiceModule) mVoiceModule->setLipSyncEnabled(enabled);
+ LLWebRTCVoiceClient::getInstance()->setMuteMic(new_mic_mute);
+ LLVivoxVoiceClient::getInstance()->setMuteMic(new_mic_mute);
}
-BOOL LLVoiceClient::lipSyncEnabled()
+void LLVoiceClient::setMuteMic(bool muted)
{
- if (mVoiceModule)
- {
- return mVoiceModule->lipSyncEnabled();
- }
- else
+ if (mMuteMic != muted)
{
- return false;
+ mMuteMic = muted;
+ updateMicMuteLogic();
+ mMicroChangedSignal();
}
}
-void LLVoiceClient::setMuteMic(bool muted)
-{
- mMuteMic = muted;
- updateMicMuteLogic();
- mMicroChangedSignal();
-}
-
// ----------------------------------------------
// PTT
@@ -627,7 +644,7 @@ void LLVoiceClient::setUsePTT(bool usePTT)
mUserPTTState = false;
}
mUsePTT = usePTT;
-
+
updateMicMuteLogic();
}
@@ -638,7 +655,7 @@ void LLVoiceClient::setPTTIsToggle(bool PTTIsToggle)
// When the user turns off toggle, reset the current state.
mUserPTTState = false;
}
-
+
mPTTIsToggle = PTTIsToggle;
updateMicMuteLogic();
@@ -653,12 +670,12 @@ void LLVoiceClient::inputUserControlState(bool down)
{
if(mPTTIsToggle)
{
- if(down) // toggle open-mic state on 'down'
+ if(down) // toggle open-mic state on 'down'
{
toggleUserPTTState();
}
}
- else // set open-mic state as an absolute
+ else // set open-mic state as an absolute
{
setUserPTTState(down);
}
@@ -675,117 +692,71 @@ void LLVoiceClient::toggleUserPTTState(void)
BOOL LLVoiceClient::getVoiceEnabled(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->getVoiceEnabled(id);
- }
- else
- {
- return FALSE;
- }
+ return isParticipant(id) ? TRUE : FALSE;
}
std::string LLVoiceClient::getDisplayName(const LLUUID& id)
{
- if (mVoiceModule)
+ std::string result = LLWebRTCVoiceClient::getInstance()->getDisplayName(id);
+ if (result.empty())
{
- return mVoiceModule->getDisplayName(id);
- }
- else
- {
- return std::string();
+ result = LLVivoxVoiceClient::getInstance()->getDisplayName(id);
}
+ return result;
}
bool LLVoiceClient::isVoiceWorking() const
{
- if (mVoiceModule)
- {
- return mVoiceModule->isVoiceWorking();
- }
- return false;
+ return LLVivoxVoiceClient::getInstance()->isVoiceWorking() ||
+ LLWebRTCVoiceClient::getInstance()->isVoiceWorking();
}
BOOL LLVoiceClient::isParticipantAvatar(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->isParticipantAvatar(id);
- }
- else
- {
- return FALSE;
- }
+ return TRUE;
}
BOOL LLVoiceClient::isOnlineSIP(const LLUUID& id)
{
- return FALSE;
+ return FALSE;
}
BOOL LLVoiceClient::getIsSpeaking(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->getIsSpeaking(id);
- }
- else
- {
- return FALSE;
- }
+ return LLWebRTCVoiceClient::getInstance()->getIsSpeaking(id) ||
+ LLVivoxVoiceClient::getInstance()->getIsSpeaking(id);
}
BOOL LLVoiceClient::getIsModeratorMuted(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->getIsModeratorMuted(id);
- }
- else
- {
- return FALSE;
- }
+ // don't bother worrying about p2p calls, as
+ // p2p calls don't have mute.
+ return LLWebRTCVoiceClient::getInstance()->getIsModeratorMuted(id) ||
+ LLVivoxVoiceClient::getInstance()->getIsModeratorMuted(id);
}
F32 LLVoiceClient::getCurrentPower(const LLUUID& id)
-{
- if (mVoiceModule)
- {
- return mVoiceModule->getCurrentPower(id);
- }
- else
- {
- return 0.0;
- }
+{
+ return std::fmax(LLVivoxVoiceClient::getInstance()->getCurrentPower(id),
+ LLWebRTCVoiceClient::getInstance()->getCurrentPower(id));
}
BOOL LLVoiceClient::getOnMuteList(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->getOnMuteList(id);
- }
- else
- {
- return FALSE;
- }
+ // don't bother worrying about p2p calls, as
+ // p2p calls don't have mute.
+ return LLMuteList::getInstance()->isMuted(id, LLMute::flagVoiceChat);
}
F32 LLVoiceClient::getUserVolume(const LLUUID& id)
{
- if (mVoiceModule)
- {
- return mVoiceModule->getUserVolume(id);
- }
- else
- {
- return 0.0;
- }
+ return std::fmax(LLVivoxVoiceClient::getInstance()->getUserVolume(id), LLWebRTCVoiceClient::getInstance()->getUserVolume(id));
}
void LLVoiceClient::setUserVolume(const LLUUID& id, F32 volume)
{
- if (mVoiceModule) mVoiceModule->setUserVolume(id, volume);
+ LLWebRTCVoiceClient::getInstance()->setUserVolume(id, volume);
+ LLVivoxVoiceClient::getInstance()->setUserVolume(id, volume);
}
//--------------------------------------------------
@@ -793,48 +764,49 @@ void LLVoiceClient::setUserVolume(const LLUUID& id, F32 volume)
void LLVoiceClient::addObserver(LLVoiceClientStatusObserver* observer)
{
- if (mVoiceModule) mVoiceModule->addObserver(observer);
+ LLVivoxVoiceClient::getInstance()->addObserver(observer);
+ LLWebRTCVoiceClient::getInstance()->addObserver(observer);
}
void LLVoiceClient::removeObserver(LLVoiceClientStatusObserver* observer)
{
- if (mVoiceModule)
- {
- mVoiceModule->removeObserver(observer);
- }
+ LLVivoxVoiceClient::getInstance()->removeObserver(observer);
+ LLWebRTCVoiceClient::getInstance()->removeObserver(observer);
}
void LLVoiceClient::addObserver(LLFriendObserver* observer)
{
- if (mVoiceModule) mVoiceModule->addObserver(observer);
+ LLVivoxVoiceClient::getInstance()->addObserver(observer);
+ LLWebRTCVoiceClient::getInstance()->addObserver(observer);
}
void LLVoiceClient::removeObserver(LLFriendObserver* observer)
{
- if (mVoiceModule)
- {
- mVoiceModule->removeObserver(observer);
- }
+ LLVivoxVoiceClient::getInstance()->removeObserver(observer);
+ LLWebRTCVoiceClient::getInstance()->removeObserver(observer);
}
void LLVoiceClient::addObserver(LLVoiceClientParticipantObserver* observer)
{
- if (mVoiceModule) mVoiceModule->addObserver(observer);
+ LLVivoxVoiceClient::getInstance()->addObserver(observer);
+ LLWebRTCVoiceClient::getInstance()->addObserver(observer);
}
void LLVoiceClient::removeObserver(LLVoiceClientParticipantObserver* observer)
{
- if (mVoiceModule)
- {
- mVoiceModule->removeObserver(observer);
- }
+ LLVivoxVoiceClient::getInstance()->removeObserver(observer);
+ LLWebRTCVoiceClient::getInstance()->removeObserver(observer);
}
std::string LLVoiceClient::sipURIFromID(const LLUUID &id)
{
- if (mVoiceModule)
+ if (mNonSpatialVoiceModule)
+ {
+ return mNonSpatialVoiceModule->sipURIFromID(id);
+ }
+ else if (mSpatialVoiceModule)
{
- return mVoiceModule->sipURIFromID(id);
+ return mSpatialVoiceModule->sipURIFromID(id);
}
else
{
@@ -844,7 +816,7 @@ std::string LLVoiceClient::sipURIFromID(const LLUUID &id)
LLVoiceEffectInterface* LLVoiceClient::getVoiceEffectInterface() const
{
- return getVoiceEffectEnabled() ? dynamic_cast<LLVoiceEffectInterface*>(mVoiceModule) : NULL;
+ return getVoiceEffectEnabled() ? dynamic_cast<LLVoiceEffectInterface*>(mSpatialVoiceModule) : NULL;
}
///////////////////
@@ -852,31 +824,52 @@ LLVoiceEffectInterface* LLVoiceClient::getVoiceEffectInterface() const
class LLViewerRequiredVoiceVersion : public LLHTTPNode
{
- static BOOL sAlertedUser;
+ static bool sAlertedUser;
virtual void post(
LLHTTPNode::ResponsePtr response,
const LLSD& context,
const LLSD& input) const
{
- //You received this messsage (most likely on region cross or
- //teleport)
- if ( input.has("body") && input["body"].has("major_version") )
+ std::string voice_server_type = "vivox";
+ if (input.has("body") && input["body"].has("voice_server_type"))
+ {
+ voice_server_type = input["body"]["voice_server_type"].asString();
+ }
+
+ LLVoiceModuleInterface *voiceModule = NULL;
+
+ if (voice_server_type == "vivox" || voice_server_type.empty())
{
- int major_voice_version =
- input["body"]["major_version"].asInteger();
- // int minor_voice_version =
- // input["body"]["minor_version"].asInteger();
- LLVoiceVersionInfo versionInfo = LLVoiceClient::getInstance()->getVersion();
-
- if (major_voice_version > 1)
+ voiceModule = (LLVoiceModuleInterface *) LLVivoxVoiceClient::getInstance();
+ }
+ else if (voice_server_type == "webrtc")
+ {
+ voiceModule = (LLVoiceModuleInterface *) LLWebRTCVoiceClient::getInstance();
+ }
+ else
+ {
+ LL_WARNS("Voice") << "Unknown voice server type " << voice_server_type << LL_ENDL;
+ if (!sAlertedUser)
+ {
+ // sAlertedUser = true;
+ LLNotificationsUtil::add("VoiceVersionMismatch");
+ }
+ return;
+ }
+
+ LLVoiceVersionInfo versionInfo = voiceModule->getVersion();
+ if (input.has("body") && input["body"].has("major_version") &&
+ input["body"]["major_version"].asInteger() > versionInfo.majorVersion)
+ {
+ if (!sAlertedUser)
{
- if (!sAlertedUser)
- {
- //sAlertedUser = TRUE;
- LLNotificationsUtil::add("VoiceVersionMismatch");
- gSavedSettings.setBOOL("EnableVoiceChat", FALSE); // toggles listener
- }
+ // sAlertedUser = true;
+ LLNotificationsUtil::add("VoiceVersionMismatch");
+ LL_WARNS("Voice") << "Voice server version mismatch " << input["body"]["major_version"].asInteger() << "/"
+ << versionInfo.majorVersion
+ << LL_ENDL;
}
+ return;
}
}
};
@@ -890,41 +883,27 @@ class LLViewerParcelVoiceInfo : public LLHTTPNode
{
//the parcel you are in has changed something about its
//voice information
-
+
//this is a misnomer, as it can also be when you are not in
//a parcel at all. Should really be something like
//LLViewerVoiceInfoChanged.....
if ( input.has("body") )
{
LLSD body = input["body"];
-
+
//body has "region_name" (str), "parcel_local_id"(int),
//"voice_credentials" (map).
-
+
//body["voice_credentials"] has "channel_uri" (str),
//body["voice_credentials"] has "channel_credentials" (str)
-
+
//if we really wanted to be extra careful,
//we'd check the supplied
//local parcel id to make sure it's for the same parcel
//we believe we're in
if ( body.has("voice_credentials") )
{
- LLSD voice_credentials = body["voice_credentials"];
- std::string uri;
- std::string credentials;
-
- if ( voice_credentials.has("channel_uri") )
- {
- uri = voice_credentials["channel_uri"].asString();
- }
- if ( voice_credentials.has("channel_credentials") )
- {
- credentials =
- voice_credentials["channel_credentials"].asString();
- }
-
- LLVoiceClient::getInstance()->setSpatialChannel(uri, credentials);
+ LLVoiceClient::getInstance()->setSpatialChannel(body["voice_credentials"]);
}
}
}
@@ -966,7 +945,7 @@ void LLSpeakerVolumeStorage::storeSpeakerVolume(const LLUUID& speaker_id, F32 vo
bool LLSpeakerVolumeStorage::getSpeakerVolume(const LLUUID& speaker_id, F32& volume)
{
speaker_data_map_t::const_iterator it = mSpeakersData.find(speaker_id);
-
+
if (it != mSpeakersData.end())
{
volume = it->second;
@@ -1045,9 +1024,9 @@ void LLSpeakerVolumeStorage::load()
if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings_llsd, file))
{
LL_WARNS("Voice") << "failed to parse " << filename << LL_ENDL;
-
+
}
-
+
}
for (LLSD::map_const_iterator iter = settings_llsd.beginMap();
@@ -1087,7 +1066,7 @@ void LLSpeakerVolumeStorage::save()
}
}
-BOOL LLViewerRequiredVoiceVersion::sAlertedUser = FALSE;
+bool LLViewerRequiredVoiceVersion::sAlertedUser = false;
LLHTTPRegistration<LLViewerParcelVoiceInfo>
gHTTPRegistrationMessageParcelVoiceInfo(