diff options
author | Marco Nelissen <marcone@google.com> | 2015-04-16 18:55:36 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-16 18:55:36 +0000 |
commit | 8cd4132a85239fd318193e10c0817ac7784c304a (patch) | |
tree | 8ed8cf28dd10bc092401253b3e28b15f2b423f5f /media | |
parent | 6a2dffb1c7a0e45388257bc5d2ec763f234f8cca (diff) | |
parent | 3f22f5a2d95699650a454041bcaa1d5a248cca88 (diff) | |
download | frameworks_av-8cd4132a85239fd318193e10c0817ac7784c304a.zip frameworks_av-8cd4132a85239fd318193e10c0817ac7784c304a.tar.gz frameworks_av-8cd4132a85239fd318193e10c0817ac7784c304a.tar.bz2 |
am 3f22f5a2: Merge "Signal EOS at end of mpeg video to flush out final sample"
* commit '3f22f5a2d95699650a454041bcaa1d5a248cca88':
Signal EOS at end of mpeg video to flush out final sample
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ESQueue.cpp | 21 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ESQueue.h | 2 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp | 3 |
4 files changed, 33 insertions, 1 deletions
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp index 482ccff..1eae6cf 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.cpp +++ b/media/libstagefright/mpeg2ts/ATSParser.cpp @@ -136,6 +136,7 @@ private: sp<ABuffer> mBuffer; sp<AnotherPacketSource> mSource; bool mPayloadStarted; + bool mEOSReached; uint64_t mPrevPTS; @@ -493,6 +494,7 @@ ATSParser::Stream::Stream( mPCR_PID(PCR_PID), mExpectedContinuityCounter(-1), mPayloadStarted(false), + mEOSReached(false), mPrevPTS(0), mQueue(NULL) { switch (mStreamType) { @@ -692,6 +694,8 @@ void ATSParser::Stream::signalEOS(status_t finalResult) { if (mSource != NULL) { mSource->signalEOS(finalResult); } + mEOSReached = true; + flush(); } status_t ATSParser::Stream::parsePES(ABitReader *br) { @@ -902,6 +906,10 @@ void ATSParser::Stream::onPayloadData( status_t err = mQueue->appendData(data, size, timeUs); + if (mEOSReached) { + mQueue->signalEOS(); + } + if (err != OK) { return; } diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp index f257289..5527df0 100644 --- a/media/libstagefright/mpeg2ts/ESQueue.cpp +++ b/media/libstagefright/mpeg2ts/ESQueue.cpp @@ -38,7 +38,8 @@ namespace android { ElementaryStreamQueue::ElementaryStreamQueue(Mode mode, uint32_t flags) : mMode(mode), - mFlags(flags) { + mFlags(flags), + mEOSReached(false) { } sp<MetaData> ElementaryStreamQueue::getFormat() { @@ -244,6 +245,11 @@ static bool IsSeeminglyValidMPEGAudioHeader(const uint8_t *ptr, size_t size) { status_t ElementaryStreamQueue::appendData( const void *data, size_t size, int64_t timeUs) { + + if (mEOSReached) { + ALOGE("appending data after EOS"); + return ERROR_MALFORMED; + } if (mBuffer == NULL || mBuffer->size() == 0) { switch (mMode) { case H264: @@ -1282,4 +1288,17 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitMPEG4Video() { return NULL; } +void ElementaryStreamQueue::signalEOS() { + if (!mEOSReached) { + if (mMode == MPEG_VIDEO) { + const char *theEnd = "\x00\x00\x01\x00"; + appendData(theEnd, 4, 0); + } + mEOSReached = true; + } else { + ALOGW("EOS already signaled"); + } +} + + } // namespace android diff --git a/media/libstagefright/mpeg2ts/ESQueue.h b/media/libstagefright/mpeg2ts/ESQueue.h index eb4b1c9..a6d812f 100644 --- a/media/libstagefright/mpeg2ts/ESQueue.h +++ b/media/libstagefright/mpeg2ts/ESQueue.h @@ -46,6 +46,7 @@ struct ElementaryStreamQueue { ElementaryStreamQueue(Mode mode, uint32_t flags = 0); status_t appendData(const void *data, size_t size, int64_t timeUs); + void signalEOS(); void clear(bool clearFormat); sp<ABuffer> dequeueAccessUnit(); @@ -60,6 +61,7 @@ private: Mode mMode; uint32_t mFlags; + bool mEOSReached; sp<ABuffer> mBuffer; List<RangeInfo> mRangeInfos; diff --git a/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp b/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp index 33cfd1d..74cb5d8 100644 --- a/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp +++ b/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp @@ -204,6 +204,9 @@ status_t MPEG2TSExtractor::feedMore() { ssize_t n = mDataSource->readAt(mOffset, packet, kTSPacketSize); if (n < (ssize_t)kTSPacketSize) { + if (n >= 0) { + mParser->signalEOS(ERROR_END_OF_STREAM); + } return (n < 0) ? (status_t)n : ERROR_END_OF_STREAM; } |