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

Side by Side Diff: webrtc/p2p/client/basicportallocator.h

Issue 1956453003: Relanding: Implement RTCConfiguration.iceCandidatePoolSize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing uninitialized variable (noticed by msan) Created 4 years, 7 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
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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
(...skipping 20 matching lines...) Expand all
31 BasicPortAllocator(rtc::NetworkManager* network_manager, 31 BasicPortAllocator(rtc::NetworkManager* network_manager,
32 rtc::PacketSocketFactory* socket_factory, 32 rtc::PacketSocketFactory* socket_factory,
33 const ServerAddresses& stun_servers); 33 const ServerAddresses& stun_servers);
34 BasicPortAllocator(rtc::NetworkManager* network_manager, 34 BasicPortAllocator(rtc::NetworkManager* network_manager,
35 const ServerAddresses& stun_servers, 35 const ServerAddresses& stun_servers,
36 const rtc::SocketAddress& relay_server_udp, 36 const rtc::SocketAddress& relay_server_udp,
37 const rtc::SocketAddress& relay_server_tcp, 37 const rtc::SocketAddress& relay_server_tcp,
38 const rtc::SocketAddress& relay_server_ssl); 38 const rtc::SocketAddress& relay_server_ssl);
39 virtual ~BasicPortAllocator(); 39 virtual ~BasicPortAllocator();
40 40
41 void SetIceServers(
42 const ServerAddresses& stun_servers,
43 const std::vector<RelayServerConfig>& turn_servers) override {
44 stun_servers_ = stun_servers;
45 turn_servers_ = turn_servers;
46 }
47
48 // Set to kDefaultNetworkIgnoreMask by default. 41 // Set to kDefaultNetworkIgnoreMask by default.
49 void SetNetworkIgnoreMask(int network_ignore_mask) override { 42 void SetNetworkIgnoreMask(int network_ignore_mask) override {
50 // TODO(phoglund): implement support for other types than loopback. 43 // TODO(phoglund): implement support for other types than loopback.
51 // See https://code.google.com/p/webrtc/issues/detail?id=4288. 44 // See https://code.google.com/p/webrtc/issues/detail?id=4288.
52 // Then remove set_network_ignore_list from NetworkManager. 45 // Then remove set_network_ignore_list from NetworkManager.
53 network_ignore_mask_ = network_ignore_mask; 46 network_ignore_mask_ = network_ignore_mask;
54 } 47 }
55 48
56 int network_ignore_mask() const { return network_ignore_mask_; } 49 int network_ignore_mask() const { return network_ignore_mask_; }
57 50
58 rtc::NetworkManager* network_manager() { return network_manager_; } 51 rtc::NetworkManager* network_manager() { return network_manager_; }
59 52
60 // If socket_factory() is set to NULL each PortAllocatorSession 53 // If socket_factory() is set to NULL each PortAllocatorSession
61 // creates its own socket factory. 54 // creates its own socket factory.
62 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } 55 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; }
63 56
64 const ServerAddresses& stun_servers() const {
65 return stun_servers_;
66 }
67
68 const std::vector<RelayServerConfig>& turn_servers() const {
69 return turn_servers_;
70 }
71 virtual void AddTurnServer(const RelayServerConfig& turn_server) {
72 turn_servers_.push_back(turn_server);
73 }
74
75 PortAllocatorSession* CreateSessionInternal( 57 PortAllocatorSession* CreateSessionInternal(
76 const std::string& content_name, 58 const std::string& content_name,
77 int component, 59 int component,
78 const std::string& ice_ufrag, 60 const std::string& ice_ufrag,
79 const std::string& ice_pwd) override; 61 const std::string& ice_pwd) override;
80 62
63 // Convenience method that adds a TURN server to the configuration.
64 void AddTurnServer(const RelayServerConfig& turn_server);
65
81 private: 66 private:
82 void Construct(); 67 void Construct();
83 68
84 rtc::NetworkManager* network_manager_; 69 rtc::NetworkManager* network_manager_;
85 rtc::PacketSocketFactory* socket_factory_; 70 rtc::PacketSocketFactory* socket_factory_;
86 ServerAddresses stun_servers_;
87 std::vector<RelayServerConfig> turn_servers_;
88 bool allow_tcp_listen_; 71 bool allow_tcp_listen_;
89 int network_ignore_mask_ = rtc::kDefaultNetworkIgnoreMask; 72 int network_ignore_mask_ = rtc::kDefaultNetworkIgnoreMask;
90 }; 73 };
91 74
92 struct PortConfiguration; 75 struct PortConfiguration;
93 class AllocationSequence; 76 class AllocationSequence;
94 77
95 class BasicPortAllocatorSession : public PortAllocatorSession, 78 class BasicPortAllocatorSession : public PortAllocatorSession,
96 public rtc::MessageHandler { 79 public rtc::MessageHandler {
97 public: 80 public:
98 BasicPortAllocatorSession(BasicPortAllocator* allocator, 81 BasicPortAllocatorSession(BasicPortAllocator* allocator,
99 const std::string& content_name, 82 const std::string& content_name,
100 int component, 83 int component,
101 const std::string& ice_ufrag, 84 const std::string& ice_ufrag,
102 const std::string& ice_pwd); 85 const std::string& ice_pwd);
103 ~BasicPortAllocatorSession(); 86 ~BasicPortAllocatorSession();
104 87
105 virtual BasicPortAllocator* allocator() { return allocator_; } 88 virtual BasicPortAllocator* allocator() { return allocator_; }
106 rtc::Thread* network_thread() { return network_thread_; } 89 rtc::Thread* network_thread() { return network_thread_; }
107 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; } 90 rtc::PacketSocketFactory* socket_factory() { return socket_factory_; }
108 91
109 void StartGettingPorts() override; 92 void StartGettingPorts() override;
110 void StopGettingPorts() override; 93 void StopGettingPorts() override;
111 void ClearGettingPorts() override; 94 void ClearGettingPorts() override;
112 bool IsGettingPorts() override { return running_; } 95 bool IsGettingPorts() override { return running_; }
96 // These will all be cricket::Ports.
97 std::vector<PortInterface*> ReadyPorts() const override;
98 std::vector<Candidate> ReadyCandidates() const override;
99 bool CandidatesAllocationDone() const override;
113 100
114 protected: 101 protected:
102 void UpdateIceParametersInternal() override;
103
115 // Starts the process of getting the port configurations. 104 // Starts the process of getting the port configurations.
116 virtual void GetPortConfigurations(); 105 virtual void GetPortConfigurations();
117 106
118 // Adds a port configuration that is now ready. Once we have one for each 107 // Adds a port configuration that is now ready. Once we have one for each
119 // network (or a timeout occurs), we will start allocating ports. 108 // network (or a timeout occurs), we will start allocating ports.
120 virtual void ConfigReady(PortConfiguration* config); 109 virtual void ConfigReady(PortConfiguration* config);
121 110
122 // MessageHandler. Can be overriden if message IDs do not conflict. 111 // MessageHandler. Can be overriden if message IDs do not conflict.
123 void OnMessage(rtc::Message* message) override; 112 void OnMessage(rtc::Message* message) override;
124 113
125 private: 114 private:
126 class PortData { 115 class PortData {
127 public: 116 public:
128 PortData() : port_(NULL), sequence_(NULL), state_(STATE_INIT) {} 117 PortData() : port_(NULL), sequence_(NULL), state_(STATE_INIT) {}
129 PortData(Port* port, AllocationSequence* seq) 118 PortData(Port* port, AllocationSequence* seq)
130 : port_(port), sequence_(seq), state_(STATE_INIT) { 119 : port_(port), sequence_(seq), state_(STATE_INIT) {
131 } 120 }
132 121
133 Port* port() { return port_; } 122 Port* port() const { return port_; }
134 AllocationSequence* sequence() { return sequence_; } 123 AllocationSequence* sequence() const { return sequence_; }
135 bool ready() const { return state_ == STATE_READY; } 124 bool ready() const { return state_ == STATE_READY; }
136 bool complete() const { 125 bool complete() const { return state_ == STATE_COMPLETE; }
137 // Returns true if candidate allocation has completed one way or another. 126 bool error() const { return state_ == STATE_ERROR; }
138 return ((state_ == STATE_COMPLETE) || (state_ == STATE_ERROR));
139 }
140 127
141 void set_ready() { ASSERT(state_ == STATE_INIT); state_ = STATE_READY; } 128 void set_ready() { ASSERT(state_ == STATE_INIT); state_ = STATE_READY; }
142 void set_complete() { 129 void set_complete() {
143 state_ = STATE_COMPLETE; 130 state_ = STATE_COMPLETE;
144 } 131 }
145 void set_error() { 132 void set_error() {
146 ASSERT(state_ == STATE_INIT || state_ == STATE_READY); 133 ASSERT(state_ == STATE_INIT || state_ == STATE_READY);
147 state_ = STATE_ERROR; 134 state_ = STATE_ERROR;
148 } 135 }
149 136
(...skipping 25 matching lines...) Expand all
175 void OnPortComplete(Port* port); 162 void OnPortComplete(Port* port);
176 void OnPortError(Port* port); 163 void OnPortError(Port* port);
177 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto); 164 void OnProtocolEnabled(AllocationSequence* seq, ProtocolType proto);
178 void OnPortDestroyed(PortInterface* port); 165 void OnPortDestroyed(PortInterface* port);
179 void OnShake(); 166 void OnShake();
180 void MaybeSignalCandidatesAllocationDone(); 167 void MaybeSignalCandidatesAllocationDone();
181 void OnPortAllocationComplete(AllocationSequence* seq); 168 void OnPortAllocationComplete(AllocationSequence* seq);
182 PortData* FindPort(Port* port); 169 PortData* FindPort(Port* port);
183 void GetNetworks(std::vector<rtc::Network*>* networks); 170 void GetNetworks(std::vector<rtc::Network*>* networks);
184 171
185 bool CheckCandidateFilter(const Candidate& c); 172 bool CheckCandidateFilter(const Candidate& c) const;
186 173
187 BasicPortAllocator* allocator_; 174 BasicPortAllocator* allocator_;
188 rtc::Thread* network_thread_; 175 rtc::Thread* network_thread_;
189 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; 176 std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_;
190 rtc::PacketSocketFactory* socket_factory_; 177 rtc::PacketSocketFactory* socket_factory_;
191 bool allocation_started_; 178 bool allocation_started_;
192 bool network_manager_started_; 179 bool network_manager_started_;
193 bool running_; // set when StartGetAllPorts is called 180 bool running_; // set when StartGetAllPorts is called
194 bool allocation_sequences_created_; 181 bool allocation_sequences_created_;
195 std::vector<PortConfiguration*> configs_; 182 std::vector<PortConfiguration*> configs_;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; 311 std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_;
325 // There will be only one udp port per AllocationSequence. 312 // There will be only one udp port per AllocationSequence.
326 UDPPort* udp_port_; 313 UDPPort* udp_port_;
327 std::vector<TurnPort*> turn_ports_; 314 std::vector<TurnPort*> turn_ports_;
328 int phase_; 315 int phase_;
329 }; 316 };
330 317
331 } // namespace cricket 318 } // namespace cricket
332 319
333 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ 320 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportcontroller_unittest.cc ('k') | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698