[Speculative revert to fix browser_tests on Blink canaries.]

Revert "Remove "needkey" event and add it's replacement, "encrypted"."

This reverts commit ad09c3ed1914691ee4a089cfe95988892ed42407.

BUG=
TBR=sandersd

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

git-svn-id: svn://svn.chromium.org/blink/trunk@183580 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c3897cd3
Test reloading during encrypted media playback. Test reloading during encrypted media playback.
EVENT(encrypted) EVENT(needkey)
EVENT(encrypted) EVENT(needkey)
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 onEncrypted(event) function onNeedKey(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaKeyNeededEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'needkey');
// 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.initDataType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.contentType, 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('encrypted', video, onEncrypted, test); waitForEventAndRunStep('needkey', video, onNeedKey, 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 encrypted event is fired on an encrypted media file. Test that needkey event is fired on an encrypted media file.
EVENT(encrypted) EVENT(needkey)
EVENT(encrypted) EVENT(needkey)
This is a testharness.js-based test. This is a testharness.js-based test.
PASS encrypted fired on encrypted media file. PASS Needkey 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>onencrypted</title> <title>NeedKey</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 encrypted event is fired on an encrypted media file.</p> <p>Test that needkey event is fired on an encrypted media file.</p>
<script> <script>
var expectedInitData = stringToUint8Array('0123456789012345'); var expectedInitData = stringToUint8Array('0123456789012345');
...@@ -20,21 +20,20 @@ ...@@ -20,21 +20,20 @@
{ {
var video = document.getElementById('testVideo'); var video = document.getElementById('testVideo');
var onEncrypted = function(event) var onNeedKey = function(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaKeyNeededEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'needkey');
assert_equals(event.initDataType, 'webm'); assert_array_equals(event.initData, expectedInitData);
assert_array_equals(new Uint8Array(event.initData), expectedInitData);
if (--expectedEvents == 0) if (--expectedEvents == 0)
test.done(); test.done();
}; };
waitForEventAndRunStep('encrypted', video, onEncrypted, test); waitForEventAndRunStep('needkey', video, onNeedKey, test);
video.src = '../content/test-encrypted.webm'; video.src = '../content/test-encrypted.webm';
}, 'encrypted fired on encrypted media file.'); }, 'Needkey 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(encrypted) EVENT(needkey)
EVENT(encrypted) EVENT(needkey)
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 onEncrypted(event) function onNeedKey(event)
{ {
var keyId = String.fromCharCode.apply(null, new Uint8Array(event.initData)); var keyId = String.fromCharCode.apply(null, 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.initDataType, event.initData).then(function() { mediaKeySession.generateRequest(event.contentType, 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('encrypted', video, onEncrypted, test); waitForEventAndRunStep('needkey', video, onNeedKey, 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(encrypted) EVENT(needkey)
EVENT(encrypted) EVENT(needkey)
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 onEncrypted(event) function onNeedKey(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaKeyNeededEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'needkey');
// 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.initDataType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.contentType, 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('encrypted', video, onEncrypted, test); waitForEventAndRunStep('needkey', video, onNeedKey, 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(encrypted) EVENT(needkey)
EVENT(encrypted) EVENT(needkey)
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 onEncrypted(event) function onNeedKey(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaKeyNeededEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'needkey');
// 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.initDataType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.contentType, 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('encrypted', video, onEncrypted, test); waitForEventAndRunStep('needkey', video, onNeedKey, 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, onencrypted. // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, mediakeys, onneedkey.
</script> </script>
</body> </body>
</html> </html>
EVENT(encrypted) EVENT(needkey)
EVENT(encrypted) EVENT(needkey)
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 onEncrypted(event) function onNeedKey(event)
{ {
assert_equals(event.target, video); assert_equals(event.target, video);
assert_true(event instanceof window.MediaEncryptedEvent); assert_true(event instanceof window.MediaKeyNeededEvent);
assert_equals(event.type, 'encrypted'); assert_equals(event.type, 'needkey');
// 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.initDataType, event.initData).catch(function(error) { mediaKeySession.generateRequest(event.contentType, 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('encrypted', video, onEncrypted, test); waitForEventAndRunStep('needkey', video, onNeedKey, 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.MediaKeyEvent == 'true') OK EXPECTED (keyNeededEvent instanceof window.MediaKeyNeededEvent == '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("MediaKeyEvent"); var keyNeededEvent = document.createEvent("MediaKeyNeededEvent");
testExpected("keyNeededEvent", null, "!="); testExpected("keyNeededEvent", null, "!=");
testExpected("keyNeededEvent instanceof window.MediaKeyEvent", true); testExpected("keyNeededEvent instanceof window.MediaKeyNeededEvent", 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,7 +75,6 @@ dragstart ...@@ -75,7 +75,6 @@ dragstart
drop drop
durationchange durationchange
emptied emptied
encrypted
end end
ended ended
endEvent endEvent
...@@ -131,6 +130,7 @@ mouseover ...@@ -131,6 +130,7 @@ mouseover
mouseup mouseup
mousewheel mousewheel
mute mute
needkey
negotiationneeded negotiationneeded
nomatch nomatch
noupdate noupdate
......
...@@ -14,13 +14,12 @@ ...@@ -14,13 +14,12 @@
#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/MediaEncryptedEvent.h" #include "modules/encryptedmedia/MediaKeyNeededEvent.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"
...@@ -287,20 +286,20 @@ ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt ...@@ -287,20 +286,20 @@ ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt
return SetMediaKeysHandler::create(scriptState, element, mediaKeys); return SetMediaKeysHandler::create(scriptState, element, mediaKeys);
} }
// Create a MediaEncryptedEvent for WD EME. // Create a MediaKeyNeededEvent for WD EME.
static PassRefPtrWillBeRawPtr<Event> createEncryptedEvent(const String& initDataType, const unsigned char* initData, unsigned initDataLength) static PassRefPtrWillBeRawPtr<Event> createNeedKeyEvent(const String& contentType, const unsigned char* initData, unsigned initDataLength)
{ {
MediaEncryptedEventInit initializer; MediaKeyNeededEventInit initializer;
initializer.initDataType = initDataType; initializer.contentType = contentType;
initializer.initData = ArrayBuffer::create(initData, initDataLength); initializer.initData = Uint8Array::create(initData, initDataLength);
initializer.bubbles = false; initializer.bubbles = false;
initializer.cancelable = false; initializer.cancelable = false;
return MediaEncryptedEvent::create(EventTypeNames::encrypted, initializer); return MediaKeyNeededEvent::create(EventTypeNames::needkey, initializer);
} }
// Create a 'needkey' MediaKeyEvent for v0.1b EME. // Create a 'needkey' MediaKeyEvent for v0.1b EME.
static PassRefPtrWillBeRawPtr<Event> createWebkitNeedKeyEvent(const unsigned char* initData, unsigned initDataLength) static PassRefPtrWillBeRawPtr<Event> createWebkitNeedKeyEvent(const String& contentType, const unsigned char* initData, unsigned initDataLength)
{ {
MediaKeyEventInit webkitInitializer; MediaKeyEventInit webkitInitializer;
webkitInitializer.keySystem = String(); webkitInitializer.keySystem = String();
...@@ -501,21 +500,20 @@ void HTMLMediaElementEncryptedMedia::keyMessage(HTMLMediaElement& element, const ...@@ -501,21 +500,20 @@ void HTMLMediaElementEncryptedMedia::keyMessage(HTMLMediaElement& element, const
element.scheduleEvent(event.release()); element.scheduleEvent(event.release());
} }
void HTMLMediaElementEncryptedMedia::encrypted(HTMLMediaElement& element, const String& initDataType, const unsigned char* initData, unsigned initDataLength) void HTMLMediaElementEncryptedMedia::keyNeeded(HTMLMediaElement& element, const String& contentType, const unsigned char* initData, unsigned initDataLength)
{ {
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::encrypted: initDataType=%s", initDataType.utf8().data()); WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyNeeded: contentType=%s", contentType.utf8().data());
if (RuntimeEnabledFeatures::encryptedMediaEnabled()) { if (RuntimeEnabledFeatures::encryptedMediaEnabled()) {
// Send event for WD EME. // Send event for WD EME.
// FIXME: Check origin before providing initData. http://crbug.com/418233. RefPtrWillBeRawPtr<Event> event = createNeedKeyEvent(contentType, initData, initDataLength);
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(initData, initDataLength); RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(contentType, 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(encrypted); DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(needkey);
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 encrypted(HTMLMediaElement&, const String& initDataType, const unsigned char* initData, unsigned initDataLength); static void keyNeeded(HTMLMediaElement&, const String& contentType, 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 onencrypted; [RuntimeEnabled=EncryptedMedia] attribute EventHandler onneedkey;
}; };
...@@ -24,35 +24,37 @@ ...@@ -24,35 +24,37 @@
*/ */
#include "config.h" #include "config.h"
#include "modules/encryptedmedia/MediaEncryptedEvent.h" #include "modules/encryptedmedia/MediaKeyNeededEvent.h"
#include "wtf/Uint8Array.h"
namespace blink { namespace blink {
MediaEncryptedEventInit::MediaEncryptedEventInit() MediaKeyNeededEventInit::MediaKeyNeededEventInit()
{ {
} }
MediaEncryptedEvent::MediaEncryptedEvent() MediaKeyNeededEvent::MediaKeyNeededEvent()
{ {
} }
MediaEncryptedEvent::MediaEncryptedEvent(const AtomicString& type, const MediaEncryptedEventInit& initializer) MediaKeyNeededEvent::MediaKeyNeededEvent(const AtomicString& type, const MediaKeyNeededEventInit& initializer)
: Event(type, initializer) : Event(type, initializer)
, m_initDataType(initializer.initDataType) , m_contentType(initializer.contentType)
, m_initData(initializer.initData) , m_initData(initializer.initData)
{ {
} }
MediaEncryptedEvent::~MediaEncryptedEvent() MediaKeyNeededEvent::~MediaKeyNeededEvent()
{ {
} }
const AtomicString& MediaEncryptedEvent::interfaceName() const const AtomicString& MediaKeyNeededEvent::interfaceName() const
{ {
return EventNames::MediaEncryptedEvent; return EventNames::MediaKeyNeededEvent;
} }
void MediaEncryptedEvent::trace(Visitor* visitor) void MediaKeyNeededEvent::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 MediaEncryptedEvent_h #ifndef MediaKeyNeededEvent_h
#define MediaEncryptedEvent_h #define MediaKeyNeededEvent_h
#include "core/html/MediaKeyError.h"
#include "modules/EventModules.h" #include "modules/EventModules.h"
#include "wtf/ArrayBuffer.h"
namespace blink { namespace blink {
struct MediaEncryptedEventInit : public EventInit { struct MediaKeyNeededEventInit : public EventInit {
MediaEncryptedEventInit(); MediaKeyNeededEventInit();
String initDataType; String contentType;
RefPtr<ArrayBuffer> initData; RefPtr<Uint8Array> initData;
}; };
class MediaEncryptedEvent final : public Event { class MediaKeyNeededEvent final : public Event {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
virtual ~MediaEncryptedEvent(); virtual ~MediaKeyNeededEvent();
static PassRefPtrWillBeRawPtr<MediaEncryptedEvent> create() static PassRefPtrWillBeRawPtr<MediaKeyNeededEvent> create()
{ {
return adoptRefWillBeNoop(new MediaEncryptedEvent); return adoptRefWillBeNoop(new MediaKeyNeededEvent);
} }
static PassRefPtrWillBeRawPtr<MediaEncryptedEvent> create(const AtomicString& type, const MediaEncryptedEventInit& initializer) static PassRefPtrWillBeRawPtr<MediaKeyNeededEvent> create(const AtomicString& type, const MediaKeyNeededEventInit& initializer)
{ {
return adoptRefWillBeNoop(new MediaEncryptedEvent(type, initializer)); return adoptRefWillBeNoop(new MediaKeyNeededEvent(type, initializer));
} }
virtual const AtomicString& interfaceName() const override; virtual const AtomicString& interfaceName() const override;
String initDataType() const { return m_initDataType; } String contentType() const { return m_contentType; }
ArrayBuffer* initData() const { return m_initData.get(); } Uint8Array* initData() const { return m_initData.get(); }
virtual void trace(Visitor*) override; virtual void trace(Visitor*) override;
private: private:
MediaEncryptedEvent(); MediaKeyNeededEvent();
MediaEncryptedEvent(const AtomicString& type, const MediaEncryptedEventInit& initializer); MediaKeyNeededEvent(const AtomicString& type, const MediaKeyNeededEventInit& initializer);
String m_initDataType; String m_contentType;
RefPtr<ArrayBuffer> m_initData; RefPtr<Uint8Array> m_initData;
}; };
} // namespace blink } // namespace blink
#endif // MediaEncryptedEvent_h #endif // MediaKeyNeededEvent_h
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
[ [
EventConstructor, EventConstructor,
RuntimeEnabled=EncryptedMedia RuntimeEnabled=EncryptedMedia
] interface MediaEncryptedEvent : Event { ] interface MediaKeyNeededEvent : Event {
readonly attribute DOMString initDataType; readonly attribute DOMString contentType;
readonly attribute ArrayBuffer? initData; readonly attribute Uint8Array 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,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#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"
...@@ -125,12 +126,7 @@ void WebMediaPlayerClientImpl::keyMessage(const WebString& keySystem, const WebS ...@@ -125,12 +126,7 @@ 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::encrypted(mediaElement(), contentType, initData, initDataLength); HTMLMediaElementEncryptedMedia::keyNeeded(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,9 +70,7 @@ public: ...@@ -70,9 +70,7 @@ 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,9 +83,7 @@ public: ...@@ -83,9 +83,7 @@ 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