diff options
author | Lajos Molnar <lajos@google.com> | 2014-03-07 02:38:21 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-07 02:38:21 +0000 |
commit | e389b1bdd13e768baa2532f537236b2c5e6243fa (patch) | |
tree | f42a7afdfd302ac31fc8dfaa472c07d64c33d635 | |
parent | 3bd0270c2106241674b1d8cb4951e5c5a7bc98d2 (diff) | |
parent | ad21a81af3e7d6b58002c9dce9c3278b6323e4a9 (diff) | |
download | frameworks_av-e389b1bdd13e768baa2532f537236b2c5e6243fa.zip frameworks_av-e389b1bdd13e768baa2532f537236b2c5e6243fa.tar.gz frameworks_av-e389b1bdd13e768baa2532f537236b2c5e6243fa.tar.bz2 |
am ad21a81a: Merge "stagefright: Fix issue with tracking media format in packet source" into klp-dev
* commit 'ad21a81af3e7d6b58002c9dce9c3278b6323e4a9':
stagefright: Fix issue with tracking media format in packet source
-rw-r--r-- | media/libstagefright/httplive/PlaylistFetcher.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 48 |
2 files changed, 44 insertions, 13 deletions
diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp index 1754bf2..f095987 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -861,12 +861,13 @@ status_t PlaylistFetcher::extractAndQueueAccessUnits( && source->dequeueAccessUnit(&accessUnit) == OK) { // Note that we do NOT dequeue any discontinuities. + // for simplicity, store a reference to the format in each unit + sp<MetaData> format = source->getFormat(); + if (format != NULL) { + accessUnit->meta()->setObject("format", format); + } packetSource->queueAccessUnit(accessUnit); } - - if (packetSource->getFormat() == NULL) { - packetSource->setFormat(source->getFormat()); - } } return OK; 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<MetaData> AnotherPacketSource::getFormat() { - return mFormat; + Mutex::Autolock autoLock(mLock); + if (mFormat != NULL) { + return mFormat; + } + + List<sp<ABuffer> >::iterator it = mBuffers.begin(); + while (it != mBuffers.end()) { + sp<ABuffer> buffer = *it; + int32_t discontinuity; + if (buffer->meta()->findInt32("discontinuity", &discontinuity)) { + break; + } + + sp<RefBase> object; + if (buffer->meta()->findObject("format", &object)) { + return static_cast<MetaData*>(object.get()); + } + + ++it; + } + return NULL; } status_t AnotherPacketSource::dequeueAccessUnit(sp<ABuffer> *buffer) { @@ -94,6 +114,11 @@ status_t AnotherPacketSource::dequeueAccessUnit(sp<ABuffer> *buffer) { return INFO_DISCONTINUITY; } + sp<RefBase> object; + if ((*buffer)->meta()->findObject("format", &object)) { + mFormat = static_cast<MetaData*>(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<RefBase> object; + if (buffer->meta()->findObject("format", &object)) { + mFormat = static_cast<MetaData*>(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; |