race between session established and data channel ready
parent
49a1b4038f
commit
90efc71ef9
|
|
@ -476,40 +476,22 @@ void LLWebRTCImpl::OnDevicesUpdated()
|
|||
|
||||
void LLWebRTCImpl::setTuningMode(bool enable)
|
||||
{
|
||||
mWorkerThread->BlockingCall(
|
||||
[this, enable]()
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
|
||||
mTuningDeviceModule->StartRecording();
|
||||
|
||||
if (mPeerDeviceModule)
|
||||
{
|
||||
mPeerDeviceModule->StopRecording();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mTuningDeviceModule->StartRecording();
|
||||
if (mPeerDeviceModule)
|
||||
{
|
||||
mPeerDeviceModule->StartRecording();
|
||||
}
|
||||
}
|
||||
});
|
||||
for (auto& connection : mPeerConnections)
|
||||
{
|
||||
if (enable)
|
||||
mSignalingThread->PostTask(
|
||||
[this, enable]
|
||||
{
|
||||
connection->enableSenderTracks(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
connection->resetMute();
|
||||
}
|
||||
connection->enableReceiverTracks(!enable);
|
||||
}
|
||||
for (auto &connection : mPeerConnections)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
connection->enableSenderTracks(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
connection->resetMute();
|
||||
}
|
||||
connection->enableReceiverTracks(!enable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
float LLWebRTCImpl::getTuningAudioLevel() { return -20 * log10f(mTuningAudioDeviceObserver->getMicrophoneEnergy()); }
|
||||
|
|
|
|||
|
|
@ -2843,9 +2843,23 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
|
|||
mWebRTCAudioInterface->setReceiveVolume(mSpeakerVolume);
|
||||
mWebRTCAudioInterface->setSendVolume(mMicGain);
|
||||
LLWebRTCVoiceClient::getInstance()->OnConnectionEstablished(mChannelID, mRegionID);
|
||||
setVoiceConnectionState(VOICE_STATE_SESSION_UP);
|
||||
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_DATA_CHANNEL);
|
||||
break;
|
||||
}
|
||||
case VOICE_STATE_WAIT_FOR_DATA_CHANNEL:
|
||||
{
|
||||
if (mShutDown)
|
||||
{
|
||||
setVoiceConnectionState(VOICE_STATE_DISCONNECT);
|
||||
break;
|
||||
}
|
||||
if (mWebRTCDataInterface)
|
||||
{
|
||||
sendJoin();
|
||||
setVoiceConnectionState(VOICE_STATE_SESSION_UP);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VOICE_STATE_SESSION_UP:
|
||||
{
|
||||
if (mShutDown)
|
||||
|
|
@ -3006,21 +3020,24 @@ void LLVoiceWebRTCConnection::OnDataChannelReady(llwebrtc::LLWebRTCDataInterface
|
|||
{
|
||||
mWebRTCDataInterface = data_interface;
|
||||
mWebRTCDataInterface->setDataObserver(this);
|
||||
|
||||
Json::FastWriter writer;
|
||||
Json::Value root = Json::objectValue;
|
||||
Json::Value join_obj = Json::objectValue;
|
||||
LLUUID regionID = gAgent.getRegion()->getRegionID();
|
||||
if (regionID == mRegionID)
|
||||
{
|
||||
join_obj["p"] = true;
|
||||
}
|
||||
root["j"] = join_obj;
|
||||
std::string json_data = writer.write(root);
|
||||
mWebRTCDataInterface->sendData(json_data, false);
|
||||
}
|
||||
}
|
||||
|
||||
void LLVoiceWebRTCConnection::sendJoin()
|
||||
{
|
||||
Json::FastWriter writer;
|
||||
Json::Value root = Json::objectValue;
|
||||
Json::Value join_obj = Json::objectValue;
|
||||
LLUUID regionID = gAgent.getRegion()->getRegionID();
|
||||
if (regionID == mRegionID)
|
||||
{
|
||||
join_obj["p"] = true;
|
||||
}
|
||||
root["j"] = join_obj;
|
||||
std::string json_data = writer.write(root);
|
||||
mWebRTCDataInterface->sendData(json_data, false);
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// WebRTC Spatial Connection
|
||||
|
||||
|
|
|
|||
|
|
@ -769,6 +769,7 @@ class LLVoiceWebRTCConnection :
|
|||
void OnDataChannelReady(llwebrtc::LLWebRTCDataInterface *data_interface) override;
|
||||
//@}
|
||||
|
||||
void sendJoin();
|
||||
void sendData(const std::string &data);
|
||||
|
||||
virtual void processIceUpdates();
|
||||
|
|
@ -806,13 +807,13 @@ class LLVoiceWebRTCConnection :
|
|||
VOICE_STATE_REQUEST_CONNECTION = 0x4,
|
||||
VOICE_STATE_CONNECTION_WAIT = 0x8,
|
||||
VOICE_STATE_SESSION_ESTABLISHED = 0x10,
|
||||
VOICE_STATE_SESSION_UP = 0x20,
|
||||
VOICE_STATE_SESSION_RETRY = 0x40,
|
||||
VOICE_STATE_DISCONNECT = 0x80,
|
||||
VOICE_STATE_WAIT_FOR_EXIT = 0x100,
|
||||
VOICE_STATE_SESSION_EXIT = 0x200,
|
||||
VOICE_STATE_SESSION_STOPPING = 0x3c0,
|
||||
VOICE_STATE_SESSION_WAITING = 0x10a
|
||||
VOICE_STATE_WAIT_FOR_DATA_CHANNEL = 0x20,
|
||||
VOICE_STATE_SESSION_UP = 0x40,
|
||||
VOICE_STATE_SESSION_RETRY = 0x80,
|
||||
VOICE_STATE_DISCONNECT = 0x100,
|
||||
VOICE_STATE_WAIT_FOR_EXIT = 0x200,
|
||||
VOICE_STATE_SESSION_EXIT = 0x400,
|
||||
VOICE_STATE_SESSION_STOPPING = 0x780
|
||||
} EVoiceConnectionState;
|
||||
|
||||
EVoiceConnectionState mVoiceConnectionState;
|
||||
|
|
|
|||
Loading…
Reference in New Issue