From b582f89d732bbce47c3668b4087b5a5a69813e5d Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Fri, 2 Aug 2024 04:03:04 +0300 Subject: [PATCH] Patch: Unbundle libSRTP --- src/pc/external_hmac.cc | 1 - src/pc/external_hmac.h | 9 ++++++--- src/pc/srtp_session.cc | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/pc/external_hmac.cc b/src/pc/external_hmac.cc index 27b5d0e5a..222f5d9ae 100644 --- a/src/pc/external_hmac.cc +++ b/src/pc/external_hmac.cc @@ -15,7 +15,6 @@ #include "rtc_base/logging.h" #include "rtc_base/zero_memory.h" -#include "third_party/libsrtp/include/srtp.h" // Begin test case 0 */ static const uint8_t kExternalHmacTestCase0Key[20] = { diff --git a/src/pc/external_hmac.h b/src/pc/external_hmac.h index c5071fc19..7a209a36e 100644 --- a/src/pc/external_hmac.h +++ b/src/pc/external_hmac.h @@ -30,9 +30,12 @@ #include -#include "third_party/libsrtp/crypto/include/crypto_types.h" -#include "third_party/libsrtp/include/srtp.h" -#include "third_party/libsrtp/include/srtp_priv.h" +#ifdef WEBRTC_EXTERNAL_SRTP +# include +# include +#else +# include "srtp_priv.h" +#endif #define EXTERNAL_HMAC_SHA1 SRTP_HMAC_SHA1 + 1 #define HMAC_KEY_LENGTH 20 diff --git a/src/pc/srtp_session.cc b/src/pc/srtp_session.cc index f16679cef..88e79a08e 100644 --- a/src/pc/srtp_session.cc +++ b/src/pc/srtp_session.cc @@ -30,8 +30,12 @@ #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/metrics.h" -#include "third_party/libsrtp/include/srtp.h" -#include "third_party/libsrtp/include/srtp_priv.h" + +#ifdef WEBRTC_EXTERNAL_SRTP +# include +#else +# include "srtp_priv.h" +#endif namespace cricket { @@ -290,6 +294,9 @@ bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) { bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { RTC_DCHECK(thread_checker_.IsCurrent()); RTC_DCHECK(IsExternalAuthActive()); +#ifdef WEBRTC_EXTERNAL_SRTP + return false; +#else if (!IsExternalAuthActive()) { return false; } @@ -313,6 +320,7 @@ bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { *key_len = external_hmac->key_length; *tag_len = rtp_auth_tag_len_; return true; +#endif } int SrtpSession::GetSrtpOverhead() const { @@ -342,6 +350,9 @@ bool SrtpSession::GetSendStreamPacketIndex(void* p, int in_len, int64_t* index) { RTC_DCHECK(thread_checker_.IsCurrent()); +#ifdef WEBRTC_EXTERNAL_SRTP + return false; +#else srtp_hdr_t* hdr = reinterpret_cast(p); srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc); if (!stream) { @@ -352,6 +363,7 @@ bool SrtpSession::GetSendStreamPacketIndex(void* p, *index = static_cast(rtc::NetworkToHost64( srtp_rdbx_get_packet_index(&stream->rtp_rdbx) << 16)); return true; +#endif } bool SrtpSession::DoSetKey(int type,