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: