summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/mpeg2ts
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2013-12-17 14:10:46 -0800
committerLajos Molnar <lajos@google.com>2014-03-06 16:25:11 -0800
commite62d20268de87f63083896b5eef083d541078322 (patch)
treefce776fcf4d2eb288e7eae863932ae980c95b128 /media/libstagefright/mpeg2ts
parent6708a45ba1b5eacf583d5e80b2075b68940fe0ab (diff)
downloadframeworks_av-e62d20268de87f63083896b5eef083d541078322.zip
frameworks_av-e62d20268de87f63083896b5eef083d541078322.tar.gz
frameworks_av-e62d20268de87f63083896b5eef083d541078322.tar.bz2
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 <lajos@google.com> Bug: 12060952
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r--media/libstagefright/mpeg2ts/AnotherPacketSource.cpp48
1 files changed, 39 insertions, 9 deletions
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;