Changeset 114067 in webkit


Ignore:
Timestamp:
Apr 12, 2012 6:32:36 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Add Encrypted Media Extensions events and errors to HTMLMediaElement
https://bugs.webkit.org/show_bug.cgi?id=82974

Patch by David Dorwin <ddorwin@chromium.org> on 2012-04-12
Reviewed by Adam Barth.

The new events and errors are behind the ENABLE(ENCRYPTED_MEDIA) feature define.
Implementation is based on v0.1 of the draft proposal at
http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#events.

Source/WebCore:

Tests: fast/events/constructors/media-key-event-constructor.html

media/encrypted-media/encrypted-media-constants.html
media/encrypted-media/encrypted-media-events.html

  • WebCore.gypi:
  • bindings/v8/Dictionary.cpp:

(WebCore::Dictionary::get):
(WebCore):

  • bindings/v8/Dictionary.h:

(WebCore):
(Dictionary):

  • dom/EventNames.h:

(WebCore):

  • dom/EventNames.in:
  • html/HTMLAttributeNames.in:
  • html/HTMLMediaElement.cpp:

(WebCore):
(WebCore::HTMLMediaElement::mediaPlayerKeyAdded):
(WebCore::HTMLMediaElement::mediaPlayerKeyError):
(WebCore::HTMLMediaElement::mediaPlayerKeyMessage):
(WebCore::HTMLMediaElement::mediaPlayerKeyNeeded):

  • html/HTMLMediaElement.h:

(HTMLMediaElement):

  • html/HTMLMediaElement.idl:
  • html/MediaError.h:
  • html/MediaError.idl:
  • html/MediaKeyError.h: Added.

(WebCore):
(MediaKeyError):
(WebCore::MediaKeyError::create):
(WebCore::MediaKeyError::code):
(WebCore::MediaKeyError::MediaKeyError):

  • html/MediaKeyError.idl: Added.
  • html/MediaKeyEvent.cpp: Added.

(WebCore):
(WebCore::MediaKeyEventInit::MediaKeyEventInit):
(WebCore::MediaKeyEvent::MediaKeyEvent):
(WebCore::MediaKeyEvent::~MediaKeyEvent):
(WebCore::MediaKeyEvent::interfaceName):

  • html/MediaKeyEvent.h: Added.

(WebCore):
(MediaKeyEventInit):
(MediaKeyEvent):
(WebCore::MediaKeyEvent::create):
(WebCore::MediaKeyEvent::keySystem):
(WebCore::MediaKeyEvent::sessionId):
(WebCore::MediaKeyEvent::initData):
(WebCore::MediaKeyEvent::message):
(WebCore::MediaKeyEvent::defaultURL):
(WebCore::MediaKeyEvent::errorCode):
(WebCore::MediaKeyEvent::systemCode):

  • html/MediaKeyEvent.idl: Added.
  • page/DOMWindow.idl:
  • platform/graphics/MediaPlayer.cpp:

(WebCore):
(WebCore::MediaPlayer::keyAdded):
(WebCore::MediaPlayer::keyError):
(WebCore::MediaPlayer::keyMessage):
(WebCore::MediaPlayer::keyNeeded):

  • platform/graphics/MediaPlayer.h:

(MediaPlayerClient):
(WebCore::MediaPlayerClient::mediaPlayerKeyAdded):
(WebCore::MediaPlayerClient::mediaPlayerKeyError):
(WebCore::MediaPlayerClient::mediaPlayerKeyMessage):
(WebCore::MediaPlayerClient::mediaPlayerKeyNeeded):
(MediaPlayer):

Source/WebKit/chromium:

  • public/WebMediaPlayerClient.h:
  • src/AssertMatchingEnums.cpp:
  • src/WebMediaPlayerClientImpl.cpp:

(WebKit::WebMediaPlayerClientImpl::keyAdded):
(WebKit):
(WebKit::WebMediaPlayerClientImpl::keyError):
(WebKit::WebMediaPlayerClientImpl::keyMessage):
(WebKit::WebMediaPlayerClientImpl::keyNeeded):

  • src/WebMediaPlayerClientImpl.h:

(WebMediaPlayerClientImpl):

LayoutTests:

  • fast/events/constructors/media-key-event-constructor-expected.txt: Added.
  • fast/events/constructors/media-key-event-constructor.html: Added.
  • fast/js/resources/js-test-pre.js:

