From 22619b3ed6854f7c5ebe57bbf30d8e4ccf8882ba Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Thu, 12 Dec 2019 13:15:54 +0100 Subject: [PATCH] Allow external initialization of libsrtp. Bug: webrtc:11205 Change-Id: I906651e3afc5c50977ff567f13a44e5087604028 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161952 Reviewed-by: Per Kjellander Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#30074} --- pc/srtp_session.cc | 5 +++++ pc/srtp_session.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pc/srtp_session.cc b/pc/srtp_session.cc index 4108c12a09..5ded455ee5 100644 --- a/pc/srtp_session.cc +++ b/pc/srtp_session.cc @@ -366,6 +366,11 @@ bool SrtpSession::UpdateKey(int type, ABSL_CONST_INIT int g_libsrtp_usage_count = 0; ABSL_CONST_INIT rtc::GlobalLock g_libsrtp_lock; +void ProhibitLibsrtpInitialization() { + rtc::GlobalLockScope ls(&g_libsrtp_lock); + ++g_libsrtp_usage_count; +} + // static bool SrtpSession::IncrementLibsrtpUsageCountAndMaybeInit() { rtc::GlobalLockScope ls(&g_libsrtp_lock); diff --git a/pc/srtp_session.h b/pc/srtp_session.h index 5aa715855d..0a26c02c9f 100644 --- a/pc/srtp_session.h +++ b/pc/srtp_session.h @@ -22,6 +22,11 @@ struct srtp_ctx_t_; namespace cricket { +// Prohibits webrtc from initializing libsrtp. This can be used if libsrtp is +// initialized by another library or explicitly. Note that this must be called +// before creating an SRTP session with WebRTC. +void ProhibitLibsrtpInitialization(); + // Class that wraps a libSRTP session. class SrtpSession { public: