Skip to content

Commit

Permalink
cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Oct 19, 2023
1 parent 4220018 commit 7115b45
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
8 changes: 5 additions & 3 deletions worker/include/RTC/IceServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ namespace RTC
}
bool IsValidTuple(const RTC::TransportTuple* tuple) const;
void RemoveTuple(RTC::TransportTuple* tuple);
// This should be just called in 'connected' or completed' state
// and the given tuple must be an already valid tuple.
void ForceSelectedTuple(const RTC::TransportTuple* tuple);
/**
* This should be just called in 'connected' or completed' state and the
* given tuple must be an already valid tuple.
*/
void MayForceSelectedTuple(const RTC::TransportTuple* tuple);

private:
void HandleTuple(
Expand Down
19 changes: 13 additions & 6 deletions worker/src/RTC/IceServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,25 @@ namespace RTC
}
}

void IceServer::ForceSelectedTuple(const RTC::TransportTuple* tuple)
void IceServer::MayForceSelectedTuple(const RTC::TransportTuple* tuple)
{
MS_TRACE();

MS_ASSERT(
this->selectedTuple, "cannot force the selected tuple if there was not a selected tuple");
if (this->state != IceState::CONNECTED && this->state != IceState::COMPLETED)
{
MS_WARN_TAG(ice, "cannot force selected tuple if not in state 'connected' or 'completed'");

return;
}

auto* storedTuple = HasTuple(tuple);

MS_ASSERT(
storedTuple,
"cannot force the selected tuple if the given tuple was not already a valid tuple");
if (!storedTuple)
{
MS_WARN_TAG(ice, "cannot force selected tuple if the given tuple was not already a valid one");

return;
}

// Mark it as selected tuple.
SetSelectedTuple(storedTuple);
Expand Down
14 changes: 8 additions & 6 deletions worker/src/RTC/WebRtcTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,10 +1058,11 @@ namespace RTC
}

// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
// NOTE: Only do it if we already have a selected ICE candidate tuple.
if (this->iceServer->GetSelectedTuple())
if (
this->iceServer->GetState() == RTC::IceServer::IceState::CONNECTED ||
this->iceServer->GetState() == RTC::IceServer::IceState::COMPLETED)
{
this->iceServer->ForceSelectedTuple(tuple);
this->iceServer->MayForceSelectedTuple(tuple);
}

// Check that DTLS status is 'connecting' or 'connected'.
Expand Down Expand Up @@ -1146,10 +1147,11 @@ namespace RTC
}

// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
// NOTE: Only do it if we already have a selected ICE candidate tuple.
if (this->iceServer->GetSelectedTuple())
if (
this->iceServer->GetState() == RTC::IceServer::IceState::CONNECTED ||
this->iceServer->GetState() == RTC::IceServer::IceState::COMPLETED)
{
this->iceServer->ForceSelectedTuple(tuple);
this->iceServer->MayForceSelectedTuple(tuple);
}

// Pass the packet to the parent transport.
Expand Down

0 comments on commit 7115b45

Please sign in to comment.