Changeset 241:4eec3ed19919 in mediastreamer2
- Timestamp:
- Feb 5, 2009 6:45:02 PM (4 years ago)
- Branch:
- default
- Location:
- linphone/mediastreamer2
- Files:
-
- 2 edited
-
include/mediastreamer2/msfilter.h (modified) (1 diff)
-
src/msconf.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linphone/mediastreamer2/include/mediastreamer2/msfilter.h
r205 r241 389 389 #define MS_FILTER_ENABLE_AGC MS_FILTER_BASE_METHOD(20,int) 390 390 #define MS_FILTER_SET_PLAYBACKDELAY MS_FILTER_BASE_METHOD(21,int) 391 #define MS_FILTER_ENABLE_HALFDUPLEX MS_FILTER_BASE_METHOD(22,int) 392 #define MS_FILTER_SET_VAD_PROB_START MS_FILTER_BASE_METHOD(23,int) 393 #define MS_FILTER_SET_VAD_PROB_CONTINUE MS_FILTER_BASE_METHOD(24,int) 394 391 395 /** @} */ 392 396 -
linphone/mediastreamer2/src/msconf.c
r205 r241 45 45 bool_t has_contributed; 46 46 bool_t is_used; 47 48 int is_speaking; 49 47 50 int count; 48 51 int missed; … … 63 66 int enable_directmode; 64 67 int enable_vad; 68 69 int enable_halfduplex; 70 int vad_prob_start; 71 int vad_prob_continue; 72 65 73 int agc_level; 66 74 int mix_mode; … … 74 82 75 83 static void channel_init(ConfState *s, Channel *chan, int pos){ 84 memset(chan, 0, sizeof(Channel)); 76 85 ms_bufferizer_init(&chan->buff); 77 86 #ifndef DISABLE_SPEEX … … 92 101 speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_SET_VAD, &val); 93 102 } 103 else if (pos==0 && s->enable_halfduplex>0) 104 { 105 val=1; 106 speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_SET_VAD, &val); 107 val = s->vad_prob_start; // xx% 108 speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_SET_PROB_START, &val); 109 val = s->vad_prob_continue; // xx% 110 speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_SET_PROB_CONTINUE, &val); 111 } 112 94 113 /* enable AGC only on local soundcard */ 95 114 if (s->agc_level>0 && pos==0) … … 250 269 251 270 /* skip soundread and short buffer entry */ 252 #if 0253 if (i>0254 && ms_bufferizer_get_avail(&chan->buff)>=s->conf_gran*s->adaptative_msconf_buf)255 {256 while (ms_bufferizer_get_avail(&chan->buff)>=s->conf_gran*2)257 #endif258 271 if (i>0 259 272 && ms_bufferizer_get_avail(&chan->buff)> s->conf_gran … … 283 296 } 284 297 285 for(j=0;j<s->conf_nsamples;++j){ 286 s->sum[j]+=chan->input[j]; 287 } 288 chan->has_contributed=TRUE; 298 if (s->channels[0].is_speaking<=0) 299 { 300 for(j=0;j<s->conf_nsamples;++j){ 301 s->sum[j]+=chan->input[j]; 302 } 303 chan->has_contributed=TRUE; 304 } 289 305 chan->stat_processed++; 290 306 } … … 297 313 int vad; 298 314 vad = speex_preprocess(chan->speex_pp, (short*)chan->input, NULL); 299 } 300 else if (chan->speex_pp!=NULL && s->enable_vad==TRUE) 301 { 302 speex_preprocess_estimate_update(chan->speex_pp, (short*)chan->input); 303 } 304 #endif 305 306 for(j=0;j<s->conf_nsamples;++j){ 307 s->sum[j]+=chan->input[j]; 308 } 309 chan->has_contributed=TRUE; 315 if (s->enable_halfduplex>0) 316 { 317 if (vad>0) 318 { 319 /* speech detected */ 320 chan->is_speaking++; 321 if (chan->is_speaking>5) 322 chan->is_speaking=5; 323 } 324 else 325 { 326 chan->is_speaking--; 327 if (chan->is_speaking<-5) 328 chan->is_speaking=-5; 329 } 330 if (chan->is_speaking<=0) 331 ms_message("silence on! (%i)", chan->is_speaking); 332 else 333 ms_message("speech on! (%i)", chan->is_speaking); 334 } 335 } 336 else if (chan->speex_pp!=NULL && s->enable_vad==TRUE) 337 { 338 speex_preprocess_estimate_update(chan->speex_pp, (short*)chan->input); 339 } 340 #endif 341 342 if (i==0 343 || s->channels[0].is_speaking<=0) 344 { 345 for(j=0;j<s->conf_nsamples;++j){ 346 s->sum[j]+=chan->input[j]; 347 } 348 chan->has_contributed=TRUE; 349 } 310 350 chan->stat_processed++; 311 351 } else { … … 445 485 int i; 446 486 ConfState *s=(ConfState*)f->data; 447 Channel *chan; 448 /*read from all inputs and put into bufferizers*/ 449 for (i=0;i<CONF_MAX_PINS;++i){ 450 if (f->inputs[i]!=NULL){ 451 chan=&s->channels[i]; 452 ms_bufferizer_uninit(&chan->buff); 453 ms_bufferizer_init(&chan->buff); 454 } 455 } 456 } 487 for (i=0;i<CONF_MAX_PINS;i++) 488 channel_uninit(&s->channels[i]); 489 for (i=0;i<CONF_MAX_PINS;i++) 490 channel_init(s, &s->channels[i], i); 491 } 492 457 493 static int msconf_set_sr(MSFilter *f, void *arg){ 458 494 ConfState *s=(ConfState*)f->data; … … 479 515 int i; 480 516 s->agc_level = *(int*)arg; 517 518 for (i=0;i<CONF_MAX_PINS;i++) 519 channel_uninit(&s->channels[i]); 520 for (i=0;i<CONF_MAX_PINS;i++) 521 channel_init(s, &s->channels[i], i); 522 return 0; 523 } 524 525 static int msconf_enable_halfduplex(MSFilter *f, void *arg){ 526 ConfState *s=(ConfState*)f->data; 527 int i; 528 s->enable_halfduplex = *(int*)arg; 529 530 for (i=0;i<CONF_MAX_PINS;i++) 531 channel_uninit(&s->channels[i]); 532 for (i=0;i<CONF_MAX_PINS;i++) 533 channel_init(s, &s->channels[i], i); 534 return 0; 535 } 536 537 static int msconf_set_vad_prob_start(MSFilter *f, void *arg){ 538 ConfState *s=(ConfState*)f->data; 539 int i; 540 s->vad_prob_start = *(int*)arg; 541 542 for (i=0;i<CONF_MAX_PINS;i++) 543 channel_uninit(&s->channels[i]); 544 for (i=0;i<CONF_MAX_PINS;i++) 545 channel_init(s, &s->channels[i], i); 546 return 0; 547 } 548 549 static int msconf_set_vad_prob_continue(MSFilter *f, void *arg){ 550 ConfState *s=(ConfState*)f->data; 551 int i; 552 s->vad_prob_continue = *(int*)arg; 481 553 482 554 for (i=0;i<CONF_MAX_PINS;i++) … … 555 627 { MS_FILTER_GET_STAT_MISSED, msconf_get_stat_missed }, 556 628 { MS_FILTER_GET_STAT_OUTPUT, msconf_get_stat_processed }, 629 630 { MS_FILTER_ENABLE_HALFDUPLEX, msconf_enable_halfduplex }, 631 { MS_FILTER_SET_VAD_PROB_START, msconf_set_vad_prob_start }, 632 { MS_FILTER_SET_VAD_PROB_CONTINUE, msconf_set_vad_prob_continue }, 557 633 { 0 , NULL} 558 634 };
Note: See TracChangeset
for help on using the changeset viewer.
