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

Unified Diff: webrtc/api/quicdatatransport.h

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 side-by-side diff with in-line comments
Download patch
Index: webrtc/api/quicdatatransport.h
diff --git a/webrtc/api/quicdatatransport.h b/webrtc/api/quicdatatransport.h
new file mode 100644
index 0000000000000000000000000000000000000000..9da16b3273a7e48b741a8d23c59f7ae158b4a278
--- /dev/null
+++ b/webrtc/api/quicdatatransport.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_API_QUICDATATRANSPORT_H_
+#define WEBRTC_API_QUICDATATRANSPORT_H_
+
+#include <string>
+#include <unordered_map>
+
+#include "webrtc/api/datachannelinterface.h"
+#include "webrtc/api/quicdatachannel.h"
+#include "webrtc/base/scoped_ref_ptr.h"
+#include "webrtc/base/sigslot.h"
+#include "webrtc/base/thread.h"
+
+namespace net {
+typedef uint32_t QuicStreamId;
+} // namespace net
+
+namespace cricket {
+class QuicTransportChannel;
+class ReliableQuicStream;
+} // namepsace cricket
+
+namespace webrtc {
+
+// QuicDataTransport reads the data channel ID from the incming QUIC stream,
+// then
+// looks it up in a map of id => QuicDataChannel. If the data channel exists, it
+// sends the stream to the QuicDataChannel. Otherwise it creates a new
+// QuicDataChannel with the given ID.
+//
+// Each time the local peer creates a QuicDataChannel, the local peer should
+// call RegisterDataChannel() to register it to the map of QuicDataChannel ids.
+// The local peer should call UnregisterDataChannel() if the QuicDataChannel
+// should no longer be accessed.
+class QuicDataTransport : public QuicDataChannel::MessageHelper,
+ public sigslot::has_slots<> {
+ public:
+ QuicDataTransport();
+ ~QuicDataTransport() override;
+ // Sets the QUIC transport channel that will notify this class when incoming
+ // QUIC streams arrive.
+ void SetTransportChannel(
+ cricket::QuicTransportChannel* quic_transport_channel);
+ // Adds a QUIC data channel to the map of existing QUIC data channels.
+ virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
+ rtc::Thread* signaling_thread,
+ rtc::Thread* worker_thread,
+ const std::string& label,
+ const DataChannelInit* config);
+ // Removes a QUIC data channel from the map of QUIC data channels.
+ virtual void DestroyDataChannel(int id);
+ bool HasDataChannel(int id) const;
+ bool HasDataChannels() const;
+
+ // QuicDataChannel::MessageHelper override.
+ void Encode(const DataBuffer& message,
+ int data_channel_id,
+ uint64_t message_id,
+ rtc::CopyOnWriteBuffer* payload) const override;
+
+ private:
+ // Called by QuicTransportChannel when a QUIC stream is created for incoming
+ // data.
+ void OnIncomingStream(cricket::ReliableQuicStream* stream);
+ // Called by ReliableQuicStream when the first QUIC stream frame is received
+ // for incoming data.
+ void OnDataReceived(net::QuicStreamId stream_id,
+ const char* data,
+ size_t len);
+
+ // Map of data channel ID => QUIC data channel values.
+ std::unordered_map<int, rtc::scoped_refptr<QuicDataChannel>>
+ data_channel_by_id_;
+ // Map of QUIC stream ID => ReliableQuicStream* values.
+ std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*>
+ quic_stream_by_id_;
+ // QuicTransportChannel for sending/receiving data.
+ cricket::QuicTransportChannel* quic_transport_channel_ = nullptr;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_API_QUICDATATRANSPORT_H_

Powered by Google App Engine
This is Rietveld 408576698