Changeset 1983 for pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c
- Timestamp:
- Jun 5, 2008 10:50:40 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c
r1846 r1983 516 516 { 517 517 struct gsm_data *gsm_data = (struct gsm_data*) codec->codec_data; 518 519 pj_assert(gsm_data != NULL); 520 PJ_ASSERT_RETURN(input && output, PJ_EINVAL); 521 522 if (output_buf_len < 33) 523 return PJMEDIA_CODEC_EFRMTOOSHORT; 524 525 PJ_ASSERT_RETURN(input->size==320, PJMEDIA_CODEC_EPCMFRMINLEN); 518 pj_int16_t *pcm_in; 519 unsigned in_size; 520 521 pj_assert(gsm_data && input && output); 522 523 pcm_in = (pj_int16_t*)input->buf; 524 in_size = input->size; 525 526 PJ_ASSERT_RETURN(in_size % 320 == 0, PJMEDIA_CODEC_EPCMFRMINLEN); 527 PJ_ASSERT_RETURN(output_buf_len >= 33 * in_size/320, 528 PJMEDIA_CODEC_EFRMTOOSHORT); 526 529 527 530 /* Detect silence */ … … 552 555 553 556 /* Encode */ 554 gsm_encode(gsm_data->encoder, (short*)input->buf, 555 (unsigned char*)output->buf); 556 557 output->size = 33; 557 output->size = 0; 558 while (in_size >= 320) { 559 gsm_encode(gsm_data->encoder, pcm_in, 560 (unsigned char*)output->buf + output->size); 561 pcm_in += 160; 562 output->size += 33; 563 in_size -= 320; 564 } 565 558 566 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 559 567
Note: See TracChangeset
for help on using the changeset viewer.