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

Side by Side Diff: webrtc/api/quicdatatransport.h

Issue 2166873002: Modified PeerConnection and WebRtcSession for end-to-end QuicDataChannel usage. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Change the comments and minor fix. Created 4 years, 4 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
« no previous file with comments | « webrtc/api/peerconnectioninterface_unittest.cc ('k') | webrtc/api/quicdatatransport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_API_QUICDATATRANSPORT_H_ 11 #ifndef WEBRTC_API_QUICDATATRANSPORT_H_
12 #define WEBRTC_API_QUICDATATRANSPORT_H_ 12 #define WEBRTC_API_QUICDATATRANSPORT_H_
13 13
14 #include <string> 14 #include <string>
15 #include <unordered_map> 15 #include <unordered_map>
16 16
17 #include "webrtc/api/datachannelinterface.h" 17 #include "webrtc/api/datachannelinterface.h"
18 #include "webrtc/api/quicdatachannel.h" 18 #include "webrtc/api/quicdatachannel.h"
19 #include "webrtc/base/scoped_ref_ptr.h" 19 #include "webrtc/base/scoped_ref_ptr.h"
20 #include "webrtc/base/sigslot.h" 20 #include "webrtc/base/sigslot.h"
21 #include "webrtc/base/thread.h" 21 #include "webrtc/base/thread.h"
22 #include "webrtc/p2p/base/transportcontroller.h"
22 23
23 namespace cricket { 24 namespace cricket {
24 class QuicTransportChannel; 25 class QuicTransportChannel;
25 class ReliableQuicStream; 26 class ReliableQuicStream;
26 } // namepsace cricket 27 } // namepsace cricket
27 28
28 namespace webrtc { 29 namespace webrtc {
29 30
30 // QuicDataTransport creates QuicDataChannels for the PeerConnection. It also 31 // QuicDataTransport creates QuicDataChannels for the PeerConnection. It also
31 // handles QUIC stream demuxing by distributing incoming QUIC streams from the 32 // handles QUIC stream demuxing by distributing incoming QUIC streams from the
32 // QuicTransportChannel among the QuicDataChannels that it has created. 33 // QuicTransportChannel among the QuicDataChannels that it has created.
33 // 34 //
34 // QuicDataTransport reads the data channel ID from the incoming QUIC stream, 35 // QuicDataTransport reads the data channel ID from the incoming QUIC stream,
35 // then looks it up in a map of ID => QuicDataChannel. If the data channel 36 // then looks it up in a map of ID => QuicDataChannel. If the data channel
36 // exists, it sends the QUIC stream to the QuicDataChannel. 37 // exists, it sends the QUIC stream to the QuicDataChannel.
37 class QuicDataTransport : public sigslot::has_slots<> { 38 class QuicDataTransport : public sigslot::has_slots<> {
38 public: 39 public:
39 QuicDataTransport(rtc::Thread* signaling_thread, 40 QuicDataTransport(rtc::Thread* signaling_thread,
40 rtc::Thread* worker_thread, 41 rtc::Thread* worker_thread,
41 rtc::Thread* network_thread); 42 rtc::Thread* network_thread,
43 cricket::TransportController* transport_controller);
42 ~QuicDataTransport() override; 44 ~QuicDataTransport() override;
43 45
44 // Sets the QUIC transport channel for the QuicDataChannels and the 46 // The QuicDataTransport acts like a BaseChannel with these functions.
45 // QuicDataTransport. Returns false if a different QUIC transport channel is 47 bool SetTransport(const std::string& transport_name);
46 // already set, the QUIC transport channel cannot be set for any of the 48 const std::string& transport_name() const { return transport_name_; }
47 // QuicDataChannels, or |channel| is NULL. 49 const std::string& content_name() const { return content_name_; }
48 bool SetTransportChannel(cricket::QuicTransportChannel* channel); 50 void set_content_name(const std::string& content_name) {
51 content_name_ = content_name;
52 }
49 53
50 // Creates a QuicDataChannel that uses this QuicDataTransport. 54 // Creates a QuicDataChannel that uses this QuicDataTransport.
51 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( 55 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
52 const std::string& label, 56 const std::string& label,
53 const DataChannelInit* config); 57 const DataChannelInit* config);
54 58
55 // Removes a QuicDataChannel with the given ID from the QuicDataTransport's 59 // Removes a QuicDataChannel with the given ID from the QuicDataTransport's
56 // data channel map. 60 // data channel map.
57 void DestroyDataChannel(int id); 61 void DestroyDataChannel(int id);
58 62
59 // True if the QuicDataTransport has a data channel with the given ID. 63 // True if the QuicDataTransport has a data channel with the given ID.
60 bool HasDataChannel(int id) const; 64 bool HasDataChannel(int id) const;
61 65
62 // True if the QuicDataTransport has data channels. 66 // True if the QuicDataTransport has data channels.
63 bool HasDataChannels() const; 67 bool HasDataChannels() const;
64 68
69 cricket::QuicTransportChannel* quic_transport_channel() {
70 return quic_transport_channel_;
71 }
72
65 private: 73 private:
74 // Sets the QUIC transport channel for the QuicDataChannels and the
75 // QuicDataTransport. Returns false if a different QUIC transport channel is
76 // already set, the QUIC transport channel cannot be set for any of the
77 // QuicDataChannels, or |channel| is NULL.
78 bool SetTransportChannel(cricket::QuicTransportChannel* channel);
79
66 // Called from the QuicTransportChannel when a ReliableQuicStream is created 80 // Called from the QuicTransportChannel when a ReliableQuicStream is created
67 // to receive incoming data. 81 // to receive incoming data.
68 void OnIncomingStream(cricket::ReliableQuicStream* stream); 82 void OnIncomingStream(cricket::ReliableQuicStream* stream);
69 // Called from the ReliableQuicStream when the first QUIC stream frame is 83 // Called from the ReliableQuicStream when the first QUIC stream frame is
70 // received for incoming data. The QuicDataTransport reads the data channel ID 84 // received for incoming data. The QuicDataTransport reads the data channel ID
71 // and message ID from the incoming data, then dispatches the 85 // and message ID from the incoming data, then dispatches the
72 // ReliableQuicStream to the QuicDataChannel with the same data channel ID. 86 // ReliableQuicStream to the QuicDataChannel with the same data channel ID.
73 void OnDataReceived(net::QuicStreamId stream_id, 87 void OnDataReceived(net::QuicStreamId stream_id,
74 const char* data, 88 const char* data,
75 size_t len); 89 size_t len);
76 90
91 cricket::QuicTransportChannel* CreateTransportChannel(
92 const std::string& transport_name);
93 void DestroyTransportChannel(cricket::TransportChannel* transport_channel);
94
77 // Map of data channel ID => QUIC data channel values. 95 // Map of data channel ID => QUIC data channel values.
78 std::unordered_map<int, rtc::scoped_refptr<QuicDataChannel>> 96 std::unordered_map<int, rtc::scoped_refptr<QuicDataChannel>>
79 data_channel_by_id_; 97 data_channel_by_id_;
80 // Map of QUIC stream ID => ReliableQuicStream* values. 98 // Map of QUIC stream ID => ReliableQuicStream* values.
81 std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*> 99 std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*>
82 quic_stream_by_id_; 100 quic_stream_by_id_;
83 // QuicTransportChannel for sending/receiving data. 101 // QuicTransportChannel for sending/receiving data.
84 cricket::QuicTransportChannel* quic_transport_channel_ = nullptr; 102 cricket::QuicTransportChannel* quic_transport_channel_ = nullptr;
85 // Threads for the QUIC data channel. 103 // Threads for the QUIC data channel.
86 rtc::Thread* const signaling_thread_; 104 rtc::Thread* const signaling_thread_;
87 rtc::Thread* const worker_thread_; 105 rtc::Thread* const worker_thread_;
88 rtc::Thread* const network_thread_; 106 rtc::Thread* const network_thread_;
107
108 cricket::TransportController* transport_controller_;
109 std::string content_name_;
110 std::string transport_name_;
89 }; 111 };
90 112
91 } // namespace webrtc 113 } // namespace webrtc
92 114
93 #endif // WEBRTC_API_QUICDATATRANSPORT_H_ 115 #endif // WEBRTC_API_QUICDATATRANSPORT_H_
OLDNEW
« no previous file with comments | « webrtc/api/peerconnectioninterface_unittest.cc ('k') | webrtc/api/quicdatatransport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698