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

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

Issue 1844803002: Modify PeerConnection for end-to-end QuicDataChannel usage (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove webrtcsdp.cc from this CL Created 4 years, 8 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
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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 session_->SignalVoiceChannelDestroyed.connect( 589 session_->SignalVoiceChannelDestroyed.connect(
590 this, &PeerConnection::OnVoiceChannelDestroyed); 590 this, &PeerConnection::OnVoiceChannelDestroyed);
591 session_->SignalVideoChannelDestroyed.connect( 591 session_->SignalVideoChannelDestroyed.connect(
592 this, &PeerConnection::OnVideoChannelDestroyed); 592 this, &PeerConnection::OnVideoChannelDestroyed);
593 session_->SignalDataChannelCreated.connect( 593 session_->SignalDataChannelCreated.connect(
594 this, &PeerConnection::OnDataChannelCreated); 594 this, &PeerConnection::OnDataChannelCreated);
595 session_->SignalDataChannelDestroyed.connect( 595 session_->SignalDataChannelDestroyed.connect(
596 this, &PeerConnection::OnDataChannelDestroyed); 596 this, &PeerConnection::OnDataChannelDestroyed);
597 session_->SignalDataChannelOpenMessage.connect( 597 session_->SignalDataChannelOpenMessage.connect(
598 this, &PeerConnection::OnDataChannelOpenMessage); 598 this, &PeerConnection::OnDataChannelOpenMessage);
599 #ifdef HAVE_QUIC
600 session_->SignalQuicTransportChannelCreated.connect(
601 this, &PeerConnection::OnQuicTransportChannelCreated);
602 #endif // HAVE_QUIC
599 return true; 603 return true;
600 } 604 }
601 605
602 rtc::scoped_refptr<StreamCollectionInterface> 606 rtc::scoped_refptr<StreamCollectionInterface>
603 PeerConnection::local_streams() { 607 PeerConnection::local_streams() {
604 return local_streams_; 608 return local_streams_;
605 } 609 }
606 610
607 rtc::scoped_refptr<StreamCollectionInterface> 611 rtc::scoped_refptr<StreamCollectionInterface>
608 PeerConnection::remote_streams() { 612 PeerConnection::remote_streams() {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 PeerConnectionInterface::IceGatheringState 830 PeerConnectionInterface::IceGatheringState
827 PeerConnection::ice_gathering_state() { 831 PeerConnection::ice_gathering_state() {
828 return ice_gathering_state_; 832 return ice_gathering_state_;
829 } 833 }
830 834
831 rtc::scoped_refptr<DataChannelInterface> 835 rtc::scoped_refptr<DataChannelInterface>
832 PeerConnection::CreateDataChannel( 836 PeerConnection::CreateDataChannel(
833 const std::string& label, 837 const std::string& label,
834 const DataChannelInit* config) { 838 const DataChannelInit* config) {
835 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); 839 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel");
840 #ifdef HAVE_QUIC
841 if (session_->data_channel_type() == cricket::DCT_QUIC) {
842 // TODO(mikescarlett): Handle case when config is NULL.
843 if (!config) {
844 LOG(LS_ERROR) << "Missing config for QUIC data channel.";
845 return nullptr;
846 }
847 // TODO(mikescarlett): Allow unreliable or ordered QUIC data channels.
848 if (!config->reliable || config->ordered) {
849 LOG(LS_ERROR) << "QUIC data channel does not implement unreliable or "
850 "ordered delivery.";
851 return nullptr;
852 }
853 return quic_data_transport_.CreateDataChannel(
854 session_->signaling_thread(), session_->worker_thread(), label, config);
855 }
856 #endif // HAVE_QUIC
857
836 bool first_datachannel = !HasDataChannels(); 858 bool first_datachannel = !HasDataChannels();
837 859
838 rtc::scoped_ptr<InternalDataChannelInit> internal_config; 860 rtc::scoped_ptr<InternalDataChannelInit> internal_config;
839 if (config) { 861 if (config) {
840 internal_config.reset(new InternalDataChannelInit(*config)); 862 internal_config.reset(new InternalDataChannelInit(*config));
841 } 863 }
842 rtc::scoped_refptr<DataChannelInterface> channel( 864 rtc::scoped_refptr<DataChannelInterface> channel(
843 InternalCreateDataChannel(label, internal_config.get())); 865 InternalCreateDataChannel(label, internal_config.get()));
844 if (!channel.get()) { 866 if (!channel.get()) {
845 return nullptr; 867 return nullptr;
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 if (rtc_options.offer_to_receive_video == RTCOfferAnswerOptions::kUndefined) { 1515 if (rtc_options.offer_to_receive_video == RTCOfferAnswerOptions::kUndefined) {
1494 session_options->recv_video = 1516 session_options->recv_video =
1495 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO) || 1517 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO) ||
1496 !remote_video_tracks_.empty(); 1518 !remote_video_tracks_.empty();
1497 } 1519 }
1498 session_options->bundle_enabled = 1520 session_options->bundle_enabled =
1499 session_options->bundle_enabled && 1521 session_options->bundle_enabled &&
1500 (session_options->has_audio() || session_options->has_video() || 1522 (session_options->has_audio() || session_options->has_video() ||
1501 session_options->has_data()); 1523 session_options->has_data());
1502 1524
1503 if (session_->data_channel_type() == cricket::DCT_SCTP && HasDataChannels()) { 1525 if (HasDataChannels()) {
1504 session_options->data_channel_type = cricket::DCT_SCTP; 1526 if (session_->data_channel_type() == cricket::DCT_SCTP) {
1527 session_options->data_channel_type = cricket::DCT_SCTP;
1528 } else if (session_->data_channel_type() == cricket::DCT_QUIC) {
1529 session_options->data_channel_type = cricket::DCT_QUIC;
pthatcher1 2016/04/12 00:58:38 Why not just do session_options->data_channel_type
mikescarlett 2016/04/13 16:53:37 Sure I'll do that. I didn't know if RTP data chann
1530 }
1505 } 1531 }
1506 return true; 1532 return true;
1507 } 1533 }
1508 1534
1509 void PeerConnection::FinishOptionsForAnswer( 1535 void PeerConnection::FinishOptionsForAnswer(
1510 cricket::MediaSessionOptions* session_options) { 1536 cricket::MediaSessionOptions* session_options) {
1511 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of 1537 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of
1512 // ContentInfos. 1538 // ContentInfos.
1513 if (session_->remote_description()) { 1539 if (session_->remote_description()) {
1514 // Initialize the transport_options map. 1540 // Initialize the transport_options map.
1515 for (const cricket::ContentInfo& content : 1541 for (const cricket::ContentInfo& content :
1516 session_->remote_description()->description()->contents()) { 1542 session_->remote_description()->description()->contents()) {
1517 session_options->transport_options[content.name] = 1543 session_options->transport_options[content.name] =
1518 cricket::TransportOptions(); 1544 cricket::TransportOptions();
1519 } 1545 }
1520 } 1546 }
1521 AddSendStreams(session_options, senders_, rtp_data_channels_); 1547 AddSendStreams(session_options, senders_, rtp_data_channels_);
1522 session_options->bundle_enabled = 1548 session_options->bundle_enabled =
1523 session_options->bundle_enabled && 1549 session_options->bundle_enabled &&
1524 (session_options->has_audio() || session_options->has_video() || 1550 (session_options->has_audio() || session_options->has_video() ||
1525 session_options->has_data()); 1551 session_options->has_data());
1526 1552
1527 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams 1553 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams
1528 // are not signaled in the SDP so does not go through that path and must be 1554 // are not signaled in the SDP so does not go through that path and must be
1529 // handled here. 1555 // handled here.
1530 if (session_->data_channel_type() == cricket::DCT_SCTP) { 1556 if (session_->data_channel_type() == cricket::DCT_SCTP) {
1531 session_options->data_channel_type = cricket::DCT_SCTP; 1557 session_options->data_channel_type = cricket::DCT_SCTP;
1532 } 1558 }
1559 if (session_->data_channel_type() == cricket::DCT_QUIC) {
1560 session_options->data_channel_type = cricket::DCT_QUIC;
1561 }
pthatcher1 2016/04/12 00:58:38 Same here.
mikescarlett 2016/04/13 16:53:37 Done.
1533 } 1562 }
1534 1563
1535 bool PeerConnection::GetOptionsForAnswer( 1564 bool PeerConnection::GetOptionsForAnswer(
1536 const MediaConstraintsInterface* constraints, 1565 const MediaConstraintsInterface* constraints,
1537 cricket::MediaSessionOptions* session_options) { 1566 cricket::MediaSessionOptions* session_options) {
1538 session_options->recv_audio = false; 1567 session_options->recv_audio = false;
1539 session_options->recv_video = false; 1568 session_options->recv_video = false;
1540 if (!ParseConstraintsForAnswer(constraints, session_options)) { 1569 if (!ParseConstraintsForAnswer(constraints, session_options)) {
1541 return false; 1570 return false;
1542 } 1571 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 RTC_DCHECK(channel->data_channel_type() == cricket::DCT_SCTP); 1943 RTC_DCHECK(channel->data_channel_type() == cricket::DCT_SCTP);
1915 sctp_data_channels_.push_back(channel); 1944 sctp_data_channels_.push_back(channel);
1916 channel->SignalClosed.connect(this, 1945 channel->SignalClosed.connect(this,
1917 &PeerConnection::OnSctpDataChannelClosed); 1946 &PeerConnection::OnSctpDataChannelClosed);
1918 } 1947 }
1919 1948
1920 return channel; 1949 return channel;
1921 } 1950 }
1922 1951
1923 bool PeerConnection::HasDataChannels() const { 1952 bool PeerConnection::HasDataChannels() const {
1953 #ifdef HAVE_QUIC
1954 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty() ||
1955 quic_data_transport_.HasDataChannels();
1956 #else
1924 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty(); 1957 return !rtp_data_channels_.empty() || !sctp_data_channels_.empty();
1958 #endif // HAVE_QUIC
1925 } 1959 }
1926 1960
1927 void PeerConnection::AllocateSctpSids(rtc::SSLRole role) { 1961 void PeerConnection::AllocateSctpSids(rtc::SSLRole role) {
1928 for (const auto& channel : sctp_data_channels_) { 1962 for (const auto& channel : sctp_data_channels_) {
1929 if (channel->id() < 0) { 1963 if (channel->id() < 0) {
1930 int sid; 1964 int sid;
1931 if (!sid_allocator_.AllocateSid(role, &sid)) { 1965 if (!sid_allocator_.AllocateSid(role, &sid)) {
1932 LOG(LS_ERROR) << "Failed to allocate SCTP sid."; 1966 LOG(LS_ERROR) << "Failed to allocate SCTP sid.";
1933 continue; 1967 continue;
1934 } 1968 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 2091
2058 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { 2092 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const {
2059 for (const auto& channel : sctp_data_channels_) { 2093 for (const auto& channel : sctp_data_channels_) {
2060 if (channel->id() == sid) { 2094 if (channel->id() == sid) {
2061 return channel; 2095 return channel;
2062 } 2096 }
2063 } 2097 }
2064 return nullptr; 2098 return nullptr;
2065 } 2099 }
2066 2100
2101 #ifdef HAVE_QUIC
2102 void PeerConnection::OnQuicTransportChannelCreated(
2103 cricket::QuicTransportChannel* channel) {
2104 quic_data_transport_.SetTransportChannel(channel);
2105 }
2106 #endif // HAVE_QUIC
2107
2067 } // namespace webrtc 2108 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698