Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 } | 224 } |
| 225 if (tinfo->description.ice_ufrag.empty() || | 225 if (tinfo->description.ice_ufrag.empty() || |
| 226 tinfo->description.ice_pwd.empty()) { | 226 tinfo->description.ice_pwd.empty()) { |
| 227 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd."; | 227 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd."; |
| 228 return false; | 228 return false; |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 | 233 |
| 234 // Forces |sdesc->crypto_required| to the appropriate state based on the | |
| 235 // current security policy, to ensure a failure occurs if there is an error | |
| 236 // in crypto negotiation. | |
| 237 // Called when processing the local session description. | |
| 238 static void UpdateSessionDescriptionSecurePolicy(cricket::CryptoType type, | |
| 239 SessionDescription* sdesc) { | |
| 240 if (!sdesc) { | |
| 241 return; | |
| 242 } | |
| 243 | |
| 244 // Updating the |crypto_required_| in MediaContentDescription to the | |
| 245 // appropriate state based on the current security policy. | |
| 246 for (cricket::ContentInfos::iterator iter = sdesc->contents().begin(); | |
| 247 iter != sdesc->contents().end(); ++iter) { | |
| 248 if (cricket::IsMediaContent(&*iter)) { | |
| 249 MediaContentDescription* mdesc = | |
| 250 static_cast<MediaContentDescription*> (iter->description); | |
| 251 if (mdesc) { | |
| 252 mdesc->set_crypto_required(type); | |
| 253 } | |
| 254 } | |
| 255 } | |
| 256 } | |
| 257 | |
| 258 static bool GetAudioSsrcByTrackId(const SessionDescription* session_description, | 234 static bool GetAudioSsrcByTrackId(const SessionDescription* session_description, |
| 259 const std::string& track_id, | 235 const std::string& track_id, |
| 260 uint32_t* ssrc) { | 236 uint32_t* ssrc) { |
| 261 const cricket::ContentInfo* audio_info = | 237 const cricket::ContentInfo* audio_info = |
| 262 cricket::GetFirstAudioContent(session_description); | 238 cricket::GetFirstAudioContent(session_description); |
| 263 if (!audio_info) { | 239 if (!audio_info) { |
| 264 LOG(LS_ERROR) << "Audio not used in this call"; | 240 LOG(LS_ERROR) << "Audio not used in this call"; |
| 265 return false; | 241 return false; |
| 266 } | 242 } |
| 267 | 243 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 } | 610 } |
| 635 if (video_channel() && video_channel()->content_name() == content_name) { | 611 if (video_channel() && video_channel()->content_name() == content_name) { |
| 636 return video_channel(); | 612 return video_channel(); |
| 637 } | 613 } |
| 638 if (data_channel() && data_channel()->content_name() == content_name) { | 614 if (data_channel() && data_channel()->content_name() == content_name) { |
| 639 return data_channel(); | 615 return data_channel(); |
| 640 } | 616 } |
| 641 return nullptr; | 617 return nullptr; |
| 642 } | 618 } |
| 643 | 619 |
| 644 void WebRtcSession::SetSdesPolicy(cricket::SecurePolicy secure_policy) { | |
| 645 webrtc_session_desc_factory_->SetSdesPolicy(secure_policy); | |
| 646 } | |
| 647 | |
| 648 cricket::SecurePolicy WebRtcSession::SdesPolicy() const { | 620 cricket::SecurePolicy WebRtcSession::SdesPolicy() const { |
| 649 return webrtc_session_desc_factory_->SdesPolicy(); | 621 return webrtc_session_desc_factory_->SdesPolicy(); |
| 650 } | 622 } |
| 651 | 623 |
| 624 bool WebRtcSession::SecureRequired() const { | |
| 625 return dtls_enabled_ || | |
| 626 webrtc_session_desc_factory_->SdesPolicy() == cricket::SEC_REQUIRED; | |
| 627 } | |
| 628 | |
| 652 bool WebRtcSession::GetSslRole(const std::string& transport_name, | 629 bool WebRtcSession::GetSslRole(const std::string& transport_name, |
| 653 rtc::SSLRole* role) { | 630 rtc::SSLRole* role) { |
| 654 if (!local_desc_ || !remote_desc_) { | 631 if (!local_desc_ || !remote_desc_) { |
| 655 LOG(LS_INFO) << "Local and Remote descriptions must be applied to get " | 632 LOG(LS_INFO) << "Local and Remote descriptions must be applied to get " |
| 656 << "SSL Role of the session."; | 633 << "SSL Role of the session."; |
| 657 return false; | 634 return false; |
| 658 } | 635 } |
| 659 | 636 |
| 660 return transport_controller_->GetSslRole(transport_name, role); | 637 return transport_controller_->GetSslRole(transport_name, role); |
| 661 } | 638 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 690 return false; | 667 return false; |
| 691 } | 668 } |
| 692 | 669 |
| 693 // Update the initial_offerer flag if this session is the initial_offerer. | 670 // Update the initial_offerer flag if this session is the initial_offerer. |
| 694 Action action = GetAction(desc->type()); | 671 Action action = GetAction(desc->type()); |
| 695 if (state() == STATE_INIT && action == kOffer) { | 672 if (state() == STATE_INIT && action == kOffer) { |
| 696 initial_offerer_ = true; | 673 initial_offerer_ = true; |
| 697 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLING); | 674 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| 698 } | 675 } |
| 699 | 676 |
| 700 cricket::SecurePolicy sdes_policy = | |
| 701 webrtc_session_desc_factory_->SdesPolicy(); | |
| 702 cricket::CryptoType crypto_required = dtls_enabled_ ? | |
| 703 cricket::CT_DTLS : (sdes_policy == cricket::SEC_REQUIRED ? | |
| 704 cricket::CT_SDES : cricket::CT_NONE); | |
| 705 // Update the MediaContentDescription crypto settings as per the policy set. | |
| 706 UpdateSessionDescriptionSecurePolicy(crypto_required, desc->description()); | |
| 707 | |
| 708 local_desc_.reset(desc_temp.release()); | 677 local_desc_.reset(desc_temp.release()); |
| 709 | 678 |
| 710 // Transport and Media channels will be created only when offer is set. | 679 // Transport and Media channels will be created only when offer is set. |
| 711 if (action == kOffer && !CreateChannels(local_desc_->description())) { | 680 if (action == kOffer && !CreateChannels(local_desc_->description())) { |
| 712 // TODO(mallinath) - Handle CreateChannel failure, as new local description | 681 // TODO(mallinath) - Handle CreateChannel failure, as new local description |
| 713 // is applied. Restore back to old description. | 682 // is applied. Restore back to old description. |
| 714 return BadLocalSdp(desc->type(), kCreateChannelFailed, err_desc); | 683 return BadLocalSdp(desc->type(), kCreateChannelFailed, err_desc); |
| 715 } | 684 } |
| 716 | 685 |
| 717 // Remove unused channels if MediaContentDescription is rejected. | 686 // Remove unused channels if MediaContentDescription is rejected. |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1656 return true; | 1625 return true; |
| 1657 } | 1626 } |
| 1658 | 1627 |
| 1659 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, | 1628 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, |
| 1660 const std::string* bundle_transport) { | 1629 const std::string* bundle_transport) { |
| 1661 bool require_rtcp_mux = | 1630 bool require_rtcp_mux = |
| 1662 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; | 1631 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 1663 bool create_rtcp_transport_channel = !require_rtcp_mux; | 1632 bool create_rtcp_transport_channel = !require_rtcp_mux; |
| 1664 voice_channel_.reset(channel_manager_->CreateVoiceChannel( | 1633 voice_channel_.reset(channel_manager_->CreateVoiceChannel( |
| 1665 media_controller_, transport_controller_.get(), content->name, | 1634 media_controller_, transport_controller_.get(), content->name, |
| 1666 bundle_transport, create_rtcp_transport_channel, audio_options_)); | 1635 bundle_transport, create_rtcp_transport_channel, SecureRequired(), |
|
pthatcher1
2016/11/30 19:16:17
Does SecureRequired()/srtp_required() need to be p
Taylor Brandstetter
2016/12/01 02:41:34
I guess so. I just made it public because SdesPoli
| |
| 1636 audio_options_)); | |
| 1667 if (!voice_channel_) { | 1637 if (!voice_channel_) { |
| 1668 return false; | 1638 return false; |
| 1669 } | 1639 } |
| 1670 if (require_rtcp_mux) { | 1640 if (require_rtcp_mux) { |
| 1671 voice_channel_->ActivateRtcpMux(); | 1641 voice_channel_->ActivateRtcpMux(); |
| 1672 } | 1642 } |
| 1673 | 1643 |
| 1674 voice_channel_->SignalDtlsSetupFailure.connect( | 1644 voice_channel_->SignalDtlsSetupFailure.connect( |
| 1675 this, &WebRtcSession::OnDtlsSetupFailure); | 1645 this, &WebRtcSession::OnDtlsSetupFailure); |
| 1676 | 1646 |
| 1677 SignalVoiceChannelCreated(); | 1647 SignalVoiceChannelCreated(); |
| 1678 voice_channel_->SignalSentPacket.connect(this, | 1648 voice_channel_->SignalSentPacket.connect(this, |
| 1679 &WebRtcSession::OnSentPacket_w); | 1649 &WebRtcSession::OnSentPacket_w); |
| 1680 return true; | 1650 return true; |
| 1681 } | 1651 } |
| 1682 | 1652 |
| 1683 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, | 1653 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
| 1684 const std::string* bundle_transport) { | 1654 const std::string* bundle_transport) { |
| 1685 bool require_rtcp_mux = | 1655 bool require_rtcp_mux = |
| 1686 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; | 1656 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 1687 bool create_rtcp_transport_channel = !require_rtcp_mux; | 1657 bool create_rtcp_transport_channel = !require_rtcp_mux; |
| 1688 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1658 video_channel_.reset(channel_manager_->CreateVideoChannel( |
| 1689 media_controller_, transport_controller_.get(), content->name, | 1659 media_controller_, transport_controller_.get(), content->name, |
| 1690 bundle_transport, create_rtcp_transport_channel, video_options_)); | 1660 bundle_transport, create_rtcp_transport_channel, SecureRequired(), |
| 1661 video_options_)); | |
| 1691 if (!video_channel_) { | 1662 if (!video_channel_) { |
| 1692 return false; | 1663 return false; |
| 1693 } | 1664 } |
| 1694 if (require_rtcp_mux) { | 1665 if (require_rtcp_mux) { |
| 1695 video_channel_->ActivateRtcpMux(); | 1666 video_channel_->ActivateRtcpMux(); |
| 1696 } | 1667 } |
| 1697 video_channel_->SignalDtlsSetupFailure.connect( | 1668 video_channel_->SignalDtlsSetupFailure.connect( |
| 1698 this, &WebRtcSession::OnDtlsSetupFailure); | 1669 this, &WebRtcSession::OnDtlsSetupFailure); |
| 1699 | 1670 |
| 1700 SignalVideoChannelCreated(); | 1671 SignalVideoChannelCreated(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1713 quic_data_transport_->SetTransport(transport_name); | 1684 quic_data_transport_->SetTransport(transport_name); |
| 1714 return true; | 1685 return true; |
| 1715 } | 1686 } |
| 1716 #endif // HAVE_QUIC | 1687 #endif // HAVE_QUIC |
| 1717 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); | 1688 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
| 1718 bool require_rtcp_mux = | 1689 bool require_rtcp_mux = |
| 1719 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; | 1690 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 1720 bool create_rtcp_transport_channel = !sctp && !require_rtcp_mux; | 1691 bool create_rtcp_transport_channel = !sctp && !require_rtcp_mux; |
| 1721 data_channel_.reset(channel_manager_->CreateDataChannel( | 1692 data_channel_.reset(channel_manager_->CreateDataChannel( |
| 1722 transport_controller_.get(), content->name, bundle_transport, | 1693 transport_controller_.get(), content->name, bundle_transport, |
| 1723 create_rtcp_transport_channel, data_channel_type_)); | 1694 create_rtcp_transport_channel, SecureRequired(), data_channel_type_)); |
| 1724 if (!data_channel_) { | 1695 if (!data_channel_) { |
| 1725 return false; | 1696 return false; |
| 1726 } | 1697 } |
| 1727 if (require_rtcp_mux) { | 1698 if (require_rtcp_mux) { |
| 1728 data_channel_->ActivateRtcpMux(); | 1699 data_channel_->ActivateRtcpMux(); |
| 1729 } | 1700 } |
| 1730 | 1701 |
| 1731 if (sctp) { | 1702 if (sctp) { |
| 1732 data_channel_->SignalDataReceived.connect( | 1703 data_channel_->SignalDataReceived.connect( |
| 1733 this, &WebRtcSession::OnDataChannelMessageReceived); | 1704 this, &WebRtcSession::OnDataChannelMessageReceived); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2079 } | 2050 } |
| 2080 | 2051 |
| 2081 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 2052 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
| 2082 if (metrics_observer_) { | 2053 if (metrics_observer_) { |
| 2083 metrics_observer_->IncrementEnumCounter( | 2054 metrics_observer_->IncrementEnumCounter( |
| 2084 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), | 2055 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), |
| 2085 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); | 2056 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); |
| 2086 } | 2057 } |
| 2087 } | 2058 } |
| 2088 } // namespace webrtc | 2059 } // namespace webrtc |
| OLD | NEW |