]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_rtp_asterisk: Fix placement of txcount increment 94/2494/1
authorGeorge Joseph <george.joseph@fairview5.com>
Wed, 30 Mar 2016 14:46:32 +0000 (08:46 -0600)
committerGeorge Joseph <george.joseph@fairview5.com>
Wed, 30 Mar 2016 14:46:32 +0000 (08:46 -0600)
Commit 1bce690ccb36a4744a327c07af23a9a3a0fa20cd was incrementing txcount
for rtcp packets as well as rtp packets and that was causing sender reports
to be generated instead of receiver reports in cases where no rtp was actually
being sent.

Moved the txcount increment from __rtp_sento, which handles both rtp and rtcp,
to rtp_sento which only handles rtp packets.

Discovered by the hep/rtcp-receiver test.

Change-Id: Ie442e4bb947a68847a676497021ba10ffaf376d5

res/res_rtp_asterisk.c

index 4c6ee185fdc17c5c77040d25772307c4ab863188..029aff01b49162a449b38a7bfcfbecaaf29758a2 100644 (file)
@@ -2252,7 +2252,6 @@ static int __rtp_sendto(struct ast_rtp_instance *instance, void *buf, size_t siz
        struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
        struct ast_srtp *srtp = ast_rtp_instance_get_srtp(instance);
        int res;
-       int hdrlen = 12;
 
        *ice = 0;
 
@@ -2260,9 +2259,6 @@ static int __rtp_sendto(struct ast_rtp_instance *instance, void *buf, size_t siz
                return -1;
        }
 
-       rtp->txcount++;
-       rtp->txoctetcount += (len - hdrlen);
-
 #ifdef HAVE_PJPROJECT
        if (rtp->ice) {
                pj_thread_register_check();
@@ -2289,7 +2285,16 @@ static int rtcp_sendto(struct ast_rtp_instance *instance, void *buf, size_t size
 
 static int rtp_sendto(struct ast_rtp_instance *instance, void *buf, size_t size, int flags, struct ast_sockaddr *sa, int *ice)
 {
-       return __rtp_sendto(instance, buf, size, flags, sa, 0, ice, 1);
+       struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+       int hdrlen = 12;
+       int res;
+
+       if ((res = __rtp_sendto(instance, buf, size, flags, sa, 0, ice, 1)) > 0) {
+               rtp->txcount++;
+               rtp->txoctetcount += (res - hdrlen);
+       }
+
+       return res;
 }
 
 static int rtp_get_rate(struct ast_format *format)