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"
12 class P2PPortAllocatorSession
;
13 class P2PSocketDispatcher
;
15 class P2PPortAllocator
: public cricket::BasicPortAllocator
{
21 struct RelayServerConfig
{
27 std::string server_address
;
29 std::string transport_type
;
33 std::set
<rtc::SocketAddress
> stun_servers
;
35 std::vector
<RelayServerConfig
> relays
;
37 // Disable TCP-based transport when set to true.
38 bool disable_tcp_transport
;
40 // Disable binding to individual NICs when set to false.
41 bool enable_multiple_routes
;
44 P2PPortAllocator(P2PSocketDispatcher
* socket_dispatcher
,
45 rtc::NetworkManager
* network_manager
,
46 rtc::PacketSocketFactory
* socket_factory
,
47 const Config
& config
);
48 ~P2PPortAllocator() override
;
50 cricket::PortAllocatorSession
* CreateSessionInternal(
51 const std::string
& content_name
,
53 const std::string
& ice_username_fragment
,
54 const std::string
& ice_password
) override
;
57 friend class P2PPortAllocatorSession
;
59 P2PSocketDispatcher
* socket_dispatcher_
;
62 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator
);
65 class P2PPortAllocatorSession
: public cricket::BasicPortAllocatorSession
{
67 P2PPortAllocatorSession(
68 P2PPortAllocator
* allocator
,
69 const std::string
& content_name
,
71 const std::string
& ice_username_fragment
,
72 const std::string
& ice_password
);
73 ~P2PPortAllocatorSession() override
;
76 // Overrides for cricket::BasicPortAllocatorSession.
77 void GetPortConfigurations() override
;
80 P2PPortAllocator
* allocator_
;
82 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession
);
85 } // namespace content
87 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_