Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: talk/app/webrtc/webrtcsession.cc

Issue 1269843005: Added DtlsCertificate, a ref counted object owning an SSLIdentity (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: webrtcsession_unittest cleanup Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 SignalVoiceChannelDestroyed(); 510 SignalVoiceChannelDestroyed();
511 channel_manager_->DestroyVoiceChannel(voice_channel_.release(), nullptr); 511 channel_manager_->DestroyVoiceChannel(voice_channel_.release(), nullptr);
512 } 512 }
513 if (data_channel_) { 513 if (data_channel_) {
514 SignalDataChannelDestroyed(); 514 SignalDataChannelDestroyed();
515 channel_manager_->DestroyDataChannel(data_channel_.release()); 515 channel_manager_->DestroyDataChannel(data_channel_.release());
516 } 516 }
517 for (size_t i = 0; i < saved_candidates_.size(); ++i) { 517 for (size_t i = 0; i < saved_candidates_.size(); ++i) {
518 delete saved_candidates_[i]; 518 delete saved_candidates_[i];
519 } 519 }
520 delete identity();
521 } 520 }
522 521
523 bool WebRtcSession::Initialize( 522 bool WebRtcSession::Initialize(
524 const PeerConnectionFactoryInterface::Options& options, 523 const PeerConnectionFactoryInterface::Options& options,
525 const MediaConstraintsInterface* constraints, 524 const MediaConstraintsInterface* constraints,
526 DTLSIdentityServiceInterface* dtls_identity_service, 525 rtc::scoped_refptr<webrtc::DtlsCertificate> certificate,
Henrik Grunell WebRTC 2015/08/05 07:41:20 Who keeps references to the certificate? (Why does
hbos 2015/08/06 12:11:34 The certificate (and its identity) is used in a lo
Henrik Grunell WebRTC 2015/08/06 14:06:52 Acknowledged.
527 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { 526 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
528 bundle_policy_ = rtc_configuration.bundle_policy; 527 bundle_policy_ = rtc_configuration.bundle_policy;
529 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; 528 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy;
530 SetSslMaxProtocolVersion(options.ssl_max_version); 529 SetSslMaxProtocolVersion(options.ssl_max_version);
531 530
532 // TODO(perkj): Take |constraints| into consideration. Return false if not all 531 // TODO(perkj): Take |constraints| into consideration. Return false if not all
533 // mandatory constraints can be fulfilled. Note that |constraints| 532 // mandatory constraints can be fulfilled. Note that |constraints|
534 // can be null. 533 // can be null.
535 bool value; 534 bool value;
536 535
537 if (options.disable_encryption) { 536 if (options.disable_encryption) {
538 dtls_enabled_ = false; 537 dtls_enabled_ = false;
539 } else { 538 } else {
540 // Enable DTLS by default if |dtls_identity_service| is valid. 539 // Enable DTLS by default if |certificate| is valid.
541 dtls_enabled_ = (dtls_identity_service != NULL); 540 dtls_enabled_ = (certificate.get() != nullptr);
542 // |constraints| can override the default |dtls_enabled_| value. 541 // |constraints| can override the default |dtls_enabled_| value.
543 if (FindConstraint( 542 if (FindConstraint(
544 constraints, 543 constraints,
545 MediaConstraintsInterface::kEnableDtlsSrtp, 544 MediaConstraintsInterface::kEnableDtlsSrtp,
546 &value, NULL)) { 545 &value, nullptr)) {
547 dtls_enabled_ = value; 546 dtls_enabled_ = value;
548 } 547 }
549 } 548 }
550 549
551 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set. 550 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set.
552 // It takes precendence over the disable_sctp_data_channels 551 // It takes precendence over the disable_sctp_data_channels
553 // PeerConnectionFactoryInterface::Options. 552 // PeerConnectionFactoryInterface::Options.
554 if (FindConstraint( 553 if (FindConstraint(
555 constraints, MediaConstraintsInterface::kEnableRtpDataChannels, 554 constraints, MediaConstraintsInterface::kEnableRtpDataChannels,
556 &value, NULL) && value) { 555 &value, NULL) && value) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 JsepSessionDescription::kDefaultVideoCodecName, 654 JsepSessionDescription::kDefaultVideoCodecName,
656 JsepSessionDescription::kMaxVideoCodecWidth, 655 JsepSessionDescription::kMaxVideoCodecWidth,
657 JsepSessionDescription::kMaxVideoCodecHeight, 656 JsepSessionDescription::kMaxVideoCodecHeight,
658 JsepSessionDescription::kDefaultVideoCodecFramerate, 657 JsepSessionDescription::kDefaultVideoCodecFramerate,
659 JsepSessionDescription::kDefaultVideoCodecPreference); 658 JsepSessionDescription::kDefaultVideoCodecPreference);
660 channel_manager_->SetDefaultVideoEncoderConfig( 659 channel_manager_->SetDefaultVideoEncoderConfig(
661 cricket::VideoEncoderConfig(default_codec)); 660 cricket::VideoEncoderConfig(default_codec));
662 661
663 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( 662 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
664 signaling_thread(), 663 signaling_thread(),
664 worker_thread(),
665 channel_manager_, 665 channel_manager_,
666 mediastream_signaling_, 666 mediastream_signaling_,
667 dtls_identity_service, 667 certificate,
668 this, 668 this,
669 id(), 669 id(),
670 data_channel_type_, 670 data_channel_type_,
671 dtls_enabled_)); 671 dtls_enabled_));
672 672
673 webrtc_session_desc_factory_->SignalIdentityReady.connect( 673 webrtc_session_desc_factory_->SignalCertificateReady.connect(
674 this, &WebRtcSession::OnIdentityReady); 674 this, &WebRtcSession::OnCertificateReady);
675 675
676 if (options.disable_encryption) { 676 if (options.disable_encryption) {
677 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); 677 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED);
678 } 678 }
679 port_allocator()->set_candidate_filter( 679 port_allocator()->set_candidate_filter(
680 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); 680 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type));
681 return true; 681 return true;
682 } 682 }
683 683
684 void WebRtcSession::Terminate() { 684 void WebRtcSession::Terminate() {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 } 1291 }
1292 1292
1293 bool WebRtcSession::IceRestartPending() const { 1293 bool WebRtcSession::IceRestartPending() const {
1294 return ice_restart_latch_->Get(); 1294 return ice_restart_latch_->Get();
1295 } 1295 }
1296 1296
1297 void WebRtcSession::ResetIceRestartLatch() { 1297 void WebRtcSession::ResetIceRestartLatch() {
1298 ice_restart_latch_->Reset(); 1298 ice_restart_latch_->Reset();
1299 } 1299 }
1300 1300
1301 void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) { 1301 void WebRtcSession::OnCertificateReady(
1302 SetIdentity(identity); 1302 rtc::scoped_refptr<DtlsCertificate> certificate) {
1303 certificate_ = certificate;
1304 SetIdentity(certificate_->identity());
1303 } 1305 }
1304 1306
1305 bool WebRtcSession::waiting_for_identity() const { 1307 bool WebRtcSession::waiting_for_certificate() const {
1306 return webrtc_session_desc_factory_->waiting_for_identity(); 1308 return webrtc_session_desc_factory_->waiting_for_certificate();
1307 } 1309 }
1308 1310
1309 void WebRtcSession::SetIceConnectionState( 1311 void WebRtcSession::SetIceConnectionState(
1310 PeerConnectionInterface::IceConnectionState state) { 1312 PeerConnectionInterface::IceConnectionState state) {
1311 if (ice_connection_state_ == state) { 1313 if (ice_connection_state_ == state) {
1312 return; 1314 return;
1313 } 1315 }
1314 1316
1315 // ASSERT that the requested transition is allowed. Note that 1317 // ASSERT that the requested transition is allowed. Note that
1316 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled 1318 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 1962
1961 if (!srtp_cipher.empty()) { 1963 if (!srtp_cipher.empty()) {
1962 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); 1964 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher);
1963 } 1965 }
1964 if (!ssl_cipher.empty()) { 1966 if (!ssl_cipher.empty()) {
1965 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); 1967 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher);
1966 } 1968 }
1967 } 1969 }
1968 1970
1969 } // namespace webrtc 1971 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698