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

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

Issue 1241943002: Fix an NPE. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Updated the comments. Created 5 years, 5 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 | « no previous file | webrtc/p2p/client/basicportallocator.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 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // Determines whether the given relay server supports the given protocol. 229 // Determines whether the given relay server supports the given protocol.
230 bool SupportsProtocol(const RelayServerConfig& relay, 230 bool SupportsProtocol(const RelayServerConfig& relay,
231 ProtocolType type) const; 231 ProtocolType type) const;
232 bool SupportsProtocol(RelayType turn_type, ProtocolType type) const; 232 bool SupportsProtocol(RelayType turn_type, ProtocolType type) const;
233 // Helper method returns the server addresses for the matching RelayType and 233 // Helper method returns the server addresses for the matching RelayType and
234 // Protocol type. 234 // Protocol type.
235 ServerAddresses GetRelayServerAddresses( 235 ServerAddresses GetRelayServerAddresses(
236 RelayType turn_type, ProtocolType type) const; 236 RelayType turn_type, ProtocolType type) const;
237 }; 237 };
238 238
239 class UDPPort;
240 class TurnPort;
241
242 // Performs the allocation of ports, in a sequenced (timed) manner, for a given
243 // network and IP address.
244 class AllocationSequence : public rtc::MessageHandler,
245 public sigslot::has_slots<> {
246 public:
247 enum State {
248 kInit, // Initial state.
249 kRunning, // Started allocating ports.
250 kStopped, // Stopped from running.
251 kCompleted, // All ports are allocated.
252
253 // kInit --> kRunning --> {kCompleted|kStopped}
254 };
255 AllocationSequence(BasicPortAllocatorSession* session,
256 rtc::Network* network,
257 PortConfiguration* config,
258 uint32 flags);
259 ~AllocationSequence();
260 bool Init();
261 void Clear();
262
263 State state() const { return state_; }
264
265 // Disables the phases for a new sequence that this one already covers for an
266 // equivalent network setup.
267 void DisableEquivalentPhases(rtc::Network* network,
268 PortConfiguration* config,
269 uint32* flags);
270
271 // Starts and stops the sequence. When started, it will continue allocating
272 // new ports on its own timed schedule.
273 void Start();
274 void Stop();
275
276 // MessageHandler
277 void OnMessage(rtc::Message* msg);
278
279 void EnableProtocol(ProtocolType proto);
280 bool ProtocolEnabled(ProtocolType proto) const;
281
282 // Signal from AllocationSequence, when it's done with allocating ports.
283 // This signal is useful, when port allocation fails which doesn't result
284 // in any candidates. Using this signal BasicPortAllocatorSession can send
285 // its candidate discovery conclusion signal. Without this signal,
286 // BasicPortAllocatorSession doesn't have any event to trigger signal. This
287 // can also be achieved by starting timer in BPAS.
288 sigslot::signal1<AllocationSequence*> SignalPortAllocationComplete;
289
290 protected:
291 // For testing.
292 void CreateTurnPort(const RelayServerConfig& config);
293
294 private:
295 typedef std::vector<ProtocolType> ProtocolList;
296
297 bool IsFlagSet(uint32 flag) { return ((flags_ & flag) != 0); }
298 void CreateUDPPorts();
299 void CreateTCPPorts();
300 void CreateStunPorts();
301 void CreateRelayPorts();
302 void CreateGturnPort(const RelayServerConfig& config);
303
304 void OnReadPacket(rtc::AsyncPacketSocket* socket,
305 const char* data,
306 size_t size,
307 const rtc::SocketAddress& remote_addr,
308 const rtc::PacketTime& packet_time);
309
310 void OnPortDestroyed(PortInterface* port);
311
312 BasicPortAllocatorSession* session_;
313 rtc::Network* network_;
314 rtc::IPAddress ip_;
315 PortConfiguration* config_;
316 State state_;
317 uint32 flags_;
318 ProtocolList protocols_;
319 rtc::scoped_ptr<rtc::AsyncPacketSocket> udp_socket_;
320 // There will be only one udp port per AllocationSequence.
321 UDPPort* udp_port_;
322 std::vector<TurnPort*> turn_ports_;
323 int phase_;
324 };
325
239 } // namespace cricket 326 } // namespace cricket
240 327
241 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ 328 #endif // WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/client/basicportallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698