Check all BasicPortAllocatorSession methods are called on the network thread
Bug: None Change-Id: I12e56b2b95ba9822db660f7eac66fc8088988e4f Reviewed-on: https://webrtc-review.googlesource.com/c/103307 Reviewed-by: Qingsi Wang <qingsi@webrtc.org> Commit-Queue: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24939}
This commit is contained in:
@ -262,7 +262,7 @@ BasicPortAllocatorSession::BasicPortAllocatorSession(
|
|||||||
ice_pwd,
|
ice_pwd,
|
||||||
allocator->flags()),
|
allocator->flags()),
|
||||||
allocator_(allocator),
|
allocator_(allocator),
|
||||||
network_thread_(NULL),
|
network_thread_(rtc::Thread::Current()),
|
||||||
socket_factory_(allocator->socket_factory()),
|
socket_factory_(allocator->socket_factory()),
|
||||||
allocation_started_(false),
|
allocation_started_(false),
|
||||||
network_manager_started_(false),
|
network_manager_started_(false),
|
||||||
@ -274,6 +274,7 @@ BasicPortAllocatorSession::BasicPortAllocatorSession(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BasicPortAllocatorSession::~BasicPortAllocatorSession() {
|
BasicPortAllocatorSession::~BasicPortAllocatorSession() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
allocator_->network_manager()->StopUpdating();
|
allocator_->network_manager()->StopUpdating();
|
||||||
if (network_thread_ != NULL)
|
if (network_thread_ != NULL)
|
||||||
network_thread_->Clear(this);
|
network_thread_->Clear(this);
|
||||||
@ -296,10 +297,12 @@ BasicPortAllocatorSession::~BasicPortAllocatorSession() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BasicPortAllocator* BasicPortAllocatorSession::allocator() {
|
BasicPortAllocator* BasicPortAllocatorSession::allocator() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
return allocator_;
|
return allocator_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::SetCandidateFilter(uint32_t filter) {
|
void BasicPortAllocatorSession::SetCandidateFilter(uint32_t filter) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
if (filter == candidate_filter_) {
|
if (filter == candidate_filter_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -323,7 +326,7 @@ void BasicPortAllocatorSession::SetCandidateFilter(uint32_t filter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::StartGettingPorts() {
|
void BasicPortAllocatorSession::StartGettingPorts() {
|
||||||
network_thread_ = rtc::Thread::Current();
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
state_ = SessionState::GATHERING;
|
state_ = SessionState::GATHERING;
|
||||||
if (!socket_factory_) {
|
if (!socket_factory_) {
|
||||||
owned_socket_factory_.reset(
|
owned_socket_factory_.reset(
|
||||||
@ -338,7 +341,7 @@ void BasicPortAllocatorSession::StartGettingPorts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::StopGettingPorts() {
|
void BasicPortAllocatorSession::StopGettingPorts() {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
ClearGettingPorts();
|
ClearGettingPorts();
|
||||||
// Note: this must be called after ClearGettingPorts because both may set the
|
// Note: this must be called after ClearGettingPorts because both may set the
|
||||||
// session state and we should set the state to STOPPED.
|
// session state and we should set the state to STOPPED.
|
||||||
@ -346,7 +349,7 @@ void BasicPortAllocatorSession::StopGettingPorts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::ClearGettingPorts() {
|
void BasicPortAllocatorSession::ClearGettingPorts() {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
network_thread_->Clear(this, MSG_ALLOCATE);
|
network_thread_->Clear(this, MSG_ALLOCATE);
|
||||||
for (uint32_t i = 0; i < sequences_.size(); ++i) {
|
for (uint32_t i = 0; i < sequences_.size(); ++i) {
|
||||||
sequences_[i]->Stop();
|
sequences_[i]->Stop();
|
||||||
@ -356,18 +359,23 @@ void BasicPortAllocatorSession::ClearGettingPorts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BasicPortAllocatorSession::IsGettingPorts() {
|
bool BasicPortAllocatorSession::IsGettingPorts() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
return state_ == SessionState::GATHERING;
|
return state_ == SessionState::GATHERING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BasicPortAllocatorSession::IsCleared() const {
|
bool BasicPortAllocatorSession::IsCleared() const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
return state_ == SessionState::CLEARED;
|
return state_ == SessionState::CLEARED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BasicPortAllocatorSession::IsStopped() const {
|
bool BasicPortAllocatorSession::IsStopped() const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
return state_ == SessionState::STOPPED;
|
return state_ == SessionState::STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() {
|
std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
|
|
||||||
std::vector<rtc::Network*> networks = GetNetworks();
|
std::vector<rtc::Network*> networks = GetNetworks();
|
||||||
|
|
||||||
// A network interface may have both IPv4 and IPv6 networks. Only if
|
// A network interface may have both IPv4 and IPv6 networks. Only if
|
||||||
@ -394,6 +402,8 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
|
void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
|
|
||||||
// Find the list of networks that have no connection.
|
// Find the list of networks that have no connection.
|
||||||
std::vector<rtc::Network*> failed_networks = GetFailedNetworks();
|
std::vector<rtc::Network*> failed_networks = GetFailedNetworks();
|
||||||
if (failed_networks.empty()) {
|
if (failed_networks.empty()) {
|
||||||
@ -419,6 +429,8 @@ void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::RegatherOnAllNetworks() {
|
void BasicPortAllocatorSession::RegatherOnAllNetworks() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
|
|
||||||
std::vector<rtc::Network*> networks = GetNetworks();
|
std::vector<rtc::Network*> networks = GetNetworks();
|
||||||
if (networks.empty()) {
|
if (networks.empty()) {
|
||||||
return;
|
return;
|
||||||
@ -437,6 +449,7 @@ void BasicPortAllocatorSession::Regather(
|
|||||||
const std::vector<rtc::Network*>& networks,
|
const std::vector<rtc::Network*>& networks,
|
||||||
bool disable_equivalent_phases,
|
bool disable_equivalent_phases,
|
||||||
IceRegatheringReason reason) {
|
IceRegatheringReason reason) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
// Remove ports from being used locally and send signaling to remove
|
// Remove ports from being used locally and send signaling to remove
|
||||||
// the candidates on the remote side.
|
// the candidates on the remote side.
|
||||||
std::vector<PortData*> ports_to_prune = GetUnprunedPorts(networks);
|
std::vector<PortData*> ports_to_prune = GetUnprunedPorts(networks);
|
||||||
@ -454,6 +467,7 @@ void BasicPortAllocatorSession::Regather(
|
|||||||
|
|
||||||
void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts(
|
void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts(
|
||||||
const absl::optional<int>& stun_keepalive_interval) {
|
const absl::optional<int>& stun_keepalive_interval) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
auto ports = ReadyPorts();
|
auto ports = ReadyPorts();
|
||||||
for (PortInterface* port : ports) {
|
for (PortInterface* port : ports) {
|
||||||
// The port type and protocol can be used to identify different subclasses
|
// The port type and protocol can be used to identify different subclasses
|
||||||
@ -468,6 +482,7 @@ void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const {
|
std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
std::vector<PortInterface*> ret;
|
std::vector<PortInterface*> ret;
|
||||||
for (const PortData& data : ports_) {
|
for (const PortData& data : ports_) {
|
||||||
if (data.ready()) {
|
if (data.ready()) {
|
||||||
@ -478,6 +493,7 @@ std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const {
|
std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
std::vector<Candidate> candidates;
|
std::vector<Candidate> candidates;
|
||||||
for (const PortData& data : ports_) {
|
for (const PortData& data : ports_) {
|
||||||
if (!data.ready()) {
|
if (!data.ready()) {
|
||||||
@ -491,6 +507,7 @@ std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const {
|
|||||||
void BasicPortAllocatorSession::GetCandidatesFromPort(
|
void BasicPortAllocatorSession::GetCandidatesFromPort(
|
||||||
const PortData& data,
|
const PortData& data,
|
||||||
std::vector<Candidate>* candidates) const {
|
std::vector<Candidate>* candidates) const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
RTC_CHECK(candidates != nullptr);
|
RTC_CHECK(candidates != nullptr);
|
||||||
for (const Candidate& candidate : data.port()->Candidates()) {
|
for (const Candidate& candidate : data.port()->Candidates()) {
|
||||||
if (!CheckCandidateFilter(candidate)) {
|
if (!CheckCandidateFilter(candidate)) {
|
||||||
@ -503,6 +520,7 @@ void BasicPortAllocatorSession::GetCandidatesFromPort(
|
|||||||
|
|
||||||
Candidate BasicPortAllocatorSession::SanitizeCandidate(
|
Candidate BasicPortAllocatorSession::SanitizeCandidate(
|
||||||
const Candidate& c) const {
|
const Candidate& c) const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
Candidate copy = c;
|
Candidate copy = c;
|
||||||
// If the candidate has a generated hostname, we need to obfuscate its IP
|
// If the candidate has a generated hostname, we need to obfuscate its IP
|
||||||
// address when signaling this candidate.
|
// address when signaling this candidate.
|
||||||
@ -529,6 +547,7 @@ Candidate BasicPortAllocatorSession::SanitizeCandidate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BasicPortAllocatorSession::CandidatesAllocationDone() const {
|
bool BasicPortAllocatorSession::CandidatesAllocationDone() const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
// Done only if all required AllocationSequence objects
|
// Done only if all required AllocationSequence objects
|
||||||
// are created.
|
// are created.
|
||||||
if (!allocation_sequences_created_) {
|
if (!allocation_sequences_created_) {
|
||||||
@ -553,23 +572,18 @@ bool BasicPortAllocatorSession::CandidatesAllocationDone() const {
|
|||||||
void BasicPortAllocatorSession::OnMessage(rtc::Message* message) {
|
void BasicPortAllocatorSession::OnMessage(rtc::Message* message) {
|
||||||
switch (message->message_id) {
|
switch (message->message_id) {
|
||||||
case MSG_CONFIG_START:
|
case MSG_CONFIG_START:
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
|
||||||
GetPortConfigurations();
|
GetPortConfigurations();
|
||||||
break;
|
break;
|
||||||
case MSG_CONFIG_READY:
|
case MSG_CONFIG_READY:
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
|
||||||
OnConfigReady(static_cast<PortConfiguration*>(message->pdata));
|
OnConfigReady(static_cast<PortConfiguration*>(message->pdata));
|
||||||
break;
|
break;
|
||||||
case MSG_ALLOCATE:
|
case MSG_ALLOCATE:
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
|
||||||
OnAllocate();
|
OnAllocate();
|
||||||
break;
|
break;
|
||||||
case MSG_SEQUENCEOBJECTS_CREATED:
|
case MSG_SEQUENCEOBJECTS_CREATED:
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
|
||||||
OnAllocationSequenceObjectsCreated();
|
OnAllocationSequenceObjectsCreated();
|
||||||
break;
|
break;
|
||||||
case MSG_CONFIG_STOP:
|
case MSG_CONFIG_STOP:
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
|
||||||
OnConfigStop();
|
OnConfigStop();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -578,6 +592,7 @@ void BasicPortAllocatorSession::OnMessage(rtc::Message* message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::UpdateIceParametersInternal() {
|
void BasicPortAllocatorSession::UpdateIceParametersInternal() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
for (PortData& port : ports_) {
|
for (PortData& port : ports_) {
|
||||||
port.port()->set_content_name(content_name());
|
port.port()->set_content_name(content_name());
|
||||||
port.port()->SetIceParameters(component(), ice_ufrag(), ice_pwd());
|
port.port()->SetIceParameters(component(), ice_ufrag(), ice_pwd());
|
||||||
@ -585,6 +600,7 @@ void BasicPortAllocatorSession::UpdateIceParametersInternal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::GetPortConfigurations() {
|
void BasicPortAllocatorSession::GetPortConfigurations() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
PortConfiguration* config =
|
PortConfiguration* config =
|
||||||
new PortConfiguration(allocator_->stun_servers(), username(), password());
|
new PortConfiguration(allocator_->stun_servers(), username(), password());
|
||||||
|
|
||||||
@ -595,11 +611,13 @@ void BasicPortAllocatorSession::GetPortConfigurations() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) {
|
void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_READY, config);
|
network_thread_->Post(RTC_FROM_HERE, this, MSG_CONFIG_READY, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds a configuration to the list.
|
// Adds a configuration to the list.
|
||||||
void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) {
|
void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
if (config) {
|
if (config) {
|
||||||
configs_.push_back(config);
|
configs_.push_back(config);
|
||||||
}
|
}
|
||||||
@ -608,7 +626,7 @@ void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::OnConfigStop() {
|
void BasicPortAllocatorSession::OnConfigStop() {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
|
|
||||||
// If any of the allocated ports have not completed the candidates allocation,
|
// If any of the allocated ports have not completed the candidates allocation,
|
||||||
// mark those as error. Since session doesn't need any new candidates
|
// mark those as error. Since session doesn't need any new candidates
|
||||||
@ -639,11 +657,13 @@ void BasicPortAllocatorSession::OnConfigStop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::AllocatePorts() {
|
void BasicPortAllocatorSession::AllocatePorts() {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE);
|
network_thread_->Post(RTC_FROM_HERE, this, MSG_ALLOCATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::OnAllocate() {
|
void BasicPortAllocatorSession::OnAllocate() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
|
|
||||||
if (network_manager_started_ && !IsStopped()) {
|
if (network_manager_started_ && !IsStopped()) {
|
||||||
bool disable_equivalent_phases = true;
|
bool disable_equivalent_phases = true;
|
||||||
DoAllocate(disable_equivalent_phases);
|
DoAllocate(disable_equivalent_phases);
|
||||||
@ -653,6 +673,7 @@ void BasicPortAllocatorSession::OnAllocate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
std::vector<rtc::Network*> networks;
|
std::vector<rtc::Network*> networks;
|
||||||
rtc::NetworkManager* network_manager = allocator_->network_manager();
|
rtc::NetworkManager* network_manager = allocator_->network_manager();
|
||||||
RTC_DCHECK(network_manager != nullptr);
|
RTC_DCHECK(network_manager != nullptr);
|
||||||
@ -738,6 +759,7 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
|
|||||||
// For each network, see if we have a sequence that covers it already. If not,
|
// For each network, see if we have a sequence that covers it already. If not,
|
||||||
// create a new sequence to create the appropriate ports.
|
// create a new sequence to create the appropriate ports.
|
||||||
void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) {
|
void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
bool done_signal_needed = false;
|
bool done_signal_needed = false;
|
||||||
std::vector<rtc::Network*> networks = GetNetworks();
|
std::vector<rtc::Network*> networks = GetNetworks();
|
||||||
if (networks.empty()) {
|
if (networks.empty()) {
|
||||||
@ -801,6 +823,7 @@ void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::OnNetworksChanged() {
|
void BasicPortAllocatorSession::OnNetworksChanged() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
std::vector<rtc::Network*> networks = GetNetworks();
|
std::vector<rtc::Network*> networks = GetNetworks();
|
||||||
std::vector<rtc::Network*> failed_networks;
|
std::vector<rtc::Network*> failed_networks;
|
||||||
for (AllocationSequence* sequence : sequences_) {
|
for (AllocationSequence* sequence : sequences_) {
|
||||||
@ -839,6 +862,7 @@ void BasicPortAllocatorSession::DisableEquivalentPhases(
|
|||||||
rtc::Network* network,
|
rtc::Network* network,
|
||||||
PortConfiguration* config,
|
PortConfiguration* config,
|
||||||
uint32_t* flags) {
|
uint32_t* flags) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
for (uint32_t i = 0; i < sequences_.size() &&
|
for (uint32_t i = 0; i < sequences_.size() &&
|
||||||
(*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES;
|
(*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES;
|
||||||
++i) {
|
++i) {
|
||||||
@ -849,6 +873,7 @@ void BasicPortAllocatorSession::DisableEquivalentPhases(
|
|||||||
void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
|
void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
|
||||||
AllocationSequence* seq,
|
AllocationSequence* seq,
|
||||||
bool prepare_address) {
|
bool prepare_address) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
if (!port)
|
if (!port)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -878,6 +903,7 @@ void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {
|
void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
allocation_sequences_created_ = true;
|
allocation_sequences_created_ = true;
|
||||||
// Send candidate allocation complete signal if we have no sequences.
|
// Send candidate allocation complete signal if we have no sequences.
|
||||||
MaybeSignalCandidatesAllocationDone();
|
MaybeSignalCandidatesAllocationDone();
|
||||||
@ -885,7 +911,7 @@ void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {
|
|||||||
|
|
||||||
void BasicPortAllocatorSession::OnCandidateReady(Port* port,
|
void BasicPortAllocatorSession::OnCandidateReady(Port* port,
|
||||||
const Candidate& c) {
|
const Candidate& c) {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
PortData* data = FindPort(port);
|
PortData* data = FindPort(port);
|
||||||
RTC_DCHECK(data != NULL);
|
RTC_DCHECK(data != NULL);
|
||||||
RTC_LOG(LS_INFO) << port->ToString()
|
RTC_LOG(LS_INFO) << port->ToString()
|
||||||
@ -938,6 +964,7 @@ void BasicPortAllocatorSession::OnCandidateReady(Port* port,
|
|||||||
|
|
||||||
Port* BasicPortAllocatorSession::GetBestTurnPortForNetwork(
|
Port* BasicPortAllocatorSession::GetBestTurnPortForNetwork(
|
||||||
const std::string& network_name) const {
|
const std::string& network_name) const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
Port* best_turn_port = nullptr;
|
Port* best_turn_port = nullptr;
|
||||||
for (const PortData& data : ports_) {
|
for (const PortData& data : ports_) {
|
||||||
if (data.port()->Network()->name() == network_name &&
|
if (data.port()->Network()->name() == network_name &&
|
||||||
@ -950,6 +977,7 @@ Port* BasicPortAllocatorSession::GetBestTurnPortForNetwork(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) {
|
bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
// Note: We determine the same network based only on their network names. So
|
// Note: We determine the same network based only on their network names. So
|
||||||
// if an IPv4 address and an IPv6 address have the same network name, they
|
// if an IPv4 address and an IPv6 address have the same network name, they
|
||||||
// are considered the same network here.
|
// are considered the same network here.
|
||||||
@ -983,13 +1011,14 @@ bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::PruneAllPorts() {
|
void BasicPortAllocatorSession::PruneAllPorts() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
for (PortData& data : ports_) {
|
for (PortData& data : ports_) {
|
||||||
data.Prune();
|
data.Prune();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::OnPortComplete(Port* port) {
|
void BasicPortAllocatorSession::OnPortComplete(Port* port) {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
RTC_LOG(LS_INFO) << port->ToString()
|
RTC_LOG(LS_INFO) << port->ToString()
|
||||||
<< ": Port completed gathering candidates.";
|
<< ": Port completed gathering candidates.";
|
||||||
PortData* data = FindPort(port);
|
PortData* data = FindPort(port);
|
||||||
@ -1007,7 +1036,7 @@ void BasicPortAllocatorSession::OnPortComplete(Port* port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::OnPortError(Port* port) {
|
void BasicPortAllocatorSession::OnPortError(Port* port) {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
RTC_LOG(LS_INFO) << port->ToString()
|
RTC_LOG(LS_INFO) << port->ToString()
|
||||||
<< ": Port encountered error while gathering candidates.";
|
<< ": Port encountered error while gathering candidates.";
|
||||||
PortData* data = FindPort(port);
|
PortData* data = FindPort(port);
|
||||||
@ -1025,6 +1054,8 @@ void BasicPortAllocatorSession::OnPortError(Port* port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) const {
|
bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
|
|
||||||
uint32_t filter = candidate_filter_;
|
uint32_t filter = candidate_filter_;
|
||||||
|
|
||||||
// When binding to any address, before sending packets out, the getsockname
|
// When binding to any address, before sending packets out, the getsockname
|
||||||
@ -1057,6 +1088,8 @@ bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) const {
|
|||||||
|
|
||||||
bool BasicPortAllocatorSession::CandidatePairable(const Candidate& c,
|
bool BasicPortAllocatorSession::CandidatePairable(const Candidate& c,
|
||||||
const Port* port) const {
|
const Port* port) const {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
|
|
||||||
bool candidate_signalable = CheckCandidateFilter(c);
|
bool candidate_signalable = CheckCandidateFilter(c);
|
||||||
|
|
||||||
// When device enumeration is disabled (to prevent non-default IP addresses
|
// When device enumeration is disabled (to prevent non-default IP addresses
|
||||||
@ -1077,11 +1110,13 @@ bool BasicPortAllocatorSession::CandidatePairable(const Candidate& c,
|
|||||||
|
|
||||||
void BasicPortAllocatorSession::OnPortAllocationComplete(
|
void BasicPortAllocatorSession::OnPortAllocationComplete(
|
||||||
AllocationSequence* seq) {
|
AllocationSequence* seq) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
// Send candidate allocation complete signal if all ports are done.
|
// Send candidate allocation complete signal if all ports are done.
|
||||||
MaybeSignalCandidatesAllocationDone();
|
MaybeSignalCandidatesAllocationDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
|
void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
if (CandidatesAllocationDone()) {
|
if (CandidatesAllocationDone()) {
|
||||||
if (pooled()) {
|
if (pooled()) {
|
||||||
RTC_LOG(LS_INFO) << "All candidates gathered for pooled session.";
|
RTC_LOG(LS_INFO) << "All candidates gathered for pooled session.";
|
||||||
@ -1094,7 +1129,7 @@ void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasicPortAllocatorSession::OnPortDestroyed(PortInterface* port) {
|
void BasicPortAllocatorSession::OnPortDestroyed(PortInterface* port) {
|
||||||
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
for (std::vector<PortData>::iterator iter = ports_.begin();
|
for (std::vector<PortData>::iterator iter = ports_.begin();
|
||||||
iter != ports_.end(); ++iter) {
|
iter != ports_.end(); ++iter) {
|
||||||
if (port == iter->port()) {
|
if (port == iter->port()) {
|
||||||
@ -1109,6 +1144,7 @@ void BasicPortAllocatorSession::OnPortDestroyed(PortInterface* port) {
|
|||||||
|
|
||||||
BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort(
|
BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort(
|
||||||
Port* port) {
|
Port* port) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
for (std::vector<PortData>::iterator it = ports_.begin(); it != ports_.end();
|
for (std::vector<PortData>::iterator it = ports_.begin(); it != ports_.end();
|
||||||
++it) {
|
++it) {
|
||||||
if (it->port() == port) {
|
if (it->port() == port) {
|
||||||
@ -1121,6 +1157,7 @@ BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort(
|
|||||||
std::vector<BasicPortAllocatorSession::PortData*>
|
std::vector<BasicPortAllocatorSession::PortData*>
|
||||||
BasicPortAllocatorSession::GetUnprunedPorts(
|
BasicPortAllocatorSession::GetUnprunedPorts(
|
||||||
const std::vector<rtc::Network*>& networks) {
|
const std::vector<rtc::Network*>& networks) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
std::vector<PortData*> unpruned_ports;
|
std::vector<PortData*> unpruned_ports;
|
||||||
for (PortData& port : ports_) {
|
for (PortData& port : ports_) {
|
||||||
if (!port.pruned() &&
|
if (!port.pruned() &&
|
||||||
@ -1134,6 +1171,7 @@ BasicPortAllocatorSession::GetUnprunedPorts(
|
|||||||
|
|
||||||
void BasicPortAllocatorSession::PrunePortsAndRemoveCandidates(
|
void BasicPortAllocatorSession::PrunePortsAndRemoveCandidates(
|
||||||
const std::vector<PortData*>& port_data_list) {
|
const std::vector<PortData*>& port_data_list) {
|
||||||
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
std::vector<PortInterface*> pruned_ports;
|
std::vector<PortInterface*> pruned_ports;
|
||||||
std::vector<Candidate> removed_candidates;
|
std::vector<Candidate> removed_candidates;
|
||||||
for (PortData* data : port_data_list) {
|
for (PortData* data : port_data_list) {
|
||||||
|
Reference in New Issue
Block a user