Ring Daemon 16.0.0
Loading...
Searching...
No Matches
channeled_transport.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 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
19#include "noncopyable.h"
20#include "scheduled_executor.h"
22
23#include <dhtnet/multiplexed_socket.h>
24
25#include <atomic>
26#include <condition_variable>
27#include <chrono>
28#include <list>
29#include <memory>
30#include <thread>
31#include <type_traits>
32#include <utility>
33
34namespace jami {
35
36using onShutdownCb = std::function<void(void)>;
37
38namespace tls {
39
46{
47public:
49 const std::shared_ptr<dhtnet::ChannelSocket>& socket,
52
56 void start();
57
58 pjsip_transport* getTransportBase() override { return &trData_.base; }
59
60 dhtnet::IpAddr getLocalAddress() const override { return local_; }
61
62private:
64
65 // The SIP transport uses a ChannelSocket to send and receive datas
66 std::shared_ptr<dhtnet::ChannelSocket> socket_ {};
67 onShutdownCb shutdownCb_ {};
68 dhtnet::IpAddr local_ {};
69 dhtnet::IpAddr remote_ {};
70
71 // PJSIP transport backend
72 TransportData trData_ {}; // uplink to "this" (used by PJSIP called C-callbacks)
73
74 std::unique_ptr<pj_pool_t, decltype(pj_pool_release)*> pool_;
75 std::unique_ptr<pj_pool_t, decltype(pj_pool_release)*> rxPool_;
76 pjsip_rx_data rdata_ {};
77
79
80 // Handle disconnected event
81 std::atomic_bool disconnected_ {false};
82};
83
84} // namespace tls
85} // namespace jami
dhtnet::IpAddr getLocalAddress() const override
void start()
Connect callbacks for channeled socket, must be done when the channel is ready to be used.
pjsip_transport * getTransportBase() override
void emitSignal(Args... args)
Definition ring_signal.h:64
std::function< void(void)> onShutdownCb
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30