Changeset 2834 for pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
- Timestamp:
- Jul 15, 2009 5:55:16 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
r2760 r2834 377 377 struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 378 378 pj_status_t status; 379 unsigned i, dec_fmtp_mode = 0, enc_fmtp_mode = 0; 379 unsigned i; 380 pj_uint16_t dec_fmtp_mode = DEFAULT_MODE, 381 enc_fmtp_mode = DEFAULT_MODE; 380 382 381 383 pj_assert(ilbc_codec != NULL); … … 387 389 if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, &STR_MODE) == 0) 388 390 { 389 dec_fmtp_mode = ( unsigned)391 dec_fmtp_mode = (pj_uint16_t) 390 392 pj_strtoul(&attr->setting.dec_fmtp.param[i].val); 391 393 break; … … 401 403 if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name, &STR_MODE) == 0) 402 404 { 403 enc_fmtp_mode = ( unsigned)405 enc_fmtp_mode = (pj_uint16_t) 404 406 pj_strtoul(&attr->setting.enc_fmtp.param[i].val); 405 407 break; … … 407 409 } 408 410 409 /* The enc mode must be set in the attribute 410 * (from the mode parameter in fmtp attribute in the SDP 411 * received from remote) 411 PJ_ASSERT_RETURN(enc_fmtp_mode==20 || enc_fmtp_mode==30, 412 PJMEDIA_CODEC_EINMODE); 413 414 /* Both sides of a bi-directional session MUST use the same "mode" value. 415 * In this point, possible values are only 20 or 30, so when encoder and 416 * decoder modes are not same, just use the default mode, it is 30. 412 417 */ 413 if (enc_fmtp_mode == 0)414 enc_fmtp_mode = dec_fmtp_mode;415 416 PJ_ASSERT_RETURN(enc_fmtp_mode==20 ||417 enc_fmtp_mode==30, PJMEDIA_CODEC_EINMODE);418 419 /* Update enc_ptime in the param */420 418 if (enc_fmtp_mode != dec_fmtp_mode) { 421 attr->info.enc_ptime = (pj_uint16_t)enc_fmtp_mode; 422 } else { 423 attr->info.enc_ptime = 0; 424 } 425 426 /* Create enc */ 419 enc_fmtp_mode = dec_fmtp_mode = DEFAULT_MODE; 420 PJ_LOG(4,(ilbc_codec->obj_name, 421 "Normalized iLBC encoder and decoder modes to %d", 422 DEFAULT_MODE)); 423 } 424 425 /* Update some attributes based on negotiated mode. */ 426 attr->info.avg_bps = (dec_fmtp_mode == 30? 13333 : 15200); 427 attr->info.frm_ptime = dec_fmtp_mode; 428 429 /* Create encoder */ 427 430 ilbc_codec->enc_frame_size = initEncode(&ilbc_codec->enc, enc_fmtp_mode); 428 431 ilbc_codec->enc_samples_per_frame = CLOCK_RATE * enc_fmtp_mode / 1000; … … 433 436 dec_fmtp_mode, 434 437 attr->setting.penh); 435 if (dec_fmtp_mode == 20) 436 ilbc_codec->dec_frame_size = 38; 437 else if (dec_fmtp_mode == 30) 438 ilbc_codec->dec_frame_size = 50; 439 else { 440 pj_assert(!"Invalid iLBC mode"); 441 ilbc_codec->dec_frame_size = ilbc_codec->enc_frame_size; 442 } 438 ilbc_codec->dec_frame_size = (dec_fmtp_mode == 20? 38 : 50); 443 439 ilbc_codec->dec_ready = PJ_TRUE; 444 440 … … 460 456 461 457 PJ_LOG(5,(ilbc_codec->obj_name, 462 "iLBC codec opened, encoder mode=%d, decoder mode=%d", 463 enc_fmtp_mode, dec_fmtp_mode)); 458 "iLBC codec opened, mode=%d", dec_fmtp_mode)); 464 459 465 460 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.