Changeset 655 for pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
- Timestamp:
- Aug 6, 2006 2:15:47 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
r653 r655 28 28 29 29 #define THIS_FILE "echo_suppress.c" 30 #define PJMEDIA_ECHO_SUPPRESS_THRESHOLD 2030 #define PJMEDIA_ECHO_SUPPRESS_THRESHOLD PJMEDIA_SILENCE_DET_THRESHOLD 31 31 32 32 … … 36 36 typedef struct echo_supp 37 37 { 38 unsigned threshold;39 pj _bool_t suppressing;40 pj_time_val last_signal;41 unsigned samples_per_frame;42 unsigned tail_ms;38 pj_bool_t suppressing; 39 pjmedia_silence_det *sd; 40 pj_time_val last_signal; 41 unsigned samples_per_frame; 42 unsigned tail_ms; 43 43 } echo_supp; 44 44 … … 79 79 { 80 80 echo_supp *ec; 81 pj_status_t status; 81 82 82 83 PJ_UNUSED_ARG(clock_rate); … … 84 85 85 86 ec = pj_pool_zalloc(pool, sizeof(struct echo_supp)); 86 ec->threshold = PJMEDIA_ECHO_SUPPRESS_THRESHOLD;87 87 ec->samples_per_frame = samples_per_frame; 88 88 ec->tail_ms = tail_ms; 89 90 status = pjmedia_silence_det_create(pool, clock_rate, samples_per_frame, 91 &ec->sd); 92 if (status != PJ_SUCCESS) 93 return status; 94 95 pjmedia_silence_det_set_name(ec->sd, "ecsu%p"); 96 pjmedia_silence_det_set_adaptive(ec->sd, PJMEDIA_ECHO_SUPPRESS_THRESHOLD); 97 pjmedia_silence_det_set_params(ec->sd, 0, 500, 3000); 89 98 90 99 *p_state = ec; … … 110 119 { 111 120 echo_supp *ec = state; 121 pj_bool_t silence; 112 122 pj_bool_t last_suppressing = ec->suppressing; 113 unsigned level;114 123 115 level = pjmedia_calc_avg_signal(play_frm, ec->samples_per_frame);116 level = linear2ulaw(level) ^ 0xff;124 silence = pjmedia_silence_det_detect(ec->sd, play_frm, 125 ec->samples_per_frame, NULL); 117 126 118 if (level >= ec->threshold) { 127 ec->suppressing = !silence; 128 129 if (ec->suppressing) { 119 130 pj_gettimeofday(&ec->last_signal); 120 ec->suppressing = 1;121 } else {122 ec->suppressing = 0;123 131 } 124 132 … … 169 177 { 170 178 echo_supp *ec = state; 171 unsigned level;179 pj_bool_t silence; 172 180 173 181 PJ_UNUSED_ARG(options); 174 182 PJ_UNUSED_ARG(reserved); 175 183 176 level = pjmedia_calc_avg_signal(play_frm, ec->samples_per_frame);177 level = linear2ulaw(level) ^ 0xff;184 silence = pjmedia_silence_det_detect(ec->sd, play_frm, 185 ec->samples_per_frame, NULL); 178 186 179 if ( level >= ec->threshold) {187 if (!silence) { 180 188 pjmedia_zero_samples(rec_frm, ec->samples_per_frame); 181 189 }
Note: See TracChangeset
for help on using the changeset viewer.