Bug 1269408: P9. Move handling logic of skip to next keyframe to its own function. r=gerald

MozReview-Commit-ID: EjCAFvdcdJ6
This commit is contained in:
Jean-Yves Avenard 2016-05-06 15:58:51 +10:00
parent 946c83d7c5
commit 10c2e4ded5

View File

@ -528,17 +528,6 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
// 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;
@ -1403,16 +1392,22 @@ 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,