-
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.
[EME] Blocked encrypted samples are not enqueued after a CDM is attac…
…hed to a SourceBuffer (affects netflix.com) https://bugs.webkit.org/show_bug.cgi?id=267804 rdar://120879185 Reviewed by Jean-Yves Avenard and Jer Noble. When SourceBuffer attempts to enqueue an encrypted sample before either a CDM is attached or a usable key is present it adds the sample to a list of "blocked" samples. The intention was to later enqueue these samples once a CDM was attached and usable keys were present, however this would never occur for two reasons: 1. While SourceBufferPrivateAVFObjC had a key status observer that would enqueue blocked samples when called, it was never added to the attached CDM and therefore never called. 2. Even if the observer were added, if key status resolved to a terminal state prior to the CDM being attached then the observer would never be called. These issues manifested in sporadic playback failures on netflix.com (and possibly other EME sites). Addressed (1) by adding SourceBufferPrivateAVFObjC's key status observer to the attached CDM. Addressed (2) by attempting to enqueue blocked samples immediately at CDM attachment time. Added a layout test. * LayoutTests/http/tests/media/fairplay/eme2016.js: (async startEME): (async fetchAppendAndWaitForEncrypted): (async createBufferAppendAndWaitForEncrypted): * LayoutTests/http/tests/media/fairplay/fps-mse-attach-cdm-after-key-exchange-expected.txt: Added. * LayoutTests/http/tests/media/fairplay/fps-mse-attach-cdm-after-key-exchange.html: Copied from LayoutTests/http/tests/media/fairplay/fps-mse-play-while-not-in-dom.html. * LayoutTests/http/tests/media/fairplay/fps-mse-play-while-not-in-dom.html: * LayoutTests/http/tests/media/fairplay/fps-mse-unmuxed-audio-only.html: * LayoutTests/http/tests/media/fairplay/fps-mse-unmuxed-key-renewal.html: * LayoutTests/http/tests/media/fairplay/fps-mse-unmuxed-key-rotation.html: * LayoutTests/http/tests/media/fairplay/fps-mse-unmuxed-multiple-keys.html: * LayoutTests/http/tests/media/fairplay/fps-mse-unmuxed-same-key.html: * LayoutTests/platform/mac/TestExpectations: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::enterFullscreen): * Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h: * Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm: (WebCore::CDMInstanceFairPlayStreamingAVFObjC::addKeyStatusesChangedObserver): (WebCore::CDMInstanceFairPlayStreamingAVFObjC::removeKeyStatusesChangedObserver): * Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::setCDMInstance): (WebCore::SourceBufferPrivateAVFObjC::attemptToDecrypt): (WebCore::SourceBufferPrivateAVFObjC::tryToEnqueueBlockedSamples): (WebCore::SourceBufferPrivateAVFObjC::keyStatusesChanged): Renamed to tryToEnqueueBlockedSamples. Canonical link: https://commits.webkit.org/273340@main
- Loading branch information
Showing
15 changed files
with
132 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
25 changes: 25 additions & 0 deletions
25
LayoutTests/http/tests/media/fairplay/fps-mse-attach-cdm-after-key-exchange-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,25 @@ | ||
PROMISE: requestMediaKeySystemAccess resolved | ||
PROMISE: createMediaKeys resolved | ||
FETCH: resources/cert.der OK | ||
PROMISE: keys.setServerCertificate 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()) | ||
PROMISE: setMediaKeys() resolved | ||
EVENT(playing) | ||
PROMISE: playing event dispatched | ||
END OF TEST | ||
|
52 changes: 52 additions & 0 deletions
52
LayoutTests/http/tests/media/fairplay/fps-mse-attach-cdm-after-key-exchange.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,52 @@ | ||
<!DOCTYPE html><!-- webkit-test-runner [ SampleBufferContentKeySessionSupportEnabled=true ] --> | ||
<html> | ||
<head> | ||
<title>fps-mse-attach-cdm-after-key-exchange</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.querySelector('video'); | ||
let keys = await startEME({video: video, setMediaKeys: false, 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, keys, '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()'); | ||
let playingEvent = waitForEventWithTimeout(video, 'playing', 10000, 'Did not play in time'); | ||
|
||
await video.setMediaKeys(keys); | ||
consoleWrite('PROMISE: setMediaKeys() resolved'); | ||
|
||
await playingEvent; | ||
consoleWrite('PROMISE: playing event dispatched'); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<video controls width="480"></video> | ||
</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
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
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