Line data Source code
1 : /*
2 : * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 : *
4 : * This program is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 3 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * This program is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 : */
17 : #pragma once
18 : #include "account_config.h"
19 :
20 : namespace jami {
21 : constexpr static const char* const OVERRTP_STR = "overrtp";
22 : constexpr static const char* const SIPINFO_STR = "sipinfo";
23 : constexpr static unsigned MAX_PORT {65536};
24 : constexpr static unsigned HALF_MAX_PORT {MAX_PORT / 2};
25 :
26 : struct SipAccountBaseConfig : public AccountConfig
27 : {
28 1199 : SipAccountBaseConfig(const std::string& type, const std::string& id, const std::filesystem::path& path)
29 4796 : : AccountConfig(type, id, path)
30 1199 : {}
31 :
32 : void serializeDiff(YAML::Emitter& out, const SipAccountBaseConfig& def) const;
33 : void unserialize(const YAML::Node& node) override;
34 :
35 : std::map<std::string, std::string> toMap() const override;
36 : void fromMap(const std::map<std::string, std::string>&) override;
37 :
38 : /**
39 : * interface name on which this account is bound
40 : */
41 : std::string interface {"default"};
42 :
43 : /**
44 : * Flag which determine if localIpAddress_ or publishedIpAddress_ is used in
45 : * sip headers
46 : */
47 : bool publishedSameasLocal {true};
48 :
49 : std::string publishedIp;
50 :
51 : /**
52 : * Determine if TURN public address resolution is required to register this account. In this
53 : * case a TURN server hostname must be specified.
54 : */
55 : bool turnEnabled {false};
56 :
57 : /**
58 : * The TURN server hostname (optional), used to provide the public IP address in case the
59 : * softphone stay behind a NAT.
60 : */
61 : std::string turnServer;
62 : std::string turnServerUserName;
63 : std::string turnServerPwd;
64 : std::string turnServerRealm;
65 :
66 : std::string tlsCaListFile;
67 : std::string tlsCertificateFile;
68 : std::string tlsPrivateKeyFile;
69 : std::string tlsPassword;
70 :
71 : std::string dtmfType {OVERRTP_STR};
72 : /*
73 : * Port range for audio RTP ports
74 : */
75 1199 : std::pair<uint16_t, uint16_t> audioPortRange {16384, 32766};
76 :
77 : /**
78 : * Port range for video RTP ports
79 : */
80 1199 : std::pair<uint16_t, uint16_t> videoPortRange {49152, (65536) - 2};
81 : };
82 :
83 : inline void
84 3184 : updateRange(uint16_t min, uint16_t max, std::pair<uint16_t, uint16_t>& range)
85 : {
86 3184 : if (min > 0 and (max > min) and max <= MAX_PORT - 2) {
87 1688 : range.first = min;
88 1688 : range.second = max;
89 : }
90 3184 : }
91 :
92 : } // namespace jami
|