diff options
author | Robert Shih <robertshih@google.com> | 2014-05-09 19:08:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-09 19:08:24 +0000 |
commit | 01427884471391999393a15abbb95b5f0dce7d3b (patch) | |
tree | fa913a5d908956170d4ed81c821352d45093e9bd | |
parent | 70c2fd3dc648b512ea088ee9de5e505c626fd39c (diff) | |
parent | 170056540e9ce65261b45efd15f67e72e2df1bed (diff) | |
download | frameworks_av-01427884471391999393a15abbb95b5f0dce7d3b.zip frameworks_av-01427884471391999393a15abbb95b5f0dce7d3b.tar.gz frameworks_av-01427884471391999393a15abbb95b5f0dce7d3b.tar.bz2 |
Merge "Expose sample duration in MPEG4Extractor."
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 12 | ||||
-rw-r--r-- | media/libstagefright/SampleIterator.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/SampleTable.cpp | 7 | ||||
-rw-r--r-- | media/libstagefright/include/SampleIterator.h | 4 | ||||
-rw-r--r-- | media/libstagefright/include/SampleTable.h | 3 |
5 files changed, 27 insertions, 8 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 2a3fa04..e07b6aa 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -3540,7 +3540,7 @@ status_t MPEG4Source::read( off64_t offset; size_t size; - uint32_t cts; + uint32_t cts, stts; bool isSyncSample; bool newBuffer = false; if (mBuffer == NULL) { @@ -3548,7 +3548,7 @@ status_t MPEG4Source::read( status_t err = mSampleTable->getMetaDataForSample( - mCurrentSampleIndex, &offset, &size, &cts, &isSyncSample); + mCurrentSampleIndex, &offset, &size, &cts, &isSyncSample, &stts); if (err != OK) { return err; @@ -3579,6 +3579,8 @@ status_t MPEG4Source::read( mBuffer->meta_data()->clear(); mBuffer->meta_data()->setInt64( kKeyTime, ((int64_t)cts * 1000000) / mTimescale); + mBuffer->meta_data()->setInt64( + kKeyDuration, ((int64_t)stts * 1000000) / mTimescale); if (targetSampleTimeUs >= 0) { mBuffer->meta_data()->setInt64( @@ -3701,6 +3703,8 @@ status_t MPEG4Source::read( mBuffer->meta_data()->clear(); mBuffer->meta_data()->setInt64( kKeyTime, ((int64_t)cts * 1000000) / mTimescale); + mBuffer->meta_data()->setInt64( + kKeyDuration, ((int64_t)stts * 1000000) / mTimescale); if (targetSampleTimeUs >= 0) { mBuffer->meta_data()->setInt64( @@ -3850,6 +3854,8 @@ status_t MPEG4Source::fragmentedRead( mBuffer->set_range(0, size); mBuffer->meta_data()->setInt64( kKeyTime, ((int64_t)cts * 1000000) / mTimescale); + mBuffer->meta_data()->setInt64( + kKeyDuration, ((int64_t)smpl->duration * 1000000) / mTimescale); if (targetSampleTimeUs >= 0) { mBuffer->meta_data()->setInt64( @@ -3973,6 +3979,8 @@ status_t MPEG4Source::fragmentedRead( mBuffer->meta_data()->setInt64( kKeyTime, ((int64_t)cts * 1000000) / mTimescale); + mBuffer->meta_data()->setInt64( + kKeyDuration, ((int64_t)smpl->duration * 1000000) / mTimescale); if (targetSampleTimeUs >= 0) { mBuffer->meta_data()->setInt64( diff --git a/media/libstagefright/SampleIterator.cpp b/media/libstagefright/SampleIterator.cpp index eae721b..2748349 100644 --- a/media/libstagefright/SampleIterator.cpp +++ b/media/libstagefright/SampleIterator.cpp @@ -133,7 +133,8 @@ status_t SampleIterator::seekTo(uint32_t sampleIndex) { } status_t err; - if ((err = findSampleTime(sampleIndex, &mCurrentSampleTime)) != OK) { + if ((err = findSampleTimeAndDuration( + sampleIndex, &mCurrentSampleTime, &mCurrentSampleDuration)) != OK) { ALOGE("findSampleTime return error"); return err; } @@ -285,8 +286,8 @@ status_t SampleIterator::getSampleSizeDirect( return OK; } -status_t SampleIterator::findSampleTime( - uint32_t sampleIndex, uint32_t *time) { +status_t SampleIterator::findSampleTimeAndDuration( + uint32_t sampleIndex, uint32_t *time, uint32_t *duration) { if (sampleIndex >= mTable->mNumSampleSizes) { return ERROR_OUT_OF_RANGE; } @@ -309,6 +310,8 @@ status_t SampleIterator::findSampleTime( *time += mTable->getCompositionTimeOffset(sampleIndex); + *duration = mTTSDuration; + return OK; } diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp index d9858d7..9a92805 100644 --- a/media/libstagefright/SampleTable.cpp +++ b/media/libstagefright/SampleTable.cpp @@ -778,7 +778,8 @@ status_t SampleTable::getMetaDataForSample( off64_t *offset, size_t *size, uint32_t *compositionTime, - bool *isSyncSample) { + bool *isSyncSample, + uint32_t *sampleDuration) { Mutex::Autolock autoLock(mLock); status_t err; @@ -820,6 +821,10 @@ status_t SampleTable::getMetaDataForSample( } } + if (sampleDuration) { + *sampleDuration = mSampleIterator->getSampleDuration(); + } + return OK; } diff --git a/media/libstagefright/include/SampleIterator.h b/media/libstagefright/include/SampleIterator.h index b5a043c..60c9e7e 100644 --- a/media/libstagefright/include/SampleIterator.h +++ b/media/libstagefright/include/SampleIterator.h @@ -30,6 +30,7 @@ struct SampleIterator { off64_t getSampleOffset() const { return mCurrentSampleOffset; } size_t getSampleSize() const { return mCurrentSampleSize; } uint32_t getSampleTime() const { return mCurrentSampleTime; } + uint32_t getSampleDuration() const { return mCurrentSampleDuration; } status_t getSampleSizeDirect( uint32_t sampleIndex, size_t *size); @@ -61,11 +62,12 @@ private: off64_t mCurrentSampleOffset; size_t mCurrentSampleSize; uint32_t mCurrentSampleTime; + uint32_t mCurrentSampleDuration; void reset(); status_t findChunkRange(uint32_t sampleIndex); status_t getChunkOffset(uint32_t chunk, off64_t *offset); - status_t findSampleTime(uint32_t sampleIndex, uint32_t *time); + status_t findSampleTimeAndDuration(uint32_t sampleIndex, uint32_t *time, uint32_t *duration); SampleIterator(const SampleIterator &); SampleIterator &operator=(const SampleIterator &); diff --git a/media/libstagefright/include/SampleTable.h b/media/libstagefright/include/SampleTable.h index 847dff7..fe146f2 100644 --- a/media/libstagefright/include/SampleTable.h +++ b/media/libstagefright/include/SampleTable.h @@ -66,7 +66,8 @@ public: off64_t *offset, size_t *size, uint32_t *compositionTime, - bool *isSyncSample = NULL); + bool *isSyncSample = NULL, + uint32_t *sampleDuration = NULL); enum { kFlagBefore, |