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 // Disable TCP-based transport when set to true.
39 bool disable_tcp_transport
;
41 // Disable binding to individual NICs when set to false.
42 bool enable_multiple_routes
;
45 P2PPortAllocator(P2PSocketDispatcher
* socket_dispatcher
,
46 rtc::NetworkManager
* network_manager
,
47 rtc::PacketSocketFactory
* socket_factory
,
50 ~P2PPortAllocator() override
;
52 cricket::PortAllocatorSession
* CreateSessionInternal(
53 const std::string
& content_name
,
55 const std::string
& ice_username_fragment
,
56 const std::string
& ice_password
) override
;
59 friend class P2PPortAllocatorSession
;
61 P2PSocketDispatcher
* socket_dispatcher_
;
65 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator
);
68 class P2PPortAllocatorSession
: public cricket::BasicPortAllocatorSession
{
70 P2PPortAllocatorSession(
71 P2PPortAllocator
* allocator
,
72 const std::string
& content_name
,
74 const std::string
& ice_username_fragment
,
75 const std::string
& ice_password
);
76 ~P2PPortAllocatorSession() override
;
79 // Overrides for cricket::BasicPortAllocatorSession.
80 void GetPortConfigurations() override
;
83 P2PPortAllocator
* allocator_
;
85 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession
);
88 } // namespace content
90 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_