diff options
author | Marco Nelissen <marcone@google.com> | 2015-04-16 19:25:50 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-16 19:25:50 +0000 |
commit | ff9863b206cd5d1e856dbfdf66bc85581aee7608 (patch) | |
tree | d0b99acf32a9e6e2032db8b46789c6d5de8c5b2f | |
parent | c224ec53a17994fa97ab2f29304647c9f195c51c (diff) | |
parent | 6705a49f6481ad1728215a2a72472fe43c786cd0 (diff) | |
download | frameworks_av-ff9863b206cd5d1e856dbfdf66bc85581aee7608.zip frameworks_av-ff9863b206cd5d1e856dbfdf66bc85581aee7608.tar.gz frameworks_av-ff9863b206cd5d1e856dbfdf66bc85581aee7608.tar.bz2 |
am 6705a49f: am 541a9ac7: am 8cd4132a: am 3f22f5a2: Merge "Signal EOS at end of mpeg video to flush out final sample"
* commit '6705a49f6481ad1728215a2a72472fe43c786cd0':
Signal EOS at end of mpeg video to flush out final sample
-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 0a868bc..14ae81c 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.cpp +++ b/media/libstagefright/mpeg2ts/ATSParser.cpp @@ -146,6 +146,7 @@ private: sp<ABuffer> mBuffer; sp<AnotherPacketSource> mSource; bool mPayloadStarted; + bool mEOSReached; uint64_t mPrevPTS; @@ -567,6 +568,7 @@ ATSParser::Stream::Stream( mPCR_PID(PCR_PID), mExpectedContinuityCounter(-1), mPayloadStarted(false), + mEOSReached(false), mPrevPTS(0), mQueue(NULL) { switch (mStreamType) { @@ -766,6 +768,8 @@ void ATSParser::Stream::signalEOS(status_t finalResult) { if (mSource != NULL) { mSource->signalEOS(finalResult); } + mEOSReached = true; + flush(); } status_t ATSParser::Stream::parsePES(ABitReader *br) { @@ -976,6 +980,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 a279049..55262ff 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: @@ -1274,4 +1280,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 45b4624..5425367 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; } |