| 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 #ifndef HTMLMediaElementEncryptedMedia_h | 5 #ifndef HTMLMediaElementEncryptedMedia_h |
| 6 #define HTMLMediaElementEncryptedMedia_h | 6 #define HTMLMediaElementEncryptedMedia_h |
| 7 | 7 |
| 8 #include "modules/EventTargetModules.h" | 8 #include "core/EventTypeNames.h" |
| 9 #include "core/dom/DOMTypedArray.h" |
| 10 #include "core/events/EventTarget.h" |
| 9 #include "platform/Supplementable.h" | 11 #include "platform/Supplementable.h" |
| 10 #include "platform/graphics/media/MediaPlayer.h" | 12 #include "platform/graphics/media/MediaPlayer.h" |
| 11 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 12 #include "public/platform/WebMediaPlayerClient.h" | 14 #include "public/platform/WebMediaPlayerClient.h" |
| 13 #include "wtf/Forward.h" | |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class ExceptionState; | 18 class ExceptionState; |
| 18 class HTMLMediaElement; | 19 class HTMLMediaElement; |
| 19 class MediaKeys; | 20 class MediaKeys; |
| 20 class ScriptPromise; | 21 class ScriptPromise; |
| 21 class ScriptState; | 22 class ScriptState; |
| 22 | 23 |
| 23 class HTMLMediaElementEncryptedMedia final : public NoBaseWillBeGarbageCollected
<HTMLMediaElementEncryptedMedia>, public WillBeHeapSupplement<HTMLMediaElement>
{ | 24 class HTMLMediaElementEncryptedMedia final : public NoBaseWillBeGarbageCollected
<HTMLMediaElementEncryptedMedia>, public WillBeHeapSupplement<HTMLMediaElement>
{ |
| 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElementEncryptedMedia); | 25 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElementEncryptedMedia); |
| 25 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMe
dia); | 26 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMe
dia); |
| 26 public: | 27 public: |
| 27 // encrypted media extensions (v0.1b) | 28 // encrypted media extensions (v0.1b) |
| 28 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys
tem, PassRefPtr<Uint8Array> initData, ExceptionState&); | 29 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys
tem, PassRefPtr<DOMUint8Array> initData, ExceptionState&); |
| 29 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys
tem, ExceptionState&); | 30 static void webkitGenerateKeyRequest(HTMLMediaElement&, const String& keySys
tem, ExceptionState&); |
| 30 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef
Ptr<Uint8Array> key, PassRefPtr<Uint8Array> initData, const String& sessionId, E
xceptionState&); | 31 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef
Ptr<DOMUint8Array> key, PassRefPtr<DOMUint8Array> initData, const String& sessio
nId, ExceptionState&); |
| 31 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef
Ptr<Uint8Array> key, ExceptionState&); | 32 static void webkitAddKey(HTMLMediaElement&, const String& keySystem, PassRef
Ptr<DOMUint8Array> key, ExceptionState&); |
| 32 static void webkitCancelKeyRequest(HTMLMediaElement&, const String& keySyste
m, const String& sessionId, ExceptionState&); | 33 static void webkitCancelKeyRequest(HTMLMediaElement&, const String& keySyste
m, const String& sessionId, ExceptionState&); |
| 33 | 34 |
| 34 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded); | 35 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded); |
| 35 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror); | 36 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror); |
| 36 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage); | 37 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage); |
| 37 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitneedkey); | 38 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(webkitneedkey); |
| 38 | 39 |
| 39 // encrypted media extensions (WD) | 40 // encrypted media extensions (WD) |
| 40 static MediaKeys* mediaKeys(HTMLMediaElement&); | 41 static MediaKeys* mediaKeys(HTMLMediaElement&); |
| 41 static ScriptPromise setMediaKeys(ScriptState*, HTMLMediaElement&, MediaKeys
*); | 42 static ScriptPromise setMediaKeys(ScriptState*, HTMLMediaElement&, MediaKeys
*); |
| 42 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(encrypted); | 43 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(encrypted); |
| 43 | 44 |
| 44 static void keyAdded(HTMLMediaElement&, const String& keySystem, const Strin
g& sessionId); | 45 static void keyAdded(HTMLMediaElement&, const String& keySystem, const Strin
g& sessionId); |
| 45 static void keyError(HTMLMediaElement&, const String& keySystem, const Strin
g& sessionId, WebMediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode
); | 46 static void keyError(HTMLMediaElement&, const String& keySystem, const Strin
g& sessionId, WebMediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode
); |
| 46 static void keyMessage(HTMLMediaElement&, const String& keySystem, const Str
ing& sessionId, const unsigned char* message, unsigned messageLength, const WebU
RL& defaultURL); | 47 static void keyMessage(HTMLMediaElement&, const String& keySystem, const Str
ing& sessionId, const unsigned char* message, unsigned messageLength, const WebU
RL& defaultURL); |
| 47 static void encrypted(HTMLMediaElement&, const String& initDataType, const u
nsigned char* initData, unsigned initDataLength); | 48 static void encrypted(HTMLMediaElement&, const String& initDataType, const u
nsigned char* initData, unsigned initDataLength); |
| 48 static void playerDestroyed(HTMLMediaElement&); | 49 static void playerDestroyed(HTMLMediaElement&); |
| 49 static WebContentDecryptionModule* contentDecryptionModule(HTMLMediaElement&
); | 50 static WebContentDecryptionModule* contentDecryptionModule(HTMLMediaElement&
); |
| 50 | 51 |
| 51 static HTMLMediaElementEncryptedMedia& from(HTMLMediaElement&); | 52 static HTMLMediaElementEncryptedMedia& from(HTMLMediaElement&); |
| 52 static const char* supplementName(); | 53 static const char* supplementName(); |
| 53 | 54 |
| 54 virtual void trace(Visitor*) override; | 55 virtual void trace(Visitor*) override; |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 friend class SetMediaKeysHandler; | 58 friend class SetMediaKeysHandler; |
| 58 | 59 |
| 59 HTMLMediaElementEncryptedMedia(); | 60 HTMLMediaElementEncryptedMedia(); |
| 60 void generateKeyRequest(WebMediaPlayer*, const String& keySystem, PassRefPtr
<Uint8Array> initData, ExceptionState&); | 61 void generateKeyRequest(WebMediaPlayer*, const String& keySystem, PassRefPtr
<DOMUint8Array> initData, ExceptionState&); |
| 61 void addKey(WebMediaPlayer*, const String& keySystem, PassRefPtr<Uint8Array>
key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionState&)
; | 62 void addKey(WebMediaPlayer*, const String& keySystem, PassRefPtr<DOMUint8Arr
ay> key, PassRefPtr<DOMUint8Array> initData, const String& sessionId, ExceptionS
tate&); |
| 62 void cancelKeyRequest(WebMediaPlayer*, const String& keySystem, const String
& sessionId, ExceptionState&); | 63 void cancelKeyRequest(WebMediaPlayer*, const String& keySystem, const String
& sessionId, ExceptionState&); |
| 63 | 64 |
| 64 // EventTarget | 65 // EventTarget |
| 65 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<Eve
ntListener>); | 66 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<Eve
ntListener>); |
| 66 EventListener* getAttributeEventListener(const AtomicString& eventType); | 67 EventListener* getAttributeEventListener(const AtomicString& eventType); |
| 67 | 68 |
| 68 // Currently we have both EME v0.1b and EME WD implemented in media element. | 69 // Currently we have both EME v0.1b and EME WD implemented in media element. |
| 69 // But we do not want to support both at the same time. The one used first | 70 // But we do not want to support both at the same time. The one used first |
| 70 // will be supported. Use |m_emeMode| to track this selection. | 71 // will be supported. Use |m_emeMode| to track this selection. |
| 71 // FIXME: Remove EmeMode once EME v0.1b support is removed. See crbug.com/24
9976. | 72 // FIXME: Remove EmeMode once EME v0.1b support is removed. See crbug.com/24
9976. |
| 72 enum EmeMode { EmeModeNotSelected, EmeModePrefixed, EmeModeUnprefixed }; | 73 enum EmeMode { EmeModeNotSelected, EmeModePrefixed, EmeModeUnprefixed }; |
| 73 | 74 |
| 74 // check (and set if necessary) the encrypted media extensions (EME) mode | 75 // check (and set if necessary) the encrypted media extensions (EME) mode |
| 75 // (v0.1b or WD). Returns whether the mode is allowed and successfully set. | 76 // (v0.1b or WD). Returns whether the mode is allowed and successfully set. |
| 76 bool setEmeMode(EmeMode); | 77 bool setEmeMode(EmeMode); |
| 77 | 78 |
| 78 WebContentDecryptionModule* contentDecryptionModule(); | 79 WebContentDecryptionModule* contentDecryptionModule(); |
| 79 | 80 |
| 80 EmeMode m_emeMode; | 81 EmeMode m_emeMode; |
| 81 | 82 |
| 82 PersistentWillBeMember<MediaKeys> m_mediaKeys; | 83 PersistentWillBeMember<MediaKeys> m_mediaKeys; |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 } // namespace blink | 86 } // namespace blink |
| 86 | 87 |
| 87 #endif | 88 #endif |
| OLD | NEW |