summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-05-17 12:12:39 -0700
committerAndreas Huber <andih@google.com>2012-05-17 12:12:39 -0700
commit8647bbe4420ca487467318404127f52c567e346b (patch)
tree6c6f23d84034a5e4ca0aee0542707bd0bca70570 /media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp
parentcd28dc10d49c359566c69d48a29a6f0d3eefa6d9 (diff)
downloadframeworks_av-8647bbe4420ca487467318404127f52c567e346b.zip
frameworks_av-8647bbe4420ca487467318404127f52c567e346b.tar.gz
frameworks_av-8647bbe4420ca487467318404127f52c567e346b.tar.bz2
Prefix MPEG4-generic audio data with ADTS headers
to work around limitations of the new AAC decoder. Change-Id: I4988c7c39fedb7d04eb1ae2ba2d618aa6cb14e77 related-to-bug: 6488547
Diffstat (limited to 'media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp')
-rw-r--r--media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp52
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> &notify, const AString &desc, const AString &params)
@@ -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);