Changeset 411 for pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
- Timestamp:
- Apr 27, 2006 10:36:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
r320 r411 57 57 58 58 /* Prototypes for Speex implementation. */ 59 static pj_status_t spx_codec_default_attr(pjmedia_codec *codec,60 pjmedia_codec_param *attr);61 59 static pj_status_t spx_codec_init( pjmedia_codec *codec, 62 60 pj_pool_t *pool ); … … 81 79 static pjmedia_codec_op spx_op = 82 80 { 83 &spx_codec_default_attr,84 81 &spx_codec_init, 85 82 &spx_codec_open, … … 231 228 spx_factory.speex_param[PARAM_NB].enabled = 232 229 ((options & PJMEDIA_SPEEX_NO_NB) == 0); 233 spx_factory.speex_param[PARAM_NB].pt = 102;230 spx_factory.speex_param[PARAM_NB].pt = PJMEDIA_RTP_PT_SPEEX_NB; 234 231 spx_factory.speex_param[PARAM_NB].mode = &speex_nb_mode; 235 232 spx_factory.speex_param[PARAM_NB].clock_rate = 8000; … … 239 236 spx_factory.speex_param[PARAM_WB].enabled = 240 237 ((options & PJMEDIA_SPEEX_NO_WB) == 0); 241 spx_factory.speex_param[PARAM_WB].pt = 103;238 spx_factory.speex_param[PARAM_WB].pt = PJMEDIA_RTP_PT_SPEEX_WB; 242 239 spx_factory.speex_param[PARAM_WB].mode = &speex_wb_mode; 243 240 spx_factory.speex_param[PARAM_WB].clock_rate = 16000; … … 247 244 spx_factory.speex_param[PARAM_UWB].enabled = 248 245 ((options & PJMEDIA_SPEEX_NO_UWB) == 0); 249 spx_factory.speex_param[PARAM_UWB].pt = 104;246 spx_factory.speex_param[PARAM_UWB].pt = PJMEDIA_RTP_PT_SPEEX_UWB; 250 247 spx_factory.speex_param[PARAM_UWB].mode = &speex_uwb_mode; 251 248 spx_factory.speex_param[PARAM_UWB].clock_rate = 32000; … … 359 356 /* Check clock-rate */ 360 357 for (i=0; i<PJ_ARRAY_SIZE(spx_factory.speex_param); ++i) { 361 if (info-> sample_rate == spx_factory.speex_param[i].clock_rate) {358 if (info->clock_rate == spx_factory.speex_param[i].clock_rate) { 362 359 /* Okay, let's Speex! */ 363 360 return PJ_SUCCESS; … … 382 379 pj_memset(attr, 0, sizeof(pjmedia_codec_param)); 383 380 attr->pt = id->pt; 384 385 if (id->sample_rate <= 8000) { 386 attr->sample_rate = spx_factory.speex_param[PARAM_NB].clock_rate; 381 attr->channel_cnt = 1; 382 383 if (id->clock_rate <= 8000) { 384 attr->clock_rate = spx_factory.speex_param[PARAM_NB].clock_rate; 387 385 attr->avg_bps = spx_factory.speex_param[PARAM_NB].bitrate; 388 386 389 } else if (id-> sample_rate <= 16000) {390 attr-> sample_rate = spx_factory.speex_param[PARAM_WB].clock_rate;387 } else if (id->clock_rate <= 16000) { 388 attr->clock_rate = spx_factory.speex_param[PARAM_WB].clock_rate; 391 389 attr->avg_bps = spx_factory.speex_param[PARAM_WB].bitrate; 392 390 393 391 } else { 394 392 /* Wow.. somebody is doing ultra-wideband. Cool...! */ 395 attr-> sample_rate = spx_factory.speex_param[PARAM_UWB].clock_rate;393 attr->clock_rate = spx_factory.speex_param[PARAM_UWB].clock_rate; 396 394 attr->avg_bps = spx_factory.speex_param[PARAM_UWB].bitrate; 397 395 } … … 402 400 403 401 /* Default flags. */ 404 attr->cng _enabled= 1;405 attr->concl _enabled= 1;406 attr->hpf _enabled= 1;407 attr->lpf _enabled=1 ;408 attr->penh _enabled=1 ;402 attr->cng = 1; 403 attr->concl = 1; 404 attr->hpf = 1; 405 attr->lpf =1 ; 406 attr->penh =1 ; 409 407 410 408 /* Default, set VAD off as it caused voice chip off */ 411 attr->vad _enabled= 0;409 attr->vad = 0; 412 410 413 411 return PJ_SUCCESS; … … 443 441 codecs[*count].pt = spx_factory.speex_param[i].pt; 444 442 codecs[*count].type = PJMEDIA_TYPE_AUDIO; 445 codecs[*count].sample_rate = spx_factory.speex_param[i].clock_rate; 443 codecs[*count].clock_rate = spx_factory.speex_param[i].clock_rate; 444 codecs[*count].channel_cnt = 1; 446 445 447 446 ++*count; … … 487 486 spx->dec = NULL; 488 487 489 if (id-> sample_rate <= 8000)488 if (id->clock_rate <= 8000) 490 489 spx->param_id = PARAM_NB; 491 else if (id-> sample_rate <= 16000)490 else if (id->clock_rate <= 16000) 492 491 spx->param_id = PARAM_WB; 493 492 else … … 521 520 522 521 return PJ_SUCCESS; 523 }524 525 /*526 * Get codec default attributes.527 */528 static pj_status_t spx_codec_default_attr( pjmedia_codec *codec,529 pjmedia_codec_param *attr)530 {531 struct spx_private *spx;532 pjmedia_codec_info info;533 534 spx = (struct spx_private*) codec->codec_data;535 536 info.encoding_name = pj_str("speex");537 info.pt = 200; /* Don't care */538 info.sample_rate = spx_factory.speex_param[spx->param_id].clock_rate;539 info.type = PJMEDIA_TYPE_AUDIO;540 541 return spx_default_attr( codec->factory, &info, attr);542 522 } 543 523 … … 580 560 581 561 /* Sampling rate. */ 582 tmp = attr-> sample_rate;562 tmp = attr->clock_rate; 583 563 speex_encoder_ctl(spx->enc, SPEEX_SET_SAMPLING_RATE, 584 564 &spx_factory.speex_param[id].clock_rate); 585 565 586 566 /* VAD */ 587 tmp = attr->vad _enabled;567 tmp = attr->vad; 588 568 speex_encoder_ctl(spx->enc, SPEEX_SET_VAD, &tmp); 589 569 … … 609 589 610 590 /* PENH */ 611 tmp = attr->penh _enabled;591 tmp = attr->penh; 612 592 speex_decoder_ctl(spx->dec, SPEEX_SET_ENH, &tmp); 613 593
Note: See TracChangeset
for help on using the changeset viewer.