[asterisk-commits] irroot: branch irroot/distrotech-customers-trunk r327403 - in /team/irroot/di...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jul 10 07:26:48 CDT 2011
Author: irroot
Date: Sun Jul 10 07:26:42 2011
New Revision: 327403
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=327403
Log:
Merged revisions 327359 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r327359 | may | 2011-07-10 03:37:58 +0200 (Sun, 10 Jul 2011) | 18 lines
Full T.38 handshaking and fax detection
Add full t.38 handshaking for OOH323 that are required for newest T.38
gateway codes.
Add fax detection (cng tone, t38) and dialplan redirection to fax ext on
fax event detected.
Add OOH323() function to set/get t38support and faxdetect parameters.
(closes issue ASTERISK-17754)
Reported by: irroot
Patches:
ooh323_faxdetect.patch uploaded by irroot (license 52)
issue19183-final.patch uploaded by may213 (license 454)
Tested by: may213, irroot
Review: https://reviewboard.asterisk.org/r/1174/
........
Modified:
team/irroot/distrotech-customers-trunk/ (props changed)
team/irroot/distrotech-customers-trunk/addons/chan_ooh323.c
team/irroot/distrotech-customers-trunk/configs/chan_ooh323.conf.sample
Propchange: team/irroot/distrotech-customers-trunk/
------------------------------------------------------------------------------
automerge = *
Propchange: team/irroot/distrotech-customers-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Jul 10 07:26:42 2011
@@ -1,1 +1,1 @@
-/trunk:1-327309
+/trunk:1-327402
Modified: team/irroot/distrotech-customers-trunk/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/addons/chan_ooh323.c?view=diff&rev=327403&r1=327402&r2=327403
==============================================================================
--- team/irroot/distrotech-customers-trunk/addons/chan_ooh323.c (original)
+++ team/irroot/distrotech-customers-trunk/addons/chan_ooh323.c Sun Jul 10 07:26:42 2011
@@ -84,6 +84,9 @@
#define T38_DISABLED 0
#define T38_ENABLED 1
#define T38_FAXGW 1
+
+#define FAXDETECT_CNG 1
+#define FAXDETECT_T38 2
/* Channel description */
static const char type[] = "OOH323";
@@ -335,7 +338,7 @@
static struct ast_codec_pref gPrefs;
static int gDTMFMode = H323_DTMF_RFC2833;
static int gDTMFCodec = 101;
-static int gFAXdetect = 1;
+static int gFAXdetect = FAXDETECT_CNG;
static int gT38Support = T38_FAXGW;
static char gGatekeeper[100];
static enum RasGatekeeperMode gRasGkMode = RasNoGatekeeper;
@@ -431,7 +434,7 @@
ast_module_ref(myself);
/* Allocate dsp for in-band DTMF support */
- if ((i->dtmfmode & H323_DTMF_INBAND) || i->faxdetect) {
+ if ((i->dtmfmode & H323_DTMF_INBAND) || (i->faxdetect & FAXDETECT_CNG)) {
i->vad = ast_dsp_new();
}
@@ -444,7 +447,7 @@
}
/* fax detection*/
- if (i->faxdetect) {
+ if (i->faxdetect & FAXDETECT_CNG) {
features |= DSP_FEATURE_FAX_DETECT;
ast_dsp_set_faxmode(i->vad,
DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED);
@@ -2356,9 +2359,23 @@
user->dtmfcodec = atoi(v->value);
} else if (!strcasecmp(v->name, "faxdetect")) {
if (ast_true(v->value)) {
- user->faxdetect = 1;
+ user->faxdetect = FAXDETECT_CNG | FAXDETECT_T38;
+ } else if (ast_false(v->value)) {
+ user->faxdetect = 0;
} else {
+ char *buf = ast_strdupa(v->value);
+ char *word, *next = buf;
user->faxdetect = 0;
+ while ((word = strsep(&next, ","))) {
+ if (!strcasecmp(word, "cng")) {
+ user->faxdetect |= FAXDETECT_CNG;
+ } else if (!strcasecmp(word, "t38")) {
+ user->faxdetect |= FAXDETECT_T38;
+ } else {
+ ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
+ }
+ }
+
}
} else if (!strcasecmp(v->name, "t38support")) {
if (!strcasecmp(v->value, "disabled"))
@@ -2510,9 +2527,23 @@
peer->dtmfcodec = atoi(v->value);
} else if (!strcasecmp(v->name, "faxdetect")) {
if (ast_true(v->value)) {
- peer->faxdetect = 1;
+ peer->faxdetect = FAXDETECT_CNG | FAXDETECT_T38;
+ } else if (ast_false(v->value)) {
+ peer->faxdetect = 0;
} else {
+ char *buf = ast_strdupa(v->value);
+ char *word, *next = buf;
peer->faxdetect = 0;
+ while ((word = strsep(&next, ","))) {
+ if (!strcasecmp(word, "cng")) {
+ peer->faxdetect |= FAXDETECT_CNG;
+ } else if (!strcasecmp(word, "t38")) {
+ peer->faxdetect |= FAXDETECT_T38;
+ } else {
+ ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
+ }
+ }
+
}
} else if (!strcasecmp(v->name, "t38support")) {
if (!strcasecmp(v->value, "disabled"))
@@ -2636,7 +2667,7 @@
memset(&gPrefs, 0, sizeof(struct ast_codec_pref));
gDTMFMode = H323_DTMF_RFC2833;
gDTMFCodec = 101;
- gFAXdetect = 1;
+ gFAXdetect = FAXDETECT_CNG;
gT38Support = T38_FAXGW;
gTRCLVL = OOTRCLVLERR;
gRasGkMode = RasNoGatekeeper;
@@ -2842,9 +2873,23 @@
gDTMFCodec = atoi(v->value);
} else if (!strcasecmp(v->name, "faxdetect")) {
if (ast_true(v->value)) {
- gFAXdetect = 1;
+ gFAXdetect = FAXDETECT_CNG | FAXDETECT_T38;
+ } else if (ast_false(v->value)) {
+ gFAXdetect = 0;
} else {
+ char *buf = ast_strdupa(v->value);
+ char *word, *next = buf;
gFAXdetect = 0;
+ while ((word = strsep(&next, ","))) {
+ if (!strcasecmp(word, "cng")) {
+ gFAXdetect |= FAXDETECT_CNG;
+ } else if (!strcasecmp(word, "t38")) {
+ gFAXdetect |= FAXDETECT_T38;
+ } else {
+ ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
+ }
+ }
+
}
} else if (!strcasecmp(v->name, "t38support")) {
if (!strcasecmp(v->value, "disabled"))
@@ -2980,7 +3025,16 @@
} else if (peer->t38support == T38_FAXGW) {
ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible");
}
- ast_cli(a->fd,"%-15s%s\n", "FAX Detect:", (peer->faxdetect) ? "Yes" : "No");
+ if (peer->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes");
+ } else if (peer->faxdetect & FAXDETECT_CNG) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Cng");
+ } else if (peer->faxdetect & FAXDETECT_T38) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "T.38");
+ } else {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No");
+ }
+
ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", peer->accountcode);
ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_cdr_flags2str(peer->amaflags));
ast_cli(a->fd, "%-15.15s%s\n", "IP:Port: ", ip_port);
@@ -3127,7 +3181,16 @@
} else if (user->t38support == T38_FAXGW) {
ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible");
}
- ast_cli(a->fd,"%-15s%s\n", "FAX Detect:", (user->faxdetect) ? "Yes" : "No");
+ if (user->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes");
+ } else if (user->faxdetect & FAXDETECT_CNG) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Cng");
+ } else if (user->faxdetect & FAXDETECT_T38) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "T.38");
+ } else {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No");
+ }
+
ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", user->accountcode);
ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_cdr_flags2str(user->amaflags));
ast_cli(a->fd, "%-15.15s%s\n", "Context: ", user->context);
@@ -3300,7 +3363,15 @@
} else if (gT38Support == T38_FAXGW) {
ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible");
}
- ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", (gFAXdetect) ? "Yes" : "No");
+ if (gFAXdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes");
+ } else if (gFAXdetect & FAXDETECT_CNG) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Cng");
+ } else if (gFAXdetect & FAXDETECT_T38) {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "T.38");
+ } else {
+ ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No");
+ }
if (gRTDRCount && gRTDRInterval) {
ast_cli(a->fd, "%-20.15s%d,%d\n", "RoundTrip: ", gRTDRCount, gRTDRInterval);
@@ -3342,11 +3413,19 @@
{
struct ooh323_pvt *p = chan->tech_pvt;
+ ast_channel_lock(chan);
+ if (!p) {
+ ast_channel_unlock(chan);
+ return -1;
+ }
+
if (strcmp(chan->tech->type, "OOH323")) {
- ast_log(LOG_ERROR, "This function is only supported on OOH323 channels Channel is %s\n", chan->tech->type);
+ ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", chan->tech->type);
+ ast_channel_unlock(chan);
return -1;
}
+ ast_mutex_lock(&p->lock);
if (!strcasecmp(data, "faxdetect")) {
ast_copy_string(buf, p->faxdetect ? "1" : "0", len);
} else if (!strcasecmp(data, "t38support")) {
@@ -3368,6 +3447,9 @@
} else if (!strcasecmp(data, "callee_url")) {
ast_copy_string(buf, p->callee_url, len);
}
+ ast_mutex_unlock(&p->lock);
+
+ ast_channel_unlock(chan);
return 0;
}
@@ -3375,11 +3457,18 @@
static int function_ooh323_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
{
struct ooh323_pvt *p = chan->tech_pvt;
-
int res = -1;
+
+ ast_channel_lock(chan);
+ if (!p) {
+ ast_channel_unlock(chan);
+ return -1;
+ }
+
if (strcmp(chan->tech->type, "OOH323")) {
- ast_log(LOG_ERROR, "This function is only supported on OOH323 channels Channel is %s\n", chan->tech->type);
- return res;
+ ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", chan->tech->type);
+ ast_channel_unlock(chan);
+ return -1;
}
ast_mutex_lock(&p->lock);
@@ -3387,9 +3476,25 @@
if (ast_true(value)) {
p->faxdetect = 1;
res = 0;
- } else {
+ } else if (ast_false(value)) {
p->faxdetect = 0;
res = 0;
+ } else {
+ char *buf = ast_strdupa(value);
+ char *word, *next = buf;
+ p->faxdetect = 0;
+ res = 0;
+ while ((word = strsep(&next, ","))) {
+ if (!strcasecmp(word, "cng")) {
+ p->faxdetect |= FAXDETECT_CNG;
+ } else if (!strcasecmp(word, "t38")) {
+ p->faxdetect |= FAXDETECT_T38;
+ } else {
+ ast_log(LOG_WARNING, "Unknown faxdetect mode '%s'.\n", word);
+ res = -1;
+ }
+ }
+
}
} else if (!strcasecmp(data, "t38support")) {
if (ast_true(value)) {
@@ -3401,6 +3506,7 @@
}
}
ast_mutex_unlock(&p->lock);
+ ast_channel_unlock(chan);
return res;
}
@@ -4517,7 +4623,7 @@
ast_set_read_format(p->owner, &p->owner->readformat);
ast_set_write_format(p->owner, &p->owner->writeformat);
}
- if (((p->dtmfmode & H323_DTMF_INBAND) || p->faxdetect) && p->vad &&
+ if (((p->dtmfmode & H323_DTMF_INBAND) || (p->faxdetect & FAXDETECT_CNG)) && p->vad &&
(f->subclass.format.id == AST_FORMAT_SLINEAR || f->subclass.format.id == AST_FORMAT_ALAW ||
f->subclass.format.id == AST_FORMAT_ULAW)) {
dfr = ast_frdup(f);
@@ -4535,12 +4641,8 @@
if (gH323Debug)
ast_verbose("request to change %s to t.38 because fax ced\n", p->callToken);
p->chmodepend = 1;
+ p->faxdetected = 1;
ooRequestChangeMode(p->callToken, 1);
- p->faxdetect = 0;
- if (!(p->dtmfmode & H323_DTMF_INBAND)) {
- ast_dsp_free(p->vad);
- p->vad = NULL;
- }
} else if ((dfr->subclass.integer == 'f') && !p->faxdetected) {
const char *target_context = S_OR(p->owner->macrocontext, p->owner->context);
if ((strcmp(p->owner->exten, "fax")) &&
@@ -4552,6 +4654,9 @@
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", p->owner->name,target_context);
}
p->faxdetected = 1;
+ if (dfr) {
+ ast_frfree(dfr);
+ }
return &ast_null_frame;
}
}
@@ -4612,10 +4717,26 @@
if (p->t38support == T38_ENABLED) {
+ struct ast_control_t38_parameters parameters = { .request_response = 0 };
+
+ if ((p->faxdetect & FAXDETECT_T38) && !p->faxdetected) {
+ const char *target_context;
+ ast_debug(1, "* Detected T.38 Request\n");
+ target_context = S_OR(p->owner->macrocontext, p->owner->context);
+ if ((strcmp(p->owner->exten, "fax")) &&
+ (ast_exists_extension(p->owner, target_context, "fax", 1,
+ S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL)))) {
+ ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", p->owner->name);
+ pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
+ if (ast_async_goto(p->owner, target_context, "fax", 1)) {
+ ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", p->owner->name,target_context);
+ }
+ }
+ p->faxdetected = 1;
+ }
/* AST_T38_CONTROL mode */
- struct ast_control_t38_parameters parameters = { .request_response = 0 };
parameters.request_response = AST_T38_REQUEST_NEGOTIATE;
if (call->T38FarMaxDatagram) {
ast_udptl_set_far_max_datagram(p->udptl, call->T38FarMaxDatagram);
@@ -4631,6 +4752,7 @@
¶meters, sizeof(parameters));
p->faxmode = 1;
+
}
} else {
if (p->t38support == T38_ENABLED) {
@@ -4642,6 +4764,7 @@
¶meters, sizeof(parameters));
}
p->faxmode = 0;
+ p->faxdetected = 0;
p->t38_init = 0;
}
Modified: team/irroot/distrotech-customers-trunk/configs/chan_ooh323.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/configs/chan_ooh323.conf.sample?view=diff&rev=327403&r1=327402&r2=327403
==============================================================================
--- team/irroot/distrotech-customers-trunk/configs/chan_ooh323.conf.sample (original)
+++ team/irroot/distrotech-customers-trunk/configs/chan_ooh323.conf.sample Sun Jul 10 07:26:42 2011
@@ -122,6 +122,18 @@
;
;roundtrip=x,y
+;
+; FAX detection will cause the OOH323 channel to jump to the 'fax' extension (if it exists)
+; based one or more events being detected. The events that can be detected are an incoming
+; CNG tone or an incoming T.38 RequestMode packet
+;
+; yes - enable both detection (CNG & T.38)
+; no - disable both
+; cng - enable CNG detection (default)
+; t38 - enable T.38 request detection
+;
+faxdetect = cng
+
; User/peer/friend definitions:
; User config options Peer config options
; ------------------ -------------------
More information about the asterisk-commits
mailing list