Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSE][GStreamer] Pause after seek is not working #465

Draft
wants to merge 1 commit into
base: lgi-wpe-2.38-23Q4
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions LayoutTests/media/media-controller-play-then-pause-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

RUN(controller = video.controller)
EVENT(canplaythrough)
RUN(controller.play())
EVENT(playing)
RUN(controller.pause())
EVENT(pause)
RUN(controller.play())
EVENT(play)
EXPECTED (controller.playbackState == 'playing') OK
EXPECTED (!internals.isPlayerPaused(video)) OK
EXPECTED (!internals.isPlayerPaused(video2)) OK
END OF TEST

41 changes: 41 additions & 0 deletions LayoutTests/media/media-controller-play-then-pause.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<meta name="timeout" content="long">
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
var controller;
var video2;

async function start() {
var videos = document.getElementsByTagName('video');
video = videos[0];
video2 = videos[1];
run('controller = video.controller');
var src = findMediaFile('video', 'content/test');
video.src = src;
video2.src = src;
await waitFor(controller, 'canplaythrough');

run('controller.play()');
await waitFor(controller, 'playing');

run('controller.pause()');
await waitFor(controller, 'pause');

run('controller.play()');
await waitFor(controller, 'play');

testExpected('controller.playbackState', 'playing');
await waitForConditionOrTimeout('!internals.isPlayerPaused(video)');
await waitForConditionOrTimeout('!internals.isPlayerPaused(video2)');
endTest();
}
</script>
</head>
<body onload="start()">
<video mediaGroup="group" controls></video>
<video mediaGroup="group" controls></video>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

RUN(controller = video.controller)
RUN(video.src = URL.createObjectURL(source))
EVENT(sourceopen)
RUN(sourceBuffer = source.addSourceBuffer(loader.type()))
RUN(sourceBuffer.appendBuffer(loader.initSegment()))
EVENT(update)
Append all media segments
RUN(video2.src = URL.createObjectURL(source2))
EVENT(sourceopen)
RUN(sourceBuffer2 = source2.addSourceBuffer(loader.type()))
RUN(sourceBuffer2.appendBuffer(loader.initSegment()))
EVENT(update)
Append all media segments
RUN(controller.play())
EVENT(playing)
EXPECTED (!internals.isPlayerPaused(video)) OK
EXPECTED (!internals.isPlayerPaused(video2)) OK
RUN(controller.pause())
EVENT(pause)
EXPECTED (internals.isPlayerPaused(video)) OK
EXPECTED (internals.isPlayerPaused(video2)) OK
RUN(controller.play())
EVENT(play)
EXPECTED (controller.playbackState == 'playing') OK
EXPECTED (!internals.isPlayerPaused(video)) OK
EXPECTED (!internals.isPlayerPaused(video2)) OK
END OF TEST

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html>
<head>
<meta name="timeout" content="long">
<script src="media-source-loader.js"></script>
<script src="../video-test.js"></script>
<script>
var loader;
var source;
var source2;
var sourceBuffer;
var sourceBuffer2;
var controller;
var video2;
var i;

function loaderPromise(loader) {
return new Promise((resolve, reject) => {
loader.onload = resolve;
loader.onerror = reject;
});
}

