From e62d20268de87f63083896b5eef083d541078322 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Tue, 17 Dec 2013 14:10:46 -0800 Subject: stagefright: Fix issue with tracking media format in packet source Media format in AnotherPacketSource is now tracked across discontinuities. This fixes a bug where format was set on queueAccessUnit and cleared on dequeueAccessUnit, thereby allowing it to remain cleared. Change-Id: I20975a630443f4a223a2b4344e8244f34b9560b9 Signed-off-by: Lajos Molnar Bug: 12060952 --- .../libstagefright/mpeg2ts/AnotherPacketSource.cpp | 48 ++++++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'media/libstagefright/mpeg2ts') diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 3153c8b..52fb2a5 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -70,7 +70,27 @@ status_t AnotherPacketSource::stop() { } sp AnotherPacketSource::getFormat() { - return mFormat; + Mutex::Autolock autoLock(mLock); + if (mFormat != NULL) { + return mFormat; + } + + List >::iterator it = mBuffers.begin(); + while (it != mBuffers.end()) { + sp buffer = *it; + int32_t discontinuity; + if (buffer->meta()->findInt32("discontinuity", &discontinuity)) { + break; + } + + sp object; + if (buffer->meta()->findObject("format", &object)) { + return static_cast(object.get()); + } + + ++it; + } + return NULL; } status_t AnotherPacketSource::dequeueAccessUnit(sp *buffer) { @@ -94,6 +114,11 @@ status_t AnotherPacketSource::dequeueAccessUnit(sp *buffer) { return INFO_DISCONTINUITY; } + sp object; + if ((*buffer)->meta()->findObject("format", &object)) { + mFormat = static_cast(object.get()); + } + return OK; } @@ -120,17 +145,22 @@ status_t AnotherPacketSource::read( } return INFO_DISCONTINUITY; - } else { - int64_t timeUs; - CHECK(buffer->meta()->findInt64("timeUs", &timeUs)); + } - MediaBuffer *mediaBuffer = new MediaBuffer(buffer); + sp object; + if (buffer->meta()->findObject("format", &object)) { + mFormat = static_cast(object.get()); + } - mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs); + int64_t timeUs; + CHECK(buffer->meta()->findInt64("timeUs", &timeUs)); - *out = mediaBuffer; - return OK; - } + MediaBuffer *mediaBuffer = new MediaBuffer(buffer); + + mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs); + + *out = mediaBuffer; + return OK; } return mEOSResult; -- cgit v1.1 From 7e50e1c0c10cba1e27cafe581273adcadf93877d Mon Sep 17 00:00:00 2001 From: Robert Shih Date: Thu, 23 Jan 2014 14:25:32 -0800 Subject: AnotherPacketSource support to get latest buffered MetaData. Bug: 11854054 Change-Id: Ib3b6e0984036082bf3c4eb7901a2b29be52fdd29 --- .../libstagefright/mpeg2ts/AnotherPacketSource.cpp | 24 ++++++++++++++++++++-- media/libstagefright/mpeg2ts/AnotherPacketSource.h | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'media/libstagefright/mpeg2ts') diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 52fb2a5..2b0bf30 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -34,7 +34,8 @@ AnotherPacketSource::AnotherPacketSource(const sp &meta) : mIsAudio(false), mFormat(NULL), mLastQueuedTimeUs(0), - mEOSResult(OK) { + mEOSResult(OK), + mLatestEnqueuedMeta(NULL) { setFormat(meta); } @@ -182,12 +183,24 @@ void AnotherPacketSource::queueAccessUnit(const sp &buffer) { return; } - CHECK(buffer->meta()->findInt64("timeUs", &mLastQueuedTimeUs)); + int64_t lastQueuedTimeUs; + CHECK(buffer->meta()->findInt64("timeUs", &lastQueuedTimeUs)); + mLastQueuedTimeUs = lastQueuedTimeUs; ALOGV("queueAccessUnit timeUs=%lld us (%.2f secs)", mLastQueuedTimeUs, mLastQueuedTimeUs / 1E6); Mutex::Autolock autoLock(mLock); mBuffers.push_back(buffer); mCondition.signal(); + + if (!mLatestEnqueuedMeta.get()) { + mLatestEnqueuedMeta = buffer->meta(); + } else { + int64_t latestTimeUs = 0; + CHECK(mLatestEnqueuedMeta->findInt64("timeUs", &latestTimeUs)); + if (lastQueuedTimeUs > latestTimeUs) { + mLatestEnqueuedMeta = buffer->meta(); + } + } } void AnotherPacketSource::clear() { @@ -197,6 +210,7 @@ void AnotherPacketSource::clear() { mEOSResult = OK; mFormat = NULL; + mLatestEnqueuedMeta = NULL; } void AnotherPacketSource::queueDiscontinuity( @@ -221,6 +235,7 @@ void AnotherPacketSource::queueDiscontinuity( mEOSResult = OK; mLastQueuedTimeUs = 0; + mLatestEnqueuedMeta = NULL; sp buffer = new ABuffer(0); buffer->meta()->setInt32("discontinuity", static_cast(type)); @@ -308,4 +323,9 @@ bool AnotherPacketSource::isFinished(int64_t duration) const { return (mEOSResult != OK); } +sp AnotherPacketSource::getLatestMeta() { + Mutex::Autolock autoLock(mLock); + return mLatestEnqueuedMeta; +} + } // namespace android diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h index e16cf78..9b193a2 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h @@ -62,6 +62,8 @@ struct AnotherPacketSource : public MediaSource { bool isFinished(int64_t duration) const; + sp getLatestMeta(); + protected: virtual ~AnotherPacketSource(); @@ -74,6 +76,7 @@ private: int64_t mLastQueuedTimeUs; List > mBuffers; status_t mEOSResult; + sp mLatestEnqueuedMeta; bool wasFormatChange(int32_t discontinuityType) const; -- cgit v1.1 From 43ca783effd99bba0e6e2dd6fe177a8888578ef8 Mon Sep 17 00:00:00 2001 From: Robert Shih Date: Thu, 27 Feb 2014 12:33:24 -0800 Subject: httplive: block-by-block fetch, decrypt, and parse ts files. Bug: 12060952 Change-Id: I695345081fe23961b9d0ef6db264885f914703ec --- media/libstagefright/mpeg2ts/ATSParser.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'media/libstagefright/mpeg2ts') diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h index a10edc9..8a80069 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.h +++ b/media/libstagefright/mpeg2ts/ATSParser.h @@ -71,8 +71,9 @@ struct ATSParser : public RefBase { void signalEOS(status_t finalResult); enum SourceType { - VIDEO, - AUDIO + VIDEO = 0, + AUDIO = 1, + NUM_SOURCE_TYPES = 2 }; sp getSource(SourceType type); -- cgit v1.1