? zap_pri_callprogress.diff
? channels/chan_zap.c.progress
Index: channels/chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.392
diff -u -r1.392 chan_zap.c
--- channels/chan_zap.c	16 Dec 2004 03:14:59 -0000	1.392
+++ channels/chan_zap.c	21 Dec 2004 18:17:20 -0000
@@ -578,6 +578,7 @@
 	int alreadyhungup;
 	int proceeding;
 	int setup_ack;		/* wheter we received SETUP_ACKNOWLEDGE or not */
+	int dsp_features;
 #endif	
 #ifdef ZAPATA_R2
 	int r2prot;
@@ -4464,6 +4465,7 @@
 	pbx_builtin_setvar_helper(chan, "CALLTYPE", s);
 }
 #endif
+
 static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int index, int law, int ctype)
 {
 	struct ast_channel *tmp;
@@ -4539,6 +4541,15 @@
 			} else {
 				i->dsp = ast_dsp_new();
 				if (i->dsp) {
+#ifdef ZAPATA_PRI
+					/* We cannot do progress detection until receives PROGRESS message */
+					if (i->outgoing && (i->sig == SIG_PRI)) {
+						/* Remember requested DSP features, don't treat
+						   talking as ANSWER */
+						i->dsp_features = features & ~DSP_PROGRESS_TALK;
+						features = 0;
+					}
+#endif
 					ast_dsp_set_features(i->dsp, features);
 					ast_dsp_digitmode(i->dsp, DSP_DIGITMODE_DTMF | i->dtmfrelax);
 					if (!ast_strlen_zero(progzone))
@@ -7876,6 +7887,18 @@
 							pri->pvts[chanpos]->proceeding=2;
 						} else
 							ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n");
+#ifdef PRI_PROGRESS_MASK
+						if (e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) {
+#else
+						if (e->ringing.progress == 8) {
+#endif
+							/* Now we can do call progress detection */
+							if(pri->pvts[chanpos]->dsp && pri->pvts[chanpos]->dsp_features) {
+								/* RINGING detection isn't required because we got ALERTING signal */
+								ast_dsp_set_features(pri->pvts[chanpos]->dsp, pri->pvts[chanpos]->dsp_features & ~DSP_PROGRESS_RINGING);
+								pri->pvts[chanpos]->dsp_features = 0;
+							}
+						}
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}
@@ -7890,7 +7913,18 @@
 						ast_mutex_lock(&pri->pvts[chanpos]->lock);
 						ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n",
 								pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
-							zap_queue_frame(pri->pvts[chanpos], &f, pri);
+						zap_queue_frame(pri->pvts[chanpos], &f, pri);
+#ifdef PRI_PROGRESS_MASK
+						if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
+#else
+						if (e->proceeding.progress == 8) {
+#endif
+							/* Now we can do call progress detection */
+							if(pri->pvts[chanpos]->dsp && pri->pvts[chanpos]->dsp_features) {
+								ast_dsp_set_features(pri->pvts[chanpos]->dsp, pri->pvts[chanpos]->dsp_features);
+								pri->pvts[chanpos]->dsp_features = 0;
+							}
+						}
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}
@@ -7908,6 +7942,17 @@
 						f.subclass = AST_CONTROL_PROCEEDING;
 						zap_queue_frame(pri->pvts[chanpos], &f, pri);
 						pri->pvts[chanpos]->proceeding=2;
+#ifdef PRI_PROGRESS_MASK
+						if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
+#else
+						if (e->proceeding.progress == 8) {
+#endif
+							/* Now we can do call progress detection */
+							if(pri->pvts[chanpos]->dsp && pri->pvts[chanpos]->dsp_features) {
+								ast_dsp_set_features(pri->pvts[chanpos]->dsp, pri->pvts[chanpos]->dsp_features);
+								pri->pvts[chanpos]->dsp_features = 0;
+							}
+						}
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}
@@ -7951,6 +7996,17 @@
 						chanpos = -1;
 					} else {
 						ast_mutex_lock(&pri->pvts[chanpos]->lock);
+#ifdef PRI_PROGRESS_MASK
+						if (e->answer.progressmask & PRI_PROG_INBAND_AVAILABLE) {
+#else
+						if (e->answer.progress == 8) {
+#endif
+							/* Now we can do call progress detection */
+							if(pri->pvts[chanpos]->dsp && pri->pvts[chanpos]->dsp_features) {
+								ast_dsp_set_features(pri->pvts[chanpos]->dsp, pri->pvts[chanpos]->dsp_features);
+								pri->pvts[chanpos]->dsp_features = 0;
+							}
+						}
 						if (pri->pvts[chanpos]->realcall && (pri->pvts[chanpos]->realcall->sig == SIG_FXSKS)) {
 							ast_log(LOG_DEBUG, "Starting up GR-303 trunk now that we got CONNECT...\n");
 							x = ZT_START;
