[svn-commits] kpfleming: branch 1.4 r65685 - /branches/1.4/channels/chan_iax2.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed May 23 13:59:19 MST 2007


Author: kpfleming
Date: Wed May 23 15:59:19 2007
New Revision: 65685

URL: http://svn.digium.com/view/asterisk?view=rev&rev=65685
Log:
start the delayed PBX when receive voice or video full frames as well, and comment this delayed-PBX activity

Modified:
    branches/1.4/channels/chan_iax2.c

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=65685&r1=65684&r2=65685
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Wed May 23 15:59:19 2007
@@ -6657,6 +6657,25 @@
 				f.data = empty;
 			memset(&ies, 0, sizeof(ies));
 		}
+
+		/* when we receive the first full frame for a new incoming channel,
+		   it is safe to start the PBX on the channel because we have now
+		   completed a 3-way handshake with the peer */
+		if ((f.frametype == AST_FRAME_VOICE) ||
+		    (f.frametype == AST_FRAME_VIDEO) ||
+		    (f.frametype == AST_FRAME_IAX)) {
+			if (ast_test_flag(iaxs[fr->callno], IAX_DELAYPBXSTART)) {
+				ast_clear_flag(iaxs[fr->callno], IAX_DELAYPBXSTART);
+				if (ast_pbx_start(iaxs[fr->callno]->owner)) {
+					ast_log(LOG_WARNING, "Unable to start PBX on %s\n", iaxs[fr->callno]->owner->name);
+					ast_hangup(iaxs[fr->callno]->owner);
+					iaxs[fr->callno]->owner = NULL;
+					ast_mutex_unlock(&iaxsl[fr->callno]);
+					return 1;
+				}
+			}
+		}
+
 		if (f.frametype == AST_FRAME_VOICE) {
 			if (f.subclass != iaxs[fr->callno]->voiceformat) {
 					iaxs[fr->callno]->voiceformat = f.subclass;
@@ -6711,17 +6730,6 @@
 				iaxs[fr->callno]->last = fr->ts;
 				if (option_debug && iaxdebug)
 					ast_log(LOG_DEBUG, "For call=%d, set last=%d\n", fr->callno, fr->ts);
-			}
-
-			if (ast_test_flag(iaxs[fr->callno], IAX_DELAYPBXSTART)) {
-				ast_clear_flag(iaxs[fr->callno], IAX_DELAYPBXSTART);
-				if (ast_pbx_start(iaxs[fr->callno]->owner)) {
-					ast_log(LOG_WARNING, "Unable to start PBX on %s\n", iaxs[fr->callno]->owner->name);
-					ast_hangup(iaxs[fr->callno]->owner);
-					iaxs[fr->callno]->owner = NULL;
-					ast_mutex_unlock(&iaxsl[fr->callno]);
-					return 1;
-				}
 			}
 
 			switch(f.subclass) {
@@ -6932,7 +6940,9 @@
 												VERBOSE_PREFIX_4,
 												using_prefs);
 								
-								if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format, 1)))
+								/* create an Asterisk channel for this call, but don't start
+								   a PBX on it until we have received a full frame from the peer */
+								if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format, 1)))
 									iax2_destroy(fr->callno);
 							} else {
 								ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD);



More information about the svn-commits mailing list