Changeset 867 for pjproject/trunk
- Timestamp:
- Dec 26, 2006 9:18:11 PM (18 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/codec.h
r637 r867 315 315 */ 316 316 pj_status_t (*open)(pjmedia_codec *codec, 317 pjmedia_codec_param *param );317 const pjmedia_codec_param *param ); 318 318 319 319 /** … … 327 327 pj_status_t (*close)(pjmedia_codec *codec); 328 328 329 /** 330 * Modify the codec parameter after the codec is open. 331 * Note that not all codec parameters can be modified during run-time. 332 * When the parameter cannot be changed, this function will return 333 * non-PJ_SUCCESS, and the original parameters will not be changed. 334 * 335 * Application can expect changing trivial codec settings such as 336 * changing VAD setting to succeed. 337 * 338 * @param codec The codec instance. 339 * @param param The new codec parameter. 340 * 341 * @return PJ_SUCCESS on success. 342 */ 343 pj_status_t (*modify)(pjmedia_codec *codec, 344 const pjmedia_codec_param *param ); 329 345 330 346 /** -
pjproject/trunk/pjmedia/include/pjmedia/silencedet.h
r658 r867 186 186 187 187 188 /**189 * Declaration linear2ulaw190 */191 unsigned char linear2ulaw(int pcm_val);192 193 188 194 189 PJ_END_DECL -
pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c
r627 r867 55 55 pj_pool_t *pool ); 56 56 static pj_status_t gsm_codec_open( pjmedia_codec *codec, 57 pjmedia_codec_param *attr );57 const pjmedia_codec_param *attr ); 58 58 static pj_status_t gsm_codec_close( pjmedia_codec *codec ); 59 static pj_status_t gsm_codec_modify(pjmedia_codec *codec, 60 const pjmedia_codec_param *attr ); 59 61 static pj_status_t gsm_codec_parse( pjmedia_codec *codec, 60 62 void *pkt, … … 81 83 &gsm_codec_open, 82 84 &gsm_codec_close, 85 &gsm_codec_modify, 83 86 &gsm_codec_parse, 84 87 &gsm_codec_encode, … … 386 389 */ 387 390 static pj_status_t gsm_codec_open( pjmedia_codec *codec, 388 pjmedia_codec_param *attr )391 const pjmedia_codec_param *attr ) 389 392 { 390 393 struct gsm_data *gsm_data = codec->codec_data; … … 392 395 pj_assert(gsm_data != NULL); 393 396 pj_assert(gsm_data->encoder == NULL && gsm_data->decoder == NULL); 394 395 PJ_UNUSED_ARG(attr);396 397 397 398 gsm_data->encoder = gsm_create(); … … 426 427 gsm_data->decoder = NULL; 427 428 } 429 430 return PJ_SUCCESS; 431 } 432 433 434 /* 435 * Modify codec settings. 436 */ 437 static pj_status_t gsm_codec_modify(pjmedia_codec *codec, 438 const pjmedia_codec_param *attr ) 439 { 440 struct gsm_data *gsm_data = codec->codec_data; 441 442 pj_assert(gsm_data != NULL); 443 pj_assert(gsm_data->encoder == NULL && gsm_data->decoder == NULL); 444 445 gsm_data->vad_enabled = (attr->setting.vad != 0); 446 gsm_data->plc_enabled = (attr->setting.plc != 0); 428 447 429 448 return PJ_SUCCESS; -
pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
r738 r867 64 64 pj_pool_t *pool ); 65 65 static pj_status_t ilbc_codec_open(pjmedia_codec *codec, 66 pjmedia_codec_param *attr );66 const pjmedia_codec_param *attr ); 67 67 static pj_status_t ilbc_codec_close(pjmedia_codec *codec ); 68 static pj_status_t ilbc_codec_modify(pjmedia_codec *codec, 69 const pjmedia_codec_param *attr ); 68 70 static pj_status_t ilbc_codec_parse(pjmedia_codec *codec, 69 71 void *pkt, … … 90 92 &ilbc_codec_open, 91 93 &ilbc_codec_close, 94 &ilbc_codec_modify, 92 95 &ilbc_codec_parse, 93 96 &ilbc_codec_encode, … … 124 127 char obj_name[PJ_MAX_OBJ_NAME]; 125 128 pjmedia_silence_det *vad; 129 pj_bool_t vad_enabled; 126 130 pj_bool_t plc_enabled; 127 131 … … 361 365 */ 362 366 static pj_status_t ilbc_codec_open(pjmedia_codec *codec, 363 pjmedia_codec_param *attr )367 const pjmedia_codec_param *param_attr ) 364 368 { 365 369 struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 370 pjmedia_codec_param attr_copy, *attr; 371 pj_status_t status; 366 372 367 373 pj_assert(ilbc_codec != NULL); 368 374 pj_assert(ilbc_codec->enc_ready == PJ_FALSE && 369 375 ilbc_codec->dec_ready == PJ_FALSE); 376 377 /* Copy param to temporary location since we need to modify fmtp_mode */ 378 pj_memcpy(&attr_copy, param_attr, sizeof(*param_attr)); 379 attr = &attr_copy; 370 380 371 381 /* Decoder mode must be set */ … … 405 415 406 416 /* Save plc flags */ 407 ilbc_codec->plc_enabled = attr->setting.plc != 0; 408 409 /* Create silence detector, if wanted. */ 410 if (attr->setting.vad != 0) { 411 pj_status_t status; 412 status = pjmedia_silence_det_create(ilbc_codec->pool, CLOCK_RATE, 413 ilbc_codec->enc_samples_per_frame, 414 &ilbc_codec->vad); 415 if (status != PJ_SUCCESS) 416 return status; 417 } 417 ilbc_codec->plc_enabled = (attr->setting.plc != 0); 418 419 /* Create silence detector. */ 420 ilbc_codec->vad_enabled = (attr->setting.vad != 0); 421 status = pjmedia_silence_det_create(ilbc_codec->pool, CLOCK_RATE, 422 ilbc_codec->enc_samples_per_frame, 423 &ilbc_codec->vad); 424 if (status != PJ_SUCCESS) 425 return status; 418 426 419 427 PJ_LOG(5,(ilbc_codec->obj_name, … … 439 447 } 440 448 449 /* 450 * Modify codec settings. 451 */ 452 static pj_status_t ilbc_codec_modify(pjmedia_codec *codec, 453 const pjmedia_codec_param *attr ) 454 { 455 struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 456 457 ilbc_codec->plc_enabled = (attr->setting.plc != 0); 458 ilbc_codec->vad_enabled = (attr->setting.vad != 0); 459 460 return PJ_SUCCESS; 461 } 441 462 442 463 /* … … 494 515 495 516 /* Detect silence */ 496 if (ilbc_codec->vad ) {517 if (ilbc_codec->vad_enabled) { 497 518 pj_bool_t is_silence; 498 519 -
pjproject/trunk/pjmedia/src/pjmedia-codec/l16.c
r582 r867 60 60 pj_pool_t *pool ); 61 61 static pj_status_t l16_open( pjmedia_codec *codec, 62 pjmedia_codec_param *attr );62 const pjmedia_codec_param *attr ); 63 63 static pj_status_t l16_close( pjmedia_codec *codec ); 64 static pj_status_t l16_modify(pjmedia_codec *codec, 65 const pjmedia_codec_param *attr ); 64 66 static pj_status_t l16_parse(pjmedia_codec *codec, 65 67 void *pkt, … … 83 85 &l16_open, 84 86 &l16_close, 87 &l16_modify, 85 88 &l16_parse, 86 89 &l16_encode, … … 487 490 488 491 static pj_status_t l16_open(pjmedia_codec *codec, 489 pjmedia_codec_param *attr )492 const pjmedia_codec_param *attr ) 490 493 { 491 494 /* Nothing to do.. */ … … 500 503 /* Nothing to do */ 501 504 return PJ_SUCCESS; 505 } 506 507 static pj_status_t l16_modify(pjmedia_codec *codec, 508 const pjmedia_codec_param *attr ) 509 { 510 /* Don't want to do anything. */ 511 PJ_UNUSED_ARG(codec); 512 PJ_UNUSED_ARG(attr); 513 return PJ_EINVALIDOP; 502 514 } 503 515 -
pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
r807 r867 60 60 pj_pool_t *pool ); 61 61 static pj_status_t spx_codec_open( pjmedia_codec *codec, 62 pjmedia_codec_param *attr );62 const pjmedia_codec_param *attr ); 63 63 static pj_status_t spx_codec_close( pjmedia_codec *codec ); 64 static pj_status_t spx_codec_modify(pjmedia_codec *codec, 65 const pjmedia_codec_param *attr ); 64 66 static pj_status_t spx_codec_parse( pjmedia_codec *codec, 65 67 void *pkt, … … 86 88 &spx_codec_open, 87 89 &spx_codec_close, 90 &spx_codec_modify, 88 91 &spx_codec_parse, 89 92 &spx_codec_encode, … … 545 548 */ 546 549 static pj_status_t spx_codec_open( pjmedia_codec *codec, 547 pjmedia_codec_param *attr )550 const pjmedia_codec_param *attr ) 548 551 { 549 552 struct spx_private *spx; … … 552 555 spx = (struct spx_private*) codec->codec_data; 553 556 id = spx->param_id; 557 558 /* Only supports one frame per packet */ 559 PJ_ASSERT_RETURN(attr->setting.frm_per_pkt==1, PJ_EINVAL); 554 560 555 561 /* … … 626 632 speex_bits_destroy( &spx->dec_bits ); 627 633 } 634 635 return PJ_SUCCESS; 636 } 637 638 639 /* 640 * Modify codec settings. 641 */ 642 static pj_status_t spx_codec_modify(pjmedia_codec *codec, 643 const pjmedia_codec_param *attr ) 644 { 645 struct spx_private *spx; 646 int tmp; 647 648 spx = (struct spx_private*) codec->codec_data; 649 650 /* Only supports one frame per packet */ 651 PJ_ASSERT_RETURN(attr->setting.frm_per_pkt==1, PJ_EINVAL); 652 653 /* VAD */ 654 tmp = (attr->setting.vad != 0); 655 speex_encoder_ctl(spx->enc, SPEEX_SET_VAD, &tmp); 656 speex_encoder_ctl(spx->enc, SPEEX_SET_DTX, &tmp); 657 658 /* PENH */ 659 tmp = attr->setting.penh; 660 speex_decoder_ctl(spx->dec, SPEEX_SET_ENH, &tmp); 628 661 629 662 return PJ_SUCCESS; -
pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
r855 r867 84 84 PJ_UNUSED_ARG(clock_rate); 85 85 PJ_UNUSED_ARG(options); 86 PJ_UNUSED_ARG(latency_ms); 86 87 87 88 ec = pj_pool_zalloc(pool, sizeof(struct echo_supp)); -
pjproject/trunk/pjmedia/src/pjmedia/g711.c
r838 r867 63 63 pj_pool_t *pool ); 64 64 static pj_status_t g711_open( pjmedia_codec *codec, 65 pjmedia_codec_param *attr );65 const pjmedia_codec_param *attr ); 66 66 static pj_status_t g711_close( pjmedia_codec *codec ); 67 static pj_status_t g711_modify(pjmedia_codec *codec, 68 const pjmedia_codec_param *attr ); 67 69 static pj_status_t g711_parse(pjmedia_codec *codec, 68 70 void *pkt, … … 89 91 &g711_open, 90 92 &g711_close, 93 &g711_modify, 91 94 &g711_parse, 92 95 &g711_encode, … … 395 398 396 399 static pj_status_t g711_open(pjmedia_codec *codec, 397 pjmedia_codec_param *attr )400 const pjmedia_codec_param *attr ) 398 401 { 399 402 struct g711_private *priv = codec->codec_data; … … 408 411 PJ_UNUSED_ARG(codec); 409 412 /* Nothing to do */ 413 return PJ_SUCCESS; 414 } 415 416 static pj_status_t g711_modify(pjmedia_codec *codec, 417 const pjmedia_codec_param *attr ) 418 { 419 struct g711_private *priv = codec->codec_data; 420 421 if (attr->info.pt != priv->pt) 422 return PJMEDIA_EINVALIDPT; 423 424 priv->plc_enabled = (attr->setting.plc != 0); 425 priv->vad_enabled = (attr->setting.vad != 0); 426 410 427 return PJ_SUCCESS; 411 428 }
Note: See TracChangeset
for help on using the changeset viewer.