Changeset 2198 for pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
- Timestamp:
- Aug 9, 2008 5:40:22 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
r2039 r2198 36 36 typedef struct echo_supp 37 37 { 38 pj_bool_t suppressing;39 38 pjmedia_silence_det *sd; 40 pj_time_val last_signal;41 39 unsigned samples_per_frame; 42 40 unsigned tail_ms; … … 50 48 PJ_DEF(pj_status_t) echo_supp_create( pj_pool_t *pool, 51 49 unsigned clock_rate, 50 unsigned channel_count, 52 51 unsigned samples_per_frame, 53 52 unsigned tail_ms, 54 unsigned latency_ms,55 53 unsigned options, 56 54 void **p_state ) … … 60 58 61 59 PJ_UNUSED_ARG(clock_rate); 60 PJ_UNUSED_ARG(channel_count); 62 61 PJ_UNUSED_ARG(options); 63 PJ_UNUSED_ARG(latency_ms);64 62 65 63 ec = PJ_POOL_ZALLOC_T(pool, struct echo_supp); … … 92 90 93 91 /* 94 * Let the AEC knows that a frame has been played to the speaker.92 * Reset 95 93 */ 96 PJ_DEF(pj_status_t) echo_supp_playback( void *state, 97 pj_int16_t *play_frm ) 94 PJ_DEF(void) echo_supp_reset(void *state) 98 95 { 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; 119 98 } 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!=0142 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 #else148 pjmedia_zero_samples(rec_frm, ec->samples_per_frame);149 #endif150 }151 152 return PJ_SUCCESS;153 }154 155 99 156 100 /*
Note: See TracChangeset
for help on using the changeset viewer.