Commit 16fba831 authored by sandersd@chromium.org's avatar sandersd@chromium.org

Reland: Remove "needkey" event and add its replacement, "encrypted".

This new event is of type MediaEncryptedEvent, which has initDataType instead of contentType (but this CL just renames one to the other, without translation), and changes the type of initData from Uint8Array to ArrayBuffer as per the WD EME spec.

Also in this CL:
  - Start renaming keyNeeded() to encrypted() by renaming the it on HTMLMediaElementEncryptedMedia.
  - Remove unused contentType argument from createWebkitNeedKeyEvent() (good thing it's unused or the contentType to initDataType change would be a lot harder).
  - Fix prefixed/encrypted-media-events.html test to test the prefixed needkey event instead of the unprefixed one.

TBR=jochen@chromium.org,ddorwin@chromium.org
BUG=224786
(cherry picked from commit ad09c3ed1914691ee4a089cfe95988892ed42407)

Review URL: https://codereview.chromium.org/655603003

git-svn-id: svn://svn.chromium.org/blink/trunk@183628 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b10d7584
Test reloading during encrypted media playback. Test reloading during encrypted media playback.
EVENT(needkey) EVENT(encrypted)
EVENT(needkey) EVENT(encrypted)
EVENT(message) EVENT(message)
EVENT(playing) EVENT(playing)
This is a testharness.js-based test. This is a testharness.js-based test.
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
function onNeedKey(event) function onEncrypted(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaKeyNeededEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'needkey'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so only // The same decryption key is shared by all streams so only
// create a shared session once. // create a shared session once.
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
mediaKeySession = video.mediaKeys.createSession(); mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
mediaKeySession.generateRequest(event.contentType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.initDataType, event.initData).catch(function(error) {
forceTestFailureFromPromise(test, error); forceTestFailureFromPromise(test, error);
}); });
} }
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
} }
MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) {
waitForEventAndRunStep('needkey', video, onNeedKey, test); waitForEventAndRunStep('encrypted', video, onEncrypted, test);
waitForEventAndRunStep('playing', video, onPlaying, test); waitForEventAndRunStep('playing', video, onPlaying, test);
video.src = '../content/test-encrypted.webm'; video.src = '../content/test-encrypted.webm';
return video.setMediaKeys(mediaKeys); return video.setMediaKeys(mediaKeys);
......
Test that needkey event is fired on an encrypted media file. Test that encrypted event is fired on an encrypted media file.
EVENT(needkey) EVENT(encrypted)
EVENT(needkey) EVENT(encrypted)
This is a testharness.js-based test. This is a testharness.js-based test.
PASS Needkey fired on encrypted media file. PASS encrypted fired on encrypted media file.
Harness: the test ran to completion. Harness: the test ran to completion.
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>NeedKey</title> <title>onencrypted</title>
<script src="encrypted-media-utils.js"></script> <script src="encrypted-media-utils.js"></script>
<script src="../../resources/testharness.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<body> <body>
<video id="testVideo" controls></video> <video id="testVideo" controls></video>
<div id="log"></div> <div id="log"></div>
<p>Test that needkey event is fired on an encrypted media file.</p> <p>Test that encrypted event is fired on an encrypted media file.</p>
<script> <script>
var expectedInitData = stringToUint8Array('0123456789012345'); var expectedInitData = stringToUint8Array('0123456789012345');
...@@ -20,20 +20,21 @@ ...@@ -20,20 +20,21 @@
{ {
var video = document.getElementById('testVideo'); var video = document.getElementById('testVideo');
var onNeedKey = function(event) var onEncrypted = function(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaKeyNeededEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'needkey'); assert_equals(event.type, 'encrypted');
assert_array_equals(event.initData, expectedInitData); assert_equals(event.initDataType, 'webm');
assert_array_equals(new Uint8Array(event.initData), expectedInitData);
if (--expectedEvents == 0) if (--expectedEvents == 0)
test.done(); test.done();
}; };
waitForEventAndRunStep('needkey', video, onNeedKey, test); waitForEventAndRunStep('encrypted', video, onEncrypted, test);
video.src = '../content/test-encrypted.webm'; video.src = '../content/test-encrypted.webm';
}, 'Needkey fired on encrypted media file.'); }, 'encrypted fired on encrypted media file.');
</script> </script>
</body> </body>
</html> </html>
Test playback of encrypted media using Clear Key key system with multiple sessions. Test playback of encrypted media using Clear Key key system with multiple sessions.
EVENT(needkey) EVENT(encrypted)
EVENT(needkey) EVENT(encrypted)
EVENT(message) EVENT(message)
EVENT(message) EVENT(message)
EVENT(playing) EVENT(playing)
......
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B, var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B,
0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE4, 0xAE, 0x0A]); 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE4, 0xAE, 0x0A]);
function onNeedKey(event) function onEncrypted(event)
{ {
var keyId = String.fromCharCode.apply(null, event.initData); var keyId = String.fromCharCode.apply(null, new Uint8Array(event.initData));
var mediaKeySession = video.mediaKeys.createSession(); var mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
mediaKeySession.generateRequest(event.contentType, event.initData).then(function() { mediaKeySession.generateRequest(event.initDataType, event.initData).then(function() {
if (keyId == videoKeyId) { if (keyId == videoKeyId) {
assert_equals(videoMediaKeySession, null); assert_equals(videoMediaKeySession, null);
videoMediaKeySession = mediaKeySession; videoMediaKeySession = mediaKeySession;
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
} }
MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) {
waitForEventAndRunStep('needkey', video, onNeedKey, test); waitForEventAndRunStep('encrypted', video, onEncrypted, test);
waitForEventAndRunStep('playing', video, onPlaying, test); waitForEventAndRunStep('playing', video, onPlaying, test);
video.src = '../content/test-encrypted-different-av-keys.webm'; video.src = '../content/test-encrypted-different-av-keys.webm';
return video.setMediaKeys(mediaKeys); return video.setMediaKeys(mediaKeys);
......
Test playback of encrypted media using Clear Key key system. Test playback of encrypted media using Clear Key key system.
EVENT(needkey) EVENT(encrypted)
EVENT(needkey) EVENT(encrypted)
EVENT(message) EVENT(message)
EVENT(playing) EVENT(playing)
This is a testharness.js-based test. This is a testharness.js-based test.
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
function onNeedKey(event) function onEncrypted(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaKeyNeededEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'needkey'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so // The same decryption key is shared by all streams so
// only create a shared session once. // only create a shared session once.
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
var mediaKeySession = video.mediaKeys.createSession(); var mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
mediaKeySession.generateRequest(event.contentType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.initDataType, event.initData).catch(function(error) {
forceTestFailureFromPromise(test, error); forceTestFailureFromPromise(test, error);
}); });
} }
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) {
waitForEventAndRunStep('needkey', video, onNeedKey, test); waitForEventAndRunStep('encrypted', video, onEncrypted, test);
waitForEventAndRunStep('playing', video, onPlaying, test); waitForEventAndRunStep('playing', video, onPlaying, test);
video.src = '../content/test-encrypted.webm'; video.src = '../content/test-encrypted.webm';
......
Test playback of encrypted media using Clear Key key system. Test playback of encrypted media using Clear Key key system.
EVENT(needkey) EVENT(encrypted)
EVENT(needkey) EVENT(encrypted)
EVENT(message) EVENT(message)
EVENT(playing) EVENT(playing)
This is a testharness.js-based test. This is a testharness.js-based test.
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
function onNeedKey(event) function onEncrypted(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaKeyNeededEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'needkey'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so only create a shared session once. // The same decryption key is shared by all streams so only create a shared session once.
if (isSessionCreated) if (isSessionCreated)
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
var mediaKeySession = video.mediaKeys.createSession(); var mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
mediaKeySession.generateRequest(event.contentType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.initDataType, event.initData).catch(function(error) {
forceTestFailureFromPromise(test, error); forceTestFailureFromPromise(test, error);
}); });
} }
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) {
waitForEventAndRunStep('needkey', video, onNeedKey, test); waitForEventAndRunStep('encrypted', video, onEncrypted, test);
waitForEventAndRunStep('playing', video, onPlaying, test); waitForEventAndRunStep('playing', video, onPlaying, test);
return video.setMediaKeys(mediaKeys); return video.setMediaKeys(mediaKeys);
......
...@@ -591,7 +591,7 @@ ...@@ -591,7 +591,7 @@
// FIXME: Add syntax checks for MediaKeys.IsTypeSupported(). // FIXME: Add syntax checks for MediaKeys.IsTypeSupported().
// FIXME: Add syntax checks for MediaKeyError and MediaKeySession events. // FIXME: Add syntax checks for MediaKeyError and MediaKeySession events.
// FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, mediakeys, onneedkey. // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, mediakeys, onencrypted.
</script> </script>
</body> </body>
</html> </html>
EVENT(needkey) EVENT(encrypted)
EVENT(needkey) EVENT(encrypted)
EVENT(message) EVENT(message)
EVENT(playing) EVENT(playing)
This is a testharness.js-based test. This is a testharness.js-based test.
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
function onNeedKey(event) function onEncrypted(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaKeyNeededEvent); assert_true(event instanceof window.MediaEncryptedEvent);
assert_equals(event.type, 'needkey'); assert_equals(event.type, 'encrypted');
// The same decryption key is shared by all streams so only // The same decryption key is shared by all streams so only
// create a shared session once. // create a shared session once.
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
mediaKeySession = video.mediaKeys.createSession(); mediaKeySession = video.mediaKeys.createSession();
waitForEventAndRunStep('message', mediaKeySession, onMessage, test); waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
mediaKeySession.generateRequest(event.contentType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.initDataType, event.initData).catch(function(error) {
forceTestFailureFromPromise(test, error); forceTestFailureFromPromise(test, error);
}); });
} }
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
} }
MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) {
waitForEventAndRunStep('needkey', video, onNeedKey, test); waitForEventAndRunStep('encrypted', video, onEncrypted, test);
waitForEventAndRunStep('playing', video, onPlaying, test); waitForEventAndRunStep('playing', video, onPlaying, test);
video.src = '../content/test-encrypted.webm'; video.src = '../content/test-encrypted.webm';
return video.setMediaKeys(mediaKeys); return video.setMediaKeys(mediaKeys);
......
...@@ -3,7 +3,7 @@ Test all the key-related events. ...@@ -3,7 +3,7 @@ Test all the key-related events.
EXPECTED (messageEvent != 'null') OK EXPECTED (messageEvent != 'null') OK
EXPECTED (messageEvent instanceof window.MediaKeyMessageEvent == 'true') OK EXPECTED (messageEvent instanceof window.MediaKeyMessageEvent == 'true') OK
EXPECTED (keyNeededEvent != 'null') OK EXPECTED (keyNeededEvent != 'null') OK
EXPECTED (keyNeededEvent instanceof window.MediaKeyNeededEvent == 'true') OK EXPECTED (keyNeededEvent instanceof window.MediaKeyEvent == 'true') OK
*** Verify the presence of on* attributes. These would return undefined if they are not present. *** *** Verify the presence of on* attributes. These would return undefined if they are not present. ***
EXPECTED (video.onwebkitkeyadded === 'null') OK EXPECTED (video.onwebkitkeyadded === 'null') OK
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
var messageEvent = document.createEvent("MediaKeyMessageEvent"); var messageEvent = document.createEvent("MediaKeyMessageEvent");
testExpected("messageEvent", null, "!="); testExpected("messageEvent", null, "!=");
testExpected("messageEvent instanceof window.MediaKeyMessageEvent", true); testExpected("messageEvent instanceof window.MediaKeyMessageEvent", true);
var keyNeededEvent = document.createEvent("MediaKeyNeededEvent"); var keyNeededEvent = document.createEvent("MediaKeyEvent");
testExpected("keyNeededEvent", null, "!="); testExpected("keyNeededEvent", null, "!=");
testExpected("keyNeededEvent instanceof window.MediaKeyNeededEvent", true); testExpected("keyNeededEvent instanceof window.MediaKeyEvent", true);
// Next, The test runs twice, once using on* and then using addEventListener(). // Next, The test runs twice, once using on* and then using addEventListener().
var isFirstRun = true; var isFirstRun = true;
......
...@@ -229,11 +229,11 @@ MIDIMessageEvent ...@@ -229,11 +229,11 @@ MIDIMessageEvent
Map Map
MediaController MediaController
MediaElementAudioSourceNode MediaElementAudioSourceNode
MediaEncryptedEvent
MediaError MediaError
MediaKeyError MediaKeyError
MediaKeyEvent MediaKeyEvent
MediaKeyMessageEvent MediaKeyMessageEvent
MediaKeyNeededEvent
MediaKeySession MediaKeySession
MediaKeys MediaKeys
MediaList MediaList
......
...@@ -75,6 +75,7 @@ dragstart ...@@ -75,6 +75,7 @@ dragstart
drop drop
durationchange durationchange
emptied emptied
encrypted
end end
ended ended
endEvent endEvent
...@@ -130,7 +131,6 @@ mouseover ...@@ -130,7 +131,6 @@ mouseover
mouseup mouseup
mousewheel mousewheel
mute mute
needkey
negotiationneeded negotiationneeded
nomatch nomatch
noupdate noupdate
......
...@@ -14,12 +14,13 @@ ...@@ -14,12 +14,13 @@
#include "core/html/HTMLMediaElement.h" #include "core/html/HTMLMediaElement.h"
#include "core/html/MediaKeyError.h" #include "core/html/MediaKeyError.h"
#include "core/html/MediaKeyEvent.h" #include "core/html/MediaKeyEvent.h"
#include "modules/encryptedmedia/MediaKeyNeededEvent.h" #include "modules/encryptedmedia/MediaEncryptedEvent.h"
#include "modules/encryptedmedia/MediaKeys.h" #include "modules/encryptedmedia/MediaKeys.h"
#include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h"
#include "platform/ContentDecryptionModuleResult.h" #include "platform/ContentDecryptionModuleResult.h"
#include "platform/Logging.h" #include "platform/Logging.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#include "wtf/ArrayBuffer.h"
#include "wtf/Functional.h" #include "wtf/Functional.h"
#include "wtf/Uint8Array.h" #include "wtf/Uint8Array.h"
...@@ -286,20 +287,20 @@ ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt ...@@ -286,20 +287,20 @@ ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt
return SetMediaKeysHandler::create(scriptState, element, mediaKeys); return SetMediaKeysHandler::create(scriptState, element, mediaKeys);
} }
// Create a MediaKeyNeededEvent for WD EME. // Create a MediaEncryptedEvent for WD EME.
static PassRefPtrWillBeRawPtr<Event> createNeedKeyEvent(const String& contentType, const unsigned char* initData, unsigned initDataLength) static PassRefPtrWillBeRawPtr<Event> createEncryptedEvent(const String& initDataType, const unsigned char* initData, unsigned initDataLength)
{ {
MediaKeyNeededEventInit initializer; MediaEncryptedEventInit initializer;
initializer.contentType = contentType; initializer.initDataType = initDataType;
initializer.initData = Uint8Array::create(initData, initDataLength); initializer.initData = ArrayBuffer::create(initData, initDataLength);
initializer.bubbles = false; initializer.bubbles = false;
initializer.cancelable = false; initializer.cancelable = false;
return MediaKeyNeededEvent::create(EventTypeNames::needkey, initializer); return MediaEncryptedEvent::create(EventTypeNames::encrypted, initializer);
} }
// Create a 'needkey' MediaKeyEvent for v0.1b EME. // Create a 'needkey' MediaKeyEvent for v0.1b EME.
static PassRefPtrWillBeRawPtr<Event> createWebkitNeedKeyEvent(const String& contentType, const unsigned char* initData, unsigned initDataLength) static PassRefPtrWillBeRawPtr<Event> createWebkitNeedKeyEvent(const unsigned char* initData, unsigned initDataLength)
{ {
MediaKeyEventInit webkitInitializer; MediaKeyEventInit webkitInitializer;
webkitInitializer.keySystem = String(); webkitInitializer.keySystem = String();
...@@ -500,20 +501,21 @@ void HTMLMediaElementEncryptedMedia::keyMessage(HTMLMediaElement& element, const ...@@ -500,20 +501,21 @@ void HTMLMediaElementEncryptedMedia::keyMessage(HTMLMediaElement& element, const
element.scheduleEvent(event.release()); element.scheduleEvent(event.release());
} }
void HTMLMediaElementEncryptedMedia::keyNeeded(HTMLMediaElement& element, const String& contentType, const unsigned char* initData, unsigned initDataLength) void HTMLMediaElementEncryptedMedia::encrypted(HTMLMediaElement& element, const String& initDataType, const unsigned char* initData, unsigned initDataLength)
{ {
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyNeeded: contentType=%s", contentType.utf8().data()); WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::encrypted: initDataType=%s", initDataType.utf8().data());
if (RuntimeEnabledFeatures::encryptedMediaEnabled()) { if (RuntimeEnabledFeatures::encryptedMediaEnabled()) {
// Send event for WD EME. // Send event for WD EME.
RefPtrWillBeRawPtr<Event> event = createNeedKeyEvent(contentType, initData, initDataLength); // FIXME: Check origin before providing initData. http://crbug.com/418233.
RefPtrWillBeRawPtr<Event> event = createEncryptedEvent(initDataType, initData, initDataLength);
event->setTarget(&element); event->setTarget(&element);
element.scheduleEvent(event.release()); element.scheduleEvent(event.release());
} }
if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) {
// Send event for v0.1b EME. // Send event for v0.1b EME.
RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(contentType, initData, initDataLength); RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(initData, initDataLength);
event->setTarget(&element); event->setTarget(&element);
element.scheduleEvent(event.release()); element.scheduleEvent(event.release());
} }
......
...@@ -39,12 +39,12 @@ public: ...@@ -39,12 +39,12 @@ public:
// encrypted media extensions (WD) // encrypted media extensions (WD)
static MediaKeys* mediaKeys(HTMLMediaElement&); static MediaKeys* mediaKeys(HTMLMediaElement&);
static ScriptPromise setMediaKeys(ScriptState*, HTMLMediaElement&, MediaKeys*); static ScriptPromise setMediaKeys(ScriptState*, HTMLMediaElement&, MediaKeys*);
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(needkey); DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(encrypted);
static void keyAdded(HTMLMediaElement&, const String& keySystem, const String& sessionId); static void keyAdded(HTMLMediaElement&, const String& keySystem, const String& sessionId);
static void keyError(HTMLMediaElement&, const String& keySystem, const String& sessionId, WebMediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode); static void keyError(HTMLMediaElement&, const String& keySystem, const String& sessionId, WebMediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode);
static void keyMessage(HTMLMediaElement&, const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL); static void keyMessage(HTMLMediaElement&, const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL);
static void keyNeeded(HTMLMediaElement&, const String& contentType, const unsigned char* initData, unsigned initDataLength); static void encrypted(HTMLMediaElement&, const String& initDataType, const unsigned char* initData, unsigned initDataLength);
static void playerDestroyed(HTMLMediaElement&); static void playerDestroyed(HTMLMediaElement&);
static WebContentDecryptionModule* contentDecryptionModule(HTMLMediaElement&); static WebContentDecryptionModule* contentDecryptionModule(HTMLMediaElement&);
......
...@@ -14,5 +14,5 @@ partial interface HTMLMediaElement { ...@@ -14,5 +14,5 @@ partial interface HTMLMediaElement {
[RuntimeEnabled=EncryptedMedia] readonly attribute MediaKeys mediaKeys; [RuntimeEnabled=EncryptedMedia] readonly attribute MediaKeys mediaKeys;
[RuntimeEnabled=EncryptedMedia, TypeChecking=Interface, CallWith=ScriptState] Promise setMediaKeys(MediaKeys? mediaKeys); [RuntimeEnabled=EncryptedMedia, TypeChecking=Interface, CallWith=ScriptState] Promise setMediaKeys(MediaKeys? mediaKeys);
[RuntimeEnabled=EncryptedMedia] attribute EventHandler onneedkey; [RuntimeEnabled=EncryptedMedia] attribute EventHandler onencrypted;
}; };
...@@ -24,37 +24,35 @@ ...@@ -24,37 +24,35 @@
*/ */
#include "config.h" #include "config.h"
#include "modules/encryptedmedia/MediaKeyNeededEvent.h" #include "modules/encryptedmedia/MediaEncryptedEvent.h"
#include "wtf/Uint8Array.h"
namespace blink { namespace blink {
MediaKeyNeededEventInit::MediaKeyNeededEventInit() MediaEncryptedEventInit::MediaEncryptedEventInit()
{ {
} }
MediaKeyNeededEvent::MediaKeyNeededEvent() MediaEncryptedEvent::MediaEncryptedEvent()
{ {
} }
MediaKeyNeededEvent::MediaKeyNeededEvent(const AtomicString& type, const MediaKeyNeededEventInit& initializer) MediaEncryptedEvent::MediaEncryptedEvent(const AtomicString& type, const MediaEncryptedEventInit& initializer)
: Event(type, initializer) : Event(type, initializer)
, m_contentType(initializer.contentType) , m_initDataType(initializer.initDataType)
, m_initData(initializer.initData) , m_initData(initializer.initData)
{ {
} }
MediaKeyNeededEvent::~MediaKeyNeededEvent() MediaEncryptedEvent::~MediaEncryptedEvent()
{ {
} }
const AtomicString& MediaKeyNeededEvent::interfaceName() const const AtomicString& MediaEncryptedEvent::interfaceName() const
{ {
return EventNames::MediaKeyNeededEvent; return EventNames::MediaEncryptedEvent;
} }
void MediaKeyNeededEvent::trace(Visitor* visitor) void MediaEncryptedEvent::trace(Visitor* visitor)
{ {
Event::trace(visitor); Event::trace(visitor);
} }
......
...@@ -23,51 +23,51 @@ ...@@ -23,51 +23,51 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef MediaKeyNeededEvent_h #ifndef MediaEncryptedEvent_h
#define MediaKeyNeededEvent_h #define MediaEncryptedEvent_h
#include "core/html/MediaKeyError.h"
#include "modules/EventModules.h" #include "modules/EventModules.h"
#include "wtf/ArrayBuffer.h"
namespace blink { namespace blink {
struct MediaKeyNeededEventInit : public EventInit { struct MediaEncryptedEventInit : public EventInit {
MediaKeyNeededEventInit(); MediaEncryptedEventInit();
String contentType; String initDataType;
RefPtr<Uint8Array> initData; RefPtr<ArrayBuffer> initData;
}; };
class MediaKeyNeededEvent final : public Event { class MediaEncryptedEvent final : public Event {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
virtual ~MediaKeyNeededEvent(); virtual ~MediaEncryptedEvent();
static PassRefPtrWillBeRawPtr<MediaKeyNeededEvent> create() static PassRefPtrWillBeRawPtr<MediaEncryptedEvent> create()
{ {
return adoptRefWillBeNoop(new MediaKeyNeededEvent); return adoptRefWillBeNoop(new MediaEncryptedEvent);
} }
static PassRefPtrWillBeRawPtr<MediaKeyNeededEvent> create(const AtomicString& type, const MediaKeyNeededEventInit& initializer) static PassRefPtrWillBeRawPtr<MediaEncryptedEvent> create(const AtomicString& type, const MediaEncryptedEventInit& initializer)
{ {
return adoptRefWillBeNoop(new MediaKeyNeededEvent(type, initializer)); return adoptRefWillBeNoop(new MediaEncryptedEvent(type, initializer));
} }
virtual const AtomicString& interfaceName() const override; virtual const AtomicString& interfaceName() const override;
String contentType() const { return m_contentType; } String initDataType() const { return m_initDataType; }
Uint8Array* initData() const { return m_initData.get(); } ArrayBuffer* initData() const { return m_initData.get(); }
virtual void trace(Visitor*) override; virtual void trace(Visitor*) override;
private: private:
MediaKeyNeededEvent(); MediaEncryptedEvent();
MediaKeyNeededEvent(const AtomicString& type, const MediaKeyNeededEventInit& initializer); MediaEncryptedEvent(const AtomicString& type, const MediaEncryptedEventInit& initializer);
String m_contentType; String m_initDataType;
RefPtr<Uint8Array> m_initData; RefPtr<ArrayBuffer> m_initData;
}; };
} // namespace blink } // namespace blink
#endif // MediaKeyNeededEvent_h #endif // MediaEncryptedEvent_h
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
[ [
EventConstructor, EventConstructor,
RuntimeEnabled=EncryptedMedia RuntimeEnabled=EncryptedMedia
] interface MediaKeyNeededEvent : Event { ] interface MediaEncryptedEvent : Event {
readonly attribute DOMString contentType; readonly attribute DOMString initDataType;
readonly attribute Uint8Array initData; readonly attribute ArrayBuffer? initData;
}; };
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
'device_orientation/DeviceRotationRate.idl', 'device_orientation/DeviceRotationRate.idl',
'encoding/TextDecoder.idl', 'encoding/TextDecoder.idl',
'encoding/TextEncoder.idl', 'encoding/TextEncoder.idl',
'encryptedmedia/MediaEncryptedEvent.idl',
'encryptedmedia/MediaKeyMessageEvent.idl', 'encryptedmedia/MediaKeyMessageEvent.idl',
'encryptedmedia/MediaKeyNeededEvent.idl',
'encryptedmedia/MediaKeySession.idl', 'encryptedmedia/MediaKeySession.idl',
'encryptedmedia/MediaKeys.idl', 'encryptedmedia/MediaKeys.idl',
'filesystem/DOMFileSystem.idl', 'filesystem/DOMFileSystem.idl',
...@@ -260,8 +260,8 @@ ...@@ -260,8 +260,8 @@
'device_light/DeviceLightEvent.idl', 'device_light/DeviceLightEvent.idl',
'device_orientation/DeviceMotionEvent.idl', 'device_orientation/DeviceMotionEvent.idl',
'device_orientation/DeviceOrientationEvent.idl', 'device_orientation/DeviceOrientationEvent.idl',
'encryptedmedia/MediaEncryptedEvent.idl',
'encryptedmedia/MediaKeyMessageEvent.idl', 'encryptedmedia/MediaKeyMessageEvent.idl',
'encryptedmedia/MediaKeyNeededEvent.idl',
'gamepad/GamepadEvent.idl', 'gamepad/GamepadEvent.idl',
'geofencing/GeofencingEvent.idl', 'geofencing/GeofencingEvent.idl',
'indexeddb/IDBVersionChangeEvent.idl', 'indexeddb/IDBVersionChangeEvent.idl',
...@@ -409,10 +409,10 @@ ...@@ -409,10 +409,10 @@
'encoding/TextEncoder.h', 'encoding/TextEncoder.h',
'encryptedmedia/HTMLMediaElementEncryptedMedia.cpp', 'encryptedmedia/HTMLMediaElementEncryptedMedia.cpp',
'encryptedmedia/HTMLMediaElementEncryptedMedia.h', 'encryptedmedia/HTMLMediaElementEncryptedMedia.h',
'encryptedmedia/MediaEncryptedEvent.cpp',
'encryptedmedia/MediaEncryptedEvent.h',
'encryptedmedia/MediaKeyMessageEvent.cpp', 'encryptedmedia/MediaKeyMessageEvent.cpp',
'encryptedmedia/MediaKeyMessageEvent.h', 'encryptedmedia/MediaKeyMessageEvent.h',
'encryptedmedia/MediaKeyNeededEvent.cpp',
'encryptedmedia/MediaKeyNeededEvent.h',
'encryptedmedia/MediaKeySession.cpp', 'encryptedmedia/MediaKeySession.cpp',
'encryptedmedia/MediaKeySession.h', 'encryptedmedia/MediaKeySession.h',
'encryptedmedia/MediaKeys.cpp', 'encryptedmedia/MediaKeys.cpp',
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "core/rendering/RenderView.h" #include "core/rendering/RenderView.h"
#include "core/rendering/compositing/RenderLayerCompositor.h" #include "core/rendering/compositing/RenderLayerCompositor.h"
#include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h"
#include "modules/encryptedmedia/MediaKeyNeededEvent.h"
#include "modules/mediastream/MediaStreamRegistry.h" #include "modules/mediastream/MediaStreamRegistry.h"
#include "platform/audio/AudioBus.h" #include "platform/audio/AudioBus.h"
#include "platform/audio/AudioSourceProviderClient.h" #include "platform/audio/AudioSourceProviderClient.h"
...@@ -126,7 +125,12 @@ void WebMediaPlayerClientImpl::keyMessage(const WebString& keySystem, const WebS ...@@ -126,7 +125,12 @@ void WebMediaPlayerClientImpl::keyMessage(const WebString& keySystem, const WebS
void WebMediaPlayerClientImpl::keyNeeded(const WebString& contentType, const unsigned char* initData, unsigned initDataLength) void WebMediaPlayerClientImpl::keyNeeded(const WebString& contentType, const unsigned char* initData, unsigned initDataLength)
{ {
HTMLMediaElementEncryptedMedia::keyNeeded(mediaElement(), contentType, initData, initDataLength); HTMLMediaElementEncryptedMedia::encrypted(mediaElement(), contentType, initData, initDataLength);
}
void WebMediaPlayerClientImpl::encrypted(const WebString& initDataType, const unsigned char* initData, unsigned initDataLength)
{
HTMLMediaElementEncryptedMedia::encrypted(mediaElement(), initDataType, initData, initDataLength);
} }
void WebMediaPlayerClientImpl::setWebLayer(WebLayer* layer) void WebMediaPlayerClientImpl::setWebLayer(WebLayer* layer)
......
...@@ -70,7 +70,9 @@ public: ...@@ -70,7 +70,9 @@ public:
virtual void keyAdded(const WebString& keySystem, const WebString& sessionId) override; virtual void keyAdded(const WebString& keySystem, const WebString& sessionId) override;
virtual void keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode, unsigned short systemCode) override; virtual void keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode, unsigned short systemCode) override;
virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL) override; virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL) override;
// FIXME: Remove keyNeeded() once rename to encrypted() is complete.
virtual void keyNeeded(const WebString& contentType, const unsigned char* initData, unsigned initDataLength) override; virtual void keyNeeded(const WebString& contentType, const unsigned char* initData, unsigned initDataLength) override;
virtual void encrypted(const WebString& initDataType, const unsigned char* initData, unsigned initDataLength) override;
virtual void setWebLayer(WebLayer*) override; virtual void setWebLayer(WebLayer*) override;
virtual WebMediaPlayer::TrackId addAudioTrack(const WebString& id, AudioTrackKind, const WebString& label, const WebString& language, bool enabled) override; virtual WebMediaPlayer::TrackId addAudioTrack(const WebString& id, AudioTrackKind, const WebString& label, const WebString& language, bool enabled) override;
......
...@@ -83,7 +83,9 @@ public: ...@@ -83,7 +83,9 @@ public:
virtual void keyAdded(const WebString& keySystem, const WebString& sessionId) = 0; virtual void keyAdded(const WebString& keySystem, const WebString& sessionId) = 0;
virtual void keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode, unsigned short systemCode) = 0; virtual void keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode, unsigned short systemCode) = 0;
virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL) = 0; virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL) = 0;
// FIXME: Remove keyNeeded() once rename to encrypted() is complete.
virtual void keyNeeded(const WebString& contentType, const unsigned char* initData, unsigned initDataLength) = 0; virtual void keyNeeded(const WebString& contentType, const unsigned char* initData, unsigned initDataLength) = 0;
virtual void encrypted(const WebString& initDataType, const unsigned char* initData, unsigned initDataLength) = 0;
virtual void setWebLayer(WebLayer*) = 0; virtual void setWebLayer(WebLayer*) = 0;
virtual WebMediaPlayer::TrackId addAudioTrack(const WebString& id, AudioTrackKind, const WebString& label, const WebString& language, bool enabled) = 0; virtual WebMediaPlayer::TrackId addAudioTrack(const WebString& id, AudioTrackKind, const WebString& label, const WebString& language, bool enabled) = 0;
virtual void removeAudioTrack(WebMediaPlayer::TrackId) = 0; virtual void removeAudioTrack(WebMediaPlayer::TrackId) = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment