Index: webrtc/p2p/base/p2ptransportchannel.h |
diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h |
index ada3ecfb8bb2deeb6bc5d9120eb1647d7cd1a1da..7d79704690038c30416cc873e5292d00edb8a7df 100644 |
--- a/webrtc/p2p/base/p2ptransportchannel.h |
+++ b/webrtc/p2p/base/p2ptransportchannel.h |
@@ -40,6 +40,12 @@ namespace cricket { |
extern const int WEAK_PING_INTERVAL; |
static const int MIN_PINGS_AT_WEAK_PING_INTERVAL = 3; |
+// When the selected connection is suddenly deleted and no other connection |
+// is available, we will try to recover the ICE connectivity via continual |
+// gathering on the local client. If no writable connection is established |
+// after this amount of time, will declare the transport channel to be |
+// unwritable. |
+static const int MAX_RECOVERING_TIME = 5000; // 5 seconds. |
struct IceParameters { |
std::string ufrag; |
@@ -197,10 +203,15 @@ class P2PTransportChannel : public TransportChannelImpl, |
const std::vector<RemoteCandidate>& remote_candidates() const { |
return remote_candidates_; |
} |
+ // For testing. |
+ void set_check_restore_backup_connection_interval(int interval); |
Taylor Brandstetter
2016/06/06 18:18:37
Can you add a TODO to remove this method and use t
honghaiz3
2016/06/07 16:42:06
Done.
|
private: |
rtc::Thread* thread() { return worker_thread_; } |
bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } |
+ // Start regathering on the given list of networks. If |networks| is nullptr, |
+ // regathering on all active networks. |
Taylor Brandstetter
2016/06/06 18:18:37
"regathering" => "start regathering"
honghaiz3
2016/06/07 16:42:06
Done.
|
+ void StartRegathering(std::vector<rtc::Network*>* networks); |
// A transport channel is weak if the current best connection is either |
// not receiving or not writable, or if there is no best connection at all. |
@@ -257,6 +268,7 @@ class P2PTransportChannel : public TransportChannelImpl, |
void OnMessage(rtc::Message* pmsg) override; |
void OnSort(); |
void OnCheckAndPing(); |
+ void OnCheckAndRestoreBackupConnection(); |
void PruneConnections(); |
Connection* best_nominated_connection() const; |
@@ -292,6 +304,11 @@ class P2PTransportChannel : public TransportChannelImpl, |
: static_cast<uint32_t>(remote_ice_parameters_.size() - 1); |
} |
+ bool IsRecoveringConnectivity() const { |
+ return recovering_start_time_ > 0 && |
+ rtc::TimeMillis() - recovering_start_time_ <= MAX_RECOVERING_TIME; |
+ } |
+ |
PortAllocator* allocator_; |
rtc::Thread* worker_thread_; |
bool incoming_only_; |
@@ -327,11 +344,14 @@ class P2PTransportChannel : public TransportChannelImpl, |
IceGatheringState gathering_state_; |
int check_receiving_interval_; |
+ int check_restore_backup_connection_interval_; |
int64_t last_ping_sent_ms_ = 0; |
int weak_ping_interval_ = WEAK_PING_INTERVAL; |
TransportChannelState state_ = TransportChannelState::STATE_INIT; |
IceConfig config_; |
int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. |
+ int64_t recovering_start_time_ = 0; |
+ std::vector<Candidate> candidates_removed_; |
RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
}; |