Jonas Oreland | 202994c | 2017-12-18 12:10:43 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | namespace rtc { |
| 21 | class AsyncPacketSocket; |
| 22 | class Network; |
| 23 | class PacketSocketFactory; |
| 24 | class Thread; |
| 25 | } // namespace rtc |
| 26 | |
| 27 | namespace webrtc { |
| 28 | class TurnCustomizer; |
| 29 | } // namespace webrtc |
| 30 | |
| 31 | namespace cricket { |
| 32 | class Port; |
| 33 | struct ProtocolAddress; |
| 34 | struct RelayServerConfig; |
| 35 | |
| 36 | // A struct containing arguments to RelayPortFactory::Create() |
| 37 | struct 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 | |
| 50 | inline CreateRelayPortArgs::CreateRelayPortArgs() {} |
| 51 | |
| 52 | // A factory for creating RelayPort's. |
| 53 | class 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_ |