[svn-commits] kpfleming: branch kpfleming/dahdi-dsp-options r183443 - in /team/kpfleming/da...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Mar 19 16:14:51 CDT 2009
Author: kpfleming
Date: Thu Mar 19 16:14:48 2009
New Revision: 183443
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183443
Log:
save away some work done to allow DAHDI channel DSP stuff to be disabled by applications when it is not needed
Added:
team/kpfleming/dahdi-dsp-options/
- copied from r183442, branches/1.6.0/
Modified:
team/kpfleming/dahdi-dsp-options/channels/chan_dahdi.c
team/kpfleming/dahdi-dsp-options/include/asterisk/frame.h
Modified: team/kpfleming/dahdi-dsp-options/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/kpfleming/dahdi-dsp-options/channels/chan_dahdi.c?view=diff&rev=183443&r1=183442&r2=183443
==============================================================================
--- team/kpfleming/dahdi-dsp-options/channels/chan_dahdi.c (original)
+++ team/kpfleming/dahdi-dsp-options/channels/chan_dahdi.c Thu Mar 19 16:14:48 2009
@@ -1173,6 +1173,7 @@
static int dahdi_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen);
static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int datalen);
+static int dahdi_queryoption(struct ast_channel *chan, int option, void *data, int *datalen);
static int dahdi_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
static const struct ast_channel_tech dahdi_tech = {
@@ -1193,6 +1194,7 @@
.indicate = dahdi_indicate,
.fixup = dahdi_fixup,
.setoption = dahdi_setoption,
+ .queryoption = dahdi_queryoption,
.func_channel_read = dahdi_func_read,
};
@@ -3812,6 +3814,68 @@
return res;
}
+static void disable_dtmf_detect(struct dahdi_pvt *p)
+{
+ int val;
+
+ p->ignoredtmf = 1;
+
+ val = 0;
+ ioctl(p->subs[SUB_REAL].dfd, DAHDI_TONEDETECT, &val);
+
+ if (!p->hardwaredtmf && p->dsp) {
+ p->dsp_features &= ~DSP_FEATURE_DTMF_DETECT;
+ ast_dsp_set_features(p->dsp, p->dsp_features);
+ }
+}
+
+static void enable_dtmf_detect(struct dahdi_pvt *p)
+{
+ int val;
+
+ if (p->channel == CHAN_PSEUDO)
+ return;
+
+ p->ignoredtmf = 0;
+
+ val = DAHDI_TONEDETECT_ON | DAHDI_TONEDETECT_MUTE;
+ ioctl(p->subs[SUB_REAL].dfd, DAHDI_TONEDETECT, &val);
+
+ if (!p->hardwaredtmf && p->dsp) {
+ p->dsp_features |= DSP_FEATURE_DTMF_DETECT;
+ ast_dsp_set_features(p->dsp, p->dsp_features);
+ }
+}
+
+static int dahdi_queryoption(struct ast_channel *chan, int option, void *data, int *datalen)
+{
+ char *cp;
+ struct dahdi_pvt *p = chan->tech_pvt;
+
+ /* all supported options require data */
+ if (!data || (*datalen < 1)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ switch (option) {
+ case AST_OPTION_DIGIT_DETECT:
+ cp = (char *) data;
+ *cp = p->ignoredtmf ? 0 : 1;
+ ast_debug(1, "Reporting digit detection %sabled on %s\n", *cp ? "en" : "dis", chan->name);
+ break;
+ case AST_OPTION_FAX_DETECT:
+ cp = (char *) data;
+ *cp = (p->callprogress & CALLPROGRESS_FAX) ? 0 : 1;
+ ast_debug(1, "Reporting fax tone detection %sabled on %s\n", *cp ? "en" : "dis", chan->name);
+ break;
+ }
+
+ errno = 0;
+
+ return 0;
+}
+
static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int datalen)
{
char *cp;
@@ -3987,6 +4051,29 @@
dahdi_disable_ec(p);
}
break;
+ case AST_OPTION_DIGIT_DETECT:
+ cp = (char *) data;
+ ast_debug(1, "%sabling digit detection on %s\n", *cp ? "En" : "Dis", chan->name);
+ if (*cp) {
+ enable_dtmf_detect(p);
+ } else {
+ disable_dtmf_detect(p);
+ }
+ break;
+ case AST_OPTION_FAX_DETECT:
+ cp = (char *) data;
+ if (p->dsp) {
+ ast_debug(1, "%sabling fax tone detection on %s\n", *cp ? "En" : "Dis", chan->name);
+ if (*cp) {
+ p->callprogress |= CALLPROGRESS_FAX;
+ p->dsp_features |= DSP_FEATURE_FAX_DETECT;
+ } else {
+ p->callprogress &= ~CALLPROGRESS_FAX;
+ p->dsp_features &= ~DSP_FEATURE_FAX_DETECT;
+ }
+ ast_dsp_set_features(p->dsp, p->dsp_features);
+ }
+ break;
}
errno = 0;
@@ -4089,39 +4176,6 @@
slave->master = master;
ast_debug(1, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
-}
-
-static void disable_dtmf_detect(struct dahdi_pvt *p)
-{
- int val;
-
- p->ignoredtmf = 1;
-
- val = 0;
- ioctl(p->subs[SUB_REAL].dfd, DAHDI_TONEDETECT, &val);
-
- if (!p->hardwaredtmf && p->dsp) {
- p->dsp_features &= ~DSP_FEATURE_DTMF_DETECT;
- ast_dsp_set_features(p->dsp, p->dsp_features);
- }
-}
-
-static void enable_dtmf_detect(struct dahdi_pvt *p)
-{
- int val;
-
- if (p->channel == CHAN_PSEUDO)
- return;
-
- p->ignoredtmf = 0;
-
- val = DAHDI_TONEDETECT_ON | DAHDI_TONEDETECT_MUTE;
- ioctl(p->subs[SUB_REAL].dfd, DAHDI_TONEDETECT, &val);
-
- if (!p->hardwaredtmf && p->dsp) {
- p->dsp_features |= DSP_FEATURE_DTMF_DETECT;
- ast_dsp_set_features(p->dsp, p->dsp_features);
- }
}
static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
@@ -4612,6 +4666,10 @@
/* Fax tone -- Handle and return NULL */
if ((p->callprogress & CALLPROGRESS_FAX) && !p->faxhandled) {
p->faxhandled = 1;
+ p->callprogress &= ~CALLPROGRESS_FAX;
+ p->dsp_features &= ~DSP_FEATURE_FAX_DETECT;
+ ast_dsp_set_features(p->dsp, p->dsp_features);
+ ast_debug(1, "Disabling FAX tone detection on %s after tone received\n", ast->name);
if (strcmp(ast->exten, "fax")) {
const char *target_context = S_OR(ast->macrocontext, ast->context);
Modified: team/kpfleming/dahdi-dsp-options/include/asterisk/frame.h
URL: http://svn.digium.com/svn-view/asterisk/team/kpfleming/dahdi-dsp-options/include/asterisk/frame.h?view=diff&rev=183443&r1=183442&r2=183443
==============================================================================
--- team/kpfleming/dahdi-dsp-options/include/asterisk/frame.h (original)
+++ team/kpfleming/dahdi-dsp-options/include/asterisk/frame.h Thu Mar 19 16:14:48 2009
@@ -375,6 +375,12 @@
*/
#define AST_OPTION_T38_STATE 10
+/*! Get or set the digit detection state of the channel */
+#define AST_OPTION_DIGIT_DETECT 11
+
+/*! Get or set the fax tone detection state of the channel */
+#define AST_OPTION_FAX_DETECT 12
+
struct oprmode {
struct ast_channel *peer;
int mode;
More information about the svn-commits
mailing list