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

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

Issue 2514883002: Create //webrtc/api:libjingle_peerconnection_api + refactorings. (Closed)
Patch Set: Rebase Created 3 years, 11 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/quicdatachannel_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
(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 #include "webrtc/p2p/base/transportcontroller.h"
23
24 namespace cricket {
25 class QuicTransportChannel;
26 class ReliableQuicStream;
27 } // namepsace cricket
28
29 namespace webrtc {
30
31 // QuicDataTransport creates QuicDataChannels for the PeerConnection. It also
32 // handles QUIC stream demuxing by distributing incoming QUIC streams from the
33 // QuicTransportChannel among the QuicDataChannels that it has created.
34 //
35 // QuicDataTransport reads the data channel ID from the incoming QUIC stream,
36 // then looks it up in a map of ID => QuicDataChannel. If the data channel
37 // exists, it sends the QUIC stream to the QuicDataChannel.
38 class QuicDataTransport : public sigslot::has_slots<> {
39 public:
40 QuicDataTransport(rtc::Thread* signaling_thread,
41 rtc::Thread* worker_thread,
42 rtc::Thread* network_thread,
43 cricket::TransportController* transport_controller);
44 ~QuicDataTransport() override;
45
46 // The QuicDataTransport acts like a BaseChannel with these functions.
47 bool SetTransport(const std::string& transport_name);
48 const std::string& transport_name() const { return transport_name_; }
49 const std::string& content_name() const { return content_name_; }
50 void set_content_name(const std::string& content_name) {
51 content_name_ = content_name;
52 }
53
54 // Creates a QuicDataChannel that uses this QuicDataTransport.
55 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
56 const std::string& label,
57 const DataChannelInit* config);
58
59 // Removes a QuicDataChannel with the given ID from the QuicDataTransport's
60 // data channel map.
61 void DestroyDataChannel(int id);
62
63 // True if the QuicDataTransport has a data channel with the given ID.
64 bool HasDataChannel(int id) const;
65
66 // True if the QuicDataTransport has data channels.
67 bool HasDataChannels() const;
68
69 cricket::QuicTransportChannel* quic_transport_channel() {
70 return quic_transport_channel_;
71 }
72
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
80 // Called from the QuicTransportChannel when a ReliableQuicStream is created
81 // to receive incoming data.
82 void OnIncomingStream(cricket::ReliableQuicStream* stream);
83 // Called from the ReliableQuicStream when the first QUIC stream frame is
84 // received for incoming data. The QuicDataTransport reads the data channel ID
85 // and message ID from the incoming data, then dispatches the
86 // ReliableQuicStream to the QuicDataChannel with the same data channel ID.
87 void OnDataReceived(net::QuicStreamId stream_id,
88 const char* data,
89 size_t len);
90
91 cricket::QuicTransportChannel* CreateTransportChannel(
92 const std::string& transport_name);
93 void DestroyTransportChannel(cricket::TransportChannel* transport_channel);
94
95 // Map of data channel ID => QUIC data channel values.
96 std::unordered_map<int, rtc::scoped_refptr<QuicDataChannel>>
97 data_channel_by_id_;
98 // Map of QUIC stream ID => ReliableQuicStream* values.
99 std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*>
100 quic_stream_by_id_;
101 // QuicTransportChannel for sending/receiving data.
102 cricket::QuicTransportChannel* quic_transport_channel_ = nullptr;
103 // Threads for the QUIC data channel.
104 rtc::Thread* const signaling_thread_;
105 rtc::Thread* const worker_thread_;
106 rtc::Thread* const network_thread_;
107
108 cricket::TransportController* transport_controller_;
109 std::string content_name_;
110 std::string transport_name_;
111 };
112
113 } // namespace webrtc
114
115 #endif // WEBRTC_API_QUICDATATRANSPORT_H_
OLDNEW
« no previous file with comments | « webrtc/api/quicdatachannel_unittest.cc ('k') | webrtc/api/quicdatatransport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698