| Index: webrtc/p2p/base/p2ptransportchannel.cc
|
| diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
|
| index 94eb01754d459111533fa7f9a7c71e9e5e3223d1..80cdcff732159f71595b101253a0403b1c1aae6b 100644
|
| --- a/webrtc/p2p/base/p2ptransportchannel.cc
|
| +++ b/webrtc/p2p/base/p2ptransportchannel.cc
|
| @@ -11,6 +11,7 @@
|
| #include "webrtc/p2p/base/p2ptransportchannel.h"
|
|
|
| #include <set>
|
| +#include <algorithm>
|
| #include "webrtc/p2p/base/common.h"
|
| #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE.
|
| #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE.
|
| @@ -180,25 +181,25 @@ namespace cricket {
|
| P2PTransportChannel::P2PTransportChannel(const std::string& content_name,
|
| int component,
|
| P2PTransport* transport,
|
| - PortAllocator *allocator) :
|
| - TransportChannelImpl(content_name, component),
|
| - transport_(transport),
|
| - allocator_(allocator),
|
| - worker_thread_(rtc::Thread::Current()),
|
| - incoming_only_(false),
|
| - waiting_for_signaling_(false),
|
| - error_(0),
|
| - best_connection_(NULL),
|
| - pending_best_connection_(NULL),
|
| - sort_dirty_(false),
|
| - was_writable_(false),
|
| - protocol_type_(ICEPROTO_HYBRID),
|
| - remote_ice_mode_(ICEMODE_FULL),
|
| - ice_role_(ICEROLE_UNKNOWN),
|
| - tiebreaker_(0),
|
| - remote_candidate_generation_(0),
|
| - check_receiving_delay_(MIN_CHECK_RECEIVING_DELAY * 5),
|
| - receiving_timeout_(MIN_CHECK_RECEIVING_DELAY * 50) {
|
| + PortAllocator* allocator)
|
| + : TransportChannelImpl(content_name, component),
|
| + transport_(transport),
|
| + allocator_(allocator),
|
| + worker_thread_(rtc::Thread::Current()),
|
| + incoming_only_(false),
|
| + error_(0),
|
| + best_connection_(NULL),
|
| + pending_best_connection_(NULL),
|
| + sort_dirty_(false),
|
| + was_writable_(false),
|
| + protocol_type_(ICEPROTO_HYBRID),
|
| + remote_ice_mode_(ICEMODE_FULL),
|
| + ice_role_(ICEROLE_UNKNOWN),
|
| + tiebreaker_(0),
|
| + remote_candidate_generation_(0),
|
| + gathering_state_(kGatheringNew),
|
| + check_receiving_delay_(MIN_CHECK_RECEIVING_DELAY * 5),
|
| + receiving_timeout_(MIN_CHECK_RECEIVING_DELAY * 50) {
|
| }
|
|
|
| P2PTransportChannel::~P2PTransportChannel() {
|
| @@ -325,7 +326,7 @@ void P2PTransportChannel::SetIceCredentials(const std::string& ice_ufrag,
|
|
|
| if (ice_restart) {
|
| // Restart candidate gathering.
|
| - Allocate();
|
| + StartGatheringCandidates();
|
| }
|
| }
|
|
|
| @@ -381,7 +382,7 @@ void P2PTransportChannel::Connect() {
|
| }
|
|
|
| // Kick off an allocator session
|
| - Allocate();
|
| + StartGatheringCandidates();
|
|
|
| // Start pinging as the ports come in.
|
| thread()->Post(this, MSG_PING);
|
| @@ -435,17 +436,21 @@ void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
|
|
|
| // A new candidate is available, let listeners know
|
| void P2PTransportChannel::OnCandidatesReady(
|
| - PortAllocatorSession *session, const std::vector<Candidate>& candidates) {
|
| + PortAllocatorSession* session,
|
| + const std::vector<Candidate>& candidates) {
|
| ASSERT(worker_thread_ == rtc::Thread::Current());
|
| for (size_t i = 0; i < candidates.size(); ++i) {
|
| - SignalCandidateReady(this, candidates[i]);
|
| + SignalCandidateGathered(this, candidates[i]);
|
| }
|
| }
|
|
|
| void P2PTransportChannel::OnCandidatesAllocationDone(
|
| PortAllocatorSession* session) {
|
| ASSERT(worker_thread_ == rtc::Thread::Current());
|
| - SignalCandidatesAllocationDone(this);
|
| + gathering_state_ = kGatheringComplete;
|
| + LOG(LS_INFO) << "P2PTransportChannel: " << content_name() << ", component "
|
| + << component() << " gathering complete";
|
| + SignalGatheringState(this);
|
| }
|
|
|
| // Handle stun packets
|
| @@ -631,16 +636,6 @@ void P2PTransportChannel::OnRoleConflict(PortInterface* port) {
|
| // from Transport.
|
| }
|
|
|
| -// When the signalling channel is ready, we can really kick off the allocator
|
| -void P2PTransportChannel::OnSignalingReady() {
|
| - ASSERT(worker_thread_ == rtc::Thread::Current());
|
| - if (waiting_for_signaling_) {
|
| - waiting_for_signaling_ = false;
|
| - AddAllocatorSession(allocator_->CreateSession(
|
| - SessionId(), content_name(), component(), ice_ufrag_, ice_pwd_));
|
| - }
|
| -}
|
| -
|
| void P2PTransportChannel::OnUseCandidate(Connection* conn) {
|
| ASSERT(worker_thread_ == rtc::Thread::Current());
|
| ASSERT(ice_role_ == ICEROLE_CONTROLLED);
|
| @@ -917,7 +912,7 @@ bool P2PTransportChannel::GetStats(ConnectionInfos *infos) {
|
|
|
| std::vector<Connection *>::const_iterator it;
|
| for (it = connections_.begin(); it != connections_.end(); ++it) {
|
| - Connection *connection = *it;
|
| + Connection* connection = *it;
|
| ConnectionInfo info;
|
| info.best_connection = (best_connection_ == connection);
|
| info.readable =
|
| @@ -952,12 +947,14 @@ rtc::DiffServCodePoint P2PTransportChannel::DefaultDscpValue() const {
|
| return static_cast<rtc::DiffServCodePoint> (it->second);
|
| }
|
|
|
| -// Begin allocate (or immediately re-allocate, if MSG_ALLOCATE pending)
|
| -void P2PTransportChannel::Allocate() {
|
| - // Time for a new allocator, lets make sure we have a signalling channel
|
| - // to communicate candidates through first.
|
| - waiting_for_signaling_ = true;
|
| - SignalRequestSignaling(this);
|
| +void P2PTransportChannel::StartGatheringCandidates() {
|
| + // Time for a new allocator
|
| + if (gathering_state_ != kGatheringGathering) {
|
| + gathering_state_ = kGatheringGathering;
|
| + SignalGatheringState(this);
|
| + }
|
| + AddAllocatorSession(allocator_->CreateSession(
|
| + SessionId(), content_name(), component(), ice_ufrag_, ice_pwd_));
|
| }
|
|
|
| // Monitor connection states.
|
| @@ -1406,9 +1403,10 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
|
| }
|
|
|
| // We data is available, let listeners know
|
| -void P2PTransportChannel::OnReadPacket(
|
| - Connection *connection, const char *data, size_t len,
|
| - const rtc::PacketTime& packet_time) {
|
| +void P2PTransportChannel::OnReadPacket(Connection* connection,
|
| + const char* data,
|
| + size_t len,
|
| + const rtc::PacketTime& packet_time) {
|
| ASSERT(worker_thread_ == rtc::Thread::Current());
|
|
|
| // Do not deliver, if packet doesn't belong to the correct transport channel.
|
|
|