(shouldBeZero):
(shouldBeEmptyString):

  • media/encrypted-media/encrypted-media-constants-expected.txt: Added.
  • media/encrypted-media/encrypted-media-constants.html: Added.
  • media/encrypted-media/encrypted-media-events-expected.txt: Added.
  • media/encrypted-media/encrypted-media-events.html: Added.
  • media/video-test.js:

(testExpected):
(testArraysEqual):

Location:
trunk
Files:
7 added
23 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r114064 r114067  
     12012-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
    1252012-04-12  Pablo Flouret  <pablof@motorola.com>
    226
  • trunk/LayoutTests/fast/js/resources/js-test-pre.js

    r110650 r114067  
    255255function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
    256256function shouldBeNull(_a) { shouldBe(_a, "null"); }
     257function shouldBeZero(_a) { shouldBe(_a, "0"); }
    257258
    258259function shouldBeEqualToString(a, b)
     
    261262  shouldBe(a, unevaledString);
    262263}
     264
     265function shouldBeEmptyString(_a) { shouldBeEqualToString(_a, ""); }
    263266
    264267function shouldEvaluateTo(actual, expected) {
  • trunk/LayoutTests/media/video-test.js

    r107831 r114067  
    8080        case '!=':  success = observed != expected; break;
    8181        case '==': success = observed == expected; break;
     82        case '===': success = observed === expected; break;
    8283    }
    8384
    8485    reportExpected(success, testFuncString, comparison, expected, observed)
     86}
     87
     88function 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    }
    85103}
    86104
  • trunk/Source/WebCore/ChangeLog

    r114065 r114067  
     12012-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
    1792012-04-12  Anders Carlsson  <andersca@apple.com>
    280
  • trunk/Source/WebCore/WebCore.gypi

    r113966 r114067  
    10641064            'html/MediaController.idl',
    10651065            'html/MediaError.idl',
     1066            'html/MediaKeyError.idl',
     1067            'html/MediaKeyEvent.idl',
    10661068            'html/TextMetrics.idl',
    10671069            'html/TimeRanges.idl',
     
    55705572            'html/MediaFragmentURIParser.cpp',
    55715573            'html/MediaFragmentURIParser.h',
     5574            'html/MediaKeyError.h',
     5575            'html/MediaKeyEvent.cpp',
     5576            'html/MediaKeyEvent.h',
    55725577            'html/MicroDataItemValue.cpp',
    55735578            'html/MicroDataItemValue.h',
     
    75687573            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaError.cpp',
    75697574            '<(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',
    75707579            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaList.cpp',
    75717580            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSMediaList.h',
  • trunk/Source/WebCore/bindings/v8/Dictionary.cpp

    r110547 r114067  
    3131#include "V8DOMWindow.h"
    3232#include "V8Storage.h"
     33#include "V8Uint8Array.h"
    3334#include "V8Utilities.h"
    3435#include <wtf/MathExtras.h>
     
    3738#include "IDBKeyRange.h"
    3839#include "V8IDBKeyRange.h"
     40#endif
     41
     42#if ENABLE(ENCRYPTED_MEDIA)
     43#include "V8MediaKeyError.h"
    3944#endif
    4045
     
    294299}
    295300
     301bool 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)
     320bool 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
    296339#if ENABLE(VIDEO_TRACK)
    297340bool Dictionary::get(const String& key, RefPtr<TrackBase>& value) const
  • trunk/Source/WebCore/bindings/v8/Dictionary.h

    r110547 r114067  
    4040class IDBKeyRange;
    4141class Storage;
     42class MediaKeyError;
    4243class TrackBase;
    4344class SpeechRecognitionError;
     
    6869    bool get(const String&, RefPtr<Storage>&) const;
    6970    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
    7075#if ENABLE(VIDEO_TRACK)
    7176    bool get(const String&, RefPtr<TrackBase>&) const;
  • trunk/Source/WebCore/dom/EventNames.h

    r112815 r114067  
    162162    macro(webkitsourceclose) \
    163163    \
     164    macro(webkitkeyadded) \
     165    macro(webkitkeyerror) \
     166    macro(webkitkeymessage) \
     167    macro(webkitneedkey) \
     168    \
    164169    macro(progress) \
    165170    macro(stalled) \
  • trunk/Source/WebCore/dom/EventNames.in

    r110420 r114067  
    4343DeviceOrientationEvent conditional=DEVICE_ORIENTATION
    4444OrientationEvent interfaceName=Event, conditional=ORIENTATION_EVENTS
     45MediaKeyEvent conditional=ENCRYPTED_MEDIA
    4546TrackEvent conditional=VIDEO_TRACK
  • trunk/Source/WebCore/html/HTMLAttributeNames.in

    r113143 r114067  
    248248onwebkitfullscreenchange
    249249onwebkitfullscreenerror
     250onwebkitkeyadded
     251onwebkitkeyerror
     252onwebkitkeymessage
     253onwebkitneedkey
    250254onwebkittransitionend
    251255open
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r114026 r114067  
    5959#include "MediaError.h"
    6060#include "MediaFragmentURIParser.h"
     61#include "MediaKeyError.h"
     62#include "MediaKeyEvent.h"
    6163#include "MediaList.h"
    6264#include "MediaPlayer.h"
     
    16881690#endif
    16891691
     1692#if ENABLE(ENCRYPTED_MEDIA)
     1693void 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
     1706void 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
     1743void 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
     1757void 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
    16901772void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
    16911773{
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r113914 r114067  
    187187    void webkitAddKey(const String& keySystem, PassRefPtr<Uint8Array> key, ExceptionCode&);
    188188    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);
    189194#endif
    190195
     
    261266    void updateWidget(PluginCreationOption);
    262267#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(); }
    263275
    264276    bool hasSingleSecurityOrigin() const { return !m_player || m_player->hasSingleSecurityOrigin(); }
     
    398410#endif
    399411
     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
    400419    virtual String mediaPlayerReferrer() const OVERRIDE;
    401420    virtual String mediaPlayerUserAgent() const OVERRIDE;
  • trunk/Source/WebCore/html/HTMLMediaElement.idl

    r113914 r114067  
    123123    [V8EnabledAtRuntime=encryptedMedia] void webkitCancelKeyRequest(in [TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString keySystem, in [Optional=DefaultIsNullString] DOMString sessionId)
    124124        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;
    125130#endif
    126131
  • trunk/Source/WebCore/html/MediaError.h

    r58826 r114067  
    3636class MediaError : public RefCounted<MediaError> {
    3737public:
    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    };
    3947
    4048    static PassRefPtr<MediaError> create(Code code) { return adoptRef(new MediaError(code)); }
  • trunk/Source/WebCore/html/MediaError.idl

    r89269 r114067  
    3232          const unsigned short MEDIA_ERR_DECODE = 3;
    3333          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
    3437          readonly attribute unsigned short code;
    3538    };
  • trunk/Source/WebCore/html/MediaKeyError.h

    r114065 r114067  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2012 Google Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef MediaError_h
    27 #define MediaError_h
     26#ifndef MediaKeyError_h
     27#define MediaKeyError_h
    2828
    29 #if ENABLE(VIDEO)
     29#if ENABLE(ENCRYPTED_MEDIA)
    3030
    3131#include <wtf/PassRefPtr.h>
     
    3434namespace WebCore {
    3535
    36 class MediaError : public RefCounted<MediaError> {
     36class MediaKeyError : public RefCounted<MediaKeyError> {
    3737public:
    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    };
    3946
    40     static PassRefPtr<MediaError> create(Code code) { return adoptRef(new MediaError(code)); }
     47    static PassRefPtr<MediaKeyError> create(Code code) { return adoptRef(new MediaKeyError(code)); }
    4148
    4249    Code code() const { return m_code; }
    4350
    4451private:
    45     MediaError(Code code) : m_code(code) { }
     52    explicit MediaKeyError(Code code) : m_code(code) { }
    4653
    4754    Code m_code;
  • trunk/Source/WebCore/html/MediaKeyError.idl

    r114065 r114067  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2012 Google Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626module html {
    2727    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;
    3538    };
    3639}
  • trunk/Source/WebCore/html/MediaKeyEvent.cpp

    r114065 r114067  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2012 Google Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef MediaError_h
    27 #define MediaError_h
     26#include "config.h"
    2827
    29 #if ENABLE(VIDEO)
     28#if ENABLE(ENCRYPTED_MEDIA)
    3029
    31 #include <wtf/PassRefPtr.h>
    32 #include <wtf/RefCounted.h>
     30#include "MediaKeyEvent.h"
     31
     32#include "EventNames.h"
     33#include <wtf/Uint8Array.h>
    3334
    3435namespace WebCore {
    3536
    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 };
     37MediaKeyEventInit::MediaKeyEventInit()
     38    : systemCode(0)
     39{
     40}
    3941
    40     static PassRefPtr<MediaError> create(Code code) { return adoptRef(new MediaError(code)); }
     42MediaKeyEvent::MediaKeyEvent()
     43{
     44}
    4145
    42     Code code() const { return m_code; }
     46MediaKeyEvent::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}
    4357
    44 private:
    45     MediaError(Code code) : m_code(code) { }
     58MediaKeyEvent::~MediaKeyEvent()
     59{
     60}
    4661
    47     Code m_code;
    48 };
     62const AtomicString& MediaKeyEvent::interfaceName() const
     63{
     64    return eventNames().interfaceForMediaKeyEvent;
     65}
    4966
    5067} // namespace WebCore
    5168
    5269#endif
    53 #endif
  • trunk/Source/WebCore/html/MediaKeyEvent.idl

    r114065 r114067  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2012 Google Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626module html {
     27
    2728    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;
    3540    };
     41
    3642}
  • trunk/Source/WebCore/page/DOMWindow.idl

    r113573 r114067  
    466466        attribute [JSCustomGetter, CustomConstructor] HTMLImageElementConstructorConstructor Image; // Usable with new operator
    467467        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;
    468471
    469472        attribute [Conditional=VIDEO_TRACK, V8EnabledAtRuntime=webkitVideoTrack] HTMLTrackElementConstructor HTMLTrackElement;
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r113914 r114067  
    970970}
    971971#endif // WEB_AUDIO
    972    
     972
     973#if ENABLE(ENCRYPTED_MEDIA)
     974void MediaPlayer::keyAdded(const String& keySystem, const String& sessionId)
     975{
     976    if (m_mediaPlayerClient)
     977        m_mediaPlayerClient->mediaPlayerKeyAdded(this, keySystem, sessionId);
     978}
     979
     980void 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
     986void 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
     992void 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
    973999String MediaPlayer::referrer() const
    9741000{
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r113914 r114067  
    169169#endif
    170170
     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
    171179    virtual String mediaPlayerReferrer() const { return String(); }
    172180    virtual String mediaPlayerUserAgent() const { return String(); }
     
    345353    void sourceOpened();
    346354    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);
    347362#endif
    348363
  • trunk/Source/WebKit/chromium/ChangeLog

    r113972 r114067  
     12012-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
    1232012-04-12  Kent Tamura  <tkent@chromium.org>
    224
  • trunk/Source/WebKit/chromium/public/WebMediaPlayerClient.h

    r103857 r114067  
    4141class WebMediaPlayerClient {
    4242public:
     43    enum MediaKeyErrorCode {
     44        UnknownError = 1,
     45        ClientError,
     46        ServiceError,
     47        OutputError,
     48        HardwareChangeError,
     49        DomainError
     50    };
     51
    4352    virtual void networkStateChanged() = 0;
    4453    virtual void readyStateChanged() = 0;
     
    5766    virtual void sourceOpened() = 0;
    5867    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;
    5972    virtual void disableAcceleratedCompositing() = 0;
    6073protected:
  • trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp

    r113865 r114067  
    8888#include "WebInputElement.h"
    8989#include "WebMediaPlayer.h"
     90#include "WebMediaPlayerClient.h"
    9091#include "WebNotificationPresenter.h"
    9192#include "WebPageVisibilityState.h"
     
    393394COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::InvalidPlayerState, MediaPlayer::InvalidPlayerState);
    394395COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::KeySystemNotSupported, MediaPlayer::KeySystemNotSupported);
     396
     397COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::UnknownError, MediaPlayerClient::UnknownError);
     398COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::ClientError, MediaPlayerClient::ClientError);
     399COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::ServiceError, MediaPlayerClient::ServiceError);
     400COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::OutputError, MediaPlayerClient::OutputError);
     401COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::HardwareChangeError, MediaPlayerClient::HardwareChangeError);
     402COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayerClient::DomainError, MediaPlayerClient::DomainError);
    395403#endif
    396404
  • trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp

    r113914 r114067  
    218218}
    219219
     220void 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
     231void 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
     244void 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
     257void 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
    220270void WebMediaPlayerClientImpl::disableAcceleratedCompositing()
    221271{
  • trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h

    r113914 r114067  
    8787    virtual void sourceOpened();
    8888    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);
    8993    virtual void disableAcceleratedCompositing();
    9094
Note: See TracChangeset for help on using the changeset viewer.