diff options
author | Andreas Huber <andih@google.com> | 2012-05-17 12:42:18 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-17 12:42:18 -0700 |
commit | b33eaec751d712c237e1c1b53a18a259456fa682 (patch) | |
tree | 901552bb8293298e45fe3763e2845ee9e90f9232 /media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp | |
parent | 35c53ccdc1be56879ba25956bf2284d2cff7c3c4 (diff) | |
parent | 8647bbe4420ca487467318404127f52c567e346b (diff) | |
download | frameworks_av-b33eaec751d712c237e1c1b53a18a259456fa682.zip frameworks_av-b33eaec751d712c237e1c1b53a18a259456fa682.tar.gz frameworks_av-b33eaec751d712c237e1c1b53a18a259456fa682.tar.bz2 |
Merge "Prefix MPEG4-generic audio data with ADTS headers" into jb-dev
Diffstat (limited to 'media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp')
-rw-r--r-- | media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp b/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp index 687d72b..eefceba 100644 --- a/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp +++ b/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp @@ -21,6 +21,7 @@ #include "AMPEG4ElementaryAssembler.h" #include "ARTPSource.h" +#include "ASessionDescription.h" #include <media/stagefright/foundation/ABitReader.h> #include <media/stagefright/foundation/ABuffer.h> @@ -85,6 +86,25 @@ static bool GetIntegerAttribute( return true; } +static bool GetSampleRateIndex(int32_t sampleRate, size_t *tableIndex) { + static const int32_t kSampleRateTable[] = { + 96000, 88200, 64000, 48000, 44100, 32000, + 24000, 22050, 16000, 12000, 11025, 8000 + }; + const size_t kNumSampleRates = + sizeof(kSampleRateTable) / sizeof(kSampleRateTable[0]); + + *tableIndex = 0; + for (size_t index = 0; index < kNumSampleRates; ++index) { + if (sampleRate == kSampleRateTable[index]) { + *tableIndex = index; + return true; + } + } + + return false; +} + // static AMPEG4ElementaryAssembler::AMPEG4ElementaryAssembler( const sp<AMessage> ¬ify, const AString &desc, const AString ¶ms) @@ -100,6 +120,8 @@ AMPEG4ElementaryAssembler::AMPEG4ElementaryAssembler( mStreamStateIndication(0), mAuxiliaryDataSizeLength(0), mHasAUHeader(false), + mChannelConfig(0), + mSampleRateIndex(0), mAccessUnitRTPTime(0), mNextExpectedSeqNoValid(false), mNextExpectedSeqNo(0), @@ -163,6 +185,13 @@ AMPEG4ElementaryAssembler::AMPEG4ElementaryAssembler( || mDTSDeltaLength > 0 || mRandomAccessIndication || mStreamStateIndication > 0; + + int32_t sampleRate, numChannels; + ASessionDescription::ParseFormatDesc( + desc.c_str(), &sampleRate, &numChannels); + + mChannelConfig = numChannels; + CHECK(GetSampleRateIndex(sampleRate, &mSampleRateIndex)); } } @@ -338,23 +367,18 @@ void AMPEG4ElementaryAssembler::submitAccessUnit() { ALOGV("Access unit complete (%d nal units)", mPackets.size()); - size_t totalSize = 0; - for (List<sp<ABuffer> >::iterator it = mPackets.begin(); - it != mPackets.end(); ++it) { - totalSize += (*it)->size(); - } + sp<ABuffer> accessUnit; - sp<ABuffer> accessUnit = new ABuffer(totalSize); - size_t offset = 0; - for (List<sp<ABuffer> >::iterator it = mPackets.begin(); - it != mPackets.end(); ++it) { - sp<ABuffer> nal = *it; - memcpy(accessUnit->data() + offset, nal->data(), nal->size()); - offset += nal->size(); + if (mIsGeneric) { + accessUnit = MakeADTSCompoundFromAACFrames( + OMX_AUDIO_AACObjectLC - 1, + mSampleRateIndex, + mChannelConfig, + mPackets); + } else { + accessUnit = MakeCompoundFromPackets(mPackets); } - CopyTimes(accessUnit, *mPackets.begin()); - #if 0 printf(mAccessUnitDamaged ? "X" : "."); fflush(stdout); |