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 <perkj@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30074}
This commit is contained in:
Sebastian Jansson 2019-12-12 13:15:54 +01:00
parent 6286bb0b2c
commit 22619b3ed6
2 changed files with 10 additions and 0 deletions

View File

@ -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);

View File

@ -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: