Skip to content

Commit

Permalink
connect condition
Browse files Browse the repository at this point in the history
  • Loading branch information
olofkallander committed Nov 9, 2023
1 parent 71b0e92 commit 5ab6d99
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 8 additions & 8 deletions test/integration/emulator/SfuClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,20 +772,20 @@ class SfuClient : public transport::DataReceiver
return false;
}

bool connected = true;
if (_bundleTransport)
if (_bundleTransport && !_bundleTransport->isConnected())
{
connected &= _bundleTransport->isConnected();
return false;
}
if (_audioTransport)
if (_audioTransport && !_audioTransport->isConnected())
{
connected &= _audioTransport->isConnected();
return false;
}
if (_videoTransport)
if (_videoTransport && !_videoTransport->isConnected())
{
connected &= _videoTransport->isConnected();
return false;
}
return connected;

return true;
}

bool hasProcessedOffer() const { return ((_bundleTransport || _audioTransport) && _audioSource); }
Expand Down
4 changes: 2 additions & 2 deletions test/integration/emulator/SfuGroupCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class GroupCall

logger::PruneSpam logPrune(1, 10);
auto currTime = utils::Time::getAbsoluteTime();
while (currTime - start < timeout)
while (utils::Time::diffLT(start, currTime, timeout))
{
auto it = std::find_if_not(clients.begin(), clients.end(), [](auto& c) { return c->isConnected(); });

Expand Down Expand Up @@ -114,7 +114,7 @@ class GroupCall
}

auto currTime = utils::Time::getAbsoluteTime();
while (currTime - start < timeout)
while (utils::Time::diffLT(start, currTime, timeout))
{
if (client->isConnected())
{
Expand Down
10 changes: 8 additions & 2 deletions transport/TransportImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,8 @@ void TransportImpl::onIceCandidateChanged(ice::IceSession* session,
{
DtlsTimerJob::start(_jobQueue, *this, *_srtpClient, 1);
}

_isConnected = (_selectedRtp && _srtpClient->isConnected());
}
else if (_selectedRtp && endpoint != _selectedRtp)
{
Expand Down Expand Up @@ -2004,7 +2006,7 @@ void TransportImpl::onIceCompleted(ice::IceSession* session)
void TransportImpl::onIceStateChanged(ice::IceSession* session, const ice::IceSession::State state)
{
_iceState = state;
_isConnected = _selectedRtp && _srtpClient->isConnected();
_isConnected = (_selectedRtp && _srtpClient->isConnected());

switch (state)
{
Expand Down Expand Up @@ -2114,7 +2116,10 @@ void TransportImpl::onSrtpStateChange(SrtpClient*, const SrtpClient::State state
_dtlsState = state;
_isConnected = (_selectedRtp && _srtpClient->isConnected());

logger::info("SRTP %s", getLoggableId().c_str(), api::utils::toString(state));
logger::info("SRTP %s, transport connected%u",
getLoggableId().c_str(),
api::utils::toString(state),
_isConnected.load());
if (state == SrtpClient::State::CONNECTED && isConnected())
{
onTransportConnected();
Expand Down Expand Up @@ -2456,4 +2461,5 @@ void TransportImpl::asyncSetRemoteSdesKey(const srtp::AesKey& key)
{
_jobQueue.post(_jobCounter, [this, key]() { _srtpClient->setRemoteKey(key); });
}

} // namespace transport

0 comments on commit 5ab6d99

Please sign in to comment.