summaryrefslogtreecommitdiff
path: root/pjmedia/include
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-08-04 11:08:00 +0000
committerBenny Prijono <bennylp@teluu.com>2006-08-04 11:08:00 +0000
commit4a01731c11f29c2042459f37516ec313c4e8a495 (patch)
treed5049d0a6bad525526f93efed107b06097cec7ff /pjmedia/include
parent60fb5677579381a10db65cf32333fbabdd4a715e (diff)
More experimentation with AEC: (1) added media port to create bidirectional port from two unidirectional ports, (2) split AEC functionality into AEC algorithm (aec.h) and AEC media port (aec_port.h), (3) Added the AEC functionality in the sound_port.c.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@646 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia/include')
-rw-r--r--pjmedia/include/pjmedia.h2
-rw-r--r--pjmedia/include/pjmedia/aec.h153
-rw-r--r--pjmedia/include/pjmedia/bidirectional.h65
3 files changed, 220 insertions, 0 deletions
diff --git a/pjmedia/include/pjmedia.h b/pjmedia/include/pjmedia.h
index fc79c463..049e36c8 100644
--- a/pjmedia/include/pjmedia.h
+++ b/pjmedia/include/pjmedia.h
@@ -25,7 +25,9 @@
*/
#include <pjmedia/types.h>
+#include <pjmedia/aec.h>
#include <pjmedia/aec_port.h>
+#include <pjmedia/bidirectional.h>
#include <pjmedia/clock.h>
#include <pjmedia/codec.h>
#include <pjmedia/conference.h>
diff --git a/pjmedia/include/pjmedia/aec.h b/pjmedia/include/pjmedia/aec.h
new file mode 100644
index 00000000..a2354ef3
--- /dev/null
+++ b/pjmedia/include/pjmedia/aec.h
@@ -0,0 +1,153 @@
+/* $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_AEC_H__
+#define __PJMEDIA_AEC_H__
+
+
+/**
+ * @file aec.h
+ * @brief AEC (Accoustic Echo Cancellation) API.
+ */
+#include <pjmedia/types.h>
+
+
+
+/**
+ * @defgroup PJMEDIA_AEC AEC AEC (Accoustic Echo Cancellation)
+ * @ingroup PJMEDIA_PORT
+ * @brief AEC (Accoustic Echo Cancellation) API.
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Opaque type for PJMEDIA AEC.
+ */
+typedef struct pjmedia_aec pjmedia_aec;
+
+
+/**
+ * Create the AEC.
+ *
+ * @param pool Pool to allocate memory.
+ * @param clock_rate Media clock rate/sampling rate.
+ * @param samples_per_frame Number of samples per frame.
+ * @param tail_size Tail length, in number of samples.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_aec_create( pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned samples_per_frame,
+ unsigned tail_size,
+ unsigned options,
+ pjmedia_aec **p_aec );
+
+
+/**
+ * Destroy the AEC.
+ *
+ * @param aec The AEC.
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_aec_destroy(pjmedia_aec *aec );
+
+
+/**
+ * Let the AEC knows that a frame has been played to the speaker.
+ * The AEC will keep the frame in its internal buffer, to be used
+ * when cancelling the echo with #pjmedia_aec_capture().
+ *
+ * @param aec The AEC.
+ * @param ts Optional timestamp to let the AEC knows the
+ * position of the frame relative to capture
+ * position. If NULL, the AEC assumes that
+ * application will supply the AEC with continuously
+ * increasing timestamp.
+ * @param play_frm Sample buffer containing frame to be played
+ * (or has been played) to the playback device.
+ * The frame must contain exactly samples_per_frame
+ * number of samples.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_aec_playback( pjmedia_aec *aec,
+ pj_int16_t *play_frm );
+
+
+/**
+ * Let the AEC knows that a frame has been captured from the microphone.
+ * The AEC will cancel the echo from the captured signal, using the
+ * internal buffer (supplied by #pjmedia_aec_playback()) as the
+ * FES (Far End Speech) reference.
+ *
+ * @param aec The AEC.
+ * @param rec_frm On input, it contains the input signal (captured
+ * from microphone) which echo is to be removed.
+ * Upon returning this function, this buffer contain
+ * the processed signal with the echo removed.
+ * The frame must contain exactly samples_per_frame
+ * number of samples.
+ * @param options Echo cancellation options, reserved for future use.
+ * Put zero for now.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_aec_capture( pjmedia_aec *aec,
+ pj_int16_t *rec_frm,
+ unsigned options );
+
+
+/**
+ * Perform echo cancellation.
+ *
+ * @param aec The AEC.
+ * @param rec_frm On input, it contains the input signal (captured
+ * from microphone) which echo is to be removed.
+ * Upon returning this function, this buffer contain
+ * the processed signal with the echo removed.
+ * @param play_frm Sample buffer containing frame to be played
+ * (or has been played) to the playback device.
+ * The frame must contain exactly samples_per_frame
+ * number of samples.
+ * @param options Echo cancellation options, reserved for future use.
+ * Put zero for now.
+ * @param reserved Reserved for future use, put NULL for now.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_aec_cancel_echo( pjmedia_aec *aec,
+ pj_int16_t *rec_frm,
+ const pj_int16_t *play_frm,
+ unsigned options,
+ void *reserved );
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_AEC_H__ */
+
diff --git a/pjmedia/include/pjmedia/bidirectional.h b/pjmedia/include/pjmedia/bidirectional.h
new file mode 100644
index 00000000..5b16d4c6
--- /dev/null
+++ b/pjmedia/include/pjmedia/bidirectional.h
@@ -0,0 +1,65 @@
+/* $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_BIDIRECTIONAL_H__
+#define __PJMEDIA_BIDIRECTIONAL_H__
+
+/**
+ * @file bidirectional.h
+ * @brief Create bidirectional port from two unidirectional ports.
+ */
+#include <pjmedia/port.h>
+
+
+/**
+ * @defgroup PJMEDIA_BIDIRECTIONAL_PORT Bidirectional Port
+ * @ingroup PJMEDIA_PORT
+ * @brief Create bidirectional port from two unidirectional ports.
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Create bidirectional port from two unidirectional ports
+ *
+ * @param pool Pool to allocate memory.
+ * @param get_port Port where get_frame() will be directed to.
+ * @param put_port Port where put_frame() will be directed to.
+ * @param p_port Pointer to receive the port instance.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_bidirectional_port_create(pj_pool_t *pool,
+ pjmedia_port *get_port,
+ pjmedia_port *put_port,
+ pjmedia_port **p_port );
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_BIDIRECTIONAL_H__ */
+