diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llappviewer.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llimview.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llviewerregion.h | 2 | ||||
-rw-r--r-- | indra/newview/llvoiceclient.cpp | 132 | ||||
-rw-r--r-- | indra/newview/llvoiceclient.h | 17 | ||||
-rw-r--r-- | indra/newview/llvoicevivox.cpp | 29 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 22 |
7 files changed, 166 insertions, 49 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 4a43133ff6..9691bb9a8c 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3344,15 +3344,15 @@ LLSD LLAppViewer::getViewerInfo() const { LLVoiceVersionInfo version = LLVoiceClient::getInstance()->getVersion(); const std::string build_version = version.mBuildVersion; - std::ostringstream version_string; - if (std::equal(build_version.begin(), build_version.begin() + version.serverVersion.size(), + std::ostringstream version_string; + if (std::equal(version.mBuildVersion.begin(), version.mBuildVersion.begin() + version.serverVersion.size(), version.serverVersion.begin())) { // Normal case: Show type and build version. - version_string << version.serverType << " " << build_version << std::endl; + version_string << version.voiceServerType << " " << version.mBuildVersion << std::endl; } else { // Mismatch: Show both versions. - version_string << version.serverVersion << "/" << build_version << std::endl; + version_string << version.voiceServerType << " " << version.serverVersion << "/" << version.mBuildVersion << std::endl; } info["VOICE_VERSION"] = version_string.str(); } diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 9b2cd46a4b..1c8cdfd641 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -4216,7 +4216,10 @@ public: input["body"]["from_id"].asUUID(), input["body"]["from_name"].asString(), session_type_p2p ? IM_SESSION_P2P_INVITE : IM_SESSION_INVITE, - LLIMMgr::INVITATION_TYPE_VOICE); + LLIMMgr::INVITATION_TYPE_VOICE, + LLStringUtil::null, // session_handle + LLStringUtil::null, + voice_server_type); } else if ( input["body"].has("immediate") ) { diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index b24ff51479..5817bd7d8d 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -546,7 +546,7 @@ public: U8 mCentralBakeVersion; LLVOCacheEntry* mLastVisitedEntry; - U32 mInvisibilityCheckHistory; + U32 mInvisibilityCheckHistory; // Information for Homestead / CR-53 S32 mClassID; diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index de7fb248b0..3532d8e986 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -133,7 +133,6 @@ LLVoiceClient::LLVoiceClient(LLPumpIO *pump) mMuteMic(false), mDisableMic(false) { - updateSettings(); init(pump); } @@ -149,31 +148,71 @@ 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") - { - mVoiceModule = (LLVoiceModuleInterface *)LLVivoxVoiceClient::getInstance(); - } - if (voice_server == "webrtc") + mUserID = user_id; + mAgentID = agentID; + gAgent.addRegionChangedCallback(boost::bind(&LLVoiceClient::onRegionChanged, this)); +} + +void LLVoiceClient::onRegionChanged() +{ + LLViewerRegion *region = gAgent.getRegion(); + if (region && region->simulatorFeaturesReceived()) + { + LLSD simulatorFeatures; + region->getSimulatorFeatures(simulatorFeatures); + setVoiceModule(simulatorFeatures["VoiceServerType"].asString()); + } + else if (region) + { + if (mSimulatorFeaturesReceivedSlot.connected()) + { + mSimulatorFeaturesReceivedSlot.disconnect(); + } + mSimulatorFeaturesReceivedSlot = + region->setSimulatorFeaturesReceivedCallback( + boost::bind(&LLVoiceClient::onSimulatorFeaturesReceived, this, _1)); + } +} + +void LLVoiceClient::onSimulatorFeaturesReceived(const LLUUID& region_id) +{ + LLViewerRegion *region = gAgent.getRegion(); + if (region && (region->getRegionID() == region_id)) + { + LLSD simulatorFeatures; + region->getSimulatorFeatures(simulatorFeatures); + setVoiceModule(simulatorFeatures["VoiceServerType"].asString()); + } +} + +void LLVoiceClient::setVoiceModule(const std::string& voice_server_type) +{ + if (voice_server_type == "vivox" || voice_server_type.empty()) + { + mVoiceModule = (LLVoiceModuleInterface *) LLVivoxVoiceClient::getInstance(); + } + else if (voice_server_type == "webrtc") { mVoiceModule = (LLVoiceModuleInterface *) LLWebRTCVoiceClient::getInstance(); } else { - mVoiceModule = NULL; - return; + LLNotificationsUtil::add("VoiceVersionMismatch"); + mVoiceModule = nullptr; + return; } - mVoiceModule->init(m_servicePump); - mVoiceModule->userAuthorized(user_id, agentID); + mVoiceModule->userAuthorized(mUserID, mAgentID); + updateSettings(); } + + void LLVoiceClient::setHidden(bool hidden) { if (mVoiceModule) @@ -205,7 +244,7 @@ const LLVoiceVersionInfo LLVoiceClient::getVersion() { LLVoiceVersionInfo result; result.serverVersion = std::string(); - result.serverType = std::string(); + result.voiceServerType = std::string(); result.mBuildVersion = std::string(); return result; } @@ -864,31 +903,54 @@ 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")) { - 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) - { - if (!sAlertedUser) - { - //sAlertedUser = TRUE; - LLNotificationsUtil::add("VoiceVersionMismatch"); - gSavedSettings.setBOOL("EnableVoiceChat", FALSE); // toggles listener - } - } + voice_server_type = input["body"]["voice_server_type"].asString(); + } + + LLVoiceModuleInterface *voiceModule = NULL; + + if (voice_server_type == "vivox" || voice_server_type.empty()) + { + 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) + { + // sAlertedUser = true; + LLNotificationsUtil::add("VoiceVersionMismatch"); + LL_WARNS("Voice") << "Voice server version mismatch " << input["body"]["major_version"].asInteger() << "/" + << versionInfo.majorVersion + << LL_ENDL; + } + return; } } }; @@ -1099,7 +1161,7 @@ void LLSpeakerVolumeStorage::save() } } -BOOL LLViewerRequiredVoiceVersion::sAlertedUser = FALSE; +bool LLViewerRequiredVoiceVersion::sAlertedUser = false; LLHTTPRegistration<LLViewerParcelVoiceInfo> gHTTPRegistrationMessageParcelVoiceInfo( diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 69004f2000..4ed3cd5066 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -94,8 +94,10 @@ public: struct LLVoiceVersionInfo { - std::string serverType; - std::string serverVersion; + std::string voiceServerType; + int majorVersion; + int minorVersion; + std::string serverVersion; std::string mBuildVersion; }; @@ -122,6 +124,8 @@ public: virtual void setHidden(bool hidden)=0; // Hides the user from voice. virtual const LLVoiceVersionInfo& getVersion()=0; + + ///////////////////// /// @name Tuning @@ -449,9 +453,13 @@ public: void endUserIMSession(const LLUUID &uuid); //@} + void setVoiceModule(const std::string& voice_server_type); void userAuthorized(const std::string& user_id, - const LLUUID &agentID); + const LLUUID &agentID); + + void onRegionChanged(); + void onSimulatorFeaturesReceived(const LLUUID ®ion_id); void addObserver(LLVoiceClientStatusObserver* observer); void removeObserver(LLVoiceClientStatusObserver* observer); @@ -478,6 +486,9 @@ protected: LLVoiceModuleInterface* mVoiceModule; LLPumpIO *m_servicePump; + std::string mUserID; + LLUUID mAgentID; + boost::signals2::connection mSimulatorFeaturesReceivedSlot; LLCachedControl<bool> mVoiceEffectEnabled; LLCachedControl<std::string> mVoiceEffectDefault; diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 3c01f00596..d708870314 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -85,7 +85,8 @@ namespace { const F32 SPEAKING_TIMEOUT = 1.f; - static const std::string VOICE_SERVER_TYPE = "Vivox"; + static const std::string VISIBLE_VOICE_SERVER_TYPE = "Vivox"; + static const std::string VIVOX_VOICE_SERVER_TYPE = "vivox"; // Don't retry connecting to the daemon more frequently than this: const F32 DAEMON_CONNECT_THROTTLE_SECONDS = 1.0f; @@ -358,7 +359,7 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() : mSpeakerVolume = scale_speaker_volume(0); mVoiceVersion.serverVersion = ""; - mVoiceVersion.serverType = VOICE_SERVER_TYPE; + mVoiceVersion.voiceServerType = VISIBLE_VOICE_SERVER_TYPE; // gMuteListp isn't set up at this point, so we defer this until later. // gMuteListp->addObserver(&mutelist_listener); @@ -737,6 +738,19 @@ void LLVivoxVoiceClient::voiceControlStateMachine(S32 &coro_state) return; } + + // grab the active voice server version info to see if we should use + // vivox. + LLVoiceVersionInfo version = LLVoiceClient::getInstance()->getVersion(); + if (version.voiceServerType != VISIBLE_VOICE_SERVER_TYPE) + { + // we've switched to another voice provider, so + // disable voice and shut down vivox. Don't + // notify, though. + mVoiceEnabled = false; + } + + switch (coro_state) { case VOICE_STATE_TP_WAIT: @@ -1972,6 +1986,17 @@ bool LLVivoxVoiceClient::waitForChannel() return false; } + // grab the active voice server version info to see if we should use + // vivox. + LLVoiceVersionInfo version = LLVoiceClient::getInstance()->getVersion(); + if (version.voiceServerType != VISIBLE_VOICE_SERVER_TYPE) + { + // we've switched to another voice provider, so + // disable voice and shut down vivox. Don't + // notify, though. + mVoiceEnabled = false; + } + switch (state) { case VOICE_CHANNEL_STATE_LOGIN: diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index d3b9f8ba2c..0332557229 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -93,7 +93,8 @@ namespace { const F32 SPEAKING_TIMEOUT = 1.f; const F32 SPEAKING_AUDIO_LEVEL = 0.40; - static const std::string VOICE_SERVER_TYPE = "WebRTC"; + static const std::string VISIBLE_VOICE_SERVER_TYPE = "WebRTC"; + static const std::string WEBRTC_VOICE_SERVER_TYPE = "webrtc"; // Don't send positional updates more frequently than this: const F32 UPDATE_THROTTLE_SECONDS = 0.1f; @@ -289,7 +290,7 @@ LLWebRTCVoiceClient::LLWebRTCVoiceClient() : mSpeakerVolume = 0.0; mVoiceVersion.serverVersion = ""; - mVoiceVersion.serverType = VOICE_SERVER_TYPE; + mVoiceVersion.voiceServerType = VISIBLE_VOICE_SERVER_TYPE; #if LL_DARWIN || LL_LINUX // HACK: THIS DOES NOT BELONG HERE @@ -559,10 +560,24 @@ void LLWebRTCVoiceClient::voiceConnectionCoro() continue; } + LLViewerRegion *regionp = gAgent.getRegion(); + if (!regionp) + { + continue; + } + LLVoiceVersionInfo version = LLVoiceClient::getInstance()->getVersion(); + if (version.voiceServerType != VISIBLE_VOICE_SERVER_TYPE) + { + // we've switched away from webrtc voice, so shut all channels down. + // leave channel can be called again and again without adverse effects. + // it merely tells channels to shut down if they're not already doing so. + leaveChannel(false); + continue; + } + if (inSpatialChannel()) { // add session for region or parcel voice. - LLViewerRegion *regionp = gAgent.getRegion(); if (!regionp || regionp->getRegionID().isNull()) { continue; @@ -2752,6 +2767,7 @@ void LLVoiceWebRTCConnection::OnVoiceConnectionRequestSuccess(const LLSD &result } else { + LL_WARNS("Voice") << "Invalid voice provision request result:" << result << LL_ENDL; setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); mOutstandingRequests--; return; |