mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 1378691 P4 - skip to next key frame if the playback position is very close to it; r=jwwang
MozReview-Commit-ID: Gm0iZAHVLpS --HG-- extra : rebase_source : e1bc9da5b809cba474983b804085dca21473b3ac
This commit is contained in:
parent
4175fed6b6
commit
5547aba3cd
@ -1816,10 +1816,27 @@ protected:
|
||||
void RequestVideoData() override
|
||||
{
|
||||
MOZ_ASSERT(!mDoneVideoSeeking);
|
||||
mMaster->RequestVideoData(GetSeekTarget());
|
||||
|
||||
const auto& clock = mMaster->mMediaSink->IsStarted()
|
||||
? mMaster->GetClock()
|
||||
: mMaster->GetMediaTime();
|
||||
const auto& nextKeyFrameTime = GetNextKeyFrameTime();
|
||||
|
||||
auto threshold = clock;
|
||||
|
||||
if (nextKeyFrameTime.IsValid() &&
|
||||
clock >= (nextKeyFrameTime - sSkipToNextKeyFrameThreshold)) {
|
||||
threshold = nextKeyFrameTime;
|
||||
}
|
||||
|
||||
mMaster->RequestVideoData(threshold);
|
||||
}
|
||||
|
||||
private:
|
||||
// Trigger skip to next key frame if the current playback position is very
|
||||
// close the next key frame's time.
|
||||
static constexpr TimeUnit sSkipToNextKeyFrameThreshold = TimeUnit::FromMicroseconds(5000);
|
||||
|
||||
// If the media is playing, drop video until catch up playback position.
|
||||
media::TimeUnit GetSeekTarget() const override
|
||||
{
|
||||
@ -1827,8 +1844,26 @@ private:
|
||||
? mMaster->GetClock()
|
||||
: mSeekJob.mTarget->GetTime();
|
||||
}
|
||||
|
||||
media::TimeUnit GetNextKeyFrameTime() const
|
||||
{
|
||||
// We only call this method in RequestVideoData() and we only request video
|
||||
// data if we haven't done video seeking.
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mDoneVideoSeeking);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mMaster->VideoQueue().GetSize() == 0);
|
||||
|
||||
if (mFirstVideoFrameAfterSeek) {
|
||||
return mFirstVideoFrameAfterSeek->NextKeyFrameTime();
|
||||
}
|
||||
|
||||
return TimeUnit::Invalid();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
constexpr TimeUnit
|
||||
MediaDecoderStateMachine::VideoOnlySeekingState::sSkipToNextKeyFrameThreshold;
|
||||
|
||||
RefPtr<MediaDecoder::SeekPromise>
|
||||
MediaDecoderStateMachine::DormantState::HandleSeek(SeekTarget aTarget)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user