[asterisk-commits] jpeeler: branch jpeeler/asterisk-sigwork-trunk r206559 - /team/jpeeler/asteri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 14 13:50:19 CDT 2009


Author: jpeeler
Date: Tue Jul 14 13:50:16 2009
New Revision: 206559

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206559
Log:
move setting the cadence into sig_analog so that cidrings can be set properly

Modified:
    team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
    team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
    team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h

Modified: team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c?view=diff&rev=206559&r1=206558&r2=206559
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c Tue Jul 14 13:50:16 2009
@@ -368,6 +368,37 @@
 #define CALLPROGRESS_FAX_OUTGOING	2
 #define CALLPROGRESS_FAX_INCOMING	4
 #define CALLPROGRESS_FAX		(CALLPROGRESS_FAX_INCOMING | CALLPROGRESS_FAX_OUTGOING)
+
+#define NUM_CADENCE_MAX 25
+static int num_cadence = 4;
+static int user_has_defined_cadences = 0;
+
+static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX] = {
+	{ { 125, 125, 2000, 4000 } },			/*!< Quick chirp followed by normal ring */
+	{ { 250, 250, 500, 1000, 250, 250, 500, 4000 } }, /*!< British style ring */
+	{ { 125, 125, 125, 125, 125, 4000 } },	/*!< Three short bursts */
+	{ { 1000, 500, 2500, 5000 } },	/*!< Long ring */
+};
+
+/*! \brief cidrings says in which pause to transmit the cid information, where the first pause
+ * is 1, the second pause is 2 and so on.
+ */
+
+static int cidrings[NUM_CADENCE_MAX] = {
+	2,										/*!< Right after first long ring */
+	4,										/*!< Right after long part */
+	3,										/*!< After third chirp */
+	2,										/*!< Second spell */
+};
+
+/* ETSI EN300 659-1 specifies the ring pulse between 200 and 300 mS */
+static struct dahdi_ring_cadence AS_RP_cadence = {{250, 10000}};
+
+#define ISTRUNK(p) ((p->sig == SIG_FXSLS) || (p->sig == SIG_FXSKS) || \
+			(p->sig == SIG_FXSGS) || (p->sig == SIG_PRI))
+
+#define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */)
+#define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */)
 
 static char defaultcic[64] = "";
 static char defaultozz[64] = "";
@@ -1164,7 +1195,6 @@
 	unsigned int mwisend_rpas:1;		/*! Variable for enabling Ring Pulse Alert before MWI FSK Spill */
 #endif
 	int distinctivering;				/*!< Which distinctivering to use */
-	int cidrings;					/*!< Which ring to deliver CID on */
 	int dtmfrelax;					/*!< whether to run in relaxed DTMF mode */
 	/*! \brief Holding place for event injected from outside normal operation. */
 	int fake_event;
@@ -1176,7 +1206,7 @@
 	/*! \brief Start delay time if polarityonanswerdelay is nonzero. */
 	struct timeval polaritydelaytv;
 	/*!
-	 * \brief Send caller ID after this many rings.
+	 * \brief Send caller ID on FXS after this many rings. Set to 1 for US.
 	 * \note Set from the "sendcalleridafter" value read in from chan_dahdi.conf
 	 */
 	int sendcalleridafter;
@@ -1987,6 +2017,22 @@
 	return p->subs[dahdi_sub].dfd;
 }
 
