summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2008-03-26 19:05:51 +0000
committerJason Parker <jparker@digium.com>2008-03-26 19:05:51 +0000
commit6412a96e43104ccad740ff224dc616ec85b89435 (patch)
tree6370de713f623ccbd19a04fe52ccc8d1aad77288 /channels
parenta3d7dc89037ea8e5096228cec1b0f58e2b6e629f (diff)
Large cleanup of DSP code
Per comments from dimas: 1. The code now generates DTMF_BEGIN frames in addition to DTMF_END ones. 2. "quelching" rewritten - now each detector (MF/DTMF/generic tone) may mark fragment of a frame for suppression (squelching, muting) with a call to mute_fragment. Actual muting happens only once at the very end of ast_dsp_process where all marked fragments are zeroed. This way every detector sees original data in the frame without any piece of a frame being zeroed by a detector which was run before. 3. DTMF detector tries to "mute" one block before and one block after the block where actual tone was detected. Muting of previois block is something new for this patch. Obviously this operation is not always possible - if current frame does not contain data for previous block - it is too late. But at least we make our best. Muting of next block was already done by the old code but it only affects part of the next block which is in the frame being processed. New code keeps this information in state structures so it will mute proper number of samples in the next frame(s) too. 4. Removed ast_dsp_digitdetect and ast_dsp_getdigits APIs because these are not used. 5. DSP API extended a bit - ast_dsp_was_muted() function added which returns true if DSP code was muting any fragment in the last frame. chan_zap uses this function to decide it needs to turn on confmute on the channel. This is to replace AST_FRAME_DTMF 'm'/'u' (mute/unmute) functionality. (closes issue #11968) Reported by: dimas Patches: v2-11968-dsp.patch uploaded by dimas (license 88) v4-11968-zap.patch uploaded by dimas (license 88) Tested by: dimas, qwell git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@111022 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_usbradio.c2
-rw-r--r--channels/chan_vpb.cc8
-rw-r--r--channels/chan_zap.c31
3 files changed, 15 insertions, 26 deletions
diff --git a/channels/chan_usbradio.c b/channels/chan_usbradio.c
index 11c06e957..84a2ce2bb 100644
--- a/channels/chan_usbradio.c
+++ b/channels/chan_usbradio.c
@@ -1210,8 +1210,6 @@ static struct ast_frame *usbradio_read(struct ast_channel *c)
if (o->dsp) {
f1 = ast_dsp_process(c, o->dsp, f);
if ((f1->frametype == AST_FRAME_DTMF_END) || (f1->frametype == AST_FRAME_DTMF_BEGIN)) {
- if ((f1->subclass == 'm') || (f1->subclass == 'u'))
- f1->frametype = AST_FRAME_DTMF_BEGIN;
if (f1->frametype == AST_FRAME_DTMF_END)
ast_log(LOG_NOTICE,"Got DTMF char %c\n",f1->subclass);
return f1;
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index be1ed535b..bd67ab0ec 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -2400,14 +2400,6 @@ static void *do_chanreads(void *pvt)
fr = ast_dsp_process(p->owner,p->vad,fr);
if (fr && (fr->frametype == AST_FRAME_DTMF))
ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n", p->dev, fr->subclass);
- if (fr->subclass == 'm') {
- /* conf mute request */
- fr->frametype = AST_FRAME_NULL;
- fr->subclass = 0;
- } else if (fr->subclass == 'u') {
- /* Unmute */
- fr->frametype = AST_FRAME_NULL;
- fr->subclass = 0;
} else if (fr->subclass == 'f') {
}
}
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index effd5cccf..beb3c33fc 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -706,6 +706,7 @@ static struct zt_pvt {
unsigned int loopedback:1;
#endif
char begindigit;
+ int muting;
} *iflist = NULL, *ifend = NULL;
/*! \brief Channel configuration from zapata.conf .
@@ -2988,6 +2989,7 @@ static int zt_hangup(struct ast_channel *ast)
x = 0;
zt_confmute(p, 0);
+ p->muting = 0;
restore_gains(p);
if (p->origcid_num) {
ast_copy_string(p->cid_num, p->origcid_num, sizeof(p->cid_num));
@@ -4232,8 +4234,7 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
ast_free(p->cidspill);
send_cwcidspill(p);
}
- if ((f->subclass != 'm') && (f->subclass != 'u'))
- p->callwaitcas = 0;
+ p->callwaitcas = 0;
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
*dest = &p->subs[index].f;
@@ -4260,20 +4261,7 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
*dest = &p->subs[index].f;
- } else if (f->subclass == 'm') {
- /* Confmute request */
- zt_confmute(p, 1);
- p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
- *dest = &p->subs[index].f;
- } else if (f->subclass == 'u') {
- /* Unmute */
- zt_confmute(p, 0);
- p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
- *dest = &p->subs[index].f;
- } else
- zt_confmute(p, 0);
+ }
}
static struct ast_frame *zt_handle_event(struct ast_channel *ast)
@@ -5463,7 +5451,17 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
}
if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect || p->callprogress) && !index) {
/* Perform busy detection. etc on the zap line */
+ int mute;
+
f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
+
+ /* Check if DSP code thinks we should be muting this frame and mute the conference if so */
+ mute = ast_dsp_was_muted(p->dsp);
+ if (p->muting != mute) {
+ p->muting = mute;
+ zt_confmute(p, mute);
+ }
+
if (f) {
if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_BUSY)) {
if ((ast->_state == AST_STATE_UP) && !p->outgoing) {
@@ -5996,6 +5994,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
i->fake_event = 0;
/* Assure there is no confmute on this channel */
zt_confmute(i, 0);
+ i->muting = 0;
/* Configure the new channel jb */
ast_jb_configure(tmp, &global_jbconf);