Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | 6 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 11 #include "bindings/core/v8/ScriptState.h" | 11 #include "bindings/core/v8/ScriptState.h" |
| 12 #include "core/dom/DOMException.h" | 12 #include "core/dom/DOMException.h" |
| 13 #include "core/dom/ExceptionCode.h" | 13 #include "core/dom/ExceptionCode.h" |
| 14 #include "core/html/HTMLMediaElement.h" | 14 #include "core/html/HTMLMediaElement.h" |
| 15 #include "core/html/MediaKeyError.h" | 15 #include "core/html/MediaKeyError.h" |
| 16 #include "core/html/MediaKeyEvent.h" | 16 #include "core/html/MediaKeyEvent.h" |
| 17 #include "modules/encryptedmedia/MediaKeyNeededEvent.h" | 17 #include "modules/encryptedmedia/MediaEncryptedEvent.h" |
| 18 #include "modules/encryptedmedia/MediaKeys.h" | 18 #include "modules/encryptedmedia/MediaKeys.h" |
| 19 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" | 19 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" |
| 20 #include "platform/ContentDecryptionModuleResult.h" | 20 #include "platform/ContentDecryptionModuleResult.h" |
| 21 #include "platform/Logging.h" | 21 #include "platform/Logging.h" |
| 22 #include "platform/RuntimeEnabledFeatures.h" | 22 #include "platform/RuntimeEnabledFeatures.h" |
| 23 #include "wtf/ArrayBuffer.h" | |
| 23 #include "wtf/Functional.h" | 24 #include "wtf/Functional.h" |
| 24 #include "wtf/Uint8Array.h" | 25 #include "wtf/Uint8Array.h" |
| 25 | 26 |
| 26 namespace blink { | 27 namespace blink { |
| 27 | 28 |
| 28 static void throwExceptionIfMediaKeyExceptionOccurred(const String& keySystem, c onst String& sessionId, WebMediaPlayer::MediaKeyException exception, ExceptionSt ate& exceptionState) | 29 static void throwExceptionIfMediaKeyExceptionOccurred(const String& keySystem, c onst String& sessionId, WebMediaPlayer::MediaKeyException exception, ExceptionSt ate& exceptionState) |
| 29 { | 30 { |
| 30 switch (exception) { | 31 switch (exception) { |
| 31 case WebMediaPlayer::MediaKeyExceptionNoError: | 32 case WebMediaPlayer::MediaKeyExceptionNoError: |
| 32 return; | 33 return; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 | 280 |
| 280 // 1. If mediaKeys and the mediaKeys attribute are the same object, return | 281 // 1. If mediaKeys and the mediaKeys attribute are the same object, return |
| 281 // a promise resolved with undefined. | 282 // a promise resolved with undefined. |
| 282 if (thisElement.m_mediaKeys == mediaKeys) | 283 if (thisElement.m_mediaKeys == mediaKeys) |
| 283 return ScriptPromise::cast(scriptState, V8ValueTraits<V8UndefinedType>:: toV8Value(V8UndefinedType(), scriptState->context()->Global(), scriptState->isol ate())); | 284 return ScriptPromise::cast(scriptState, V8ValueTraits<V8UndefinedType>:: toV8Value(V8UndefinedType(), scriptState->context()->Global(), scriptState->isol ate())); |
| 284 | 285 |
| 285 // 2. Let promise be a new promise. Remaining steps done in handler. | 286 // 2. Let promise be a new promise. Remaining steps done in handler. |
| 286 return SetMediaKeysHandler::create(scriptState, element, mediaKeys); | 287 return SetMediaKeysHandler::create(scriptState, element, mediaKeys); |
| 287 } | 288 } |
| 288 | 289 |
| 289 // Create a MediaKeyNeededEvent for WD EME. | 290 // Create a MediaEncryptedEvent for WD EME. |
| 290 static PassRefPtrWillBeRawPtr<Event> createNeedKeyEvent(const String& contentTyp e, const unsigned char* initData, unsigned initDataLength) | 291 static PassRefPtrWillBeRawPtr<Event> createEncryptedEvent(const String& initData Type, const unsigned char* initData, unsigned initDataLength) |
| 291 { | 292 { |
| 292 MediaKeyNeededEventInit initializer; | 293 MediaEncryptedEventInit initializer; |
| 293 initializer.contentType = contentType; | 294 initializer.initDataType = initDataType; |
| 294 initializer.initData = Uint8Array::create(initData, initDataLength); | 295 initializer.initData = ArrayBuffer::create(initData, initDataLength); |
| 295 initializer.bubbles = false; | 296 initializer.bubbles = false; |
| 296 initializer.cancelable = false; | 297 initializer.cancelable = false; |
| 297 | 298 |
| 298 return MediaKeyNeededEvent::create(EventTypeNames::needkey, initializer); | 299 return MediaEncryptedEvent::create(EventTypeNames::encrypted, initializer); |
| 299 } | 300 } |
| 300 | 301 |
| 301 // Create a 'needkey' MediaKeyEvent for v0.1b EME. | 302 // Create a 'needkey' MediaKeyEvent for v0.1b EME. |
| 302 static PassRefPtrWillBeRawPtr<Event> createWebkitNeedKeyEvent(const String& cont entType, const unsigned char* initData, unsigned initDataLength) | 303 static PassRefPtrWillBeRawPtr<Event> createWebkitNeedKeyEvent(const unsigned cha r* initData, unsigned initDataLength) |
| 303 { | 304 { |
| 304 MediaKeyEventInit webkitInitializer; | 305 MediaKeyEventInit webkitInitializer; |
| 305 webkitInitializer.keySystem = String(); | 306 webkitInitializer.keySystem = String(); |
| 306 webkitInitializer.sessionId = String(); | 307 webkitInitializer.sessionId = String(); |
| 307 webkitInitializer.initData = Uint8Array::create(initData, initDataLength); | 308 webkitInitializer.initData = Uint8Array::create(initData, initDataLength); |
| 308 webkitInitializer.bubbles = false; | 309 webkitInitializer.bubbles = false; |
| 309 webkitInitializer.cancelable = false; | 310 webkitInitializer.cancelable = false; |
| 310 | 311 |
| 311 return MediaKeyEvent::create(EventTypeNames::webkitneedkey, webkitInitialize r); | 312 return MediaKeyEvent::create(EventTypeNames::webkitneedkey, webkitInitialize r); |
| 312 } | 313 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 initializer.message = Uint8Array::create(message, messageLength); | 494 initializer.message = Uint8Array::create(message, messageLength); |
| 494 initializer.defaultURL = KURL(defaultURL); | 495 initializer.defaultURL = KURL(defaultURL); |
| 495 initializer.bubbles = false; | 496 initializer.bubbles = false; |
| 496 initializer.cancelable = false; | 497 initializer.cancelable = false; |
| 497 | 498 |
| 498 RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webk itkeymessage, initializer); | 499 RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webk itkeymessage, initializer); |
| 499 event->setTarget(&element); | 500 event->setTarget(&element); |
| 500 element.scheduleEvent(event.release()); | 501 element.scheduleEvent(event.release()); |
| 501 } | 502 } |
| 502 | 503 |
| 503 void HTMLMediaElementEncryptedMedia::keyNeeded(HTMLMediaElement& element, const String& contentType, const unsigned char* initData, unsigned initDataLength) | 504 void HTMLMediaElementEncryptedMedia::keyNeeded(HTMLMediaElement& element, const String& initDataType, const unsigned char* initData, unsigned initDataLength) |
|
ddorwin
2014/09/29 23:26:41
We should rename this method. That involves the pu
sandersd (OOO until July 31)
2014/09/30 19:14:03
Done.
| |
| 504 { | 505 { |
| 505 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyNeeded: conten tType=%s", contentType.utf8().data()); | 506 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::keyNeeded: initDataType=%s", initDataType.utf8().data()); |
| 506 | 507 |
| 507 if (RuntimeEnabledFeatures::encryptedMediaEnabled()) { | 508 if (RuntimeEnabledFeatures::encryptedMediaEnabled()) { |
| 508 // Send event for WD EME. | 509 // Send event for WD EME. |
| 509 RefPtrWillBeRawPtr<Event> event = createNeedKeyEvent(contentType, initDa ta, initDataLength); | 510 // FIXME: Check origin before providing initData. http://crbug.com/41823 3. |
| 511 RefPtrWillBeRawPtr<Event> event = createEncryptedEvent(initDataType, ini tData, initDataLength); | |
| 510 event->setTarget(&element); | 512 event->setTarget(&element); |
| 511 element.scheduleEvent(event.release()); | 513 element.scheduleEvent(event.release()); |
| 512 } | 514 } |
| 513 | 515 |
| 514 if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { | 516 if (RuntimeEnabledFeatures::prefixedEncryptedMediaEnabled()) { |
| 515 // Send event for v0.1b EME. | 517 // Send event for v0.1b EME. |
| 516 RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(contentType, initData, initDataLength); | 518 RefPtrWillBeRawPtr<Event> event = createWebkitNeedKeyEvent(initData, ini tDataLength); |
| 517 event->setTarget(&element); | 519 event->setTarget(&element); |
| 518 element.scheduleEvent(event.release()); | 520 element.scheduleEvent(event.release()); |
| 519 } | 521 } |
| 520 } | 522 } |
| 521 | 523 |
| 522 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element) | 524 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element) |
| 523 { | 525 { |
| 524 #if ENABLE(OILPAN) | 526 #if ENABLE(OILPAN) |
| 525 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229 | 527 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229 |
| 526 if (element.isFinalizing()) | 528 if (element.isFinalizing()) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 541 return thisElement.contentDecryptionModule(); | 543 return thisElement.contentDecryptionModule(); |
| 542 } | 544 } |
| 543 | 545 |
| 544 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) | 546 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) |
| 545 { | 547 { |
| 546 visitor->trace(m_mediaKeys); | 548 visitor->trace(m_mediaKeys); |
| 547 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 549 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
| 548 } | 550 } |
| 549 | 551 |
| 550 } // namespace blink | 552 } // namespace blink |
| OLD | NEW |