Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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): How to decide which certificate to use? | |
|
torbjorng (webrtc)
2015/08/21 12:39:19
My understanding is that multiple certificates mak
hbos
2015/08/24 10:16:43
Acknowledged. We must look into this more, major c
| |
| 583 certificate = rtc_configuration.certificates[0]; | |
| 584 } | |
| 585 | |
| 579 // TODO(perkj): Take |constraints| into consideration. Return false if not all | 586 // TODO(perkj): Take |constraints| into consideration. Return false if not all |
| 580 // mandatory constraints can be fulfilled. Note that |constraints| | 587 // mandatory constraints can be fulfilled. Note that |constraints| |
| 581 // can be null. | 588 // can be null. |
| 582 bool value; | 589 bool value; |
| 583 | 590 |
| 584 if (options.disable_encryption) { | 591 if (options.disable_encryption) { |
| 585 dtls_enabled_ = false; | 592 dtls_enabled_ = false; |
| 586 } else { | 593 } else { |
| 587 // Enable DTLS by default if we have a |dtls_identity_store|. | 594 // Enable DTLS by default if we have an identity store or a certificate. |
| 588 dtls_enabled_ = (dtls_identity_store != nullptr); | 595 dtls_enabled_ = (dtls_identity_store || certificate); |
| 589 // |constraints| can override the default |dtls_enabled_| value. | 596 // |constraints| can override the default |dtls_enabled_| value. |
| 590 if (FindConstraint( | 597 if (FindConstraint( |
| 591 constraints, | 598 constraints, |
| 592 MediaConstraintsInterface::kEnableDtlsSrtp, | 599 MediaConstraintsInterface::kEnableDtlsSrtp, |
| 593 &value, NULL)) { | 600 &value, nullptr)) { |
| 594 dtls_enabled_ = value; | 601 dtls_enabled_ = value; |
| 595 } | 602 } |
| 596 } | 603 } |
| 597 | 604 |
| 598 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set. | 605 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set. |
| 599 // It takes precendence over the disable_sctp_data_channels | 606 // It takes precendence over the disable_sctp_data_channels |
| 600 // PeerConnectionFactoryInterface::Options. | 607 // PeerConnectionFactoryInterface::Options. |
| 601 if (FindConstraint( | 608 if (FindConstraint( |
| 602 constraints, MediaConstraintsInterface::kEnableRtpDataChannels, | 609 constraints, MediaConstraintsInterface::kEnableRtpDataChannels, |
| 603 &value, NULL) && value) { | 610 &value, NULL) && value) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 const cricket::VideoCodec default_codec( | 707 const cricket::VideoCodec default_codec( |
| 701 JsepSessionDescription::kDefaultVideoCodecId, | 708 JsepSessionDescription::kDefaultVideoCodecId, |
| 702 JsepSessionDescription::kDefaultVideoCodecName, | 709 JsepSessionDescription::kDefaultVideoCodecName, |
| 703 JsepSessionDescription::kMaxVideoCodecWidth, | 710 JsepSessionDescription::kMaxVideoCodecWidth, |
| 704 JsepSessionDescription::kMaxVideoCodecHeight, | 711 JsepSessionDescription::kMaxVideoCodecHeight, |
| 705 JsepSessionDescription::kDefaultVideoCodecFramerate, | 712 JsepSessionDescription::kDefaultVideoCodecFramerate, |
| 706 JsepSessionDescription::kDefaultVideoCodecPreference); | 713 JsepSessionDescription::kDefaultVideoCodecPreference); |
| 707 channel_manager_->SetDefaultVideoEncoderConfig( | 714 channel_manager_->SetDefaultVideoEncoderConfig( |
| 708 cricket::VideoEncoderConfig(default_codec)); | 715 cricket::VideoEncoderConfig(default_codec)); |
| 709 | 716 |
| 710 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( | 717 if (!dtls_enabled_) { |
| 711 signaling_thread(), | 718 // Construct with DTLS disabled. |
| 712 channel_manager_, | 719 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( |
| 713 mediastream_signaling_, | 720 signaling_thread(), |
| 714 dtls_identity_store.Pass(), | 721 channel_manager_, |
| 715 this, | 722 mediastream_signaling_, |
| 716 id(), | 723 this, |
| 717 data_channel_type_, | 724 id(), |
| 718 dtls_enabled_)); | 725 data_channel_type_)); |
| 726 } else { | |
| 727 // Construct with DTLS enabled. | |
| 728 if (!certificate) { | |
|
torbjorng (webrtc)
2015/08/21 12:39:19
Is dtls_identity_store.Pass() and certificate type
hbos
2015/08/24 10:16:43
You either use store and not certificate, or certi
| |
| 729 // Use the |dtls_identity_store| to generate a certificate. | |
| 730 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( | |
| 731 signaling_thread(), | |
| 732 channel_manager_, | |
| 733 mediastream_signaling_, | |
| 734 dtls_identity_store.Pass(), | |
| 735 this, | |
| 736 id(), | |
| 737 data_channel_type_)); | |
| 738 } else { | |
| 739 // Use the already generated certificate. | |
| 740 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( | |
| 741 signaling_thread(), | |
| 742 channel_manager_, | |
| 743 mediastream_signaling_, | |
| 744 certificate, | |
| 745 this, | |
| 746 id(), | |
| 747 data_channel_type_)); | |
| 748 } | |
| 749 } | |
| 719 | 750 |
| 720 webrtc_session_desc_factory_->SignalIdentityReady.connect( | 751 webrtc_session_desc_factory_->SignalIdentityReady.connect( |
| 721 this, &WebRtcSession::OnIdentityReady); | 752 this, &WebRtcSession::OnIdentityReady); |
| 722 | 753 |
| 723 if (options.disable_encryption) { | 754 if (options.disable_encryption) { |
| 724 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); | 755 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); |
| 725 } | 756 } |
| 726 port_allocator()->set_candidate_filter( | 757 port_allocator()->set_candidate_filter( |
| 727 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); | 758 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); |
| 728 return true; | 759 return true; |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1348 } | 1379 } |
| 1349 | 1380 |
| 1350 void WebRtcSession::ResetIceRestartLatch() { | 1381 void WebRtcSession::ResetIceRestartLatch() { |
| 1351 ice_restart_latch_->Reset(); | 1382 ice_restart_latch_->Reset(); |
| 1352 } | 1383 } |
| 1353 | 1384 |
| 1354 void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) { | 1385 void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) { |
| 1355 SetIdentity(identity); | 1386 SetIdentity(identity); |
| 1356 } | 1387 } |
| 1357 | 1388 |
| 1358 bool WebRtcSession::waiting_for_identity() const { | 1389 bool WebRtcSession::waiting_for_identity_for_testing() const { |
| 1359 return webrtc_session_desc_factory_->waiting_for_identity(); | 1390 return webrtc_session_desc_factory_->waiting_for_certificate_for_testing(); |
| 1360 } | 1391 } |
| 1361 | 1392 |
| 1362 void WebRtcSession::SetIceConnectionState( | 1393 void WebRtcSession::SetIceConnectionState( |
| 1363 PeerConnectionInterface::IceConnectionState state) { | 1394 PeerConnectionInterface::IceConnectionState state) { |
| 1364 if (ice_connection_state_ == state) { | 1395 if (ice_connection_state_ == state) { |
| 1365 return; | 1396 return; |
| 1366 } | 1397 } |
| 1367 | 1398 |
| 1368 // ASSERT that the requested transition is allowed. Note that | 1399 // ASSERT that the requested transition is allowed. Note that |
| 1369 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled | 1400 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2044 | 2075 |
| 2045 if (!srtp_cipher.empty()) { | 2076 if (!srtp_cipher.empty()) { |
| 2046 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); | 2077 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
| 2047 } | 2078 } |
| 2048 if (!ssl_cipher.empty()) { | 2079 if (!ssl_cipher.empty()) { |
| 2049 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); | 2080 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
| 2050 } | 2081 } |
| 2051 } | 2082 } |
| 2052 | 2083 |
| 2053 } // namespace webrtc | 2084 } // namespace webrtc |
| OLD | NEW |