mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1120075: Use Movie Extend Header's duration as fallback when available. r=kentuckyfriedtakahe
--HG-- extra : rebase_source : 54e554e183d9072908ec02b6c14de5c2f46e8204
This commit is contained in:
parent
52d3bbb9ae
commit
2ceb0057af
@ -144,6 +144,13 @@ MP4Demuxer::Init()
|
||||
sp<MetaData> metaData = e->getMetaData();
|
||||
mCrypto.Update(metaData);
|
||||
|
||||
int64_t movieDuration;
|
||||
if (!mVideoConfig.duration && !mAudioConfig.duration &&
|
||||
metaData->findInt64(kKeyMovieDuration, &movieDuration)) {
|
||||
// No duration were found in either tracks, use movie extend header box one.
|
||||
mVideoConfig.duration = mAudioConfig.duration = movieDuration;
|
||||
}
|
||||
|
||||
return mPrivate->mAudio.get() || mPrivate->mVideo.get();
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ enum {
|
||||
kKeyDriftTime = 'dftT', // int64_t (usecs)
|
||||
kKeyAnchorTime = 'ancT', // int64_t (usecs)
|
||||
kKeyDuration = 'dura', // int64_t (usecs)
|
||||
kKeyMovieDuration = 'mdur', // int64_t (usecs)
|
||||
kKeyColorFormat = 'colf',
|
||||
kKeyPlatformPrivate = 'priv', // pointer
|
||||
kKeyDecoderComponent = 'decC', // cstring
|
||||
|
@ -1697,6 +1697,46 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC('m', 'e', 'h', 'd'):
|
||||
{
|
||||
if (chunk_data_size < 8) {
|
||||
return ERROR_MALFORMED;
|
||||
}
|
||||
|
||||
uint8_t version;
|
||||
if (mDataSource->readAt(
|
||||
data_offset, &version, sizeof(version))
|
||||
< (ssize_t)sizeof(version)) {
|
||||
return ERROR_IO;
|
||||
}
|
||||
if (version > 1) {
|
||||
break;
|
||||
}
|
||||
int64_t duration = 0;
|
||||
if (version == 1) {
|
||||
if (mDataSource->readAt(
|
||||
data_offset + 4, &duration, sizeof(duration))
|
||||
< (ssize_t)sizeof(duration)) {
|
||||
return ERROR_IO;
|
||||
}
|
||||
duration = ntoh64(duration);
|
||||
} else {
|
||||
uint32_t duration32;
|
||||
if (mDataSource->readAt(
|
||||
data_offset + 4, &duration32, sizeof(duration32))
|
||||
< (ssize_t)sizeof(duration32)) {
|
||||
return ERROR_IO;
|
||||
}
|
||||
duration = ntohl(duration32);
|
||||
}
|
||||
if (duration) {
|
||||
mFileMetaData->setInt64(kKeyMovieDuration, duration * 1000LL);
|
||||
}
|
||||
|
||||
*offset += chunk_size;
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC('m', 'd', 'a', 't'):
|
||||
{
|
||||
ALOGV("mdat chunk, drm: %d", mIsDrm);
|
||||
|
Loading…
Reference in New Issue
Block a user