Loading media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp +1 −21 Original line number Diff line number Diff line Loading @@ -534,27 +534,7 @@ void AMPEG4AudioAssembler::submitAccessUnit() { LOG(VERBOSE) << "Access unit complete (" << mPackets.size() << " packets)"; #endif size_t totalSize = 0; List<sp<ABuffer> >::iterator it = mPackets.begin(); while (it != mPackets.end()) { const sp<ABuffer> &unit = *it; totalSize += unit->size(); ++it; } sp<ABuffer> accessUnit = new ABuffer(totalSize); size_t offset = 0; it = mPackets.begin(); while (it != mPackets.end()) { const sp<ABuffer> &unit = *it; memcpy((uint8_t *)accessUnit->data() + offset, unit->data(), unit->size()); ++it; } sp<ABuffer> accessUnit = MakeCompoundFromPackets(mPackets); accessUnit = removeLATMFraming(accessUnit); CopyTimes(accessUnit, *mPackets.begin()); Loading media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp +38 −14 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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) Loading @@ -100,6 +120,8 @@ AMPEG4ElementaryAssembler::AMPEG4ElementaryAssembler( mStreamStateIndication(0), mAuxiliaryDataSizeLength(0), mHasAUHeader(false), mChannelConfig(0), mSampleRateIndex(0), mAccessUnitRTPTime(0), mNextExpectedSeqNoValid(false), mNextExpectedSeqNo(0), Loading Loading @@ -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)); } } Loading Loading @@ -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); Loading media/libstagefright/rtsp/AMPEG4ElementaryAssembler.h +5 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ #include <utils/List.h> #include <utils/RefBase.h> #include <OMX_Audio.h> namespace android { struct ABuffer; Loading Loading @@ -57,6 +59,9 @@ private: unsigned mAuxiliaryDataSizeLength; bool mHasAUHeader; int32_t mChannelConfig; size_t mSampleRateIndex; uint32_t mAccessUnitRTPTime; bool mNextExpectedSeqNoValid; uint32_t mNextExpectedSeqNo; Loading media/libstagefright/rtsp/APacketSource.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -551,6 +551,7 @@ APacketSource::APacketSource( mFormat->setInt32(kKeySampleRate, sampleRate); mFormat->setInt32(kKeyChannelCount, numChannels); mFormat->setInt32(kKeyIsADTS, true); sp<ABuffer> codecSpecificData = MakeAACCodecSpecificData2(params.c_str()); Loading media/libstagefright/rtsp/ARTPAssembler.cpp +73 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,77 @@ void ARTPAssembler::CopyTimes(const sp<ABuffer> &to, const sp<ABuffer> &from) { to->setInt32Data(from->int32Data()); } // static sp<ABuffer> ARTPAssembler::MakeADTSCompoundFromAACFrames( unsigned profile, unsigned samplingFreqIndex, unsigned channelConfig, const List<sp<ABuffer> > &frames) { size_t totalSize = 0; for (List<sp<ABuffer> >::const_iterator it = frames.begin(); it != frames.end(); ++it) { // Each frame is prefixed by a 7 byte ADTS header totalSize += (*it)->size() + 7; } sp<ABuffer> accessUnit = new ABuffer(totalSize); size_t offset = 0; for (List<sp<ABuffer> >::const_iterator it = frames.begin(); it != frames.end(); ++it) { sp<ABuffer> nal = *it; uint8_t *dst = accessUnit->data() + offset; static const unsigned kADTSId = 0; static const unsigned kADTSLayer = 0; static const unsigned kADTSProtectionAbsent = 1; unsigned frameLength = nal->size() + 7; dst[0] = 0xff; dst[1] = 0xf0 | (kADTSId << 3) | (kADTSLayer << 1) | kADTSProtectionAbsent; dst[2] = (profile << 6) | (samplingFreqIndex << 2) | (channelConfig >> 2); dst[3] = ((channelConfig & 3) << 6) | (frameLength >> 11); dst[4] = (frameLength >> 3) & 0xff; dst[5] = (frameLength & 7) << 5; dst[6] = 0x00; memcpy(dst + 7, nal->data(), nal->size()); offset += nal->size() + 7; } CopyTimes(accessUnit, *frames.begin()); return accessUnit; } // static sp<ABuffer> ARTPAssembler::MakeCompoundFromPackets( const List<sp<ABuffer> > &packets) { size_t totalSize = 0; for (List<sp<ABuffer> >::const_iterator it = packets.begin(); it != packets.end(); ++it) { totalSize += (*it)->size(); } sp<ABuffer> accessUnit = new ABuffer(totalSize); size_t offset = 0; for (List<sp<ABuffer> >::const_iterator it = packets.begin(); it != packets.end(); ++it) { sp<ABuffer> nal = *it; memcpy(accessUnit->data() + offset, nal->data(), nal->size()); offset += nal->size(); } CopyTimes(accessUnit, *packets.begin()); return accessUnit; } } // namespace android Loading
media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp +1 −21 Original line number Diff line number Diff line Loading @@ -534,27 +534,7 @@ void AMPEG4AudioAssembler::submitAccessUnit() { LOG(VERBOSE) << "Access unit complete (" << mPackets.size() << " packets)"; #endif size_t totalSize = 0; List<sp<ABuffer> >::iterator it = mPackets.begin(); while (it != mPackets.end()) { const sp<ABuffer> &unit = *it; totalSize += unit->size(); ++it; } sp<ABuffer> accessUnit = new ABuffer(totalSize); size_t offset = 0; it = mPackets.begin(); while (it != mPackets.end()) { const sp<ABuffer> &unit = *it; memcpy((uint8_t *)accessUnit->data() + offset, unit->data(), unit->size()); ++it; } sp<ABuffer> accessUnit = MakeCompoundFromPackets(mPackets); accessUnit = removeLATMFraming(accessUnit); CopyTimes(accessUnit, *mPackets.begin()); Loading
media/libstagefright/rtsp/AMPEG4ElementaryAssembler.cpp +38 −14 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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) Loading @@ -100,6 +120,8 @@ AMPEG4ElementaryAssembler::AMPEG4ElementaryAssembler( mStreamStateIndication(0), mAuxiliaryDataSizeLength(0), mHasAUHeader(false), mChannelConfig(0), mSampleRateIndex(0), mAccessUnitRTPTime(0), mNextExpectedSeqNoValid(false), mNextExpectedSeqNo(0), Loading Loading @@ -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)); } } Loading Loading @@ -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); Loading
media/libstagefright/rtsp/AMPEG4ElementaryAssembler.h +5 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ #include <utils/List.h> #include <utils/RefBase.h> #include <OMX_Audio.h> namespace android { struct ABuffer; Loading Loading @@ -57,6 +59,9 @@ private: unsigned mAuxiliaryDataSizeLength; bool mHasAUHeader; int32_t mChannelConfig; size_t mSampleRateIndex; uint32_t mAccessUnitRTPTime; bool mNextExpectedSeqNoValid; uint32_t mNextExpectedSeqNo; Loading
media/libstagefright/rtsp/APacketSource.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -551,6 +551,7 @@ APacketSource::APacketSource( mFormat->setInt32(kKeySampleRate, sampleRate); mFormat->setInt32(kKeyChannelCount, numChannels); mFormat->setInt32(kKeyIsADTS, true); sp<ABuffer> codecSpecificData = MakeAACCodecSpecificData2(params.c_str()); Loading
media/libstagefright/rtsp/ARTPAssembler.cpp +73 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,77 @@ void ARTPAssembler::CopyTimes(const sp<ABuffer> &to, const sp<ABuffer> &from) { to->setInt32Data(from->int32Data()); } // static sp<ABuffer> ARTPAssembler::MakeADTSCompoundFromAACFrames( unsigned profile, unsigned samplingFreqIndex, unsigned channelConfig, const List<sp<ABuffer> > &frames) { size_t totalSize = 0; for (List<sp<ABuffer> >::const_iterator it = frames.begin(); it != frames.end(); ++it) { // Each frame is prefixed by a 7 byte ADTS header totalSize += (*it)->size() + 7; } sp<ABuffer> accessUnit = new ABuffer(totalSize); size_t offset = 0; for (List<sp<ABuffer> >::const_iterator it = frames.begin(); it != frames.end(); ++it) { sp<ABuffer> nal = *it; uint8_t *dst = accessUnit->data() + offset; static const unsigned kADTSId = 0; static const unsigned kADTSLayer = 0; static const unsigned kADTSProtectionAbsent = 1; unsigned frameLength = nal->size() + 7; dst[0] = 0xff; dst[1] = 0xf0 | (kADTSId << 3) | (kADTSLayer << 1) | kADTSProtectionAbsent; dst[2] = (profile << 6) | (samplingFreqIndex << 2) | (channelConfig >> 2); dst[3] = ((channelConfig & 3) << 6) | (frameLength >> 11); dst[4] = (frameLength >> 3) & 0xff; dst[5] = (frameLength & 7) << 5; dst[6] = 0x00; memcpy(dst + 7, nal->data(), nal->size()); offset += nal->size() + 7; } CopyTimes(accessUnit, *frames.begin()); return accessUnit; } // static sp<ABuffer> ARTPAssembler::MakeCompoundFromPackets( const List<sp<ABuffer> > &packets) { size_t totalSize = 0; for (List<sp<ABuffer> >::const_iterator it = packets.begin(); it != packets.end(); ++it) { totalSize += (*it)->size(); } sp<ABuffer> accessUnit = new ABuffer(totalSize); size_t offset = 0; for (List<sp<ABuffer> >::const_iterator it = packets.begin(); it != packets.end(); ++it) { sp<ABuffer> nal = *it; memcpy(accessUnit->data() + offset, nal->data(), nal->size()); offset += nal->size(); } CopyTimes(accessUnit, *packets.begin()); return accessUnit; } } // namespace android