Changeset 5182 for pjproject/trunk
- Timestamp:
- Sep 28, 2015 5:54:25 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
r4537 r5182 670 670 pj_int16_t *pcm_in; 671 671 pj_size_t nsamples; 672 #if defined(PJMEDIA_ILBC_CODEC_USE_COREAUDIO)&& PJMEDIA_ILBC_CODEC_USE_COREAUDIO673 UInt32 npackets;674 OSStatus err;675 AudioBufferList theABL;676 #endif677 672 678 673 pj_assert(ilbc_codec && input && output); … … 715 710 /* Encode */ 716 711 output->size = 0; 717 #if defined(PJMEDIA_ILBC_CODEC_USE_COREAUDIO)&& PJMEDIA_ILBC_CODEC_USE_COREAUDIO 718 npackets = nsamples / ilbc_codec->enc_samples_per_frame; 719 720 theABL.mNumberBuffers = 1; 721 theABL.mBuffers[0].mNumberChannels = 1; 722 theABL.mBuffers[0].mDataByteSize = output_buf_len; 723 theABL.mBuffers[0].mData = output->buf; 724 725 ilbc_codec->enc_total_packets = npackets; 726 ilbc_codec->enc_buffer = (char *)input->buf; 727 ilbc_codec->enc_buffer_offset = 0; 728 729 err = AudioConverterFillComplexBuffer(ilbc_codec->enc, encodeDataProc, 730 ilbc_codec, &npackets, 731 &theABL, NULL); 732 if (err == noErr) { 733 output->size = npackets * ilbc_codec->enc_frame_size; 734 } 712 while (nsamples >= ilbc_codec->enc_samples_per_frame) { 713 #if defined(PJMEDIA_ILBC_CODEC_USE_COREAUDIO)&& PJMEDIA_ILBC_CODEC_USE_COREAUDIO 714 OSStatus err; 715 AudioBufferList theABL; 716 UInt32 npackets = 1; 717 718 theABL.mNumberBuffers = 1; 719 theABL.mBuffers[0].mNumberChannels = 1; 720 theABL.mBuffers[0].mDataByteSize = output_buf_len; 721 theABL.mBuffers[0].mData = output->buf + output->size; 722 723 ilbc_codec->enc_total_packets = 1; 724 ilbc_codec->enc_buffer = (char *)input->buf; 725 ilbc_codec->enc_buffer_offset = input->size - (nsamples << 1); 726 727 err = AudioConverterFillComplexBuffer(ilbc_codec->enc, encodeDataProc, 728 ilbc_codec, &npackets, 729 &theABL, NULL); 730 if (err == noErr && npackets) { 731 output->size += npackets * ilbc_codec->enc_frame_size; 732 } 735 733 #else 736 while (nsamples >= ilbc_codec->enc_samples_per_frame) { 737 unsigned i; 738 739 /* Convert to float */ 740 for (i=0; i<ilbc_codec->enc_samples_per_frame; ++i) { 741 ilbc_codec->enc_block[i] = (float) (*pcm_in++); 742 } 743 744 iLBC_encode((unsigned char *)output->buf + output->size, 745 ilbc_codec->enc_block, 746 &ilbc_codec->enc); 747 748 output->size += ilbc_codec->enc.no_of_bytes; 734 unsigned i; 735 736 /* Convert to float */ 737 for (i=0; i<ilbc_codec->enc_samples_per_frame; ++i) { 738 ilbc_codec->enc_block[i] = (float) (*pcm_in++); 739 } 740 741 iLBC_encode((unsigned char *)output->buf + output->size, 742 ilbc_codec->enc_block, 743 &ilbc_codec->enc); 744 745 output->size += ilbc_codec->enc.no_of_bytes; 746 #endif 747 749 748 nsamples -= ilbc_codec->enc_samples_per_frame; 750 749 } 751 #endif752 750 753 751 output->type = PJMEDIA_FRAME_TYPE_AUDIO;
Note: See TracChangeset
for help on using the changeset viewer.