blob: 3e4c931b79a45d1c9890e0cbe8975a5121bc7095 [file] [log] [blame]
Adrien Béraud6de3f882023-07-06 12:56:29 -04001/*
2 * Copyright (C) 2004-2023 Savoir-faire Linux Inc.
3 *
Adrien Béraudcb753622023-07-17 22:32:49 -04004 * This program is free software: you can redistribute it and/or modify
Adrien Béraud6de3f882023-07-06 12:56:29 -04005 * it under the terms of the GNU General Public License as published by
Adrien Béraudcb753622023-07-17 22:32:49 -04006 * the Free Software Foundation, either version 3 of the License, or
Adrien Béraud6de3f882023-07-06 12:56:29 -04007 * (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
Adrien Béraudcb753622023-07-17 22:32:49 -040011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Adrien Béraud6de3f882023-07-06 12:56:29 -040012 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
Adrien Béraudcb753622023-07-17 22:32:49 -040015 * along with this program. If not, see <https://www.gnu.org/licenses/>.
Adrien Béraud6de3f882023-07-06 12:56:29 -040016 */
Adrien Béraud6de3f882023-07-06 12:56:29 -040017#pragma once
18
19#include "ice_options.h"
Adrien Béraud5c93b5a2023-07-09 19:39:35 -040020#include "ice_transport.h"
Adrien Béraud6de3f882023-07-06 12:56:29 -040021#include "ip_utils.h"
François-Simon Fauteux-Chapleau2ef5b662024-03-27 12:30:26 -040022#include "pj_init_lock.h"
Adrien Béraud6de3f882023-07-06 12:56:29 -040023
Adrien Béraud6de3f882023-07-06 12:56:29 -040024#include <functional>
25#include <memory>
26#include <vector>
27
Adrien Béraud9e0f84f2023-07-27 16:02:21 -040028extern "C" {
29#include <pjnath.h>
30#include <pjlib.h>
31#include <pjlib-util.h>
32}
33
Adrien Béraud1ae60aa2023-07-07 09:55:09 -040034namespace dhtnet {
Adrien Béraud6de3f882023-07-06 12:56:29 -040035
36class IceTransportFactory
37{
38public:
Adrien Béraud89933c12023-07-26 14:53:30 -040039 IceTransportFactory(const std::shared_ptr<Logger>& logger = {});
Adrien Béraud6de3f882023-07-06 12:56:29 -040040 ~IceTransportFactory();
41
42 std::shared_ptr<IceTransport> createTransport(std::string_view name);
43
44 std::unique_ptr<IceTransport> createUTransport(std::string_view name);
45
46 /**
47 * PJSIP specifics
48 */
49 pj_ice_strans_cfg getIceCfg() const { return ice_cfg_; }
50 pj_pool_factory* getPoolFactory() { return &cp_->factory; }
51 std::shared_ptr<pj_caching_pool> getPoolCaching() { return cp_; }
52
53private:
François-Simon Fauteux-Chapleau2ef5b662024-03-27 12:30:26 -040054 // Declaring pjInitLock_ before cp_ because its constructor needs to be called
55 // first (see constructor implementation for a comment with more information).
56 PjInitLock pjInitLock_;
Adrien Béraud6de3f882023-07-06 12:56:29 -040057 std::shared_ptr<pj_caching_pool> cp_;
58 pj_ice_strans_cfg ice_cfg_;
Adrien Béraud89933c12023-07-26 14:53:30 -040059 std::shared_ptr<Logger> logger_ {};
Adrien Béraud6de3f882023-07-06 12:56:29 -040060};
61
62}; // namespace jami