Ignore:
Timestamp:
Aug 6, 2006 12:07:13 PM (18 years ago)
Author:
bennylp
Message:

Change AEC into generic echo canceller framework with either AEC or simple echo suppressor backend can be selected during runtime.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/echo.h

    r652 r653  
    1717 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
    1818 */ 
    19 #ifndef __PJMEDIA_AEC_H__ 
    20 #define __PJMEDIA_AEC_H__ 
     19#ifndef __PJMEDIA_ECHO_H__ 
     20#define __PJMEDIA_ECHO_H__ 
    2121 
    2222 
    2323/** 
    24  * @file aec.h 
    25  * @brief AEC (Accoustic Echo Cancellation) API. 
     24 * @file echo.h 
     25 * @brief Echo Cancellation API. 
    2626 */ 
    2727#include <pjmedia/types.h> 
     
    3030 
    3131/** 
    32  * @defgroup PJMEDIA_AEC AEC AEC (Accoustic Echo Cancellation) 
     32 * @defgroup PJMEDIA_Echo_Cancel Canceller Echo Cancellation 
    3333 * @ingroup PJMEDIA_PORT 
    34  * @brief AEC (Accoustic Echo Cancellation) API. 
     34 * @brief Echo Cancellation API. 
    3535 * @{ 
     36 * 
     37 * This section describes API to perform echo cancellation to audio signal. 
     38 * There may be multiple echo canceller implementation in PJMEDIA, ranging 
     39 * from simple echo suppressor to a full Accoustic Echo Canceller/AEC. By  
     40 * using this API, application should be able to use which EC backend to 
     41 * use base on the requirement and capability of the platform. 
    3642 */ 
    3743 
     
    4147 
    4248/** 
    43  * Opaque type for PJMEDIA AEC. 
     49 * Opaque type for PJMEDIA Echo Canceller state. 
    4450 */ 
    45 typedef struct pjmedia_aec pjmedia_aec; 
     51typedef struct pjmedia_echo_state pjmedia_echo_state; 
    4652 
    4753 
    4854/** 
    49  * Create the AEC.  
     55 * Echo cancellation options. 
     56 */ 
     57typedef enum pjmedia_echo_flag 
     58{ 
     59    /** 
     60     * If PJMEDIA_ECHO_SIMPLE flag is specified during echo canceller 
     61     * creation, then a simple echo suppressor will be used instead of 
     62     * an accoustic echo cancellation. 
     63     */ 
     64    PJMEDIA_ECHO_SIMPLE = 1, 
     65 
     66    /** 
     67     * If PJMEDIA_ECHO_NO_LOCK flag is specified, no mutex will be created 
     68     * for the echo canceller, but application will guarantee that echo 
     69     * canceller will not be called by different threads at the same time. 
     70     */ 
     71    PJMEDIA_ECHO_NO_LOCK = 2 
     72 
     73} pjmedia_echo_flag; 
     74 
     75 
     76 
     77 
     78/** 
     79 * Create the echo canceller.  
    5080 * 
    5181 * @param pool              Pool to allocate memory. 
     
    5383 * @param samples_per_frame Number of samples per frame. 
    5484 * @param tail_ms           Tail length, miliseconds. 
     85 * @param options           Options. If PJMEDIA_ECHO_SIMPLE is specified, 
     86 *                          then a simple echo suppressor implementation  
     87 *                          will be used instead of an accoustic echo  
     88 *                          cancellation. 
     89 *                          See #pjmedia_echo_flag for other options. 
     90 * @param p_echo            Pointer to receive the Echo Canceller state. 
    5591 * 
    56  * @return                  PJ_SUCCESS on success. 
     92 * @return                  PJ_SUCCESS on success, or the appropriate status. 
    5793 */ 
    58 PJ_DECL(pj_status_t) pjmedia_aec_create( pj_pool_t *pool, 
     94PJ_DECL(pj_status_t) pjmedia_echo_create(pj_pool_t *pool, 
    5995                                         unsigned clock_rate, 
    6096                                         unsigned samples_per_frame, 
    6197                                         unsigned tail_ms, 
    6298                                         unsigned options, 
    63                                          pjmedia_aec **p_aec ); 
     99                                         pjmedia_echo_state **p_echo ); 
    64100 
    65101 
    66102/** 
    67  * Destroy the AEC.  
     103 * Destroy the Echo Canceller.  
    68104 * 
    69  * @param aec           The AEC. 
     105 * @param echo          The Echo Canceller. 
     106 * 
    70107 * @return              PJ_SUCCESS on success. 
    71108 */ 
    72 PJ_DECL(pj_status_t) pjmedia_aec_destroy(pjmedia_aec *aec ); 
     109PJ_DECL(pj_status_t) pjmedia_echo_destroy(pjmedia_echo_state *echo ); 
    73110 
    74111 
    75112/** 
    76  * Let the AEC knows that a frame has been played to the speaker. 
    77  * The AEC will keep the frame in its internal buffer, to be used 
    78  * when cancelling the echo with #pjmedia_aec_capture(). 
     113 * Let the Echo Canceller knows that a frame has been played to the speaker. 
     114 * The Echo Canceller will keep the frame in its internal buffer, to be used 
     115 * when cancelling the echo with #pjmedia_echo_capture(). 
    79116 * 
    80  * @param aec           The AEC. 
    81  * @param ts            Optional timestamp to let the AEC knows the 
    82  *                      position of the frame relative to capture 
    83  *                      position. If NULL, the AEC assumes that 
    84  *                      application will supply the AEC with continuously 
    85  *                      increasing timestamp. 
     117 * @param echo          The Echo Canceller. 
    86118 * @param play_frm      Sample buffer containing frame to be played 
    87119 *                      (or has been played) to the playback device. 
     
    91123 * @return              PJ_SUCCESS on success. 
    92124 */ 
    93 PJ_DECL(pj_status_t) pjmedia_aec_playback( pjmedia_aec *aec, 
     125PJ_DECL(pj_status_t) pjmedia_echo_playback(pjmedia_echo_state *echo, 
    94126                                           pj_int16_t *play_frm ); 
    95127 
    96128 
    97129/** 
    98  * Let the AEC knows that a frame has been captured from the microphone. 
    99  * The AEC will cancel the echo from the captured signal, using the 
    100  * internal buffer (supplied by #pjmedia_aec_playback()) as the 
    101  * FES (Far End Speech) reference. 
     130 * Let the Echo Canceller knows that a frame has been captured from  
     131 * the microphone. 
     132 * The Echo Canceller will cancel the echo from the captured signal,  
     133 * using the internal buffer (supplied by #pjmedia_echo_playback())  
     134 * as the FES (Far End Speech) reference. 
    102135 * 
    103  * @param aec           The AEC. 
     136 * @param echo          The Echo Canceller. 
    104137 * @param rec_frm       On input, it contains the input signal (captured  
    105138 *                      from microphone) which echo is to be removed. 
     
    113146 * @return              PJ_SUCCESS on success. 
    114147 */ 
    115 PJ_DECL(pj_status_t) pjmedia_aec_capture( pjmedia_aec *aec, 
     148PJ_DECL(pj_status_t) pjmedia_echo_capture(pjmedia_echo_state *echo, 
    116149                                          pj_int16_t *rec_frm, 
    117150                                          unsigned options ); 
     
    121154 * Perform echo cancellation. 
    122155 * 
    123  * @param aec           The AEC. 
     156 * @param echo          The Echo Canceller. 
    124157 * @param rec_frm       On input, it contains the input signal (captured  
    125158 *                      from microphone) which echo is to be removed. 
     
    136169 * @return              PJ_SUCCESS on success. 
    137170 */ 
    138 PJ_DECL(pj_status_t) pjmedia_aec_cancel_echo( pjmedia_aec *aec, 
    139                                               pj_int16_t *rec_frm, 
    140                                               const pj_int16_t *play_frm, 
    141                                               unsigned options, 
    142                                               void *reserved ); 
     171PJ_DECL(pj_status_t) pjmedia_echo_cancel( pjmedia_echo_state *echo, 
     172                                          pj_int16_t *rec_frm, 
     173                                          const pj_int16_t *play_frm, 
     174                                          unsigned options, 
     175                                          void *reserved ); 
    143176 
    144177 
     
    150183 
    151184 
    152 #endif  /* __PJMEDIA_AEC_H__ */ 
     185#endif  /* __PJMEDIA_ECHO_H__ */ 
    153186 
Note: See TracChangeset for help on using the changeset viewer.