Index: webrtc/api/quictransport.h |
diff --git a/webrtc/api/quictransport.h b/webrtc/api/quictransport.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..06f814cfda8246a436638497d3424d7c11eb5373 |
--- /dev/null |
+++ b/webrtc/api/quictransport.h |
@@ -0,0 +1,77 @@ |
+/* |
+ * 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_QUICTRANSPORT_H_ |
+#define WEBRTC_API_QUICTRANSPORT_H_ |
+ |
+#include <string> |
+#include <unordered_map> |
+#include <unordered_set> |
+ |
+#include "webrtc/api/quicdatachannel.h" |
+#include "webrtc/base/bytebuffer.h" |
+#include "webrtc/base/scoped_ref_ptr.h" |
pthatcher1
2016/03/30 20:34:49
If these aren't used in this file, please move the
mikescarlett
2016/04/05 19:58:51
Done.
|
+#include "webrtc/base/sigslot.h" |
+ |
+namespace net { |
+typedef uint32_t QuicStreamId; |
+} // namespace net |
+ |
+namespace cricket { |
+class QuicTransportChannel; |
+class ReliableQuicStream; |
+} // namepsace cricket |
+ |
+namespace webrtc { |
+ |
+// QuicTransport dispatches each ReliableQuicStream initiated by the |
+// remote peer to its corresponding QuicDataChannel, and encapsulates a |
pthatcher1
2016/03/30 20:34:49
Might be more clear as "by reading the data channe
mikescarlett
2016/04/05 19:58:51
Done.
|
+// <data channel id, QuicDataChannel*> map. It reads the initial stream frame |
+// sent by the remote peer's ReliableQuicStream to obtain the data channel id. |
+// If the local peer has no existing QuicDataChannel with the given id, then a |
+// new QuicDataChannel is created with the given id and remaining data from the |
+// ReliableQuicStream. Otherwise the ReliableQuicStream is dispatched to an |
+// existing QuicDataChannel, which reads the remaining data. |
pthatcher1
2016/03/30 20:34:49
Might be more clear as "if the QuicDataChannel exi
mikescarlett
2016/04/05 19:58:51
Done.
|
+// |
+// 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 QuicTransport : public sigslot::has_slots<> { |
+ public: |
+ explicit QuicTransport(cricket::QuicTransportChannel* quic_transport_channel); |
+ // Adds a QUIC data channel to the map of existing QUIC data channels. |
+ void RegisterDataChannel(QuicDataChannel* data_channel); |
+ // Removes a QUIC data channel from the map of QUIC data channels. |
+ void UnregisterDataChannel(int id); |
pthatcher1
2016/03/30 20:34:49
I think AddDataChannel and RemoveDataChannel would
mikescarlett
2016/04/05 19:58:51
Done.
|
+ bool has_data_channel(int id) const { |
pthatcher1
2016/03/30 20:34:49
HasDataChannel
mikescarlett
2016/04/05 19:58:51
Done.
|
+ return data_channel_map_.find(id) != data_channel_map_.end(); |
+ } |
+ |
+ 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, QuicDataChannel*> values. |
pthatcher1
2016/03/30 20:34:49
Might be easier to read as "data channel ID => Qui
mikescarlett
2016/04/05 19:58:51
Done.
|
+ std::unordered_map<int, QuicDataChannel*> data_channel_map_; |
pthatcher1
2016/03/30 20:34:49
I think a better name would be data_channel_by_id_
mikescarlett
2016/04/05 19:58:51
Done.
|
+ // Map of <QUIC stream id, ReliableQuicStream*> values. |
pthatcher1
2016/03/30 20:34:49
Similarly, "QUIC stream ID => ReliableQuicStream"
mikescarlett
2016/04/05 19:58:51
Done.
|
+ std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*> |
+ quic_stream_map_; |
pthatcher1
2016/03/30 20:34:49
quic_stream_by_id_
mikescarlett
2016/04/05 19:58:51
Done.
|
+}; |
+ |
+} // namespace webrtc |
+ |
+#endif // WEBRTC_API_QUICTRANSPORT_H_ |