Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2023 Savoir-faire Linux Inc. |
| 3 | * |
Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 4 | * This program is free software: you can redistribute it and/or modify |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 5 | * it under the terms of the GNU General Public License as published by |
Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 6 | * the Free Software Foundation, either version 3 of the License, or |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 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 |
Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
Adrien Béraud | cb75362 | 2023-07-17 22:32:49 -0400 | [diff] [blame] | 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 16 | */ |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 17 | #pragma once |
| 18 | |
| 19 | #include "ice_options.h" |
Adrien Béraud | 5c93b5a | 2023-07-09 19:39:35 -0400 | [diff] [blame] | 20 | #include "ice_transport.h" |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 21 | #include "ip_utils.h" |
François-Simon Fauteux-Chapleau | 2ef5b66 | 2024-03-27 12:30:26 -0400 | [diff] [blame] | 22 | #include "pj_init_lock.h" |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 23 | |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 24 | #include <functional> |
| 25 | #include <memory> |
| 26 | #include <vector> |
| 27 | |
Adrien Béraud | 9e0f84f | 2023-07-27 16:02:21 -0400 | [diff] [blame] | 28 | extern "C" { |
| 29 | #include <pjnath.h> |
| 30 | #include <pjlib.h> |
| 31 | #include <pjlib-util.h> |
| 32 | } |
| 33 | |
Adrien Béraud | 1ae60aa | 2023-07-07 09:55:09 -0400 | [diff] [blame] | 34 | namespace dhtnet { |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 35 | |
| 36 | class IceTransportFactory |
| 37 | { |
| 38 | public: |
Adrien Béraud | 89933c1 | 2023-07-26 14:53:30 -0400 | [diff] [blame] | 39 | IceTransportFactory(const std::shared_ptr<Logger>& logger = {}); |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 40 | ~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 | |
| 53 | private: |
François-Simon Fauteux-Chapleau | 2ef5b66 | 2024-03-27 12:30:26 -0400 | [diff] [blame] | 54 | // 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éraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 57 | std::shared_ptr<pj_caching_pool> cp_; |
| 58 | pj_ice_strans_cfg ice_cfg_; |
Adrien Béraud | 89933c1 | 2023-07-26 14:53:30 -0400 | [diff] [blame] | 59 | std::shared_ptr<Logger> logger_ {}; |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | }; // namespace jami |