From da89159d885b3aa71bbd73aaf58010791f57ae52 Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Tue, 12 Mar 2024 18:07:21 +0000 Subject: [PATCH] Add SDP proto to support DTLS --- libsofia-sip-ua/sdp/sdp.c | 1 + libsofia-sip-ua/sdp/sdp_parse.c | 6 +++--- libsofia-sip-ua/sdp/sdp_print.c | 2 ++ libsofia-sip-ua/sdp/sofia-sip/sdp.h | 6 ++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libsofia-sip-ua/sdp/sdp.c b/libsofia-sip-ua/sdp/sdp.c index 8ed84ff3..d136c7e7 100644 --- a/libsofia-sip-ua/sdp/sdp.c +++ b/libsofia-sip-ua/sdp/sdp.c @@ -1851,6 +1851,7 @@ int sdp_media_uses_rtp(sdp_media_t const *m) return m && (m->m_proto == sdp_proto_rtp || m->m_proto == sdp_proto_srtp || m->m_proto == sdp_proto_extended_srtp || + m->m_proto == sdp_proto_srtp_dtls || m->m_proto == sdp_proto_extended_srtp_dtls || (m->m_proto == sdp_proto_x && m->m_proto_name && su_casenmatch(m->m_proto_name, "RTP/", 4))); } diff --git a/libsofia-sip-ua/sdp/sdp_parse.c b/libsofia-sip-ua/sdp/sdp_parse.c index f57b3ee0..218c798d 100644 --- a/libsofia-sip-ua/sdp/sdp_parse.c +++ b/libsofia-sip-ua/sdp/sdp_parse.c @@ -1416,11 +1416,11 @@ void sdp_media_transport(sdp_media_t *m, char const *s) else if (su_casematch(s, "RTP/SAVP")) m->m_proto = sdp_proto_srtp, m->m_proto_name = "RTP/SAVP"; else if (su_casematch(s, "UDP/TLS/RTP/SAVP")) - m->m_proto = sdp_proto_srtp, m->m_proto_name = "RTP/SAVP"; + m->m_proto = sdp_proto_srtp_dtls, m->m_proto_name = "UDP/TLS/RTP/SAVP"; else if (su_casematch(s, "RTP/SAVPF")) m->m_proto = sdp_proto_extended_srtp, m->m_proto_name = "RTP/SAVPF"; else if (su_casematch(s, "UDP/TLS/RTP/SAVPF")) - m->m_proto = sdp_proto_extended_srtp, m->m_proto_name = "UDP/TLS/RTP/SAVPF"; + m->m_proto = sdp_proto_extended_srtp_dtls, m->m_proto_name = "UDP/TLS/RTP/SAVPF"; else if (su_casematch(s, "RTP/AVPF")) m->m_proto = sdp_proto_extended_rtp, m->m_proto_name = "RTP/AVPF"; else if (su_casematch(s, "UDP/RTP/AVPF")) @@ -1445,7 +1445,7 @@ void sdp_media_transport(sdp_media_t *m, char const *s) /** Check if media uses RTP as its transport protocol. */ int sdp_media_has_rtp(sdp_media_t const *m) { - return m && (m->m_proto == sdp_proto_rtp || m->m_proto == sdp_proto_srtp || m->m_proto == sdp_proto_extended_srtp || m->m_proto == sdp_proto_extended_rtp); + return m && (m->m_proto == sdp_proto_rtp || m->m_proto == sdp_proto_srtp || m->m_proto == sdp_proto_extended_srtp || m->m_proto == sdp_proto_extended_rtp || m->m_proto == sdp_proto_srtp_dtls || m->m_proto == sdp_proto_extended_srtp_dtls); } #define RTPMAP(pt, encoding, rate, params) \ diff --git a/libsofia-sip-ua/sdp/sdp_print.c b/libsofia-sip-ua/sdp/sdp_print.c index ce30ad56..35245071 100644 --- a/libsofia-sip-ua/sdp/sdp_print.c +++ b/libsofia-sip-ua/sdp/sdp_print.c @@ -594,7 +594,9 @@ static void print_media(sdp_printer_t *p, case sdp_proto_udp: proto = "udp"; break; case sdp_proto_rtp: proto = "RTP/AVP"; break; case sdp_proto_srtp: proto = "RTP/SAVP"; break; + case sdp_proto_srtp_dtls: proto = "UDP/TLS/RTP/SAVP"; break; //case sdp_proto_extended_srtp: proto = "RTP/SAVPF"; break; + case sdp_proto_extended_srtp_dtls: proto = "UDP/TLS/RTP/SAVPF"; break; case sdp_proto_udptl: proto = "udptl"; break; case sdp_proto_msrp: proto = "TCP/MSRP"; break; case sdp_proto_msrps: proto = "TCP/TLS/MSRP"; break; diff --git a/libsofia-sip-ua/sdp/sofia-sip/sdp.h b/libsofia-sip-ua/sdp/sofia-sip/sdp.h index ffc68d6e..e9bb6380 100644 --- a/libsofia-sip-ua/sdp/sofia-sip/sdp.h +++ b/libsofia-sip-ua/sdp/sofia-sip/sdp.h @@ -249,8 +249,10 @@ typedef enum sdp_proto_udptl = 258, /**< UDPTL. @NEW_1_12_4. */ sdp_proto_msrp = 259, /**< TCP/MSRP @NEW_MSRP*/ sdp_proto_msrps = 260, /**< TCP/TLS/MSRP @NEW_MSRP*/ - sdp_proto_extended_srtp = 261, /** WEBRTC SAVPF */ - sdp_proto_extended_rtp = 262, /** WEBRTC AVPF */ + sdp_proto_extended_srtp = 261, /** WEBRTC SAVPF */ + sdp_proto_extended_rtp = 262, /** WEBRTC AVPF */ + sdp_proto_extended_srtp_dtls = 263, /** WEBRTC AVPF DTLS */ + sdp_proto_srtp_dtls = 264, /**< RTP/SAVP DTLS */ sdp_proto_tls = 511, /**< TLS over TCP */ sdp_proto_any = 512 /**< * wildcard */ } sdp_proto_e;