[asterisk-commits] oej: branch 1.4 r216430 - in /branches/1.4: apps/ channels/ configs/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 4 08:45:53 CDT 2009


Author: oej
Date: Fri Sep  4 08:45:48 2009
New Revision: 216430

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=216430
Log:
Make apps send PROGRESS control frame for early media and fix too early media issue in SIP

The issue at hand is that some legacy (dying) PBX systems send empty media frames on PRI
links *before* any call progress. The SIP channel receives these frames and by default
signals 183 Session progress and starts sending media. This will cause phones to 
play silence and ignore the later 180 ringing message. A bad user experience.

The fix is twofold:
- We discovered that asterisk apps that support early media ("noanswer") did not send
  any PROGRESS frame to indicate early media. Fixed.
- We introduce a setting in chan_sip so that users can disable any relay of media frames
  before the outbound channel actually indicates any sort of call progress.
  In 1.4, 1.6.0 and 1.6.1, this will be disabled for backward compatibility. In later versions
  of Asterisk, this will be enabled. We don't assume that it will change your Asterisk
  phone experience - only for the better.

We encourage third-party application developers to make sure that if they have applications
that wants to send early media, add a PROGRESS control frame transmission to make sure that
all channel drivers actually will start sending early media. This has not been the default
in Asterisk previous to this patch, so if you got inspiration from our code, you need to
update accordingly. Sorry for the trouble and thanks for your support.

This code has been running for a few months in a large scale installation (over 250
servers with PRI and/or BRI links to old PBX systems). 
That's no proof that this is an excellent patch, but, well, it's tested :-)


Modified:
    branches/1.4/apps/app_disa.c
    branches/1.4/apps/app_playback.c
    branches/1.4/channels/chan_sip.c
    branches/1.4/configs/sip.conf.sample
    branches/1.4/main/pbx.c

Modified: branches/1.4/apps/app_disa.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/apps/app_disa.c?view=diff&rev=216430&r1=216429&r2=216430
==============================================================================
--- branches/1.4/apps/app_disa.c (original)
+++ branches/1.4/apps/app_disa.c Fri Sep  4 08:45:48 2009
@@ -176,7 +176,12 @@
 			/* answer */
 			ast_answer(chan);
 		}
-	} else special_noanswer = 1;
+	} else {
+		special_noanswer = 1;
+		if (chan->_state != AST_STATE_UP) {
+			ast_indicate(chan, AST_CONTROL_PROGRESS);
+		}
+	}
 	i = k = x = 0; /* k is 0 for pswd entry, 1 for ext entry */
 	did_ignore = 0;
 	exten[0] = 0;

