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;
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
{
public:
@@ -66,59 +51,29 @@ private:
};
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();
}
}
LLVoiceChannel::voice_channel_map_t LLVoiceChannel::sVoiceChannelMap;
LLVoiceChannel::voice_channel_map_uri_t LLVoiceChannel::sVoiceChannelURIMap;
LLVoiceChannel* LLVoiceChannel::sCurrentVoiceChannel = nullptr;
LLVoiceChannel* LLVoiceChannel::sSuspendedVoiceChannel = nullptr;
LLVoiceChannel::channel_changed_signal_t LLVoiceChannel::sCurrentVoiceChannelChangedSignal;
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;
}
BOOL LLVoiceChannel::sSuspended = FALSE;
channelp->setChannelInfo(
mContent["voice_credentials"]["channel_uri"].asString(),
mContent["voice_credentials"]["channel_credentials"].asString());
}
}
//
// Constants
//
const U32 DEFAULT_RETRIES_COUNT = 3;
//
// LLVoiceChannel
//
LLVoiceChannel::LLVoiceChannel(const LLUUID& session_id, const std::string& session_name) :
mCallDirection(OUTGOING_CALL),
mSessionID(session_id),
mState(STATE_NO_CHANNEL_INFO),
mSessionName(session_name),
mCallDirection(OUTGOING_CALL),
mIgnoreNextSessionLeave(FALSE),
mCallEndedByAgent(false)
mCallEndedByAgent(false),
mIgnoreNextSessionLeave(FALSE)
{
mNotifyArgs["VOICE_CHANNEL_NAME"] = mSessionName;
@@ -203,19 +158,9 @@ void LLVoiceChannel::handleStatusChange(EStatusType type)
switch(type)
{
case STATUS_LOGIN_RETRY:
//mLoginNotificationHandle = LLNotifyBox::showXml("VoiceLoginRetry")->getHandle();
LLNotificationsUtil::add("VoiceLoginRetry");
// no user notice
break;
case STATUS_LOGGED_IN:
//if (!mLoginNotificationHandle.isDead())
//{
// LLNotifyBox* notifyp = (LLNotifyBox*)mLoginNotificationHandle.get();
// if (notifyp)
// {
// notifyp->close();
// }
// mLoginNotificationHandle.markDead();
//}
break;
case STATUS_LEFT_CHANNEL:
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);
if (found_it == sVoiceChannelMap.end())
{
return NULL;
return nullptr;
}
else
{
@@ -360,7 +305,7 @@ LLVoiceChannel* LLVoiceChannel::getChannelByURI(std::string uri)
voice_channel_map_uri_t::iterator found_it = sVoiceChannelURIMap.find(uri);
if (found_it == sVoiceChannelURIMap.end())
{
return NULL;
return nullptr;
}
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
//

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
* @brief Voice client delegation class implementation.
@@ -51,7 +53,7 @@ public:
// requests will be throttled from a non-trusted browser
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")
{
@@ -111,8 +113,8 @@ std::string LLVoiceClientStatusObserver::status2string(LLVoiceClientStatusObserv
LLVoiceClient::LLVoiceClient()
:
mVoiceModule(NULL),
m_servicePump(NULL),
mVoiceModule(nullptr),
m_servicePump(nullptr),
mVoiceEffectEnabled(LLCachedControl<bool>(gSavedSettings, "VoiceMorphingEnabled", true)),
mVoiceEffectDefault(LLCachedControl<std::string>(gSavedPerAccountSettings, "VoiceEffectDefault", "00000000-0000-0000-0000-000000000000")),
mPTTDirty(true),
@@ -153,18 +155,17 @@ void LLVoiceClient::userAuthorized(const std::string& user_id, const LLUUID &age
}
else
{
mVoiceModule = NULL;
mVoiceModule = nullptr;
return;
}
mVoiceModule->init(m_servicePump);
mVoiceModule->userAuthorized(user_id, agentID);
}
void LLVoiceClient::terminate()
{
if (mVoiceModule) mVoiceModule->terminate();
mVoiceModule = NULL;
mVoiceModule = nullptr;
}
const LLVoiceVersionInfo LLVoiceClient::getVersion()
@@ -192,7 +193,10 @@ void LLVoiceClient::updateSettings()
updateMicMuteLogic();
if (mVoiceModule) mVoiceModule->updateSettings();
if (mVoiceModule)
{
mVoiceModule->updateSettings();
}
}
//--------------------------------------------------
@@ -394,24 +398,36 @@ void LLVoiceClient::setNonSpatialChannel(
const std::string &uri,
const std::string &credentials)
{
if (mVoiceModule) mVoiceModule->setNonSpatialChannel(uri, 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 (mVoiceModule)
{
mVoiceModule->setSpatialChannel(uri, credentials);
}
}
void LLVoiceClient::leaveNonSpatialChannel()
{
if (mVoiceModule) mVoiceModule->leaveNonSpatialChannel();
if (mVoiceModule)
{
mVoiceModule->leaveNonSpatialChannel();
}
}
void LLVoiceClient::leaveChannel(void)
{
if (mVoiceModule) mVoiceModule->leaveChannel();
if (mVoiceModule)
{
mVoiceModule->leaveChannel();
}
}
std::string LLVoiceClient::getCurrentChannel()
@@ -497,7 +513,10 @@ bool LLVoiceClient::voiceEnabled()
void LLVoiceClient::setVoiceEnabled(bool enabled)
{
if (mVoiceModule) mVoiceModule->setVoiceEnabled(enabled);
if (mVoiceModule)
{
mVoiceModule->setVoiceEnabled(enabled);
}
}
void LLVoiceClient::updateMicMuteLogic()
@@ -637,31 +656,32 @@ void LLVoiceClient::keyDown(KEY key, MASK mask)
return;
}
if(!mPTTIsMiddleMouse)
if(!mPTTIsMiddleMouse && mPTTKey != KEY_NONE)
{
bool down = (mPTTKey != KEY_NONE)
&& gKeyboard->getKeyDown(mPTTKey);
inputUserControlState(down);
bool down = gKeyboard->getKeyDown(mPTTKey);
if (down)
{
inputUserControlState(down);
}
}
}
void LLVoiceClient::keyUp(KEY key, MASK mask)
{
if(!mPTTIsMiddleMouse)
if(!mPTTIsMiddleMouse && mPTTKey != KEY_NONE)
{
bool down = (mPTTKey != KEY_NONE)
&& gKeyboard->getKeyDown(mPTTKey);
inputUserControlState(down);
bool down = gKeyboard->getKeyDown(mPTTKey);
if (!down)
{
inputUserControlState(down);
}
}
}
void LLVoiceClient::middleMouseState(bool down)
{
if(mPTTIsMiddleMouse)
{
if(mPTTIsMiddleMouse)
{
inputUserControlState(down);
}
}
}
@@ -840,10 +860,11 @@ LLVoiceEffectInterface* LLVoiceClient::getVoiceEffectInterface() const
class LLViewerRequiredVoiceVersion : public LLHTTPNode
{
static BOOL sAlertedUser;
virtual void post(
void post(
LLHTTPNode::ResponsePtr response,
const LLSD& context,
const LLSD& input) const
const LLSD& input) const override
{
//You received this messsage (most likely on region cross or
//teleport)
@@ -870,10 +891,10 @@ class LLViewerRequiredVoiceVersion : public LLHTTPNode
class LLViewerParcelVoiceInfo : public LLHTTPNode
{
virtual void post(
void post(
LLHTTPNode::ResponsePtr response,
const LLSD& context,
const LLSD& input) const
const LLSD& input) const override
{
//the parcel you are in has changed something about its
//voice information