[asterisk-commits] res rtp asterisk: Fix packet stats on bridged connection (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 29 14:31:17 CDT 2016


Joshua Colp has submitted this change and it was merged.

Change subject: res_rtp_asterisk:  Fix packet stats on bridged connection
......................................................................


res_rtp_asterisk:  Fix packet stats on bridged connection

rxcount, txcount, rxoctetcount and txoctetcount weren't being calculated
for bridged streams because the calulations were being done after the
bridged short-circuit.  Actually, rxoctetcount wasn't ever being calculated.

Moved the calculations so they occur for all valid received packets and
all transmitted packets.  Also added rxoctetcount and txoctetcount to
ast_rtp_instance_stat.

Change-Id: I08fb06011a82d38c3b4068867a615068fbe59cbb
---
M include/asterisk/rtp_engine.h
M res/res_rtp_asterisk.c
2 files changed, 20 insertions(+), 3 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index 6734033..411ae8a 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -228,6 +228,10 @@
 	AST_RTP_INSTANCE_STAT_REMOTE_SSRC,
 	/*! Retrieve channel unique ID */
 	AST_RTP_INSTANCE_STAT_CHANNEL_UNIQUEID,
+	/*! Retrieve number of octets transmitted */
+	AST_RTP_INSTANCE_STAT_TXOCTETCOUNT,
+	/*! Retrieve number of octets received */
+	AST_RTP_INSTANCE_STAT_RXOCTETCOUNT,
 };
 
 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
@@ -359,6 +363,10 @@
 	unsigned int remote_ssrc;
 	/*! The Asterisk channel's unique ID that owns this instance */
 	char channel_uniqueid[MAX_CHANNEL_ID];
+	/*! Number of octets transmitted */
+	unsigned int txoctetcount;
+	/*! Number of octets received */
+	unsigned int rxoctetcount;
 };
 
 #define AST_RTP_STAT_SET(current_stat, combined, placement, value) \
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 9c7432e..45bc310 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -2252,12 +2252,16 @@
 	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) {
@@ -2274,6 +2278,7 @@
 	if (res > 0) {
 		ast_rtp_instance_set_last_tx(instance, time(NULL));
 	}
+
 	return res;
 }
 
@@ -3352,9 +3357,6 @@
 				ast_set_flag(rtp, FLAG_NAT_INACTIVE_NOWARN);
 			}
 		} else {
-			rtp->txcount++;
-			rtp->txoctetcount += (res - hdrlen);
-
 			if (rtp->rtcp && rtp->rtcp->schedid < 0) {
 				ast_debug(1, "Starting RTCP transmission on RTP instance '%p'\n", instance);
 				ao2_ref(instance, +1);
@@ -4287,6 +4289,9 @@
 		return -1;
 	}
 
+	rtp->rxcount++;
+	rtp->rxoctetcount += (len - hdrlen);
+
 	/* If the payload coming in is not one of the negotiated ones then send it to the core, this will cause formats to change and the bridge to break */
 	if (ast_rtp_codecs_find_payload_code(ast_rtp_instance_get_codecs(instance1), bridged_payload) == -1) {
 		ast_debug(1, "Unsupported payload type received \n");
@@ -4517,6 +4522,7 @@
 
 		rtp->seedrxseqno = 0;
 		rtp->rxcount = 0;
+		rtp->rxoctetcount = 0;
 		rtp->cycles = 0;
 		rtp->lastrxseqno = 0;
 		rtp->last_seqno = 0;
@@ -4560,6 +4566,7 @@
 	}
 
 	rtp->rxcount++;
+	rtp->rxoctetcount += (res - hdrlen);
 	if (rtp->rxcount == 1) {
 		rtp->seedrxseqno = seqno;
 	}
@@ -4961,6 +4968,8 @@
 
 	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_TXCOUNT, -1, stats->txcount, rtp->txcount);
 	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_RXCOUNT, -1, stats->rxcount, rtp->rxcount);
+	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_TXOCTETCOUNT, -1, stats->txoctetcount, rtp->txoctetcount);
+	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_RXOCTETCOUNT, -1, stats->rxoctetcount, rtp->rxoctetcount);
 
 	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_TXPLOSS, AST_RTP_INSTANCE_STAT_COMBINED_LOSS, stats->txploss, rtp->rtcp->reported_lost);
 	AST_RTP_STAT_SET(AST_RTP_INSTANCE_STAT_RXPLOSS, AST_RTP_INSTANCE_STAT_COMBINED_LOSS, stats->rxploss, rtp->rtcp->expected_prior - rtp->rtcp->received_prior);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I08fb06011a82d38c3b4068867a615068fbe59cbb
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-commits mailing list