summaryrefslogtreecommitdiff
path: root/res/res_rtp_asterisk.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2016-03-27 11:53:16 -0600
committerGeorge Joseph <george.joseph@fairview5.com>2016-03-28 11:23:08 -0600
commit1bce690ccb36a4744a327c07af23a9a3a0fa20cd (patch)
tree5a3081d5d815baf4c47644abf96e8b2b454a7b0f /res/res_rtp_asterisk.c
parentc88c09a9204544c8d903ef333ba9bbeb3c8cd692 (diff)
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
Diffstat (limited to 'res/res_rtp_asterisk.c')
-rw-r--r--res/res_rtp_asterisk.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 611920e80..4c6ee185f 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -2252,6 +2252,7 @@ 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;
@@ -2259,6 +2260,9 @@ 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();
@@ -2274,6 +2278,7 @@ static int __rtp_sendto(struct ast_rtp_instance *instance, void *buf, size_t siz
if (res > 0) {
ast_rtp_instance_set_last_tx(instance, time(NULL));
}
+
return res;
}
@@ -3352,9 +3357,6 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
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);
@@ -4288,6 +4290,9 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, unsigned int
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");
@@ -4518,6 +4523,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
rtp->seedrxseqno = 0;
rtp->rxcount = 0;
+ rtp->rxoctetcount = 0;
rtp->cycles = 0;
rtp->lastrxseqno = 0;
rtp->last_seqno = 0;
@@ -4561,6 +4567,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
}
rtp->rxcount++;
+ rtp->rxoctetcount += (res - hdrlen);
if (rtp->rxcount == 1) {
rtp->seedrxseqno = seqno;
}
@@ -4962,6 +4969,8 @@ static int ast_rtp_get_stat(struct ast_rtp_instance *instance, struct ast_rtp_in
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);