From 738aedb0860d098f6ba7260a70a0d9dc8667d735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Sun, 18 Feb 2024 14:56:26 -0500 Subject: [PATCH] add support for QoS Change-Id: Ic75d07dd85a09af8255e24d5993920d8bf1ed005 --- include/ice_options.h | 15 +++++++++++++++ src/ice_transport.cpp | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/include/ice_options.h b/include/ice_options.h index 33ac76e..f117495 100644 --- a/include/ice_options.h +++ b/include/ice_options.h @@ -67,6 +67,19 @@ struct TurnServerInfo std::string realm; // credentials realm (optional, empty if not used) }; +/** Maps PJSIP QOS types */ +enum class QosType +{ + BEST_EFFORT, /**< Best effort traffic (default value). + Any QoS function calls with specifying + this value are effectively no-op */ + BACKGROUND, /**< Background traffic. */ + VIDEO, /**< Video traffic. */ + VOICE, /**< Voice traffic. */ + CONTROL, /**< Control traffic. */ + SIGNALLING /**< Signalling traffic. */ +}; + struct IceTransportOptions { std::shared_ptr<IceTransportFactory> factory {}; @@ -83,6 +96,8 @@ struct IceTransportOptions IpAddr accountLocalAddr {}; IpAddr accountPublicAddr {}; std::shared_ptr<upnp::UPnPContext> upnpContext {}; + /** Per component QoS Type. */ + std::vector<QosType> qosType {}; }; } diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index 2817195..52a6383 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -423,6 +423,15 @@ IceTransport::Impl::initIceInstance(const IceTransportOptions& options) config_.stun.conn_type = PJ_STUN_TP_UDP; config_.turn.conn_type = PJ_TURN_TP_UDP; } + if (options.qosType.size() == 1) { + config_.stun.cfg.qos_type = (pj_qos_type)options.qosType[0]; + config_.turn.cfg.qos_type = (pj_qos_type)options.qosType[0]; + } + if (options.qosType.size() == compCount_) { + for (unsigned i = 0; i < compCount_; ++i) { + config_.comp[i].qos_type = (pj_qos_type)(options.qosType[i]); + } + } pool_.reset( pj_pool_create(factory->getPoolFactory(), "IceTransport.pool", 512, 512, NULL)); -- GitLab