summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/mpeg2ts
diff options
context:
space:
mode:
authorRobert Shih <robertshih@google.com>2014-02-15 01:58:05 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-02-15 01:58:05 +0000
commit8d0f9819d19ef34d7b66f86e612b2424d924c6ab (patch)
tree396e56b82634a7e1b1906e54addb83f934693b70 /media/libstagefright/mpeg2ts
parenta0c0a9ab441fc3cbb302c7a2e783f6d4c3b63bed (diff)
parent69634506fbfe79605c37f337a8d6748cda4445b1 (diff)
downloadframeworks_av-8d0f9819d19ef34d7b66f86e612b2424d924c6ab.zip
frameworks_av-8d0f9819d19ef34d7b66f86e612b2424d924c6ab.tar.gz
frameworks_av-8d0f9819d19ef34d7b66f86e612b2424d924c6ab.tar.bz2
Merge "AnotherPacketSource support to get latest buffered MetaData."
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r--media/libstagefright/mpeg2ts/AnotherPacketSource.cpp24
-rw-r--r--media/libstagefright/mpeg2ts/AnotherPacketSource.h3
2 files changed, 25 insertions, 2 deletions
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
index 9fb13c1..6dfaa94 100644
--- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
+++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp
@@ -34,7 +34,8 @@ AnotherPacketSource::AnotherPacketSource(const sp<MetaData> &meta)
: mIsAudio(false),
mFormat(NULL),
mLastQueuedTimeUs(0),
- mEOSResult(OK) {
+ mEOSResult(OK),
+ mLatestEnqueuedMeta(NULL) {
setFormat(meta);
}
@@ -182,12 +183,24 @@ void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &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<ABuffer> buffer = new ABuffer(0);
buffer->meta()->setInt32("discontinuity", static_cast<int32_t>(type));
@@ -308,4 +323,9 @@ bool AnotherPacketSource::isFinished(int64_t duration) const {
return (mEOSResult != OK);
}
+sp<AMessage> 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<AMessage> getLatestMeta();
+
protected:
virtual ~AnotherPacketSource();
@@ -74,6 +76,7 @@ private:
int64_t mLastQueuedTimeUs;
List<sp<ABuffer> > mBuffers;
status_t mEOSResult;
+ sp<AMessage> mLatestEnqueuedMeta;
bool wasFormatChange(int32_t discontinuityType) const;