diff options
author | Andreas Huber <andih@google.com> | 2011-03-02 15:34:46 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-03-02 15:38:32 -0800 |
commit | 669ad13de924af145771837b339c882e30ea8ce2 (patch) | |
tree | 178ee1fedeba8f4b48b93f4fc2a70f1ffdb323aa /media/libstagefright/mpeg2ts | |
parent | ded35fcf62946acd1ec89bbe7c991c7ebd4d4483 (diff) | |
download | frameworks_base-669ad13de924af145771837b339c882e30ea8ce2.zip frameworks_base-669ad13de924af145771837b339c882e30ea8ce2.tar.gz frameworks_base-669ad13de924af145771837b339c882e30ea8ce2.tar.bz2 |
Allow optional specification of a PTS timestamp when signalling a discontinuity.
If present, rendering will be suppressed until reaching the timestamp.
Change-Id: Ic64bdf4225063c5a4d042ea9809960b843a46d19
related-to-bug: 3489454
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.cpp | 52 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.h | 5 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 4 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.h | 5 |
4 files changed, 50 insertions, 16 deletions
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp index 6056739..5ba4a4f 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.cpp +++ b/media/libstagefright/mpeg2ts/ATSParser.cpp @@ -32,6 +32,7 @@ #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MetaData.h> +#include <media/IStreamSource.h> #include <utils/KeyedVector.h> namespace android { @@ -49,7 +50,9 @@ struct ATSParser::Program : public RefBase { unsigned pid, unsigned payload_unit_start_indicator, ABitReader *br); - void signalDiscontinuity(DiscontinuityType type); + void signalDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra); + void signalEOS(status_t finalResult); sp<MediaSource> getSource(SourceType type); @@ -83,7 +86,9 @@ struct ATSParser::Stream : public RefBase { unsigned payload_unit_start_indicator, ABitReader *br); - void signalDiscontinuity(DiscontinuityType type); + void signalDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra); + void signalEOS(status_t finalResult); sp<MediaSource> getSource(SourceType type); @@ -100,6 +105,7 @@ private: sp<AnotherPacketSource> mSource; bool mPayloadStarted; DiscontinuityType mPendingDiscontinuity; + sp<AMessage> mPendingDiscontinuityExtra; ElementaryStreamQueue mQueue; @@ -112,7 +118,8 @@ private: void extractAACFrames(const sp<ABuffer> &buffer); - void deferDiscontinuity(DiscontinuityType type); + void deferDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra); DISALLOW_EVIL_CONSTRUCTORS(Stream); }; @@ -150,9 +157,10 @@ bool ATSParser::Program::parsePID( return true; } -void ATSParser::Program::signalDiscontinuity(DiscontinuityType type) { +void ATSParser::Program::signalDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra) { for (size_t i = 0; i < mStreams.size(); ++i) { - mStreams.editValueAt(i)->signalDiscontinuity(type); + mStreams.editValueAt(i)->signalDiscontinuity(type, extra); } } @@ -283,7 +291,8 @@ void ATSParser::Program::parseProgramMap(ABitReader *br) { mStreams.add(info.mPID, stream); if (PIDsChanged) { - stream->signalDiscontinuity(DISCONTINUITY_FORMATCHANGE); + sp<AMessage> extra; + stream->signalDiscontinuity(DISCONTINUITY_FORMATCHANGE, extra); } } } @@ -366,7 +375,8 @@ void ATSParser::Stream::parse( mBuffer->setRange(0, mBuffer->size() + payloadSizeBits / 8); } -void ATSParser::Stream::signalDiscontinuity(DiscontinuityType type) { +void ATSParser::Stream::signalDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra) { mPayloadStarted = false; mBuffer->setRange(0, 0); @@ -378,10 +388,21 @@ void ATSParser::Stream::signalDiscontinuity(DiscontinuityType type) { mQueue.clear(!isASeek); + uint64_t resumeAtPTS; + if (extra != NULL + && extra->findInt64( + IStreamListener::kKeyResumeAtPTS, + (int64_t *)&resumeAtPTS)) { + int64_t resumeAtMediaTimeUs = + mProgram->convertPTSToTimestamp(resumeAtPTS); + + extra->setInt64("resume-at-mediatimeUs", resumeAtMediaTimeUs); + } + if (mSource != NULL) { - mSource->queueDiscontinuity(type); + mSource->queueDiscontinuity(type, extra); } else { - deferDiscontinuity(type); + deferDiscontinuity(type, extra); } break; } @@ -392,10 +413,12 @@ void ATSParser::Stream::signalDiscontinuity(DiscontinuityType type) { } } -void ATSParser::Stream::deferDiscontinuity(DiscontinuityType type) { +void ATSParser::Stream::deferDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra) { if (type > mPendingDiscontinuity) { // Only upgrade discontinuities. mPendingDiscontinuity = type; + mPendingDiscontinuityExtra = extra; } } @@ -596,8 +619,10 @@ void ATSParser::Stream::onPayloadData( mSource = new AnotherPacketSource(meta); if (mPendingDiscontinuity != DISCONTINUITY_NONE) { - mSource->queueDiscontinuity(mPendingDiscontinuity); + mSource->queueDiscontinuity( + mPendingDiscontinuity, mPendingDiscontinuityExtra); mPendingDiscontinuity = DISCONTINUITY_NONE; + mPendingDiscontinuityExtra.clear(); } mSource->queueAccessUnit(accessUnit); @@ -639,9 +664,10 @@ void ATSParser::feedTSPacket(const void *data, size_t size) { parseTS(&br); } -void ATSParser::signalDiscontinuity(DiscontinuityType type) { +void ATSParser::signalDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra) { for (size_t i = 0; i < mPrograms.size(); ++i) { - mPrograms.editItemAt(i)->signalDiscontinuity(type); + mPrograms.editItemAt(i)->signalDiscontinuity(type, extra); } } diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h index 455f9d5..3936f05 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.h +++ b/media/libstagefright/mpeg2ts/ATSParser.h @@ -41,7 +41,10 @@ struct ATSParser : public RefBase { ATSParser(); void feedTSPacket(const void *data, size_t size); - void signalDiscontinuity(DiscontinuityType type); + + void signalDiscontinuity( + DiscontinuityType type, const sp<AMessage> &extra); + void signalEOS(status_t finalResult); enum SourceType { diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 0ad883b..59de17e 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -136,9 +136,11 @@ void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &buffer) { } void AnotherPacketSource::queueDiscontinuity( - ATSParser::DiscontinuityType type) { + ATSParser::DiscontinuityType type, + const sp<AMessage> &extra) { sp<ABuffer> buffer = new ABuffer(0); buffer->meta()->setInt32("discontinuity", static_cast<int32_t>(type)); + buffer->meta()->setMessage("extra", extra); Mutex::Autolock autoLock(mLock); diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h index 6fe93f8..439c785 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h @@ -46,7 +46,10 @@ struct AnotherPacketSource : public MediaSource { status_t nextBufferTime(int64_t *timeUs); void queueAccessUnit(const sp<ABuffer> &buffer); - void queueDiscontinuity(ATSParser::DiscontinuityType type); + + void queueDiscontinuity( + ATSParser::DiscontinuityType type, const sp<AMessage> &extra); + void signalEOS(status_t result); status_t dequeueAccessUnit(sp<ABuffer> *buffer); |