]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res/res_rtp_asterisk: generate new SSRC on native bridge end
authorTorrey Searle <tsearle@voxbone.com>
Fri, 19 Feb 2021 11:50:21 +0000 (12:50 +0100)
committerGeorge Joseph <gjoseph@digium.com>
Mon, 8 Mar 2021 14:14:34 +0000 (08:14 -0600)
For RTCP to work, we update the ssrc to be the one corresponding to
the native bridge while active.  However when the bridge ends we
should generate a new SSRC as the sequence numbers will not continue
from the native bridge left off.

ASTERISK-29300 #close

Change-Id: I23334b6934d2bf6490bda4bbf6414d96b8d17d10

res/res_rtp_asterisk.c

index a962d70267f08f22fe5c7a78bfb5d4e3f1c2d462..21eff54511eb08d8bb3b6f43e3c9a078b69b9e52 100644 (file)
@@ -362,6 +362,8 @@ struct ast_rtp {
        struct ast_frame f;
        unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];
        unsigned int ssrc;              /*!< Synchronization source, RFC 3550, page 10. */
+       unsigned int ssrc_orig;         /*!< SSRC used before native bridge activated */
+       unsigned char ssrc_saved;       /*!< indicates if ssrc_orig has a value */
        char cname[AST_UUID_STR_LEN]; /*!< Our local CNAME */
        unsigned int themssrc;          /*!< Their SSRC */
        unsigned int themssrc_valid;    /*!< True if their SSRC is available. */
@@ -8530,6 +8532,18 @@ static int ast_rtp_local_bridge(struct ast_rtp_instance *instance0, struct ast_r
                ast_smoother_free(rtp->smoother);
                rtp->smoother = NULL;
        }
+
+       /* We must use a new SSRC when local bridge ends */
+       if (!instance1) {
+               rtp->ssrc = rtp->ssrc_orig;
+               rtp->ssrc_orig = 0;
+               rtp->ssrc_saved = 0;
+       } else if (!rtp->ssrc_saved) {
+               /* In case ast_rtp_local_bridge is called multiple times, only save the ssrc from before local bridge began */
+               rtp->ssrc_orig = rtp->ssrc;
+               rtp->ssrc_saved = 1;
+       }
+
        ao2_unlock(instance0);
 
        return 0;