summaryrefslogtreecommitdiff
path: root/main/dsp.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-06-30 20:33:15 +0000
committerDavid Vossel <dvossel@digium.com>2011-06-30 20:33:15 +0000
commit1339a0a535f42ae51577aa01cfffc5f086915740 (patch)
treeafcca011f073934d3bf0b6e94b9ca2f326b265ad /main/dsp.c
parentc81556d8ef7500fbc092637512f1e337933acbc6 (diff)
Video support for ConfBridge.
Review: https://reviewboard.asterisk.org/r/1288/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@325931 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/dsp.c')
-rw-r--r--main/dsp.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/main/dsp.c b/main/dsp.c
index 9e3e2e724..ee1891823 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -1103,7 +1103,7 @@ int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf)
return __ast_dsp_call_progress(dsp, inf->data.ptr, inf->datalen / 2);
}
-static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise)
+static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise, int *frames_energy)
{
int accum;
int x;
@@ -1163,6 +1163,9 @@ static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *
if (totalnoise) {
*totalnoise = dsp->totalnoise;
}
+ if (frames_energy) {
+ *frames_energy = accum;
+ }
return res;
}
@@ -1318,7 +1321,25 @@ int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
}
s = f->data.ptr;
len = f->datalen/2;
- return __ast_dsp_silence_noise(dsp, s, len, totalsilence, NULL);
+ return __ast_dsp_silence_noise(dsp, s, len, totalsilence, NULL, NULL);
+}
+
+int ast_dsp_silence_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence, int *frames_energy)
+{
+ short *s;
+ int len;
+
+ if (f->frametype != AST_FRAME_VOICE) {
+ ast_log(LOG_WARNING, "Can't calculate silence on a non-voice frame\n");
+ return 0;
+ }
+ if (!ast_format_is_slinear(&f->subclass.format)) {
+ ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n");
+ return 0;
+ }
+ s = f->data.ptr;
+ len = f->datalen/2;
+ return __ast_dsp_silence_noise(dsp, s, len, totalsilence, NULL, frames_energy);
}
int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
@@ -1336,7 +1357,7 @@ int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
}
s = f->data.ptr;
len = f->datalen/2;
- return __ast_dsp_silence_noise(dsp, s, len, NULL, totalnoise);
+ return __ast_dsp_silence_noise(dsp, s, len, NULL, totalnoise, NULL);
}
@@ -1393,7 +1414,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
/* Need to run the silence detection stuff for silence suppression and busy detection */
if ((dsp->features & DSP_FEATURE_SILENCE_SUPPRESS) || (dsp->features & DSP_FEATURE_BUSY_DETECT)) {
- res = __ast_dsp_silence_noise(dsp, shortdata, len, &silence, NULL);
+ res = __ast_dsp_silence_noise(dsp, shortdata, len, &silence, NULL, NULL);
}
if ((dsp->features & DSP_FEATURE_SILENCE_SUPPRESS) && silence) {