Bug 1022913 - Ensure that fastSeek() doesn't skip behind the current playback position if we're seeking forwards. r=cajbir
This commit is contained in:
@@ -1966,6 +1966,25 @@ void MediaDecoderStateMachine::DecodeSeek()
|
||||
video = mReader->FindStartTime(nextSampleStartTime);
|
||||
}
|
||||
|
||||
if (seekTime > mediaTime &&
|
||||
nextSampleStartTime < mediaTime &&
|
||||
mSeekTarget.mType == SeekTarget::PrevSyncPoint) {
|
||||
// We are doing a fastSeek, but we ended up *before* the previous
|
||||
// playback position. This is surprising UX, so switch to an accurate
|
||||
// seek and decode to the seek target. This is not conformant to the
|
||||
// spec, fastSeek should always be fast, but until we get the time to
|
||||
// change all Readers to seek to the keyframe after the currentTime
|
||||
// in this case, we'll just decode forward. Bug 1026330.
|
||||
ResetPlayback();
|
||||
{
|
||||
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
|
||||
res = mReader->DecodeToTarget(seekTime);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
video = mReader->FindStartTime(nextSampleStartTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup timestamp state.
|
||||
if (seekTime == mEndTime) {
|
||||
newCurrentTime = mAudioStartTime = seekTime;
|
||||
|
||||
@@ -347,6 +347,7 @@ skip-if = buildapp == 'b2g' # bug 1021676
|
||||
[test_error_in_video_document.html]
|
||||
[test_error_on_404.html]
|
||||
[test_fastSeek.html]
|
||||
[test_fastSeek-forwards.html]
|
||||
[test_info_leak.html]
|
||||
[test_invalid_reject.html]
|
||||
[test_load.html]
|
||||
|
||||
74
content/media/test/test_fastSeek-forwards.html
Normal file
74
content/media/test/test_fastSeek-forwards.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1022913
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1022913</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="application/javascript">
|
||||
|
||||
// Test that if we're doing a fastSeek() forwards that we don't end up
|
||||
// seeking backwards. This can happen if the keyframe before the seek
|
||||
// target is before the current playback position. We'd prefer to seek to
|
||||
// the keyframe after the seek target in this case, but we don't implement
|
||||
// this yet (bug 1026330).
|
||||
var manager = new MediaTestManager;
|
||||
|
||||
var onSecondSeekComplete = function(event) {
|
||||
var v = event.target;
|
||||
ok(v.currentTime >= v.firstSeekTarget, v.name + " seek never go backwards. time=" + v.currentTime + " firstSeekTarget=" + v.firstSeekTarget + " secondSeekTarget=" + v.secondSeekTarget);
|
||||
manager.finished(v.token);
|
||||
};
|
||||
|
||||
var onFirstSeekComplete = function(event) {
|
||||
var v = event.target;
|
||||
v.removeEventListener("seeked", onFirstSeekComplete);
|
||||
// Seek to 75% of the way between the start and the first keyframe
|
||||
// using fastSeek. We then test that the currentTime doesn't drop back
|
||||
// to the previous keyframe, currentTime should go forwards.
|
||||
v.addEventListener("seeked", onSecondSeekComplete);
|
||||
v.secondSeekTarget = v.keyframes[1] * 0.75;
|
||||
v.fastSeek(v.secondSeekTarget);
|
||||
}
|
||||
|
||||
var onLoadedMetadata = function(event) {
|
||||
// Seek to the mid-point between the start and the first keyframe.
|
||||
var v = event.target;
|
||||
v.addEventListener("seeked", onFirstSeekComplete);
|
||||
v.firstSeekTarget = v.keyframes[1] * 0.5;
|
||||
v.currentTime = v.firstSeekTarget;
|
||||
}
|
||||
|
||||
function startTest(test, token) {
|
||||
manager.started(token);
|
||||
v = document.createElement("video");
|
||||
v.src = test.name;
|
||||
v.name = test.name;
|
||||
v.preload = "metadata";
|
||||
v.token = token;
|
||||
v.target = 0;
|
||||
v.keyframes = test.keyframes;
|
||||
v.keyframeIndex = 0;
|
||||
ok(v.keyframes.length >= 2, v.name + " - video should have at least two sync points");
|
||||
v.addEventListener("loadedmetadata", onLoadedMetadata);
|
||||
document.body.appendChild(v);
|
||||
}
|
||||
|
||||
manager.runTests(gFastSeekTests, startTest);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1022913">Mozilla Bug 1022913</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user