aboutsummaryrefslogtreecommitdiff
path: root/pc
diff options
context:
space:
mode:
authorBenjamin Wright <benwright@webrtc.org>2018-05-02 15:12:47 -0700
committerCommit Bot <commit-bot@chromium.org>2018-05-04 19:18:05 +0000
commitcab58888ad62031db9f92aff45e9189fd7c4105a (patch)
treeb3abe13e7afc5e196094ae22b0d7e5fc689d7395 /pc
parentc816ffc0a592457d38039c10c7b18c98eaa2cedb (diff)
downloadwebrtc-cab58888ad62031db9f92aff45e9189fd7c4105a.tar.gz
Integrated PeerConnectionDependencies into PeerConnection::Initialize
Integrates the new PeerConnectionDependencies structure into PeerConnection::Initialize to simplify future injections. Bug: webrtc:7913 Change-Id: Ida1feae8b81819dfbfe5b79ed7807a63b091e73f Reviewed-on: https://webrtc-review.googlesource.com/73960 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Benjamin Wright <benwright@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23130}
Diffstat (limited to 'pc')
-rw-r--r--pc/peerconnection.cc20
-rw-r--r--pc/peerconnection.h4
-rw-r--r--pc/peerconnectionfactory.cc6
3 files changed, 11 insertions, 19 deletions
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index 454746f40e..ea76e3da44 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -882,9 +882,7 @@ void PeerConnection::DestroyAllChannels() {
bool PeerConnection::Initialize(
const PeerConnectionInterface::RTCConfiguration& configuration,
- std::unique_ptr<cricket::PortAllocator> allocator,
- std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
- PeerConnectionObserver* observer) {
+ PeerConnectionDependencies dependencies) {
TRACE_EVENT0("webrtc", "PeerConnection::Initialize");
RTCError config_error = ValidateConfiguration(configuration);
@@ -893,21 +891,21 @@ bool PeerConnection::Initialize(
return false;
}
- if (!allocator) {
+ if (!dependencies.allocator) {
RTC_LOG(LS_ERROR)
<< "PeerConnection initialized without a PortAllocator? "
"This shouldn't happen if using PeerConnectionFactory.";
return false;
}
- if (!observer) {
+ if (!dependencies.observer) {
// TODO(deadbeef): Why do we do this?
RTC_LOG(LS_ERROR) << "PeerConnection initialized without a "
"PeerConnectionObserver";
return false;
}
- observer_ = observer;
- port_allocator_ = std::move(allocator);
+ observer_ = dependencies.observer;
+ port_allocator_ = std::move(dependencies.allocator);
// The port allocator lives on the network thread and should be initialized
// there.
@@ -971,7 +969,7 @@ bool PeerConnection::Initialize(
dtls_enabled_ = false;
} else {
// Enable DTLS by default if we have an identity store or a certificate.
- dtls_enabled_ = (cert_generator || certificate);
+ dtls_enabled_ = (dependencies.cert_generator || certificate);
// |configuration| can override the default |dtls_enabled_| value.
if (configuration.enable_dtls_srtp) {
dtls_enabled_ = *(configuration.enable_dtls_srtp);
@@ -1005,16 +1003,16 @@ bool PeerConnection::Initialize(
// what PeerConnectionDescriptionFactory will do, so make sure that we give it
// the right instructions by clearing the variables if needed.
if (!dtls_enabled_) {
- cert_generator.reset();
+ dependencies.cert_generator.reset();
certificate = nullptr;
} else if (certificate) {
// Favor generated certificate over the certificate generator.
- cert_generator.reset();
+ dependencies.cert_generator.reset();
}
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
signaling_thread(), channel_manager(), this, session_id(),
- std::move(cert_generator), certificate));
+ std::move(dependencies.cert_generator), certificate));
webrtc_session_desc_factory_->SignalCertificateReady.connect(
this, &PeerConnection::OnCertificateReady);
diff --git a/pc/peerconnection.h b/pc/peerconnection.h
index eaebc1d75b..a03e9522d8 100644
--- a/pc/peerconnection.h
+++ b/pc/peerconnection.h
@@ -61,9 +61,7 @@ class PeerConnection : public PeerConnectionInternal,
bool Initialize(
const PeerConnectionInterface::RTCConfiguration& configuration,
- std::unique_ptr<cricket::PortAllocator> allocator,
- std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
- PeerConnectionObserver* observer);
+ PeerConnectionDependencies dependencies);
rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
diff --git a/pc/peerconnectionfactory.cc b/pc/peerconnectionfactory.cc
index b6865ceff2..4889723174 100644
--- a/pc/peerconnectionfactory.cc
+++ b/pc/peerconnectionfactory.cc
@@ -307,11 +307,7 @@ PeerConnectionFactory::CreatePeerConnection(
new rtc::RefCountedObject<PeerConnection>(this, std::move(event_log),
std::move(call)));
- // TODO(benwright) Update initialize to take the entire dependencies
- // structure.
- if (!pc->Initialize(configuration, std::move(dependencies.allocator),
- std::move(dependencies.cert_generator),
- dependencies.observer)) {
+ if (!pc->Initialize(configuration, std::move(dependencies))) {
return nullptr;
}
return PeerConnectionProxy::Create(signaling_thread(), pc);