+static void my_set_cadence(void *pvt, int *cidrings, struct ast_channel *ast)
+{
+	struct dahdi_pvt *p = pvt;
+
+	/* Choose proper cadence */
+	if ((p->distinctivering > 0) && (p->distinctivering <= num_cadence)) {
+		if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCADENCE, &cadences[p->distinctivering - 1]))
+			ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s': %s\n", p->distinctivering, ast->name, strerror(errno));
+		*cidrings = cidrings[p->distinctivering - 1];
+	} else {
+		if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCADENCE, NULL))
+			ast_log(LOG_WARNING, "Unable to reset default ring on '%s': %s\n", ast->name, strerror(errno));
+		*cidrings = p->sendcalleridafter;
+	}
+}
+
 static void my_increase_ss_count(void)
 {
 	ast_mutex_lock(&ss_thread_lock);
@@ -2640,6 +2686,7 @@
 	.get_and_handle_alarms = my_get_and_handle_alarms,
 	.get_sigpvt_bridged_channel = my_get_sigpvt_bridged_channel,
 	.get_sub_fd = my_get_sub_fd,
+	.set_cadence = my_set_cadence,
 };
 
 static struct dahdi_pvt *round_robin[32];
@@ -2668,36 +2715,6 @@
 	return 0;
 }
 #endif	/* defined(HAVE_SS7) */
-#define NUM_CADENCE_MAX 25
-static int num_cadence = 4;
-static int user_has_defined_cadences = 0;
-
-static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX] = {
-	{ { 125, 125, 2000, 4000 } },			/*!< Quick chirp followed by normal ring */
-	{ { 250, 250, 500, 1000, 250, 250, 500, 4000 } }, /*!< British style ring */
-	{ { 125, 125, 125, 125, 125, 4000 } },	/*!< Three short bursts */
-	{ { 1000, 500, 2500, 5000 } },	/*!< Long ring */
-};
-
-/*! \brief cidrings says in which pause to transmit the cid information, where the first pause
- * is 1, the second pause is 2 and so on.
- */
-
-static int cidrings[NUM_CADENCE_MAX] = {
-	2,										/*!< Right after first long ring */
-	4,										/*!< Right after long part */
-	3,										/*!< After third chirp */
-	2,										/*!< Second spell */
-};
-
-/* ETSI EN300 659-1 specifies the ring pulse between 200 and 300 mS */
-static struct dahdi_ring_cadence AS_RP_cadence = {{250, 10000}};
-
-#define ISTRUNK(p) ((p->sig == SIG_FXSLS) || (p->sig == SIG_FXSKS) || \
-			(p->sig == SIG_FXSGS) || (p->sig == SIG_PRI))
-
-#define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */)
-#define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */)
 
 static int dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok)
 {
@@ -4283,29 +4300,6 @@
 	}
 #endif
 
-	/* Set the ring cadence */
-	mysig = p->sig;
-	if (p->outsigmod > -1)
-		mysig = p->outsigmod;
-	switch (mysig) {
-	case SIG_FXOLS:
-	case SIG_FXOGS:
-	case SIG_FXOKS:
-		if (p->owner == ast) {
-			/* Choose proper cadence */
-			if ((p->distinctivering > 0) && (p->distinctivering <= num_cadence)) {
-				if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCADENCE, &cadences[p->distinctivering - 1]))
-					ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s': %s\n", p->distinctivering, ast->name, strerror(errno));
-				p->cidrings = cidrings[p->distinctivering - 1];
-			} else {
-				if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCADENCE, NULL))
-					ast_log(LOG_WARNING, "Unable to reset default ring on '%s': %s\n", ast->name, strerror(errno));
-				p->cidrings = p->sendcalleridafter;
-			}
-		}
-		break;
-	}
-
 	/* If this is analog signalling we can exit here */
 	if (analog_lib_handles(p->sig, p->radio, p->oprmode)) {
 		p->callwaitrings = 0;
@@ -4314,6 +4308,7 @@
 		return res;
 	}
 
