Index: webrtc/p2p/base/p2ptransportchannel.h |
diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h |
index 3927b17659b0d226a029d5717b23868274641003..1273764e1eefbd3771d1fa6871e7eecda8b86e70 100644 |
--- a/webrtc/p2p/base/p2ptransportchannel.h |
+++ b/webrtc/p2p/base/p2ptransportchannel.h |
@@ -21,6 +21,7 @@ |
#define WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
#include <map> |
+#include <set> |
#include <string> |
#include <vector> |
#include "webrtc/p2p/base/candidate.h" |
@@ -35,6 +36,7 @@ |
namespace cricket { |
extern const uint32_t WEAK_PING_DELAY; |
+extern const uint32_t MAX_CURRENT_STRONG_DELAY; |
struct IceParameters { |
std::string ufrag; |
@@ -91,6 +93,7 @@ class P2PTransportChannel : public TransportChannelImpl, |
// Sets the receiving timeout and gather_continually. |
// This also sets the check_receiving_delay proportionally. |
void SetIceConfig(const IceConfig& config) override; |
+ IceConfig GetIceConfig() const; |
// From TransportChannel: |
int SendPacket(const char* data, |
@@ -184,6 +187,45 @@ class P2PTransportChannel : public TransportChannelImpl, |
} |
private: |
+ // This class maintains the std::vector interface to allow enumeration and |
+ // wraps the logic of determining the next pingable connection. Connections[0] |
+ // is always the candidate of the best connection after sorted. |
+ class Connections : public std::vector<Connection*> { |
pthatcher1
2016/01/27 19:59:58
This seems a little crazy.
guoweis_webrtc
2016/02/29 18:03:00
Removed the class.
|
+ public: |
+ typedef std::vector<Connection*> Base; |
+ Connections(P2PTransportChannel* channel); |
+ void enable_most_likely_first(bool enable); |
+ bool most_likely_first() const { return ping_most_likely_first_; } |
+ iterator erase(iterator pos); |
+ void push_back(Connection*& connection); |
+ Connection* FindNextPingableConnection(uint32_t now); |
+ void MarkConnectionPinged(Connection* connection); |
+ |
+ private: |
+ // Disallow any modifier functions. |
+ using Base::erase; |
+ using Base::insert; |
+ using Base::emplace; |
+ using Base::emplace_back; |
+ using Base::pop_back; |
+ using Base::push_back; |
+ using Base::clear; |
+ using Base::resize; |
+ using Base::swap; |
+ |
+ // Between |conn1| and |conn2|, this function returns the one which should |
+ // be pinged first. |
+ Connection* Compare(Connection* conn1, Connection* conn2); |
+ |
+ bool IsTurnTurn(Connection* conn); |
+ |
+ P2PTransportChannel* channel_ = nullptr; |
+ bool ping_most_likely_first_ = false; |
+ |
+ std::set<Connection*> pinged_connections_; |
+ std::set<Connection*> unpinged_connections_; |
+ }; |
+ |
rtc::Thread* thread() { return worker_thread_; } |
bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } |
@@ -271,7 +313,7 @@ class P2PTransportChannel : public TransportChannelImpl, |
int error_; |
std::vector<PortAllocatorSession*> allocator_sessions_; |
std::vector<PortInterface *> ports_; |
- std::vector<Connection *> connections_; |
+ Connections connections_; |
Connection* best_connection_; |
// Connection selected by the controlling agent. This should be used only |
// at controlled side when protocol type is RFC5245. |