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

Side by Side Diff: webrtc/api/peerconnection.cc

Issue 2166873002: Modified PeerConnection and WebRtcSession for end-to-end QuicDataChannel usage. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Change the comments and minor fix. Created 4 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
« no previous file with comments | « no previous file | webrtc/api/peerconnection_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 * 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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 PeerConnectionInterface::IceGatheringState 900 PeerConnectionInterface::IceGatheringState
901 PeerConnection::ice_gathering_state() { 901 PeerConnection::ice_gathering_state() {
902 return ice_gathering_state_; 902 return ice_gathering_state_;
903 } 903 }
904 904
905 rtc::scoped_refptr<DataChannelInterface> 905 rtc::scoped_refptr<DataChannelInterface>
906 PeerConnection::CreateDataChannel( 906 PeerConnection::CreateDataChannel(
907 const std::string& label, 907 const std::string& label,
908 const DataChannelInit* config) { 908 const DataChannelInit* config) {
909 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); 909 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel");
910 #ifdef HAVE_QUIC
911 if (session_->data_channel_type() == cricket::DCT_QUIC) {
912 // TODO(zhihuang): Handle case when config is NULL.
913 if (!config) {
914 LOG(LS_ERROR) << "Missing config for QUIC data channel.";
915 return nullptr;
916 }
917 // TODO(zhihuang): Allow unreliable or ordered QUIC data channels.
918 if (!config->reliable || config->ordered) {
919 LOG(LS_ERROR) << "QUIC data channel does not implement unreliable or "
920 "ordered delivery.";
921 return nullptr;
922 }
923 return session_->quic_data_transport()->CreateDataChannel(label, config);
924 }
925 #endif // HAVE_QUIC
926
910 bool first_datachannel = !HasDataChannels(); 927 bool first_datachannel = !HasDataChannels();
911 928
912 std::unique_ptr<InternalDataChannelInit> internal_config; 929 std::unique_ptr<InternalDataChannelInit> internal_config;
913 if (config) { 930 if (config) {
914 internal_config.reset(new InternalDataChannelInit(*config)); 931 internal_config.reset(new InternalDataChannelInit(*config));
915 } 932 }
916 rtc::scoped_refptr<DataChannelInterface> channel( 933 rtc::scoped_refptr<DataChannelInterface> channel(
917 InternalCreateDataChannel(label, internal_config.get())); 934 InternalCreateDataChannel(label, internal_config.get()));
918 if (!channel.get()) { 935 if (!channel.get()) {
919 return nullptr; 936 return nullptr;
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 if (rtc_options.offer_to_receive_video == RTCOfferAnswerOptions::kUndefined) { 1628 if (rtc_options.offer_to_receive_video == RTCOfferAnswerOptions::kUndefined) {
1612 session_options->recv_video = 1629 session_options->recv_video =
1613 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO) || 1630 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO) ||
1614 !remote_video_tracks_.empty(); 1631 !remote_video_tracks_.empty();
1615 } 1632 }
1616 session_options->bundle_enabled = 1633 session_options->bundle_enabled =
1617 session_options->bundle_enabled && 1634 session_options->bundle_enabled &&
1618 (session_options->has_audio() || session_options->has_video() || 1635 (session_options->has_audio() || session_options->has_video() ||
1619 session_options->has_data()); 1636 session_options->has_data());
1620 1637
1621 if (session_->data_channel_type() == cricket::DCT_SCTP && HasDataChannels()) { 1638 // Intentionally unset the data channel type for RTP data channel with the
1622 session_options->data_channel_type = cricket::DCT_SCTP; 1639 // second condition. Otherwise the RTP data channels would be successfully
1640 // negotiated by default and the unit tests in WebRtcDataBrowserTest will fail
1641 // when building with chromium. We want to leave RTP data channels broken, so
1642 // people won't try to use them.
1643 if (HasDataChannels() && session_->data_channel_type() != cricket::DCT_RTP) {
1644 session_options->data_channel_type = session_->data_channel_type();
1623 } 1645 }
1624 1646
1625 session_options->rtcp_cname = rtcp_cname_; 1647 session_options->rtcp_cname = rtcp_cname_;
1626 session_options->crypto_options = factory_->options().crypto_options; 1648 session_options->crypto_options = factory_->options().crypto_options;
1627 return true; 1649 return true;
1628 } 1650 }
1629 1651
1630 void PeerConnection::FinishOptionsForAnswer( 1652 void PeerConnection::FinishOptionsForAnswer(
1631 cricket::MediaSessionOptions* session_options) { 1653 cricket::MediaSessionOptions* session_options) {
1632 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of 1654 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of
1633 // ContentInfos. 1655 // ContentInfos.
1634 if (session_->remote_description()) { 1656 if (session_->remote_description()) {
1635 // Initialize the transport_options map. 1657 // Initialize the transport_options map.
1636 for (const cricket::ContentInfo& content : 1658 for (const cricket::ContentInfo& content :
1637 session_->remote_description()->description()->contents()) { 1659 session_->remote_description()->description()->contents()) {
1638 session_options->transport_options[content.name] = 1660 session_options->transport_options[content.name] =
1639 cricket::TransportOptions(); 1661 cricket::TransportOptions();
1640 } 1662 }
1641 } 1663 }
1642 AddSendStreams(session_options, senders_, rtp_data_channels_); 1664 AddSendStreams(session_options, senders_, rtp_data_channels_);
1643 session_options->bundle_enabled = 1665 session_options->bundle_enabled =
1644 session_options->bundle_enabled && 1666 session_options->bundle_enabled &&
1645 (session_options->has_audio() || session_options->has_video() || 1667 (session_options->has_audio() || session_options->has_video() ||
1646 session_options->has_data()); 1668 session_options->has_data());
1647 1669
1648 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams 1670 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams
1649 // are not signaled in the SDP so does not go through that path and must be 1671 // are not signaled in the SDP so does not go through that path and must be
1650 // handled here. 1672 // handled here.
1651 if (session_->data_channel_type() == cricket::DCT_SCTP) { 1673 // Intentionally unset the data channel type for RTP data channel. Otherwise
1652 session_options->data_channel_type = cricket::DCT_SCTP; 1674 // the RTP data channels would be successfully negotiated by default and the
1675 // unit tests in WebRtcDataBrowserTest will fail when building with chromium.
1676 // We want to leave RTP data channels broken, so people won't try to use them.
1677 if (session_->data_channel_type() != cricket::DCT_RTP) {
1678 session_options->data_channel_type = session_->data_channel_type();
1653 } 1679 }
1654 session_options->crypto_options = factory_->options().crypto_options; 1680 session_options->crypto_options = factory_->options().crypto_options;
1655 } 1681 }
1656 1682
1657 bool PeerConnection::GetOptionsForAnswer( 1683 bool PeerConnection::GetOptionsForAnswer(
1658 const MediaConstraintsInterface* constraints, 1684 const MediaConstraintsInterface* constraints,
1659 cricket::MediaSessionOptions* session_options) { 1685 cricket::MediaSessionOptions* session_options) {
1660 session_options->recv_audio = false; 1686 session_options->recv_audio = false;
1661 session_options->recv_video = false; 1687 session_options->recv_video = false;
1662 if (!ParseConstraintsForAnswer(constraints, session_options)) { 1688 if (!ParseConstraintsForAnswer(constraints, session_options)) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 RTC_DCHECK(channel->data_channel_type() == cricket::DCT_SCTP); 2073 RTC_DCHECK(channel->data_channel_type() == cricket::DCT_SCTP);
2048 sctp_data_channels_.push_back(channel); 2074 sctp_data_channels_.push_back(channel);
2049 channel->SignalClosed.connect(this, 2075 channel->SignalClosed.connect(this,
2050 &PeerConnection::OnSctpDataChannelClosed); 2076 &PeerConnection::OnSctpDataChannelClosed);
2051 } 2077 }
2052 2078
2053 return channel; 2079 return channel;
2054 } 2080 }
2055 2081
2056 bool PeerConnection::HasDataChannels() const { 2082 bool PeerConnection::HasDataChannels() const {
2083 #ifdef HAVE_QUIC
2084 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty() ||
2085 (session_->quic_data_transport() &&
2086 session_->quic_data_transport()->HasDataChannels());
2087 #else
2057 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty(); 2088 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty();
2089 #endif // HAVE_QUIC
2058 } 2090 }
2059 2091
2060 void PeerConnection::AllocateSctpSids(rtc::SSLRole role) { 2092 void PeerConnection::AllocateSctpSids(rtc::SSLRole role) {
2061 for (const auto& channel : sctp_data_channels_) { 2093 for (const auto& channel : sctp_data_channels_) {
2062 if (channel->id() < 0) { 2094 if (channel->id() < 0) {
2063 int sid; 2095 int sid;
2064 if (!sid_allocator_.AllocateSid(role, &sid)) { 2096 if (!sid_allocator_.AllocateSid(role, &sid)) {
2065 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; 2097 LOG(LS_ERROR) << "Failed to allocate SCTP sid.";
2066 continue; 2098 continue;
2067 } 2099 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 2323
2292 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, 2324 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file,
2293 int64_t max_size_bytes) { 2325 int64_t max_size_bytes) {
2294 return media_controller_->call_w()->StartEventLog(file, max_size_bytes); 2326 return media_controller_->call_w()->StartEventLog(file, max_size_bytes);
2295 } 2327 }
2296 2328
2297 void PeerConnection::StopRtcEventLog_w() { 2329 void PeerConnection::StopRtcEventLog_w() {
2298 media_controller_->call_w()->StopEventLog(); 2330 media_controller_->call_w()->StopEventLog();
2299 } 2331 }
2300 } // namespace webrtc 2332 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/peerconnection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698