41#include <dhtnet/ice_transport.h>
42#include <dhtnet/ice_transport_factory.h>
46#pragma GCC diagnostic push
47#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
48#include <yaml-cpp/yaml.h>
49#pragma GCC diagnostic pop
55using namespace std::literals;
61 , messageEngine_(*
this, (fileutils::get_cache_dir() / getAccountID() /
"messages").string())
62 , link_(
Manager::instance().sipVoIPLink())
87 JAMI_DBG(
"No target provided, using 'to' as target");
92 JAMI_ERR(
"Unable to create SIP dialogs for user agent client when calling %s %d",
109 const_cast<char*
>(
"Phone call"),
115 JAMI_ERR(
"Unable to create invite session for user agent client");
136 dhtnet::IpAddr publishedIp {
conf.publishedIp};
137 if (
not conf.publishedSameasLocal
and publishedIp)
156std::map<std::string, std::string>
195 std::uniform_int_distribution<uint16_t>
dist(
range.first / 2,
range.second / 2);
206 std::uniform_int_distribution<uint16_t>
dist(
range.first / 2,
range.second / 2);
227 getPortsReservation()[
port / 2] =
false;
238SIPAccountBase::generateVideoPort()
const
244dhtnet::IceTransportOptions
247 dhtnet::IceTransportOptions
opts;
255 opts.turnServers.emplace_back(dhtnet::TurnServerInfo()
257 .setUsername(
config().turnServerUserName)
276 const std::string& from,
277 const std::shared_ptr<dht::crypto::Certificate>& peerCert,
278 const std::map<std::string, std::string>& payloads)
280 JAMI_LOG(
"[Account {}] [peer {}] Text message received from {}, {:d} part(s)",
accountID_, peerCert ? peerCert->getLongId().to_view() :
""sv, from, payloads.size());
281 for (
const auto&
m : payloads) {
296 std::make_shared<JamiMessage>(
accountID_, from,
true, payloads,
false));
304 message.
received = std::time(
nullptr);
341std::vector<libjami::Message>
356std::vector<MediaAttribute>
Account specific keys/constants that must be shared in daemon and clients.
virtual void flush()
This method is called to request removal of possible account traces on the system,...
const std::string & getAccountID() const
Get the account ID.
virtual void setRegistrationState(RegistrationState state, int detail_code=0, const std::string &detail_str={})
Set the registration state of the specified link.
const std::string accountID_
Account ID are assign in constructor and shall not changed.
RegistrationState registrationState_
std::mt19937_64 rand
Random generator engine Logical account state shall never rely on the state of the random generator.
virtual std::map< std::string, std::string > getVolatileAccountDetails() const
virtual bool isIP2IP() const
Returns true if this is the IP2IP account.
virtual bool handleMessage(const std::shared_ptr< dht::crypto::Certificate > &, const std::string &, const std::pair< std::string, std::string > &)
bool getUPnPActive() const
returns whether or not UPnP is enabled and active ie: if it is able to make port mappings
bool isVideoEnabled() const
virtual void loadConfig()
Load the settings in this account.
std::shared_ptr< dhtnet::upnp::Controller > upnpCtrl_
Manager (controller) of daemon.
static LIBJAMI_TEST_EXPORT Manager & instance()
std::shared_ptr< asio::io_context > ioContext() const
const std::shared_ptr< dhtnet::IceTransportFactory > & getIceTransportFactory()
static constexpr size_t MAX_WAITING_MESSAGES_SIZE
static void releasePort(uint16_t port) noexcept
dhtnet::IpAddr publishedIp_[2]
Published IPv4/IPv6 addresses, used only if defined by the user in account configuration.
std::vector< MediaAttribute > createDefaultMediaList(bool addVideo, bool onHold=false)
const SipAccountBaseConfig & config() const
pj_status_t transportStatus_
virtual bool isSrtpEnabled() const =0
virtual void setRegistrationState(RegistrationState state, int code=0, const std::string &detail_str={}) override
Set the registration state of the specified link.
static uint16_t acquirePort(uint16_t port)
uint16_t acquireRandomEvenPort(const std::pair< uint16_t, uint16_t > &range) const
std::deque< libjami::Message > lastMessages_
std::mutex mutexLastMessages_
The deamon can be launched without any client (or with a non ready client) Like call and file transfe...
SIPAccountBase(const std::string &accountID)
Constructor.
virtual ~SIPAccountBase() noexcept
virtual std::map< std::string, std::string > getVolatileAccountDetails() const override
Retrieve volatile details such as recent registration errors.
virtual void onTextMessage(const std::string &id, const std::string &from, const std::shared_ptr< dht::crypto::Certificate > &peerCert, const std::map< std::string, std::string > &payloads)
uint16_t generateAudioPort() const
Socket port generators for media Note: given ports are application wide, a port is unable to be given...
std::vector< libjami::Message > getLastMessages(const uint64_t &base_timestamp) override
uint16_t getRandomEvenPort(const std::pair< uint16_t, uint16_t > &range) const
virtual dhtnet::IpAddr getPublishedIpAddress(uint16_t family=PF_UNSPEC) const
std::string transportError_
im::MessageEngine messageEngine_
bool CreateClientDialogAndInvite(const pj_str_t *from, const pj_str_t *contact, const pj_str_t *to, const pj_str_t *target, const pjmedia_sdp_session *local_sdp, pjsip_dialog **dlg, pjsip_inv_session **inv)
Create UAC attached dialog and invite session.
void setPublishedAddress(const dhtnet::IpAddr &ip_addr)
static std::array< bool, HALF_MAX_PORT > & getPortsReservation() noexcept
void loadConfig() override
Load the settings in this account.
virtual void flush() override
This method is called to request removal of possible account traces on the system,...
virtual dhtnet::IceTransportOptions getIceOptions() const
std::shared_ptr< dhtnet::TurnCache > turnCache_
void load()
Load persisted messages.
void save() const
Persist messages.
#define JAMI_WARNING(formatstr,...)
#define JAMI_LOG(formatstr,...)
static const char *const CONFIG_ACCOUNT_REGISTRATION_STATUS
static const char *const CONFIG_TRANSPORT_STATE_CODE
static const char *const CONFIG_TRANSPORT_STATE_DESC
const std::filesystem::path & get_cache_dir()
constexpr std::string_view DEFAULT_VIDEO_STREAMID
constexpr std::string_view DEFAULT_AUDIO_STREAMID
constexpr const pj_str_t CONST_PJ_STR(T(&a)[N]) noexcept
RegistrationState
Contains all the Registration states for an account can be in.
bool utf8_validate(std::string_view str)
utf8_validate:
void emitSignal(Args... args)
Specific VoIPLink for SIP (SIP core for incoming and outgoing events).
std::map< std::string, std::string > payloads