Changeset 655 for pjproject/trunk
- Timestamp:
- Aug 6, 2006 2:15:47 PM (18 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/conference.h
r633 r655 294 294 295 295 /** 296 * Get total number of ports connections currently set up in the bridge. 297 * 298 * @param conf The conference bridge. 299 * 300 * @return PJ_SUCCESS on success. 301 */ 302 PJ_DECL(unsigned) pjmedia_conf_get_connect_count(pjmedia_conf *conf); 303 304 305 /** 296 306 * Remove the specified port from the conference bridge. 297 307 * -
pjproject/trunk/pjmedia/include/pjmedia/silencedet.h
r518 r655 71 71 unsigned samples_per_frame, 72 72 pjmedia_silence_det **p_sd ); 73 74 75 /** 76 * Set silence detector name to identify the particular silence detector 77 * instance in the log. 78 * 79 * @param sd The silence detector. 80 * @param name Name. 81 * 82 * @return PJ_SUCCESS on success. 83 */ 84 PJ_DECL(pj_status_t) pjmedia_silence_det_set_name(pjmedia_silence_det *sd, 85 const char *name); 73 86 74 87 … … 110 123 * signal is reported. If -1 is specified, then 111 124 * the default value will be used. The default is 112 * one frame.125 * equal to one frame. 113 126 * @param recalc_time The interval to recalculate signal and silence 114 127 * proportion and to readjust the silence threshold … … 145 158 * of the input samples. 146 159 * 147 * @return PJ_SUCCESS on success.160 * @return Non zero if signal is silence. 148 161 */ 149 162 PJ_DECL(pj_bool_t) pjmedia_silence_det_detect( pjmedia_silence_det *sd, … … 174 187 * @param level Signal level. 175 188 * 176 * @return PJ_SUCCESS on success.189 * @return Non zero if signal is silence. 177 190 */ 178 191 PJ_DECL(pj_bool_t) pjmedia_silence_det_apply( pjmedia_silence_det *sd, -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r635 r655 222 222 223 223 /* Set name */ 224 pj_strdup (pool, &conf_port->name, name);224 pj_strdup_with_null(pool, &conf_port->name, name); 225 225 226 226 /* Default has tx and rx enabled. */ … … 259 259 pjmedia_silence_det_set_fixed(conf_port->vad, 2); 260 260 261 /* Set VAD name */ 262 pjmedia_silence_det_set_name(conf_port->vad, conf_port->name.ptr); 261 263 262 264 /* If port's clock rate is different than conference's clock rate, … … 895 897 896 898 return PJ_SUCCESS; 899 } 900 901 902 /* 903 * Get total number of ports connections currently set up in the bridge. 904 */ 905 PJ_DECL(unsigned) pjmedia_conf_get_connect_count(pjmedia_conf *conf) 906 { 907 return conf->connect_cnt; 897 908 } 898 909 -
pjproject/trunk/pjmedia/src/pjmedia/echo_common.c
r653 r655 119 119 120 120 #else 121 static struct ec_operations aec_op = echo_supp_op; 121 #define aec_op echo_supp_op 122 122 #endif 123 123 -
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 } -
pjproject/trunk/pjmedia/src/pjmedia/silencedet.c
r465 r655 39 39 struct pjmedia_silence_det 40 40 { 41 char objname[PJ_MAX_OBJ_NAME]; /**< VAD name. */ 42 41 43 int mode; /**< VAD mode. */ 42 44 unsigned ptime; /**< Frame time, in msec. */ … … 71 73 sd = pj_pool_zalloc(pool, sizeof(struct pjmedia_silence_det)); 72 74 75 pj_ansi_strncpy(sd->objname, THIS_FILE, PJ_MAX_OBJ_NAME); 76 sd->objname[PJ_MAX_OBJ_NAME-1] = '\0'; 77 73 78 sd->ptime = samples_per_frame * 1000 / clock_rate; 74 79 sd->signal_cnt = 0; … … 87 92 return PJ_SUCCESS; 88 93 } 94 95 96 PJ_DEF(pj_status_t) pjmedia_silence_det_set_name( pjmedia_silence_det *sd, 97 const char *name) 98 { 99 PJ_ASSERT_RETURN(sd && name, PJ_EINVAL); 100 101 pj_ansi_snprintf(sd->objname, PJ_MAX_OBJ_NAME, name, sd); 102 sd->objname[PJ_MAX_OBJ_NAME-1] = '\0'; 103 return PJ_SUCCESS; 104 } 105 89 106 90 107 PJ_DEF(pj_status_t) pjmedia_silence_det_set_adaptive(pjmedia_silence_det *sd, … … 234 251 if (sd->mode == VAD_MODE_ADAPTIVE) { 235 252 pj_bool_t updated = PJ_TRUE; 236 unsigned pct_signal ;253 unsigned pct_signal, new_threshold = sd->cur_threshold; 237 254 238 255 /* Get percentage of signal */ … … 242 259 /* Adjust according to signal/silence proportions. */ 243 260 if (pct_signal > 95) { 244 sd->cur_threshold += (sd->weakest_signal - sd->cur_threshold)/4;261 new_threshold += (sd->weakest_signal - sd->cur_threshold)/4; 245 262 } else if (pct_signal < 5) { 246 sd->cur_threshold = (sd->cur_threshold+sd->loudest_silence)/2+1;263 new_threshold = (sd->cur_threshold+sd->loudest_silence)/2+1; 247 264 } else if (pct_signal > 90) { 248 sd->cur_threshold++;265 new_threshold++; 249 266 } else if (pct_signal < 10) { 250 sd->cur_threshold--;267 new_threshold--; 251 268 } else { 252 269 updated = PJ_FALSE; 253 270 } 254 271 255 if (updated) { 256 PJ_LOG(5,(THIS_FILE, "Vad cur_threshold updated to %d", 272 if (updated && sd->cur_threshold != new_threshold) { 273 sd->cur_threshold = new_threshold; 274 PJ_LOG(5,(sd->objname, "Vad cur_threshold updated to %d", 257 275 sd->cur_threshold)); 258 276 }
Note: See TracChangeset
for help on using the changeset viewer.