Index: webrtc/p2p/client/basicportallocator.h |
diff --git a/webrtc/p2p/client/basicportallocator.h b/webrtc/p2p/client/basicportallocator.h |
index 8ea66c431e76d560a6299c2831d77a1a83dfeb06..9cae6da668c5eb42b5c8bf6c3210d3e036cb368e 100644 |
--- a/webrtc/p2p/client/basicportallocator.h |
+++ b/webrtc/p2p/client/basicportallocator.h |
@@ -47,7 +47,9 @@ class BasicPortAllocator : public PortAllocator { |
int network_ignore_mask() const { return network_ignore_mask_; } |
- rtc::NetworkManager* network_manager() { return network_manager_; } |
+ rtc::NetworkManager* network_manager() const override { |
+ return network_manager_; |
+ } |
// If socket_factory() is set to NULL each PortAllocatorSession |
// creates its own socket factory. |
@@ -84,19 +86,36 @@ class BasicPortAllocatorSession : public PortAllocatorSession, |
const std::string& ice_pwd); |
~BasicPortAllocatorSession(); |
+ // TODO(honghaiz): When continual gathering is fully enabled, we don't need |
+ // the state STATE_STOPPED. A session can always start new allocation |
+ // sequences. |
+ enum State { |
+ STATE_RUNNING, // Current allocation sequence is running, can start new |
+ // allocation sequences. |
+ STATE_CLEARED, // Current allocation sequence is complete, can start new |
+ // allocation sequences. |
+ STATE_STOPPED // Current allocation sequence is complete, cannot start |
+ // new allocation sequences. |
+ }; |
+ |
virtual BasicPortAllocator* allocator() { return allocator_; } |
rtc::Thread* network_thread() { return network_thread_; } |
rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } |
void SetCandidateFilter(uint32_t filter) override; |
+ |
void StartGettingPorts() override; |
void StopGettingPorts() override; |
void ClearGettingPorts() override; |
- bool IsGettingPorts() override { return running_; } |
+ bool IsGettingPorts() override { return state_ == STATE_RUNNING; } |
+ bool CanGetPorts() override { return state_ != STATE_STOPPED; } |
+ |
// These will all be cricket::Ports. |
std::vector<PortInterface*> ReadyPorts() const override; |
std::vector<Candidate> ReadyCandidates() const override; |
+ std::vector<Candidate> ReadyCandidates(PortInterface* port) const override; |
bool CandidatesAllocationDone() const override; |
+ bool RegatherOnFailedNetworks() override; |
protected: |
void UpdateIceParametersInternal() override; |
@@ -170,7 +189,8 @@ class BasicPortAllocatorSession : public PortAllocatorSession, |
void MaybeSignalCandidatesAllocationDone(); |
void OnPortAllocationComplete(AllocationSequence* seq); |
PortData* FindPort(Port* port); |
- void GetNetworks(std::vector<rtc::Network*>* networks); |
+ std::vector<rtc::Network*> GetNetworks() const; |
+ std::vector<rtc::Network*> GetFailedNetworks() const; |
bool CheckCandidateFilter(const Candidate& c) const; |
bool CandidatePairable(const Candidate& c, const Port* port) const; |
@@ -184,7 +204,7 @@ class BasicPortAllocatorSession : public PortAllocatorSession, |
rtc::PacketSocketFactory* socket_factory_; |
bool allocation_started_; |
bool network_manager_started_; |
- bool running_; // set when StartGetAllPorts is called |
+ State state_ = STATE_RUNNING; |
bool allocation_sequences_created_; |
std::vector<PortConfiguration*> configs_; |
std::vector<AllocationSequence*> sequences_; |
@@ -255,11 +275,15 @@ class AllocationSequence : public rtc::MessageHandler, |
~AllocationSequence(); |
bool Init(); |
void Clear(); |
- void OnNetworkRemoved(); |
+ void OnNetworkInactivated(); |
State state() const { return state_; } |
const rtc::Network* network() const { return network_; } |
- bool network_removed() const { return network_removed_; } |
+ |
+ bool network_inactive() const { return network_inactive_; } |
+ void set_network_inactive(bool network_inactive) { |
+ network_inactive_ = network_inactive; |
+ } |
// Disables the phases for a new sequence that this one already covers for an |
// equivalent network setup. |
@@ -309,7 +333,7 @@ class AllocationSequence : public rtc::MessageHandler, |
void OnPortDestroyed(PortInterface* port); |
BasicPortAllocatorSession* session_; |
- bool network_removed_ = false; |
+ bool network_inactive_ = false; |
rtc::Network* network_; |
rtc::IPAddress ip_; |
PortConfiguration* config_; |