Hang up when peer hangs up in ad-hoc driven p2p call

master
Roxie Linden 2024-02-01 21:53:33 -08:00
parent ecd6b87b19
commit 0cd8ad6ebb
7 changed files with 63 additions and 27 deletions

View File

@ -437,7 +437,8 @@ void LLVoiceChannelGroup::activate()
// we have the channel info, just need to use it now
LLVoiceClient::getInstance()->setNonSpatialChannel(
mURI,
mCredentials);
mCredentials,
!LLVoiceClient::getInstance()->hasP2PInterface());
if (!gAgent.isInGroup(mSessionID)) // ad-hoc channel
{
@ -518,7 +519,8 @@ void LLVoiceChannelGroup::setChannelInfo(
// we have the channel info, just need to use it now
LLVoiceClient::getInstance()->setNonSpatialChannel(
mURI,
mCredentials);
mCredentials,
!LLVoiceClient::getInstance()->hasP2PInterface());
}
}
@ -527,6 +529,30 @@ void LLVoiceChannelGroup::handleStatusChange(EStatusType type)
// status updates
switch(type)
{
case STATUS_LEFT_CHANNEL:
{
if (!LLVoiceClient::getInstance()->hasP2PInterface())
{
// we're using group/adhoc for p2p
if (callStarted() && !mIgnoreNextSessionLeave && !sSuspended)
{
// *TODO: use it to show DECLINE voice notification
if (mState == STATE_RINGING)
{
// other user declined call
LLNotificationsUtil::add("P2PCallDeclined", mNotifyArgs);
}
else
{
// other user hung up, so we didn't end the call
mCallEndedByAgent = false;
}
deactivate();
}
mIgnoreNextSessionLeave = FALSE;
return;
}
}
case STATUS_JOINED:
mRetries = 3;
mIsRetrying = FALSE;

View File

@ -436,11 +436,12 @@ bool LLVoiceClient::inProximalChannel()
void LLVoiceClient::setNonSpatialChannel(
const std::string &uri,
const std::string &credentials)
const std::string &credentials,
bool hangup_on_last_leave)
{
if (mVoiceModule)
{
mVoiceModule->setNonSpatialChannel(uri, credentials);
mVoiceModule->setNonSpatialChannel(uri, credentials, hangup_on_last_leave);
}
}

View File

@ -167,7 +167,8 @@ public:
virtual bool inProximalChannel()=0;
virtual void setNonSpatialChannel(const std::string &uri,
const std::string &credentials)=0;
const std::string &credentials,
bool hangup_on_last_leave = false)=0;
virtual bool setSpatialChannel(const std::string &uri,
const std::string &credentials)=0;
@ -371,9 +372,12 @@ public:
// returns true iff the user is currently in a proximal (local spatial) channel.
// Note that gestures should only fire if this returns true.
bool inProximalChannel();
void setNonSpatialChannel(
const std::string &uri,
const std::string &credentials);
const std::string &uri,
const std::string &credentials,
bool hangup_on_last_leave = false);
void setSpatialChannel(
const std::string &uri,
const std::string &credentials);

View File

@ -5025,7 +5025,8 @@ void LLVivoxVoiceClient::joinSession(const sessionStatePtr_t &session)
void LLVivoxVoiceClient::setNonSpatialChannel(
const std::string &uri,
const std::string &credentials)
const std::string &credentials,
bool hangup_on_last_leave)
{
switchChannel(uri, false, false, false, credentials);
}

View File

@ -135,7 +135,8 @@ public:
virtual bool inProximalChannel();
virtual void setNonSpatialChannel(const std::string &uri,
const std::string &credentials);
const std::string &credentials,
bool hangup_on_last_leave);
virtual bool setSpatialChannel(const std::string &uri,
const std::string &credentials);

View File

