-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cocoa] Encrypted video does not play when not in the DOM
https://bugs.webkit.org/show_bug.cgi?id=248008 rdar://102446042 Reviewed by Eric Carlson. WebCoreDecompressionSession isn't capable (by design) of decoding encrypted content. When a video element is not in the DOM, a decompression session is created to allow the element to be painted into a canvas. But since decoding encrypted samples will always fail, always create an AVSampleBufferDisplayLayer if any SourceBuffer has an enabled, protected video track. * LayoutTests/http/tests/media/fairplay/fps-mse-play-while-not-in-dom-expected.txt: Added. * LayoutTests/http/tests/media/fairplay/fps-mse-play-while-not-in-dom.html: Added. * Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: * Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::shouldEnsureLayer const): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::needsVideoLayerChanged): * Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): (WebCore::SourceBufferPrivateAVFObjC::needsVideoLayer const): (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeSelected): (WebCore::SourceBufferPrivateAVFObjC::canEnqueueSample): Canonical link: https://commits.webkit.org/256805@main
- Loading branch information
Showing
6 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
LayoutTests/http/tests/media/fairplay/fps-mse-play-while-not-in-dom-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,24 @@ | ||
PROMISE: requestMediaKeySystemAccess resolved | ||
PROMISE: createMediaKeys resolved | ||
FETCH: resources/cert.der OK | ||
PROMISE: keys.setServerCertificate resolved | ||
PROMISE: setMediaKeys() resolved | ||
Created mediaSource | ||
EVENT(sourceopen) | ||
- | ||
Appending Encrypted Video Header | ||
Created sourceBuffer | ||
FETCH: content/elementary-stream-video-header-keyid-2.m4v OK | ||
EVENT(encrypted) | ||
EVENT(message) | ||
PROMISE: licenseResponse resolved | ||
PROMISE: session.update() resolved | ||
EVENT(updateend) | ||
- | ||
Appending Encrypted Video Payload | ||
FETCH: content/elementary-stream-video-payload.m4v OK | ||
EVENT(updateend) | ||
RUN(video.play()) | ||
EVENT(playing) | ||
END OF TEST | ||
|
45 changes: 45 additions & 0 deletions
45
LayoutTests/http/tests/media/fairplay/fps-mse-play-while-not-in-dom.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>fps-mse-play-while-not-in-dom</title> | ||
<script src=../../../media-resources/video-test.js></script> | ||
<script src=support.js></script> | ||
<script src="eme2016.js"></script> | ||
<script> | ||
window.addEventListener('load', async event => { | ||
startTest().then(endTest).catch(failTest); | ||
}); | ||
|
||
async function startTest() { | ||
window.video = document.createElement('video'); | ||
let keys = await startEME({video: video, capabilities: [{ | ||
initDataTypes: ['sinf'], | ||
videoCapabilities: [{ contentType: 'video/mp4', robustness: '' }], | ||
distinctiveIdentifier: 'not-allowed', | ||
persistentState: 'not-allowed', | ||
sessionTypes: ['temporary'], | ||
}]}); | ||
|
||
let mediaSource = new MediaSource; | ||
video.srcObject = mediaSource; | ||
consoleWrite('Created mediaSource'); | ||
await waitFor(mediaSource, 'sourceopen'); | ||
|
||
consoleWrite('-'); | ||
consoleWrite('Appending Encrypted Video Header'); | ||
|
||
let {sourceBuffer: sourceBuffer, session: session} = await createBufferAppendAndWaitForEncrypted(video, mediaSource, 'video/mp4', 'content/elementary-stream-video-header-keyid-2.m4v'); | ||
|
||
consoleWrite('-'); | ||
consoleWrite('Appending Encrypted Video Payload'); | ||
|
||
await fetchAndAppend(sourceBuffer, 'content/elementary-stream-video-payload.m4v'); | ||
|
||
run('video.play()'); | ||
await waitForEventWithTimeout(video, 'playing', 10000, 'Did not play in time'); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
</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
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