[Asterisk-code-review] res rtp asterisk: Fix placement of txcount increment (asterisk[master])

George Joseph asteriskteam at digium.com
Wed Mar 30 09:52:48 CDT 2016


George Joseph has uploaded a new change for review.

  https://gerrit.asterisk.org/2495

Change subject: res_rtp_asterisk:  Fix placement of txcount increment
......................................................................

res_rtp_asterisk:  Fix placement of txcount increment

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
---
M res/res_rtp_asterisk.c
1 file changed, 10 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/95/2495/1

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 45bc310..9cc9f92 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -2252,16 +2252,12 @@
 	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;
 
 	if (use_srtp && res_srtp && srtp && res_srtp->protect(srtp, &temp, &len, rtcp) < 0) {
 		return -1;
 	}
-
-	rtp->txcount++;
-	rtp->txoctetcount += (len - hdrlen);
 
 #ifdef HAVE_PJPROJECT
 	if (rtp->ice) {
@@ -2289,7 +2285,16 @@
 
 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)

-- 
To view, visit https://gerrit.asterisk.org/2495
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie442e4bb947a68847a676497021ba10ffaf376d5
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>



More information about the asterisk-code-review mailing list