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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_API_QUICDATATRANSPORT_H_
12 #define WEBRTC_API_QUICDATATRANSPORT_H_
13
14 #include <string>
15 #include <unordered_map>
16
17 #include "webrtc/api/datachannelinterface.h"
18 #include "webrtc/api/quicdatachannel.h"
19 #include "webrtc/base/scoped_ref_ptr.h"
20 #include "webrtc/base/sigslot.h"
21 #include "webrtc/base/thread.h"
22
23 namespace net {
24 typedef uint32_t QuicStreamId;
25 } // namespace net
26
27 namespace cricket {
28 class QuicTransportChannel;
29 class ReliableQuicStream;
30 } // namepsace cricket
31
32 namespace webrtc {
33
34 // QuicDataTransport reads the data channel ID from the incming QUIC stream,
35 // then
36 // looks it up in a map of id => QuicDataChannel. If the data channel exists, it
37 // sends the stream to the QuicDataChannel. Otherwise it creates a new
38 // QuicDataChannel with the given ID.
39 //
40 // Each time the local peer creates a QuicDataChannel, the local peer should
41 // call RegisterDataChannel() to register it to the map of QuicDataChannel ids.
42 // The local peer should call UnregisterDataChannel() if the QuicDataChannel
43 // should no longer be accessed.
44 class QuicDataTransport : public QuicDataChannel::MessageHelper,
45 public sigslot::has_slots<> {
46 public:
47 QuicDataTransport();
48 ~QuicDataTransport() override;
49 // Sets the QUIC transport channel that will notify this class when incoming
50 // QUIC streams arrive.
51 void SetTransportChannel(
52 cricket::QuicTransportChannel* quic_transport_channel);
53 // Adds a QUIC data channel to the map of existing QUIC data channels.
54 virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
55 rtc::Thread* signaling_thread,
56 rtc::Thread* worker_thread,
57 const std::string& label,
58 const DataChannelInit* config);
59 // Removes a QUIC data channel from the map of QUIC data channels.
60 virtual void DestroyDataChannel(int id);
61 bool HasDataChannel(int id) const;
62 bool HasDataChannels() const;
63
64 // QuicDataChannel::MessageHelper override.
65 void Encode(const DataBuffer& message,
66 int data_channel_id,
67 uint64_t message_id,
68 rtc::CopyOnWriteBuffer* payload) const override;
69
70 private:
71 // Called by QuicTransportChannel when a QUIC stream is created for incoming
72 // data.
73 void OnIncomingStream(cricket::ReliableQuicStream* stream);
74 // Called by ReliableQuicStream when the first QUIC stream frame is received
75 // for incoming data.
76 void OnDataReceived(net::QuicStreamId stream_id,
77 const char* data,
78 size_t len);
79
80 // Map of data channel ID => QUIC data channel values.
81 std::unordered_map<int, rtc::scoped_refptr<QuicDataChannel>>
82 data_channel_by_id_;
83 // Map of QUIC stream ID => ReliableQuicStream* values.
84 std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*>
85 quic_stream_by_id_;
86 // QuicTransportChannel for sending/receiving data.
87 cricket::QuicTransportChannel* quic_transport_channel_ = nullptr;
88 };
89
90 } // namespace webrtc
91
92 #endif // WEBRTC_API_QUICDATATRANSPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698