diff options
author | Andreas Huber <andih@google.com> | 2011-11-29 14:08:13 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-29 14:08:13 -0800 |
commit | 405a4e34032f8a07028138266fe9f79f6753b466 (patch) | |
tree | 62352e960b6fe93d856304089387041104d706ac /media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | |
parent | be6ab576ff0e3bf2a8dc3feee6f476061afbda30 (diff) | |
parent | 66a051af37c3d7a610802c0c58906dc0faefa6be (diff) | |
download | frameworks_base-405a4e34032f8a07028138266fe9f79f6753b466.zip frameworks_base-405a4e34032f8a07028138266fe9f79f6753b466.tar.gz frameworks_base-405a4e34032f8a07028138266fe9f79f6753b466.tar.bz2 |
Merge "Finer granularity discontinuity support." into ics-mr1
Diffstat (limited to 'media/libstagefright/mpeg2ts/AnotherPacketSource.cpp')
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index ce07e32..f782ce5 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -29,8 +29,17 @@ namespace android { AnotherPacketSource::AnotherPacketSource(const sp<MetaData> &meta) - : mFormat(meta), + : mIsAudio(false), + mFormat(meta), mEOSResult(OK) { + const char *mime; + CHECK(meta->findCString(kKeyMIMEType, &mime)); + + if (!strncasecmp("audio/", mime, 6)) { + mIsAudio = true; + } else { + CHECK(!strncasecmp("video/", mime, 6)); + } } void AnotherPacketSource::setFormat(const sp<MetaData> &meta) { @@ -67,8 +76,7 @@ status_t AnotherPacketSource::dequeueAccessUnit(sp<ABuffer> *buffer) { int32_t discontinuity; if ((*buffer)->meta()->findInt32("discontinuity", &discontinuity)) { - - if (discontinuity == ATSParser::DISCONTINUITY_FORMATCHANGE) { + if (wasFormatChange(discontinuity)) { mFormat.clear(); } @@ -96,7 +104,7 @@ status_t AnotherPacketSource::read( int32_t discontinuity; if (buffer->meta()->findInt32("discontinuity", &discontinuity)) { - if (discontinuity == ATSParser::DISCONTINUITY_FORMATCHANGE) { + if (wasFormatChange(discontinuity)) { mFormat.clear(); } @@ -117,6 +125,15 @@ status_t AnotherPacketSource::read( return mEOSResult; } +bool AnotherPacketSource::wasFormatChange( + int32_t discontinuityType) const { + if (mIsAudio) { + return (discontinuityType & ATSParser::DISCONTINUITY_AUDIO_FORMAT) != 0; + } + + return (discontinuityType & ATSParser::DISCONTINUITY_VIDEO_FORMAT) != 0; +} + void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &buffer) { int32_t damaged; if (buffer->meta()->findInt32("damaged", &damaged) && damaged) { |