From a7d18aea9a2a50b00629faa43395205364309020 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 27 Apr 2015 10:57:07 -0400 Subject: [PATCH] reset SRTP ROC to zero when SSRC changes workaround as per issue #102 for broken audio after SSRC change by hold/unhold. workaround before full multi-SSRC support is available. --- daemon/crypto.h | 2 ++ daemon/rtp.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/daemon/crypto.h b/daemon/crypto.h index 82e02dd47..495a8d869 100644 --- a/daemon/crypto.h +++ b/daemon/crypto.h @@ -73,6 +73,7 @@ struct crypto_context { char session_salt[SRTP_MAX_SESSION_SALT_LEN]; /* k_s */ char session_auth_key[SRTP_MAX_SESSION_AUTH_LEN]; + u_int32_t ssrc; u_int64_t last_index; /* XXX replay list */ /* ? */ @@ -138,6 +139,7 @@ INLINE void crypto_cleanup(struct crypto_context *c) { INLINE void crypto_reset(struct crypto_context *c) { crypto_cleanup(c); c->last_index = 0; + c->ssrc = 0; } INLINE void crypto_params_copy(struct crypto_params *o, const struct crypto_params *i) { crypto_params_cleanup(o); diff --git a/daemon/rtp.c b/daemon/rtp.c index a1ba9ebf4..8fb624030 100644 --- a/daemon/rtp.c +++ b/daemon/rtp.c @@ -189,6 +189,14 @@ int rtp_avp2savp(str *s, struct crypto_context *c) { if (check_session_keys(c)) return -1; + /* SSRC is part of the crypto context and ROC must be reset when it changes */ + if (G_UNLIKELY(!c->ssrc)) + c->ssrc = rtp->ssrc; + else if (G_UNLIKELY(c->ssrc != rtp->ssrc)) { + c->last_index = 0; + c->ssrc = rtp->ssrc; + } + index = packet_index(c, rtp); /* rfc 3711 section 3.1 */