summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2015-04-16 19:13:41 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-16 19:13:41 +0000
commit6705a49f6481ad1728215a2a72472fe43c786cd0 (patch)
treee22e6a1b7ed1c4c13e2c34caf0f23bafe8f4ec2e
parent5c16a3877c0b32f21cbee7f1bdc77a2a4d2b79c6 (diff)
parent541a9ac77ecaa26449fcad5c116fb93657ca17c1 (diff)
downloadframeworks_av-6705a49f6481ad1728215a2a72472fe43c786cd0.zip
frameworks_av-6705a49f6481ad1728215a2a72472fe43c786cd0.tar.gz
frameworks_av-6705a49f6481ad1728215a2a72472fe43c786cd0.tar.bz2
am 541a9ac7: am 8cd4132a: am 3f22f5a2: Merge "Signal EOS at end of mpeg video to flush out final sample"
* commit '541a9ac77ecaa26449fcad5c116fb93657ca17c1': Signal EOS at end of mpeg video to flush out final sample
-rw-r--r--media/libstagefright/mpeg2ts/ATSParser.cpp8
-rw-r--r--media/libstagefright/mpeg2ts/ESQueue.cpp21
-rw-r--r--media/libstagefright/mpeg2ts/ESQueue.h2
-rw-r--r--media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp3
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;
}