Changeset 114067 in webkit
- Timestamp:
- Apr 12, 2012 6:32:36 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 23 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r114064 r114067 1 2012-04-12 David Dorwin <ddorwin@chromium.org> 2 3 Add Encrypted Media Extensions events and errors to HTMLMediaElement 4 https://bugs.webkit.org/show_bug.cgi?id=82974 5 6 Reviewed by Adam Barth. 7 8 The new events and errors are behind the ENABLE(ENCRYPTED_MEDIA) feature define. 9 Implementation is based on v0.1 of the draft proposal at 10 http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#events. 11 12 * fast/events/constructors/media-key-event-constructor-expected.txt: Added. 13 * fast/events/constructors/media-key-event-constructor.html: Added. 14 * fast/js/resources/js-test-pre.js: 15 (shouldBeZero): 16 (shouldBeEmptyString): 17 * media/encrypted-media/encrypted-media-constants-expected.txt: Added. 18 * media/encrypted-media/encrypted-media-constants.html: Added. 19 * media/encrypted-media/encrypted-media-events-expected.txt: Added. 20 * media/encrypted-media/encrypted-media-events.html: Added. 21 * media/video-test.js: 22 (testExpected): 23 (testArraysEqual): 24 1 25 2012-04-12 Pablo Flouret <pablof@motorola.com> 2 26 -
trunk/LayoutTests/fast/js/resources/js-test-pre.js
r110650 r114067 255 255 function shouldBeNaN(_a) { shouldBe(_a, "NaN"); } 256 256 function shouldBeNull(_a) { shouldBe(_a, "null"); } 257 function shouldBeZero(_a) { shouldBe(_a, "0"); } 257 258 258 259 function shouldBeEqualToString(a, b) … … 261 262 shouldBe(a, unevaledString); 262 263 } 264 265 function shouldBeEmptyString(_a) { shouldBeEqualToString(_a, ""); } 263 266 264 267 function shouldEvaluateTo(actual, expected) { -
trunk/LayoutTests/media/video-test.js
r107831 r114067 80 80 case '!=': success = observed != expected; break; 81 81 case '==': success = observed == expected; break; 82 case '===': success = observed === expected; break; 82 83 } 83 84 84 85 reportExpected(success, testFuncString, comparison, expected, observed) 86 } 87 88 function testArraysEqual(testFuncString, expected) 89 { 90 var observed; 91 try { 92 observed = eval(testFuncString); 93 } catch (ex) { 94 consoleWrite(ex); 95 return; 96 } 97 98 testExpected(testFuncString + ".length", expected.length); 99 100 for (var i = 0; i < observed.length; i++) { 101 testExpected(testFuncString + "[" + i + "]", expected[i]); 102 } 85 103 } 86 104 -
trunk/Source/WebCore/ChangeLog
r114065 r114067 1 2012-04-12 David Dorwin <ddorwin@chromium.org> 2 3 Add Encrypted Media Extensions events and errors to HTMLMediaElement 4 https://bugs.webkit.org/show_bug.cgi?id=82974 5 6 Reviewed by Adam Barth. 7 8 The new events and errors are behind the ENABLE(ENCRYPTED_MEDIA) feature define. 9 Implementation is based on v0.1 of the draft proposal at 10 http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#events. 11 12 Tests: fast/events/constructors/media-key-event-constructor.html 13 media/encrypted-media/encrypted-media-constants.html 14 media/encrypted-media/encrypted-media-events.html 15 16 * WebCore.gypi: 17 * bindings/v8/Dictionary.cpp: 18 (WebCore::Dictionary::get): 19 (WebCore): 20 * bindings/v8/Dictionary.h: 21 (WebCore): 22 (Dictionary): 23 * dom/EventNames.h: 24 (WebCore): 25 * dom/EventNames.in: 26 * html/HTMLAttributeNames.in: 27 * html/HTMLMediaElement.cpp: 28 (WebCore): 29 (WebCore::HTMLMediaElement::mediaPlayerKeyAdded): 30 (WebCore::HTMLMediaElement::mediaPlayerKeyError): 31 (WebCore::HTMLMediaElement::mediaPlayerKeyMessage): 32 (WebCore::HTMLMediaElement::mediaPlayerKeyNeeded): 33 * html/HTMLMediaElement.h: 34 (HTMLMediaElement): 35 * html/HTMLMediaElement.idl: 36 * html/MediaError.h: 37 * html/MediaError.idl: 38 * html/MediaKeyError.h: Added. 39 (WebCore): 40 (MediaKeyError): 41 (WebCore::MediaKeyError::create): 42 (WebCore::MediaKeyError::code): 43 (WebCore::MediaKeyError::MediaKeyError): 44 * html/MediaKeyError.idl: Added. 45 * html/MediaKeyEvent.cpp: Added. 46 (WebCore): 47 (WebCore::MediaKeyEventInit::MediaKeyEventInit): 48 (WebCore::MediaKeyEvent::MediaKeyEvent): 49 (WebCore::MediaKeyEvent::~MediaKeyEvent): 50 (WebCore::MediaKeyEvent::interfaceName): 51 * html/MediaKeyEvent.h: Added. 52 (WebCore): 53 (MediaKeyEventInit): 54 (MediaKeyEvent): 55 (WebCore::MediaKeyEvent::create): 56 (WebCore::MediaKeyEvent::keySystem): 57 (WebCore::MediaKeyEvent::sessionId): 58 (WebCore::MediaKeyEvent::initData): 59 (WebCore::MediaKeyEvent::message): 60 (WebCore::MediaKeyEvent::defaultURL): 61 (WebCore::MediaKeyEvent::errorCode): 62 (WebCore::MediaKeyEvent::systemCode): 63 * html/MediaKeyEvent.idl: Added. 64 * page/DOMWindow.idl: 65 * platform/graphics/MediaPlayer.cpp: 66 (WebCore): 67 (WebCore::MediaPlayer::keyAdded): 68 (WebCore::MediaPlayer::keyError): 69 (WebCore::MediaPlayer::keyMessage): 70 (WebCore::MediaPlayer::keyNeeded): 71 * platform/graphics/MediaPlayer.h: 72 (MediaPlayerClient): 73 (WebCore::MediaPlayerClient::mediaPlayerKeyAdded): 74 (WebCore::MediaPlayerClient::mediaPlayerKeyError): 75 (WebCore::MediaPlayerClient::mediaPlayerKeyMessage): 76 (WebCore::MediaPlayerClient::mediaPlayerKeyNeeded): 77 (MediaPlayer): 78 1 79 2012-04-12 Anders Carlsson <andersca@apple.com> 2 80 -
trunk/Source/WebCore/WebCore.gypi
r113966 r114067 1064 1064 'html/MediaController.idl', 1065 1065 'html/MediaError.idl', 1066 'html/MediaKeyError.idl', 1067 'html/MediaKeyEvent.idl', 1066 1068 'html/TextMetrics.idl', 1067 1069 'html/TimeRanges.idl', … … 5570 5572 'html/MediaFragmentURIParser.cpp', 5571 5573 'html/MediaFragmentURIParser.h', 5574 'html/MediaKeyError.h', 5575 'html/MediaKeyEvent.cpp', 5576 'html/MediaKeyEvent.h', 5572 5577 'html/MicroDataItemValue.cpp', 5573 5578 'html/MicroDataItemValue.h', … … 7568 7573 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaError.cpp', 7569 7574 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaError.h', 7575 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaKeyError.cpp', 7576 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaKeyError.h', 7577 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaKeyEvent.cpp', 7578 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaKeyEvent.h', 7570 7579 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaList.cpp', 7571 7580 '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaList.h', -
trunk/Source/WebCore/bindings/v8/Dictionary.cpp
r110547 r114067 31 31 #include "V8DOMWindow.h" 32 32 #include "V8Storage.h" 33 #include "V8Uint8Array.h" 33 34 #include "V8Utilities.h" 34 35 #include <wtf/MathExtras.h> … … 37 38 #include "IDBKeyRange.h" 38 39 #include "V8IDBKeyRange.h" 40 #endif 41 42 #if ENABLE(ENCRYPTED_MEDIA) 43 #include "V8MediaKeyError.h" 39 44 #endif 40 45 … … 294 299 } 295 300 301 bool Dictionary::get(const String& key, RefPtr<Uint8Array>& value) const 302 { 303 v8::Local<v8::Value> v8Value; 304 if (!getKey(key, v8Value)) 305 return false; 306 307 Uint8Array* source = 0; 308 if (v8Value->IsObject()) { 309 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); 310 311 v8::Handle<v8::Object> array = V8DOMWrapper::lookupDOMWrapper(V8Uint8Array::GetTemplate(), wrapper); 312 if (!array.IsEmpty()) 313 source = V8Uint8Array::toNative(array); 314 } 315 value = source; 316 return true; 317 } 318 319 #if ENABLE(ENCRYPTED_MEDIA) 320 bool Dictionary::get(const String& key, RefPtr<MediaKeyError>& value) const 321 { 322 v8::Local<v8::Value> v8Value; 323 if (!getKey(key, v8Value)) 324 return false; 325 326 MediaKeyError* source = 0; 327 if (v8Value->IsObject()) { 328 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); 329 330 v8::Handle<v8::Object> error = V8DOMWrapper::lookupDOMWrapper(V8MediaKeyError::GetTemplate(), wrapper); 331 if (!error.IsEmpty()) 332 source = V8MediaKeyError::toNative(error); 333 } 334 value = source; 335 return true; 336 } 337 #endif 338 296 339 #if ENABLE(VIDEO_TRACK) 297 340 bool Dictionary::get(const String& key, RefPtr<TrackBase>& value) const -
trunk/Source/WebCore/bindings/v8/Dictionary.h
r110547 r114067 40 40 class IDBKeyRange; 41 41 class Storage; 42 class MediaKeyError; 42 43 class TrackBase; 43 44 class SpeechRecognitionError; … … 68 69 bool get(const String&, RefPtr<Storage>&) const; 69 70 bool get(const String&, MessagePortArray&) const; 71 bool get(const String&, RefPtr<Uint8Array>&) const; 72 #if ENABLE(ENCRYPTED_MEDIA) 73 bool get(const String&, RefPtr<MediaKeyError>&) const; 74 #endif 70 75 #if ENABLE(VIDEO_TRACK) 71 76 bool get(const String&, RefPtr<TrackBase>&) const; -
trunk/Source/WebCore/dom/EventNames.h
r112815 r114067 162 162 macro(webkitsourceclose) \ 163 163 \ 164 macro(webkitkeyadded) \ 165 macro(webkitkeyerror) \ 166 macro(webkitkeymessage) \ 167 macro(webkitneedkey) \ 168 \ 164 169 macro(progress) \ 165 170 macro(stalled) \ -
trunk/Source/WebCore/dom/EventNames.in
r110420 r114067 43 43 DeviceOrientationEvent conditional=DEVICE_ORIENTATION 44 44 OrientationEvent interfaceName=Event, conditional=ORIENTATION_EVENTS 45 MediaKeyEvent conditional=ENCRYPTED_MEDIA 45 46 TrackEvent conditional=VIDEO_TRACK -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r113143 r114067 248 248 onwebkitfullscreenchange 249 249 onwebkitfullscreenerror 250 onwebkitkeyadded 251 onwebkitkeyerror 252 onwebkitkeymessage 253 onwebkitneedkey 250 254 onwebkittransitionend 251 255 open -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r114026 r114067 59 59 #include "MediaError.h" 60 60 #include "MediaFragmentURIParser.h" 61 #include "MediaKeyError.h" 62 #include "MediaKeyEvent.h" 61 63 #include "MediaList.h" 62 64 #include "MediaPlayer.h" … … 1688 1690 #endif 1689 1691 1692 #if ENABLE(ENCRYPTED_MEDIA) 1693 void HTMLMediaElement::mediaPlayerKeyAdded(MediaPlayer*, const String& keySystem, const String& sessionId) 1694 { 1695 MediaKeyEventInit initializer; 1696 initializer.keySystem = keySystem; 1697 initializer.sessionId = sessionId; 1698 initializer.bubbles = false; 1699 initializer.cancelable = false; 1700 1701 RefPtr<Event> event = MediaKeyEvent::create(eventNames().webkitkeyaddedEvent, initializer); 1702 event->setTarget(this); 1703 m_asyncEventQueue->enqueueEvent(event.release()); 1704 } 1705 1706 void HTMLMediaElement::mediaPlayerKeyError(MediaPlayer*, const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode errorCode, unsigned short systemCode) 1707 { 1708 MediaKeyError::Code mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; 1709 switch (errorCode) { 1710 case MediaPlayerClient::UnknownError: 1711 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_UNKNOWN; 1712 break; 1713 case MediaPlayerClient::ClientError: 1714 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_CLIENT; 1715 break; 1716 case MediaPlayerClient::ServiceError: 1717 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_SERVICE; 1718 break; 1719 case MediaPlayerClient::OutputError: 1720 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_OUTPUT; 1721 break; 1722 case MediaPlayerClient::HardwareChangeError: 1723 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_HARDWARECHANGE; 1724 break; 1725 case MediaPlayerClient::DomainError: 1726 mediaKeyErrorCode = MediaKeyError::MEDIA_KEYERR_DOMAIN; 1727 break; 1728 } 1729 1730 MediaKeyEventInit initializer; 1731 initializer.keySystem = keySystem; 1732 initializer.sessionId = sessionId; 1733 initializer.errorCode = MediaKeyError::create(mediaKeyErrorCode); 1734 initializer.systemCode = systemCode; 1735 initializer.bubbles = false; 1736 initializer.cancelable = false; 1737 1738 RefPtr<Event> event = MediaKeyEvent::create(eventNames().webkitkeyerrorEvent, initializer); 1739 event->setTarget(this); 1740 m_asyncEventQueue->enqueueEvent(event.release()); 1741 } 1742 1743 void HTMLMediaElement::mediaPlayerKeyMessage(MediaPlayer*, const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength) 1744 { 1745 MediaKeyEventInit initializer; 1746 initializer.keySystem = keySystem; 1747 initializer.sessionId = sessionId; 1748 initializer.message = Uint8Array::create(message, messageLength); 1749 initializer.bubbles = false; 1750 initializer.cancelable = false; 1751 1752 RefPtr<Event> event = MediaKeyEvent::create(eventNames().webkitkeymessageEvent, initializer); 1753 event->setTarget(this); 1754 m_asyncEventQueue->enqueueEvent(event.release()); 1755 } 1756 1757 void HTMLMediaElement::mediaPlayerKeyNeeded(MediaPlayer*, const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength) 1758 { 1759 MediaKeyEventInit initializer; 1760 initializer.keySystem = keySystem; 1761 initializer.sessionId = sessionId; 1762 initializer.initData = Uint8Array::create(initData, initDataLength); 1763 initializer.bubbles = false; 1764 initializer.cancelable = false; 1765 1766 RefPtr<Event> event = MediaKeyEvent::create(eventNames().webkitneedkeyEvent, initializer); 1767 event->setTarget(this); 1768 m_asyncEventQueue->enqueueEvent(event.release()); 1769 } 1770 #endif 1771 1690 1772 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1691 1773 { -
trunk/Source/WebCore/html/HTMLMediaElement.h
r113914 r114067 187 187 void webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, ExceptionCode&); 188 188 void webkitCancelKeyRequest(const String& keySystem, const String& sessionId, ExceptionCode&); 189 190 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded); 191 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror); 192 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage); 193 DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitneedkey); 189 194 #endif 190 195 … … 261 266 void updateWidget(PluginCreationOption); 262 267 #endif 268 269 // EventTarget function. 270 // Both Node (via HTMLElement) and ActiveDOMObject define this method, which 271 // causes an ambiguity error at compile time. This class's constructor 272 // ensures that both implementations return document, so return the result 273 // of one of them here. 274 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return HTMLElement::scriptExecutionContext(); } 263 275 264 276 bool hasSingleSecurityOrigin() const { return !m_player || m_player->hasSingleSecurityOrigin(); } … … 398 410 #endif 399 411 412 #if ENABLE(ENCRYPTED_MEDIA) 413 virtual void mediaPlayerKeyAdded(MediaPlayer*, const String& keySystem, const String& sessionId) OVERRIDE; 414 virtual void mediaPlayerKeyError(MediaPlayer*, const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode) OVERRIDE; 415 virtual void mediaPlayerKeyMessage(MediaPlayer*, const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength) OVERRIDE; 416 virtual void mediaPlayerKeyNeeded(MediaPlayer*, const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength) OVERRIDE; 417 #endif 418 400 419 virtual String mediaPlayerReferrer() const OVERRIDE; 401 420 virtual String mediaPlayerUserAgent() const OVERRIDE; -
trunk/Source/WebCore/html/HTMLMediaElement.idl
r113914 r114067 123 123 [V8EnabledAtRuntime=encryptedMedia] void webkitCancelKeyRequest(in [TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString keySystem, in [Optional=DefaultIsNullString] DOMString sessionId) 124 124 raises (DOMException); 125 126 attribute [V8EnabledAtRuntime=encryptedMedia] EventListener onwebkitkeyadded; 127 attribute [V8EnabledAtRuntime=encryptedMedia] EventListener onwebkitkeyerror; 128 attribute [V8EnabledAtRuntime=encryptedMedia] EventListener onwebkitkeymessage; 129 attribute [V8EnabledAtRuntime=encryptedMedia] EventListener onwebkitneedkey; 125 130 #endif 126 131 -
trunk/Source/WebCore/html/MediaError.h
r58826 r114067 36 36 class MediaError : public RefCounted<MediaError> { 37 37 public: 38 enum Code { MEDIA_ERR_ABORTED = 1, MEDIA_ERR_NETWORK, MEDIA_ERR_DECODE, MEDIA_ERR_SRC_NOT_SUPPORTED }; 38 enum Code { 39 MEDIA_ERR_ABORTED = 1, 40 MEDIA_ERR_NETWORK, 41 MEDIA_ERR_DECODE, 42 MEDIA_ERR_SRC_NOT_SUPPORTED 43 #if ENABLE(ENCRYPTED_MEDIA) 44 , MEDIA_ERR_ENCRYPTED 45 #endif 46 }; 39 47 40 48 static PassRefPtr<MediaError> create(Code code) { return adoptRef(new MediaError(code)); } -
trunk/Source/WebCore/html/MediaError.idl
r89269 r114067 32 32 const unsigned short MEDIA_ERR_DECODE = 3; 33 33 const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4; 34 #if defined(ENABLE_ENCRYPTED_MEDIA) && ENABLE_ENCRYPTED_MEDIA 35 const unsigned short MEDIA_ERR_ENCRYPTED = 5; 36 #endif 34 37 readonly attribute unsigned short code; 35 38 }; -
trunk/Source/WebCore/html/MediaKeyError.h
r114065 r114067 1 1 /* 2 * Copyright (C) 20 07 Apple Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef Media Error_h27 #define Media Error_h26 #ifndef MediaKeyError_h 27 #define MediaKeyError_h 28 28 29 #if ENABLE( VIDEO)29 #if ENABLE(ENCRYPTED_MEDIA) 30 30 31 31 #include <wtf/PassRefPtr.h> … … 34 34 namespace WebCore { 35 35 36 class Media Error : public RefCounted<MediaError> {36 class MediaKeyError : public RefCounted<MediaKeyError> { 37 37 public: 38 enum Code { MEDIA_ERR_ABORTED = 1, MEDIA_ERR_NETWORK, MEDIA_ERR_DECODE, MEDIA_ERR_SRC_NOT_SUPPORTED }; 38 enum Code { 39 MEDIA_KEYERR_UNKNOWN = 1, 40 MEDIA_KEYERR_CLIENT, 41 MEDIA_KEYERR_SERVICE, 42 MEDIA_KEYERR_OUTPUT, 43 MEDIA_KEYERR_HARDWARECHANGE, 44 MEDIA_KEYERR_DOMAIN 45 }; 39 46 40 static PassRefPtr<Media Error> create(Code code) { return adoptRef(new MediaError(code)); }47 static PassRefPtr<MediaKeyError> create(Code code) { return adoptRef(new MediaKeyError(code)); } 41 48 42 49 Code code() const { return m_code; } 43 50 44 51 private: 45 MediaError(Code code) : m_code(code) { }52 explicit MediaKeyError(Code code) : m_code(code) { } 46 53 47 54 Code m_code; -
trunk/Source/WebCore/html/MediaKeyError.idl
r114065 r114067 1 1 /* 2 * Copyright (C) 20 07 Apple Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 module html { 27 27 interface [ 28 Conditional=VIDEO 29 ] MediaError { 30 const unsigned short MEDIA_ERR_ABORTED = 1; 31 const unsigned short MEDIA_ERR_NETWORK = 2; 32 const unsigned short MEDIA_ERR_DECODE = 3; 33 const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4; 34 readonly attribute unsigned short code; 28 Conditional=ENCRYPTED_MEDIA, 29 V8EnabledAtRuntime=encryptedMedia, 30 ] MediaKeyError { 31 const unsigned short MEDIA_KEYERR_UNKNOWN = 1; 32 const unsigned short MEDIA_KEYERR_CLIENT = 2; 33 const unsigned short MEDIA_KEYERR_SERVICE = 3; 34 const unsigned short MEDIA_KEYERR_OUTPUT = 4; 35 const unsigned short MEDIA_KEYERR_HARDWARECHANGE = 5; 36 const unsigned short MEDIA_KEYERR_DOMAIN = 6; 37 readonly attribute unsigned short code; 35 38 }; 36 39 } -
trunk/Source/WebCore/html/MediaKeyEvent.cpp
r114065 r114067 1 1 /* 2 * Copyright (C) 20 07 Apple Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef MediaError_h 27 #define MediaError_h 26 #include "config.h" 28 27 29 #if ENABLE( VIDEO)28 #if ENABLE(ENCRYPTED_MEDIA) 30 29 31 #include <wtf/PassRefPtr.h> 32 #include <wtf/RefCounted.h> 30 #include "MediaKeyEvent.h" 31 32 #include "EventNames.h" 33 #include <wtf/Uint8Array.h> 33 34 34 35 namespace WebCore { 35 36 36 class MediaError : public RefCounted<MediaError> { 37 public: 38 enum Code { MEDIA_ERR_ABORTED = 1, MEDIA_ERR_NETWORK, MEDIA_ERR_DECODE, MEDIA_ERR_SRC_NOT_SUPPORTED }; 37 MediaKeyEventInit::MediaKeyEventInit() 38 : systemCode(0) 39 { 40 } 39 41 40 static PassRefPtr<MediaError> create(Code code) { return adoptRef(new MediaError(code)); } 42 MediaKeyEvent::MediaKeyEvent() 43 { 44 } 41 45 42 Code code() const { return m_code; } 46 MediaKeyEvent::MediaKeyEvent(const AtomicString& type, const MediaKeyEventInit& initializer) 47 : Event(type, initializer) 48 , m_keySystem(initializer.keySystem) 49 , m_sessionId(initializer.sessionId) 50 , m_initData(initializer.initData) 51 , m_message(initializer.message) 52 , m_defaultURL(initializer.defaultURL) 53 , m_errorCode(initializer.errorCode) 54 , m_systemCode(initializer.systemCode) 55 { 56 } 43 57 44 private: 45 MediaError(Code code) : m_code(code) { } 58 MediaKeyEvent::~MediaKeyEvent() 59 { 60 } 46 61 47 Code m_code; 48 }; 62 const AtomicString& MediaKeyEvent::interfaceName() const 63 { 64 return eventNames().interfaceForMediaKeyEvent; 65 } 49 66 50 67 } // namespace WebCore 51 68 52 69 #endif 53 #endif -
trunk/Source/WebCore/html/MediaKeyEvent.idl
r114065 r114067 1 1 /* 2 * Copyright (C) 20 07 Apple Inc. All rights reserved.2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 module html { 27 27 28 interface [ 28 Conditional=VIDEO 29 ] MediaError { 30 const unsigned short MEDIA_ERR_ABORTED = 1; 31 const unsigned short MEDIA_ERR_NETWORK = 2; 32 const unsigned short MEDIA_ERR_DECODE = 3; 33 const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4; 34 readonly attribute unsigned short code; 29 Conditional=ENCRYPTED_MEDIA, 30 V8EnabledAtRuntime=encryptedMedia, 31 ConstructorTemplate=Event 32 ] MediaKeyEvent : Event { 33 readonly attribute [InitializedByEventConstructor] DOMString keySystem; 34 readonly attribute [InitializedByEventConstructor] DOMString sessionId; 35 readonly attribute [InitializedByEventConstructor] Uint8Array initData; 36 readonly attribute [InitializedByEventConstructor] Uint8Array message; 37 readonly attribute [InitializedByEventConstructor] DOMString defaultURL; 38 readonly attribute [InitializedByEventConstructor] MediaKeyError errorCode; 39 readonly attribute [InitializedByEventConstructor] unsigned short systemCode; 35 40 }; 41 36 42 } -
trunk/Source/WebCore/page/DOMWindow.idl
r113573 r114067 466 466 attribute [JSCustomGetter, CustomConstructor] HTMLImageElementConstructorConstructor Image; // Usable with new operator 467 467 attribute [JSCustomGetter] HTMLOptionElementConstructorConstructor Option; // Usable with new operator 468 469 attribute [Conditional=ENCRYPTED_MEDIA, V8EnabledAtRuntime=encryptedMedia] MediaKeyErrorConstructor MediaKeyError; 470 attribute [Conditional=ENCRYPTED_MEDIA, V8EnabledAtRuntime=encryptedMedia] MediaKeyEventConstructor MediaKeyEvent; 468 471 469 472 attribute [Conditional=VIDEO_TRACK, V8EnabledAtRuntime=webkitVideoTrack] HTMLTrackElementConstructor HTMLTrackElement; -
trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp
r113914 r114067 970 970 } 971 971 #endif // WEB_AUDIO 972 972 973 #if ENABLE(ENCRYPTED_MEDIA) 974 void MediaPlayer::keyAdded(const String& keySystem, const String& sessionId) 975 { 976 if (m_mediaPlayerClient) 977 m_mediaPlayerClient->mediaPlayerKeyAdded(this, keySystem, sessionId); 978 } 979 980 void MediaPlayer::keyError(const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode errorCode, unsigned short systemCode) 981 { 982 if (m_mediaPlayerClient) 983 m_mediaPlayerClient->mediaPlayerKeyError(this, keySystem, sessionId, errorCode, systemCode); 984 } 985 986 void MediaPlayer::keyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength) 987 { 988 if (m_mediaPlayerClient) 989 m_mediaPlayerClient->mediaPlayerKeyMessage(this, keySystem, sessionId, message, messageLength); 990 } 991 992 void MediaPlayer::keyNeeded(const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength) 993 { 994 if (m_mediaPlayerClient) 995 m_mediaPlayerClient->mediaPlayerKeyNeeded(this, keySystem, sessionId, initData, initDataLength); 996 } 997 #endif 998 973 999 String MediaPlayer::referrer() const 974 1000 { -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r113914 r114067 169 169 #endif 170 170 171 #if ENABLE(ENCRYPTED_MEDIA) 172 enum MediaKeyErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError }; 173 virtual void mediaPlayerKeyAdded(MediaPlayer*, const String& keySystem, const String& sessionId) { } 174 virtual void mediaPlayerKeyError(MediaPlayer*, const String& keySystem, const String& sessionId, MediaKeyErrorCode errorCode, unsigned short systemCode) { } 175 virtual void mediaPlayerKeyMessage(MediaPlayer*, const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength) { } 176 virtual void mediaPlayerKeyNeeded(MediaPlayer*, const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength) { } 177 #endif 178 171 179 virtual String mediaPlayerReferrer() const { return String(); } 172 180 virtual String mediaPlayerUserAgent() const { return String(); } … … 345 353 void sourceOpened(); 346 354 String sourceURL() const; 355 #endif 356 357 #if ENABLE(ENCRYPTED_MEDIA) 358 void keyAdded(const String& keySystem, const String& sessionId); 359 void keyError(const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode); 360 void keyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength); 361 void keyNeeded(const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength); 347 362 #endif 348 363 -
trunk/Source/WebKit/chromium/ChangeLog
r113972 r114067 1 2012-04-12 David Dorwin <ddorwin@chromium.org> 2 3 Add Encrypted Media Extensions events and errors to HTMLMediaElement 4 https://bugs.webkit.org/show_bug.cgi?id=82974 5 6 Reviewed by Adam Barth. 7 8 The new events and errors are behind the ENABLE(ENCRYPTED_MEDIA) feature define. 9 Implementation is based on v0.1 of the draft proposal at 10 http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#events. 11 12 * public/WebMediaPlayerClient.h: 13 * src/AssertMatchingEnums.cpp: 14 * src/WebMediaPlayerClientImpl.cpp: 15 (WebKit::WebMediaPlayerClientImpl::keyAdded): 16 (WebKit): 17 (WebKit::WebMediaPlayerClientImpl::keyError): 18 (WebKit::WebMediaPlayerClientImpl::keyMessage): 19 (WebKit::WebMediaPlayerClientImpl::keyNeeded): 20 * src/WebMediaPlayerClientImpl.h: 21 (WebMediaPlayerClientImpl): 22 1 23 2012-04-12 Kent Tamura <tkent@chromium.org> 2 24 -
trunk/Source/WebKit/chromium/public/WebMediaPlayerClient.h
r103857 r114067 41 41 class WebMediaPlayerClient { 42 42 public: 43 enum MediaKeyErrorCode { 44 UnknownError = 1, 45 ClientError, 46 ServiceError, 47 OutputError, 48 HardwareChangeError, 49 DomainError 50 }; 51 43 52 virtual void networkStateChanged() = 0; 44 53 virtual void readyStateChanged() = 0; … … 57 66 virtual void sourceOpened() = 0; 58 67 virtual WebKit::WebURL sourceURL() const = 0; 68 virtual void keyAdded(const WebString&, const WebString&) = 0; 69 virtual void keyError(const WebString&, const WebString&, MediaKeyErrorCode, unsigned short systemCode) = 0; 70 virtual void keyMessage(const WebString&, const WebString&, const unsigned char*, unsigned) = 0; 71 virtual void keyNeeded(const WebString&, const WebString&, const unsigned char* initData, unsigned initDataLength) = 0; 59 72 virtual void disableAcceleratedCompositing() = 0; 60 73 protected: -
trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
r113865 r114067 88 88 #include "WebInputElement.h" 89 89 #include "WebMediaPlayer.h" 90 #include "WebMediaPlayerClient.h" 90 91 #include "WebNotificationPresenter.h" 91 92 #include "WebPageVisibilityState.h" … … 393 394 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::InvalidPlayerState, MediaPlayer::InvalidPlayerState); 394 395 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::KeySystemNotSupported, MediaPlayer::KeySystemNotSupported); 396 397 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::UnknownError, MediaPlayerClient::UnknownError); 398 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::ClientError, MediaPlayerClient::ClientError); 399 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::ServiceError, MediaPlayerClient::ServiceError); 400 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::OutputError, MediaPlayerClient::OutputError); 401 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::HardwareChangeError, MediaPlayerClient::HardwareChangeError); 402 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::DomainError, MediaPlayerClient::DomainError); 395 403 #endif 396 404 -
trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp
r113914 r114067 218 218 } 219 219 220 void WebMediaPlayerClientImpl::keyAdded(const WebString& keySystem, const WebString& sessionId) 221 { 222 #if ENABLE(ENCRYPTED_MEDIA) 223 ASSERT(m_mediaPlayer); 224 m_mediaPlayer->keyAdded(keySystem, sessionId); 225 #else 226 UNUSED_PARAM(keySystem); 227 UNUSED_PARAM(sessionId); 228 #endif 229 } 230 231 void WebMediaPlayerClientImpl::keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode errorCode, unsigned short systemCode) 232 { 233 #if ENABLE(ENCRYPTED_MEDIA) 234 ASSERT(m_mediaPlayer); 235 m_mediaPlayer->keyError(keySystem, sessionId, static_cast<MediaPlayerClient::MediaKeyErrorCode>(errorCode), systemCode); 236 #else 237 UNUSED_PARAM(keySystem); 238 UNUSED_PARAM(sessionId); 239 UNUSED_PARAM(errorCode); 240 UNUSED_PARAM(systemCode); 241 #endif 242 } 243 244 void WebMediaPlayerClientImpl::keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength) 245 { 246 #if ENABLE(ENCRYPTED_MEDIA) 247 ASSERT(m_mediaPlayer); 248 m_mediaPlayer->keyMessage(keySystem, sessionId, message, messageLength); 249 #else 250 UNUSED_PARAM(keySystem); 251 UNUSED_PARAM(sessionId); 252 UNUSED_PARAM(message); 253 UNUSED_PARAM(messageLength); 254 #endif 255 } 256 257 void WebMediaPlayerClientImpl::keyNeeded(const WebString& keySystem, const WebString& sessionId, const unsigned char* initData, unsigned initDataLength) 258 { 259 #if ENABLE(ENCRYPTED_MEDIA) 260 ASSERT(m_mediaPlayer); 261 m_mediaPlayer->keyNeeded(keySystem, sessionId, initData, initDataLength); 262 #else 263 UNUSED_PARAM(keySystem); 264 UNUSED_PARAM(sessionId); 265 UNUSED_PARAM(initData); 266 UNUSED_PARAM(initDataLength); 267 #endif 268 } 269 220 270 void WebMediaPlayerClientImpl::disableAcceleratedCompositing() 221 271 { -
trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h
r113914 r114067 87 87 virtual void sourceOpened(); 88 88 virtual WebKit::WebURL sourceURL() const; 89 virtual void keyAdded(const WebString& keySystem, const WebString& sessionId); 90 virtual void keyError(const WebString& keySystem, const WebString& sessionId, MediaKeyErrorCode, unsigned short systemCode); 91 virtual void keyMessage(const WebString& keySystem, const WebString& sessionId, const unsigned char* message, unsigned messageLength); 92 virtual void keyNeeded(const WebString& keySystem, const WebString& sessionId, const unsigned char* initData, unsigned initDataLength); 89 93 virtual void disableAcceleratedCompositing(); 90 94
Note: See TracChangeset
for help on using the changeset viewer.