Index: third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp b/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
index bab33a8f6364bc624608704914371f5c3416cda8..ac877066e86adb133a4ebefe6ab86afe63af050b 100644 |
--- a/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
+++ b/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp |
@@ -13,8 +13,6 @@ |
#include "core/dom/DOMTypedArray.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/html/HTMLMediaElement.h" |
-#include "core/html/MediaKeyError.h" |
-#include "core/html/MediaKeyEvent.h" |
#include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" |
#include "modules/encryptedmedia/EncryptedMediaUtils.h" |
#include "modules/encryptedmedia/MediaEncryptedEvent.h" |
@@ -26,26 +24,6 @@ |
namespace blink { |
-static void throwExceptionIfMediaKeyExceptionOccurred(const String& keySystem, const String& sessionId, WebMediaPlayer::MediaKeyException exception, ExceptionState& exceptionState) |
-{ |
- switch (exception) { |
- case WebMediaPlayer::MediaKeyExceptionNoError: |
- return; |
- case WebMediaPlayer::MediaKeyExceptionInvalidPlayerState: |
- exceptionState.throwDOMException(InvalidStateError, "The player is in an invalid state."); |
- return; |
- case WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported: |
- exceptionState.throwDOMException(NotSupportedError, "The key system provided ('" + keySystem +"') is not supported."); |
- return; |
- case WebMediaPlayer::MediaKeyExceptionInvalidAccess: |
- exceptionState.throwDOMException(InvalidAccessError, "The session ID provided ('" + sessionId + "') is invalid."); |
- return; |
- } |
- |
- ASSERT_NOT_REACHED(); |
- return; |
-} |
- |
// This class allows MediaKeys to be set asynchronously. |
class SetMediaKeysHandler : public ScriptPromiseResolver { |
WTF_MAKE_NONCOPYABLE(SetMediaKeysHandler); |
@@ -292,7 +270,6 @@ DEFINE_TRACE(SetMediaKeysHandler) |
HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia(HTMLMediaElement& element) |
: m_mediaElement(&element) |
- , m_emeMode(EmeModeNotSelected) |
, m_isWaitingForKey(false) |
{ |
} |
@@ -321,15 +298,6 @@ HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl |
return *supplement; |
} |
-bool HTMLMediaElementEncryptedMedia::setEmeMode(EmeMode emeMode) |
-{ |
- if (m_emeMode != EmeModeNotSelected && m_emeMode != emeMode) |
- return false; |
- |
- m_emeMode = emeMode; |
- return true; |
-} |
- |
MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) |
{ |
HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element); |
@@ -341,9 +309,6 @@ ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt |
HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element); |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::setMediaKeys current(%p), new(%p)", thisElement.m_mediaKeys.get(), mediaKeys); |
- if (!thisElement.setEmeMode(EmeModeUnprefixed)) |
- return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "Mixed use of EME prefixed and unprefixed API not allowed.")); |
- |
// 1. If mediaKeys and the mediaKeys attribute are the same object, return |
// a promise resolved with undefined. |
if (thisElement.m_mediaKeys == mediaKeys) |
@@ -365,198 +330,6 @@ static PassRefPtrWillBeRawPtr<Event> createEncryptedEvent(WebEncryptedMediaInitD |
return MediaEncryptedEvent::create(EventTypeNames::encrypted, initializer); |
} |
-// Create a 'needkey' MediaKeyEvent for v0.1b EME. |
-static PassRefPtrWillBeRawPtr<Event> createWebkitNeedKeyEvent(const unsigned char* initData, unsigned initDataLength) |
-{ |
- MediaKeyEventInit webkitInitializer; |
- webkitInitializer.setInitData(DOMUint8Array::create(initData, initDataLength)); |
- |
- return MediaKeyEvent::create(EventTypeNames::webkitneedkey, webkitInitializer); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest(HTMLMediaElement& element, const String& keySystem, PassRefPtr<DOMUint8Array> initData, ExceptionState& exceptionState) |
-{ |
- HTMLMediaElementEncryptedMedia::from(element).generateKeyRequest(element.webMediaPlayer(), keySystem, initData, exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::generateKeyRequest(WebMediaPlayer* webMediaPlayer, const String& keySystem, PassRefPtr<DOMUint8Array> initData, ExceptionState& exceptionState) |
-{ |
- WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest"); |
- |
- if (!setEmeMode(EmeModePrefixed)) { |
- exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME prefixed and unprefixed API not allowed."); |
- return; |
- } |
- |
- if (keySystem.isEmpty()) { |
- exceptionState.throwDOMException(SyntaxError, "The key system provided is empty."); |
- return; |
- } |
- |
- if (!webMediaPlayer) { |
- exceptionState.throwDOMException(InvalidStateError, "No media has been loaded."); |
- return; |
- } |
- |
- const unsigned char* initDataPointer = 0; |
- unsigned initDataLength = 0; |
- if (initData) { |
- initDataPointer = initData->data(); |
- initDataLength = initData->length(); |
- } |
- |
- WebMediaPlayer::MediaKeyException result = webMediaPlayer->generateKeyRequest(keySystem, initDataPointer, initDataLength); |
- throwExceptionIfMediaKeyExceptionOccurred(keySystem, String(), result, exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest(HTMLMediaElement& mediaElement, const String& keySystem, ExceptionState& exceptionState) |
-{ |
- webkitGenerateKeyRequest(mediaElement, keySystem, DOMUint8Array::create(0), exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::webkitAddKey(HTMLMediaElement& element, const String& keySystem, PassRefPtr<DOMUint8Array> key, PassRefPtr<DOMUint8Array> initData, const String& sessionId, ExceptionState& exceptionState) |
-{ |
- HTMLMediaElementEncryptedMedia::from(element).addKey(element.webMediaPlayer(), keySystem, key, initData, sessionId, exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::addKey(WebMediaPlayer* webMediaPlayer, const String& keySystem, PassRefPtr<DOMUint8Array> key, PassRefPtr<DOMUint8Array> initData, const String& sessionId, ExceptionState& exceptionState) |
-{ |
- WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitAddKey"); |
- |
- if (!setEmeMode(EmeModePrefixed)) { |
- exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME prefixed and unprefixed API not allowed."); |
- return; |
- } |
- |
- if (keySystem.isEmpty()) { |
- exceptionState.throwDOMException(SyntaxError, "The key system provided is empty."); |
- return; |
- } |
- |
- if (!key) { |
- exceptionState.throwDOMException(SyntaxError, "The key provided is invalid."); |
- return; |
- } |
- |
- if (!key->length()) { |
- exceptionState.throwDOMException(TypeMismatchError, "The key provided is invalid."); |
- return; |
- } |
- |
- if (!webMediaPlayer) { |
- exceptionState.throwDOMException(InvalidStateError, "No media has been loaded."); |
- return; |
- } |
- |
- const unsigned char* initDataPointer = 0; |
- unsigned initDataLength = 0; |
- if (initData) { |
- initDataPointer = initData->data(); |
- initDataLength = initData->length(); |
- } |
- |
- WebMediaPlayer::MediaKeyException result = webMediaPlayer->addKey(keySystem, key->data(), key->length(), initDataPointer, initDataLength, sessionId); |
- throwExceptionIfMediaKeyExceptionOccurred(keySystem, sessionId, result, exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::webkitAddKey(HTMLMediaElement& mediaElement, const String& keySystem, PassRefPtr<DOMUint8Array> key, ExceptionState& exceptionState) |
-{ |
- webkitAddKey(mediaElement, keySystem, key, DOMUint8Array::create(0), String(), exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest(HTMLMediaElement& element, const String& keySystem, const String& sessionId, ExceptionState& exceptionState) |
-{ |
- HTMLMediaElementEncryptedMedia::from(element).cancelKeyRequest(element.webMediaPlayer(), keySystem, sessionId, exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::cancelKeyRequest(WebMediaPlayer* webMediaPlayer, const String& keySystem, const String& sessionId, ExceptionState& exceptionState) |
-{ |
- WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest"); |
- |
- if (!setEmeMode(EmeModePrefixed)) { |
- exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME prefixed and unprefixed API not allowed."); |
- return; |
- } |
- |
- if (keySystem.isEmpty()) { |
- exceptionState.throwDOMException(SyntaxError, "The key system provided is empty."); |
- return; |
- } |
- |
- if (!webMediaPlayer) { |
- exceptionState.throwDOMException(InvalidStateError, "No media has been loaded."); |
- return; |
- } |
- |
- WebMediaPlayer::MediaKeyException result = webMediaPlayer->cancelKeyRequest(keySystem, sessionId); |
- throwExceptionIfMediaKeyExceptionOccurred(keySystem, sessionId, result, exceptionState); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::keyAdded(const WebString& keySystem, const WebString& sessionId) |
-{ |
- WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyAdded"); |
- |
- MediaKeyEventInit initializer; |
- initializer.setKeySystem(keySystem); |
- initializer.setSessionId(sessionId); |
- |
- RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyadded, initializer); |
- event->setTarget(m_mediaElement); |
- m_mediaElement->scheduleEvent(event.release()); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::keyError(const WebString& keySystem, const WebString& sessionId, WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCode errorCode, unsigned short systemCode) |
-{ |
- WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyError: sessionID=%s, errorCode=%d, systemCode=%d", sessionId.utf8().data(), errorCode, systemCode); |
- |
- MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
- switch (errorCode) { |
- case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeUnknown: |
- mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; |
- break; |
- case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeClient: |
- mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; |
- break; |
- case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeService: |
- mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_SERVICE; |
- break; |
- case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeOutput: |
- mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_OUTPUT; |
- break; |
- case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeHardwareChange: |
- mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_HARDWARECHANGE; |
- break; |
- case WebMediaPlayerEncryptedMediaClient::MediaKeyErrorCodeDomain: |
- mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_DOMAIN; |
- break; |
- } |
- |
- MediaKeyEventInit initializer; |
- initializer.setKeySystem(keySystem); |
- initializer.setSessionId(sessionId); |
- initializer.setErrorCode(MediaKeyError::create(mediaKeyErrorCode)); |
- initializer.setSystemCode(systemCode); |
- |
- RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyerror, initializer); |
- event->setTarget(m_mediaElement); |
- m_mediaElement->scheduleEvent(event.release()); |
-} |
- |
-void HTMLMediaElementEncryptedMedia::keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength, const WebURL& defaultURL) |
-{ |
- WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyMessage: sessionID=%s", sessionId.utf8().data()); |
- |
- MediaKeyEventInit initializer; |
- initializer.setKeySystem(keySystem); |
- initializer.setSessionId(sessionId); |
- initializer.setMessage(DOMUint8Array::create(message, messageLength)); |
- initializer.setDefaultURL(KURL(defaultURL)); |
- |
- RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeymessage, initializer); |
- event->setTarget(m_mediaElement); |
- m_mediaElement->scheduleEvent(event.release()); |
-} |
- |
void HTMLMediaElementEncryptedMedia::encrypted(WebEncryptedMediaInitDataType initDataType, const unsigned char* initData, unsigned initDataLength) |
{ |
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::encrypted"); |
@@ -575,13 +348,6 @@ void HTMLMediaElementEncryptedMedia::encrypted(WebEncryptedMediaInitDataType ini |
event->setTarget(m_mediaElement); |
m_mediaElement->scheduleEvent(event.release()); |
} |
- |
- if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { |
- // Send event for v0.1b EME. |
- RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(initData, initDataLength); |
- event->setTarget(m_mediaElement); |
- m_mediaElement->scheduleEvent(event.release()); |
- } |
} |
void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey() |