Changeset 2236 for pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
- Timestamp:
- Aug 25, 2008 1:58:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
r2039 r2236 144 144 }; 145 145 146 146 static pj_str_t STR_MODE = {"mode", 4}; 147 147 148 148 /* … … 274 274 attr->setting.plc = 1; 275 275 attr->setting.penh = 1; 276 attr->setting.dec_fmtp_mode = (pj_uint8_t)ilbc_factory.mode; 276 attr->setting.dec_fmtp.cnt = 1; 277 attr->setting.dec_fmtp.param[0].name = STR_MODE; 278 if (ilbc_factory.mode == 30) 279 attr->setting.dec_fmtp.param[0].val = pj_str("30"); 280 else 281 attr->setting.dec_fmtp.param[0].val = pj_str("20"); 277 282 278 283 return PJ_SUCCESS; … … 371 376 struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 372 377 pj_status_t status; 378 unsigned i, dec_fmtp_mode = 0, enc_fmtp_mode = 0; 373 379 374 380 pj_assert(ilbc_codec != NULL); … … 376 382 ilbc_codec->dec_ready == PJ_FALSE); 377 383 384 /* Get decoder mode */ 385 for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) { 386 if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, &STR_MODE) == 0) 387 { 388 dec_fmtp_mode = (unsigned) 389 pj_strtoul(&attr->setting.dec_fmtp.param[i].val); 390 break; 391 } 392 } 393 378 394 /* Decoder mode must be set */ 379 PJ_ASSERT_RETURN(attr->setting.dec_fmtp_mode==20 || 380 attr->setting.dec_fmtp_mode==30, PJMEDIA_CODEC_EINMODE); 395 PJ_ASSERT_RETURN(dec_fmtp_mode == 20 || dec_fmtp_mode == 30, 396 PJMEDIA_CODEC_EINMODE); 397 398 /* Get encoder mode */ 399 for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) { 400 if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name, &STR_MODE) == 0) 401 { 402 enc_fmtp_mode = (unsigned) 403 pj_strtoul(&attr->setting.enc_fmtp.param[i].val); 404 break; 405 } 406 } 381 407 382 408 /* The enc mode must be set in the attribute … … 384 410 * received from remote) 385 411 */ 386 if ( attr->setting.enc_fmtp_mode == 0)387 attr->setting.enc_fmtp_mode = attr->setting.dec_fmtp_mode;388 389 PJ_ASSERT_RETURN( attr->setting.enc_fmtp_mode==20 ||390 attr->setting.enc_fmtp_mode==30, PJMEDIA_CODEC_EINMODE);412 if (enc_fmtp_mode == 0) 413 enc_fmtp_mode = dec_fmtp_mode; 414 415 PJ_ASSERT_RETURN(enc_fmtp_mode==20 || 416 enc_fmtp_mode==30, PJMEDIA_CODEC_EINMODE); 391 417 392 418 /* Update enc_ptime in the param */ 393 if ( attr->setting.enc_fmtp_mode != attr->setting.dec_fmtp_mode) {394 attr->info.enc_ptime = attr->setting.enc_fmtp_mode;419 if (enc_fmtp_mode != dec_fmtp_mode) { 420 attr->info.enc_ptime = (pj_uint16_t)enc_fmtp_mode; 395 421 } else { 396 422 attr->info.enc_ptime = 0; … … 398 424 399 425 /* Create enc */ 400 ilbc_codec->enc_frame_size = initEncode(&ilbc_codec->enc, 401 attr->setting.enc_fmtp_mode); 402 ilbc_codec->enc_samples_per_frame = CLOCK_RATE*attr->setting.enc_fmtp_mode/ 403 1000; 426 ilbc_codec->enc_frame_size = initEncode(&ilbc_codec->enc, enc_fmtp_mode); 427 ilbc_codec->enc_samples_per_frame = CLOCK_RATE * enc_fmtp_mode / 1000; 404 428 ilbc_codec->enc_ready = PJ_TRUE; 405 429 406 430 /* Create decoder */ 407 431 ilbc_codec->dec_samples_per_frame = initDecode(&ilbc_codec->dec, 408 attr->setting.dec_fmtp_mode,432 dec_fmtp_mode, 409 433 attr->setting.penh); 410 if ( attr->setting.dec_fmtp_mode == 20)434 if (dec_fmtp_mode == 20) 411 435 ilbc_codec->dec_frame_size = 38; 412 else if ( attr->setting.dec_fmtp_mode == 30)436 else if (dec_fmtp_mode == 30) 413 437 ilbc_codec->dec_frame_size = 50; 414 438 else { … … 436 460 PJ_LOG(5,(ilbc_codec->obj_name, 437 461 "iLBC codec opened, encoder mode=%d, decoder mode=%d", 438 attr->setting.enc_fmtp_mode, attr->setting.dec_fmtp_mode));462 enc_fmtp_mode, dec_fmtp_mode)); 439 463 440 464 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.