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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 20 15:55:36 CDT 2013


Author: oej
Date: Wed Mar 20 15:55:34 2013
New Revision: 383463

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383463
Log:
Add a setting in chan_sip

Modified:
    team/oej/pinefool-poor-mans-plc-1.8/channels/chan_sip.c
    team/oej/pinefool-poor-mans-plc-1.8/channels/sip/include/sip.h
    team/oej/pinefool-poor-mans-plc-1.8/configs/rtp.conf.sample
    team/oej/pinefool-poor-mans-plc-1.8/include/asterisk/rtp_engine.h
    team/oej/pinefool-poor-mans-plc-1.8/main/rtp_engine.c
    team/oej/pinefool-poor-mans-plc-1.8/res/res_rtp_asterisk.c

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=383463&r1=383462&r2=383463
==============================================================================
--- 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 Wed Mar 20 15:55:34 2013
@@ -5595,6 +5595,10 @@
 
 		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);
+	}
 
 	ast_rtp_instance_set_timeout(dialog->rtp, dialog->rtptimeout);
 	ast_rtp_instance_set_hold_timeout(dialog->rtp, dialog->rtpholdtimeout);
@@ -18093,6 +18097,7 @@
 		ast_cli(fd, "  Dynamic      : %s\n", AST_CLI_YESNO(peer->host_dynamic));
 		ast_cli(fd, "  Callerid     : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>"));
 		ast_cli(fd, "  MaxCallBR    : %d kbps\n", peer->maxcallbitrate);
