aboutsummaryrefslogtreecommitdiffstats
path: root/main/rtp.c
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-18 20:28:53 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-18 20:28:53 +0000
commite55519a2e807740c4fc2e52fe280a9f3f4b24eba (patch)
tree0af5edd067c2839da46fea95efd30549ad526fc4 /main/rtp.c
parent04079cf8f55b4f5c21da4918d5ea8bb3755f58ac (diff)
Issue #9554 - Improve RTCP (Dave Troy)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@61674 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/rtp.c')
-rw-r--r--main/rtp.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/main/rtp.c b/main/rtp.c
index 35409ed2c..c69351b52 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -925,6 +925,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
lsr = (double)((ntohl(rtcpheader[i + 4]) & 0xffff0000) >> 16) + (double)((double)(ntohl(rtcpheader[i + 4]) & 0xffff) / 1000000.);
dlsr = (double)(ntohl(rtcpheader[i + 5])/65536.);
rtt = a - dlsr - lsr;
+ if (rtt>=0) {
rtp->rtcp->accumulated_transit += rtt;
rtp->rtcp->rtt = rtt;
if (rtp->rtcp->maxrtt<rtt)
@@ -932,6 +933,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
if (rtp->rtcp->minrtt>rtt)
rtp->rtcp->minrtt = rtt;
}
+ }
rtp->rtcp->reported_jitter = ntohl(rtcpheader[i + 3]);
rtp->rtcp->reported_lost = ntohl(rtcpheader[i + 1]) & 0xffffff;
if (rtcp_debug_test_addr(&sin)) {
@@ -1084,7 +1086,6 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
unsigned int seqno;
int version;
int payloadtype;
- int tseqno;
int hdrlen = 12;
int padding;
int mark;
@@ -1197,8 +1198,6 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
rtp->rxcount++; /* Only count reasonably valid packets, this'll make the rtcp stats more accurate */
- tseqno = rtp->lastrxseqno +1;
-
if (rtp->rxcount==1) {
/* This is the first RTP packet successfully received from source */
rtp->seedrxseqno = seqno;
@@ -1209,8 +1208,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
/* Schedule transmission of Receiver Report */
rtp->rtcp->schedid = ast_sched_add(rtp->sched, ast_rtcp_calc_interval(rtp), ast_rtcp_write, rtp);
}
-
- if (tseqno > RTP_SEQ_MOD) { /* if tseqno is greater than RTP_SEQ_MOD it would indicate that the sender cycled */
+ if ( rtp->lastrxseqno - seqno > 100) { /* if so it would indicate that the sender cycled; allow for misordering */
rtp->cycles += RTP_SEQ_MOD;
ast_verbose("SEQNO cycled: %u\t%d\n", rtp->cycles, seqno);
}
@@ -2348,7 +2346,7 @@ static int ast_rtcp_write_sr(void *data)
rtcpheader[7] = htonl(rtp->themssrc);
rtcpheader[8] = htonl(((fraction & 0xff) << 24) | (lost & 0xffffff));
rtcpheader[9] = htonl((rtp->cycles) | ((rtp->lastrxseqno & 0xffff)));
- rtcpheader[10] = htonl((unsigned int)rtp->rxjitter);
+ rtcpheader[10] = htonl((unsigned int)(rtp->rxjitter * 65536.));
rtcpheader[11] = htonl(rtp->rtcp->themrxlsr);
rtcpheader[12] = htonl((((dlsr.tv_sec * 1000) + (dlsr.tv_usec / 1000)) * 65536) / 1000);
len += 24;
@@ -2450,7 +2448,7 @@ static int ast_rtcp_write_rr(void *data)
rtcpheader[2] = htonl(rtp->themssrc);
rtcpheader[3] = htonl(((fraction & 0xff) << 24) | (lost & 0xffffff));
rtcpheader[4] = htonl((rtp->cycles) | ((rtp->lastrxseqno & 0xffff)));
- rtcpheader[5] = htonl((unsigned int)rtp->rxjitter);
+ rtcpheader[5] = htonl((unsigned int)(rtp->rxjitter * 65536.));
rtcpheader[6] = htonl(rtp->rtcp->themrxlsr);
rtcpheader[7] = htonl((((dlsr.tv_sec * 1000) + (dlsr.tv_usec / 1000)) * 65536) / 1000);