Modified: branches/1.4/apps/app_playback.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/apps/app_playback.c?view=diff&rev=216430&r1=216429&r2=216430
==============================================================================
--- branches/1.4/apps/app_playback.c (original)
+++ branches/1.4/apps/app_playback.c Fri Sep  4 08:45:48 2009
@@ -418,9 +418,13 @@
 		if (option_skip) {
 			/* At the user's option, skip if the line is not up */
 			goto done;
-		} else if (!option_noanswer)
+		} else if (!option_noanswer) {
 			/* Otherwise answer unless we're supposed to send this while on-hook */
 			res = ast_answer(chan);
+		} else {
+			ast_indicate(chan, AST_CONTROL_PROGRESS);
+		}
+
 	}
 	if (!res) {
 		char *back = args.filenames;

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=216430&r1=216429&r2=216430
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Fri Sep  4 08:45:48 2009
@@ -539,6 +539,7 @@
 
 /* Global settings only apply to the channel */
 static int global_directrtpsetup;	/*!< Enable support for Direct RTP setup (no re-invites) */
+static int global_prematuremediafilter;	/*!< Enable/disable premature frames in a call (causing 183 early media) */
 static int global_limitonpeers;		/*!< Match call limit on peers only */
 static int global_rtautoclear;
 static int global_notifyringing;	/*!< Send notifications on ringing */
@@ -3894,9 +3895,11 @@
 				    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
 				    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 					ast_rtp_new_source(p->rtp);
-					p->invitestate = INV_EARLY_MEDIA;
-					transmit_provisional_response(p, "183 Session Progress", &p->initreq, 1);
-					ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
+					if (!global_prematuremediafilter) {
+						p->invitestate = INV_EARLY_MEDIA;
+						transmit_provisional_response(p, "183 Session Progress", &p->initreq, 1);
+						ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
+					}
 				} else if (p->t38.state == T38_ENABLED && !p->t38.direct) {
 					p->t38.state = T38_DISABLED;
 					transmit_reinvite_with_sdp(p);
@@ -11317,6 +11320,7 @@
 	print_codec_to_cli(fd, &default_prefs);
 	ast_cli(fd, "\n");
 	ast_cli(fd, "  T1 minimum:             %d\n", global_t1min);
+	ast_cli(fd, "  No premature media:     %s\n", global_prematuremediafilter ? "Yes" : "No");
 	ast_cli(fd, "  Relax DTMF:             %s\n", global_relaxdtmf ? "Yes" : "No");
 	ast_cli(fd, "  Compact SIP headers:    %s\n", compactheaders ? "Yes" : "No");
 	ast_cli(fd, "  RTP Keepalive:          %d %s\n", global_rtpkeepalive, global_rtpkeepalive ? "" : "(Disabled)" );
@@ -18127,6 +18131,7 @@
 	expiry = DEFAULT_EXPIRY;
 	global_notifyringing = DEFAULT_NOTIFYRINGING;
 	global_limitonpeers = FALSE;
+	global_prematuremediafilter = FALSE;
 	global_directrtpsetup = FALSE;		/* Experimental feature, disabled by default */
 	global_notifyhold = FALSE;
 	global_alwaysauthreject = 0;
@@ -18232,6 +18237,8 @@
 			ast_set2_flag(&global_flags[1], i || ast_true(v->value), SIP_PAGE2_RTAUTOCLEAR);
 		} else if (!strcasecmp(v->name, "usereqphone")) {
 			ast_set2_flag(&global_flags[0], ast_true(v->value), SIP_USEREQPHONE);	
+		} else if (!strcasecmp(v->name, "prematuremedia")) {
+			global_prematuremediafilter = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "relaxdtmf")) {
 			global_relaxdtmf = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "checkmwi")) {

Modified: branches/1.4/configs/sip.conf.sample
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/configs/sip.conf.sample?view=diff&rev=216430&r1=216429&r2=216430
==============================================================================
--- branches/1.4/configs/sip.conf.sample (original)
+++ branches/1.4/configs/sip.conf.sample Fri Sep  4 08:45:48 2009
@@ -115,6 +115,12 @@
                                  ; use 'never' to never use in-band signalling, even in cases
                                  ; where some buggy devices might not render it
                                  ; Valid values: yes, no, never Default: never
+;prematuremedia=no		 ; Some ISDN links send empty media frames before 
+				 ; the call is in ringing or progress state. The SIP 
+				 ; channel will then send 183 indicating early media
+				 ; which will be empty - thus users get no ring signal.
+				 ; Setting this to "no" will stop any media before we have
+				 ; call progress. Default is "yes".
 ;useragent=Asterisk PBX          ; Allows you to change the user agent string
 ;promiscredir = no               ; If yes, allows 302 or REDIR to non-local SIP address
                                  ; Note that promiscredir when redirects are made to the

Modified: branches/1.4/main/pbx.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/main/pbx.c?view=diff&rev=216430&r1=216429&r2=216430
==============================================================================
--- branches/1.4/main/pbx.c (original)
+++ branches/1.4/main/pbx.c Fri Sep  4 08:45:48 2009
@@ -5710,6 +5710,8 @@
 		} else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
 			res = ast_answer(chan);
 		}
+		/* Send progress control frame to start early media */
+		ast_indicate(chan, AST_CONTROL_PROGRESS);
 	}
 
 	if (!res) {




More information about the asterisk-commits mailing list