1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_
6 #define CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_
8 #include "third_party/webrtc/p2p/client/basicportallocator.h"
13 class P2PPortAllocatorSession
;
14 class P2PSocketDispatcher
;
16 class P2PPortAllocator
: public cricket::BasicPortAllocator
{
22 struct RelayServerConfig
{
28 std::string server_address
;
30 std::string transport_type
;
34 std::set
<rtc::SocketAddress
> stun_servers
;
36 std::vector
<RelayServerConfig
> relays
;
38 // Enable non-proxied UDP-based transport when set to true. When set to
39 // false, it effectively disables all UDP traffic until UDP-supporting proxy
40 // RETURN is available in the future.
41 bool enable_nonproxied_udp
= true;
43 // Disable binding to individual NICs when set to false.
44 bool enable_multiple_routes
= true;
47 P2PPortAllocator(P2PSocketDispatcher
* socket_dispatcher
,
48 rtc::NetworkManager
* network_manager
,
49 rtc::PacketSocketFactory
* socket_factory
,
52 ~P2PPortAllocator() override
;
54 cricket::PortAllocatorSession
* CreateSessionInternal(
55 const std::string
& content_name
,
57 const std::string
& ice_username_fragment
,
58 const std::string
& ice_password
) override
;
61 friend class P2PPortAllocatorSession
;
63 P2PSocketDispatcher
* socket_dispatcher_
;
67 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator
);
70 class P2PPortAllocatorSession
: public cricket::BasicPortAllocatorSession
{
72 P2PPortAllocatorSession(
73 P2PPortAllocator
* allocator
,
74 const std::string
& content_name
,
76 const std::string
& ice_username_fragment
,
77 const std::string
& ice_password
);
78 ~P2PPortAllocatorSession() override
;
81 // Overrides for cricket::BasicPortAllocatorSession.
82 void GetPortConfigurations() override
;
85 P2PPortAllocator
* allocator_
;
87 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession
);
90 } // namespace content
92 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_