summaryrefslogtreecommitdiff
path: root/indra/newview/llvoicewebrtc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoicewebrtc.cpp')
-rw-r--r--indra/newview/llvoicewebrtc.cpp75
1 files changed, 46 insertions, 29 deletions
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp
index 22b53c0b85..b2e5de5371 100644
--- a/indra/newview/llvoicewebrtc.cpp
+++ b/indra/newview/llvoicewebrtc.cpp
@@ -87,6 +87,8 @@ namespace {
const F32 SPEAKING_AUDIO_LEVEL = 0.30;
+ const uint32_t PEER_GAIN_CONVERSION_FACTOR = 220;
+
static const std::string REPORTED_VOICE_SERVER_TYPE = "Secondlife WebRTC Gateway";
// Don't send positional updates more frequently than this:
@@ -256,6 +258,8 @@ void LLWebRTCVoiceClient::cleanupSingleton()
}
cleanUp();
sessionState::clearSessions();
+
+ mStatusObservers.clear();
}
//---------------------------------------------------
@@ -401,8 +405,9 @@ void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESt
LL_DEBUGS("Voice") << "( " << LLVoiceClientStatusObserver::status2string(status) << " )"
<< " mSession=" << mSession << LL_ENDL;
+ bool in_spatial_channel = inSpatialChannel();
LL_DEBUGS("Voice") << " " << LLVoiceClientStatusObserver::status2string(status) << ", session channelInfo "
- << getAudioSessionChannelInfo() << ", proximal is " << inSpatialChannel() << LL_ENDL;
+ << getAudioSessionChannelInfo() << ", proximal is " << in_spatial_channel << LL_ENDL;
mIsProcessingChannels = status == LLVoiceClientStatusObserver::STATUS_JOINED;
@@ -410,7 +415,7 @@ void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESt
for (status_observer_set_t::iterator it = mStatusObservers.begin(); it != mStatusObservers.end();)
{
LLVoiceClientStatusObserver *observer = *it;
- observer->onChange(status, channelInfo, inSpatialChannel());
+ observer->onChange(status, channelInfo, in_spatial_channel);
// In case onError() deleted an entry.
it = mStatusObservers.upper_bound(observer);
}
@@ -420,7 +425,7 @@ void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESt
status != LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL &&
status != LLVoiceClientStatusObserver::STATUS_VOICE_DISABLED)
{
- bool voice_status = LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking();
+ bool voice_status = LLVoiceClient::getInstance()->voiceEnabled() && mIsProcessingChannels;
gAgent.setVoiceConnected(voice_status);
@@ -1335,7 +1340,10 @@ bool LLWebRTCVoiceClient::startAdHocSession(const LLSD& channelInfo, bool notify
bool LLWebRTCVoiceClient::isVoiceWorking() const
{
- return mIsProcessingChannels;
+ // webrtc is working if the coroutine is active in the case of
+ // webrtc. WebRTC doesn't need to connect to a secondary process
+ // or a login server to become active.
+ return mIsCoroutineActive;
}
// Returns true if calling back the session URI after the session has closed is possible.
@@ -2012,7 +2020,10 @@ bool LLWebRTCVoiceClient::estateSessionState::processConnectionStates()
// shut down connections to neighbors that are too far away.
spatialConnection.get()->shutDown();
}
- neighbor_ids.erase(regionID);
+ if (!spatialConnection.get()->isShuttingDown())
+ {
+ neighbor_ids.erase(regionID);
+ }
}
// add new connections for new neighbors
@@ -2437,7 +2448,7 @@ void LLVoiceWebRTCConnection::setSpeakerVolume(F32 volume)
void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume)
{
- boost::json::object root = {{"ug", {id.asString(), (uint32_t) (volume * 200)}}};
+ boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } };
std::string json_data = boost::json::serialize(root);
if (mWebRTCDataInterface)
{
@@ -2447,7 +2458,7 @@ void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume)
void LLVoiceWebRTCConnection::setUserMute(const LLUUID& id, bool mute)
{
- boost::json::object root = {{"m", {id.asString(), mute}}};
+ boost::json::object root = { { "m", { { id.asString(), mute } } } };
std::string json_data = boost::json::serialize(root);
if (mWebRTCDataInterface)
{
@@ -2512,8 +2523,6 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
httpOpts->setWantHeaders(true);
- connection->mOutstandingRequests++;
-
// tell the server to shut down the connection as a courtesy.
// shutdownConnection will drop the WebRTC connection which will
// also shut things down.
@@ -2544,6 +2553,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection()
// try again.
setVoiceConnectionState(VOICE_STATE_REQUEST_CONNECTION);
+ mOutstandingRequests--;
return;
}
@@ -2551,6 +2561,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection()
if (url.empty())
{
setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
+ mOutstandingRequests--;
return;
}
@@ -2575,7 +2586,6 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection()
LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
httpOpts->setWantHeaders(true);
- mOutstandingRequests++;
LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts);
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
@@ -2663,7 +2673,10 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE;
- processIceUpdates();
+ if (!mShutDown)
+ {
+ processIceUpdates();
+ }
switch (getVoiceConnectionState())
{
@@ -2707,6 +2720,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
// a given voice channel. On completion, we'll move on to the
// VOICE_STATE_SESSION_ESTABLISHED via a callback on a webrtc thread.
setVoiceConnectionState(VOICE_STATE_CONNECTION_WAIT);
+ mOutstandingRequests++;
LLCoros::getInstance()->launch("LLVoiceWebRTCConnection::requestVoiceConnectionCoro",
boost::bind(&LLVoiceWebRTCConnection::requestVoiceConnectionCoro, this->shared_from_this()));
break;
@@ -2757,24 +2771,25 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
case VOICE_STATE_SESSION_UP:
{
mRetryWaitPeriod = 0;
- mRetryWaitSecs = (F32)((F32) rand() / (RAND_MAX)) + 0.5f;
- LLUUID agentRegionID;
- if (isSpatial() && gAgent.getRegion())
- {
-
- bool primary = (mRegionID == gAgent.getRegion()->getRegionID());
- if (primary != mPrimary)
- {
- mPrimary = primary;
- sendJoin();
- }
- }
+ mRetryWaitSecs = (F32)((F32)rand() / (RAND_MAX)) + 0.5f;
// we'll stay here as long as the session remains up.
if (mShutDown)
{
setVoiceConnectionState(VOICE_STATE_DISCONNECT);
}
+ else
+ {
+ if (isSpatial() && gAgent.getRegion())
+ {
+ bool primary = (mRegionID == gAgent.getRegion()->getRegionID());
+ if (primary != mPrimary)
+ {
+ mPrimary = primary;
+ sendJoin();
+ }
+ }
+ }
break;
}
@@ -2799,6 +2814,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
case VOICE_STATE_DISCONNECT:
if (!LLWebRTCVoiceClient::isShuttingDown())
{
+ mOutstandingRequests++;
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_EXIT);
LLCoros::instance().launch("LLVoiceWebRTCConnection::breakVoiceConnectionCoro",
boost::bind(&LLVoiceWebRTCConnection::breakVoiceConnectionCoro, this->shared_from_this()));
@@ -2807,7 +2823,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
{
// llwebrtc::terminate() is already shuting down the connection.
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE);
- mOutstandingRequests++;
}
break;
@@ -2976,7 +2991,9 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
// we got a 'power' update.
if (participant_obj.contains("p") && participant_obj["p"].is_number())
{
- participant->mLevel = (F32)participant_obj["p"].as_int64();
+ // server sends up power as an integer which is level * 128 to save
+ // character count.
+ participant->mLevel = (F32)participant_obj["p"].as_int64()/128.0f;
}
if (participant_obj.contains("v") && participant_obj["v"].is_bool())
@@ -2984,10 +3001,9 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
participant->mIsSpeaking = participant_obj["v"].as_bool();
}
- if (participant_obj.contains("v") && participant_obj["m"].is_bool())
+ if (participant_obj.contains("m") && participant_obj["m"].is_bool())
{
participant->mIsModeratorMuted = participant_obj["m"].as_bool();
- ;
}
}
}
@@ -3051,7 +3067,6 @@ void LLVoiceWebRTCConnection::sendJoin()
boost::json::object root;
boost::json::object join_obj;
- LLUUID regionID = gAgent.getRegion()->getRegionID();
if (mPrimary)
{
join_obj["p"] = true;
@@ -3134,6 +3149,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection()
LL_DEBUGS("Voice") << "no capabilities for voice provisioning; retrying " << LL_ENDL;
// try again.
setVoiceConnectionState(VOICE_STATE_REQUEST_CONNECTION);
+ mOutstandingRequests--;
return;
}
@@ -3141,6 +3157,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection()
if (url.empty())
{
setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
+ mOutstandingRequests--;
return;
}
@@ -3164,7 +3181,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection()
LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
httpOpts->setWantHeaders(true);
- mOutstandingRequests++;
+
LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts);
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];