[Asterisk-code-review] res rtp asterisk: make sure that rtp timestamps always increase (asterisk[11])

Torrey Searle asteriskteam at digium.com
Thu Sep 29 13:04:48 CDT 2016


Torrey Searle has uploaded a new change for review.

  https://gerrit.asterisk.org/4000

Change subject: res_rtp_asterisk: make sure that rtp timestamps always increase
......................................................................

res_rtp_asterisk: make sure that rtp timestamps always increase

Change-Id: Ieb27b380207e001ec46dea7b5946b424fcde77a6
---
M res/res_rtp_asterisk.c
1 file changed, 15 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/00/4000/1

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 3223cc9..2cbd06f 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -3254,7 +3254,11 @@
 		pred = rtp->lastts + frame->samples;
 
 		/* Re-calculate last TS */
-		rtp->lastts = rtp->lastts + ms * rate;
+		if (ast_test_flag(frame, AST_FRFLAG_HAS_TIMING_INFO) && frame->ts * rate > rtp->lastts) {
+			rtp->lastts = frame->ts * rate;
+		} else {
+			rtp->lastts = rtp->lastts + ms * rate;
+		}
 		if (ast_tvzero(frame->delivery)) {
 			/* If this isn't an absolute delivery time, Check if it is close to our prediction,
 			   and if so, go with our prediction */
@@ -3269,7 +3273,11 @@
 		mark = ast_format_get_video_mark(&frame->subclass.format);
 		pred = rtp->lastovidtimestamp + frame->samples;
 		/* Re-calculate last TS */
-		rtp->lastts = rtp->lastts + ms * 90;
+		if (ast_test_flag(frame, AST_FRFLAG_HAS_TIMING_INFO) && frame->ts * rate > rtp->lastts) {
+			rtp->lastts = frame->ts * rate;
+		} else {
+			rtp->lastts = rtp->lastts + ms * 90;
+		}
 		/* If it's close to our prediction, go for it */
 		if (ast_tvzero(frame->delivery)) {
 			if (abs((int)rtp->lastts - pred) < 7200) {
@@ -3283,7 +3291,11 @@
 	} else {
 		pred = rtp->lastotexttimestamp + frame->samples;
 		/* Re-calculate last TS */
-		rtp->lastts = rtp->lastts + ms;
+		if (ast_test_flag(frame, AST_FRFLAG_HAS_TIMING_INFO) && frame->ts * rate > rtp->lastts) {
+			rtp->lastts = frame->ts * rate;
+		} else {
+			rtp->lastts = rtp->lastts + ms;
+		}
 		/* If it's close to our prediction, go for it */
 		if (ast_tvzero(frame->delivery)) {
 			if (abs((int)rtp->lastts - pred) < 7200) {
@@ -3305,10 +3317,6 @@
 	/* If the timestamp for non-digt packets has moved beyond the timestamp for digits, update the digit timestamp */
 	if (rtp->lastts > rtp->lastdigitts) {
 		rtp->lastdigitts = rtp->lastts;
-	}
-
-	if (ast_test_flag(frame, AST_FRFLAG_HAS_TIMING_INFO)) {
-		rtp->lastts = frame->ts * rate;
 	}
 
 	ast_rtp_instance_get_remote_address(instance, &remote_address);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb27b380207e001ec46dea7b5946b424fcde77a6
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>



More information about the asterisk-code-review mailing list