+		ast_cli(fd, "  PLC          : %s\n", AST_CLI_YESNO(ast_test_flag(&peer->flags[2], SIP_PAGE3_POORMANSPLC)));
 		ast_cli(fd, "  Expire       : %ld\n", ast_sched_when(sched, peer->expire));
 		ast_cli(fd, "  Insecure     : %s\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE)));
 		ast_cli(fd, "  Force rport  : %s\n", AST_CLI_YESNO(ast_test_flag(&peer->flags[0], SIP_NAT_FORCE_RPORT)));
@@ -18785,6 +18790,7 @@
 	ast_cli(a->fd, "  Relax DTMF:             %s\n", AST_CLI_YESNO(global_relaxdtmf));
 	ast_cli(a->fd, "  RFC2833 Compensation:   %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[1], SIP_PAGE2_RFC2833_COMPENSATE)));
 	ast_cli(a->fd, "  Symmetric RTP:          %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[1], SIP_PAGE2_SYMMETRICRTP)));
+	ast_cli(a->fd, "  Poor man's PLC:         %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[2], SIP_PAGE3_POORMANSPLC)));
 	ast_cli(a->fd, "  Compact SIP headers:    %s\n", AST_CLI_YESNO(sip_cfg.compactheaders));
 	ast_cli(a->fd, "  RTP Keepalive:          %d %s\n", global_rtpkeepalive, global_rtpkeepalive ? "" : "(Disabled)" );
 	ast_cli(a->fd, "  RTP Timeout:            %d %s\n", global_rtptimeout, global_rtptimeout ? "" : "(Disabled)" );
@@ -19194,6 +19200,7 @@
 			ast_cli(a->fd, "  T.38 support            %s\n", AST_CLI_YESNO(cur->udptl != NULL));
 			ast_cli(a->fd, "  Video support           %s\n", AST_CLI_YESNO(cur->vrtp != NULL));
 			ast_cli(a->fd, "  MaxCallBR:              %d kbps\n", cur->maxcallbitrate);
+			ast_cli(a->fd, "  Poor man's PLC:         %s\n", AST_CLI_YESNO(ast_test_flag(&cur->flags[2], SIP_PAGE3_POORMANSPLC)));
 			ast_cli(a->fd, "  Theoretical Address:    %s\n", ast_sockaddr_stringify(&cur->sa));
 			ast_cli(a->fd, "  Received Address:       %s\n", ast_sockaddr_stringify(&cur->recv));
 			ast_cli(a->fd, "  SIP Transfer mode:      %s\n", transfermode2str(cur->allowtransfer));
@@ -27476,6 +27483,10 @@
 		else {
 			ast_log(LOG_WARNING, "Unknown dtmf mode '%s' on line %d, using rfc2833\n", v->value, v->lineno);
 			ast_set_flag(&flags[0], SIP_DTMF_RFC2833);
+		}
+	} else if (!strcasecmp(v->name, "plc")) {
+		if (ast_true(v->value)) {
+			ast_set_flag(&flags[2], SIP_PAGE3_POORMANSPLC);
 		}
 	} else if (!strcasecmp(v->name, "nat")) {
 		ast_set_flag(&mask[0], SIP_NAT_FORCE_RPORT);

Modified: team/oej/pinefool-poor-mans-plc-1.8/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefool-poor-mans-plc-1.8/channels/sip/include/sip.h?view=diff&rev=383463&r1=383462&r2=383463
==============================================================================
--- team/oej/pinefool-poor-mans-plc-1.8/channels/sip/include/sip.h (original)
+++ team/oej/pinefool-poor-mans-plc-1.8/channels/sip/include/sip.h Wed Mar 20 15:55:34 2013
@@ -359,9 +359,10 @@
 
 #define SIP_PAGE3_SNOM_AOC               (1 << 0)  /*!< DPG: Allow snom aoc messages */
 #define SIP_PAGE3_DIRECT_MEDIA_OUTGOING  (1 << 1)  /*!< DP: Only send direct media reinvites on outgoing calls */
+#define SIP_PAGE3_POORMANSPLC		 (1 << 28)	/*!< DPG: Enable poor man's PLC - packet loss concealment */
 
 #define SIP_PAGE3_FLAGS_TO_COPY \
-	(SIP_PAGE3_SNOM_AOC | SIP_PAGE3_DIRECT_MEDIA_OUTGOING)
+	(SIP_PAGE3_SNOM_AOC | SIP_PAGE3_DIRECT_MEDIA_OUTGOING | SIP_PAGE3_POORMANSPLC)
 
 /*@}*/
 

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=383463&r1=383462&r2=383463
==============================================================================
--- 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 Wed Mar 20 15:55:34 2013
@@ -44,4 +44,8 @@
 ; 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.
+;
+; You can turn this on per device or globally in sip.conf too.
 ;plc=yes

Modified: team/oej/pinefool-poor-mans-plc-1.8/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefool-poor-mans-plc-1.8/include/asterisk/rtp_engine.h?view=diff&rev=383463&r1=383462&r2=383463
==============================================================================
--- team/oej/pinefool-poor-mans-plc-1.8/include/asterisk/rtp_engine.h (original)
+++ team/oej/pinefool-poor-mans-plc-1.8/include/asterisk/rtp_engine.h Wed Mar 20 15:55:34 2013
@@ -377,6 +377,8 @@
 	format_t (*available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
 	/*! Callback to send CNG */
 	int (*sendcng)(struct ast_rtp_instance *instance, int level);
+	/*! Callback to turn on or off poor man's packet loss concealment in the RTP engine */
+	void (*plc_set_state)(struct ast_rtp_instance *instance, int state);
 	/*! Linked list information */
 	AST_RWLIST_ENTRY(ast_rtp_engine) entry;
 };
@@ -1854,6 +1856,13 @@
  */
 struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance);
 
+/*!
+ * \brief Change state of PLC for RTP instance
+ * \param instance the RTP instance
+ * \param state 1 for on, 0 for off
+ */
+void ast_rtp_instance_plc_set_state(struct ast_rtp_instance *instance, int state);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/oej/pinefool-poor-mans-plc-1.8/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefool-poor-mans-plc-1.8/main/rtp_engine.c?view=diff&rev=383463&r1=383462&r2=383463
==============================================================================
--- team/oej/pinefool-poor-mans-plc-1.8/main/rtp_engine.c (original)
+++ team/oej/pinefool-poor-mans-plc-1.8/main/rtp_engine.c Wed Mar 20 15:55:34 2013
@@ -782,6 +782,14 @@
 		instance->engine->stop(instance);
 	}
 }
+
+void ast_rtp_instance_plc_set_state(struct ast_rtp_instance *instance, int state)
+{
+	if (instance->engine->plc_set_state) {
+		instance->engine->plc_set_state(instance, state);
+	}
+}
+
 
 int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
 {

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=383463&r1=383462&r2=383463
==============================================================================
--- 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 Wed Mar 20 15:55:34 2013
@@ -114,6 +114,7 @@
 #define FLAG_NAT_INACTIVE_NOWARN        (1 << 1)
 #define FLAG_NEED_MARKER_BIT            (1 << 3)
 #define FLAG_DTMF_COMPENSATE            (1 << 4)
+#define FLAG_POORMANSPLC	        (1 << 15)
 
 /*! \brief RTP session description */
 struct ast_rtp {
@@ -295,11 +296,13 @@
 static void ast_rtp_stop(struct ast_rtp_instance *instance);
 static int ast_rtp_qos_set(struct ast_rtp_instance *instance, int tos, int cos, const char* desc);
 static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level);
+static void ast_rtp_plc_set_state(struct ast_rtp_instance *instance, int state);
 
 /* RTP Engine Declaration */
 static struct ast_rtp_engine asterisk_rtp_engine = {
 	.name = "asterisk",
 	.new = ast_rtp_new,
+	.plc_set_state = ast_rtp_plc_set_state,
 	.destroy = ast_rtp_destroy,
 	.dtmf_begin = ast_rtp_dtmf_begin,
 	.dtmf_end = ast_rtp_dtmf_end,
@@ -532,6 +535,10 @@
 
 	/* Set default parameters on the newly created RTP structure */
 	rtp->plcbuf = NULL;
+
+	if (poormansplc) {
+		ast_set_flag(rtp, FLAG_POORMANSPLC);	/* If PLC is globally set, turn it on */
+	}
 	rtp->ssrc = ast_random();
 	rtp->seqno = ast_random() & 0xffff;
 	rtp->strict_rtp_state = (strictrtp ? STRICT_RTP_LEARN : STRICT_RTP_OPEN);
@@ -1154,6 +1161,16 @@
 	}
 
 	return res;
+}
+
+static void ast_rtp_plc_set_state(struct ast_rtp_instance *instance, int state)
+{
+	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+	if (state) {
+		ast_set_flag(rtp, FLAG_POORMANSPLC);
+	} else {
+		ast_clear_flag(rtp, FLAG_POORMANSPLC);
+	}
 }
 
 static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame *frame, int codec)
@@ -2335,7 +2352,7 @@
 		rtp->cycles += RTP_SEQ_MOD;
 
 	if (rtp->rxcount > 1) {
-		if (poormansplc && seqno < rtp->lastrxseqno)  {
+		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
 			   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
@@ -2349,7 +2366,7 @@
 		if (lostpackets) {
 			ast_log(LOG_DEBUG, "**** Packet loss detected - # %d. Current Seqno %-6.6u\n", lostpackets, seqno);
 		}
-		if (poormansplc && rtp->plcbuf != NULL) {
+		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);
@@ -2524,10 +2541,7 @@
 		rtp->f.delivery.tv_usec = 0;
 	}
 
-	//	if (rtp->plcbuf) {
-	//		ast_frfree(rtp->plcbuf);
-	//	}
-	if (poormansplc) {
+	if (ast_test_flag(rtp, FLAG_POORMANSPLC)) {
 		/* Copy this frame to buffer */
 		if (rtp->plcbuf) {
 			/* We have something here. Take it away, dear Henry. */




More information about the asterisk-commits mailing list