Index: talk/app/webrtc/webrtcsession.cc |
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc |
index b6a178cf392c2a671453de59da79410ac477b658..3162bd3e5f2d8fdf5640cbdee801fb6928d42852 100644 |
--- a/talk/app/webrtc/webrtcsession.cc |
+++ b/talk/app/webrtc/webrtcsession.cc |
@@ -517,13 +517,13 @@ WebRtcSession::~WebRtcSession() { |
for (size_t i = 0; i < saved_candidates_.size(); ++i) { |
delete saved_candidates_[i]; |
} |
- delete identity(); |
} |
bool WebRtcSession::Initialize( |
const PeerConnectionFactoryInterface::Options& options, |
- const MediaConstraintsInterface* constraints, |
+ const MediaConstraintsInterface* constraints, |
DTLSIdentityServiceInterface* dtls_identity_service, |
+ rtc::scoped_refptr<webrtc::DtlsCertificate> certificate, |
const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
bundle_policy_ = rtc_configuration.bundle_policy; |
rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; |
@@ -537,13 +537,13 @@ bool WebRtcSession::Initialize( |
if (options.disable_encryption) { |
dtls_enabled_ = false; |
} else { |
- // Enable DTLS by default if |dtls_identity_service| is valid. |
- dtls_enabled_ = (dtls_identity_service != NULL); |
+ // Enable DTLS by default if a service or certificate was provided. |
+ dtls_enabled_ = (dtls_identity_service || certificate.get()); |
// |constraints| can override the default |dtls_enabled_| value. |
if (FindConstraint( |
constraints, |
MediaConstraintsInterface::kEnableDtlsSrtp, |
- &value, NULL)) { |
+ &value, nullptr)) { |
dtls_enabled_ = value; |
} |
} |
@@ -662,16 +662,18 @@ bool WebRtcSession::Initialize( |
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( |
signaling_thread(), |
+ worker_thread(), |
channel_manager_, |
mediastream_signaling_, |
dtls_identity_service, |
+ certificate, |
this, |
id(), |
data_channel_type_, |
dtls_enabled_)); |
- webrtc_session_desc_factory_->SignalIdentityReady.connect( |
- this, &WebRtcSession::OnIdentityReady); |
+ webrtc_session_desc_factory_->SignalCertificateReady.connect( |
+ this, &WebRtcSession::OnCertificateReady); |
if (options.disable_encryption) { |
webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); |
@@ -1304,12 +1306,18 @@ void WebRtcSession::ResetIceRestartLatch() { |
ice_restart_latch_->Reset(); |
} |
-void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) { |
- SetIdentity(identity); |
+void WebRtcSession::OnCertificateReady( |
+ rtc::scoped_refptr<DtlsCertificate> certificate) { |
+ certificate_ = certificate; |
+ SetIdentity(certificate_->identity()); |
+} |
+ |
+bool WebRtcSession::waiting_for_certificate() const { |
+ return webrtc_session_desc_factory_->waiting_for_certificate(); |
} |
-bool WebRtcSession::waiting_for_identity() const { |
- return webrtc_session_desc_factory_->waiting_for_identity(); |
+rtc::scoped_refptr<DtlsCertificate> WebRtcSession::get_certificate() const { |
+ return certificate_; |
} |
void WebRtcSession::SetIceConnectionState( |