+	mysig = p->outsigmod > -1 ? p->outsigmod : p->sig;
 	switch (mysig) {
 	case 0:
 		/* Special pseudo -- automatically up*/
@@ -5049,7 +5044,6 @@
 		p->ringt = 0;
 		p->distinctivering = 0;
 		p->confirmanswer = 0;
-		p->cidrings = 1;
 		p->outgoing = 0;
 		p->digital = 0;
 		p->faxhandled = 0;
@@ -11008,7 +11002,6 @@
 				analog_p->polarityonanswerdelay = conf->chan.polarityonanswerdelay;
 				analog_p->answeronpolarityswitch = conf->chan.answeronpolarityswitch;
 				analog_p->hanguponpolarityswitch = conf->chan.hanguponpolarityswitch;
-				analog_p->sendcalleridafter = conf->chan.sendcalleridafter;
 				analog_p->permcallwaiting = 1;
 				analog_p->callreturn = conf->chan.callreturn;
 				analog_p->cancallforward = conf->chan.cancallforward;

Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c?view=diff&rev=206559&r1=206558&r2=206559
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c Tue Jul 14 13:50:16 2009
@@ -688,6 +688,13 @@
 		return 0;
 }
 
+static void analog_set_cadence(struct analog_pvt *p, struct ast_channel *chan)
+{
+	if (p->calls->set_cadence) {
+		return p->calls->set_cadence(p->chan_pvt, &p->cidrings, chan);
+	}
+}
+
 int analog_call(struct analog_pvt *p, struct ast_channel *ast, char *rdest, int timeout)
 {
 	int res, index,mysig;
@@ -724,20 +731,7 @@
 
 			/* Don't send audio while on hook, until the call is answered */
 			p->dialing = 1;
-			/* XXX */
-#if 0
-			/* Choose proper cadence */
-			if ((p->distinctivering > 0) && (p->distinctivering <= num_cadence)) {
-				if (ioctl(p->subs[ANALOG_SUB_REAL].dfd, DAHDI_SETCADENCE, &cadences[p->distinctivering - 1]))
-					ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s': %s\n", p->distinctivering, ast->name, strerror(errno));
-				p->cidrings = cidrings[p->distinctivering - 1];
-			} else {
-				if (ioctl(p->subs[ANALOG_SUB_REAL].dfd, DAHDI_SETCADENCE, NULL))
-					ast_log(LOG_WARNING, "Unable to reset default ring on '%s': %s\n", ast->name, strerror(errno));
-				p->cidrings = p->sendcalleridafter;
-			}
-#endif
-			p->cidrings = p->sendcalleridafter;
+			analog_set_cadence(p, ast); /* and set p->cidrings */
 
 			/* nick at dccinc.com 4/3/03 mods to allow for deferred dialing */
 			c = strchr(dest, '/');
@@ -1057,6 +1051,7 @@
 		p->ringt = 0;
 		p->outgoing = 0;
 		p->onhooktime = time(NULL);
+		p->cidrings = 1;
 
 		/* Perform low level hangup if no owner left */
 		res = analog_on_hook(p);
@@ -3156,7 +3151,6 @@
 	p->chan_pvt = private_data;
 
 	/* Some defaults for values */
-	p->sendcalleridafter = 1;
 	p->cid_start = ANALOG_CID_START_RING;
 	p->cid_signalling = CID_SIG_BELL;
 	/* Sub real is assumed to always be alloc'd */

Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h?view=diff&rev=206559&r1=206558&r2=206559
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h Tue Jul 14 13:50:16 2009
@@ -191,6 +191,7 @@
 	void (* const get_and_handle_alarms)(void *pvt);
 	void * (* const get_sigpvt_bridged_channel)(struct ast_channel *chan);
 	int (* const get_sub_fd)(void *pvt, enum analog_sub sub);
+	void (* const set_cadence)(void *pvt, int *cidrings, struct ast_channel *chan);
 };
 
 
@@ -254,8 +255,6 @@
 	int polarityonanswerdelay;
 	int stripmsd;
 	enum analog_cid_start cid_start;
-	/* Number of rings to wait to send callerid on FXS.  Set to 1 for US */
-	int sendcalleridafter;
 	int callwaitingcallerid;
 	char mohsuggest[MAX_MUSICCLASS];
 	char cid_num[AST_MAX_EXTENSION];




More information about the asterisk-commits mailing list