quicker turnaround on re-establishing voice when server goes down.
parent
72d66a9a42
commit
85f987128b
|
|
@ -497,7 +497,7 @@ bool LLWebRTCImpl::initializeConnection()
|
|||
|
||||
void LLWebRTCImpl::shutdownConnection()
|
||||
{
|
||||
mSignalingThread->PostTask(
|
||||
mSignalingThread->BlockingCall(
|
||||
[this]()
|
||||
{
|
||||
if (mPeerConnection)
|
||||
|
|
@ -507,24 +507,21 @@ void LLWebRTCImpl::shutdownConnection()
|
|||
}
|
||||
mPeerConnectionFactory = nullptr;
|
||||
});
|
||||
mWorkerThread->PostTask(
|
||||
mWorkerThread->BlockingCall(
|
||||
[this]()
|
||||
{
|
||||
if (mTuningDeviceModule)
|
||||
{
|
||||
mTuningDeviceModule->StopRecording();
|
||||
mTuningDeviceModule->Terminate();
|
||||
}
|
||||
if (mPeerDeviceModule)
|
||||
{
|
||||
mPeerDeviceModule->StopRecording();
|
||||
mPeerDeviceModule->Terminate();
|
||||
}
|
||||
mTuningDeviceModule = nullptr;
|
||||
mPeerDeviceModule = nullptr;
|
||||
mTaskQueueFactory = nullptr;
|
||||
if (mPeerAudioDeviceObserver)
|
||||
{
|
||||
mPeerAudioDeviceObserver = nullptr;
|
||||
}
|
||||
});
|
||||
mNetworkThread->PostTask(
|
||||
mNetworkThread->BlockingCall(
|
||||
[this]()
|
||||
{
|
||||
if (mDataChannel)
|
||||
|
|
@ -694,6 +691,7 @@ static std::string iceCandidateToTrickleString(const webrtc::IceCandidateInterfa
|
|||
std::to_string(candidate->candidate().priority()) << " " <<
|
||||
candidate->candidate().address().ipaddr().ToString() << " " <<
|
||||
candidate->candidate().address().PortAsString() << " typ ";
|
||||
|
||||
if (candidate->candidate().type() == cricket::LOCAL_PORT_TYPE)
|
||||
{
|
||||
candidate_stream << "host";
|
||||
|
|
@ -716,6 +714,9 @@ static std::string iceCandidateToTrickleString(const webrtc::IceCandidateInterfa
|
|||
"raddr " << candidate->candidate().related_address().ipaddr().ToString() << " " <<
|
||||
"rport " << candidate->candidate().related_address().PortAsString();
|
||||
}
|
||||
else {
|
||||
RTC_LOG(LS_ERROR) << __FUNCTION__ << " Unknown candidate type " << candidate->candidate().type();
|
||||
}
|
||||
if (candidate->candidate().protocol() == "tcp")
|
||||
{
|
||||
candidate_stream << " tcptype " << candidate->candidate().tcptype();
|
||||
|
|
@ -827,8 +828,10 @@ void LLWebRTCImpl::OnSetRemoteDescriptionComplete(webrtc::RTCError error)
|
|||
ice_candidate.sdp_mid = candidate->sdp_mid();
|
||||
observer->OnIceCandidate(ice_candidate);
|
||||
}
|
||||
mCachedIceCandidates.clear();
|
||||
}
|
||||
mCachedIceCandidates.clear();
|
||||
OnIceGatheringChange(mPeerConnection->ice_gathering_state());
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -616,6 +616,10 @@ void LLWebRTCVoiceClient::voiceControlStateMachine()
|
|||
}
|
||||
else
|
||||
{
|
||||
LLMutexLock lock(&mVoiceStateMutex);
|
||||
|
||||
mTrickling = false;
|
||||
mIceCompleted = false;
|
||||
setVoiceControlStateUnless(VOICE_STATE_START_SESSION, VOICE_STATE_SESSION_RETRY);
|
||||
}
|
||||
break;
|
||||
|
|
@ -673,7 +677,7 @@ void LLWebRTCVoiceClient::voiceControlStateMachine()
|
|||
{
|
||||
// We failed to connect, give it a bit time before retrying.
|
||||
retry++;
|
||||
F32 full_delay = llmin(5.f * (F32) retry, 60.f);
|
||||
F32 full_delay = llmin(2.f * (F32) retry, 10.f);
|
||||
F32 current_delay = 0.f;
|
||||
LL_INFOS("Voice") << "Voice failed to establish session after " << retry << " tries. Will attempt to reconnect in "
|
||||
<< full_delay << " seconds" << LL_ENDL;
|
||||
|
|
@ -686,11 +690,12 @@ void LLWebRTCVoiceClient::voiceControlStateMachine()
|
|||
llcoro::suspendUntilTimeout(1.f);
|
||||
}
|
||||
}
|
||||
setVoiceControlStateUnless(VOICE_STATE_WAIT_FOR_EXIT);
|
||||
setVoiceControlStateUnless(VOICE_STATE_DISCONNECT);
|
||||
break;
|
||||
|
||||
case VOICE_STATE_SESSION_ESTABLISHED:
|
||||
{
|
||||
retry = 0;
|
||||
if (mTuningMode)
|
||||
{
|
||||
performMicTuning();
|
||||
|
|
@ -2388,11 +2393,20 @@ void LLWebRTCVoiceClient::OnIceGatheringState(llwebrtc::LLWebRTCSignalingObserve
|
|||
{
|
||||
LL_INFOS("Voice") << "Ice Gathering voice account. " << state << LL_ENDL;
|
||||
|
||||
if (state == llwebrtc::LLWebRTCSignalingObserver::IceGatheringState::ICE_GATHERING_COMPLETE)
|
||||
{
|
||||
LLMutexLock lock(&mVoiceStateMutex);
|
||||
mIceCompleted = true;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case llwebrtc::LLWebRTCSignalingObserver::IceGatheringState::ICE_GATHERING_COMPLETE:
|
||||
{
|
||||
LLMutexLock lock(&mVoiceStateMutex);
|
||||
mIceCompleted = true;
|
||||
break;
|
||||
}
|
||||
case llwebrtc::LLWebRTCSignalingObserver::IceGatheringState::ICE_GATHERING_NEW:
|
||||
{
|
||||
LLMutexLock lock(&mVoiceStateMutex);
|
||||
mIceCompleted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLWebRTCVoiceClient::OnIceCandidate(const llwebrtc::LLWebRTCIceCandidate &candidate)
|
||||
|
|
@ -2425,53 +2439,55 @@ void LLWebRTCVoiceClient::processIceUpdates()
|
|||
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
|
||||
LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
|
||||
|
||||
bool iceCompleted = false;
|
||||
LLSD body;
|
||||
{
|
||||
LLMutexLock lock(&mVoiceStateMutex);
|
||||
|
||||
if (mIceCandidates.size())
|
||||
if (!mTrickling)
|
||||
{
|
||||
LLSD candidates = LLSD::emptyArray();
|
||||
body["candidates"] = LLSD::emptyArray();
|
||||
for (auto &ice_candidate : mIceCandidates)
|
||||
if (mIceCandidates.size())
|
||||
{
|
||||
LLSD candidates = LLSD::emptyArray();
|
||||
body["candidates"] = LLSD::emptyArray();
|
||||
for (auto &ice_candidate : mIceCandidates)
|
||||
{
|
||||
LLSD body_candidate;
|
||||
body_candidate["sdpMid"] = ice_candidate.sdp_mid;
|
||||
body_candidate["sdpMLineIndex"] = ice_candidate.mline_index;
|
||||
body_candidate["candidate"] = ice_candidate.candidate;
|
||||
candidates.append(body_candidate);
|
||||
}
|
||||
body["candidates"] = candidates;
|
||||
mIceCandidates.clear();
|
||||
}
|
||||
else if (mIceCompleted)
|
||||
{
|
||||
LLSD body_candidate;
|
||||
body_candidate["sdpMid"] = ice_candidate.sdp_mid;
|
||||
body_candidate["sdpMLineIndex"] = ice_candidate.mline_index;
|
||||
body_candidate["candidate"] = ice_candidate.candidate;
|
||||
candidates.append(body_candidate);
|
||||
body_candidate["completed"] = true;
|
||||
body["candidate"] = body_candidate;
|
||||
iceCompleted = mIceCompleted;
|
||||
mIceCompleted = false;
|
||||
}
|
||||
body["candidates"] = candidates;
|
||||
mIceCandidates.clear();
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(
|
||||
url,
|
||||
LLCore::HttpRequest::DEFAULT_POLICY_ID,
|
||||
body,
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateComplete, this, iceCompleted, _1),
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateError, this, 3, url, body, iceCompleted, _1));
|
||||
mTrickling = true;
|
||||
}
|
||||
else if (mIceCompleted)
|
||||
{
|
||||
LLSD body_candidate;
|
||||
body_candidate["completed"] = true;
|
||||
body["candidate"] = body_candidate;
|
||||
mIceCompleted = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url,
|
||||
LLCore::HttpRequest::DEFAULT_POLICY_ID,
|
||||
body,
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateComplete, this, _1),
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateError, this, 3, url, body, _1));
|
||||
}
|
||||
|
||||
void LLWebRTCVoiceClient::onIceUpdateComplete(const LLSD& result)
|
||||
{
|
||||
if (sShuttingDown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void LLWebRTCVoiceClient::onIceUpdateError(int retries, std::string url, LLSD body, const LLSD& result)
|
||||
void LLWebRTCVoiceClient::onIceUpdateComplete(bool ice_completed, const LLSD& result)
|
||||
{ mTrickling = false; }
|
||||
|
||||
void LLWebRTCVoiceClient::onIceUpdateError(int retries, std::string url, LLSD body, bool ice_completed, const LLSD& result)
|
||||
{
|
||||
if (sShuttingDown)
|
||||
{
|
||||
|
|
@ -2482,16 +2498,18 @@ void LLWebRTCVoiceClient::onIceUpdateError(int retries, std::string url, LLSD bo
|
|||
|
||||
if (retries >= 0)
|
||||
{
|
||||
LL_WARNS("Voice") << "Unable to complete ice trickling voice account, retrying." << LL_ENDL;
|
||||
LL_WARNS("Voice") << "Unable to complete ice trickling voice account, retrying. " << result << LL_ENDL;
|
||||
LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url,
|
||||
LLCore::HttpRequest::DEFAULT_POLICY_ID,
|
||||
body,
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateComplete, this, _1),
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateError, this, retries - 1, url, body, _1));
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateComplete, this, ice_completed, _1),
|
||||
boost::bind(&LLWebRTCVoiceClient::onIceUpdateError, this, retries - 1, url, body, ice_completed, _1));
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("Voice") << "Unable to complete ice trickling voice account, retrying." << LL_ENDL;
|
||||
LL_WARNS("Voice") << "Unable to complete ice trickling voice account, restarting connection. " << result << LL_ENDL;
|
||||
setVoiceControlStateUnless(VOICE_STATE_SESSION_RETRY);
|
||||
mTrickling = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -275,8 +275,8 @@ public:
|
|||
//@}
|
||||
|
||||
void processIceUpdates();
|
||||
void onIceUpdateComplete(const LLSD& result);
|
||||
void onIceUpdateError(int retries, std::string url, LLSD body, const LLSD& result);
|
||||
void onIceUpdateComplete(bool ice_completed, const LLSD& result);
|
||||
void onIceUpdateError(int retries, std::string url, LLSD body, bool ice_completed, const LLSD& result);
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
|
|
@ -786,6 +786,7 @@ private:
|
|||
LLVoiceDeviceList mRenderDevices;
|
||||
std::vector<llwebrtc::LLWebRTCIceCandidate> mIceCandidates;
|
||||
bool mIceCompleted;
|
||||
bool mTrickling;
|
||||
|
||||
uint32_t mAudioLevel;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue