[asterisk-commits] jpeeler: branch jpeeler/asterisk-sigwork-trunk r204891 - /team/jpeeler/asteri...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 2 18:10:47 CDT 2009
Author: jpeeler
Date: Thu Jul 2 18:10:43 2009
New Revision: 204891
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=204891
Log:
checkpoint stopping for now, but i think distinctive ring works as before now
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=204891&r1=204890&r2=204891
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/chan_dahdi.c Thu Jul 2 18:10:43 2009
@@ -1557,6 +1557,7 @@
static int my_get_callerid(void *pvt, char *namebuf, char *numbuf, enum analog_event *ev, size_t timeout)
{
struct dahdi_pvt *p = pvt;
+ struct analog_pvt *analog_p = p->sig_pvt;
struct pollfd poller;
char *name, *num;
int index = SUB_REAL;
@@ -1590,6 +1591,12 @@
}
}
+ if (analog_p->ringt)
+ analog_p->ringt--;
+ if (analog_p->ringt == 1) {
+ return -1;
+ }
+
if (p->cid_signalling == CID_SIG_V23_JP) {
res = callerid_feed_jp(p->cs, buf, res, AST_LAW(p));
} else {
@@ -1620,7 +1627,7 @@
static const char *event2str(int event);
static int restore_gains(struct dahdi_pvt *p);
-static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int checkaftercid)
+static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int checkaftercid, int *ringdata)
{
unsigned char buf[256];
int distMatches;
@@ -1632,13 +1639,17 @@
int res;
struct dahdi_pvt *p = pvt;
+ struct analog_pvt *analog_p = p->sig_pvt;
+
+ if (ringdata == NULL)
+ ringdata = curRingData;
/* We must have a ring by now, so, if configured, lets try to listen for
* distinctive ringing */
if ((checkaftercid && distinctiveringaftercid) || !checkaftercid) {
/* Clear the current ring data array so we dont have old data in it. */
- for (receivedRingT = 0; receivedRingT < ARRAY_LEN(curRingData); receivedRingT++)
- curRingData[receivedRingT] = 0;
+ for (receivedRingT = 0; receivedRingT < ARRAY_LEN(ringdata); receivedRingT++)
+ ringdata[receivedRingT] = 0;
receivedRingT = 0;
if (checkaftercid && distinctiveringaftercid)
ast_verb(3, "Detecting post-CID distinctive ring\n");
@@ -1661,13 +1672,13 @@
res = 0;
/* Let us detect distinctive ring */
- curRingData[receivedRingT] = p->ringt;
-
- if (p->ringt < p->ringt_base/2)
+ ringdata[receivedRingT] = analog_p->ringt;
+
+ if (analog_p->ringt < analog_p->ringt_base/2)
break;
/* Increment the ringT counter so we can match it against
values in chan_dahdi.conf for distinctive ring */
- if (++receivedRingT == ARRAY_LEN(curRingData))
+ if (++receivedRingT == ARRAY_LEN(ringdata))
break;
} else if (i & DAHDI_IOMUX_READ) {
res = read(p->subs[idx].dfd, buf, sizeof(buf));
@@ -1679,9 +1690,9 @@
}
break;
}
- if (p->ringt)
- p->ringt--;
- if (p->ringt == 1) {
+ if (analog_p->ringt)
+ analog_p->ringt--;
+ if (analog_p->ringt == 1) {
res = -1;
break;
}
@@ -1690,7 +1701,7 @@
}
if ((checkaftercid && usedistinctiveringdetection) || !checkaftercid) {
/* this only shows up if you have n of the dring patterns filled in */
- ast_verb(3, "Detected ring pattern: %d,%d,%d\n",curRingData[0],curRingData[1],curRingData[2]);
+ ast_verb(3, "Detected ring pattern: %d,%d,%d\n",ringdata[0],ringdata[1],ringdata[2]);
for (counter = 0; counter < 3; counter++) {
/* Check to see if the rings we received match any of the ones in chan_dahdi.conf for this channel */
distMatches = 0;
@@ -1703,10 +1714,10 @@
ast_verb(3, "Ring pattern check range: %d\n", p->drings.ringnum[counter].range);
if (p->drings.ringnum[counter].ring[counter1] == -1) {
ast_verb(3, "Pattern ignore (-1) detected, so matching pattern %d regardless.\n",
- curRingData[counter1]);
+ ringdata[counter1]);
distMatches++;
- } else if (curRingData[counter1] <= (p->drings.ringnum[counter].ring[counter1] + p->drings.ringnum[counter].range) &&
- curRingData[counter1] >= (p->drings.ringnum[counter].ring[counter1] - p->drings.ringnum[counter].range)) {
+ } else if (ringdata[counter1] <= (p->drings.ringnum[counter].ring[counter1] + p->drings.ringnum[counter].range) &&
+ ringdata[counter1] >= (p->drings.ringnum[counter].ring[counter1] - p->drings.ringnum[counter].range)) {
ast_verb(3, "Ring pattern matched in range: %d to %d\n",
(p->drings.ringnum[counter].ring[counter1] - p->drings.ringnum[counter].range),
(p->drings.ringnum[counter].ring[counter1] + p->drings.ringnum[counter].range));
@@ -10975,6 +10986,8 @@
analog_p->cid_start = ANALOG_CID_START_RING;
tmp->callwaitingcallerid = analog_p->callwaitingcallerid = 1;
analog_p->usedistinctiveringdetection = conf->chan.usedistinctiveringdetection;
+ analog_p->ringt = conf->chan.ringt;
+ analog_p->ringt_base = conf->chan.ringt_base;
ast_copy_string(analog_p->mohsuggest, conf->chan.mohsuggest, sizeof(analog_p->mohsuggest));
ast_copy_string(analog_p->cid_num, conf->chan.cid_num, sizeof(analog_p->cid_num));
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=204891&r1=204890&r2=204891
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c Thu Jul 2 18:10:43 2009
@@ -1037,9 +1037,7 @@
if (!p->subs[ANALOG_SUB_REAL].owner && !p->subs[ANALOG_SUB_CALLWAIT].owner && !p->subs[ANALOG_SUB_THREEWAY].owner) {
p->owner = NULL;
-#if 0
p->ringt = 0;
-#endif
#if 0 /* Since we set it in _call */
p->cidrings = 1;
#endif
@@ -1110,9 +1108,7 @@
case ANALOG_SIG_FXSLS:
case ANALOG_SIG_FXSGS:
case ANALOG_SIG_FXSKS:
-#if 0
p->ringt = 0;
-#endif
/* Fall through */
case ANALOG_SIG_EM:
case ANALOG_SIG_EM_E1:
@@ -1254,10 +1250,10 @@
return -1;
}
-static int analog_distinctive_ring(struct ast_channel *chan, struct analog_pvt *p, int idx, int checkaftercid)
+static int analog_distinctive_ring(struct ast_channel *chan, struct analog_pvt *p, int idx, int checkaftercid, int *ringdata)
{
if (p->calls->distinctive_ring) {
- return p->calls->distinctive_ring(chan, p->chan_pvt, idx, checkaftercid);
+ return p->calls->distinctive_ring(chan, p->chan_pvt, idx, checkaftercid, ringdata);
} else
return -1;
@@ -1965,7 +1961,7 @@
break; /* Got ring */
}
- if (analog_distinctive_ring(chan, p, index, 1))
+ if (analog_distinctive_ring(chan, p, index, 0, NULL))
goto quit;
if (res < 0) {
@@ -1987,6 +1983,8 @@
int timeout = 10000; /* Ten seconds */
struct timeval start = ast_tvnow();
enum analog_event ev;
+ int curRingData[3] = { 0 };
+ int receivedRingT = 0;
namebuf[0] = 0;
numbuf[0] = 0;
@@ -2008,6 +2006,15 @@
} else if (ev != ANALOG_EVENT_NONE) {
break;
}
+ /* Let us detect callerid when the telco uses distinctive ring */
+ curRingData[receivedRingT] = p->ringt;
+
+ if (p->ringt < p->ringt_base/2)
+ break;
+ /* Increment the ringT counter so we can match it against
+ values in chan_dahdi.conf for distinctive ring */
+ if (++receivedRingT == ARRAY_LEN(curRingData))
+ break;
}
if (ast_tvdiff_ms(ast_tvnow(), start) > timeout)
@@ -2019,7 +2026,7 @@
analog_stop_cid_detect(p);
- if (analog_distinctive_ring(chan, p, index, 1))
+ if (analog_distinctive_ring(chan, p, index, 1, curRingData))
goto quit;
if (res < 0) {
@@ -2355,11 +2362,9 @@
case ANALOG_SIG_FXSLS:
case ANALOG_SIG_FXSGS:
case ANALOG_SIG_FXSKS:
-#if 0
if (ast->_state == AST_STATE_RING) {
p->ringt = p->ringt_base;
}
-#endif
/* Fall through */
case ANALOG_SIG_EM:
@@ -2401,11 +2406,9 @@
case ANALOG_SIG_FXSLS:
case ANALOG_SIG_FXSGS:
case ANALOG_SIG_FXSKS:
-#if 0
if (ast->_state == AST_STATE_RING) {
p->ringt = p->ringt_base;
}
-#endif
break;
}
break;
@@ -2954,9 +2957,7 @@
case ANALOG_SIG_FXSLS:
case ANALOG_SIG_FXSGS:
case ANALOG_SIG_FXSKS:
-#if 0
i->ringt = i->ringt_base;
-#endif
/* Fall through */
case ANALOG_SIG_EMWINK:
case ANALOG_SIG_FEATD:
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=204891&r1=204890&r2=204891
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.h Thu Jul 2 18:10:43 2009
@@ -186,7 +186,7 @@
void (* const increase_ss_count)(void);
void (* const decrease_ss_count)(void);
- int (* const distinctive_ring)(struct ast_channel *chan, void *pvt, int idx, int checkaftercid);
+ int (* const distinctive_ring)(struct ast_channel *chan, void *pvt, int idx, int checkaftercid, int *ringdata);
};
More information about the asterisk-commits
mailing list