[asterisk-commits] jpeeler: trunk r222108 - /trunk/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 5 14:20:39 CDT 2009


Author: jpeeler
Date: Mon Oct  5 14:20:36 2009
New Revision: 222108

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=222108
Log:
Add a few missing events to analog_handle_event.

The reported bug was actually only for pulsedigit, dtmfup, and dtmfdown
handling. Also added recognition for fax events (just some verbose output) and
fixed handling for the ec_disabled_event. In order to make comparing the analog
version of events to the DAHDI events easier, the ordering has been changed to
follow that of the DAHDI events.

(closes issue #15924)
Reported by: tzafrir


Modified:
    trunk/channels/chan_dahdi.c
    trunk/channels/sig_analog.c
    trunk/channels/sig_analog.h

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=222108&r1=222107&r2=222108
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Mon Oct  5 14:20:36 2009
@@ -2118,6 +2118,18 @@
 	}
 }
 
+static int my_confmute(void *pvt, int mute)
+{
+	struct dahdi_pvt *p = pvt;
+	return dahdi_confmute(p, mute);
+}
+
+static void my_set_pulsedial(void *pvt, int flag)
+{
+	struct dahdi_pvt *p = pvt;
+	p->pulsedial = flag;
+}
+
 static void my_increase_ss_count(void)
 {
 	ast_mutex_lock(&ss_thread_lock);
@@ -2370,20 +2382,17 @@
 
 static enum analog_event dahdievent_to_analogevent(int event)
 {
-	enum analog_event res = ANALOG_EVENT_ERROR;
+	enum analog_event res;
 
 	switch (event) {
-	case DAHDI_EVENT_DIALCOMPLETE:
-		res = ANALOG_EVENT_DIALCOMPLETE;
-		break;
-	case DAHDI_EVENT_WINKFLASH:
-		res = ANALOG_EVENT_WINKFLASH;
-		break;
 	case DAHDI_EVENT_ONHOOK:
 		res = ANALOG_EVENT_ONHOOK;
 		break;
 	case DAHDI_EVENT_RINGOFFHOOK:
 		res = ANALOG_EVENT_RINGOFFHOOK;
+		break;
+	case DAHDI_EVENT_WINKFLASH:
+		res = ANALOG_EVENT_WINKFLASH;
 		break;
 	case DAHDI_EVENT_ALARM:
 		res = ANALOG_EVENT_ALARM;
@@ -2391,11 +2400,8 @@
 	case DAHDI_EVENT_NOALARM:
 		res = ANALOG_EVENT_NOALARM;
 		break;
-	case DAHDI_EVENT_HOOKCOMPLETE:
-		res = ANALOG_EVENT_HOOKCOMPLETE;
-		break;
-	case DAHDI_EVENT_POLARITY:
-		res = ANALOG_EVENT_POLARITY;
+	case DAHDI_EVENT_DIALCOMPLETE:
+		res = ANALOG_EVENT_DIALCOMPLETE;
 		break;
 	case DAHDI_EVENT_RINGERON:
 		res = ANALOG_EVENT_RINGERON;
@@ -2403,20 +2409,55 @@
 	case DAHDI_EVENT_RINGEROFF:
 		res = ANALOG_EVENT_RINGEROFF;
 		break;
+	case DAHDI_EVENT_HOOKCOMPLETE:
+		res = ANALOG_EVENT_HOOKCOMPLETE;
+		break;
+	case DAHDI_EVENT_PULSE_START:
+		res = ANALOG_EVENT_PULSE_START;
+		break;
+	case DAHDI_EVENT_POLARITY:
+		res = ANALOG_EVENT_POLARITY;
+		break;
 	case DAHDI_EVENT_RINGBEGIN:
 		res = ANALOG_EVENT_RINGBEGIN;
 		break;
-	case DAHDI_EVENT_PULSE_START:
-		res = ANALOG_EVENT_PULSE_START;
-	break;
+	case DAHDI_EVENT_EC_DISABLED:
+		res = ANALOG_EVENT_EC_DISABLED;
+		break;
 	case DAHDI_EVENT_REMOVED:
 		res = ANALOG_EVENT_REMOVED;
-	break;
+		break;
 	case DAHDI_EVENT_NEONMWI_ACTIVE:
 		res = ANALOG_EVENT_NEONMWI_ACTIVE;
 		break;
 	case DAHDI_EVENT_NEONMWI_INACTIVE:
 		res = ANALOG_EVENT_NEONMWI_INACTIVE;
+		break;
+#ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE
+	case DAHDI_EVENT_TX_CED_DETECTED:
+		res = ANALOG_EVENT_TX_CED_DETECTED;
+		break;
+	case DAHDI_EVENT_RX_CED_DETECTED:
+		res = ANALOG_EVENT_RX_CED_DETECTED;
+		break;
+	case DAHDI_EVENT_EC_NLP_DISABLED:
+		res = ANALOG_EVENT_EC_NLP_DISABLED;
+		break;
+	case DAHDI_EVENT_EC_NLP_ENABLED:
+		res = ANALOG_EVENT_EC_NLP_ENABLED;
+		break;
+#endif
+	case DAHDI_EVENT_PULSEDIGIT:
+		res = ANALOG_EVENT_PULSEDIGIT;
+		break;
+	case DAHDI_EVENT_DTMFDOWN:
+		res = ANALOG_EVENT_DTMFDOWN;
+		break;
+	case DAHDI_EVENT_DTMFUP:
+		res = ANALOG_EVENT_DTMFUP;
+		break;
+	default:
+		res = ANALOG_EVENT_ERROR;
 		break;
 	}
 
@@ -2846,6 +2887,8 @@
 	.set_confirmanswer = my_set_confirmanswer,
 	.check_confirmanswer = my_check_confirmanswer,
 	.cancel_cidspill = my_cancel_cidspill,
+	.confmute = my_confmute,
+	.set_pulsedial = my_set_pulsedial,
 };
 
 static struct dahdi_pvt *round_robin[32];

Modified: trunk/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_analog.c?view=diff&rev=222108&r1=222107&r2=222108
==============================================================================
--- trunk/channels/sig_analog.c (original)
+++ trunk/channels/sig_analog.c Mon Oct  5 14:20:36 2009
@@ -220,42 +220,45 @@
 {
 	char *res;
 	switch (event) {
+	case ANALOG_EVENT_ONHOOK:
+		res = "ANALOG_EVENT_ONHOOK";
+		break;
+	case ANALOG_EVENT_RINGOFFHOOK:
+		res = "ANALOG_EVENT_RINGOFFHOOK";
+		break;
+	case ANALOG_EVENT_WINKFLASH:
+		res = "ANALOG_EVENT_WINKFLASH";
+		break;
+	case ANALOG_EVENT_ALARM:
+		res = "ANALOG_EVENT_ALARM";
+		break;
+	case ANALOG_EVENT_NOALARM:
+		res = "ANALOG_EVENT_NOALARM";
+		break;
 	case ANALOG_EVENT_DIALCOMPLETE:
 		res = "ANALOG_EVENT_DIALCOMPLETE";
 		break;
-	case ANALOG_EVENT_WINKFLASH:
-		res = "ANALOG_EVENT_WINKFLASH";
-		break;
-	case ANALOG_EVENT_ONHOOK:
-		res = "ANALOG_EVENT_ONHOOK";
-		break;
-	case ANALOG_EVENT_RINGOFFHOOK:
-		res = "ANALOG_EVENT_RINGOFFHOOK";
-		break;
-	case ANALOG_EVENT_ALARM:
-		res = "ANALOG_EVENT_ALARM";
-		break;
-	case ANALOG_EVENT_NOALARM:
-		res = "ANALOG_EVENT_NOALARM";
-		break;
 	case ANALOG_EVENT_HOOKCOMPLETE:
 		res = "ANALOG_EVENT_HOOKCOMPLETE";
 		break;
+	case ANALOG_EVENT_PULSE_START:
+		res = "ANALOG_EVENT_PULSE_START";
+		break;
 	case ANALOG_EVENT_POLARITY:
 		res = "ANALOG_EVENT_POLARITY";
 		break;
+	case ANALOG_EVENT_RINGBEGIN:
+		res = "ANALOG_EVENT_RINGBEGIN";
+		break;
+	case ANALOG_EVENT_EC_DISABLED:
+		res = "ANALOG_EVENT_EC_DISABLED";
+		break;
 	case ANALOG_EVENT_RINGERON:
 		res = "ANALOG_EVENT_RINGERON";
 		break;
 	case ANALOG_EVENT_RINGEROFF:
 		res = "ANALOG_EVENT_RINGEROFF";
 		break;
-	case ANALOG_EVENT_RINGBEGIN:
-		res = "ANALOG_EVENT_RINGBEGIN";
-		break;
-	case ANALOG_EVENT_PULSE_START:
-		res = "ANALOG_EVENT_PULSE_START";
-		break;
 	case ANALOG_EVENT_REMOVED:
 		res = "ANALOG_EVENT_REMOVED";
 		break;
@@ -264,6 +267,29 @@
 		break;
 	case ANALOG_EVENT_NEONMWI_INACTIVE:
 		res = "ANALOG_EVENT_NEONMWI_INACTIVE";
+		break;
+#ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE
+	case ANALOG_EVENT_TX_CED_DETECTED:
+		res = "ANALOG_EVENT_TX_CED_DETECTED";
+		break;
+	case ANALOG_EVENT_RX_CED_DETECTED:
+		res = "ANALOG_EVENT_RX_CED_DETECTED";
+		break;
+	case ANALOG_EVENT_EC_NLP_DISABLED:
+		res = "ANALOG_EVENT_EC_NLP_DISABLED";
+		break;
+	case ANALOG_EVENT_EC_NLP_ENABLED:
+		res = "ANALOG_EVENT_EC_NLP_ENABLED";
+		break;
+#endif
+	case ANALOG_EVENT_PULSEDIGIT:
+		res = "ANALOG_EVENT_PULSEDIGIT";
+		break;
+	case ANALOG_EVENT_DTMFDOWN:
+		res = "ANALOG_EVENT_DTMFDOWN";
+		break;
+	case ANALOG_EVENT_DTMFUP:
+		res = "ANALOG_EVENT_DTMFUP";
 		break;
 	default:
 		res = "UNKNOWN/OTHER";
@@ -781,6 +807,22 @@
 	}
 
 	p->calls->cancel_cidspill(p->chan_pvt);
+}
+
+static int analog_confmute(struct analog_pvt *p, int mute)
+{
+	if (p->calls->confmute) {
+		return p->calls->confmute(p->chan_pvt, mute);
+	}
+	return 0;
+}
+
+static void analog_set_pulsedial(struct analog_pvt *p, int flag)
+{
+	if (!p->calls->set_pulsedial) {
+		return;
+	}
+	p->calls->set_pulsedial(p->chan_pvt, flag);
 }
 
 static int analog_set_linear_mode(struct analog_pvt *p, int index, int linear_mode)
@@ -1167,6 +1209,7 @@
 		p->owner = NULL;
 		analog_set_ringtimeout(p, 0);
 		analog_set_confirmanswer(p, 0);
+		analog_set_pulsedial(p, 0);
 		p->outgoing = 0;
 		p->onhooktime = time(NULL);
 		p->cidrings = 1;
@@ -2332,11 +2375,42 @@
 
 	ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", analog_event2str(res), res, p->channel, index);
 
+	if (res & (ANALOG_EVENT_PULSEDIGIT | ANALOG_EVENT_DTMFUP)) {
+		analog_set_pulsedial(p, (res & ANALOG_EVENT_PULSEDIGIT));
+		ast_debug(1, "Detected %sdigit '%c'\n", (res & ANALOG_EVENT_PULSEDIGIT) ? "pulse ": "", res & 0xff);
+		analog_confmute(p, 0);
+		p->subs[index].f.frametype = AST_FRAME_DTMF_END;
+		p->subs[index].f.subclass = res & 0xff;
+		analog_handle_dtmfup(p, ast, index, &f);
+		return f;
+	}
+
+	if (res & ANALOG_EVENT_DTMFDOWN) {
+		ast_debug(1, "DTMF Down '%c'\n", res & 0xff);
+		/* Mute conference */
+		analog_confmute(p, 1);
+		p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
+		p->subs[index].f.subclass = res & 0xff;
+		return f;
+	}
+
 	switch (res) {
-#ifdef ANALOG_EVENT_EC_DISABLED
 	case ANALOG_EVENT_EC_DISABLED:
 		ast_verb(3, "Channel %d echo canceler disabled due to CED detection\n", p->channel);
-		p->echocanon = 0;
+		analog_set_echocanceller(p, 0);
+		break;
+#ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE
+	case ANALOG_EVENT_TX_CED_DETECTED:
+		ast_verb(3, "Channel %d detected a CED tone towards the network.\n", p->channel);
+		break;
+	case ANALOG_EVENT_RX_CED_DETECTED:
+		ast_verb(3, "Channel %d detected a CED tone from the network.\n", p->channel);
+		break;
+	case ANALOG_EVENT_EC_NLP_DISABLED:
+		ast_verb(3, "Channel %d echo canceler disabled its NLP.\n", p->channel);
+		break;
+	case ANALOG_EVENT_EC_NLP_ENABLED:
+		ast_verb(3, "Channel %d echo canceler enabled its NLP.\n", p->channel);
 		break;
 #endif
 	case ANALOG_EVENT_PULSE_START:

Modified: trunk/channels/sig_analog.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_analog.h?view=diff&rev=222108&r1=222107&r2=222108
==============================================================================
--- trunk/channels/sig_analog.h (original)
+++ trunk/channels/sig_analog.h Mon Oct  5 14:20:36 2009
@@ -65,23 +65,31 @@
 
 enum analog_event {
 	ANALOG_EVENT_NONE = 0,
-	ANALOG_EVENT_DIALCOMPLETE,
-	ANALOG_EVENT_WINKFLASH,
 	ANALOG_EVENT_ONHOOK,
 	ANALOG_EVENT_RINGOFFHOOK,
+	ANALOG_EVENT_WINKFLASH,
 	ANALOG_EVENT_ALARM,
 	ANALOG_EVENT_NOALARM,
-	ANALOG_EVENT_HOOKCOMPLETE,
-	ANALOG_EVENT_POLARITY,
+	ANALOG_EVENT_DIALCOMPLETE,
 	ANALOG_EVENT_RINGERON,
 	ANALOG_EVENT_RINGEROFF,
+	ANALOG_EVENT_HOOKCOMPLETE,
+	ANALOG_EVENT_PULSE_START,
+	ANALOG_EVENT_POLARITY,
 	ANALOG_EVENT_RINGBEGIN,
-	ANALOG_EVENT_PULSE_START,
-	ANALOG_EVENT_ERROR,
+	ANALOG_EVENT_EC_DISABLED,
 	ANALOG_EVENT_REMOVED,
 	ANALOG_EVENT_NEONMWI_ACTIVE,
 	ANALOG_EVENT_NEONMWI_INACTIVE,
-	ANALOG_EVENT_DTMFCID,
+	ANALOG_EVENT_TX_CED_DETECTED,
+	ANALOG_EVENT_RX_CED_DETECTED,
+	ANALOG_EVENT_EC_NLP_DISABLED,
+	ANALOG_EVENT_EC_NLP_ENABLED,
+	ANALOG_EVENT_ERROR, /* not a DAHDI event */
+	ANALOG_EVENT_DTMFCID, /* not a DAHDI event */
+	ANALOG_EVENT_PULSEDIGIT = (1 << 16), 
+	ANALOG_EVENT_DTMFDOWN = (1 << 17),
+	ANALOG_EVENT_DTMFUP = (1 << 18),
 };
 
 enum analog_sub {
@@ -203,6 +211,8 @@
 	void (* const set_confirmanswer)(void *pvt, int flag);
 	int (* const check_confirmanswer)(void *pvt);
 	void (* const cancel_cidspill)(void *pvt);
+	int (* const confmute)(void *pvt, int mute);	
+	void (* const set_pulsedial)(void *pvt, int flag);
 };
 
 
@@ -279,7 +289,6 @@
 	unsigned int echobreak:1;
 	unsigned int hidecallerid:1;
 	unsigned int outgoing:1;
-	unsigned int pulsedial:1;		/*!< TRUE if a pulsed digit was detected. (Pulse dial phone detected) */
 
 	char callwait_num[AST_MAX_EXTENSION];
 	char callwait_name[AST_MAX_EXTENSION];




More information about the asterisk-commits mailing list