Remove PORTALLOCATOR_ENABLE_BUNDLE, PortAllocatorSessionProxy, PortAllocatorSessionMuxer, and PortProxy.
R=decurtis@webrtc.org Review URL: https://webrtc-codereview.appspot.com/46809004 Cr-Commit-Position: refs/heads/master@{#8999}
This commit is contained in:
parent
74b9769e4e
commit
73ba7a690f
@ -31,7 +31,6 @@
|
||||
using cricket::kDefaultPortAllocatorFlags;
|
||||
using cricket::kMinimumStepDelay;
|
||||
using cricket::kDefaultStepDelay;
|
||||
using cricket::PORTALLOCATOR_ENABLE_BUNDLE;
|
||||
using cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG;
|
||||
using cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET;
|
||||
using cricket::ServerAddresses;
|
||||
@ -284,15 +283,6 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
std::string ice_pwd_ep1_cd2_ch = kIcePwd[2];
|
||||
std::string ice_ufrag_ep2_cd2_ch = kIceUfrag[3];
|
||||
std::string ice_pwd_ep2_cd2_ch = kIcePwd[3];
|
||||
// In BUNDLE each endpoint must share common ICE credentials.
|
||||
if (ep1_.allocator_->flags() & PORTALLOCATOR_ENABLE_BUNDLE) {
|
||||
ice_ufrag_ep1_cd2_ch = ice_ufrag_ep1_cd1_ch;
|
||||
ice_pwd_ep1_cd2_ch = ice_pwd_ep1_cd1_ch;
|
||||
}
|
||||
if (ep2_.allocator_->flags() & PORTALLOCATOR_ENABLE_BUNDLE) {
|
||||
ice_ufrag_ep2_cd2_ch = ice_ufrag_ep2_cd1_ch;
|
||||
ice_pwd_ep2_cd2_ch = ice_pwd_ep2_cd1_ch;
|
||||
}
|
||||
ep1_.cd2_.ch_.reset(CreateChannel(
|
||||
0, cricket::ICE_CANDIDATE_COMPONENT_DEFAULT,
|
||||
ice_ufrag_ep1_cd2_ch, ice_pwd_ep1_cd2_ch,
|
||||
@ -1190,20 +1180,6 @@ TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeAsIce) {
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
// Test that we restart candidate allocation when local ufrag&pwd changed.
|
||||
// Standard Ice protocol is used.
|
||||
TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeBundleAsIce) {
|
||||
ConfigureEndpoints(
|
||||
OPEN, OPEN,
|
||||
PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG,
|
||||
PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG,
|
||||
kMinimumStepDelay, kMinimumStepDelay,
|
||||
cricket::ICEPROTO_RFC5245);
|
||||
CreateChannels(2);
|
||||
TestHandleIceUfragPasswordChanged();
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
// Test that we restart candidate allocation when local ufrag&pwd changed.
|
||||
// Google Ice protocol is used.
|
||||
TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeAsGice) {
|
||||
@ -1217,20 +1193,6 @@ TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeAsGice) {
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
// Test that ICE restart works when bundle is enabled.
|
||||
// Google Ice protocol is used.
|
||||
TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeBundleAsGice) {
|
||||
ConfigureEndpoints(
|
||||
OPEN, OPEN,
|
||||
PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG,
|
||||
PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG,
|
||||
kDefaultStepDelay, kDefaultStepDelay,
|
||||
cricket::ICEPROTO_GOOGLE);
|
||||
CreateChannels(2);
|
||||
TestHandleIceUfragPasswordChanged();
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
// Test the operation of GetStats.
|
||||
TEST_F(P2PTransportChannelTest, GetStats) {
|
||||
ConfigureEndpoints(OPEN, OPEN,
|
||||
@ -1452,75 +1414,9 @@ TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) {
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
TEST_F(P2PTransportChannelTest, TestBundleAllocatorToBundleAllocator) {
|
||||
TEST_F(P2PTransportChannelTest, TestIceRoleConflict) {
|
||||
AddAddress(0, kPublicAddrs[0]);
|
||||
AddAddress(1, kPublicAddrs[1]);
|
||||
SetAllocatorFlags(
|
||||
0, PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
SetAllocatorFlags(
|
||||
1, PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
|
||||
CreateChannels(2);
|
||||
|
||||
EXPECT_TRUE_WAIT(ep1_ch1()->readable() &&
|
||||
ep1_ch1()->writable() &&
|
||||
ep2_ch1()->readable() &&
|
||||
ep2_ch1()->writable(),
|
||||
1000);
|
||||
EXPECT_TRUE(ep1_ch1()->best_connection() &&
|
||||
ep2_ch1()->best_connection());
|
||||
|
||||
EXPECT_FALSE(ep1_ch2()->readable());
|
||||
EXPECT_FALSE(ep1_ch2()->writable());
|
||||
EXPECT_FALSE(ep2_ch2()->readable());
|
||||
EXPECT_FALSE(ep2_ch2()->writable());
|
||||
|
||||
TestSendRecv(1); // Only 1 channel is writable per Endpoint.
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
TEST_F(P2PTransportChannelTest, TestBundleAllocatorToNonBundleAllocator) {
|
||||
AddAddress(0, kPublicAddrs[0]);
|
||||
AddAddress(1, kPublicAddrs[1]);
|
||||
// Enable BUNDLE flag at one side.
|
||||
SetAllocatorFlags(
|
||||
0, PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
|
||||
CreateChannels(2);
|
||||
|
||||
EXPECT_TRUE_WAIT(ep1_ch1()->readable() &&
|
||||
ep1_ch1()->writable() &&
|
||||
ep2_ch1()->readable() &&
|
||||
ep2_ch1()->writable(),
|
||||
1000);
|
||||
EXPECT_TRUE_WAIT(ep1_ch2()->readable() &&
|
||||
ep1_ch2()->writable() &&
|
||||
ep2_ch2()->readable() &&
|
||||
ep2_ch2()->writable(),
|
||||
1000);
|
||||
|
||||
EXPECT_TRUE(ep1_ch1()->best_connection() &&
|
||||
ep2_ch1()->best_connection());
|
||||
EXPECT_TRUE(ep1_ch2()->best_connection() &&
|
||||
ep2_ch2()->best_connection());
|
||||
|
||||
TestSendRecv(2);
|
||||
DestroyChannels();
|
||||
}
|
||||
|
||||
TEST_F(P2PTransportChannelTest, TestIceRoleConflictWithoutBundle) {
|
||||
AddAddress(0, kPublicAddrs[0]);
|
||||
AddAddress(1, kPublicAddrs[1]);
|
||||
TestSignalRoleConflict();
|
||||
}
|
||||
|
||||
TEST_F(P2PTransportChannelTest, TestIceRoleConflictWithBundle) {
|
||||
AddAddress(0, kPublicAddrs[0]);
|
||||
AddAddress(1, kPublicAddrs[1]);
|
||||
SetAllocatorFlags(
|
||||
0, PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
SetAllocatorFlags(
|
||||
1, PORTALLOCATOR_ENABLE_BUNDLE | PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
TestSignalRoleConflict();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
|
||||
#include "webrtc/p2p/base/portproxy.h"
|
||||
#include "webrtc/p2p/base/relayport.h"
|
||||
#include "webrtc/p2p/base/stunport.h"
|
||||
#include "webrtc/p2p/base/tcpport.h"
|
||||
@ -2209,21 +2208,6 @@ TEST_F(PortTest, TestComputeCandidatePriority) {
|
||||
ASSERT_EQ(expected_priority_6bone, port->Candidates()[8].priority());
|
||||
}
|
||||
|
||||
TEST_F(PortTest, TestPortProxyProperties) {
|
||||
rtc::scoped_ptr<TestPort> port(
|
||||
CreateTestPort(kLocalAddr1, "name", "pass"));
|
||||
port->SetIceRole(cricket::ICEROLE_CONTROLLING);
|
||||
port->SetIceTiebreaker(kTiebreaker1);
|
||||
|
||||
// Create a proxy port.
|
||||
rtc::scoped_ptr<PortProxy> proxy(new PortProxy());
|
||||
proxy->set_impl(port.get());
|
||||
EXPECT_EQ(port->Type(), proxy->Type());
|
||||
EXPECT_EQ(port->Network(), proxy->Network());
|
||||
EXPECT_EQ(port->GetIceRole(), proxy->GetIceRole());
|
||||
EXPECT_EQ(port->IceTiebreaker(), proxy->IceTiebreaker());
|
||||
}
|
||||
|
||||
// In the case of shared socket, one port may be shared by local and stun.
|
||||
// Test that candidates with different types will have different foundation.
|
||||
TEST_F(PortTest, TestFoundation) {
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
#include "webrtc/p2p/base/portallocator.h"
|
||||
|
||||
#include "webrtc/p2p/base/portallocatorsessionproxy.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
PortAllocatorSession::PortAllocatorSession(const std::string& content_name,
|
||||
@ -28,16 +26,6 @@ PortAllocatorSession::PortAllocatorSession(const std::string& content_name,
|
||||
// by itself.
|
||||
username_(flags_ & PORTALLOCATOR_ENABLE_SHARED_UFRAG ? ice_ufrag : ""),
|
||||
password_(flags_ & PORTALLOCATOR_ENABLE_SHARED_UFRAG ? ice_pwd : "") {
|
||||
// If bundle is enabled, shared ufrag must be enabled too.
|
||||
ASSERT((!(flags_ & PORTALLOCATOR_ENABLE_BUNDLE)) ||
|
||||
(flags_ & PORTALLOCATOR_ENABLE_SHARED_UFRAG));
|
||||
}
|
||||
|
||||
PortAllocator::~PortAllocator() {
|
||||
for (SessionMuxerMap::iterator iter = muxers_.begin();
|
||||
iter != muxers_.end(); ++iter) {
|
||||
delete iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
PortAllocatorSession* PortAllocator::CreateSession(
|
||||
@ -46,50 +34,7 @@ PortAllocatorSession* PortAllocator::CreateSession(
|
||||
int component,
|
||||
const std::string& ice_ufrag,
|
||||
const std::string& ice_pwd) {
|
||||
if (flags_ & PORTALLOCATOR_ENABLE_BUNDLE) {
|
||||
// If we just use |sid| as key in identifying PortAllocatorSessionMuxer,
|
||||
// ICE restart will not result in different candidates, as |sid| will
|
||||
// be same. To yield different candiates we are using combination of
|
||||
// |ice_ufrag| and |ice_pwd|.
|
||||
// Ideally |ice_ufrag| and |ice_pwd| should change together, but
|
||||
// there can be instances where only ice_pwd will be changed.
|
||||
std::string key_str = ice_ufrag + ":" + ice_pwd;
|
||||
PortAllocatorSessionMuxer* muxer = GetSessionMuxer(key_str);
|
||||
if (!muxer) {
|
||||
PortAllocatorSession* session_impl = CreateSessionInternal(
|
||||
content_name, component, ice_ufrag, ice_pwd);
|
||||
// Create PortAllocatorSessionMuxer object for |session_impl|.
|
||||
muxer = new PortAllocatorSessionMuxer(session_impl);
|
||||
muxer->SignalDestroyed.connect(
|
||||
this, &PortAllocator::OnSessionMuxerDestroyed);
|
||||
// Add PortAllocatorSession to the map.
|
||||
muxers_[key_str] = muxer;
|
||||
}
|
||||
PortAllocatorSessionProxy* proxy =
|
||||
new PortAllocatorSessionProxy(content_name, component, flags_);
|
||||
muxer->RegisterSessionProxy(proxy);
|
||||
return proxy;
|
||||
}
|
||||
return CreateSessionInternal(content_name, component, ice_ufrag, ice_pwd);
|
||||
}
|
||||
|
||||
PortAllocatorSessionMuxer* PortAllocator::GetSessionMuxer(
|
||||
const std::string& key) const {
|
||||
SessionMuxerMap::const_iterator iter = muxers_.find(key);
|
||||
if (iter != muxers_.end())
|
||||
return iter->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void PortAllocator::OnSessionMuxerDestroyed(
|
||||
PortAllocatorSessionMuxer* session) {
|
||||
SessionMuxerMap::iterator iter;
|
||||
for (iter = muxers_.begin(); iter != muxers_.end(); ++iter) {
|
||||
if (iter->second == session)
|
||||
break;
|
||||
}
|
||||
if (iter != muxers_.end())
|
||||
muxers_.erase(iter);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -33,7 +33,6 @@ enum {
|
||||
PORTALLOCATOR_DISABLE_RELAY = 0x04,
|
||||
PORTALLOCATOR_DISABLE_TCP = 0x08,
|
||||
PORTALLOCATOR_ENABLE_SHAKER = 0x10,
|
||||
PORTALLOCATOR_ENABLE_BUNDLE = 0x20,
|
||||
PORTALLOCATOR_ENABLE_IPV6 = 0x40,
|
||||
PORTALLOCATOR_ENABLE_SHARED_UFRAG = 0x80,
|
||||
PORTALLOCATOR_ENABLE_SHARED_SOCKET = 0x100,
|
||||
@ -57,8 +56,6 @@ enum {
|
||||
CF_ALL = 0x7,
|
||||
};
|
||||
|
||||
class PortAllocatorSessionMuxer;
|
||||
|
||||
class PortAllocatorSession : public sigslot::has_slots<> {
|
||||
public:
|
||||
// Content name passed in mostly for logging and debugging.
|
||||
@ -116,7 +113,7 @@ class PortAllocator : public sigslot::has_slots<> {
|
||||
candidate_filter_(CF_ALL) {
|
||||
// This will allow us to have old behavior on non webrtc clients.
|
||||
}
|
||||
virtual ~PortAllocator();
|
||||
virtual ~PortAllocator() {}
|
||||
|
||||
PortAllocatorSession* CreateSession(
|
||||
const std::string& sid,
|
||||
@ -125,9 +122,6 @@ class PortAllocator : public sigslot::has_slots<> {
|
||||
const std::string& ice_ufrag,
|
||||
const std::string& ice_pwd);
|
||||
|
||||
PortAllocatorSessionMuxer* GetSessionMuxer(const std::string& key) const;
|
||||
void OnSessionMuxerDestroyed(PortAllocatorSessionMuxer* session);
|
||||
|
||||
uint32 flags() const { return flags_; }
|
||||
void set_flags(uint32 flags) { flags_ = flags; }
|
||||
|
||||
@ -179,15 +173,12 @@ class PortAllocator : public sigslot::has_slots<> {
|
||||
const std::string& ice_ufrag,
|
||||
const std::string& ice_pwd) = 0;
|
||||
|
||||
typedef std::map<std::string, PortAllocatorSessionMuxer*> SessionMuxerMap;
|
||||
|
||||
uint32 flags_;
|
||||
std::string agent_;
|
||||
rtc::ProxyInfo proxy_;
|
||||
int min_port_;
|
||||
int max_port_;
|
||||
uint32 step_delay_;
|
||||
SessionMuxerMap muxers_;
|
||||
bool allow_tcp_listen_;
|
||||
uint32 candidate_filter_;
|
||||
std::string origin_;
|
||||
|
@ -1,222 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/p2p/base/portallocatorsessionproxy.h"
|
||||
|
||||
#include "webrtc/p2p/base/portallocator.h"
|
||||
#include "webrtc/p2p/base/portproxy.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
enum {
|
||||
MSG_SEND_ALLOCATION_DONE = 1,
|
||||
MSG_SEND_ALLOCATED_PORTS,
|
||||
};
|
||||
|
||||
typedef rtc::TypedMessageData<PortAllocatorSessionProxy*> ProxyObjData;
|
||||
|
||||
PortAllocatorSessionMuxer::PortAllocatorSessionMuxer(
|
||||
PortAllocatorSession* session)
|
||||
: worker_thread_(rtc::Thread::Current()),
|
||||
session_(session),
|
||||
candidate_done_signal_received_(false) {
|
||||
session_->SignalPortReady.connect(
|
||||
this, &PortAllocatorSessionMuxer::OnPortReady);
|
||||
session_->SignalCandidatesAllocationDone.connect(
|
||||
this, &PortAllocatorSessionMuxer::OnCandidatesAllocationDone);
|
||||
}
|
||||
|
||||
PortAllocatorSessionMuxer::~PortAllocatorSessionMuxer() {
|
||||
for (size_t i = 0; i < session_proxies_.size(); ++i)
|
||||
delete session_proxies_[i];
|
||||
|
||||
SignalDestroyed(this);
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::RegisterSessionProxy(
|
||||
PortAllocatorSessionProxy* session_proxy) {
|
||||
session_proxies_.push_back(session_proxy);
|
||||
session_proxy->SignalDestroyed.connect(
|
||||
this, &PortAllocatorSessionMuxer::OnSessionProxyDestroyed);
|
||||
session_proxy->set_impl(session_.get());
|
||||
|
||||
// Populate new proxy session with the information available in the actual
|
||||
// implementation.
|
||||
if (!ports_.empty()) {
|
||||
worker_thread_->Post(
|
||||
this, MSG_SEND_ALLOCATED_PORTS, new ProxyObjData(session_proxy));
|
||||
}
|
||||
|
||||
if (candidate_done_signal_received_) {
|
||||
worker_thread_->Post(
|
||||
this, MSG_SEND_ALLOCATION_DONE, new ProxyObjData(session_proxy));
|
||||
}
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::OnCandidatesAllocationDone(
|
||||
PortAllocatorSession* session) {
|
||||
candidate_done_signal_received_ = true;
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::OnPortReady(PortAllocatorSession* session,
|
||||
PortInterface* port) {
|
||||
ASSERT(session == session_.get());
|
||||
ports_.push_back(port);
|
||||
port->SignalDestroyed.connect(
|
||||
this, &PortAllocatorSessionMuxer::OnPortDestroyed);
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::OnPortDestroyed(PortInterface* port) {
|
||||
std::vector<PortInterface*>::iterator it =
|
||||
std::find(ports_.begin(), ports_.end(), port);
|
||||
if (it != ports_.end())
|
||||
ports_.erase(it);
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::OnSessionProxyDestroyed(
|
||||
PortAllocatorSession* proxy) {
|
||||
|
||||
std::vector<PortAllocatorSessionProxy*>::iterator it =
|
||||
std::find(session_proxies_.begin(), session_proxies_.end(), proxy);
|
||||
if (it != session_proxies_.end()) {
|
||||
session_proxies_.erase(it);
|
||||
}
|
||||
|
||||
if (session_proxies_.empty()) {
|
||||
// Destroy PortAllocatorSession and its associated muxer object if all
|
||||
// proxies belonging to this session are already destroyed.
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::OnMessage(rtc::Message *pmsg) {
|
||||
ProxyObjData* proxy = static_cast<ProxyObjData*>(pmsg->pdata);
|
||||
switch (pmsg->message_id) {
|
||||
case MSG_SEND_ALLOCATION_DONE:
|
||||
SendAllocationDone_w(proxy->data());
|
||||
delete proxy;
|
||||
break;
|
||||
case MSG_SEND_ALLOCATED_PORTS:
|
||||
SendAllocatedPorts_w(proxy->data());
|
||||
delete proxy;
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::SendAllocationDone_w(
|
||||
PortAllocatorSessionProxy* proxy) {
|
||||
std::vector<PortAllocatorSessionProxy*>::iterator iter =
|
||||
std::find(session_proxies_.begin(), session_proxies_.end(), proxy);
|
||||
if (iter != session_proxies_.end()) {
|
||||
proxy->OnCandidatesAllocationDone(session_.get());
|
||||
}
|
||||
}
|
||||
|
||||
void PortAllocatorSessionMuxer::SendAllocatedPorts_w(
|
||||
PortAllocatorSessionProxy* proxy) {
|
||||
std::vector<PortAllocatorSessionProxy*>::iterator iter =
|
||||
std::find(session_proxies_.begin(), session_proxies_.end(), proxy);
|
||||
if (iter != session_proxies_.end()) {
|
||||
for (size_t i = 0; i < ports_.size(); ++i) {
|
||||
PortInterface* port = ports_[i];
|
||||
proxy->OnPortReady(session_.get(), port);
|
||||
// If port already has candidates, send this to the clients of proxy
|
||||
// session. This can happen if proxy is created later than the actual
|
||||
// implementation.
|
||||
if (!port->Candidates().empty()) {
|
||||
proxy->OnCandidatesReady(session_.get(), port->Candidates());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PortAllocatorSessionProxy::~PortAllocatorSessionProxy() {
|
||||
std::map<PortInterface*, PortProxy*>::iterator it;
|
||||
for (it = proxy_ports_.begin(); it != proxy_ports_.end(); it++)
|
||||
delete it->second;
|
||||
|
||||
SignalDestroyed(this);
|
||||
}
|
||||
|
||||
void PortAllocatorSessionProxy::set_impl(
|
||||
PortAllocatorSession* session) {
|
||||
impl_ = session;
|
||||
|
||||
impl_->SignalCandidatesReady.connect(
|
||||
this, &PortAllocatorSessionProxy::OnCandidatesReady);
|
||||
impl_->SignalPortReady.connect(
|
||||
this, &PortAllocatorSessionProxy::OnPortReady);
|
||||
impl_->SignalCandidatesAllocationDone.connect(
|
||||
this, &PortAllocatorSessionProxy::OnCandidatesAllocationDone);
|
||||
}
|
||||
|
||||
void PortAllocatorSessionProxy::StartGettingPorts() {
|
||||
ASSERT(impl_ != NULL);
|
||||
// Since all proxies share a common PortAllocatorSession, this check will
|
||||
// prohibit sending multiple STUN ping messages to the stun server, which
|
||||
// is a problem on Chrome. GetInitialPorts() and StartGetAllPorts() called
|
||||
// from the worker thread and are called together from TransportChannel,
|
||||
// checking for IsGettingAllPorts() for GetInitialPorts() will not be a
|
||||
// problem.
|
||||
if (!impl_->IsGettingPorts()) {
|
||||
impl_->StartGettingPorts();
|
||||
}
|
||||
}
|
||||
|
||||
void PortAllocatorSessionProxy::StopGettingPorts() {
|
||||
ASSERT(impl_ != NULL);
|
||||
if (impl_->IsGettingPorts()) {
|
||||
impl_->StopGettingPorts();
|
||||
}
|
||||
}
|
||||
|
||||
bool PortAllocatorSessionProxy::IsGettingPorts() {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->IsGettingPorts();
|
||||
}
|
||||
|
||||
void PortAllocatorSessionProxy::OnPortReady(PortAllocatorSession* session,
|
||||
PortInterface* port) {
|
||||
ASSERT(session == impl_);
|
||||
|
||||
PortProxy* proxy_port = new PortProxy();
|
||||
proxy_port->set_impl(port);
|
||||
proxy_ports_[port] = proxy_port;
|
||||
SignalPortReady(this, proxy_port);
|
||||
}
|
||||
|
||||
void PortAllocatorSessionProxy::OnCandidatesReady(
|
||||
PortAllocatorSession* session,
|
||||
const std::vector<Candidate>& candidates) {
|
||||
ASSERT(session == impl_);
|
||||
|
||||
// Since all proxy sessions share a common PortAllocatorSession,
|
||||
// all Candidates will have name associated with the common PAS.
|
||||
// Change Candidate name with the PortAllocatorSessionProxy name.
|
||||
std::vector<Candidate> our_candidates;
|
||||
for (size_t i = 0; i < candidates.size(); ++i) {
|
||||
Candidate new_local_candidate = candidates[i];
|
||||
new_local_candidate.set_component(component_);
|
||||
our_candidates.push_back(new_local_candidate);
|
||||
}
|
||||
SignalCandidatesReady(this, our_candidates);
|
||||
}
|
||||
|
||||
void PortAllocatorSessionProxy::OnCandidatesAllocationDone(
|
||||
PortAllocatorSession* session) {
|
||||
ASSERT(session == impl_);
|
||||
SignalCandidatesAllocationDone(this);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
|
||||
#define WEBRTC_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/p2p/base/candidate.h"
|
||||
#include "webrtc/p2p/base/portallocator.h"
|
||||
|
||||
namespace cricket {
|
||||
class PortAllocator;
|
||||
class PortAllocatorSessionProxy;
|
||||
class PortProxy;
|
||||
|
||||
// This class maintains the list of cricket::Port* objects. Ports will be
|
||||
// deleted upon receiving SignalDestroyed signal. This class is used when
|
||||
// PORTALLOCATOR_ENABLE_BUNDLE flag is set.
|
||||
|
||||
class PortAllocatorSessionMuxer : public rtc::MessageHandler,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
explicit PortAllocatorSessionMuxer(PortAllocatorSession* session);
|
||||
virtual ~PortAllocatorSessionMuxer();
|
||||
|
||||
void RegisterSessionProxy(PortAllocatorSessionProxy* session_proxy);
|
||||
|
||||
void OnPortReady(PortAllocatorSession* session, PortInterface* port);
|
||||
void OnPortDestroyed(PortInterface* port);
|
||||
void OnCandidatesAllocationDone(PortAllocatorSession* session);
|
||||
|
||||
const std::vector<PortInterface*>& ports() { return ports_; }
|
||||
|
||||
sigslot::signal1<PortAllocatorSessionMuxer*> SignalDestroyed;
|
||||
|
||||
private:
|
||||
virtual void OnMessage(rtc::Message *pmsg);
|
||||
void OnSessionProxyDestroyed(PortAllocatorSession* proxy);
|
||||
void SendAllocationDone_w(PortAllocatorSessionProxy* proxy);
|
||||
void SendAllocatedPorts_w(PortAllocatorSessionProxy* proxy);
|
||||
|
||||
// Port will be deleted when SignalDestroyed received, otherwise delete
|
||||
// happens when PortAllocatorSession dtor is called.
|
||||
rtc::Thread* worker_thread_;
|
||||
std::vector<PortInterface*> ports_;
|
||||
rtc::scoped_ptr<PortAllocatorSession> session_;
|
||||
std::vector<PortAllocatorSessionProxy*> session_proxies_;
|
||||
bool candidate_done_signal_received_;
|
||||
};
|
||||
|
||||
class PortAllocatorSessionProxy : public PortAllocatorSession {
|
||||
public:
|
||||
PortAllocatorSessionProxy(const std::string& content_name,
|
||||
int component,
|
||||
uint32 flags)
|
||||
// Use empty string as the ufrag and pwd because the proxy always uses
|
||||
// the ufrag and pwd from the underlying implementation.
|
||||
: PortAllocatorSession(content_name, component, "", "", flags),
|
||||
impl_(NULL) {
|
||||
}
|
||||
|
||||
virtual ~PortAllocatorSessionProxy();
|
||||
|
||||
PortAllocatorSession* impl() { return impl_; }
|
||||
void set_impl(PortAllocatorSession* session);
|
||||
|
||||
// Forwards call to the actual PortAllocatorSession.
|
||||
virtual void StartGettingPorts();
|
||||
virtual void StopGettingPorts();
|
||||
virtual bool IsGettingPorts();
|
||||
|
||||
virtual void set_generation(uint32 generation) {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->set_generation(generation);
|
||||
}
|
||||
|
||||
virtual uint32 generation() {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->generation();
|
||||
}
|
||||
|
||||
private:
|
||||
void OnPortReady(PortAllocatorSession* session, PortInterface* port);
|
||||
void OnCandidatesReady(PortAllocatorSession* session,
|
||||
const std::vector<Candidate>& candidates);
|
||||
void OnPortDestroyed(PortInterface* port);
|
||||
void OnCandidatesAllocationDone(PortAllocatorSession* session);
|
||||
|
||||
// This is the actual PortAllocatorSession, owned by PortAllocator.
|
||||
PortAllocatorSession* impl_;
|
||||
std::map<PortInterface*, PortProxy*> proxy_ports_;
|
||||
|
||||
friend class PortAllocatorSessionMuxer;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // WEBRTC_P2P_BASE_PORTALLOCATORSESSIONPROXY_H_
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
|
||||
#include "webrtc/p2p/base/portallocatorsessionproxy.h"
|
||||
#include "webrtc/p2p/client/basicportallocator.h"
|
||||
#include "webrtc/p2p/client/fakeportallocator.h"
|
||||
#include "webrtc/base/fakenetwork.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
|
||||
using cricket::Candidate;
|
||||
using cricket::PortAllocatorSession;
|
||||
using cricket::PortAllocatorSessionMuxer;
|
||||
using cricket::PortAllocatorSessionProxy;
|
||||
|
||||
// Based on ICE_UFRAG_LENGTH
|
||||
static const char kIceUfrag0[] = "TESTICEUFRAG0000";
|
||||
// Based on ICE_PWD_LENGTH
|
||||
static const char kIcePwd0[] = "TESTICEPWD00000000000000";
|
||||
|
||||
class TestSessionChannel : public sigslot::has_slots<> {
|
||||
public:
|
||||
explicit TestSessionChannel(PortAllocatorSessionProxy* proxy)
|
||||
: proxy_session_(proxy),
|
||||
candidates_count_(0),
|
||||
allocation_complete_(false),
|
||||
ports_count_(0) {
|
||||
proxy_session_->SignalCandidatesAllocationDone.connect(
|
||||
this, &TestSessionChannel::OnCandidatesAllocationDone);
|
||||
proxy_session_->SignalCandidatesReady.connect(
|
||||
this, &TestSessionChannel::OnCandidatesReady);
|
||||
proxy_session_->SignalPortReady.connect(
|
||||
this, &TestSessionChannel::OnPortReady);
|
||||
}
|
||||
virtual ~TestSessionChannel() {
|
||||
delete proxy_session_;
|
||||
}
|
||||
void OnCandidatesReady(PortAllocatorSession* session,
|
||||
const std::vector<Candidate>& candidates) {
|
||||
EXPECT_EQ(proxy_session_, session);
|
||||
candidates_count_ += static_cast<int>(candidates.size());
|
||||
}
|
||||
void OnCandidatesAllocationDone(PortAllocatorSession* session) {
|
||||
EXPECT_EQ(proxy_session_, session);
|
||||
allocation_complete_ = true;
|
||||
}
|
||||
void OnPortReady(PortAllocatorSession* session,
|
||||
cricket::PortInterface* port) {
|
||||
EXPECT_EQ(proxy_session_, session);
|
||||
++ports_count_;
|
||||
}
|
||||
int candidates_count() { return candidates_count_; }
|
||||
bool allocation_complete() { return allocation_complete_; }
|
||||
int ports_count() { return ports_count_; }
|
||||
|
||||
void StartGettingPorts() {
|
||||
proxy_session_->StartGettingPorts();
|
||||
}
|
||||
|
||||
void StopGettingPorts() {
|
||||
proxy_session_->StopGettingPorts();
|
||||
}
|
||||
|
||||
bool IsGettingPorts() {
|
||||
return proxy_session_->IsGettingPorts();
|
||||
}
|
||||
|
||||
private:
|
||||
PortAllocatorSessionProxy* proxy_session_;
|
||||
int candidates_count_;
|
||||
bool allocation_complete_;
|
||||
int ports_count_;
|
||||
};
|
||||
|
||||
class PortAllocatorSessionProxyTest : public testing::Test {
|
||||
public:
|
||||
PortAllocatorSessionProxyTest()
|
||||
: socket_factory_(rtc::Thread::Current()),
|
||||
allocator_(rtc::Thread::Current(), NULL),
|
||||
session_(new cricket::FakePortAllocatorSession(
|
||||
rtc::Thread::Current(), &socket_factory_,
|
||||
"test content", 1,
|
||||
kIceUfrag0, kIcePwd0)),
|
||||
session_muxer_(new PortAllocatorSessionMuxer(session_)) {
|
||||
}
|
||||
virtual ~PortAllocatorSessionProxyTest() {}
|
||||
void RegisterSessionProxy(PortAllocatorSessionProxy* proxy) {
|
||||
session_muxer_->RegisterSessionProxy(proxy);
|
||||
}
|
||||
|
||||
TestSessionChannel* CreateChannel() {
|
||||
PortAllocatorSessionProxy* proxy =
|
||||
new PortAllocatorSessionProxy("test content", 1, 0);
|
||||
TestSessionChannel* channel = new TestSessionChannel(proxy);
|
||||
session_muxer_->RegisterSessionProxy(proxy);
|
||||
channel->StartGettingPorts();
|
||||
return channel;
|
||||
}
|
||||
|
||||
protected:
|
||||
rtc::BasicPacketSocketFactory socket_factory_;
|
||||
cricket::FakePortAllocator allocator_;
|
||||
cricket::FakePortAllocatorSession* session_;
|
||||
// Muxer object will be delete itself after all registered session proxies
|
||||
// are deleted.
|
||||
PortAllocatorSessionMuxer* session_muxer_;
|
||||
};
|
||||
|
||||
TEST_F(PortAllocatorSessionProxyTest, TestBasic) {
|
||||
TestSessionChannel* channel = CreateChannel();
|
||||
EXPECT_EQ_WAIT(1, channel->candidates_count(), 1000);
|
||||
EXPECT_EQ(1, channel->ports_count());
|
||||
EXPECT_TRUE(channel->allocation_complete());
|
||||
delete channel;
|
||||
}
|
||||
|
||||
TEST_F(PortAllocatorSessionProxyTest, TestLateBinding) {
|
||||
TestSessionChannel* channel1 = CreateChannel();
|
||||
EXPECT_EQ_WAIT(1, channel1->candidates_count(), 1000);
|
||||
EXPECT_EQ(1, channel1->ports_count());
|
||||
EXPECT_TRUE(channel1->allocation_complete());
|
||||
EXPECT_EQ(1, session_->port_config_count());
|
||||
// Creating another PortAllocatorSessionProxy and it also should receive
|
||||
// already happened events.
|
||||
PortAllocatorSessionProxy* proxy =
|
||||
new PortAllocatorSessionProxy("test content", 2, 0);
|
||||
TestSessionChannel* channel2 = new TestSessionChannel(proxy);
|
||||
session_muxer_->RegisterSessionProxy(proxy);
|
||||
EXPECT_TRUE(channel2->IsGettingPorts());
|
||||
EXPECT_EQ_WAIT(1, channel2->candidates_count(), 1000);
|
||||
EXPECT_EQ(1, channel2->ports_count());
|
||||
EXPECT_TRUE_WAIT(channel2->allocation_complete(), 1000);
|
||||
EXPECT_EQ(1, session_->port_config_count());
|
||||
delete channel1;
|
||||
delete channel2;
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/p2p/base/portproxy.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
void PortProxy::set_impl(PortInterface* port) {
|
||||
impl_ = port;
|
||||
impl_->SignalUnknownAddress.connect(
|
||||
this, &PortProxy::OnUnknownAddress);
|
||||
impl_->SignalDestroyed.connect(this, &PortProxy::OnPortDestroyed);
|
||||
impl_->SignalRoleConflict.connect(this, &PortProxy::OnRoleConflict);
|
||||
}
|
||||
|
||||
const std::string& PortProxy::Type() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->Type();
|
||||
}
|
||||
|
||||
rtc::Network* PortProxy::Network() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->Network();
|
||||
}
|
||||
|
||||
void PortProxy::SetIceProtocolType(IceProtocolType protocol) {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->SetIceProtocolType(protocol);
|
||||
}
|
||||
|
||||
IceProtocolType PortProxy::IceProtocol() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->IceProtocol();
|
||||
}
|
||||
|
||||
// Methods to set/get ICE role and tiebreaker values.
|
||||
void PortProxy::SetIceRole(IceRole role) {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->SetIceRole(role);
|
||||
}
|
||||
|
||||
IceRole PortProxy::GetIceRole() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->GetIceRole();
|
||||
}
|
||||
|
||||
void PortProxy::SetIceTiebreaker(uint64 tiebreaker) {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->SetIceTiebreaker(tiebreaker);
|
||||
}
|
||||
|
||||
uint64 PortProxy::IceTiebreaker() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->IceTiebreaker();
|
||||
}
|
||||
|
||||
bool PortProxy::SharedSocket() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->SharedSocket();
|
||||
}
|
||||
|
||||
void PortProxy::PrepareAddress() {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->PrepareAddress();
|
||||
}
|
||||
|
||||
Connection* PortProxy::CreateConnection(const Candidate& remote_candidate,
|
||||
CandidateOrigin origin) {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->CreateConnection(remote_candidate, origin);
|
||||
}
|
||||
|
||||
int PortProxy::SendTo(const void* data,
|
||||
size_t size,
|
||||
const rtc::SocketAddress& addr,
|
||||
const rtc::PacketOptions& options,
|
||||
bool payload) {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->SendTo(data, size, addr, options, payload);
|
||||
}
|
||||
|
||||
int PortProxy::SetOption(rtc::Socket::Option opt,
|
||||
int value) {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->SetOption(opt, value);
|
||||
}
|
||||
|
||||
int PortProxy::GetOption(rtc::Socket::Option opt,
|
||||
int* value) {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->GetOption(opt, value);
|
||||
}
|
||||
|
||||
int PortProxy::GetError() {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->GetError();
|
||||
}
|
||||
|
||||
const std::vector<Candidate>& PortProxy::Candidates() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->Candidates();
|
||||
}
|
||||
|
||||
void PortProxy::SendBindingResponse(
|
||||
StunMessage* request, const rtc::SocketAddress& addr) {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->SendBindingResponse(request, addr);
|
||||
}
|
||||
|
||||
Connection* PortProxy::GetConnection(
|
||||
const rtc::SocketAddress& remote_addr) {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->GetConnection(remote_addr);
|
||||
}
|
||||
|
||||
void PortProxy::SendBindingErrorResponse(
|
||||
StunMessage* request, const rtc::SocketAddress& addr,
|
||||
int error_code, const std::string& reason) {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->SendBindingErrorResponse(request, addr, error_code, reason);
|
||||
}
|
||||
|
||||
void PortProxy::EnablePortPackets() {
|
||||
ASSERT(impl_ != NULL);
|
||||
impl_->EnablePortPackets();
|
||||
}
|
||||
|
||||
std::string PortProxy::ToString() const {
|
||||
ASSERT(impl_ != NULL);
|
||||
return impl_->ToString();
|
||||
}
|
||||
|
||||
void PortProxy::OnUnknownAddress(
|
||||
PortInterface *port,
|
||||
const rtc::SocketAddress &addr,
|
||||
ProtocolType proto,
|
||||
IceMessage *stun_msg,
|
||||
const std::string &remote_username,
|
||||
bool port_muxed) {
|
||||
ASSERT(port == impl_);
|
||||
ASSERT(!port_muxed);
|
||||
SignalUnknownAddress(this, addr, proto, stun_msg, remote_username, true);
|
||||
}
|
||||
|
||||
void PortProxy::OnRoleConflict(PortInterface* port) {
|
||||
ASSERT(port == impl_);
|
||||
SignalRoleConflict(this);
|
||||
}
|
||||
|
||||
void PortProxy::OnPortDestroyed(PortInterface* port) {
|
||||
ASSERT(port == impl_);
|
||||
// |port| will be destroyed in PortAllocatorSessionMuxer.
|
||||
SignalDestroyed(this);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_P2P_BASE_PORTPROXY_H_
|
||||
#define WEBRTC_P2P_BASE_PORTPROXY_H_
|
||||
|
||||
#include "webrtc/p2p/base/portinterface.h"
|
||||
#include "webrtc/base/sigslot.h"
|
||||
|
||||
namespace rtc {
|
||||
class Network;
|
||||
}
|
||||
|
||||
namespace cricket {
|
||||
|
||||
class PortProxy : public PortInterface, public sigslot::has_slots<> {
|
||||
public:
|
||||
PortProxy() {}
|
||||
virtual ~PortProxy() {}
|
||||
|
||||
PortInterface* impl() { return impl_; }
|
||||
void set_impl(PortInterface* port);
|
||||
|
||||
virtual const std::string& Type() const;
|
||||
virtual rtc::Network* Network() const;
|
||||
|
||||
virtual void SetIceProtocolType(IceProtocolType protocol);
|
||||
virtual IceProtocolType IceProtocol() const;
|
||||
|
||||
// Methods to set/get ICE role and tiebreaker values.
|
||||
virtual void SetIceRole(IceRole role);
|
||||
virtual IceRole GetIceRole() const;
|
||||
|
||||
virtual void SetIceTiebreaker(uint64 tiebreaker);
|
||||
virtual uint64 IceTiebreaker() const;
|
||||
|
||||
virtual bool SharedSocket() const;
|
||||
|
||||
// Forwards call to the actual Port.
|
||||
virtual void PrepareAddress();
|
||||
virtual Connection* CreateConnection(const Candidate& remote_candidate,
|
||||
CandidateOrigin origin);
|
||||
virtual Connection* GetConnection(
|
||||
const rtc::SocketAddress& remote_addr);
|
||||
|
||||
virtual int SendTo(const void* data, size_t size,
|
||||
const rtc::SocketAddress& addr,
|
||||
const rtc::PacketOptions& options,
|
||||
bool payload);
|
||||
virtual int SetOption(rtc::Socket::Option opt, int value);
|
||||
virtual int GetOption(rtc::Socket::Option opt, int* value);
|
||||
virtual int GetError();
|
||||
|
||||
virtual const std::vector<Candidate>& Candidates() const;
|
||||
|
||||
virtual void SendBindingResponse(StunMessage* request,
|
||||
const rtc::SocketAddress& addr);
|
||||
virtual void SendBindingErrorResponse(
|
||||
StunMessage* request, const rtc::SocketAddress& addr,
|
||||
int error_code, const std::string& reason);
|
||||
|
||||
virtual void EnablePortPackets();
|
||||
virtual std::string ToString() const;
|
||||
|
||||
private:
|
||||
void OnUnknownAddress(PortInterface *port,
|
||||
const rtc::SocketAddress &addr,
|
||||
ProtocolType proto,
|
||||
IceMessage *stun_msg,
|
||||
const std::string &remote_username,
|
||||
bool port_muxed);
|
||||
void OnRoleConflict(PortInterface* port);
|
||||
void OnPortDestroyed(PortInterface* port);
|
||||
|
||||
PortInterface* impl_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // WEBRTC_P2P_BASE_PORTPROXY_H_
|
@ -11,7 +11,6 @@
|
||||
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
|
||||
#include "webrtc/p2p/base/constants.h"
|
||||
#include "webrtc/p2p/base/p2ptransportchannel.h"
|
||||
#include "webrtc/p2p/base/portallocatorsessionproxy.h"
|
||||
#include "webrtc/p2p/base/testrelayserver.h"
|
||||
#include "webrtc/p2p/base/teststunserver.h"
|
||||
#include "webrtc/p2p/base/testturnserver.h"
|
||||
@ -688,89 +687,6 @@ TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PortAllocatorTest, TestBasicMuxFeatures) {
|
||||
AddInterface(kClientAddr);
|
||||
allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_BUNDLE |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
// Session ID - session1.
|
||||
rtc::scoped_ptr<cricket::PortAllocatorSession> session1(
|
||||
CreateSession("session1", cricket::ICE_CANDIDATE_COMPONENT_RTP));
|
||||
rtc::scoped_ptr<cricket::PortAllocatorSession> session2(
|
||||
CreateSession("session1", cricket::ICE_CANDIDATE_COMPONENT_RTCP));
|
||||
session1->StartGettingPorts();
|
||||
session2->StartGettingPorts();
|
||||
// Each session should receive two proxy ports of local and stun.
|
||||
ASSERT_EQ_WAIT(14U, candidates_.size(), kDefaultAllocationTimeout);
|
||||
EXPECT_EQ(8U, ports_.size());
|
||||
|
||||
rtc::scoped_ptr<cricket::PortAllocatorSession> session3(
|
||||
CreateSession("session1", cricket::ICE_CANDIDATE_COMPONENT_RTP));
|
||||
session3->StartGettingPorts();
|
||||
// Already allocated candidates and ports will be sent to the newly
|
||||
// allocated proxy session.
|
||||
ASSERT_EQ_WAIT(21U, candidates_.size(), kDefaultAllocationTimeout);
|
||||
EXPECT_EQ(12U, ports_.size());
|
||||
}
|
||||
|
||||
// This test verifies by changing ice_ufrag and/or ice_pwd
|
||||
// will result in different set of candidates when BUNDLE is enabled.
|
||||
// If BUNDLE is disabled, CreateSession will always allocate new
|
||||
// set of candidates.
|
||||
TEST_F(PortAllocatorTest, TestBundleIceRestart) {
|
||||
AddInterface(kClientAddr);
|
||||
allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_BUNDLE |
|
||||
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG);
|
||||
// Session ID - session1.
|
||||
rtc::scoped_ptr<cricket::PortAllocatorSession> session1(
|
||||
CreateSession("session1", kContentName,
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP,
|
||||
kIceUfrag0, kIcePwd0));
|
||||
session1->StartGettingPorts();
|
||||
ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
|
||||
EXPECT_EQ(4U, ports_.size());
|
||||
|
||||
// Allocate a different session with sid |session1| and different ice_ufrag.
|
||||
rtc::scoped_ptr<cricket::PortAllocatorSession> session2(
|
||||
CreateSession("session1", kContentName,
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP,
|
||||
"TestIceUfrag", kIcePwd0));
|
||||
session2->StartGettingPorts();
|
||||
ASSERT_EQ_WAIT(14U, candidates_.size(), kDefaultAllocationTimeout);
|
||||
EXPECT_EQ(8U, ports_.size());
|
||||
// Verifying the candidate address different from previously allocated
|
||||
// address.
|
||||
// Skipping verification of component id and candidate type.
|
||||
EXPECT_NE(candidates_[0].address(), candidates_[7].address());
|
||||
EXPECT_NE(candidates_[1].address(), candidates_[8].address());
|
||||
|
||||
// Allocating a different session with sid |session1| and
|
||||
// different ice_pwd.
|
||||
rtc::scoped_ptr<cricket::PortAllocatorSession> session3(
|
||||
CreateSession("session1", kContentName,
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP,
|
||||
kIceUfrag0, "TestIcePwd"));
|
||||
session3->StartGettingPorts();
|
||||
ASSERT_EQ_WAIT(21U, candidates_.size(), kDefaultAllocationTimeout);
|
||||
EXPECT_EQ(12U, ports_.size());
|
||||
// Verifying the candidate address different from previously
|
||||
// allocated address.
|
||||
EXPECT_NE(candidates_[7].address(), candidates_[14].address());
|
||||
EXPECT_NE(candidates_[8].address(), candidates_[15].address());
|
||||
|
||||
// Allocating a session with by changing both ice_ufrag and ice_pwd.
|
||||
rtc::scoped_ptr<cricket::PortAllocatorSession> session4(
|
||||
CreateSession("session1", kContentName,
|
||||
cricket::ICE_CANDIDATE_COMPONENT_RTP,
|
||||
"TestIceUfrag", "TestIcePwd"));
|
||||
session4->StartGettingPorts();
|
||||
ASSERT_EQ_WAIT(28U, candidates_.size(), kDefaultAllocationTimeout);
|
||||
EXPECT_EQ(16U, ports_.size());
|
||||
// Verifying the candidate address different from previously
|
||||
// allocated address.
|
||||
EXPECT_NE(candidates_[14].address(), candidates_[21].address());
|
||||
EXPECT_NE(candidates_[15].address(), candidates_[22].address());
|
||||
}
|
||||
|
||||
// Test that when the PORTALLOCATOR_ENABLE_SHARED_UFRAG is enabled we got same
|
||||
// ufrag and pwd for the collected candidates.
|
||||
TEST_F(PortAllocatorTest, TestEnableSharedUfrag) {
|
||||
|
@ -39,11 +39,7 @@
|
||||
'base/port.h',
|
||||
'base/portallocator.cc',
|
||||
'base/portallocator.h',
|
||||
'base/portallocatorsessionproxy.cc',
|
||||
'base/portallocatorsessionproxy.h',
|
||||
'base/portinterface.h',
|
||||
'base/portproxy.cc',
|
||||
'base/portproxy.h',
|
||||
'base/pseudotcp.cc',
|
||||
'base/pseudotcp.h',
|
||||
'base/rawtransport.cc',
|
||||
|
@ -18,7 +18,6 @@
|
||||
'base/fakesession.h',
|
||||
'base/p2ptransportchannel_unittest.cc',
|
||||
'base/port_unittest.cc',
|
||||
'base/portallocatorsessionproxy_unittest.cc',
|
||||
'base/pseudotcp_unittest.cc',
|
||||
'base/relayport_unittest.cc',
|
||||
'base/relayserver_unittest.cc',
|
||||
|
Loading…
x
Reference in New Issue
Block a user