summaryrefslogtreecommitdiff
path: root/indra/newview/llvoicechannel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoicechannel.cpp')
-rw-r--r--indra/newview/llvoicechannel.cpp281
1 files changed, 139 insertions, 142 deletions
diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp
index 7ca73a24bf..5914303e80 100644
--- a/indra/newview/llvoicechannel.cpp
+++ b/indra/newview/llvoicechannel.cpp
@@ -39,12 +39,11 @@
#include "llcorehttputil.h"
LLVoiceChannel::voice_channel_map_t LLVoiceChannel::sVoiceChannelMap;
-LLVoiceChannel::voice_channel_map_uri_t LLVoiceChannel::sVoiceChannelURIMap;
LLVoiceChannel* LLVoiceChannel::sCurrentVoiceChannel = NULL;
LLVoiceChannel* LLVoiceChannel::sSuspendedVoiceChannel = NULL;
LLVoiceChannel::channel_changed_signal_t LLVoiceChannel::sCurrentVoiceChannelChangedSignal;
-BOOL LLVoiceChannel::sSuspended = FALSE;
+bool LLVoiceChannel::sSuspended = false;
//
// Constants
@@ -59,7 +58,7 @@ LLVoiceChannel::LLVoiceChannel(const LLUUID& session_id, const std::string& sess
mState(STATE_NO_CHANNEL_INFO),
mSessionName(session_name),
mCallDirection(OUTGOING_CALL),
- mIgnoreNextSessionLeave(FALSE),
+ mIgnoreNextSessionLeave(false),
mCallEndedByAgent(false)
{
mNotifyArgs["VOICE_CHANNEL_NAME"] = mSessionName;
@@ -89,29 +88,18 @@ LLVoiceChannel::~LLVoiceChannel()
}
sVoiceChannelMap.erase(mSessionID);
- sVoiceChannelURIMap.erase(mURI);
}
-void LLVoiceChannel::setChannelInfo(
- const std::string& uri,
- const std::string& credentials)
+void LLVoiceChannel::setChannelInfo(const LLSD &channelInfo)
{
- setURI(uri);
-
- mCredentials = credentials;
+ mChannelInfo = channelInfo;
if (mState == STATE_NO_CHANNEL_INFO)
{
- if (mURI.empty())
- {
- LLNotificationsUtil::add("VoiceChannelJoinFailed", mNotifyArgs);
- LL_WARNS("Voice") << "Received empty URI for channel " << mSessionName << LL_ENDL;
- deactivate();
- }
- else if (mCredentials.empty())
+ if (mChannelInfo.isUndefined() || !mChannelInfo.isMap() || mChannelInfo.size() == 0)
{
LLNotificationsUtil::add("VoiceChannelJoinFailed", mNotifyArgs);
- LL_WARNS("Voice") << "Received empty credentials for channel " << mSessionName << LL_ENDL;
+ LL_WARNS("Voice") << "Received empty channel info for channel " << mSessionName << LL_ENDL;
deactivate();
}
else
@@ -130,9 +118,15 @@ void LLVoiceChannel::setChannelInfo(
}
}
-void LLVoiceChannel::onChange(EStatusType type, const std::string &channelURI, bool proximal)
+void LLVoiceChannel::onChange(EStatusType type, const LLSD& channelInfo, bool proximal)
{
- if (channelURI != mURI)
+ LL_DEBUGS("Voice") << "Incoming channel info: " << channelInfo << LL_ENDL;
+ LL_DEBUGS("Voice") << "Current channel info: " << mChannelInfo << LL_ENDL;
+ if (mChannelInfo.isUndefined() || (mChannelInfo.isMap() && mChannelInfo.size() == 0))
+ {
+ mChannelInfo = channelInfo;
+ }
+ if (!LLVoiceClient::getInstance()->compareChannels(mChannelInfo, channelInfo))
{
return;
}
@@ -158,13 +152,16 @@ void LLVoiceChannel::handleStatusChange(EStatusType type)
case STATUS_LOGGED_IN:
break;
case STATUS_LEFT_CHANNEL:
- if (callStarted() && !mIgnoreNextSessionLeave && !sSuspended)
+ if (callStarted() && !sSuspended)
{
// if forceably removed from channel
// update the UI and revert to default channel
+ // deactivate will set the State to STATE_HUNG_UP
+ // so when handleStatusChange is called again during
+ // shutdown callStarted will return false and deactivate
+ // won't be called again.
deactivate();
}
- mIgnoreNextSessionLeave = FALSE;
break;
case STATUS_JOINING:
if (callStarted())
@@ -190,13 +187,13 @@ void LLVoiceChannel::handleError(EStatusType type)
setState(STATE_ERROR);
}
-BOOL LLVoiceChannel::isActive()
+bool LLVoiceChannel::isActive() const
{
// only considered active when currently bound channel matches what our channel
- return callStarted() && LLVoiceClient::getInstance()->getCurrentChannel() == mURI;
+ return callStarted() && LLVoiceClient::getInstance()->isCurrentChannel(mChannelInfo);
}
-BOOL LLVoiceChannel::callStarted()
+bool LLVoiceChannel::callStarted() const
{
return mState >= STATE_CALL_STARTED;
}
@@ -206,7 +203,7 @@ void LLVoiceChannel::deactivate()
if (mState >= STATE_RINGING)
{
// ignore session leave event
- mIgnoreNextSessionLeave = TRUE;
+ mIgnoreNextSessionLeave = true;
}
if (callStarted())
@@ -246,10 +243,8 @@ void LLVoiceChannel::activate()
// activating the proximal channel between IM calls
LLVoiceChannel* old_channel = sCurrentVoiceChannel;
sCurrentVoiceChannel = this;
- mCallDialogPayload["old_channel_name"] = "";
if (old_channel)
{
- mCallDialogPayload["old_channel_name"] = old_channel->getSessionName();
old_channel->deactivate();
}
}
@@ -257,7 +252,7 @@ void LLVoiceChannel::activate()
if (mState == STATE_NO_CHANNEL_INFO)
{
// responsible for setting status to active
- getChannelInfo();
+ requestChannelInfo();
}
else
{
@@ -270,7 +265,7 @@ void LLVoiceChannel::activate()
sCurrentVoiceChannelChangedSignal(this->mSessionID);
}
-void LLVoiceChannel::getChannelInfo()
+void LLVoiceChannel::requestChannelInfo()
{
// pretend we have everything we need
if (sCurrentVoiceChannel == this)
@@ -293,20 +288,6 @@ LLVoiceChannel* LLVoiceChannel::getChannelByID(const LLUUID& session_id)
}
}
-//static
-LLVoiceChannel* LLVoiceChannel::getChannelByURI(std::string uri)
-{
- voice_channel_map_uri_t::iterator found_it = sVoiceChannelURIMap.find(uri);
- if (found_it == sVoiceChannelURIMap.end())
- {
- return NULL;
- }
- else
- {
- return found_it->second;
- }
-}
-
LLVoiceChannel* LLVoiceChannel::getCurrentVoiceChannel()
{
return sCurrentVoiceChannel;
@@ -319,13 +300,6 @@ void LLVoiceChannel::updateSessionID(const LLUUID& new_session_id)
sVoiceChannelMap.insert(std::make_pair(mSessionID, this));
}
-void LLVoiceChannel::setURI(std::string uri)
-{
- sVoiceChannelURIMap.erase(mURI);
- mURI = uri;
- sVoiceChannelURIMap.insert(std::make_pair(mURI, this));
-}
-
void LLVoiceChannel::setState(EState state)
{
switch(state)
@@ -370,7 +344,7 @@ void LLVoiceChannel::suspend()
if (!sSuspended)
{
sSuspendedVoiceChannel = sCurrentVoiceChannel;
- sSuspended = TRUE;
+ sSuspended = true;
}
}
@@ -390,7 +364,7 @@ void LLVoiceChannel::resume()
LLVoiceChannelProximal::getInstance()->activate();
}
}
- sSuspended = FALSE;
+ sSuspended = false;
}
}
@@ -410,11 +384,14 @@ boost::signals2::connection LLVoiceChannel::setCurrentVoiceChannelChangedCallbac
// LLVoiceChannelGroup
//
-LLVoiceChannelGroup::LLVoiceChannelGroup(const LLUUID& session_id, const std::string& session_name) :
- LLVoiceChannel(session_id, session_name)
+LLVoiceChannelGroup::LLVoiceChannelGroup(const LLUUID &session_id,
+ const std::string &session_name,
+ bool is_p2p) :
+ LLVoiceChannel(session_id, session_name),
+ mIsP2P(is_p2p)
{
mRetries = DEFAULT_RETRIES_COUNT;
- mIsRetrying = FALSE;
+ mIsRetrying = false;
}
void LLVoiceChannelGroup::deactivate()
@@ -424,7 +401,15 @@ void LLVoiceChannelGroup::deactivate()
LLVoiceClient::getInstance()->leaveNonSpatialChannel();
}
LLVoiceChannel::deactivate();
-}
+
+ if (mIsP2P)
+ {
+ // void the channel info for p2p adhoc channels
+ // so we request it again, hence throwing up the
+ // connect dialogue on the other side.
+ setState(STATE_NO_CHANNEL_INFO);
+ }
+ }
void LLVoiceChannelGroup::activate()
{
@@ -435,43 +420,46 @@ void LLVoiceChannelGroup::activate()
if (callStarted())
{
// we have the channel info, just need to use it now
- LLVoiceClient::getInstance()->setNonSpatialChannel(
- mURI,
- mCredentials);
+ LLVoiceClient::getInstance()->setNonSpatialChannel(mChannelInfo,
+ mIsP2P && (mCallDirection == OUTGOING_CALL),
+ mIsP2P);
- if (!gAgent.isInGroup(mSessionID)) // ad-hoc channel
+ if (mIsP2P)
{
- LLIMModel::LLIMSession* session = LLIMModel::getInstance()->findIMSession(mSessionID);
- // Adding ad-hoc call participants to Recent People List.
- // If it's an outgoing ad-hoc, we can use mInitialTargetIDs that holds IDs of people we
- // called(both online and offline) as source to get people for recent (STORM-210).
- if (session->isOutgoingAdHoc())
+ LLIMModel::addSpeakersToRecent(mSessionID);
+ }
+ else
+ {
+ if (!gAgent.isInGroup(mSessionID)) // ad-hoc channel
{
- for (uuid_vec_t::iterator it = session->mInitialTargetIDs.begin();
- it!=session->mInitialTargetIDs.end();++it)
+ LLIMModel::LLIMSession *session = LLIMModel::getInstance()->findIMSession(mSessionID);
+ // Adding ad-hoc call participants to Recent People List.
+ // If it's an outgoing ad-hoc, we can use mInitialTargetIDs that holds IDs of people we
+ // called(both online and offline) as source to get people for recent (STORM-210).
+ if (session && session->isOutgoingAdHoc())
{
- const LLUUID id = *it;
- LLRecentPeople::instance().add(id);
+ for (uuid_vec_t::iterator it = session->mInitialTargetIDs.begin(); it != session->mInitialTargetIDs.end(); ++it)
+ {
+ const LLUUID id = *it;
+ LLRecentPeople::instance().add(id);
+ }
+ }
+ // If this ad-hoc is incoming then trying to get ids of people from mInitialTargetIDs
+ // would lead to EXT-8246. So in this case we get them from speakers list.
+ else
+ {
+ LLIMModel::addSpeakersToRecent(mSessionID);
}
- }
- // If this ad-hoc is incoming then trying to get ids of people from mInitialTargetIDs
- // would lead to EXT-8246. So in this case we get them from speakers list.
- else
- {
- LLIMModel::addSpeakersToRecent(mSessionID);
}
}
- //Mic default state is OFF on initiating/joining Ad-Hoc/Group calls
- if (LLVoiceClient::getInstance()->getUserPTTState() && LLVoiceClient::getInstance()->getPTTIsToggle())
- {
- LLVoiceClient::getInstance()->inputUserControlState(true);
- }
+ // Mic default state is OFF on initiating/joining Ad-Hoc/Group calls. It's on for P2P using the AdHoc infra.
+ LLVoiceClient::getInstance()->setUserPTTState(mIsP2P);
}
}
-void LLVoiceChannelGroup::getChannelInfo()
+void LLVoiceChannelGroup::requestChannelInfo()
{
LLViewerRegion* region = gAgent.getRegion();
if (region)
@@ -483,17 +471,13 @@ void LLVoiceChannelGroup::getChannelInfo()
}
}
-void LLVoiceChannelGroup::setChannelInfo(
- const std::string& uri,
- const std::string& credentials)
+void LLVoiceChannelGroup::setChannelInfo(const LLSD& channelInfo)
{
- setURI(uri);
-
- mCredentials = credentials;
+ mChannelInfo = channelInfo;
if (mState == STATE_NO_CHANNEL_INFO)
{
- if(!mURI.empty() && !mCredentials.empty())
+ if(mChannelInfo.isDefined() && mChannelInfo.isMap())
{
setState(STATE_READY);
@@ -516,9 +500,9 @@ void LLVoiceChannelGroup::setChannelInfo(
else if ( mIsRetrying )
{
// we have the channel info, just need to use it now
- LLVoiceClient::getInstance()->setNonSpatialChannel(
- mURI,
- mCredentials);
+ LLVoiceClient::getInstance()->setNonSpatialChannel(channelInfo,
+ mCallDirection == OUTGOING_CALL,
+ mIsP2P);
}
}
@@ -529,7 +513,7 @@ void LLVoiceChannelGroup::handleStatusChange(EStatusType type)
{
case STATUS_JOINED:
mRetries = 3;
- mIsRetrying = FALSE;
+ mIsRetrying = false;
default:
break;
}
@@ -553,17 +537,17 @@ void LLVoiceChannelGroup::handleError(EStatusType status)
if ( mRetries > 0 )
{
mRetries--;
- mIsRetrying = TRUE;
- mIgnoreNextSessionLeave = TRUE;
+ mIsRetrying = true;
+ mIgnoreNextSessionLeave = true;
- getChannelInfo();
+ requestChannelInfo();
return;
}
else
{
notify = "VoiceChannelJoinFailed";
mRetries = DEFAULT_RETRIES_COUNT;
- mIsRetrying = FALSE;
+ mIsRetrying = false;
}
break;
@@ -612,6 +596,16 @@ void LLVoiceChannelGroup::voiceCallCapCoro(std::string url)
LLSD postData;
postData["method"] = "call";
postData["session-id"] = mSessionID;
+ LLSD altParams;
+ 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;
@@ -651,14 +645,12 @@ void LLVoiceChannelGroup::voiceCallCapCoro(std::string url)
LLSD::map_const_iterator iter;
for (iter = result.beginMap(); iter != result.endMap(); ++iter)
{
- LL_DEBUGS("Voice") << "LLVoiceCallCapResponder::result got "
+ LL_DEBUGS("Voice") << "LLVoiceChannelGroup::voiceCallCapCoro got "
<< iter->first << LL_ENDL;
}
+ LL_INFOS("Voice") << "LLVoiceChannelGroup::voiceCallCapCoro got " << result << LL_ENDL;
- channelp->setChannelInfo(
- result["voice_credentials"]["channel_uri"].asString(),
- result["voice_credentials"]["channel_credentials"].asString());
-
+ channelp->setChannelInfo(result["voice_credentials"]);
}
@@ -670,7 +662,7 @@ LLVoiceChannelProximal::LLVoiceChannelProximal() :
{
}
-BOOL LLVoiceChannelProximal::isActive()
+bool LLVoiceChannelProximal::isActive() const
{
return callStarted() && LLVoiceClient::getInstance()->inProximalChannel();
}
@@ -684,11 +676,12 @@ void LLVoiceChannelProximal::activate()
// we're connected to a non-spatial channel, so disconnect.
LLVoiceClient::getInstance()->leaveNonSpatialChannel();
}
- LLVoiceChannel::activate();
+ LLVoiceClient::getInstance()->activateSpatialChannel(true);
+ LLVoiceChannel::activate();
}
-void LLVoiceChannelProximal::onChange(EStatusType type, const std::string &channelURI, bool proximal)
+void LLVoiceChannelProximal::onChange(EStatusType type, const LLSD& channelInfo, bool proximal)
{
if (!proximal)
{
@@ -749,7 +742,7 @@ void LLVoiceChannelProximal::handleError(EStatusType status)
LLNotificationsUtil::add(notify, mNotifyArgs);
}
- LLVoiceChannel::handleError(status);
+ // proximal voice remains up and the provider will try to reconnect.
}
void LLVoiceChannelProximal::deactivate()
@@ -758,19 +751,24 @@ void LLVoiceChannelProximal::deactivate()
{
setState(STATE_HUNG_UP);
}
+ LLVoiceClient::getInstance()->removeObserver(this);
+ LLVoiceClient::getInstance()->activateSpatialChannel(false);
}
//
// LLVoiceChannelP2P
//
-LLVoiceChannelP2P::LLVoiceChannelP2P(const LLUUID& session_id, const std::string& session_name, const LLUUID& other_user_id) :
- LLVoiceChannelGroup(session_id, session_name),
- mOtherUserID(other_user_id),
- mReceivedCall(FALSE)
+LLVoiceChannelP2P::LLVoiceChannelP2P(const LLUUID &session_id,
+ const std::string &session_name,
+ const LLUUID &other_user_id,
+ LLVoiceP2POutgoingCallInterface* outgoing_call_interface) :
+ LLVoiceChannelGroup(session_id, session_name, true),
+ mOtherUserID(other_user_id),
+ mReceivedCall(false),
+ mOutgoingCallInterface(outgoing_call_interface)
{
- // make sure URI reflects encoded version of other user's agent id
- setURI(LLVoiceClient::getInstance()->sipURIFromID(other_user_id));
+ mChannelInfo = LLVoiceClient::getInstance()->getP2PChannelInfoTemplate(other_user_id);
}
void LLVoiceChannelP2P::handleStatusChange(EStatusType type)
@@ -796,12 +794,12 @@ void LLVoiceChannelP2P::handleStatusChange(EStatusType type)
}
deactivate();
}
- mIgnoreNextSessionLeave = FALSE;
+ mIgnoreNextSessionLeave = false;
return;
case STATUS_JOINING:
// because we join session we expect to process session leave event in the future. EXT-7371
// may be this should be done in the LLVoiceChannel::handleStatusChange.
- mIgnoreNextSessionLeave = FALSE;
+ mIgnoreNextSessionLeave = false;
break;
default:
@@ -837,23 +835,23 @@ void LLVoiceChannelP2P::activate()
if (callStarted())
{
// no session handle yet, we're starting the call
- if (mSessionHandle.empty())
+ if (mIncomingCallInterface == nullptr)
{
- mReceivedCall = FALSE;
- LLVoiceClient::getInstance()->callUser(mOtherUserID);
+ mReceivedCall = false;
+ mOutgoingCallInterface->callUser(mOtherUserID);
}
// otherwise answering the call
else
{
- if (!LLVoiceClient::getInstance()->answerInvite(mSessionHandle))
+ if (!mIncomingCallInterface->answerInvite())
{
mCallEndedByAgent = false;
- mSessionHandle.clear();
+ mIncomingCallInterface.reset();
handleError(ERROR_UNKNOWN);
return;
}
- // using the session handle invalidates it. Clear it out here so we can't reuse it by accident.
- mSessionHandle.clear();
+ // using the incoming call interface invalidates it. Clear it out here so we can't reuse it by accident.
+ mIncomingCallInterface.reset();
}
// Add the party to the list of people with which we've recently interacted.
@@ -867,7 +865,17 @@ void LLVoiceChannelP2P::activate()
}
}
-void LLVoiceChannelP2P::getChannelInfo()
+void LLVoiceChannelP2P::deactivate()
+{
+ if (callStarted())
+ {
+ mOutgoingCallInterface->hangup();
+ }
+ LLVoiceChannel::deactivate();
+}
+
+
+void LLVoiceChannelP2P::requestChannelInfo()
{
// pretend we have everything we need, since P2P doesn't use channel info
if (sCurrentVoiceChannel == this)
@@ -877,9 +885,10 @@ void LLVoiceChannelP2P::getChannelInfo()
}
// receiving session from other user who initiated call
-void LLVoiceChannelP2P::setSessionHandle(const std::string& handle, const std::string &inURI)
+void LLVoiceChannelP2P::setChannelInfo(const LLSD& channel_info)
{
- BOOL needs_activate = FALSE;
+ mChannelInfo = channel_info;
+ bool needs_activate = false;
if (callStarted())
{
// defer to lower agent id when already active
@@ -887,34 +896,22 @@ void LLVoiceChannelP2P::setSessionHandle(const std::string& handle, const std::s
{
// pretend we haven't started the call yet, so we can connect to this session instead
deactivate();
- needs_activate = TRUE;
+ needs_activate = true;
}
else
{
// we are active and have priority, invite the other user again
// under the assumption they will join this new session
- mSessionHandle.clear();
- LLVoiceClient::getInstance()->callUser(mOtherUserID);
+ mOutgoingCallInterface->callUser(mOtherUserID);
return;
}
}
- mSessionHandle = handle;
-
- // The URI of a p2p session should always be the other end's SIP URI.
- if(!inURI.empty())
+ mReceivedCall = true;
+ if (channel_info.isDefined() && channel_info.isMap())
{
- setURI(inURI);
+ mIncomingCallInterface = LLVoiceClient::getInstance()->getIncomingCallInterface(channel_info);
}
- else
- {
- LL_WARNS("Voice") << "incoming SIP URL is not provided. Channel may not work properly." << LL_ENDL;
- // See LLVoiceClient::sessionAddedEvent()
- setURI(LLVoiceClient::getInstance()->sipURIFromID(mOtherUserID));
- }
-
- mReceivedCall = TRUE;
-
if (needs_activate)
{
activate();
@@ -932,7 +929,7 @@ void LLVoiceChannelP2P::setState(EState state)
if (mReceivedCall && state == STATE_RINGING)
{
//TODO: remove or redirect this call status notification
-// LLCallInfoDialog::show("answering", mNotifyArgs);
+ // LLCallInfoDialog::show("answering", mNotifyArgs);
doSetState(state);
return;
}