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

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

Issue 1288033009: RTCCertificates added to RTCConfiguration, used by WebRtcSession/-DescriptionFactory (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed torbjorng's comment and merged with master Created 5 years, 3 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
« no previous file with comments | « talk/app/webrtc/webrtcsession.h ('k') | talk/app/webrtc/webrtcsession_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 569
570 bool WebRtcSession::Initialize( 570 bool WebRtcSession::Initialize(
571 const PeerConnectionFactoryInterface::Options& options, 571 const PeerConnectionFactoryInterface::Options& options,
572 const MediaConstraintsInterface* constraints, 572 const MediaConstraintsInterface* constraints,
573 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 573 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
574 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { 574 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
575 bundle_policy_ = rtc_configuration.bundle_policy; 575 bundle_policy_ = rtc_configuration.bundle_policy;
576 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; 576 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy;
577 SetSslMaxProtocolVersion(options.ssl_max_version); 577 SetSslMaxProtocolVersion(options.ssl_max_version);
578 578
579 // Obtain a certificate from RTCConfiguration if any were provided (optional).
580 rtc::scoped_refptr<rtc::RTCCertificate> certificate;
581 if (!rtc_configuration.certificates.empty()) {
582 // TODO(hbos,torbjorng): Decide on certificate-selection strategy instead of
583 // just picking the first one. The decision should be made based on the DTLS
584 // handshake. The DTLS negotiations need to know about all certificates.
585 certificate = rtc_configuration.certificates[0];
586 }
587
579 // TODO(perkj): Take |constraints| into consideration. Return false if not all 588 // TODO(perkj): Take |constraints| into consideration. Return false if not all
580 // mandatory constraints can be fulfilled. Note that |constraints| 589 // mandatory constraints can be fulfilled. Note that |constraints|
581 // can be null. 590 // can be null.
582 bool value; 591 bool value;
583 592
584 if (options.disable_encryption) { 593 if (options.disable_encryption) {
585 dtls_enabled_ = false; 594 dtls_enabled_ = false;
586 } else { 595 } else {
587 // Enable DTLS by default if we have a |dtls_identity_store|. 596 // Enable DTLS by default if we have an identity store or a certificate.
588 dtls_enabled_ = (dtls_identity_store != nullptr); 597 dtls_enabled_ = (dtls_identity_store || certificate);
589 // |constraints| can override the default |dtls_enabled_| value. 598 // |constraints| can override the default |dtls_enabled_| value.
590 if (FindConstraint( 599 if (FindConstraint(
591 constraints, 600 constraints,
592 MediaConstraintsInterface::kEnableDtlsSrtp, 601 MediaConstraintsInterface::kEnableDtlsSrtp,
593 &value, NULL)) { 602 &value, nullptr)) {
594 dtls_enabled_ = value; 603 dtls_enabled_ = value;
595 } 604 }
596 } 605 }
597 606
598 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set. 607 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set.
599 // It takes precendence over the disable_sctp_data_channels 608 // It takes precendence over the disable_sctp_data_channels
600 // PeerConnectionFactoryInterface::Options. 609 // PeerConnectionFactoryInterface::Options.
601 if (FindConstraint( 610 if (FindConstraint(
602 constraints, MediaConstraintsInterface::kEnableRtpDataChannels, 611 constraints, MediaConstraintsInterface::kEnableRtpDataChannels,
603 &value, NULL) && value) { 612 &value, NULL) && value) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 const cricket::VideoCodec default_codec( 709 const cricket::VideoCodec default_codec(
701 JsepSessionDescription::kDefaultVideoCodecId, 710 JsepSessionDescription::kDefaultVideoCodecId,
702 JsepSessionDescription::kDefaultVideoCodecName, 711 JsepSessionDescription::kDefaultVideoCodecName,
703 JsepSessionDescription::kMaxVideoCodecWidth, 712 JsepSessionDescription::kMaxVideoCodecWidth,
704 JsepSessionDescription::kMaxVideoCodecHeight, 713 JsepSessionDescription::kMaxVideoCodecHeight,
705 JsepSessionDescription::kDefaultVideoCodecFramerate, 714 JsepSessionDescription::kDefaultVideoCodecFramerate,
706 JsepSessionDescription::kDefaultVideoCodecPreference); 715 JsepSessionDescription::kDefaultVideoCodecPreference);
707 channel_manager_->SetDefaultVideoEncoderConfig( 716 channel_manager_->SetDefaultVideoEncoderConfig(
708 cricket::VideoEncoderConfig(default_codec)); 717 cricket::VideoEncoderConfig(default_codec));
709 718
710 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( 719 if (!dtls_enabled_) {
711 signaling_thread(), 720 // Construct with DTLS disabled.
712 channel_manager_, 721 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
713 mediastream_signaling_, 722 signaling_thread(),
714 dtls_identity_store.Pass(), 723 channel_manager_,
715 this, 724 mediastream_signaling_,
716 id(), 725 this,
717 data_channel_type_, 726 id(),
718 dtls_enabled_)); 727 data_channel_type_));
728 } else {
729 // Construct with DTLS enabled.
730 if (!certificate) {
731 // Use the |dtls_identity_store| to generate a certificate.
732 DCHECK(dtls_identity_store);
733 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
734 signaling_thread(),
735 channel_manager_,
736 mediastream_signaling_,
737 dtls_identity_store.Pass(),
738 this,
739 id(),
740 data_channel_type_));
741 } else {
742 // Use the already generated certificate.
743 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
744 signaling_thread(),
745 channel_manager_,
746 mediastream_signaling_,
747 certificate,
748 this,
749 id(),
750 data_channel_type_));
751 }
752 }
719 753
720 webrtc_session_desc_factory_->SignalIdentityReady.connect( 754 webrtc_session_desc_factory_->SignalIdentityReady.connect(
721 this, &WebRtcSession::OnIdentityReady); 755 this, &WebRtcSession::OnIdentityReady);
722 756
723 if (options.disable_encryption) { 757 if (options.disable_encryption) {
724 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); 758 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED);
725 } 759 }
726 port_allocator()->set_candidate_filter( 760 port_allocator()->set_candidate_filter(
727 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); 761 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type));
728 762
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 } 1389 }
1356 1390
1357 void WebRtcSession::ResetIceRestartLatch() { 1391 void WebRtcSession::ResetIceRestartLatch() {
1358 ice_restart_latch_->Reset(); 1392 ice_restart_latch_->Reset();
1359 } 1393 }
1360 1394
1361 void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) { 1395 void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) {
1362 SetIdentity(identity); 1396 SetIdentity(identity);
1363 } 1397 }
1364 1398
1365 bool WebRtcSession::waiting_for_identity() const { 1399 bool WebRtcSession::waiting_for_identity_for_testing() const {
1366 return webrtc_session_desc_factory_->waiting_for_identity(); 1400 return webrtc_session_desc_factory_->waiting_for_certificate_for_testing();
1367 } 1401 }
1368 1402
1369 void WebRtcSession::SetIceConnectionState( 1403 void WebRtcSession::SetIceConnectionState(
1370 PeerConnectionInterface::IceConnectionState state) { 1404 PeerConnectionInterface::IceConnectionState state) {
1371 if (ice_connection_state_ == state) { 1405 if (ice_connection_state_ == state) {
1372 return; 1406 return;
1373 } 1407 }
1374 1408
1375 // ASSERT that the requested transition is allowed. Note that 1409 // ASSERT that the requested transition is allowed. Note that
1376 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled 1410 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 2085
2052 if (!srtp_cipher.empty()) { 2086 if (!srtp_cipher.empty()) {
2053 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); 2087 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher);
2054 } 2088 }
2055 if (!ssl_cipher.empty()) { 2089 if (!ssl_cipher.empty()) {
2056 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); 2090 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher);
2057 } 2091 }
2058 } 2092 }
2059 2093
2060 } // namespace webrtc 2094 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsession.h ('k') | talk/app/webrtc/webrtcsession_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698