Bug 1300703: [webm] Use default duration if known. r=kinetik

MozReview-Commit-ID: J18IdDGkL62

--HG--
extra : rebase_source : fa1e1fdba214f0a0f70656f0523bc76f2cfe5662
This commit is contained in:
Jean-Yves Avenard 2016-09-06 17:23:38 +10:00
Родитель 55ff6f1410
Коммит 5d2aa966ca
2 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@ -355,6 +355,13 @@ WebMDemuxer::ReadMetadata()
continue;
}
uint64_t defaultDuration;
r = nestegg_track_default_duration(context, track, &defaultDuration);
if (r >= 0) {
mVideoDefaultDuration =
Some(uint64_t(media::TimeUnit::FromNanoseconds(defaultDuration).ToMicroseconds()));
}
mVideoTrack = track;
mHasVideo = true;
@ -395,6 +402,13 @@ WebMDemuxer::ReadMetadata()
return NS_ERROR_FAILURE;
}
uint64_t defaultDuration;
r = nestegg_track_default_duration(context, track, &defaultDuration);
if (r >= 0) {
mAudioDefaultDuration =
Some(uint64_t(media::TimeUnit::FromNanoseconds(defaultDuration).ToMicroseconds()));
}
mAudioTrack = track;
mHasAudio = true;
mAudioCodec = nestegg_track_codec_id(context, track);
@ -587,7 +601,11 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
} else if (!mIsMediaSource ||
(mIsMediaSource && mLastAudioFrameTime.isSome())) {
next_tstamp = tstamp;
if (mAudioDefaultDuration.isSome()) {
next_tstamp += mAudioDefaultDuration.ref();
} else {
next_tstamp += tstamp - mLastAudioFrameTime.refOr(0);
}
} else {
PushAudioPacket(holder);
}
@ -602,7 +620,11 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
} else if (!mIsMediaSource ||
(mIsMediaSource && mLastVideoFrameTime.isSome())) {
next_tstamp = tstamp;
if (mVideoDefaultDuration.isSome()) {
next_tstamp += mVideoDefaultDuration.ref();
} else {
next_tstamp += tstamp - mLastVideoFrameTime.refOr(0);
}
} else {
PushVideoPacket(holder);
}

Просмотреть файл

@ -220,6 +220,8 @@ private:
// previous frame's timestamp. In NS.
Maybe<int64_t> mLastAudioFrameTime;
Maybe<int64_t> mLastVideoFrameTime;
Maybe<uint64_t> mAudioDefaultDuration;
Maybe<uint64_t> mVideoDefaultDuration;
// Codec ID of audio track
int mAudioCodec;