blob: 5890bcd9bd2bfe3e18228f58ff6db3928819f0f8 [file] [log] [blame]
Jonas Oreland202994c2017-12-18 12:10:43 +01001/*
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef P2P_CLIENT_RELAYPORTFACTORYINTERFACE_H_
12#define P2P_CLIENT_RELAYPORTFACTORYINTERFACE_H_
13
14#include <memory>
15#include <string>
16
17#include "p2p/base/portinterface.h"
18#include "rtc_base/refcount.h"
19
20namespace rtc {
21class AsyncPacketSocket;
22class Network;
23class PacketSocketFactory;
24class Thread;
25} // namespace rtc
26
27namespace webrtc {
28class TurnCustomizer;
29} // namespace webrtc
30
31namespace cricket {
32class Port;
33struct ProtocolAddress;
34struct RelayServerConfig;
35
36// A struct containing arguments to RelayPortFactory::Create()
37struct CreateRelayPortArgs {
38 CreateRelayPortArgs();
39 rtc::Thread* network_thread;
40 rtc::PacketSocketFactory* socket_factory;
41 rtc::Network* network;
42 const ProtocolAddress* server_address;
43 const RelayServerConfig* config;
44 std::string username;
45 std::string password;
46 std::string origin;
47 webrtc::TurnCustomizer* turn_customizer;
48};
49
50inline CreateRelayPortArgs::CreateRelayPortArgs() {}
51
52// A factory for creating RelayPort's.
53class RelayPortFactoryInterface {
54 public:
55 virtual ~RelayPortFactoryInterface() {}
56
57 // This variant is used for UDP connection to the relay server
58 // using a already existing shared socket.
59 virtual std::unique_ptr<Port> Create(
60 const CreateRelayPortArgs& args,
61 rtc::AsyncPacketSocket* udp_socket) = 0;
62
63 // This variant is used for the other cases.
64 virtual std::unique_ptr<Port> Create(
65 const CreateRelayPortArgs& args,
66 int min_port,
67 int max_port) = 0;
68};
69
70} // namespace cricket
71
72#endif // P2P_CLIENT_RELAYPORTFACTORYINTERFACE_H_