Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add support for MediaRecorder pause/resume
https://bugs.webkit.org/show_bug.cgi?id=217375 Reviewed by Eric Carlson. LayoutTests/imported/w3c: * web-platform-tests/mediacapture-record/MediaRecorder-pause-resume-expected.txt: * web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt: * web-platform-tests/mediacapture-record/idlharness.window-expected.txt: Source/WebCore: Implement pause and resume as per spec. MediaRecorder basically sends pause/resume order to its backend. The backend then stops observing tracks when paused and resumed observing at resume time. For video, we make sure to compute the frame timestamp so that the recorded video continues to play without interruption. Test: http/wpt/mediarecorder/pause-recording.html * Modules/mediarecorder/MediaRecorder.cpp: (WebCore::MediaRecorder::pauseRecording): (WebCore::MediaRecorder::resumeRecording): * Modules/mediarecorder/MediaRecorder.h: * Modules/mediarecorder/MediaRecorder.idl: * platform/mediarecorder/MediaRecorderPrivate.cpp: (WebCore::MediaRecorderPrivate::pause): (WebCore::MediaRecorderPrivate::resume): * platform/mediarecorder/MediaRecorderPrivate.h: * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp: (WebCore::MediaRecorderPrivateAVFImpl::pauseRecording): (WebCore::MediaRecorderPrivateAVFImpl::resumeRecording): * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h: * platform/mediarecorder/MediaRecorderPrivateMock.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm: (WebCore::MediaRecorderPrivateWriter::appendVideoSampleBuffer): (WebCore::MediaRecorderPrivateWriter::pause): (WebCore::MediaRecorderPrivateWriter::resume): Source/WebKit: Add IPC support for sending pause/resume orders. * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::pause): (WebKit::RemoteMediaRecorder::resume): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::pauseRecording): (WebKit::MediaRecorderPrivate::resumeRecording): * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: LayoutTests: fix-217375 * http/wpt/mediarecorder/pause-recording-expected.txt: Added. * http/wpt/mediarecorder/pause-recording.html: Added. Canonical link: https://commits.webkit.org/230199@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268130 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
25 changed files
with
302 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
LayoutTests/http/wpt/mediarecorder/pause-recording-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
PASS Pausing and resuming the recording should impact the video duration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>A recorded muted audio track should produce silence</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<video id="video1" controls></video> | ||
<script> | ||
if (window.internals) | ||
window.internals.setUseGPUProcessForWebRTC(false); | ||
|
||
function waitFor(duration) | ||
{ | ||
return new Promise((resolve) => setTimeout(resolve, duration)); | ||
} | ||
|
||
promise_test(async (test) => { | ||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true }); | ||
|
||
const recorder = new MediaRecorder(stream); | ||
const dataPromise = new Promise(resolve => recorder.ondataavailable = (e) => resolve(e.data)); | ||
|
||
const startPromise = new Promise(resolve => recorder.onstart = resolve); | ||
recorder.start(); | ||
await startPromise; | ||
|
||
setTimeout(() => recorder.pause(), 50); | ||
setTimeout(() => recorder.resume(), 950); | ||
|
||
await waitFor(1000); | ||
recorder.stop(); | ||
const blob = await dataPromise; | ||
|
||
const url = URL.createObjectURL(blob); | ||
video1.src = url; | ||
await video1.play(); | ||
|
||
assert_less_than(video1.duration, 0.5); | ||
|
||
URL.revokeObjectURL(url); | ||
}, "Pausing and resuming the recording should impact the video duration"); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-pause-resume-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
FAIL MediaRecorder handles pause() and resume() calls appropriately in state and events promise_test: Unhandled rejection with value: object "TypeError: recorder.pause is not a function. (In 'recorder.pause()', 'recorder.pause' is undefined)" | ||
PASS MediaRecorder handles pause() and resume() calls appropriately in state and events | ||
|
28 changes: 13 additions & 15 deletions
28
...3c/web-platform-tests/mediacapture-record/MediaRecorder-peerconnection.https-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
|
||
|
||
Harness Error (TIMEOUT), message = null | ||
|
||
PASS PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":false} with format [passthrough]. | ||
PASS PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":false} with format [passthrough]. | ||
PASS PeerConnection MediaRecorder receives data after onstart, {"video":false,"audio":true} with format [passthrough]. | ||
PASS PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":false,"audio":true} with format [passthrough]. | ||
PASS PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":true} with format [passthrough]. | ||
TIMEOUT PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":true} with format [passthrough]. Test timed out | ||
NOTRUN PeerConnection MediaRecorder receives data after onstart, {"video":false,"audio":true} with format video/webm;codecs=vp8. | ||
NOTRUN PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":false,"audio":true} with format video/webm;codecs=vp8. | ||
NOTRUN PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":false} with format video/webm;codecs=vp8. | ||
NOTRUN PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":false} with format video/webm;codecs=vp8. | ||
NOTRUN PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":true} with format video/webm;codecs=vp8. | ||
NOTRUN PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":true} with format video/webm;codecs=vp8. | ||
NOTRUN PeerConnection MediaRecorder receives data after onstart, {"video":false,"audio":true} with format video/webm;codecs=vp9. | ||
NOTRUN PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":false,"audio":true} with format video/webm;codecs=vp9. | ||
NOTRUN PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":false} with format video/webm;codecs=vp9. | ||
NOTRUN PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":false} with format video/webm;codecs=vp9. | ||
NOTRUN PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":true} with format video/webm;codecs=vp9. | ||
NOTRUN PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":true} with format video/webm;codecs=vp9. | ||
PASS PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":true} with format [passthrough]. | ||
FAIL PeerConnection MediaRecorder receives data after onstart, {"video":false,"audio":true} with format video/webm;codecs=vp8. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":false,"audio":true} with format video/webm;codecs=vp8. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":false} with format video/webm;codecs=vp8. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":false} with format video/webm;codecs=vp8. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":true} with format video/webm;codecs=vp8. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":true} with format video/webm;codecs=vp8. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder receives data after onstart, {"video":false,"audio":true} with format video/webm;codecs=vp9. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":false,"audio":true} with format video/webm;codecs=vp9. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":false} with format video/webm;codecs=vp9. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":false} with format video/webm;codecs=vp9. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder receives data after onstart, {"video":true,"audio":true} with format video/webm;codecs=vp9. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
FAIL PeerConnection MediaRecorder gets ondata on stopping recorded tracks {"video":true,"audio":true} with format video/webm;codecs=vp9. promise_test: Unhandled rejection with value: object "NotSupportedError: mimeType is not supported" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.