Ignore:
Timestamp:
Oct 21, 2013 3:11:14 AM (11 years ago)
Author:
nanang
Message:

Close #1705: Added playback and capture callbacks for echo canceller algo. Note that this changeset also modified current Speex AEC algo behaviors:

  • applied this two APIs model for Speex AEC algo
  • enabled Speex AGC preprocessing
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/echo_speex.c

    r3664 r4622  
    110110#endif 
    111111 
     112    /* Enable AGC */ 
     113    { 
     114        spx_int32_t enabled = 1; 
     115        speex_preprocess_ctl(echo->preprocess, SPEEX_PREPROCESS_SET_AGC,  
     116                             &enabled); 
     117    } 
     118 
    112119    /* Control echo cancellation in the preprocessor */ 
    113120   speex_preprocess_ctl(echo->preprocess, SPEEX_PREPROCESS_SET_ECHO_STATE,  
     
    190197} 
    191198 
     199/* 
     200 * Let AEC know that a frame was queued to be played. 
     201 */ 
     202PJ_DEF(pj_status_t) speex_aec_playback( void *state, 
     203                                        pj_int16_t *play_frm ) 
     204{ 
     205    speex_ec *echo = (speex_ec*) state; 
     206 
     207    /* Sanity checks */ 
     208    PJ_ASSERT_RETURN(echo && play_frm, PJ_EINVAL); 
     209 
     210    speex_echo_playback(echo->state, (spx_int16_t*)play_frm); 
     211 
     212    return PJ_SUCCESS; 
     213 
     214} 
     215 
     216/* 
     217 * Perform echo cancellation to captured frame. 
     218 */ 
     219PJ_DEF(pj_status_t) speex_aec_capture( void *state, 
     220                                       pj_int16_t *rec_frm, 
     221                                       unsigned options ) 
     222{ 
     223    speex_ec *echo = (speex_ec*) state; 
     224 
     225    /* Sanity checks */ 
     226    PJ_ASSERT_RETURN(echo && rec_frm, PJ_EINVAL); 
     227 
     228    PJ_UNUSED_ARG(options); 
     229 
     230    /* Cancel echo */ 
     231    pjmedia_copy_samples(echo->tmp_frame, rec_frm, echo->samples_per_frame); 
     232    speex_echo_capture(echo->state, 
     233                       (spx_int16_t*)echo->tmp_frame, 
     234                       (spx_int16_t*)rec_frm); 
     235 
     236    /* Apply preprocessing */ 
     237    speex_preprocess_run(echo->preprocess, (spx_int16_t*)rec_frm); 
     238 
     239    return PJ_SUCCESS; 
     240} 
     241 
     242 
    192243#endif 
Note: See TracChangeset for help on using the changeset viewer.