[Asterisk-code-review] translate: Re-enables native Packet-Loss Concealment (PLC) f... (asterisk[master])

Jaco Kroon asteriskteam at digium.com
Mon May 2 06:00:35 CDT 2016


Jaco Kroon has uploaded a new change for review.

  https://gerrit.asterisk.org/2739

Change subject: translate: Re-enables native Packet-Loss Concealment (PLC) for supporting codex.
......................................................................

translate: Re-enables native Packet-Loss Concealment (PLC) for
supporting codex.

ASTERISK-25629 #close

Change-Id: I41eda82a26715be860b0effa3907c04a304cab4b
ChangeId: Ibfcf0670e094e9718d82fd9920f1fb2dae122006
---
M main/translate.c
1 file changed, 39 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/39/2739/1

diff --git a/main/translate.c b/main/translate.c
index 8d37e37..b68b42d 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -358,6 +358,7 @@
 	pvt->f.offset = AST_FRIENDLY_OFFSET;
 	pvt->f.src = pvt->t->name;
 	pvt->f.data.ptr = pvt->outbuf.c;
+	pvt->f.seqno = 0x10000;
 
 	/*
 	 * If the translator has not provided a format
@@ -525,7 +526,7 @@
 struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, int consume)
 {
 	struct ast_trans_pvt *p = path;
-	struct ast_frame *out;
+	struct ast_frame *out, *current;
 	struct timeval delivery;
 	int has_timing_info;
 	long ts;
@@ -560,9 +561,44 @@
 			 f->samples, ast_format_get_sample_rate(f->subclass.format)));
 	}
 	delivery = f->delivery;
-	for (out = f; out && p ; p = p->next) {
-		struct ast_frame *current = out;
+	for (current = f; current && p ; current = AST_LIST_NEXT(current, frame_list)) {
+		if (current->seqno != path->f.seqno && path->f.seqno < 0x10000) {
+			int frames_missing = (current->seqno - path->f.seqno) & 0xffff;
+			if (frames_missing > 0x8000) {
+				/* assume out of order and just drop the frame */
+				continue;
+			} else {
+				struct ast_frame missed = {
+					.frametype = AST_FRAME_VOICE,
+					.subclass.format = f->subclass.format,
+					.datalen = 0,
+					.samples = f->samples,
+					.mallocd = 0,
+					.src = __FUNCTION__,
+					.data.uint32 = 0,
+					.delivery.tv_sec = 0,
+					.delivery.tv_usec = 0,
+					.flags = 0,
+					.seqno = path->f.seqno,
+				};
 
+				if (frames_missing > 96) {
+					ast_log(LOG_NOTICE, "%d lost frame(s) %d/%d %p\n", frames_missing, f->seqno, path->f.seqno, path);
+				}
+
+				while (missed.seqno != f->seqno) {
+					framein(p, &missed);
+					missed.seqno = (missed.seqno + 1) & 0xffff;
+				}
+			}
+
+		}
+		framein(p, current);
+	}
+	out = p->t->frameout(p);
+	p = p->next;
+	for ( ; out && p ; p = p->next) {
+		current = out;
 		do {
 			framein(p, current);
 			current = AST_LIST_NEXT(current, frame_list);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I41eda82a26715be860b0effa3907c04a304cab4b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>



More information about the asterisk-code-review mailing list