Modify PeerConnection for end-to-end QuicDataChannel usage
To allow end-to-end QuicDataChannel usage with a
PeerConnection, RTCConfiguration has been modified to
include a boolean for whether to do QUIC, since negotiation of
QUIC is not implemented. If one peer does QUIC, then it will be
assumed that the other peer must do QUIC or the connection
will fail.
PeerConnection has been modified to create data channels of type
QuicDataChannel when the peer wants to do QUIC.
WebRtcSession has been modified to use a QuicTransportChannel
instead of a DtlsTransportChannelWrapper/DataChannel
when QUIC should be used.
Modification of previous in-flight CL: https://codereview.chromium.org/1844803002/
Review-Url: https://codereview.webrtc.org/2089553002
Cr-Commit-Position: refs/heads/master@{#13470}
diff --git a/webrtc/api/quicdatachannel.cc b/webrtc/api/quicdatachannel.cc
index f4f5732..5493382 100644
--- a/webrtc/api/quicdatachannel.cc
+++ b/webrtc/api/quicdatachannel.cc
@@ -61,10 +61,12 @@
QuicDataChannel::QuicDataChannel(rtc::Thread* signaling_thread,
rtc::Thread* worker_thread,
+ rtc::Thread* network_thread,
const std::string& label,
const DataChannelInit& config)
: signaling_thread_(signaling_thread),
worker_thread_(worker_thread),
+ network_thread_(network_thread),
id_(config.id),
state_(kConnecting),
buffered_amount_(0),
@@ -91,12 +93,12 @@
<< " is not open so cannot send.";
return false;
}
- return worker_thread_->Invoke<bool>(
- RTC_FROM_HERE, rtc::Bind(&QuicDataChannel::Send_w, this, buffer));
+ return network_thread_->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&QuicDataChannel::Send_n, this, buffer));
}
-bool QuicDataChannel::Send_w(const DataBuffer& buffer) {
- RTC_DCHECK(worker_thread_->IsCurrent());
+bool QuicDataChannel::Send_n(const DataBuffer& buffer) {
+ RTC_DCHECK(network_thread_->IsCurrent());
// Encode and send the header containing the data channel ID and message ID.
rtc::CopyOnWriteBuffer header;
@@ -256,7 +258,7 @@
}
void QuicDataChannel::OnIncomingMessage(Message&& message) {
- RTC_DCHECK(worker_thread_->IsCurrent());
+ RTC_DCHECK(network_thread_->IsCurrent());
RTC_DCHECK(message.stream);
if (!observer_) {
LOG(LS_WARNING) << "QUIC data channel " << id_
@@ -295,7 +297,7 @@
void QuicDataChannel::OnDataReceived(net::QuicStreamId stream_id,
const char* data,
size_t len) {
- RTC_DCHECK(worker_thread_->IsCurrent());
+ RTC_DCHECK(network_thread_->IsCurrent());
RTC_DCHECK(data);
const auto& kv = incoming_quic_messages_.find(stream_id);
if (kv == incoming_quic_messages_.end()) {
@@ -325,7 +327,7 @@
}
void QuicDataChannel::OnReadyToSend(cricket::TransportChannel* channel) {
- RTC_DCHECK(worker_thread_->IsCurrent());
+ RTC_DCHECK(network_thread_->IsCurrent());
RTC_DCHECK(channel == quic_transport_channel_);
LOG(LS_INFO) << "QuicTransportChannel is ready to send";
invoker_.AsyncInvoke<void>(
@@ -342,7 +344,7 @@
void QuicDataChannel::OnIncomingQueuedStreamClosed(net::QuicStreamId stream_id,
int error) {
- RTC_DCHECK(worker_thread_->IsCurrent());
+ RTC_DCHECK(network_thread_->IsCurrent());
LOG(LS_VERBOSE) << "Incoming queued stream " << stream_id << " is closed.";
incoming_quic_messages_.erase(stream_id);
}