Sync some voice stuff

This commit is contained in:
Lirusaito
2018-07-15 12:12:21 -04:00
parent e31c088470
commit 4c8bd8d3ca
2 changed files with 107 additions and 98 deletions

View File

@@ -35,21 +35,6 @@
extern AIHTTPTimeoutPolicy voiceCallCapResponder_timeout; extern AIHTTPTimeoutPolicy voiceCallCapResponder_timeout;
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;
//
// Constants
//
const U32 DEFAULT_RETRIES_COUNT = 3;
class LLVoiceCallCapResponder : public LLHTTPClient::ResponderWithResult class LLVoiceCallCapResponder : public LLHTTPClient::ResponderWithResult
{ {
public: public:
@@ -66,59 +51,29 @@ private:
}; };
void LLVoiceCallCapResponder::httpFailure(void) LLVoiceChannel::voice_channel_map_t LLVoiceChannel::sVoiceChannelMap;
{ LLVoiceChannel::voice_channel_map_uri_t LLVoiceChannel::sVoiceChannelURIMap;
LL_WARNS("Voice") << "LLVoiceCallCapResponder error [status:" LLVoiceChannel* LLVoiceChannel::sCurrentVoiceChannel = nullptr;
<< mStatus << "]: " << mReason << LL_ENDL; LLVoiceChannel* LLVoiceChannel::sSuspendedVoiceChannel = nullptr;
LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID); LLVoiceChannel::channel_changed_signal_t LLVoiceChannel::sCurrentVoiceChannelChangedSignal;
if ( channelp )
{
if ( 403 == mStatus )
{
//403 == no ability
LLNotificationsUtil::add(
"VoiceNotAllowed",
channelp->getNotifyArgs());
}
else
{
LLNotificationsUtil::add(
"VoiceCallGenericError",
channelp->getNotifyArgs());
}
channelp->deactivate();
}
}
void LLVoiceCallCapResponder::httpSuccess(void) BOOL LLVoiceChannel::sSuspended = FALSE;
{
LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID);
if (channelp)
{
// *TODO: DEBUG SPAM
LLSD::map_const_iterator iter;
for(iter = mContent.beginMap(); iter != mContent.endMap(); ++iter)
{
LL_DEBUGS("Voice") << "LLVoiceCallCapResponder::result got "
<< iter->first << LL_ENDL;
}
channelp->setChannelInfo( //
mContent["voice_credentials"]["channel_uri"].asString(), // Constants
mContent["voice_credentials"]["channel_credentials"].asString()); //
} const U32 DEFAULT_RETRIES_COUNT = 3;
}
// //
// LLVoiceChannel // LLVoiceChannel
// //
LLVoiceChannel::LLVoiceChannel(const LLUUID& session_id, const std::string& session_name) : LLVoiceChannel::LLVoiceChannel(const LLUUID& session_id, const std::string& session_name) :
mCallDirection(OUTGOING_CALL),
mSessionID(session_id), mSessionID(session_id),
mState(STATE_NO_CHANNEL_INFO), mState(STATE_NO_CHANNEL_INFO),
mSessionName(session_name), mSessionName(session_name),
mCallDirection(OUTGOING_CALL), mCallEndedByAgent(false),
mIgnoreNextSessionLeave(FALSE), mIgnoreNextSessionLeave(FALSE)
mCallEndedByAgent(false)
{ {
mNotifyArgs["VOICE_CHANNEL_NAME"] = mSessionName; mNotifyArgs["VOICE_CHANNEL_NAME"] = mSessionName;
@@ -203,19 +158,9 @@ void LLVoiceChannel::handleStatusChange(EStatusType type)
switch(type) switch(type)
{ {
case STATUS_LOGIN_RETRY: case STATUS_LOGIN_RETRY:
//mLoginNotificationHandle = LLNotifyBox::showXml("VoiceLoginRetry")->getHandle(); // no user notice
LLNotificationsUtil::add("VoiceLoginRetry");
break; break;
case STATUS_LOGGED_IN: case STATUS_LOGGED_IN:
//if (!mLoginNotificationHandle.isDead())
//{
// LLNotifyBox* notifyp = (LLNotifyBox*)mLoginNotificationHandle.get();
// if (notifyp)
// {
// notifyp->close();
// }
// mLoginNotificationHandle.markDead();
//}
break; break;
case STATUS_LEFT_CHANNEL: case STATUS_LEFT_CHANNEL:
if (callStarted() && !mIgnoreNextSessionLeave && !sSuspended) if (callStarted() && !mIgnoreNextSessionLeave && !sSuspended)
@@ -346,7 +291,7 @@ LLVoiceChannel* LLVoiceChannel::getChannelByID(const LLUUID& session_id)
voice_channel_map_t::iterator found_it = sVoiceChannelMap.find(session_id); voice_channel_map_t::iterator found_it = sVoiceChannelMap.find(session_id);
if (found_it == sVoiceChannelMap.end()) if (found_it == sVoiceChannelMap.end())
{ {
return NULL; return nullptr;
} }
else else
{ {
@@ -360,7 +305,7 @@ LLVoiceChannel* LLVoiceChannel::getChannelByURI(std::string uri)
voice_channel_map_uri_t::iterator found_it = sVoiceChannelURIMap.find(uri); voice_channel_map_uri_t::iterator found_it = sVoiceChannelURIMap.find(uri);
if (found_it == sVoiceChannelURIMap.end()) if (found_it == sVoiceChannelURIMap.end())
{ {
return NULL; return nullptr;
} }
else else
{ {
@@ -664,6 +609,49 @@ void LLVoiceChannelGroup::setState(EState state)
} }
} }
void LLVoiceCallCapResponder::httpFailure(void)
{
LL_WARNS("Voice") << "LLVoiceCallCapResponder error [status:"
<< mStatus << "]: " << mReason << LL_ENDL;
LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID);
if ( channelp )
{
if ( 403 == mStatus )
{
//403 == no ability
LLNotificationsUtil::add(
"VoiceNotAllowed",
channelp->getNotifyArgs());
}
else
{
LLNotificationsUtil::add(
"VoiceCallGenericError",
channelp->getNotifyArgs());
}
channelp->deactivate();
}
}
void LLVoiceCallCapResponder::httpSuccess(void)
{
LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID);
if (channelp)
{
// *TODO: DEBUG SPAM
LLSD::map_const_iterator iter;
for(iter = mContent.beginMap(); iter != mContent.endMap(); ++iter)
{
LL_DEBUGS("Voice") << "LLVoiceCallCapResponder::result got "
<< iter->first << LL_ENDL;
}
channelp->setChannelInfo(
mContent["voice_credentials"]["channel_uri"].asString(),
mContent["voice_credentials"]["channel_credentials"].asString());
}
}
// //
// LLVoiceChannelProximal // LLVoiceChannelProximal
// //

View File

@@ -1,3 +1,5 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
/** /**
* @file llvoiceclient.cpp * @file llvoiceclient.cpp
* @brief Voice client delegation class implementation. * @brief Voice client delegation class implementation.
@@ -51,7 +53,7 @@ public:
// requests will be throttled from a non-trusted browser // requests will be throttled from a non-trusted browser
LLVoiceHandler() : LLCommandHandler("voice", UNTRUSTED_THROTTLE) {} LLVoiceHandler() : LLCommandHandler("voice", UNTRUSTED_THROTTLE) {}
bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) override
{ {
if (params[0].asString() == "effects") if (params[0].asString() == "effects")
{ {
@@ -111,8 +113,8 @@ std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserv
LLVoiceClient::LLVoiceClient() LLVoiceClient::LLVoiceClient()
: :
mVoiceModule(NULL), mVoiceModule(nullptr),
m_servicePump(NULL), m_servicePump(nullptr),
mVoiceEffectEnabled(LLCachedControl<bool>(gSavedSettings, "VoiceMorphingEnabled", true)), mVoiceEffectEnabled(LLCachedControl<bool>(gSavedSettings, "VoiceMorphingEnabled", true)),
mVoiceEffectDefault(LLCachedControl<std::string>(gSavedPerAccountSettings, "VoiceEffectDefault", "00000000-0000-0000-0000-000000000000")), mVoiceEffectDefault(LLCachedControl<std::string>(gSavedPerAccountSettings, "VoiceEffectDefault", "00000000-0000-0000-0000-000000000000")),
mPTTDirty(true), mPTTDirty(true),
@@ -153,18 +155,17 @@ void LLVoiceClient::userAuthorized(const std::string& user_id, const LLUUID &age
} }
else else
{ {
mVoiceModule = NULL; mVoiceModule = nullptr;
return; return;
} }
mVoiceModule->init(m_servicePump); mVoiceModule->init(m_servicePump);
mVoiceModule->userAuthorized(user_id, agentID); mVoiceModule->userAuthorized(user_id, agentID);
} }
void LLVoiceClient::terminate() void LLVoiceClient::terminate()
{ {
if (mVoiceModule) mVoiceModule->terminate(); if (mVoiceModule) mVoiceModule->terminate();
mVoiceModule = NULL; mVoiceModule = nullptr;
} }
const LLVoiceVersionInfo LLVoiceClient::getVersion() const LLVoiceVersionInfo LLVoiceClient::getVersion()
@@ -192,7 +193,10 @@ void LLVoiceClient::updateSettings()
updateMicMuteLogic(); updateMicMuteLogic();
if (mVoiceModule) mVoiceModule->updateSettings(); if (mVoiceModule)
{
mVoiceModule->updateSettings();
}
} }
//-------------------------------------------------- //--------------------------------------------------
@@ -394,24 +398,36 @@ void LLVoiceClient::setNonSpatialChannel(
const std::string &uri, const std::string &uri,
const std::string &credentials) const std::string &credentials)
{ {
if (mVoiceModule) mVoiceModule->setNonSpatialChannel(uri, credentials); if (mVoiceModule)
{
mVoiceModule->setNonSpatialChannel(uri, credentials);
}
} }
void LLVoiceClient::setSpatialChannel( void LLVoiceClient::setSpatialChannel(
const std::string &uri, const std::string &uri,
const std::string &credentials) const std::string &credentials)
{ {
if (mVoiceModule) mVoiceModule->setSpatialChannel(uri, credentials); if (mVoiceModule)
{
mVoiceModule->setSpatialChannel(uri, credentials);
}
} }
void LLVoiceClient::leaveNonSpatialChannel() void LLVoiceClient::leaveNonSpatialChannel()
{ {
if (mVoiceModule) mVoiceModule->leaveNonSpatialChannel(); if (mVoiceModule)
{
mVoiceModule->leaveNonSpatialChannel();
}
} }
void LLVoiceClient::leaveChannel(void) void LLVoiceClient::leaveChannel(void)
{ {
if (mVoiceModule) mVoiceModule->leaveChannel(); if (mVoiceModule)
{
mVoiceModule->leaveChannel();
}
} }
std::string LLVoiceClient::getCurrentChannel() std::string LLVoiceClient::getCurrentChannel()
@@ -497,7 +513,10 @@ bool LLVoiceClient::voiceEnabled()
void LLVoiceClient::setVoiceEnabled(bool enabled) void LLVoiceClient::setVoiceEnabled(bool enabled)
{ {
if (mVoiceModule) mVoiceModule->setVoiceEnabled(enabled); if (mVoiceModule)
{
mVoiceModule->setVoiceEnabled(enabled);
}
} }
void LLVoiceClient::updateMicMuteLogic() void LLVoiceClient::updateMicMuteLogic()
@@ -637,33 +656,34 @@ void LLVoiceClient::keyDown(KEY key, MASK mask)
return; return;
} }
if(!mPTTIsMiddleMouse) if(!mPTTIsMiddleMouse && mPTTKey != KEY_NONE)
{
bool down = gKeyboard->getKeyDown(mPTTKey);
if (down)
{ {
bool down = (mPTTKey != KEY_NONE)
&& gKeyboard->getKeyDown(mPTTKey);
inputUserControlState(down); inputUserControlState(down);
} }
}
} }
void LLVoiceClient::keyUp(KEY key, MASK mask) void LLVoiceClient::keyUp(KEY key, MASK mask)
{ {
if(!mPTTIsMiddleMouse) if(!mPTTIsMiddleMouse && mPTTKey != KEY_NONE)
{
bool down = gKeyboard->getKeyDown(mPTTKey);
if (!down)
{ {
bool down = (mPTTKey != KEY_NONE)
&& gKeyboard->getKeyDown(mPTTKey);
inputUserControlState(down); inputUserControlState(down);
} }
} }
}
void LLVoiceClient::middleMouseState(bool down) void LLVoiceClient::middleMouseState(bool down)
{
if(mPTTIsMiddleMouse)
{ {
if(mPTTIsMiddleMouse) if(mPTTIsMiddleMouse)
{ {
inputUserControlState(down); inputUserControlState(down);
} }
} }
}
//------------------------------------------- //-------------------------------------------
@@ -840,10 +860,11 @@ LLVoiceEffectInterface* LLVoiceClient::getVoiceEffectInterface() const
class LLViewerRequiredVoiceVersion : public LLHTTPNode class LLViewerRequiredVoiceVersion : public LLHTTPNode
{ {
static BOOL sAlertedUser; static BOOL sAlertedUser;
virtual void post(
void post(
LLHTTPNode::ResponsePtr response, LLHTTPNode::ResponsePtr response,
const LLSD& context, const LLSD& context,
const LLSD& input) const const LLSD& input) const override
{ {
//You received this messsage (most likely on region cross or //You received this messsage (most likely on region cross or
//teleport) //teleport)
@@ -870,10 +891,10 @@ class LLViewerRequiredVoiceVersion : public LLHTTPNode
class LLViewerParcelVoiceInfo : public LLHTTPNode class LLViewerParcelVoiceInfo : public LLHTTPNode
{ {
virtual void post( void post(
LLHTTPNode::ResponsePtr response, LLHTTPNode::ResponsePtr response,
const LLSD& context, const LLSD& context,
const LLSD& input) const const LLSD& input) const override
{ {
//the parcel you are in has changed something about its //the parcel you are in has changed something about its
//voice information //voice information