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

Unified Diff: webrtc/api/peerconnection.cc

Issue 2089553002: Refactoring on QUIC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Disable quic for review. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/api/peerconnection.cc
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index b9cb83e724de78db6683bd0dc242afb6d80a928a..4236205accc6150810198cab11a083ccc1932fa3 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -591,7 +591,13 @@ bool PeerConnection::Initialize(
media_controller_.reset(
factory_->CreateMediaController(configuration.media_config));
-
+#ifdef HAVE_QUIC
+ if (configuration.enable_quic) {
+ quic_data_transport_.reset(new QuicDataTransport(
+ factory_->signaling_thread(), factory_->worker_thread(),
+ factory_->network_thread()));
+ }
+#endif // HAVE_QUIC
session_.reset(
new WebRtcSession(media_controller_.get(), factory_->network_thread(),
factory_->worker_thread(), factory_->signaling_thread(),
@@ -618,6 +624,10 @@ bool PeerConnection::Initialize(
this, &PeerConnection::OnDataChannelDestroyed);
session_->SignalDataChannelOpenMessage.connect(
this, &PeerConnection::OnDataChannelOpenMessage);
+#ifdef HAVE_QUIC
+ session_->SignalQuicTransportChannelCreated.connect(
+ this, &PeerConnection::OnQuicTransportChannelCreated);
+#endif // HAVE_QUIC
return true;
}
@@ -863,6 +873,23 @@ PeerConnection::CreateDataChannel(
const std::string& label,
const DataChannelInit* config) {
TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel");
+#ifdef HAVE_QUIC
+ if (session_->data_channel_type() == cricket::DCT_QUIC) {
+ // TODO(mikescarlett): Handle case when config is NULL.
+ if (!config) {
+ LOG(LS_ERROR) << "Missing config for QUIC data channel.";
+ return nullptr;
+ }
+ // TODO(mikescarlett): Allow unreliable or ordered QUIC data channels.
+ if (!config->reliable || config->ordered) {
+ LOG(LS_ERROR) << "QUIC data channel does not implement unreliable or "
+ "ordered delivery.";
+ return nullptr;
+ }
+ return quic_data_transport_->CreateDataChannel(label, config);
+ }
+#endif // HAVE_QUIC
+
bool first_datachannel = !HasDataChannels();
std::unique_ptr<InternalDataChannelInit> internal_config;
@@ -1544,8 +1571,8 @@ bool PeerConnection::GetOptionsForOffer(
(session_options->has_audio() || session_options->has_video() ||
session_options->has_data());
- if (session_->data_channel_type() == cricket::DCT_SCTP && HasDataChannels()) {
- session_options->data_channel_type = cricket::DCT_SCTP;
+ if (HasDataChannels()) {
+ session_options->data_channel_type = session_->data_channel_type();
}
session_options->rtcp_cname = rtcp_cname_;
@@ -1573,9 +1600,7 @@ void PeerConnection::FinishOptionsForAnswer(
// RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams
// are not signaled in the SDP so does not go through that path and must be
// handled here.
- if (session_->data_channel_type() == cricket::DCT_SCTP) {
- session_options->data_channel_type = cricket::DCT_SCTP;
- }
+ session_options->data_channel_type = session_->data_channel_type();
}
bool PeerConnection::GetOptionsForAnswer(
@@ -1978,7 +2003,12 @@ rtc::scoped_refptr<DataChannel> PeerConnection::InternalCreateDataChannel(
}
bool PeerConnection::HasDataChannels() const {
+#ifdef HAVE_QUIC
+ return !rtp_data_channels_.empty() || !sctp_data_channels_.empty() ||
+ (quic_data_transport_ && quic_data_transport_->HasDataChannels());
+#else
return !rtp_data_channels_.empty() || !sctp_data_channels_.empty();
+#endif // HAVE_QUIC
}
void PeerConnection::AllocateSctpSids(rtc::SSLRole role) {
@@ -2193,4 +2223,12 @@ bool PeerConnection::ReconfigurePortAllocator_n(
return true;
}
+#ifdef HAVE_QUIC
+void PeerConnection::OnQuicTransportChannelCreated(
+ cricket::QuicTransportChannel* channel) {
+ RTC_DCHECK(signaling_thread()->IsCurrent());
+ quic_data_transport_->SetTransportChannel(channel);
+}
+#endif // HAVE_QUIC
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698