Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <functional> |
| 4 | #include <vector> |
| 5 | #include <string> |
| 6 | |
| 7 | #include "ip_utils.h" |
| 8 | |
| 9 | namespace jami { |
| 10 | |
Adrien Béraud | 25c30c4 | 2023-07-05 13:46:54 -0400 | [diff] [blame] | 11 | namespace upnp { |
| 12 | class UPnPContext; |
| 13 | } |
| 14 | |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 15 | class IceTransportFactory; |
| 16 | using IceTransportCompleteCb = std::function<void(bool)>; |
| 17 | |
| 18 | struct StunServerInfo |
| 19 | { |
| 20 | inline StunServerInfo& setUri(const std::string& args) { |
| 21 | uri = args; |
| 22 | return *this; |
| 23 | } |
| 24 | |
| 25 | std::string uri; // server URI, mandatory |
| 26 | }; |
| 27 | |
| 28 | struct TurnServerInfo |
| 29 | { |
| 30 | inline TurnServerInfo& setUri(const std::string& args) { |
| 31 | uri = args; |
| 32 | return *this; |
| 33 | } |
| 34 | inline TurnServerInfo& setUsername(const std::string& args) { |
| 35 | username = args; |
| 36 | return *this; |
| 37 | } |
| 38 | inline TurnServerInfo& setPassword(const std::string& args) { |
| 39 | password = args; |
| 40 | return *this; |
| 41 | } |
| 42 | inline TurnServerInfo& setRealm(const std::string& args) { |
| 43 | realm = args; |
| 44 | return *this; |
| 45 | } |
| 46 | |
| 47 | std::string uri; // server URI, mandatory |
| 48 | std::string username; // credentials username (optional, empty if not used) |
| 49 | std::string password; // credentials password (optional, empty if not used) |
| 50 | std::string realm; // credentials realm (optional, empty if not used) |
| 51 | }; |
| 52 | |
| 53 | struct IceTransportOptions |
| 54 | { |
| 55 | IceTransportFactory* factory {nullptr}; |
| 56 | bool master {true}; |
| 57 | unsigned streamsCount {1}; |
| 58 | unsigned compCountPerStream {1}; |
| 59 | bool upnpEnable {false}; |
| 60 | IceTransportCompleteCb onInitDone {}; |
| 61 | IceTransportCompleteCb onNegoDone {}; |
| 62 | std::vector<StunServerInfo> stunServers; |
| 63 | std::vector<TurnServerInfo> turnServers; |
| 64 | bool tcpEnable {false}; |
| 65 | // Addresses used by the account owning the transport instance. |
| 66 | IpAddr accountLocalAddr {}; |
| 67 | IpAddr accountPublicAddr {}; |
Adrien Béraud | 25c30c4 | 2023-07-05 13:46:54 -0400 | [diff] [blame] | 68 | std::shared_ptr<upnp::UPnPContext> upnpContext {}; |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | } |