[asterisk-commits] oej: branch oej/pinefool-poor-mans-plc-1.8 r403309 - in /team/oej/pinefool-po...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 3 05:08:17 CST 2013


Author: oej
Date: Tue Dec  3 05:08:12 2013
New Revision: 403309

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403309
Log:
Some uncommitted patches. This is an RTP day.

Modified:
    team/oej/pinefool-poor-mans-plc-1.8/   (props changed)
    team/oej/pinefool-poor-mans-plc-1.8/channels/chan_sip.c
    team/oej/pinefool-poor-mans-plc-1.8/configs/rtp.conf.sample
    team/oej/pinefool-poor-mans-plc-1.8/res/res_rtp_asterisk.c

Propchange: team/oej/pinefool-poor-mans-plc-1.8/
------------------------------------------------------------------------------
--- automerge (original)
+++ automerge Tue Dec  3 05:08:12 2013
@@ -1,1 +1,1 @@
-*
+Is-there-life-off-net?

Modified: team/oej/pinefool-poor-mans-plc-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefool-poor-mans-plc-1.8/channels/chan_sip.c?view=diff&rev=403309&r1=403308&r2=403309
==============================================================================
--- team/oej/pinefool-poor-mans-plc-1.8/channels/chan_sip.c (original)
+++ team/oej/pinefool-poor-mans-plc-1.8/channels/chan_sip.c Tue Dec  3 05:08:12 2013
@@ -5605,10 +5605,8 @@
 
 		ast_rtp_instance_set_prop(dialog->trtp, AST_RTP_PROPERTY_RTCP, 1);
 	}
-	if (ast_test_flag(&dialog->flags[2], SIP_PAGE3_POORMANSPLC)) {
-		/* This is only supported for AUDIO */
-		ast_rtp_instance_plc_set_state(dialog->rtp, TRUE);
-	}
+	/* PLC is only supported for AUDIO */
+	ast_rtp_instance_plc_set_state(dialog->rtp, ast_test_flag(&dialog->flags[2], SIP_PAGE3_POORMANSPLC));
 
 	ast_rtp_instance_set_timeout(dialog->rtp, dialog->rtptimeout);
 	ast_rtp_instance_set_hold_timeout(dialog->rtp, dialog->rtpholdtimeout);