async function start() {
loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
await loaderPromise(loader);

var videos = document.getElementsByTagName('video');
video = videos[0];
video2 = videos[1];
run('controller = video.controller');

source = new MediaSource();
run('video.src = URL.createObjectURL(source)');
await waitFor(source, 'sourceopen');
waitFor(video, 'error').then(failTest);

run('sourceBuffer = source.addSourceBuffer(loader.type())');
run('sourceBuffer.appendBuffer(loader.initSegment())');
await waitFor(sourceBuffer, 'update');

consoleWrite('Append all media segments')
for (i = 0; i < loader.mediaSegmentsLength(); i++) {
sourceBuffer.appendBuffer(loader.mediaSegment(i));
await waitFor(sourceBuffer, 'update', true);
}

source2 = new MediaSource();
run('video2.src = URL.createObjectURL(source2)');
await waitFor(source2, 'sourceopen');
waitFor(video2, 'error').then(failTest);

run('sourceBuffer2 = source2.addSourceBuffer(loader.type())');
run('sourceBuffer2.appendBuffer(loader.initSegment())');
await waitFor(sourceBuffer2, 'update');

consoleWrite('Append all media segments')
for (i = 0; i < loader.mediaSegmentsLength(); i++) {
sourceBuffer2.appendBuffer(loader.mediaSegment(i));
await waitFor(sourceBuffer2, 'update', true);
}

run('controller.play()');
await waitFor(controller, 'playing');
await waitForConditionOrTimeout('!internals.isPlayerPaused(video)', false, 5000);
await waitForConditionOrTimeout('!internals.isPlayerPaused(video2)', false, 5000);

run('controller.pause()');
await waitFor(controller, 'pause');
await waitForConditionOrTimeout('internals.isPlayerPaused(video)', false, 5000);
await waitForConditionOrTimeout('internals.isPlayerPaused(video2)', false, 5000);

run('controller.play()');
await waitFor(controller, 'play');

testExpected('controller.playbackState', 'playing');
await waitForConditionOrTimeout('!internals.isPlayerPaused(video)', false, 5000);
await waitForConditionOrTimeout('!internals.isPlayerPaused(video2)', false, 5000);

endTest();
}
</script>
</head>
<body onload="start()">
<video mediaGroup="group" controls></video>
<video mediaGroup="group" controls></video>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

RUN(video.src = URL.createObjectURL(source))
EVENT(sourceopen)
RUN(sourceBuffer = source.addSourceBuffer(loader.type()))
RUN(sourceBuffer.appendBuffer(loader.initSegment()))
EVENT(update)
Appended all media segments
RUN(video.currentTime = 0)
RUN(video.play())
EVENT(playing)
EXPECTED (video.paused == 'false') OK
RUN(video.pause())
EVENT(pause)
EXPECTED (video.paused == 'true') OK
RUN(video.currentTime = 1)
RUN(video.play())
EVENT(play)
EXPECTED (video.paused == 'false') OK
EXPECTED (!internals.isPlayerPaused(video)) OK
END OF TEST

86 changes: 86 additions & 0 deletions LayoutTests/media/media-source/media-source-seek-and-play.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html>
<head>
<meta name="timeout" content="long">
<script src="media-source-loader.js"></script>
<script src="../video-test.js"></script>
<script>
var loader;
var source;
var sourceBuffer;
var i;

function loaderPromise(loader) {
return new Promise((resolve, reject) => {
loader.onload = resolve;
loader.onerror = reject;
});
}

async function start() {

findMediaElement();

let isTestEnded = false;
let numberOfInitiatedSeeks = 0;
let numberOfCompletedSeeks = 0;

async function finalCheck() {
if (!isTestEnded || numberOfInitiatedSeeks < 2 || numberOfCompletedSeeks < 1) {
return;
}

await waitForConditionOrTimeout('!internals.isPlayerPaused(video)', false, 5000, 1000);
endTest();
}

video.addEventListener('seeking', event => {
numberOfInitiatedSeeks++;
});

video.addEventListener('seeked', event => {
numberOfCompletedSeeks++;
finalCheck();
});

loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
await loaderPromise(loader);

source = new MediaSource();
run('video.src = URL.createObjectURL(source)');
await waitFor(source, 'sourceopen');
waitFor(video, 'error').then(failTest);

run('sourceBuffer = source.addSourceBuffer(loader.type())');
run('sourceBuffer.appendBuffer(loader.initSegment())');
await waitFor(sourceBuffer, 'update');

for (i = 0; i < loader.mediaSegmentsLength(); i++) {
sourceBuffer.appendBuffer(loader.mediaSegment(i));
await waitFor(sourceBuffer, 'update', true);
}
consoleWrite('Appended all media segments')

run('video.currentTime = 0');
run('video.play()');
await waitFor(video, 'playing');
testExpected('video.paused', false);

run('video.pause()');
await waitFor(video, 'pause');
testExpected('video.paused', true);

run('video.currentTime = 1');
run('video.play()');
await waitFor(video, 'play');
testExpected('video.paused', false);

isTestEnded = true;
finalCheck();
}
</script>
</head>
<body onload="start()">
<video></video>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

