[asterisk-commits] moy: branch moy/mfcr2-1.4 r182167 - /team/moy/mfcr2-1.4/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Mar 15 22:04:08 CDT 2009


Author: moy
Date: Sun Mar 15 22:04:05 2009
New Revision: 182167

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=182167
Log:
Added support for MFCR2_DOUBLE_ANSWER variable to set this feature from the dial plan 

Modified:
    team/moy/mfcr2-1.4/channels/chan_dahdi.c

Modified: team/moy/mfcr2-1.4/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/moy/mfcr2-1.4/channels/chan_dahdi.c?view=diff&rev=182167&r1=182166&r2=182167
==============================================================================
--- team/moy/mfcr2-1.4/channels/chan_dahdi.c (original)
+++ team/moy/mfcr2-1.4/channels/chan_dahdi.c Sun Mar 15 22:04:05 2009
@@ -952,6 +952,30 @@
 	}
 }
 
+static int dahdi_r2_answer(struct dahdi_pvt *p)
+{
+	int res = 0;
+	/* openr2 1.1.0 and older does not even define OR2_LIB_INTERFACE
+	 * and does not has support for openr2_chan_answer_call_with_mode
+	 *  */
+#if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1
+	const char *double_answer = pbx_builtin_getvar_helper(p->owner, "MFCR2_DOUBLE_ANSWER");
+	int wants_double_answer = ast_true(double_answer) ? 1 : 0;
+	if (!double_answer) {
+		/* this still can result in double answer if the channel context 
+		 * was configured that way */
+		res = openr2_chan_answer_call(p->r2chan);
+	} else if (wants_double_answer) {
+		res = openr2_chan_answer_call_with_mode(p->r2chan, OR2_ANSWER_DOUBLE);
+	} else {
+		res = openr2_chan_answer_call_with_mode(p->r2chan, OR2_ANSWER_SIMPLE);
+	} 
+#else
+	res = openr2_chan_answer_call(p->r2chan);
+#endif
+	return res;
+}
+
 static openr2_calling_party_category_t dahdi_r2_get_channel_category(struct ast_channel *c)
 {
 	openr2_calling_party_category_t cat;
@@ -1138,7 +1162,7 @@
 		if (!p->mfcr2_accept_on_offer) {
 			openr2_chan_disable_read(r2chan);
 			ast_log(LOG_NOTICE, "Answering MFC/R2 call after accepting it on chan %d\n", openr2_chan_get_number(r2chan));
-			openr2_chan_answer_call(r2chan);
+			dahdi_r2_answer(p);
 			return;
 		}
 		c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, DAHDI_LAW_ALAW, 0);
@@ -3533,7 +3557,7 @@
 			}
 		} else {
 			ast_log(LOG_DEBUG, "Answering MFC/R2 call on chan %d\n", p->channel);
-			openr2_chan_answer_call(p->r2chan);
+			res = dahdi_r2_answer(p);
 		}
 		break;
 #endif




More information about the asterisk-commits mailing list