]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk: Correct erroneous lost packet information in RTCP reports
authorMatthew Jordan <mjordan@digium.com>
Sat, 28 Sep 2013 22:36:29 +0000 (22:36 +0000)
committerMatthew Jordan <mjordan@digium.com>
Sat, 28 Sep 2013 22:36:29 +0000 (22:36 +0000)
RTCP's calculation of the number of lost packets in an RTP stream is based on
that stream's sequence number count, the number of received packets, and how
many packets we expect to receive. When the SSRC for an RTP stream changes,
there can - and almost always will be - a large jump in the next packet's
timestamp and sequence number. If we don't reset the number of received
packets, sequence number count, and other metrics used by RTCP, the next RR/SR
report will use the previous SSRC's values to calculate the lost packet count
for the new SSRC - resulting in a very large number of lost packets.

This patch modifies res_rtp_asterisk such that, if it detects a SSRC change, it
will reset the various values used by the RTCP calculations. From the
perspective of RTCP, this appears as a new media stream - which is what it is.

Review: https://reviewboard.asterisk.org/r/2886/

(closes issue AST-1174)
Reported by: Thomas Arimont
........

Merged revisions 400089 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.15@400118 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_rtp_asterisk.c

index 42df85f6d475117cb8f9b7836b648f1b4f1477c9..5bbde81c4fff85ceb19318f5c710260015fe70e6 100644 (file)
@@ -1138,7 +1138,7 @@ static int ast_rtcp_write(const void *data)
        }
 
        if (!res) {
-               /* 
+               /*
                 * Not being rescheduled.
                 */
                ao2_ref(instance, -1);
@@ -2259,6 +2259,13 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
 
                f = ast_frisolate(&srcupdate);
                AST_LIST_INSERT_TAIL(&frames, f, frame_list);
+
+               rtp->seedrxseqno = 0;
+               rtp->rxcount = 0;
+               rtp->cycles = 0;
+               rtp->lastrxseqno = 0;
+               rtp->rtcp->expected_prior = 0;
+               rtp->rtcp->received_prior = 0;
        }
 
        rtp->rxssrc = ssrc;
@@ -2791,14 +2798,14 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
        payload = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(instance), AST_RTP_CN);
 
        level = 127 - (level & 0x7f);
-       
+
        rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000));
 
        /* Get a pointer to the header */
        rtpheader = (unsigned int *)data;
        rtpheader[0] = htonl((2 << 30) | (1 << 23) | (payload.code << 16) | (rtp->seqno++));
        rtpheader[1] = htonl(rtp->lastts);
-       rtpheader[2] = htonl(rtp->ssrc); 
+       rtpheader[2] = htonl(rtp->ssrc);
        data[12] = level;
 
        res = rtp_sendto(instance, (void *) rtpheader, hdrlen + 1, 0, &remote_address);