Bug 1269408: P9. Move handling logic of skip to next keyframe to its own function. r?gerald
MozReview-Commit-ID: EjCAFvdcdJ6
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -523,27 +523,16 @@ MediaFormatReader::RequestVideoData(bool
return MediaDataPromise::CreateAndReject(CANCELED, __func__);
}
media::TimeUnit timeThreshold{media::TimeUnit::FromMicroseconds(aTimeThreshold)};
// Ensure we have no pending seek going as ShouldSkip could return out of date
// information.
if (!mVideo.HasInternalSeekPending() &&
ShouldSkip(aSkipToNextKeyframe, timeThreshold)) {
- // Cancel any pending demux request.
- mVideo.mDemuxRequest.DisconnectIfExists();
-
- // I think it's still possible for an output to have been sent from the decoder
- // and is currently sitting in our event queue waiting to be processed. The following
- // flush won't clear it, and when we return to the event loop it'll be added to our
- // output queue and be used.
- // This code will count that as dropped, which was the intent, but not quite true.
- mDecoder->NotifyDecodedFrames(0, 0, SizeOfVideoQueueInFrames());
-
- Reset(TrackInfo::kVideoTrack);
RefPtr<MediaDataPromise> p = mVideo.EnsurePromise(__func__);
SkipVideoDemuxToNextKeyFrame(timeThreshold);
return p;
}
RefPtr<MediaDataPromise> p = mVideo.EnsurePromise(__func__);
NotifyDecodingRequested(TrackInfo::kVideoTrack);
@@ -1398,26 +1387,32 @@ MediaFormatReader::Reset(TrackType aTrac
LOG("Reset(%s) END", TrackTypeToStr(aTrack));
}
void
MediaFormatReader::SkipVideoDemuxToNextKeyFrame(media::TimeUnit aTimeThreshold)
{
MOZ_ASSERT(OnTaskQueue());
-
- MOZ_ASSERT(mVideo.mDecoder);
- MOZ_ASSERT(mVideo.HasPromise());
- MOZ_ASSERT(!mVideo.mDecodingRequested);
LOG("Skipping up to %lld", aTimeThreshold.ToMicroseconds());
- if (mVideo.mError) {
- mVideo.RejectPromise(DECODE_ERROR, __func__);
- return;
+ // Cancel any pending demux request and pending demuxed samples.
+ mVideo.mDemuxRequest.DisconnectIfExists();
+
+ // I think it's still possible for an output to have been sent from the decoder
+ // and is currently sitting in our event queue waiting to be processed. The following
+ // flush won't clear it, and when we return to the event loop it'll be added to our
+ // output queue and be used.
+ // This code will count that as dropped, which was the intent, but not quite true.
+ mDecoder->NotifyDecodedFrames(0, 0, SizeOfVideoQueueInFrames());
+
+ if (mVideo.mTimeThreshold) {
+ LOGV("Internal Seek pending, cancelling it");
}
+ Reset(TrackInfo::kVideoTrack);
mSkipRequest.Begin(mVideo.mTrackDemuxer->SkipToNextRandomAccessPoint(aTimeThreshold)
->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnVideoSkipCompleted,
&MediaFormatReader::OnVideoSkipFailed));
return;
}