@@ -16793,6 +16791,7 @@
 		if (!dialog_initialize_rtp(p)) {
 			if (p->rtp) {
 				ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &peer->prefs);
+				ast_rtp_instance_plc_set_state(p->rtp, ast_test_flag(&p->flags[2], SIP_PAGE3_POORMANSPLC));
 				p->autoframing = peer->autoframing;
 			}
 		} else {

Modified: team/oej/pinefool-poor-mans-plc-1.8/configs/rtp.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefool-poor-mans-plc-1.8/configs/rtp.conf.sample?view=diff&rev=403309&r1=403308&r2=403309
==============================================================================
--- team/oej/pinefool-poor-mans-plc-1.8/configs/rtp.conf.sample (original)
+++ team/oej/pinefool-poor-mans-plc-1.8/configs/rtp.conf.sample Tue Dec  3 05:08:12 2013
@@ -33,19 +33,20 @@
 ; connected. This option is set to 4 by default.
 ; probation=8
 
-; The RTP channels has an implementation of Packet Loss Concealment
-; that is named "Poor Man's PLC". Normally a PLC happens withing the
-; context of a jitter buffer. This PLC just copies the previous
-; packet into the stream again if a packet (or multiple) is missing.
-; If a packet arrives too late (reordered) it will be ignored.
-; This introduces a bit of jitter since we're sending two
-; packets at the same time. Hopefully the phone or gw at the
-; end of the line will have a jitter buffer and play out the media
-; properly. This PLC will make sure that Asterisk outbound RTP streams has
-; less skew and that recordings will actually have a proper amount of
-; media. Default is turned off.
-; This setting apply to ALL rtp streams in this Asterisk instance.
-; If you have video or text streams, it might not be a good idea.
+; The "Bridgepacketloss" is a setting that is disabled by default in this release.
+; Asterisk by default resequences RTP packets, so that if we receive packets 20,21,23,24
+; they will be renumbered as 20,21,22,23. If you set this setting to "yes" there will
+; be a gap in the outbound sequence numbers as well, which in most cases will help
+; both codecs and jitter buffers/PLC functions in the receiving end - a phone or a gateway.
+; The function also supports out of order packets, so if we receive 20,23,21,22,24
+; the seqence numbers on the outbound stream will be out of order in the same way.
+bridgepacketloss=no
+
+; If a channel driver turns on Poor Man's PLC the RTP channel will replace lost packets
+; with a copy of a previous packet. The "plcmax" setting defines the maximum number of
+; packets inserted in one operation. If the seqno indicates 200 lost packets, it doesn't
+; make much sense to inject all of them. (default 10)
+; For many codecs, the size of the packet is 20 ms (see packetization settings)
+; so 10 packets is 0.2 secs of noise. 50 packets is a second and will sound really bad.
+;plcmax = 42
 ;
-; You can turn this on per device or globally in sip.conf too.
-;plc=yes

Modified: team/oej/pinefool-poor-mans-plc-1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefool-poor-mans-plc-1.8/res/res_rtp_asterisk.c?view=diff&rev=403309&r1=403308&r2=403309
==============================================================================
--- team/oej/pinefool-poor-mans-plc-1.8/res/res_rtp_asterisk.c (original)
+++ team/oej/pinefool-poor-mans-plc-1.8/res/res_rtp_asterisk.c Tue Dec  3 05:08:12 2013
@@ -89,6 +89,9 @@
 static int rtpstart = DEFAULT_RTP_START;			/*!< First port for RTP sessions (set in rtp.conf) */
 static int rtpend = DEFAULT_RTP_END;			/*!< Last port for RTP sessions (set in rtp.conf) */
 static int bridgepacketloss;		/*!< Expose packet loss when sending RTP */
+static int plcmax;                      /*!< Maximum number of PLC injections in the stream in one operation */
+#define DEFAULT_PLCMAX 10
+
 static int rtpdebug;			/*!< Are we debugging? */
 static int rtcpdebug;			/*!< Are we debugging RTCP? */
 static int rtcpstats;			/*!< Are we debugging RTCP? */
@@ -2373,7 +2376,7 @@
 
 	if (rtp->rxcount > 1) {
 		if (ast_test_flag(rtp, FLAG_POORMANSPLC) && seqno < rtp->lastrxseqno)  {
-			/* This is a latecome we've already replaced. A jitter buffer would have handled this
+			/* This is a latecomer we've already replaced. A jitter buffer would have handled this
 			   properly, but in many cases we can't afford a jitterbuffer and will have to live
 			   with the face that the poor man's PLC already has replaced this frame and we can't
 			   insert it AGAIN, because that would cause negative skew.
@@ -2384,13 +2387,20 @@
 		lostpackets = (int) seqno - (int) rtp->lastrxseqno - 1;
 		/* RTP sequence numbers are consecutive. Have we lost a packet? */
 		if (lostpackets) {
-			ast_log(LOG_DEBUG, "**** Packet loss detected - # %d. Current Seqno %-6.6u\n", lostpackets, seqno);
+			ast_debug(2, "**** Packet loss detected - # %d. Current Seqno %-6.6u\n", lostpackets, seqno);
 		}
 		if (ast_test_flag(rtp, FLAG_POORMANSPLC) && rtp->plcbuf != NULL) {
 			int i;
-			for (i = 0; i < lostpackets; i++) {
-				AST_LIST_INSERT_TAIL(&frames, ast_frdup(rtp->plcbuf), frame_list);
-				ast_log(LOG_DEBUG, "**** Inserting buffer frame %d. \n", i + 1);
+			for (i = 0; i < lostpackets && i < plcmax; i++) {
+				struct ast_frame *new;
+				rtp->lastrxseqno++;
+				/* Fix the seqno in the frame */
+				rtp->plcbuf->seqno = rtp->lastrxseqno;
+				rtp->plcbuf->ts += rtp->plcbuf->len;
+				new = ast_frdup(rtp->plcbuf);
+
+				AST_LIST_INSERT_TAIL(&frames, new, frame_list);
+				ast_debug(2, "**** Inserting buffer frame %d. Seqno %d\n", i + 1, rtp->plcbuf->seqno);
 			}
 		}
 	}




More information about the asterisk-commits mailing list