Bug 1900191 - Use nestegg advertised default duration if it exists.

This commit is contained in:
Moonchild 2024-09-30 22:34:37 +02:00 committed by roytam1
commit ea2268b5e8
3 changed files with 19 additions and 5 deletions

View file

@ -602,9 +602,10 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
}
int64_t tstamp = holder->Timestamp();
int64_t duration = holder->Duration();
int64_t defaultDuration = holder->DefaultDuration();
if (aType == TrackInfo::TrackType::kVideoTrack) {
WEBM_DEBUG("GetNextPacket(video): tstamp=%" PRId64 ", duration=%" PRId64,
tstamp, duration);
WEBM_DEBUG("GetNextPacket(video): tstamp=%" PRId64 ", duration=%" PRId64, ", defaultDuration=%" PRId64,
tstamp, duration, defaultDuration);
}
// The end time of this frame is the start time of the next frame. Fetch
@ -646,6 +647,8 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
(mIsMediaSource && mLastVideoFrameTime.isSome())) {
next_tstamp = tstamp;
next_tstamp += tstamp - mLastVideoFrameTime.refOr(0);
} else if (defaultDuration >= 0) {
next_tstamp = tstamp + defaultDuration;
} else if (mVideoFrameEndTimeBeforeReset) {
WEBM_DEBUG("Setting next timestamp to be %" PRId64 " us",
mVideoFrameEndTimeBeforeReset.value());
@ -883,7 +886,7 @@ WebMDemuxer::DemuxPacket(TrackInfo::TrackType aType,
int64_t offset = Resource(aType).Tell();
RefPtr<NesteggPacketHolder> holder = new NesteggPacketHolder();
if (!holder->Init(packet, offset, track, false)) {
if (!holder->Init(packet, Context(aType), offset, track, false)) {
return NS_ERROR_DOM_MEDIA_DEMUXER_ERR;
}