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