summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-02-19 18:38:37 +0000
committerBenny Prijono <bennylp@teluu.com>2006-02-19 18:38:37 +0000
commitca9c14f791178caba306b47766b26bbbed8a34a8 (patch)
tree6999905c809e96e2ae44a04f1bb1476439c8985a
parent51f0bc5a46378786d98caf84df2cf31bb169e45b (diff)
Putting vad template
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@202 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjmedia/build/pjmedia.dsp8
-rw-r--r--pjmedia/include/pjmedia/vad.h83
-rw-r--r--pjmedia/src/pjmedia/vad.c42
3 files changed, 133 insertions, 0 deletions
diff --git a/pjmedia/build/pjmedia.dsp b/pjmedia/build/pjmedia.dsp
index f8434599..0f87dc57 100644
--- a/pjmedia/build/pjmedia.dsp
+++ b/pjmedia/build/pjmedia.dsp
@@ -147,6 +147,10 @@ SOURCE=..\src\pjmedia\session.c
SOURCE=..\src\pjmedia\stream.c
# End Source File
+# Begin Source File
+
+SOURCE=..\src\pjmedia\vad.c
+# End Source File
# End Group
# Begin Group "Header Files"
@@ -211,6 +215,10 @@ SOURCE=..\include\pjmedia\stream.h
SOURCE=..\include\pjmedia\types.h
# End Source File
+# Begin Source File
+
+SOURCE=..\include\pjmedia\vad.h
+# End Source File
# End Group
# Begin Group "PortAudio"
diff --git a/pjmedia/include/pjmedia/vad.h b/pjmedia/include/pjmedia/vad.h
new file mode 100644
index 00000000..4788799b
--- /dev/null
+++ b/pjmedia/include/pjmedia/vad.h
@@ -0,0 +1,83 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef __PJMEDIA_VAD_H__
+#define __PJMEDIA_VAD_H__
+
+
+/**
+ * @file vad.h
+ * @brief Voice Activity Detector.
+ */
+#include <pjmedia/types.h>
+
+
+/**
+ * Opaque data type for pjmedia vad.
+ */
+typedef struct pjmedia_vad pjmedia_vad;
+
+
+/**
+ * Create voice activity detector with default settings. The default settings
+ * are to perform adaptive silence detection, which adjusts the noise level
+ * dynamically based on current input level.
+ *
+ * @param pool Pool for allocating the structure.
+ * @param p_vad Pointer to receive the VAD instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_vad_create( pj_pool_t *pool,
+ pjmedia_vad **p_vad );
+
+
+/**
+ * Calculate average signal level for the given samples.
+ *
+ * @param samples Pointer to 16-bit PCM samples.
+ * @param count Number of samples in the input.
+ *
+ * @return The average signal level, which simply is total level
+ * divided by number of samples.
+ */
+PJ_DECL(pj_uint32_t) pjmedia_vad_calc_avg_signal_level( pj_int16_t samples[],
+ pj_size_t count );
+
+
+/**
+ * Perform voice activity detection on the given input samples.
+ *
+ * @param vad The VAD instance.
+ * @param samples Pointer to 16-bit PCM input samples.
+ * @param count Number of samples in the input.
+ * @param p_silence Pointer to receive the silence detection result.
+ * Non-zero value indicates that that input is considered
+ * as silence.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_vad_detect_silence( pjmedia_vad *vad,
+ pj_int16_t samples[],
+ pj_size_t count,
+ pj_bool_t *p_silence);
+
+
+
+#endif /* __PJMEDIA_VAD_H__ */
+
diff --git a/pjmedia/src/pjmedia/vad.c b/pjmedia/src/pjmedia/vad.c
new file mode 100644
index 00000000..399879a7
--- /dev/null
+++ b/pjmedia/src/pjmedia/vad.c
@@ -0,0 +1,42 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pjmedia/vad.h>
+#include <pjmedia/errno.h>
+
+
+PJ_DEF(pj_status_t) pjmedia_vad_create( pj_pool_t *pool,
+ pjmedia_vad **p_vad)
+{
+ return PJ_EINVALIDOP;
+}
+
+PJ_DEF(pj_uint32_t) pjmedia_vad_calc_avg_signal_level(pj_int16_t samples[],
+ pj_size_t count)
+{
+ return PJ_EINVALIDOP;
+}
+
+PJ_DEF(pj_status_t) pjmedia_vad_detect_silence( pjmedia_vad *vad,
+ pj_int16_t samples[],
+ pj_size_t count,
+ pj_bool_t *p_silence)
+{
+ return PJ_EINVALIDOP;
+}
+