@ -485,11 +485,9 @@ bool LLWebRTCVoiceClient::sessionState::processConnectionStates()
}
//////////////////////////
// LLWebRTCVoiceClient::estateSessionState
LLWebRTCVoiceClient::estateSessionState::estateSessionState()
{
mHangupOnLastLeave = false;
mChannelID = "Estate";
LLUUID region_id = gAgent.getRegion()->getRegionID();
@ -498,14 +496,16 @@ LLWebRTCVoiceClient::estateSessionState::estateSessionState()
LLWebRTCVoiceClient::parcelSessionState::parcelSessionState(const std::string &channelID, S32 parcel_local_id)
{
mHangupOnLastLeave = false;
LLUUID region_id = gAgent.getRegion()->getRegionID();
mChannelID = channelID;
mWebRTCConnections.emplace_back(new LLVoiceWebRTCSpatialConnection(region_id, parcel_local_id, channelID));
}
LLWebRTCVoiceClient::adhocSessionState::adhocSessionState(const std::string &channelID, const std::string& credentials) :
LLWebRTCVoiceClient::adhocSessionState::adhocSessionState(const std::string &channelID, const std::string& credentials, bool hangup_on_last_leave) :
mCredentials(credentials)
{
mHangupOnLastLeave = hangup_on_last_leave;
LLUUID region_id = gAgent.getRegion()->getRegionID();
mChannelID = channelID;
mWebRTCConnections.emplace_back(new LLVoiceWebRTCAdHocConnection(region_id, channelID, credentials));
@ -1181,6 +1181,12 @@ void LLWebRTCVoiceClient::removeParticipantByID(const std::string &channelID, co
if (participant)
{
session->removeParticipant(participant);
if (session->mHangupOnLastLeave &&
(id != gAgentID) &&
(session->mParticipantsByURI.size() <= 1))
{
notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL);
}
}
}
}
@ -1199,10 +1205,10 @@ bool LLWebRTCVoiceClient::startParcelSession(const std::string &channelID, S32 p
return true;
}
bool LLWebRTCVoiceClient::startAdHocSession(const std::string &channelID, const std::string &credentials)
bool LLWebRTCVoiceClient::startAdHocSession(const std::string &channelID, const std::string &credentials, bool hangup_on_last_leave)
{
leaveChannel(false);
mNextSession = addSession(channelID, sessionState::ptr_t(new adhocSessionState(channelID, credentials)));
mNextSession = addSession(channelID, sessionState::ptr_t(new adhocSessionState(channelID, credentials, hangup_on_last_leave)));
return true;
}
@ -1602,14 +1608,7 @@ void LLWebRTCVoiceClient::leaveChannel(bool stopTalking)
if (mSession)
{
// If we're already in a channel, or if we're joining one, terminate
// so we can rejoin with the new session data.
bool wasShuttingDown = mSession->mShuttingDown;
deleteSession(mSession);
if (!wasShuttingDown)
{
notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL);
}
}
if (mNextSession)
@ -2980,7 +2979,9 @@ void LLVoiceWebRTCSpatialConnection::setMuteMic(bool muted)
/////////////////////////////
// WebRTC Spatial Connection
LLVoiceWebRTCAdHocConnection::LLVoiceWebRTCAdHocConnection(const LLUUID &regionID, const std::string& channelID, const std::string& credentials) :
LLVoiceWebRTCAdHocConnection::LLVoiceWebRTCAdHocConnection(const LLUUID &regionID,
const std::string& channelID,
const std::string& credentials) :
LLVoiceWebRTCConnection(regionID, channelID),
mCredentials(credentials)
{

View File

@ -144,8 +144,8 @@ public:
// Note that gestures should only fire if this returns true.
bool inProximalChannel() override;
void setNonSpatialChannel(const std::string& uri, const std::string& credentials) override {
startAdHocSession(uri, credentials);
void setNonSpatialChannel(const std::string& uri, const std::string& credentials, bool hangup_on_last_leave) override {
startAdHocSession(uri, credentials, hangup_on_last_leave);
}
bool setSpatialChannel(const std::string &uri, const std::string &credentials) override
@ -388,6 +388,8 @@ public:
static bool hasSession(const std::string &sessionID)
{ return mSessions.find(sessionID) != mSessions.end(); }
bool mHangupOnLastLeave;
protected:
sessionState();
std::list<connectionPtr_t> mWebRTCConnections;
@ -428,7 +430,7 @@ public:
class adhocSessionState : public sessionState
{
public:
adhocSessionState(const std::string &channelID, const std::string& credentials);
adhocSessionState(const std::string &channelID, const std::string& credentials, bool hangup_on_last_leave);
bool isSpatial() override { return false; }
bool isEstate() override { return false; }
@ -601,7 +603,7 @@ private:
bool startEstateSession();
bool startParcelSession(const std::string& channelID, S32 parcelID);
bool startAdHocSession(const std::string& channelID, const std::string& credentials);
bool startAdHocSession(const std::string& channelID, const std::string& credentials, bool hangup_on_last_leave);
void joinSession(const sessionStatePtr_t &session);