| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 DTLSIdentityServiceInterface* dtls_identity_service, |
| 526 rtc::scoped_refptr<webrtc::DtlsCertificate> certificate, |
| 527 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 527 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
| 528 bundle_policy_ = rtc_configuration.bundle_policy; | 528 bundle_policy_ = rtc_configuration.bundle_policy; |
| 529 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; | 529 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; |
| 530 SetSslMaxProtocolVersion(options.ssl_max_version); | 530 SetSslMaxProtocolVersion(options.ssl_max_version); |
| 531 | 531 |
| 532 // TODO(perkj): Take |constraints| into consideration. Return false if not all | 532 // TODO(perkj): Take |constraints| into consideration. Return false if not all |
| 533 // mandatory constraints can be fulfilled. Note that |constraints| | 533 // mandatory constraints can be fulfilled. Note that |constraints| |
| 534 // can be null. | 534 // can be null. |
| 535 bool value; | 535 bool value; |
| 536 | 536 |
| 537 if (options.disable_encryption) { | 537 if (options.disable_encryption) { |
| 538 dtls_enabled_ = false; | 538 dtls_enabled_ = false; |
| 539 } else { | 539 } else { |
| 540 // Enable DTLS by default if |dtls_identity_service| is valid. | 540 // Enable DTLS by default if a service or certificate was provided. |
| 541 dtls_enabled_ = (dtls_identity_service != NULL); | 541 dtls_enabled_ = (dtls_identity_service || certificate.get()); |
| 542 // |constraints| can override the default |dtls_enabled_| value. | 542 // |constraints| can override the default |dtls_enabled_| value. |
| 543 if (FindConstraint( | 543 if (FindConstraint( |
| 544 constraints, | 544 constraints, |
| 545 MediaConstraintsInterface::kEnableDtlsSrtp, | 545 MediaConstraintsInterface::kEnableDtlsSrtp, |
| 546 &value, NULL)) { | 546 &value, nullptr)) { |
| 547 dtls_enabled_ = value; | 547 dtls_enabled_ = value; |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 | 550 |
| 551 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set. | 551 // Enable creation of RTP data channels if the kEnableRtpDataChannels is set. |
| 552 // It takes precendence over the disable_sctp_data_channels | 552 // It takes precendence over the disable_sctp_data_channels |
| 553 // PeerConnectionFactoryInterface::Options. | 553 // PeerConnectionFactoryInterface::Options. |
| 554 if (FindConstraint( | 554 if (FindConstraint( |
| 555 constraints, MediaConstraintsInterface::kEnableRtpDataChannels, | 555 constraints, MediaConstraintsInterface::kEnableRtpDataChannels, |
| 556 &value, NULL) && value) { | 556 &value, NULL) && value) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 JsepSessionDescription::kDefaultVideoCodecName, | 655 JsepSessionDescription::kDefaultVideoCodecName, |
| 656 JsepSessionDescription::kMaxVideoCodecWidth, | 656 JsepSessionDescription::kMaxVideoCodecWidth, |
| 657 JsepSessionDescription::kMaxVideoCodecHeight, | 657 JsepSessionDescription::kMaxVideoCodecHeight, |
| 658 JsepSessionDescription::kDefaultVideoCodecFramerate, | 658 JsepSessionDescription::kDefaultVideoCodecFramerate, |
| 659 JsepSessionDescription::kDefaultVideoCodecPreference); | 659 JsepSessionDescription::kDefaultVideoCodecPreference); |
| 660 channel_manager_->SetDefaultVideoEncoderConfig( | 660 channel_manager_->SetDefaultVideoEncoderConfig( |
| 661 cricket::VideoEncoderConfig(default_codec)); | 661 cricket::VideoEncoderConfig(default_codec)); |
| 662 | 662 |
| 663 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( | 663 webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory( |
| 664 signaling_thread(), | 664 signaling_thread(), |
| 665 worker_thread(), |
| 665 channel_manager_, | 666 channel_manager_, |
| 666 mediastream_signaling_, | 667 mediastream_signaling_, |
| 667 dtls_identity_service, | 668 dtls_identity_service, |
| 669 certificate, |
| 668 this, | 670 this, |
| 669 id(), | 671 id(), |
| 670 data_channel_type_, | 672 data_channel_type_, |
| 671 dtls_enabled_)); | 673 dtls_enabled_)); |
| 672 | 674 |
| 673 webrtc_session_desc_factory_->SignalIdentityReady.connect( | 675 webrtc_session_desc_factory_->SignalCertificateReady.connect( |
| 674 this, &WebRtcSession::OnIdentityReady); | 676 this, &WebRtcSession::OnCertificateReady); |
| 675 | 677 |
| 676 if (options.disable_encryption) { | 678 if (options.disable_encryption) { |
| 677 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); | 679 webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); |
| 678 } | 680 } |
| 679 port_allocator()->set_candidate_filter( | 681 port_allocator()->set_candidate_filter( |
| 680 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); | 682 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); |
| 681 return true; | 683 return true; |
| 682 } | 684 } |
| 683 | 685 |
| 684 void WebRtcSession::Terminate() { | 686 void WebRtcSession::Terminate() { |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 } | 1299 } |
| 1298 | 1300 |
| 1299 bool WebRtcSession::IceRestartPending() const { | 1301 bool WebRtcSession::IceRestartPending() const { |
| 1300 return ice_restart_latch_->Get(); | 1302 return ice_restart_latch_->Get(); |
| 1301 } | 1303 } |
| 1302 | 1304 |
| 1303 void WebRtcSession::ResetIceRestartLatch() { | 1305 void WebRtcSession::ResetIceRestartLatch() { |
| 1304 ice_restart_latch_->Reset(); | 1306 ice_restart_latch_->Reset(); |
| 1305 } | 1307 } |
| 1306 | 1308 |
| 1307 void WebRtcSession::OnIdentityReady(rtc::SSLIdentity* identity) { | 1309 void WebRtcSession::OnCertificateReady( |
| 1308 SetIdentity(identity); | 1310 rtc::scoped_refptr<DtlsCertificate> certificate) { |
| 1311 certificate_ = certificate; |
| 1312 SetIdentity(certificate_->identity()); |
| 1309 } | 1313 } |
| 1310 | 1314 |
| 1311 bool WebRtcSession::waiting_for_identity() const { | 1315 bool WebRtcSession::waiting_for_certificate() const { |
| 1312 return webrtc_session_desc_factory_->waiting_for_identity(); | 1316 return webrtc_session_desc_factory_->waiting_for_certificate(); |
| 1317 } |
| 1318 |
| 1319 rtc::scoped_refptr<DtlsCertificate> WebRtcSession::get_certificate() const { |
| 1320 return certificate_; |
| 1313 } | 1321 } |
| 1314 | 1322 |
| 1315 void WebRtcSession::SetIceConnectionState( | 1323 void WebRtcSession::SetIceConnectionState( |
| 1316 PeerConnectionInterface::IceConnectionState state) { | 1324 PeerConnectionInterface::IceConnectionState state) { |
| 1317 if (ice_connection_state_ == state) { | 1325 if (ice_connection_state_ == state) { |
| 1318 return; | 1326 return; |
| 1319 } | 1327 } |
| 1320 | 1328 |
| 1321 // ASSERT that the requested transition is allowed. Note that | 1329 // ASSERT that the requested transition is allowed. Note that |
| 1322 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled | 1330 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 | 1973 |
| 1966 if (!srtp_cipher.empty()) { | 1974 if (!srtp_cipher.empty()) { |
| 1967 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); | 1975 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
| 1968 } | 1976 } |
| 1969 if (!ssl_cipher.empty()) { | 1977 if (!ssl_cipher.empty()) { |
| 1970 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); | 1978 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
| 1971 } | 1979 } |
| 1972 } | 1980 } |
| 1973 | 1981 |
| 1974 } // namespace webrtc | 1982 } // namespace webrtc |
| OLD | NEW |