Ignore:
Timestamp:
Aug 9, 2008 5:40:22 AM (16 years ago)
Author:
bennylp
Message:

Ticket #588: Improvements to echo cancellation framework

File:
1 edited

Legend:

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

    r2039 r2198  
    3636typedef struct echo_supp 
    3737{ 
    38     pj_bool_t            suppressing; 
    3938    pjmedia_silence_det *sd; 
    40     pj_time_val          last_signal; 
    4139    unsigned             samples_per_frame; 
    4240    unsigned             tail_ms; 
     
    5048PJ_DEF(pj_status_t) echo_supp_create( pj_pool_t *pool, 
    5149                                      unsigned clock_rate, 
     50                                      unsigned channel_count, 
    5251                                      unsigned samples_per_frame, 
    5352                                      unsigned tail_ms, 
    54                                       unsigned latency_ms, 
    5553                                      unsigned options, 
    5654                                      void **p_state ) 
     
    6058 
    6159    PJ_UNUSED_ARG(clock_rate); 
     60    PJ_UNUSED_ARG(channel_count); 
    6261    PJ_UNUSED_ARG(options); 
    63     PJ_UNUSED_ARG(latency_ms); 
    6462 
    6563    ec = PJ_POOL_ZALLOC_T(pool, struct echo_supp); 
     
    9290 
    9391/* 
    94  * Let the AEC knows that a frame has been played to the speaker. 
     92 * Reset 
    9593 */ 
    96 PJ_DEF(pj_status_t) echo_supp_playback( void *state, 
    97                                         pj_int16_t *play_frm ) 
     94PJ_DEF(void) echo_supp_reset(void *state) 
    9895{ 
    99     echo_supp *ec = (echo_supp*) state; 
    100     pj_bool_t silence; 
    101     pj_bool_t last_suppressing = ec->suppressing; 
    102  
    103     silence = pjmedia_silence_det_detect(ec->sd, play_frm, 
    104                                          ec->samples_per_frame, NULL); 
    105  
    106     ec->suppressing = !silence; 
    107  
    108     if (ec->suppressing) { 
    109         pj_gettimeofday(&ec->last_signal); 
    110     } 
    111  
    112     if (ec->suppressing!=0 && last_suppressing==0) { 
    113         PJ_LOG(5,(THIS_FILE, "Start suppressing..")); 
    114     } else if (ec->suppressing==0 && last_suppressing!=0) { 
    115         PJ_LOG(5,(THIS_FILE, "Stop suppressing..")); 
    116     } 
    117  
    118     return PJ_SUCCESS; 
     96    PJ_UNUSED_ARG(state); 
     97    return; 
    11998} 
    120  
    121  
    122 /* 
    123  * Let the AEC knows that a frame has been captured from the microphone. 
    124  */ 
    125 PJ_DEF(pj_status_t) echo_supp_capture( void *state, 
    126                                        pj_int16_t *rec_frm, 
    127                                        unsigned options ) 
    128 { 
    129     echo_supp *ec = (echo_supp*) state; 
    130     pj_time_val now; 
    131     unsigned delay_ms; 
    132  
    133     PJ_UNUSED_ARG(options); 
    134  
    135     pj_gettimeofday(&now); 
    136  
    137     PJ_TIME_VAL_SUB(now, ec->last_signal); 
    138     delay_ms = PJ_TIME_VAL_MSEC(now); 
    139  
    140     if (delay_ms < ec->tail_ms) { 
    141 #if defined(PJMEDIA_ECHO_SUPPRESS_FACTOR) && PJMEDIA_ECHO_SUPPRESS_FACTOR!=0 
    142         unsigned i; 
    143         for (i=0; i<ec->samples_per_frame; ++i) { 
    144             rec_frm[i] = (pj_int16_t)(rec_frm[i] >>  
    145                                       PJMEDIA_ECHO_SUPPRESS_FACTOR); 
    146         } 
    147 #else 
    148         pjmedia_zero_samples(rec_frm, ec->samples_per_frame); 
    149 #endif 
    150     } 
    151  
    152     return PJ_SUCCESS; 
    153 } 
    154  
    15599 
    156100/* 
Note: See TracChangeset for help on using the changeset viewer.