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

Side by Side Diff: webrtc/p2p/base/transportcontroller.h

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Set media engine on voice channel Created 5 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 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_P2P_BASE_TRANSPORTCONTROLLER_H_
12 #define WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_
13
14 #include <map>
15 #include <string>
16 #include <vector>
17
18 #include "webrtc/base/sigslot.h"
19 #include "webrtc/base/sslstreamadapter.h"
20 #include "webrtc/p2p/base/candidate.h"
21 #include "webrtc/p2p/base/transport.h"
22
23 namespace rtc {
24 class Thread;
25 }
26
27 namespace cricket {
28
29 class TransportController : public sigslot::has_slots<>,
30 public rtc::MessageHandler {
31 public:
32 TransportController(rtc::Thread* signaling_thread,
33 rtc::Thread* worker_thread,
34 PortAllocator* port_allocator);
35
36 virtual ~TransportController();
37
38 rtc::Thread* signaling_thread() const { return signaling_thread_; }
39 rtc::Thread* worker_thread() const { return worker_thread_; }
40 PortAllocator* port_allocator() const { return port_allocator_; }
41
42 void SetIceConnectionReceivingTimeout(int timeout_ms);
43 void SetIceRole(IceRole ice_role);
44
45 // Takes ownership of identity and passes it down to transports
46 bool SetIdentity(rtc::SSLIdentity* identity);
pthatcher2 2015/08/19 18:32:16 Can you organize these into an order like so? 1.
Taylor Brandstetter 2015/08/25 01:04:06 Done.
47
48 // Caller owns returned identity
49 bool GetIdentity(const std::string& transport_name,
50 rtc::SSLIdentity** identity);
51
52 // Caller owns returned certificate
53 bool GetRemoteCertificate(const std::string& transport_name,
54 rtc::SSLCertificate** cert);
55
56 bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version);
57 bool SetLocalTransportDescription(const std::string& transport_name,
58 const TransportDescription& tdesc,
59 ContentAction action,
60 std::string* err);
61 bool SetRemoteTransportDescription(const std::string& transport_name,
62 const TransportDescription& tdesc,
63 ContentAction action,
64 std::string* err);
65 bool AddRemoteCandidates(const std::string& transport_name,
66 const Candidates& candidates,
67 std::string* err);
68
69 bool ReadyForRemoteCandidates(const std::string& transport_name);
70
71 bool GetSslRole(rtc::SSLRole* role);
72 bool GetStats(const std::string& transport_name, TransportStats* stats);
73
74 virtual TransportChannel* CreateTransportChannel_w(
75 const std::string& transport_name,
76 int component);
77 virtual void DestroyTransportChannel_w(const std::string& transport_name,
78 int component);
79
80 void ConnectChannels();
81
82 // All of these signals are fired on the signalling thread.
83 sigslot::signal1<ConnectionState> SignalConnectionState;
84 sigslot::signal1<bool> SignalReceiving;
85 sigslot::signal1<GatheringState> SignalGatheringState;
pthatcher2 2015/08/19 18:32:16 Can you comment on each of these about how they ag
Taylor Brandstetter 2015/08/25 01:04:06 Can I just say "refer to the W3C draft"? :)
pthatcher1 2015/08/25 18:40:38 That's not very useful for someone trying to read
Taylor Brandstetter 2015/08/25 20:39:54 Done.
86 // (transport_name, candidates)
87 sigslot::signal2<const std::string&, const Candidates&>
88 SignalCandidatesGathered;
89
90 protected:
91 virtual void OnMessage(rtc::Message* pmsg);
92
93 // protected and virtual so we can override it in unit tests.
94 virtual Transport* CreateTransport_w(const std::string& transport_name);
95
96 // for unit tests
97 const std::map<std::string, Transport*>& transports() { return transports_; }
98
99 Transport* GetOrCreateTransport_w(const std::string& transport_name);
100 Transport* GetTransport_w(const std::string& transport_name);
101 void DestroyTransport_w(const std::string& transport_name);
102 void DestroyAllTransports_w();
pthatcher2 2015/08/19 18:32:16 Why are the above protected? Also for unit tests?
Taylor Brandstetter 2015/08/25 01:04:06 I don't remember... I'm making them private again
103
104 private:
105 void SetIceConnectionReceivingTimeout_w(int timeout_ms);
106 void SetIceRole_w(IceRole ice_role);
107 bool SetIdentity_w(rtc::SSLIdentity* identity);
108 bool GetIdentity_w(const std::string& transport_name,
109 rtc::SSLIdentity** identity);
110 bool GetRemoteCertificate_w(const std::string& transport_name,
111 rtc::SSLCertificate** cert);
112 bool SetSslMaxProtocolVersion_w(rtc::SSLProtocolVersion version);
113 void ConnectChannels_w();
114 bool SetLocalTransportDescription_w(const std::string& transport_name,
115 const TransportDescription& tdesc,
116 ContentAction action,
117 std::string* err);
118 bool SetRemoteTransportDescription_w(const std::string& transport_name,
119 const TransportDescription& tdesc,
120 ContentAction action,
121 std::string* err);
122 bool AddRemoteCandidates_w(const std::string& transport_name,
123 const Candidates& candidates,
124 std::string* err);
125 bool ReadyForRemoteCandidates_w(const std::string& transport_name);
126 bool GetSslRole_w(rtc::SSLRole* role);
127 bool GetStats_w(const std::string& transport_name, TransportStats* stats);
pthatcher2 2015/08/19 18:32:16 Can you put these in the same order I suggested fo
Taylor Brandstetter 2015/08/25 01:04:06 Done.
128
129 // Handlers for signals from Transport.
130 void OnTransportConnecting_w(Transport* transport);
131 void OnTransportWritableState_w(Transport* transport);
132 void OnTransportReceivingState_w(Transport* transport);
133 void OnTransportGatheringState_w(Transport* transport);
134 void OnTransportRouteChange_w(Transport* transport,
135 int component,
136 const Candidate& candidate);
137 void OnTransportRoleConflict_w();
138 void OnTransportCompleted_w(Transport* transport);
139 void OnTransportFailed_w(Transport* transport);
140 void OnTransportCandidatesGathered_w(
141 Transport* transport,
142 const std::vector<Candidate>& candidates);
143
144 // Update our internal aggregate Transport states,
145 // and signal if they changed.
146 void UpdateState_w();
pthatcher2 2015/08/19 18:32:16 I'd call this UpdateAggregateStates_w() and just r
Taylor Brandstetter 2015/08/25 01:04:06 Done.
147
148 // Update aggregate candidate gathering state
149 void UpdateGatheringState_w();
pthatcher2 2015/08/19 18:32:16 I'd call this UpdateAggregateGatheringState_w() an
Taylor Brandstetter 2015/08/25 01:04:06 Done.
150
151 rtc::Thread* const signaling_thread_;
152 rtc::Thread* const worker_thread_;
153 PortAllocator* const port_allocator_;
154
155 // Timeout value in milliseconds for which no ICE connection receives
156 // any packets
157 int ice_receiving_timeout_ms_;
pthatcher2 2015/08/19 18:32:16 Rather than putting the default values in the cons
Taylor Brandstetter 2015/08/25 01:04:06 Ah; I'm still not used to most the C++11 features.
158 IceRole ice_role_;
pthatcher2 2015/08/19 18:32:16 Can we do a similar re-ordering here with fields:
Taylor Brandstetter 2015/08/25 01:04:06 Done.
159 rtc::scoped_ptr<rtc::SSLIdentity> identity_;
160 rtc::SSLProtocolVersion ssl_max_version_;
161 std::map<std::string, Transport*> transports_;
pthatcher2 2015/08/19 18:32:16 Given that there are usually going to be 1-3 trans
Taylor Brandstetter 2015/08/25 01:04:06 But given that the most common operation is lookin
pthatcher1 2015/08/25 18:40:38 If you have a GetTransport(name) method, it doesn'
162
163 // Flag which will be set to true after the first role switch
164 bool ice_role_switch_;
165 uint64 ice_tiebreaker_;
166
167 // Aggregate state for Transports
168 ConnectionState connection_state_;
169 bool receiving_;
170 bool candidates_allocated_;
pthatcher2 2015/08/19 18:32:16 This looks like it isn't used anywhere.
Taylor Brandstetter 2015/08/25 01:04:06 Yep, that got replaced by gathering_state_. Remove
171 GatheringState gathering_state_;
172 };
173
174 } // namespace cricket
175
176 #endif // WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698