From 03fa534fccec0004b27a0db9541def9a324ef675 Mon Sep 17 00:00:00 2001 From: jbauch Date: Wed, 28 Jun 2017 03:35:57 -0700 Subject: [PATCH] Support getting external HMAC auth context with libsrtp 2.1.0. This is in preparation of upgrading to libsrtp 2.1.0. BUG=webrtc:7856 Review-Url: https://codereview.webrtc.org/2958123002 Cr-Commit-Position: refs/heads/master@{#18805} --- webrtc/pc/srtpfilter.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/webrtc/pc/srtpfilter.cc b/webrtc/pc/srtpfilter.cc index 5494105103..fa310afdf6 100644 --- a/webrtc/pc/srtpfilter.cc +++ b/webrtc/pc/srtpfilter.cc @@ -565,10 +565,21 @@ bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { // stream_template will be the reference context for other streams. // Let's use it for getting the keys. srtp_stream_ctx_t* srtp_context = session_->stream_template; +#if defined(SRTP_MAX_MKI_LEN) + // libsrtp 2.1.0 + if (srtp_context && srtp_context->session_keys && + srtp_context->session_keys->rtp_auth) { + external_hmac = reinterpret_cast( + srtp_context->session_keys->rtp_auth->state); + } +#else + // libsrtp 2.0.0 + // TODO(jbauch): Remove after switching to libsrtp 2.1.0 if (srtp_context && srtp_context->rtp_auth) { external_hmac = reinterpret_cast( srtp_context->rtp_auth->state); } +#endif if (!external_hmac) { LOG(LS_ERROR) << "Failed to get auth keys from libsrtp!.";