RUN(video.src = URL.createObjectURL(source))
EVENT(sourceopen)
RUN(sourceBuffer = source.addSourceBuffer(loader.type()))
RUN(sourceBuffer.appendBuffer(loader.initSegment()))
EVENT(update)
Append all media segments
RUN('video.play()')
EXPECTED (video.paused == 'false') OK
RUN(video.currentTime = 2)
RUN(video.pause())
EXPECTED (internals.isPlayerPaused(video)) OK
EXPECTED (video.paused == 'true') OK
END OF TEST

56 changes: 56 additions & 0 deletions LayoutTests/media/media-source/media-source-video-seek-pause.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<title>media-source-video-seek-pause</title>
<script src="../video-test.js"></script>
<script src="media-source-loader.js"></script>
<script>
var loader;
var source;
var sourceBuffer;

function loaderPromise(loader) {
return new Promise((resolve, reject) => {
loader.onload = resolve;
loader.onerror = reject;
});
}

async function startTest()
{
findMediaElement();

loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
await loaderPromise(loader);

source = new MediaSource();
run('video.src = URL.createObjectURL(source)');
await waitFor(source, 'sourceopen');
waitFor(video, 'error').then(failTest);

run('sourceBuffer = source.addSourceBuffer(loader.type())');
run('sourceBuffer.appendBuffer(loader.initSegment())');
await waitFor(sourceBuffer, 'update');

consoleWrite('Append all media segments')
for (i = 0; i < loader.mediaSegmentsLength(); i++) {
sourceBuffer.appendBuffer(loader.mediaSegment(i));
await waitFor(sourceBuffer, 'update', true);
}

consoleWrite("RUN('video.play()')");
await video.play();
testExpected('video.paused', false);
run('video.currentTime = 2');
await sleepFor(5);
run('video.pause()');
await waitForConditionOrTimeout('internals.isPlayerPaused(video)');
testExpected('video.paused', true);
endTest();
}
</script>
</head>
<body onload="startTest()">
<video controls></video>
</body>
</html>
11 changes: 11 additions & 0 deletions LayoutTests/media/video-seek-pause-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

EVENT(canplaythrough)
RUN('video.play()')
EXPECTED (video.paused == 'false') OK
EXPECTED (internals.isPlayerPaused(video) == 'false') OK
RUN(video.currentTime = 2)
RUN(video.pause())
EXPECTED (internals.isPlayerPaused(video)) OK
EXPECTED (video.paused == 'true') OK
END OF TEST

29 changes: 29 additions & 0 deletions LayoutTests/media/video-seek-pause.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>video-seek-pause</title>
<script src="video-test.js"></script>
<script src="media-file.js"></script>
<script>
async function startTest()
{
findMediaElement();
video.src = findMediaFile('video', 'content/test');
await waitFor(video, 'canplaythrough');
consoleWrite("RUN('video.play()')");
await video.play();
testExpected('video.paused', false);
testExpected('internals.isPlayerPaused(video)', false);
run('video.currentTime = 2');
await sleepFor(5);
run('video.pause()');
await waitForConditionOrTimeout('internals.isPlayerPaused(video)', false, 2000);
testExpected('video.paused', true);
endTest();
}
</script>
</head>
<body onload="startTest()">
<video controls></video>
</body>
</html>
Loading