summaryrefslogtreecommitdiffstats
path: root/remoting/protocol
diff options
context:
space:
mode:
authordeadbeef <deadbeef@chromium.org>2015-12-10 16:24:50 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-11 00:26:24 +0000
commitad868b5edf13e869e835b847078b4dcc8aa7cd0d (patch)
tree8ab37dd4322745232c5a03bf4803b17b67c9dd31 /remoting/protocol
parentacd148966bcdf4087db82bbaac36b8ea082faa53 (diff)
downloadchromium_src-ad868b5edf13e869e835b847078b4dcc8aa7cd0d.zip
chromium_src-ad868b5edf13e869e835b847078b4dcc8aa7cd0d.tar.gz
chromium_src-ad868b5edf13e869e835b847078b4dcc8aa7cd0d.tar.bz2
Removing references to webrtc::PortAllocatorFactoryInterface.
Now using a new CreatePeerConnection method that takes a PortAllocator as input. This removes the need for some boilerplate code and code duplication between webrtc and chromium. It also fixes an issue with TURN candidate priorities. BUG=webrtc:5209 Review URL: https://codereview.chromium.org/1500663003 Cr-Commit-Position: refs/heads/master@{#364544}
Diffstat (limited to 'remoting/protocol')
-rw-r--r--remoting/protocol/chromium_port_allocator.h5
-rw-r--r--remoting/protocol/chromium_port_allocator_factory.cc24
-rw-r--r--remoting/protocol/chromium_port_allocator_factory.h14
-rw-r--r--remoting/protocol/port_allocator_factory.h25
-rw-r--r--remoting/protocol/webrtc_transport.cc22
-rw-r--r--remoting/protocol/webrtc_transport.h14
6 files changed, 53 insertions, 51 deletions
diff --git a/remoting/protocol/chromium_port_allocator.h b/remoting/protocol/chromium_port_allocator.h
index a2b759c..021000e 100644
--- a/remoting/protocol/chromium_port_allocator.h
+++ b/remoting/protocol/chromium_port_allocator.h
@@ -9,12 +9,9 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "net/url_request/url_request_context_getter.h"
#include "third_party/webrtc/p2p/client/httpportallocator.h"
-namespace net {
-class URLRequestContextGetter;
-} // namespace net
-
namespace remoting {
namespace protocol {
diff --git a/remoting/protocol/chromium_port_allocator_factory.cc b/remoting/protocol/chromium_port_allocator_factory.cc
index b262611..32c980b 100644
--- a/remoting/protocol/chromium_port_allocator_factory.cc
+++ b/remoting/protocol/chromium_port_allocator_factory.cc
@@ -20,33 +20,17 @@ ChromiumPortAllocatorFactory::ChromiumPortAllocatorFactory(
ChromiumPortAllocatorFactory::~ChromiumPortAllocatorFactory() {}
-rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
-ChromiumPortAllocatorFactory::Create(
+scoped_ptr<PortAllocatorFactory> ChromiumPortAllocatorFactory::Create(
const NetworkSettings& network_settings,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) {
- rtc::RefCountedObject<ChromiumPortAllocatorFactory>* allocator_factory =
- new rtc::RefCountedObject<ChromiumPortAllocatorFactory>(
- network_settings, url_request_context_getter);
- return allocator_factory;
+ return scoped_ptr<PortAllocatorFactory>(new ChromiumPortAllocatorFactory(
+ network_settings, url_request_context_getter));
}
-cricket::PortAllocator* ChromiumPortAllocatorFactory::CreatePortAllocator(
- const std::vector<StunConfiguration>& stun_servers,
- const std::vector<TurnConfiguration>& turn_configurations) {
+cricket::PortAllocator* ChromiumPortAllocatorFactory::CreatePortAllocator() {
scoped_ptr<ChromiumPortAllocator> port_allocator(
ChromiumPortAllocator::Create(url_request_context_getter_,
network_settings_));
-
- std::vector<rtc::SocketAddress> stun_hosts;
- for (auto stun_it = stun_servers.begin(); stun_it != stun_servers.end();
- ++stun_it) {
- stun_hosts.push_back(stun_it->server);
- }
- port_allocator->SetStunHosts(stun_hosts);
-
- // TODO(aiguha): Figure out how to translate |turn_configurations| into
- // turn hosts so we can set |port_allocator|'s relay hosts.
-
return port_allocator.release();
}
diff --git a/remoting/protocol/chromium_port_allocator_factory.h b/remoting/protocol/chromium_port_allocator_factory.h
index bbfa1b7..4c7db57 100644
--- a/remoting/protocol/chromium_port_allocator_factory.h
+++ b/remoting/protocol/chromium_port_allocator_factory.h
@@ -7,8 +7,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "remoting/protocol/network_settings.h"
-#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
+#include "remoting/protocol/port_allocator_factory.h"
namespace net {
class URLRequestContextGetter;
@@ -17,17 +18,14 @@ class URLRequestContextGetter;
namespace remoting {
namespace protocol {
-class ChromiumPortAllocatorFactory
- : public webrtc::PortAllocatorFactoryInterface {
+class ChromiumPortAllocatorFactory : public PortAllocatorFactory {
public:
- static rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> Create(
+ static scoped_ptr<PortAllocatorFactory> Create(
const NetworkSettings& network_settings,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
- // webrtc::PortAllocatorFactoryInterface implementation.
- cricket::PortAllocator* CreatePortAllocator(
- const std::vector<StunConfiguration>& stun_servers,
- const std::vector<TurnConfiguration>& turn_configurations) override;
+ // PortAllocatorFactory implementation.
+ cricket::PortAllocator* CreatePortAllocator() override;
protected:
ChromiumPortAllocatorFactory(
diff --git a/remoting/protocol/port_allocator_factory.h b/remoting/protocol/port_allocator_factory.h
new file mode 100644
index 0000000..741ccca
--- /dev/null
+++ b/remoting/protocol/port_allocator_factory.h
@@ -0,0 +1,25 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_PROTOCOL_PORT_ALLOCATOR_FACTORY_H_
+#define REMOTING_PROTOCOL_PORT_ALLOCATOR_FACTORY_H_
+
+#include "third_party/webrtc/p2p/base/portallocator.h"
+
+namespace remoting {
+namespace protocol {
+
+// Factory class used for creating cricket::PortAllocator that is used
+// for ICE negotiation.
+class PortAllocatorFactory {
+ public:
+ virtual cricket::PortAllocator* CreatePortAllocator() = 0;
+
+ virtual ~PortAllocatorFactory() {}
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_PORT_ALLOCATOR_FACTORY_H_
diff --git a/remoting/protocol/webrtc_transport.cc b/remoting/protocol/webrtc_transport.cc
index 253293e..2c82aab 100644
--- a/remoting/protocol/webrtc_transport.cc
+++ b/remoting/protocol/webrtc_transport.cc
@@ -99,11 +99,9 @@ class SetSessionDescriptionObserver
} // namespace
-WebrtcTransport::WebrtcTransport(
- rtc::Thread* worker_thread,
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
- port_allocator_factory,
- TransportRole role)
+WebrtcTransport::WebrtcTransport(rtc::Thread* worker_thread,
+ PortAllocatorFactory* port_allocator_factory,
+ TransportRole role)
: port_allocator_factory_(port_allocator_factory),
role_(role),
worker_thread_(worker_thread),
@@ -138,8 +136,11 @@ void WebrtcTransport::Start(EventHandler* event_handler,
constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
webrtc::MediaConstraintsInterface::kValueTrue);
+ rtc::scoped_ptr<cricket::PortAllocator> port_allocator(
+ port_allocator_factory_->CreatePortAllocator());
+
peer_connection_ = peer_connection_factory_->CreatePeerConnection(
- rtc_config, &constraints, port_allocator_factory_, nullptr, this);
+ rtc_config, &constraints, std::move(port_allocator), nullptr, this);
data_stream_adapter_.Initialize(peer_connection_,
role_ == TransportRole::SERVER);
@@ -488,19 +489,18 @@ void WebrtcTransport::AddPendingCandidatesIfPossible() {
WebrtcTransportFactory::WebrtcTransportFactory(
rtc::Thread* worker_thread,
SignalStrategy* signal_strategy,
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
- port_allocator_factory,
+ scoped_ptr<PortAllocatorFactory> port_allocator_factory,
TransportRole role)
: worker_thread_(worker_thread),
signal_strategy_(signal_strategy),
- port_allocator_factory_(port_allocator_factory),
+ port_allocator_factory_(std::move(port_allocator_factory)),
role_(role) {}
WebrtcTransportFactory::~WebrtcTransportFactory() {}
scoped_ptr<Transport> WebrtcTransportFactory::CreateTransport() {
- return make_scoped_ptr(
- new WebrtcTransport(worker_thread_, port_allocator_factory_, role_));
+ return make_scoped_ptr(new WebrtcTransport(
+ worker_thread_, port_allocator_factory_.get(), role_));
}
} // namespace protocol
diff --git a/remoting/protocol/webrtc_transport.h b/remoting/protocol/webrtc_transport.h
index afba35e..6fc79d7 100644
--- a/remoting/protocol/webrtc_transport.h
+++ b/remoting/protocol/webrtc_transport.h
@@ -6,11 +6,13 @@
#define REMOTING_PROTOCOL_WEBRTC_TRANSPORT_H_
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
+#include "remoting/protocol/port_allocator_factory.h"
#include "remoting/protocol/transport.h"
#include "remoting/protocol/webrtc_data_stream_adapter.h"
#include "remoting/signaling/signal_strategy.h"
@@ -27,8 +29,7 @@ class WebrtcTransport : public Transport,
public webrtc::PeerConnectionObserver {
public:
WebrtcTransport(rtc::Thread* worker_thread,
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
- port_allocator_factory,
+ PortAllocatorFactory* port_allocator_factory,
TransportRole role);
~WebrtcTransport() override;
@@ -79,8 +80,7 @@ class WebrtcTransport : public Transport,
base::ThreadChecker thread_checker_;
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
- port_allocator_factory_;
+ PortAllocatorFactory* port_allocator_factory_;
TransportRole role_;
EventHandler* event_handler_ = nullptr;
rtc::Thread* worker_thread_;
@@ -113,8 +113,7 @@ class WebrtcTransportFactory : public TransportFactory {
WebrtcTransportFactory(
rtc::Thread* worker_thread,
SignalStrategy* signal_strategy,
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
- port_allocator_factory,
+ scoped_ptr<PortAllocatorFactory> port_allocator_factory,
TransportRole role);
~WebrtcTransportFactory() override;
@@ -124,8 +123,7 @@ class WebrtcTransportFactory : public TransportFactory {
private:
rtc::Thread* worker_thread_;
SignalStrategy* signal_strategy_;
- rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface>
- port_allocator_factory_;
+ scoped_ptr<PortAllocatorFactory> port_allocator_factory_;
TransportRole role_;
DISALLOW_COPY_AND_ASSIGN(WebrtcTransportFactory);