aboutsummaryrefslogtreecommitdiff
path: root/talk
diff options
context:
space:
mode:
authorTaylor Brandstetter <deadbeef@webrtc.org>2015-12-29 14:14:52 -0800
committerTaylor Brandstetter <deadbeef@webrtc.org>2015-12-29 22:15:02 +0000
commit0c7e9f540b282d60b94081f601a1694054d8646e (patch)
tree22f5a36998dd1eb8c7591285b2cc3915e118fd82 /talk
parente86e15b2a2ee208e2d8edbb1c2d73274d9b8aec7 (diff)
downloadwebrtc-0c7e9f540b282d60b94081f601a1694054d8646e.tar.gz
Removing webrtc::PortAllocatorFactoryInterface.
ICE servers are now passed directly into PortAllocator, making PortAllocatorFactoryInterface redundant. This CL also moves SetNetworkIgnoreMask to PortAllocator. R=phoglund@webrtc.org, pthatcher@webrtc.org, tkchin@webrtc.org Review URL: https://codereview.webrtc.org/1520963002 . Cr-Commit-Position: refs/heads/master@{#11139}
Diffstat (limited to 'talk')
-rw-r--r--talk/app/webrtc/fakeportallocatorfactory.h85
-rw-r--r--talk/app/webrtc/objc/RTCPeerConnection.mm6
-rw-r--r--talk/app/webrtc/peerconnection.cc135
-rw-r--r--talk/app/webrtc/peerconnection.h22
-rw-r--r--talk/app/webrtc/peerconnection_unittest.cc163
-rw-r--r--talk/app/webrtc/peerconnectionfactory.cc41
-rw-r--r--talk/app/webrtc/peerconnectionfactory.h12
-rw-r--r--talk/app/webrtc/peerconnectionfactory_unittest.cc258
-rw-r--r--talk/app/webrtc/peerconnectionfactoryproxy.h24
-rw-r--r--talk/app/webrtc/peerconnectioninterface.h82
-rw-r--r--talk/app/webrtc/peerconnectioninterface_unittest.cc55
-rw-r--r--talk/app/webrtc/portallocatorfactory.cc68
-rw-r--r--talk/app/webrtc/portallocatorfactory.h43
-rw-r--r--talk/app/webrtc/test/peerconnectiontestwrapper.cc16
-rw-r--r--talk/app/webrtc/test/peerconnectiontestwrapper.h7
-rwxr-xr-xtalk/libjingle.gyp3
16 files changed, 267 insertions, 753 deletions
diff --git a/talk/app/webrtc/fakeportallocatorfactory.h b/talk/app/webrtc/fakeportallocatorfactory.h
deleted file mode 100644
index eb73b76d08..0000000000
--- a/talk/app/webrtc/fakeportallocatorfactory.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * libjingle
- * Copyright 2011 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// This file defines a fake port allocator factory used for testing.
-// This implementation creates instances of cricket::FakePortAllocator.
-
-#ifndef TALK_APP_WEBRTC_FAKEPORTALLOCATORFACTORY_H_
-#define TALK_APP_WEBRTC_FAKEPORTALLOCATORFACTORY_H_
-
-#include "talk/app/webrtc/peerconnectioninterface.h"
-#include "webrtc/p2p/client/fakeportallocator.h"
-
-namespace webrtc {
-
-class FakePortAllocatorFactory : public PortAllocatorFactoryInterface {
- public:
- static FakePortAllocatorFactory* Create() {
- rtc::RefCountedObject<FakePortAllocatorFactory>* allocator =
- new rtc::RefCountedObject<FakePortAllocatorFactory>();
- return allocator;
- }
-
- virtual cricket::PortAllocator* CreatePortAllocator(
- const std::vector<StunConfiguration>& stun_configurations,
- const std::vector<TurnConfiguration>& turn_configurations) {
- stun_configs_ = stun_configurations;
- turn_configs_ = turn_configurations;
- last_created_allocator_ =
- new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr);
- return last_created_allocator_;
- }
-
- const std::vector<StunConfiguration>& stun_configs() const {
- return stun_configs_;
- }
-
- const std::vector<TurnConfiguration>& turn_configs() const {
- return turn_configs_;
- }
-
- void SetNetworkIgnoreMask(int network_ignore_mask) {}
-
- // Up to caller to ensure this isn't called after the allocator has been
- // destroyed.
- cricket::FakePortAllocator* last_created_allocator() {
- return last_created_allocator_;
- }
-
- protected:
- FakePortAllocatorFactory() {}
- ~FakePortAllocatorFactory() {}
-
- private:
- std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_configs_;
- std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_configs_;
- cricket::FakePortAllocator* last_created_allocator_ = nullptr;
-};
-
-} // namespace webrtc
-
-#endif // TALK_APP_WEBRTC_FAKEPORTALLOCATORFACTORY_H_
diff --git a/talk/app/webrtc/objc/RTCPeerConnection.mm b/talk/app/webrtc/objc/RTCPeerConnection.mm
index 44d39cb090..f814f06ad8 100644
--- a/talk/app/webrtc/objc/RTCPeerConnection.mm
+++ b/talk/app/webrtc/objc/RTCPeerConnection.mm
@@ -271,11 +271,13 @@ class RTCStatsObserver : public StatsObserver {
- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface*)factory
iceServers:(const webrtc::PeerConnectionInterface::IceServers&)iceServers
constraints:(const webrtc::MediaConstraintsInterface*)constraints {
- NSParameterAssert(factory != NULL);
+ NSParameterAssert(factory != nullptr);
if (self = [super init]) {
+ webrtc::PeerConnectionInterface::RTCConfiguration config;
+ config.servers = iceServers;
_observer.reset(new webrtc::RTCPeerConnectionObserver(self));
_peerConnection = factory->CreatePeerConnection(
- iceServers, constraints, NULL, NULL, _observer.get());
+ config, constraints, nullptr, nullptr, _observer.get());
_localStreams = [[NSMutableArray alloc] init];
}
return self;
diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc
index 617eb15518..5f1e3ebdc5 100644
--- a/talk/app/webrtc/peerconnection.cc
+++ b/talk/app/webrtc/peerconnection.cc
@@ -66,12 +66,6 @@ using webrtc::MediaStreamInterface;
using webrtc::PeerConnectionInterface;
using webrtc::RtpSenderInterface;
using webrtc::StreamCollection;
-using webrtc::StunConfigurations;
-using webrtc::TurnConfigurations;
-typedef webrtc::PortAllocatorFactoryInterface::StunConfiguration
- StunConfiguration;
-typedef webrtc::PortAllocatorFactoryInterface::TurnConfiguration
- TurnConfiguration;
static const char kDefaultStreamLabel[] = "default";
static const char kDefaultAudioTrackLabel[] = "defaulta0";
@@ -86,8 +80,6 @@ static const size_t kTurnTransportTokensNum = 2;
static const int kDefaultStunPort = 3478;
static const int kDefaultStunTlsPort = 5349;
static const char kTransport[] = "transport";
-static const char kUdpTransportType[] = "udp";
-static const char kTcpTransportType[] = "tcp";
// NOTE: Must be in the same order as the ServiceType enum.
static const char* kValidIceServiceTypes[] = {"stun", "stuns", "turn", "turns"};
@@ -223,12 +215,12 @@ bool ParseHostnameAndPortFromString(const std::string& in_str,
return !host->empty();
}
-// Adds a StunConfiguration or TurnConfiguration to the appropriate list,
+// Adds a STUN or TURN server to the appropriate list,
// by parsing |url| and using the username/password in |server|.
bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
const std::string& url,
- StunConfigurations* stun_config,
- TurnConfigurations* turn_config) {
+ cricket::ServerAddresses* stun_servers,
+ std::vector<cricket::RelayServerConfig>* turn_servers) {
// draft-nandakumar-rtcweb-stun-uri-01
// stunURI = scheme ":" stun-host [ ":" stun-port ]
// scheme = "stun" / "stuns"
@@ -243,10 +235,10 @@ bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
// transport-ext = 1*unreserved
// turn-host = IP-literal / IPv4address / reg-name
// turn-port = *DIGIT
- RTC_DCHECK(stun_config != nullptr);
- RTC_DCHECK(turn_config != nullptr);
+ RTC_DCHECK(stun_servers != nullptr);
+ RTC_DCHECK(turn_servers != nullptr);
std::vector<std::string> tokens;
- std::string turn_transport_type = kUdpTransportType;
+ cricket::ProtocolType turn_transport_type = cricket::PROTO_UDP;
RTC_DCHECK(!url.empty());
rtc::tokenize(url, '?', &tokens);
std::string uri_without_transport = tokens[0];
@@ -257,11 +249,12 @@ bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
if (tokens[0] == kTransport) {
// As per above grammar transport param will be consist of lower case
// letters.
- if (tokens[1] != kUdpTransportType && tokens[1] != kTcpTransportType) {
+ if (!cricket::StringToProto(tokens[1].c_str(), &turn_transport_type) ||
+ (turn_transport_type != cricket::PROTO_UDP &&
+ turn_transport_type != cricket::PROTO_TCP)) {
LOG(LS_WARNING) << "Transport param should always be udp or tcp.";
return false;
}
- turn_transport_type = tokens[1];
}
}
@@ -300,7 +293,7 @@ bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
int port = kDefaultStunPort;
if (service_type == TURNS) {
port = kDefaultStunTlsPort;
- turn_transport_type = kTcpTransportType;
+ turn_transport_type = cricket::PROTO_TCP;
}
std::string address;
@@ -317,16 +310,14 @@ bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
switch (service_type) {
case STUN:
case STUNS:
- stun_config->push_back(StunConfiguration(address, port));
+ stun_servers->insert(rtc::SocketAddress(address, port));
break;
case TURN:
case TURNS: {
bool secure = (service_type == TURNS);
- turn_config->push_back(TurnConfiguration(address, port,
- username,
- server.password,
- turn_transport_type,
- secure));
+ turn_servers->push_back(
+ cricket::RelayServerConfig(address, port, username, server.password,
+ turn_transport_type, secure));
break;
}
case INVALID:
@@ -337,40 +328,6 @@ bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
return true;
}
-void ConvertToCricketIceServers(
- const std::vector<StunConfiguration>& stuns,
- const std::vector<TurnConfiguration>& turns,
- cricket::ServerAddresses* cricket_stuns,
- std::vector<cricket::RelayServerConfig>* cricket_turns) {
- RTC_DCHECK(cricket_stuns && cricket_turns);
- for (const StunConfiguration& stun : stuns) {
- cricket_stuns->insert(stun.server);
- }
-
- int priority = static_cast<int>(turns.size() - 1);
- for (const TurnConfiguration& turn : turns) {
- cricket::RelayCredentials credentials(turn.username, turn.password);
- cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
- cricket::ProtocolType protocol;
- // Using VERIFY because ParseIceServers should have already caught an
- // invalid transport type.
- if (!VERIFY(
- cricket::StringToProto(turn.transport_type.c_str(), &protocol))) {
- LOG(LS_WARNING) << "Ignoring TURN server " << turn.server << ". "
- << "Reason= Incorrect " << turn.transport_type
- << " transport parameter.";
- } else {
- relay_server.ports.push_back(
- cricket::ProtocolAddress(turn.server, protocol, turn.secure));
- relay_server.credentials = credentials;
- relay_server.priority = priority;
- cricket_turns->push_back(relay_server);
- }
- // First in the list gets highest priority.
- --priority;
- }
-}
-
// Check if we can send |new_stream| on a PeerConnection.
bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams,
webrtc::MediaStreamInterface* new_stream) {
@@ -563,8 +520,8 @@ bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
}
bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
- StunConfigurations* stun_config,
- TurnConfigurations* turn_config) {
+ cricket::ServerAddresses* stun_servers,
+ std::vector<cricket::RelayServerConfig>* turn_servers) {
for (const webrtc::PeerConnectionInterface::IceServer& server : servers) {
if (!server.urls.empty()) {
for (const std::string& url : server.urls) {
@@ -572,13 +529,13 @@ bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
LOG(LS_ERROR) << "Empty uri.";
return false;
}
- if (!ParseIceServerUrl(server, url, stun_config, turn_config)) {
+ if (!ParseIceServerUrl(server, url, stun_servers, turn_servers)) {
return false;
}
}
} else if (!server.uri.empty()) {
// Fallback to old .uri if new .urls isn't present.
- if (!ParseIceServerUrl(server, server.uri, stun_config, turn_config)) {
+ if (!ParseIceServerUrl(server, server.uri, stun_servers, turn_servers)) {
return false;
}
} else {
@@ -586,6 +543,13 @@ bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
return false;
}
}
+ // Candidates must have unique priorities, so that connectivity checks
+ // are performed in a well-defined order.
+ int priority = static_cast<int>(turn_servers->size() - 1);
+ for (cricket::RelayServerConfig& turn_server : *turn_servers) {
+ // First in the list gets highest priority.
+ turn_server.priority = priority--;
+ }
return true;
}
@@ -616,30 +580,6 @@ PeerConnection::~PeerConnection() {
bool PeerConnection::Initialize(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
- PortAllocatorFactoryInterface* allocator_factory,
- rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
- PeerConnectionObserver* observer) {
- RTC_DCHECK(observer != nullptr);
- if (!observer) {
- return false;
- }
-
- // This Initialize function parses ICE servers an extra time, but it will
- // be removed once all PortAllocaotrs support SetIceServers.
- std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config;
- std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config;
- if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) {
- return false;
- }
- rtc::scoped_ptr<cricket::PortAllocator> allocator(
- allocator_factory->CreatePortAllocator(stun_config, turn_config));
- return Initialize(configuration, constraints, std::move(allocator),
- std::move(dtls_identity_store), observer);
-}
-
-bool PeerConnection::Initialize(
- const PeerConnectionInterface::RTCConfiguration& configuration,
- const MediaConstraintsInterface* constraints,
rtc::scoped_ptr<cricket::PortAllocator> allocator,
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
PeerConnectionObserver* observer) {
@@ -652,17 +592,12 @@ bool PeerConnection::Initialize(
port_allocator_ = std::move(allocator);
- std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config;
- std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config;
- if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) {
+ cricket::ServerAddresses stun_servers;
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) {
return false;
}
-
- cricket::ServerAddresses cricket_stuns;
- std::vector<cricket::RelayServerConfig> cricket_turns;
- ConvertToCricketIceServers(stun_config, turn_config, &cricket_stuns,
- &cricket_turns);
- port_allocator_->SetIceServers(cricket_stuns, cricket_turns);
+ port_allocator_->SetIceServers(stun_servers, turn_servers);
// To handle both internal and externally created port allocator, we will
// enable BUNDLE here.
@@ -1185,16 +1120,12 @@ void PeerConnection::SetRemoteDescription(
bool PeerConnection::SetConfiguration(const RTCConfiguration& config) {
TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration");
if (port_allocator_) {
- std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns;
- std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns;
- if (!ParseIceServers(config.servers, &stuns, &turns)) {
+ cricket::ServerAddresses stun_servers;
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ if (!ParseIceServers(config.servers, &stun_servers, &turn_servers)) {
return false;
}
-
- cricket::ServerAddresses cricket_stuns;
- std::vector<cricket::RelayServerConfig> cricket_turns;
- ConvertToCricketIceServers(stuns, turns, &cricket_stuns, &cricket_turns);
- port_allocator_->SetIceServers(cricket_stuns, cricket_turns);
+ port_allocator_->SetIceServers(stun_servers, turn_servers);
}
session_->SetIceConfig(session_->ParseIceConfig(config));
return session_->SetIceTransports(config.type);
diff --git a/talk/app/webrtc/peerconnection.h b/talk/app/webrtc/peerconnection.h
index ab3fdcc56d..6e2b967fb4 100644
--- a/talk/app/webrtc/peerconnection.h
+++ b/talk/app/webrtc/peerconnection.h
@@ -45,11 +45,6 @@ namespace webrtc {
class MediaStreamObserver;
class RemoteMediaStreamFactory;
-typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration>
- StunConfigurations;
-typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration>
- TurnConfigurations;
-
// Populates |session_options| from |rtc_options|, and returns true if options
// are valid.
bool ConvertRtcOptionsForOffer(
@@ -61,11 +56,11 @@ bool ConvertRtcOptionsForOffer(
bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
cricket::MediaSessionOptions* session_options);
-// Parses the URLs for each server in |servers| to build |stun_config| and
-// |turn_config|.
+// Parses the URLs for each server in |servers| to build |stun_servers| and
+// |turn_servers|.
bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
- StunConfigurations* stun_config,
- TurnConfigurations* turn_config);
+ cricket::ServerAddresses* stun_servers,
+ std::vector<cricket::RelayServerConfig>* turn_servers);
// PeerConnection implements the PeerConnectionInterface interface.
// It uses WebRtcSession to implement the PeerConnection functionality.
@@ -76,15 +71,6 @@ class PeerConnection : public PeerConnectionInterface,
public:
explicit PeerConnection(PeerConnectionFactory* factory);
- // TODO(deadbeef): Remove this overload of Initialize once everyone is moved
- // to the new version.
- bool Initialize(
- const PeerConnectionInterface::RTCConfiguration& configuration,
- const MediaConstraintsInterface* constraints,
- PortAllocatorFactoryInterface* allocator_factory,
- rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
- PeerConnectionObserver* observer);
-
bool Initialize(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
diff --git a/talk/app/webrtc/peerconnection_unittest.cc b/talk/app/webrtc/peerconnection_unittest.cc
index f7f8183221..a2780a36e1 100644
--- a/talk/app/webrtc/peerconnection_unittest.cc
+++ b/talk/app/webrtc/peerconnection_unittest.cc
@@ -35,7 +35,6 @@
#include "talk/app/webrtc/dtmfsender.h"
#include "talk/app/webrtc/fakemetricsobserver.h"
-#include "talk/app/webrtc/fakeportallocatorfactory.h"
#include "talk/app/webrtc/localaudiosource.h"
#include "talk/app/webrtc/mediastreaminterface.h"
#include "talk/app/webrtc/peerconnection.h"
@@ -59,6 +58,7 @@
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/p2p/base/constants.h"
#include "webrtc/p2p/base/sessiondescription.h"
+#include "webrtc/p2p/client/fakeportallocator.h"
#define MAYBE_SKIP_TEST(feature) \
if (!(feature())) { \
@@ -740,10 +740,8 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) {
EXPECT_TRUE(!peer_connection_);
EXPECT_TRUE(!peer_connection_factory_);
- allocator_factory_ = webrtc::FakePortAllocatorFactory::Create();
- if (!allocator_factory_) {
- return false;
- }
+ rtc::scoped_ptr<cricket::PortAllocator> port_allocator(
+ new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
fake_audio_capture_module_ = FakeAudioCaptureModule::Create();
if (fake_audio_capture_module_ == nullptr) {
@@ -762,23 +760,23 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
peer_connection_factory_->SetOptions(*options);
}
peer_connection_ = CreatePeerConnection(
- allocator_factory_.get(), constraints, std::move(dtls_identity_store));
+ std::move(port_allocator), constraints, std::move(dtls_identity_store));
return peer_connection_.get() != nullptr;
}
rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
- webrtc::PortAllocatorFactoryInterface* factory,
+ rtc::scoped_ptr<cricket::PortAllocator> port_allocator,
const MediaConstraintsInterface* constraints,
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) {
- // CreatePeerConnection with IceServers.
- webrtc::PeerConnectionInterface::IceServers ice_servers;
+ // CreatePeerConnection with RTCConfiguration.
+ webrtc::PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = "stun:stun.l.google.com:19302";
- ice_servers.push_back(ice_server);
+ config.servers.push_back(ice_server);
return peer_connection_factory_->CreatePeerConnection(
- ice_servers, constraints, factory, std::move(dtls_identity_store),
- this);
+ config, constraints, std::move(port_allocator),
+ std::move(dtls_identity_store), this);
}
void HandleIncomingOffer(const std::string& msg) {
@@ -885,7 +883,6 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
std::string id_;
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> allocator_factory_;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
peer_connection_factory_;
@@ -1865,38 +1862,37 @@ class IceServerParsingTest : public testing::Test {
server.username = username;
server.password = password;
servers.push_back(server);
- return webrtc::ParseIceServers(servers, &stun_configurations_,
- &turn_configurations_);
+ return webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_);
}
protected:
- webrtc::StunConfigurations stun_configurations_;
- webrtc::TurnConfigurations turn_configurations_;
+ cricket::ServerAddresses stun_servers_;
+ std::vector<cricket::RelayServerConfig> turn_servers_;
};
// Make sure all STUN/TURN prefixes are parsed correctly.
TEST_F(IceServerParsingTest, ParseStunPrefixes) {
EXPECT_TRUE(ParseUrl("stun:hostname"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ(0U, turn_configurations_.size());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ(0U, turn_servers_.size());
+ stun_servers_.clear();
EXPECT_TRUE(ParseUrl("stuns:hostname"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ(0U, turn_configurations_.size());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ(0U, turn_servers_.size());
+ stun_servers_.clear();
EXPECT_TRUE(ParseUrl("turn:hostname"));
- EXPECT_EQ(0U, stun_configurations_.size());
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_FALSE(turn_configurations_[0].secure);
- turn_configurations_.clear();
+ EXPECT_EQ(0U, stun_servers_.size());
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_FALSE(turn_servers_[0].ports[0].secure);
+ turn_servers_.clear();
EXPECT_TRUE(ParseUrl("turns:hostname"));
- EXPECT_EQ(0U, stun_configurations_.size());
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_TRUE(turn_configurations_[0].secure);
- turn_configurations_.clear();
+ EXPECT_EQ(0U, stun_servers_.size());
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_TRUE(turn_servers_[0].ports[0].secure);
+ turn_servers_.clear();
// invalid prefixes
EXPECT_FALSE(ParseUrl("stunn:hostname"));
@@ -1908,67 +1904,69 @@ TEST_F(IceServerParsingTest, ParseStunPrefixes) {
TEST_F(IceServerParsingTest, VerifyDefaults) {
// TURNS defaults
EXPECT_TRUE(ParseUrl("turns:hostname"));
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_EQ(5349, turn_configurations_[0].server.port());
- EXPECT_EQ("tcp", turn_configurations_[0].transport_type);
- turn_configurations_.clear();
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_EQ(5349, turn_servers_[0].ports[0].address.port());
+ EXPECT_EQ(cricket::PROTO_TCP, turn_servers_[0].ports[0].proto);
+ turn_servers_.clear();
// TURN defaults
EXPECT_TRUE(ParseUrl("turn:hostname"));
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_EQ(3478, turn_configurations_[0].server.port());
- EXPECT_EQ("udp", turn_configurations_[0].transport_type);
- turn_configurations_.clear();
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_EQ(3478, turn_servers_[0].ports[0].address.port());
+ EXPECT_EQ(cricket::PROTO_UDP, turn_servers_[0].ports[0].proto);
+ turn_servers_.clear();
// STUN defaults
EXPECT_TRUE(ParseUrl("stun:hostname"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ(3478, stun_configurations_[0].server.port());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ(3478, stun_servers_.begin()->port());
+ stun_servers_.clear();
}
// Check that the 6 combinations of IPv4/IPv6/hostname and with/without port
// can be parsed correctly.
TEST_F(IceServerParsingTest, ParseHostnameAndPort) {
EXPECT_TRUE(ParseUrl("stun:1.2.3.4:1234"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ("1.2.3.4", stun_configurations_[0].server.hostname());
- EXPECT_EQ(1234, stun_configurations_[0].server.port());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ("1.2.3.4", stun_servers_.begin()->hostname());
+ EXPECT_EQ(1234, stun_servers_.begin()->port());
+ stun_servers_.clear();
EXPECT_TRUE(ParseUrl("stun:[1:2:3:4:5:6:7:8]:4321"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ("1:2:3:4:5:6:7:8", stun_configurations_[0].server.hostname());
- EXPECT_EQ(4321, stun_configurations_[0].server.port());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ("1:2:3:4:5:6:7:8", stun_servers_.begin()->hostname());
+ EXPECT_EQ(4321, stun_servers_.begin()->port());
+ stun_servers_.clear();
EXPECT_TRUE(ParseUrl("stun:hostname:9999"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ("hostname", stun_configurations_[0].server.hostname());
- EXPECT_EQ(9999, stun_configurations_[0].server.port());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ("hostname", stun_servers_.begin()->hostname());
+ EXPECT_EQ(9999, stun_servers_.begin()->port());
+ stun_servers_.clear();
EXPECT_TRUE(ParseUrl("stun:1.2.3.4"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ("1.2.3.4", stun_configurations_[0].server.hostname());
- EXPECT_EQ(3478, stun_configurations_[0].server.port());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ("1.2.3.4", stun_servers_.begin()->hostname());
+ EXPECT_EQ(3478, stun_servers_.begin()->port());
+ stun_servers_.clear();
EXPECT_TRUE(ParseUrl("stun:[1:2:3:4:5:6:7:8]"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ("1:2:3:4:5:6:7:8", stun_configurations_[0].server.hostname());
- EXPECT_EQ(3478, stun_configurations_[0].server.port());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ("1:2:3:4:5:6:7:8", stun_servers_.begin()->hostname());
+ EXPECT_EQ(3478, stun_servers_.begin()->port());
+ stun_servers_.clear();
EXPECT_TRUE(ParseUrl("stun:hostname"));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ("hostname", stun_configurations_[0].server.hostname());
- EXPECT_EQ(3478, stun_configurations_[0].server.port());
- stun_configurations_.clear();
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ("hostname", stun_servers_.begin()->hostname());
+ EXPECT_EQ(3478, stun_servers_.begin()->port());
+ stun_servers_.clear();
// Try some invalid hostname:port strings.
EXPECT_FALSE(ParseUrl("stun:hostname:99a99"));
EXPECT_FALSE(ParseUrl("stun:hostname:-1"));
+ EXPECT_FALSE(ParseUrl("stun:hostname:port:more"));
+ EXPECT_FALSE(ParseUrl("stun:hostname:port more"));
EXPECT_FALSE(ParseUrl("stun:hostname:"));
EXPECT_FALSE(ParseUrl("stun:[1:2:3:4:5:6:7:8]junk:1000"));
EXPECT_FALSE(ParseUrl("stun::5555"));
@@ -1978,14 +1976,14 @@ TEST_F(IceServerParsingTest, ParseHostnameAndPort) {
// Test parsing the "?transport=xxx" part of the URL.
TEST_F(IceServerParsingTest, ParseTransport) {
EXPECT_TRUE(ParseUrl("turn:hostname:1234?transport=tcp"));
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_EQ("tcp", turn_configurations_[0].transport_type);
- turn_configurations_.clear();
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_EQ(cricket::PROTO_TCP, turn_servers_[0].ports[0].proto);
+ turn_servers_.clear();
EXPECT_TRUE(ParseUrl("turn:hostname?transport=udp"));
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_EQ("udp", turn_configurations_[0].transport_type);
- turn_configurations_.clear();
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_EQ(cricket::PROTO_UDP, turn_servers_[0].ports[0].proto);
+ turn_servers_.clear();
EXPECT_FALSE(ParseUrl("turn:hostname?transport=invalid"));
}
@@ -1993,9 +1991,9 @@ TEST_F(IceServerParsingTest, ParseTransport) {
// Test parsing ICE username contained in URL.
TEST_F(IceServerParsingTest, ParseUsername) {
EXPECT_TRUE(ParseUrl("turn:user@hostname"));
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_EQ("user", turn_configurations_[0].username);
- turn_configurations_.clear();
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_EQ("user", turn_servers_[0].credentials.username);
+ turn_servers_.clear();
EXPECT_FALSE(ParseUrl("turn:@hostname"));
EXPECT_FALSE(ParseUrl("turn:username@"));
@@ -2004,12 +2002,12 @@ TEST_F(IceServerParsingTest, ParseUsername) {
}
// Test that username and password from IceServer is copied into the resulting
-// TurnConfiguration.
+// RelayServerConfig.
TEST_F(IceServerParsingTest, CopyUsernameAndPasswordFromIceServer) {
EXPECT_TRUE(ParseUrl("turn:hostname", "username", "password"));
- EXPECT_EQ(1U, turn_configurations_.size());
- EXPECT_EQ("username", turn_configurations_[0].username);
- EXPECT_EQ("password", turn_configurations_[0].password);
+ EXPECT_EQ(1U, turn_servers_.size());
+ EXPECT_EQ("username", turn_servers_[0].credentials.username);
+ EXPECT_EQ("password", turn_servers_[0].credentials.password);
}
// Ensure that if a server has multiple URLs, each one is parsed.
@@ -2019,10 +2017,9 @@ TEST_F(IceServerParsingTest, ParseMultipleUrls) {
server.urls.push_back("stun:hostname");
server.urls.push_back("turn:hostname");
servers.push_back(server);
- EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_,
- &turn_configurations_));
- EXPECT_EQ(1U, stun_configurations_.size());
- EXPECT_EQ(1U, turn_configurations_.size());
+ EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
+ EXPECT_EQ(1U, stun_servers_.size());
+ EXPECT_EQ(1U, turn_servers_.size());
}
#endif // if !defined(THREAD_SANITIZER)
diff --git a/talk/app/webrtc/peerconnectionfactory.cc b/talk/app/webrtc/peerconnectionfactory.cc
index 6d36c8bc2f..c58f88cb41 100644
--- a/talk/app/webrtc/peerconnectionfactory.cc
+++ b/talk/app/webrtc/peerconnectionfactory.cc
@@ -37,7 +37,6 @@
#include "talk/app/webrtc/peerconnection.h"
#include "talk/app/webrtc/peerconnectionfactoryproxy.h"
#include "talk/app/webrtc/peerconnectionproxy.h"
-#include "talk/app/webrtc/portallocatorfactory.h"
#include "talk/app/webrtc/videosource.h"
#include "talk/app/webrtc/videosourceproxy.h"
#include "talk/app/webrtc/videotrack.h"
@@ -157,7 +156,6 @@ PeerConnectionFactory::PeerConnectionFactory(
PeerConnectionFactory::~PeerConnectionFactory() {
RTC_DCHECK(signaling_thread_->IsCurrent());
channel_manager_.reset(nullptr);
- default_allocator_factory_ = nullptr;
// Make sure |worker_thread_| and |signaling_thread_| outlive
// |dtls_identity_store_|, |default_socket_factory_| and
@@ -177,11 +175,6 @@ bool PeerConnectionFactory::Initialize() {
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::InitRandom(rtc::Time());
- default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_);
- if (!default_allocator_factory_) {
- return false;
- }
-
default_network_manager_.reset(new rtc::BasicNetworkManager());
if (!default_network_manager_) {
return false;
@@ -256,37 +249,6 @@ rtc::scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
- PortAllocatorFactoryInterface* allocator_factory,
- rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
- PeerConnectionObserver* observer) {
- RTC_DCHECK(signaling_thread_->IsCurrent());
- RTC_DCHECK(allocator_factory || default_allocator_factory_);
-
- if (!dtls_identity_store.get()) {
- // Because |pc|->Initialize takes ownership of the store we need a new
- // wrapper object that can be deleted without deleting the underlying
- // |dtls_identity_store_|, protecting it from being deleted multiple times.
- dtls_identity_store.reset(
- new DtlsIdentityStoreWrapper(dtls_identity_store_));
- }
-
- PortAllocatorFactoryInterface* chosen_allocator_factory =
- allocator_factory ? allocator_factory : default_allocator_factory_.get();
- chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask);
-
- rtc::scoped_refptr<PeerConnection> pc(
- new rtc::RefCountedObject<PeerConnection>(this));
- if (!pc->Initialize(configuration, constraints, chosen_allocator_factory,
- std::move(dtls_identity_store), observer)) {
- return NULL;
- }
- return PeerConnectionProxy::Create(signaling_thread(), pc);
-}
-
-rtc::scoped_refptr<PeerConnectionInterface>
-PeerConnectionFactory::CreatePeerConnection(
- const PeerConnectionInterface::RTCConfiguration& configuration,
- const MediaConstraintsInterface* constraints,
rtc::scoped_ptr<cricket::PortAllocator> allocator,
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
PeerConnectionObserver* observer) {
@@ -304,8 +266,7 @@ PeerConnectionFactory::CreatePeerConnection(
allocator.reset(new cricket::BasicPortAllocator(
default_network_manager_.get(), default_socket_factory_.get()));
}
- default_network_manager_->set_network_ignore_mask(
- options_.network_ignore_mask);
+ allocator->SetNetworkIgnoreMask(options_.network_ignore_mask);
rtc::scoped_refptr<PeerConnection> pc(
new rtc::RefCountedObject<PeerConnection>(this));
diff --git a/talk/app/webrtc/peerconnectionfactory.h b/talk/app/webrtc/peerconnectionfactory.h
index cad89d4ab5..8b274e118c 100644
--- a/talk/app/webrtc/peerconnectionfactory.h
+++ b/talk/app/webrtc/peerconnectionfactory.h
@@ -55,17 +55,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
options_ = options;
}
- // webrtc::PeerConnectionFactoryInterface override;
- // TODO(deadbeef): Get rid of this overload once clients are moved to the
- // new version.
- rtc::scoped_refptr<PeerConnectionInterface>
- CreatePeerConnection(
- const PeerConnectionInterface::RTCConfiguration& configuration,
- const MediaConstraintsInterface* constraints,
- PortAllocatorFactoryInterface* allocator_factory,
- rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
- PeerConnectionObserver* observer) override;
-
rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
@@ -121,7 +110,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
rtc::Thread* signaling_thread_;
rtc::Thread* worker_thread_;
Options options_;
- rtc::scoped_refptr<PortAllocatorFactoryInterface> default_allocator_factory_;
// External Audio device used for audio playback.
rtc::scoped_refptr<AudioDeviceModule> default_adm_;
rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
diff --git a/talk/app/webrtc/peerconnectionfactory_unittest.cc b/talk/app/webrtc/peerconnectionfactory_unittest.cc
index d0018d9897..050d5dbb12 100644
--- a/talk/app/webrtc/peerconnectionfactory_unittest.cc
+++ b/talk/app/webrtc/peerconnectionfactory_unittest.cc
@@ -28,7 +28,6 @@
#include <string>
#include <utility>
-#include "talk/app/webrtc/fakeportallocatorfactory.h"
#include "talk/app/webrtc/mediastreaminterface.h"
#include "talk/app/webrtc/peerconnectionfactory.h"
#include "talk/app/webrtc/test/fakedtlsidentitystore.h"
@@ -40,6 +39,7 @@
#include "webrtc/base/gunit.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread.h"
+#include "webrtc/p2p/client/fakeportallocator.h"
using webrtc::DataChannelInterface;
using webrtc::DtlsIdentityStoreInterface;
@@ -48,17 +48,11 @@ using webrtc::MediaStreamInterface;
using webrtc::PeerConnectionFactoryInterface;
using webrtc::PeerConnectionInterface;
using webrtc::PeerConnectionObserver;
-using webrtc::PortAllocatorFactoryInterface;
using webrtc::VideoSourceInterface;
using webrtc::VideoTrackInterface;
namespace {
-typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration>
- StunConfigurations;
-typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration>
- TurnConfigurations;
-
static const char kStunIceServer[] = "stun:stun.l.google.com:19302";
static const char kTurnIceServer[] = "turn:test%40hello.com@test.com:1234";
static const char kTurnIceServerWithTransport[] =
@@ -111,41 +105,39 @@ class PeerConnectionFactoryTest : public testing::Test {
NULL);
ASSERT_TRUE(factory_.get() != NULL);
- allocator_factory_ = webrtc::FakePortAllocatorFactory::Create();
+ port_allocator_.reset(
+ new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
+ raw_port_allocator_ = port_allocator_.get();
}
protected:
- void VerifyStunConfigurations(StunConfigurations stun_config) {
- webrtc::FakePortAllocatorFactory* allocator =
- static_cast<webrtc::FakePortAllocatorFactory*>(
- allocator_factory_.get());
- ASSERT_TRUE(allocator != NULL);
- EXPECT_EQ(stun_config.size(), allocator->stun_configs().size());
- for (size_t i = 0; i < stun_config.size(); ++i) {
- EXPECT_EQ(stun_config[i].server.ToString(),
- allocator->stun_configs()[i].server.ToString());
- }
+ void VerifyStunServers(cricket::ServerAddresses stun_servers) {
+ EXPECT_EQ(stun_servers, raw_port_allocator_->stun_servers());
}
- void VerifyTurnConfigurations(TurnConfigurations turn_config) {
- webrtc::FakePortAllocatorFactory* allocator =
- static_cast<webrtc::FakePortAllocatorFactory*>(
- allocator_factory_.get());
- ASSERT_TRUE(allocator != NULL);
- EXPECT_EQ(turn_config.size(), allocator->turn_configs().size());
- for (size_t i = 0; i < turn_config.size(); ++i) {
- EXPECT_EQ(turn_config[i].server.ToString(),
- allocator->turn_configs()[i].server.ToString());
- EXPECT_EQ(turn_config[i].username, allocator->turn_configs()[i].username);
- EXPECT_EQ(turn_config[i].password, allocator->turn_configs()[i].password);
- EXPECT_EQ(turn_config[i].transport_type,
- allocator->turn_configs()[i].transport_type);
+ void VerifyTurnServers(std::vector<cricket::RelayServerConfig> turn_servers) {
+ EXPECT_EQ(turn_servers.size(), raw_port_allocator_->turn_servers().size());
+ for (size_t i = 0; i < turn_servers.size(); ++i) {
+ ASSERT_EQ(1u, turn_servers[i].ports.size());
+ EXPECT_EQ(1u, raw_port_allocator_->turn_servers()[i].ports.size());
+ EXPECT_EQ(
+ turn_servers[i].ports[0].address.ToString(),
+ raw_port_allocator_->turn_servers()[i].ports[0].address.ToString());
+ EXPECT_EQ(turn_servers[i].ports[0].proto,
+ raw_port_allocator_->turn_servers()[i].ports[0].proto);
+ EXPECT_EQ(turn_servers[i].credentials.username,
+ raw_port_allocator_->turn_servers()[i].credentials.username);
+ EXPECT_EQ(turn_servers[i].credentials.password,
+ raw_port_allocator_->turn_servers()[i].credentials.password);
}
}
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_;
NullPeerConnectionObserver observer_;
- rtc::scoped_refptr<PortAllocatorFactoryInterface> allocator_factory_;
+ rtc::scoped_ptr<cricket::FakePortAllocator> port_allocator_;
+ // Since the PC owns the port allocator after it's been initialized,
+ // this should only be used when known to be safe.
+ cricket::FakePortAllocator* raw_port_allocator_;
};
// Verify creation of PeerConnection using internal ADM, video factory and
@@ -155,12 +147,12 @@ TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) {
webrtc::CreatePeerConnectionFactory());
NullPeerConnectionObserver observer;
- webrtc::PeerConnectionInterface::IceServers servers;
+ webrtc::PeerConnectionInterface::RTCConfiguration config;
rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store(
new FakeDtlsIdentityStore());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory->CreatePeerConnection(
- servers, nullptr, nullptr, std::move(dtls_identity_store), &observer));
+ config, nullptr, nullptr, std::move(dtls_identity_store), &observer));
EXPECT_TRUE(pc.get() != nullptr);
}
@@ -181,22 +173,21 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
new FakeDtlsIdentityStore());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
- config, nullptr, allocator_factory_.get(), std::move(dtls_identity_store),
- &observer_));
- EXPECT_TRUE(pc.get() != NULL);
- StunConfigurations stun_configs;
- webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
- "stun.l.google.com", 19302);
- stun_configs.push_back(stun1);
- VerifyStunConfigurations(stun_configs);
- TurnConfigurations turn_configs;
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
- "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false);
- turn_configs.push_back(turn1);
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
- "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
- turn_configs.push_back(turn2);
- VerifyTurnConfigurations(turn_configs);
+ config, nullptr, std::move(port_allocator_),
+ std::move(dtls_identity_store), &observer_));
+ ASSERT_TRUE(pc.get() != NULL);
+ cricket::ServerAddresses stun_servers;
+ rtc::SocketAddress stun1("stun.l.google.com", 19302);
+ stun_servers.insert(stun1);
+ VerifyStunServers(stun_servers);
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ cricket::RelayServerConfig turn1("test.com", 1234, "test@hello.com",
+ kTurnPassword, cricket::PROTO_UDP, false);
+ turn_servers.push_back(turn1);
+ cricket::RelayServerConfig turn2("hello.com", kDefaultStunPort, "test",
+ kTurnPassword, cricket::PROTO_TCP, false);
+ turn_servers.push_back(turn2);
+ VerifyTurnServers(turn_servers);
}
// This test verifies creation of PeerConnection with valid STUN and TURN
@@ -212,58 +203,21 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersUrls) {
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
new FakeDtlsIdentityStore());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
- config, nullptr, allocator_factory_.get(), std::move(dtls_identity_store),
- &observer_));
- EXPECT_TRUE(pc.get() != NULL);
- StunConfigurations stun_configs;
- webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
- "stun.l.google.com", 19302);
- stun_configs.push_back(stun1);
- VerifyStunConfigurations(stun_configs);
- TurnConfigurations turn_configs;
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
- "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false);
- turn_configs.push_back(turn1);
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
- "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
- turn_configs.push_back(turn2);
- VerifyTurnConfigurations(turn_configs);
-}
-
-// This test verifies creation of PeerConnection with valid STUN and TURN
-// configuration. Also verifies the URL's parsed correctly as expected.
-// This version doesn't use RTCConfiguration.
-// TODO(mallinath) - Remove this method after clients start using RTCConfig.
-TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersOldSignature) {
- webrtc::PeerConnectionInterface::IceServers ice_servers;
- webrtc::PeerConnectionInterface::IceServer ice_server;
- ice_server.uri = kStunIceServer;
- ice_servers.push_back(ice_server);
- ice_server.uri = kTurnIceServer;
- ice_server.password = kTurnPassword;
- ice_servers.push_back(ice_server);
- ice_server.uri = kTurnIceServerWithTransport;
- ice_server.password = kTurnPassword;
- ice_servers.push_back(ice_server);
- rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
- new FakeDtlsIdentityStore());
- rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
- ice_servers, nullptr, allocator_factory_.get(),
+ config, nullptr, std::move(port_allocator_),
std::move(dtls_identity_store), &observer_));
- EXPECT_TRUE(pc.get() != NULL);
- StunConfigurations stun_configs;
- webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
- "stun.l.google.com", 19302);
- stun_configs.push_back(stun1);
- VerifyStunConfigurations(stun_configs);
- TurnConfigurations turn_configs;
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
- "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false);
- turn_configs.push_back(turn1);
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
- "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
- turn_configs.push_back(turn2);
- VerifyTurnConfigurations(turn_configs);
+ ASSERT_TRUE(pc.get() != NULL);
+ cricket::ServerAddresses stun_servers;
+ rtc::SocketAddress stun1("stun.l.google.com", 19302);
+ stun_servers.insert(stun1);
+ VerifyStunServers(stun_servers);
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ cricket::RelayServerConfig turn1("test.com", 1234, "test@hello.com",
+ kTurnPassword, cricket::PROTO_UDP, false);
+ turn_servers.push_back(turn1);
+ cricket::RelayServerConfig turn2("hello.com", kDefaultStunPort, "test",
+ kTurnPassword, cricket::PROTO_TCP, false);
+ turn_servers.push_back(turn2);
+ VerifyTurnServers(turn_servers);
}
TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
@@ -278,14 +232,14 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
new FakeDtlsIdentityStore());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
- config, nullptr, allocator_factory_.get(), std::move(dtls_identity_store),
- &observer_));
- EXPECT_TRUE(pc.get() != NULL);
- TurnConfigurations turn_configs;
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn(
- "test.com", 1234, kTurnUsername, kTurnPassword, "udp", false);
- turn_configs.push_back(turn);
- VerifyTurnConfigurations(turn_configs);
+ config, nullptr, std::move(port_allocator_),
+ std::move(dtls_identity_store), &observer_));
+ ASSERT_TRUE(pc.get() != NULL);
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ cricket::RelayServerConfig turn("test.com", 1234, kTurnUsername,
+ kTurnPassword, cricket::PROTO_UDP, false);
+ turn_servers.push_back(turn);
+ VerifyTurnServers(turn_servers);
}
// This test verifies the PeerConnection created properly with TURN url which
@@ -299,14 +253,14 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
new FakeDtlsIdentityStore());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
- config, nullptr, allocator_factory_.get(), std::move(dtls_identity_store),
- &observer_));
- EXPECT_TRUE(pc.get() != NULL);
- TurnConfigurations turn_configs;
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn(
- "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
- turn_configs.push_back(turn);
- VerifyTurnConfigurations(turn_configs);
+ config, nullptr, std::move(port_allocator_),
+ std::move(dtls_identity_store), &observer_));
+ ASSERT_TRUE(pc.get() != NULL);
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ cricket::RelayServerConfig turn("hello.com", kDefaultStunPort, "test",
+ kTurnPassword, cricket::PROTO_TCP, false);
+ turn_servers.push_back(turn);
+ VerifyTurnServers(turn_servers);
}
TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
@@ -324,22 +278,22 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
new FakeDtlsIdentityStore());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
- config, nullptr, allocator_factory_.get(), std::move(dtls_identity_store),
- &observer_));
- EXPECT_TRUE(pc.get() != NULL);
- TurnConfigurations turn_configs;
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
- "hello.com", kDefaultStunTlsPort, "test", kTurnPassword, "tcp", true);
- turn_configs.push_back(turn1);
+ config, nullptr, std::move(port_allocator_),
+ std::move(dtls_identity_store), &observer_));
+ ASSERT_TRUE(pc.get() != NULL);
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ cricket::RelayServerConfig turn1("hello.com", kDefaultStunTlsPort, "test",
+ kTurnPassword, cricket::PROTO_TCP, true);
+ turn_servers.push_back(turn1);
// TURNS with transport param should be default to tcp.
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
- "hello.com", 443, "test_no_transport", kTurnPassword, "tcp", true);
- turn_configs.push_back(turn2);
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn3(
- "hello.com", kDefaultStunTlsPort, "test_no_transport",
- kTurnPassword, "tcp", true);
- turn_configs.push_back(turn3);
- VerifyTurnConfigurations(turn_configs);
+ cricket::RelayServerConfig turn2("hello.com", 443, "test_no_transport",
+ kTurnPassword, cricket::PROTO_TCP, true);
+ turn_servers.push_back(turn2);
+ cricket::RelayServerConfig turn3("hello.com", kDefaultStunTlsPort,
+ "test_no_transport", kTurnPassword,
+ cricket::PROTO_TCP, true);
+ turn_servers.push_back(turn3);
+ VerifyTurnServers(turn_servers);
}
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
@@ -359,29 +313,25 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
new FakeDtlsIdentityStore());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
- config, nullptr, allocator_factory_.get(), std::move(dtls_identity_store),
- &observer_));
- EXPECT_TRUE(pc.get() != NULL);
- StunConfigurations stun_configs;
- webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
- "1.2.3.4", 1234);
- stun_configs.push_back(stun1);
- webrtc::PortAllocatorFactoryInterface::StunConfiguration stun2(
- "1.2.3.4", 3478);
- stun_configs.push_back(stun2); // Default port
- webrtc::PortAllocatorFactoryInterface::StunConfiguration stun3(
- "2401:fa00:4::", 1234);
- stun_configs.push_back(stun3);
- webrtc::PortAllocatorFactoryInterface::StunConfiguration stun4(
- "2401:fa00:4::", 3478);
- stun_configs.push_back(stun4); // Default port
- VerifyStunConfigurations(stun_configs);
+ config, nullptr, std::move(port_allocator_),
+ std::move(dtls_identity_store), &observer_));
+ ASSERT_TRUE(pc.get() != NULL);
+ cricket::ServerAddresses stun_servers;
+ rtc::SocketAddress stun1("1.2.3.4", 1234);
+ stun_servers.insert(stun1);
+ rtc::SocketAddress stun2("1.2.3.4", 3478);
+ stun_servers.insert(stun2); // Default port
+ rtc::SocketAddress stun3("2401:fa00:4::", 1234);
+ stun_servers.insert(stun3);
+ rtc::SocketAddress stun4("2401:fa00:4::", 3478);
+ stun_servers.insert(stun4); // Default port
+ VerifyStunServers(stun_servers);
- TurnConfigurations turn_configs;
- webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
- "2401:fa00:4::", 1234, "test", kTurnPassword, "udp", false);
- turn_configs.push_back(turn1);
- VerifyTurnConfigurations(turn_configs);
+ std::vector<cricket::RelayServerConfig> turn_servers;
+ cricket::RelayServerConfig turn1("2401:fa00:4::", 1234, "test", kTurnPassword,
+ cricket::PROTO_UDP, false);
+ turn_servers.push_back(turn1);
+ VerifyTurnServers(turn_servers);
}
// This test verifies the captured stream is rendered locally using a
diff --git a/talk/app/webrtc/peerconnectionfactoryproxy.h b/talk/app/webrtc/peerconnectionfactoryproxy.h
index db34ea72ce..714ce6b7eb 100644
--- a/talk/app/webrtc/peerconnectionfactoryproxy.h
+++ b/talk/app/webrtc/peerconnectionfactoryproxy.h
@@ -44,21 +44,11 @@ BEGIN_PROXY_MAP(PeerConnectionFactory)
rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& a1,
const MediaConstraintsInterface* a2,
- PortAllocatorFactoryInterface* a3,
- rtc::scoped_ptr<DtlsIdentityStoreInterface> a4,
- PeerConnectionObserver* a5) override {
- return owner_thread_->Invoke<rtc::scoped_refptr<PeerConnectionInterface>>(
- rtc::Bind(&PeerConnectionFactoryProxy::CreatePeerConnection_ot1, this,
- a1, a2, a3, a4.release(), a5));
- }
- rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
- const PeerConnectionInterface::RTCConfiguration& a1,
- const MediaConstraintsInterface* a2,
rtc::scoped_ptr<cricket::PortAllocator> a3,
rtc::scoped_ptr<DtlsIdentityStoreInterface> a4,
PeerConnectionObserver* a5) override {
return owner_thread_->Invoke<rtc::scoped_refptr<PeerConnectionInterface>>(
- rtc::Bind(&PeerConnectionFactoryProxy::CreatePeerConnection_ot2, this,
+ rtc::Bind(&PeerConnectionFactoryProxy::CreatePeerConnection_ot, this,
a1, a2, a3.release(), a4.release(), a5));
}
PROXY_METHOD1(rtc::scoped_refptr<MediaStreamInterface>,
@@ -78,17 +68,7 @@ BEGIN_PROXY_MAP(PeerConnectionFactory)
PROXY_METHOD0(void, StopRtcEventLog)
private:
- rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_ot1(
- const PeerConnectionInterface::RTCConfiguration& a1,
- const MediaConstraintsInterface* a2,
- PortAllocatorFactoryInterface* a3,
- DtlsIdentityStoreInterface* a4,
- PeerConnectionObserver* a5) {
- rtc::scoped_ptr<DtlsIdentityStoreInterface> ptr_a4(a4);
- return c_->CreatePeerConnection(a1, a2, a3, std::move(ptr_a4), a5);
- }
-
- rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_ot2(
+ rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_ot(
const PeerConnectionInterface::RTCConfiguration& a1,
const MediaConstraintsInterface* a2,
cricket::PortAllocator* a3,
diff --git a/talk/app/webrtc/peerconnectioninterface.h b/talk/app/webrtc/peerconnectioninterface.h
index 46481768b9..93f6241156 100644
--- a/talk/app/webrtc/peerconnectioninterface.h
+++ b/talk/app/webrtc/peerconnectioninterface.h
@@ -489,51 +489,6 @@ class PeerConnectionObserver {
~PeerConnectionObserver() {}
};
-// Factory class used for creating cricket::PortAllocator that is used
-// for ICE negotiation.
-class PortAllocatorFactoryInterface : public rtc::RefCountInterface {
- public:
- struct StunConfiguration {
- StunConfiguration(const std::string& address, int port)
- : server(address, port) {}
- // STUN server address and port.
- rtc::SocketAddress server;
- };
-
- struct TurnConfiguration {
- TurnConfiguration(const std::string& address,
- int port,
- const std::string& username,
- const std::string& password,
- const std::string& transport_type,
- bool secure)
- : server(address, port),
- username(username),
- password(password),
- transport_type(transport_type),
- secure(secure) {}
- rtc::SocketAddress server;
- std::string username;
- std::string password;
- std::string transport_type;
- bool secure;
- };
-
- virtual cricket::PortAllocator* CreatePortAllocator(
- const std::vector<StunConfiguration>& stun_servers,
- const std::vector<TurnConfiguration>& turn_configurations) = 0;
-
- // TODO(phoglund): Make pure virtual when Chrome's factory implements this.
- // After this method is called, the port allocator should consider loopback
- // network interfaces as well.
- virtual void SetNetworkIgnoreMask(int network_ignore_mask) {
- }
-
- protected:
- PortAllocatorFactoryInterface() {}
- ~PortAllocatorFactoryInterface() {}
-};
-
// PeerConnectionFactoryInterface is the factory interface use for creating
// PeerConnection, MediaStream and media tracks.
// PeerConnectionFactoryInterface will create required libjingle threads,
@@ -541,7 +496,7 @@ class PortAllocatorFactoryInterface : public rtc::RefCountInterface {
// If an application decides to provide its own threads and network
// implementation of these classes it should use the alternate
// CreatePeerConnectionFactory method which accepts threads as input and use the
-// CreatePeerConnection version that takes a PortAllocatorFactoryInterface as
+// CreatePeerConnection version that takes a PortAllocator as an
// argument.
class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
public:
@@ -571,45 +526,12 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
virtual void SetOptions(const Options& options) = 0;
- // TODO(deadbeef): Remove this overload of CreatePeerConnection once clients
- // are moved to the new version.
- virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
- const PeerConnectionInterface::RTCConfiguration& configuration,
- const MediaConstraintsInterface* constraints,
- PortAllocatorFactoryInterface* allocator_factory,
- rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
- PeerConnectionObserver* observer) {
- return nullptr;
- }
-
- // TODO(deadbeef): Make this pure virtual once it's implemented by all
- // subclasses.
virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
rtc::scoped_ptr<cricket::PortAllocator> allocator,
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
- PeerConnectionObserver* observer) {
- return nullptr;
- }
-
- // TODO(hbos): Remove below version after clients are updated to above method.
- // In latest W3C WebRTC draft, PC constructor will take RTCConfiguration,
- // and not IceServers. RTCConfiguration is made up of ice servers and
- // ice transport type.
- // http://dev.w3.org/2011/webrtc/editor/webrtc.html
- inline rtc::scoped_refptr<PeerConnectionInterface>
- CreatePeerConnection(
- const PeerConnectionInterface::IceServers& servers,
- const MediaConstraintsInterface* constraints,
- PortAllocatorFactoryInterface* allocator_factory,
- rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
- PeerConnectionObserver* observer) {
- PeerConnectionInterface::RTCConfiguration rtc_config;
- rtc_config.servers = servers;
- return CreatePeerConnection(rtc_config, constraints, allocator_factory,
- std::move(dtls_identity_store), observer);
- }
+ PeerConnectionObserver* observer) = 0;
virtual rtc::scoped_refptr<MediaStreamInterface>
CreateLocalMediaStream(const std::string& label) = 0;
diff --git a/talk/app/webrtc/peerconnectioninterface_unittest.cc b/talk/app/webrtc/peerconnectioninterface_unittest.cc
index 098f8aee69..7b49e45874 100644
--- a/talk/app/webrtc/peerconnectioninterface_unittest.cc
+++ b/talk/app/webrtc/peerconnectioninterface_unittest.cc
@@ -29,7 +29,6 @@
#include <utility>
#include "talk/app/webrtc/audiotrack.h"
-#include "talk/app/webrtc/fakeportallocatorfactory.h"
#include "talk/app/webrtc/jsepsessiondescription.h"
#include "talk/app/webrtc/mediastream.h"
#include "talk/app/webrtc/mediastreaminterface.h"
@@ -53,6 +52,7 @@
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/thread.h"
+#include "webrtc/p2p/client/fakeportallocator.h"
static const char kStreamLabel1[] = "local_stream_1";
static const char kStreamLabel2[] = "local_stream_2";
@@ -259,7 +259,6 @@ using webrtc::AudioTrackInterface;
using webrtc::DataBuffer;
using webrtc::DataChannelInterface;
using webrtc::FakeConstraints;
-using webrtc::FakePortAllocatorFactory;
using webrtc::IceCandidateInterface;
using webrtc::MediaConstraintsInterface;
using webrtc::MediaStream;
@@ -271,7 +270,6 @@ using webrtc::MockSetSessionDescriptionObserver;
using webrtc::MockStatsObserver;
using webrtc::PeerConnectionInterface;
using webrtc::PeerConnectionObserver;
-using webrtc::PortAllocatorFactoryInterface;
using webrtc::RtpReceiverInterface;
using webrtc::RtpSenderInterface;
using webrtc::SdpParseError;
@@ -534,15 +532,17 @@ class PeerConnectionInterfaceTest : public testing::Test {
void CreatePeerConnection(const std::string& uri,
const std::string& password,
webrtc::MediaConstraintsInterface* constraints) {
+ PeerConnectionInterface::RTCConfiguration config;
PeerConnectionInterface::IceServer server;
- PeerConnectionInterface::IceServers servers;
if (!uri.empty()) {
server.uri = uri;
server.password = password;
- servers.push_back(server);
+ config.servers.push_back(server);
}
- port_allocator_factory_ = FakePortAllocatorFactory::Create();
+ rtc::scoped_ptr<cricket::FakePortAllocator> port_allocator(
+ new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
+ port_allocator_ = port_allocator.get();
// DTLS does not work in a loopback call, so is disabled for most of the
// tests in this file. We only create a FakeIdentityService if the test
@@ -564,7 +564,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
dtls_identity_store.reset(new FakeDtlsIdentityStore());
}
pc_ = pc_factory_->CreatePeerConnection(
- servers, constraints, port_allocator_factory_.get(),
+ config, constraints, std::move(port_allocator),
std::move(dtls_identity_store), &observer_);
ASSERT_TRUE(pc_.get() != NULL);
observer_.SetPeerConnectionInterface(pc_.get());
@@ -572,42 +572,38 @@ class PeerConnectionInterfaceTest : public testing::Test {
}
void CreatePeerConnectionExpectFail(const std::string& uri) {
+ PeerConnectionInterface::RTCConfiguration config;
PeerConnectionInterface::IceServer server;
- PeerConnectionInterface::IceServers servers;
server.uri = uri;
- servers.push_back(server);
+ config.servers.push_back(server);
- scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store;
- port_allocator_factory_ = FakePortAllocatorFactory::Create();
scoped_refptr<PeerConnectionInterface> pc;
- pc = pc_factory_->CreatePeerConnection(
- servers, nullptr, port_allocator_factory_.get(),
- std::move(dtls_identity_store), &observer_);
- ASSERT_EQ(nullptr, pc);
+ pc = pc_factory_->CreatePeerConnection(config, nullptr, nullptr, nullptr,
+ &observer_);
+ EXPECT_EQ(nullptr, pc);
}
void CreatePeerConnectionWithDifferentConfigurations() {
CreatePeerConnection(kStunAddressOnly, "", NULL);
- EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size());
- EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size());
- EXPECT_EQ("address",
- port_allocator_factory_->stun_configs()[0].server.hostname());
+ EXPECT_EQ(1u, port_allocator_->stun_servers().size());
+ EXPECT_EQ(0u, port_allocator_->turn_servers().size());
+ EXPECT_EQ("address", port_allocator_->stun_servers().begin()->hostname());
EXPECT_EQ(kDefaultStunPort,
- port_allocator_factory_->stun_configs()[0].server.port());
+ port_allocator_->stun_servers().begin()->port());
CreatePeerConnectionExpectFail(kStunInvalidPort);
CreatePeerConnectionExpectFail(kStunAddressPortAndMore1);
CreatePeerConnectionExpectFail(kStunAddressPortAndMore2);
CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL);
- EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size());
- EXPECT_EQ(1u, port_allocator_factory_->turn_configs().size());
+ EXPECT_EQ(0u, port_allocator_->stun_servers().size());
+ EXPECT_EQ(1u, port_allocator_->turn_servers().size());
EXPECT_EQ(kTurnUsername,
- port_allocator_factory_->turn_configs()[0].username);
+ port_allocator_->turn_servers()[0].credentials.username);
EXPECT_EQ(kTurnPassword,
- port_allocator_factory_->turn_configs()[0].password);
+ port_allocator_->turn_servers()[0].credentials.password);
EXPECT_EQ(kTurnHostname,
- port_allocator_factory_->turn_configs()[0].server.hostname());
+ port_allocator_->turn_servers()[0].ports[0].address.hostname());
}
void ReleasePeerConnection() {
@@ -926,7 +922,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
ASSERT_TRUE(stream->AddTrack(video_track));
}
- scoped_refptr<FakePortAllocatorFactory> port_allocator_factory_;
+ cricket::FakePortAllocator* port_allocator_ = nullptr;
scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
scoped_refptr<PeerConnectionInterface> pc_;
MockPeerConnectionObserver observer_;
@@ -1729,10 +1725,9 @@ TEST_F(PeerConnectionInterfaceTest, SetConfigurationChangesIceServers) {
config.servers.push_back(server);
EXPECT_TRUE(pc_->SetConfiguration(config));
- cricket::FakePortAllocator* allocator =
- port_allocator_factory_->last_created_allocator();
- EXPECT_EQ(1u, allocator->stun_servers().size());
- EXPECT_EQ("test_hostname", allocator->stun_servers().begin()->hostname());
+ EXPECT_EQ(1u, port_allocator_->stun_servers().size());
+ EXPECT_EQ("test_hostname",
+ port_allocator_->stun_servers().begin()->hostname());
}
// Test that PeerConnection::Close changes the states to closed and all remote
diff --git a/talk/app/webrtc/portallocatorfactory.cc b/talk/app/webrtc/portallocatorfactory.cc
index 33e0e63102..64d714cd50 100644
--- a/talk/app/webrtc/portallocatorfactory.cc
+++ b/talk/app/webrtc/portallocatorfactory.cc
@@ -1,6 +1,6 @@
/*
* libjingle
- * Copyright 2004--2011 Google Inc.
+ * Copyright 2011 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -24,69 +24,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+// TODO(deadbeef): Remove this file once chromium build files no longer
+// reference it.
#include "talk/app/webrtc/portallocatorfactory.h"
-
-#include "webrtc/p2p/base/basicpacketsocketfactory.h"
-#include "webrtc/p2p/client/basicportallocator.h"
-#include "webrtc/base/logging.h"
-#include "webrtc/base/network.h"
-#include "webrtc/base/thread.h"
-
-namespace webrtc {
-
-using rtc::scoped_ptr;
-
-rtc::scoped_refptr<PortAllocatorFactoryInterface>
-PortAllocatorFactory::Create(
- rtc::Thread* worker_thread) {
- rtc::RefCountedObject<PortAllocatorFactory>* allocator =
- new rtc::RefCountedObject<PortAllocatorFactory>(worker_thread);
- return allocator;
-}
-
-PortAllocatorFactory::PortAllocatorFactory(rtc::Thread* worker_thread)
- : network_manager_(new rtc::BasicNetworkManager()),
- socket_factory_(new rtc::BasicPacketSocketFactory(worker_thread)) {
-}
-
-PortAllocatorFactory::~PortAllocatorFactory() {}
-
-void PortAllocatorFactory::SetNetworkIgnoreMask(int network_ignore_mask) {
- network_manager_->set_network_ignore_mask(network_ignore_mask);
-}
-
-cricket::PortAllocator* PortAllocatorFactory::CreatePortAllocator(
- const std::vector<StunConfiguration>& stun,
- const std::vector<TurnConfiguration>& turn) {
- cricket::ServerAddresses stun_hosts;
- typedef std::vector<StunConfiguration>::const_iterator StunIt;
- for (StunIt stun_it = stun.begin(); stun_it != stun.end(); ++stun_it) {
- stun_hosts.insert(stun_it->server);
- }
-
- scoped_ptr<cricket::BasicPortAllocator> allocator(
- new cricket::BasicPortAllocator(
- network_manager_.get(), socket_factory_.get(), stun_hosts));
-
- for (size_t i = 0; i < turn.size(); ++i) {
- cricket::RelayCredentials credentials(turn[i].username, turn[i].password);
- cricket::RelayServerConfig turn_server(cricket::RELAY_TURN);
- cricket::ProtocolType protocol;
- if (cricket::StringToProto(turn[i].transport_type.c_str(), &protocol)) {
- turn_server.ports.push_back(
- cricket::ProtocolAddress(turn[i].server, protocol, turn[i].secure));
- turn_server.credentials = credentials;
- // First in the list gets highest priority.
- turn_server.priority = static_cast<int>(turn.size() - i - 1);
- allocator->AddTurnServer(turn_server);
- } else {
- LOG(LS_WARNING) << "Ignoring TURN server " << turn[i].server << ". "
- << "Reason= Incorrect " << turn[i].transport_type
- << " transport parameter.";
- }
- }
- return allocator.release();
-}
-
-} // namespace webrtc
diff --git a/talk/app/webrtc/portallocatorfactory.h b/talk/app/webrtc/portallocatorfactory.h
index 83376d0b84..bb6cf4741f 100644
--- a/talk/app/webrtc/portallocatorfactory.h
+++ b/talk/app/webrtc/portallocatorfactory.h
@@ -24,49 +24,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-// This file defines the default implementation of
-// PortAllocatorFactoryInterface.
-// This implementation creates instances of cricket::HTTPPortAllocator and uses
-// the BasicNetworkManager and BasicPacketSocketFactory.
+// TODO(deadbeef): Remove this file once chromium build files no longer
+// reference it.
#ifndef TALK_APP_WEBRTC_PORTALLOCATORFACTORY_H_
#define TALK_APP_WEBRTC_PORTALLOCATORFACTORY_H_
-#include "talk/app/webrtc/peerconnectioninterface.h"
-#include "webrtc/base/scoped_ptr.h"
-
-namespace cricket {
-class PortAllocator;
-}
-
-namespace rtc {
-class BasicNetworkManager;
-class BasicPacketSocketFactory;
-}
-
-namespace webrtc {
-
-class PortAllocatorFactory : public PortAllocatorFactoryInterface {
- public:
- static rtc::scoped_refptr<PortAllocatorFactoryInterface> Create(
- rtc::Thread* worker_thread);
-
- virtual cricket::PortAllocator* CreatePortAllocator(
- const std::vector<StunConfiguration>& stun,
- const std::vector<TurnConfiguration>& turn);
-
- virtual void SetNetworkIgnoreMask(int network_ignore_mask);
-
- protected:
- explicit PortAllocatorFactory(rtc::Thread* worker_thread);
- ~PortAllocatorFactory();
-
- private:
- rtc::scoped_ptr<rtc::BasicNetworkManager> network_manager_;
- rtc::scoped_ptr<rtc::BasicPacketSocketFactory> socket_factory_;
-};
-
-} // namespace webrtc
-
#endif // TALK_APP_WEBRTC_PORTALLOCATORFACTORY_H_
diff --git a/talk/app/webrtc/test/peerconnectiontestwrapper.cc b/talk/app/webrtc/test/peerconnectiontestwrapper.cc
index 032044c36e..86b7842517 100644
--- a/talk/app/webrtc/test/peerconnectiontestwrapper.cc
+++ b/talk/app/webrtc/test/peerconnectiontestwrapper.cc
@@ -27,13 +27,13 @@
#include <utility>
-#include "talk/app/webrtc/fakeportallocatorfactory.h"
#include "talk/app/webrtc/test/fakedtlsidentitystore.h"
#include "talk/app/webrtc/test/fakeperiodicvideocapturer.h"
#include "talk/app/webrtc/test/mockpeerconnectionobservers.h"
#include "talk/app/webrtc/test/peerconnectiontestwrapper.h"
#include "talk/app/webrtc/videosourceinterface.h"
#include "webrtc/base/gunit.h"
+#include "webrtc/p2p/client/fakeportallocator.h"
static const char kStreamLabelBase[] = "stream_label";
static const char kVideoTrackLabelBase[] = "video_track";
@@ -72,10 +72,8 @@ PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {}
bool PeerConnectionTestWrapper::CreatePc(
const MediaConstraintsInterface* constraints) {
- allocator_factory_ = webrtc::FakePortAllocatorFactory::Create();
- if (!allocator_factory_) {
- return false;
- }
+ rtc::scoped_ptr<cricket::PortAllocator> port_allocator(
+ new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
fake_audio_capture_module_ = FakeAudioCaptureModule::Create();
if (fake_audio_capture_module_ == NULL) {
@@ -89,16 +87,16 @@ bool PeerConnectionTestWrapper::CreatePc(
return false;
}
- // CreatePeerConnection with IceServers.
- webrtc::PeerConnectionInterface::IceServers ice_servers;
+ // CreatePeerConnection with RTCConfiguration.
+ webrtc::PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = "stun:stun.l.google.com:19302";
- ice_servers.push_back(ice_server);
+ config.servers.push_back(ice_server);
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ?
new FakeDtlsIdentityStore() : nullptr);
peer_connection_ = peer_connection_factory_->CreatePeerConnection(
- ice_servers, constraints, allocator_factory_.get(),
+ config, constraints, std::move(port_allocator),
std::move(dtls_identity_store), this);
return peer_connection_.get() != NULL;
diff --git a/talk/app/webrtc/test/peerconnectiontestwrapper.h b/talk/app/webrtc/test/peerconnectiontestwrapper.h
index b65426326f..883f2f2454 100644
--- a/talk/app/webrtc/test/peerconnectiontestwrapper.h
+++ b/talk/app/webrtc/test/peerconnectiontestwrapper.h
@@ -34,11 +34,6 @@
#include "talk/app/webrtc/test/fakevideotrackrenderer.h"
#include "webrtc/base/sigslot.h"
-namespace webrtc {
-class DtlsIdentityStoreInterface;
-class PortAllocatorFactoryInterface;
-}
-
class PeerConnectionTestWrapper
: public webrtc::PeerConnectionObserver,
public webrtc::CreateSessionDescriptionObserver,
@@ -110,8 +105,6 @@ class PeerConnectionTestWrapper
bool video, const webrtc::FakeConstraints& video_constraints);
std::string name_;
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
- allocator_factory_;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
peer_connection_factory_;
diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp
index e3480ca7a6..afde2fa992 100755
--- a/talk/libjingle.gyp
+++ b/talk/libjingle.gyp
@@ -731,7 +731,6 @@
'app/webrtc/dtmfsender.cc',
'app/webrtc/dtmfsender.h',
'app/webrtc/dtmfsenderinterface.h',
- 'app/webrtc/fakeportallocatorfactory.h',
'app/webrtc/jsep.h',
'app/webrtc/jsepicecandidate.cc',
'app/webrtc/jsepicecandidate.h',
@@ -760,8 +759,6 @@
'app/webrtc/peerconnectionfactoryproxy.h',
'app/webrtc/peerconnectioninterface.h',
'app/webrtc/peerconnectionproxy.h',
- 'app/webrtc/portallocatorfactory.cc',
- 'app/webrtc/portallocatorfactory.h',
'app/webrtc/proxy.h',
'app/webrtc/remoteaudiosource.cc',
'app/webrtc/remoteaudiosource.h',