Commit 09c10fbf authored by jer.noble@apple.com's avatar jer.noble@apple.com

Bring WebKit up to speed with latest Encrypted Media spec.

https://bugs.webkit.org/show_bug.cgi?id=97037

Reviewed by Eric Carlson.

Source/JavaScriptCore:

Define the ENABLE_ENCRYPTED_MEDIA_V2 setting.

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

The most recent version of the Encrypted Media Extensions spec breaks functionality out of the
HTMLMediaElement and into new MediaKeys and MediaKeySession classes. Since the CDM functionality
has been pulled out of the media element, we create a proxy CDM class and factory system for
creating specific CDM key system implementations. The spec also breaks out MediaKeyEvent
into distinct event classes, MediaKeyNeededEvent and MediaKeyMessageEvent, for needkey and
keymessage events, respectively.

Tests: media/encrypted-media/encrypted-media-v2-events.html
       media/encrypted-media/encrypted-media-v2-syntax.html

CDM is a proxy class (a la MediaPlayer) for a specific CDMPrivateInterface implementation. A CDM
implementation is registered with the CDMFactory and will be created if that implementation supports
the key system passed into the MediaKeys constructor. CDMSession is a pure-virtual interface exposed
by concrete CDMPrivate subclasses.  Its lifetime is owned by MediaKeySession.
* Modules/encryptedmedia/CDM.cpp: Added.
(WebCore::installedCDMFactories): Initialize all the known CDM subtypes. Ports will add CDM implementations here.
(WebCore::CDM::registerCDMFactory): Registers a new CDMFactory using the passed in function pointers.
(WebCore::CDMFactoryForKeySystem): Return the first CDM factory which supports the requested key system.
(WebCore::CDM::supportsKeySystem): Walk the installed CDMs and ask if the given key system is supported.
(WebCore::CDM::supportsKeySystemMIMETypeAndCodec): Ditto, with an additional MIME type and codec string.
(WebCore::CDM::create): Simple constructor wrapper.
(WebCore::CDM::CDM): Simple constructor; calls bestCDMForKeySystem() to create it's private implementation.
(WebCore::CDM::~CDM): Simple destructor.
(WebCore::CDM::createSession): Creates a new CDMSession.
* Modules/encryptedmedia/CDM.h: Added.
(WebCore::CDM::keySystem): Simple accessor for m_keySystem.
(WebCore::CDMSession::CDMSession): Simple constructor.
(WebCore::CDMSession::~CDMSession): Simple destructor.
* Modules/encryptedmedia/CDMPrivate.h: Added.
(WebCore::CDMPrivateInterface::CDMPrivateInterface): Simple constructor.
(WebCore::CDMPrivateInterface::~CDMPrivateInterface): Simple destructor.

The new classes, MediaKeyMessageEvent and MediaKeyNeededEvent, take distinct subsets of the initializers of
the original MediaKeyMessageEvent.
* Modules/encryptedmedia/MediaKeyMessageEvent.cpp: Copied from Source/WebCore/html/MediaKeyEvent.cpp.
(WebCore::MediaKeyMessageEventInit::MediaKeyMessageEventInit): Initializer now only takes message and destinationURL
    parameters.
(WebCore::MediaKeyMessageEvent::MediaKeyMessageEvent): Simple constructor.
(WebCore::MediaKeyMessageEvent::~MediaKeyMessageEvent): Simple destructor.
(WebCore::MediaKeyMessageEvent::interfaceName): Standard interfaceName.
* Modules/encryptedmedia/MediaKeyMessageEvent.h: Copied from Source/WebCore/html/MediaKeyEvent.h.
(WebCore::MediaKeyMessageEvent::create): Simple construction wrapper.
(WebCore::MediaKeyMessageEvent::message): Simple accessor for m_message.
(WebCore::MediaKeyMessageEvent::destinationURL): Simple accessor for m_destinationURL.
* Modules/encryptedmedia/MediaKeyMessageEvent.idl: Copied from Source/WebCore/html/MediaKeyEvent.idl.
* Modules/encryptedmedia/MediaKeyNeededEvent.cpp: Copied from Source/WebCore/html/MediaKeyEvent.h.
(WebCore::MediaKeyNeededEventInit::MediaKeyNeededEventInit): Initializer now only takes initData parameter.
(WebCore::MediaKeyNeededEvent::MediaKeyNeededEvent): Simple constructor.
(WebCore::MediaKeyNeededEvent::~MediaKeyNeededEvent): Simple destructor.
(WebCore::MediaKeyNeededEvent::interfaceName): Standard interfaceName.
* Modules/encryptedmedia/MediaKeyNeededEvent.h: Copied from Source/WebCore/html/MediaKeyEvent.h.
(WebCore::MediaKeyNeededEvent::create): Simple construction wrapper.
(WebCore::MediaKeyNeededEvent::initData): Simple accessor for m_initData.
* Modules/encryptedmedia/MediaKeyNeededEvent.idl: Copied from Source/WebCore/html/MediaKeyEvent.idl.

MediaKeySession is a new class that maps keys and key requests to a given session ID:
* Modules/encryptedmedia/MediaKeySession.cpp: Added.
(WebCore::MediaKeySession::create): Simple construction wrapper.
(WebCore::MediaKeySession::MediaKeySession): Simple constructor.
(WebCore::MediaKeySession::~MediaKeySession): Simple destructor; calls close().
(WebCore::MediaKeySession::setError): Simple setter for m_error;
(WebCore::MediaKeySession::close): Tell the CDM to clear any saved session keys.
(WebCore::MediaKeySession::generateKeyRequest): Start a one-shot timer, handled in keyRequestTimerFired.
(WebCore::MediaKeySession::keyRequestTimerFired): Follow the steps in the spec; ask the CDM to generate a key request.
(WebCore::MediaKeySession::addKey): Start a one-shot timer, handled in addKeyTimerFired.
(WebCore::MediaKeySession::addKeyTimerFired): Follow the steps in the spec; provide the key data to the CDM.
* Modules/encryptedmedia/MediaKeySession.h: Added.
(WebCore::MediaKeySession::keySystem): Simple accessor for m_keySystem.
(WebCore::MediaKeySession::sessionId): Simple accessor for m_sessionId.
(WebCore::MediaKeySession::error): Simple accessor for m_error;
* Modules/encryptedmedia/MediaKeySession.idl:

MediaKeySession inherits from EventTarget, and must override the pure virtual functions in that class:
* Modules/encryptedmedia/MediaKeySession.cpp: Added.
(WebCore::MediaKeySession::interfaceName):
* Modules/encryptedmedia/MediaKeySession.h: Added.
(WebCore::MediaKeySession::refEventTarget):
(WebCore::MediaKeySession::derefEventTarget):
(WebCore::MediaKeySession::eventTargetData):
(WebCore::MediaKeySession::ensureEventTargetData):
(WebCore::MediaKeySession::scriptExecutionContext):

MediaKeys is a new class that encapsulates a CDM and a number of key sessions:
* Modules/encryptedmedia/MediaKeys.cpp: Added.
(WebCore::MediaKeys::create): Throw an exception if the key system parameter is unsupported; create a CDM object
    and a new MediaKeys session.
(WebCore::MediaKeys::MediaKeys): Simple constructor.
(WebCore::MediaKeys::~MediaKeys): Simple destructor.
(WebCore::MediaKeys::createSession): Follow the spec and create a new key session.
* Modules/encryptedmedia/MediaKeys.h: Added.
* Modules/encryptedmedia/MediaKeys.idl: Copied from Source/WebCore/html/MediaError.idl.

Provide a new interface to HTMLMediaElement for MediaPlayer which does not require a sessionId or a key system:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerKeyNeeded):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::keyNeeded):

MediaKeyError now has a systemCode parameter and member variable.
* html/MediaKeyError.h:
(WebCore::MediaKeyError::create): Take a systemCode parameter with a default (0) value.
(WebCore::MediaKeyError::MediaKeyError): Ditto.
(WebCore::MediaKeyError::systemCode): Simple accessor for m_systemCode.
* html/MediaKeyError.idl:

Add new methods to HTMLMediaElement to support MediaKeys. Support different initializer
for the MediaKeyNeededEvent.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setMediaKeys): Simple setter for m_mediaKeys.
(WebCore::HTMLMediaElement::mediaPlayerKeyNeeded): This version takes fewer parameters
    than the deprecated version.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::mediaKeys): Simple accessor for m_mediaKeys.
* html/HTMLMediaElement.idl: Add the mediaKeys attribute.

Add an ENABLE(ENCRYPTED_MEDIA_V2) check to the existing ENABLE(ENCRYPTED_MEDIA) one:
* html/MediaError.h:
* html/MediaError.idl:
* platform/graphics/MediaPlayer.cpp:
(WebCore::bestMediaEngineForTypeAndCodecs):
(WebCore::MediaPlayer::supportsType):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayer::keyNeeded): This version takes fewer parameters than the
    deprecated version.

Support the new version of canPlayType which takes an extra parameter:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine):
(WebCore::MediaPlayerPrivateAVFoundationObjC::extendedSupportsType):
* platform/graphics/mac/MediaPlayerPrivateQTKit.h:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::registerMediaEngine):
(WebCore::MediaPlayerPrivateQTKit::extendedSupportsType):

Add a mock CDM for use within DRT and WKTR to test the MediaKeys and MediaKeySession
APIs and events:
* testing/Internals.cpp:
(WebCore::Internals::initializeMockCDM): Add the MockCDM class to the CDM factories.
* testing/Internals.h:
* testing/Internals.idl: Add the initializeMockCDM() method.
* testing/MockCDM.cpp: Added.
(WebCore::MockCDM::supportsKeySystem): Only supports the 'com.webcore.mock' key system.
(WebCore::MockCDM::supportsMIMEType): Only supports the 'video/mock' mime type.
(WebCore::initDataPrefix): Static method which returns a Uint8Array containing 'mock'.
(WebCore::keyPrefix): Static method which returns a Uint8Array containing 'key'.
(WebCore::keyRequest): Static method which returns a Uint8Array containing 'request'.
(WebCore::generateSessionId): Return a monotonically increasing number.
(WebCore::MockCDMSession::MockCDMSession): Simple constructor.
(WebCore::MockCDMSession::generateKeyRequest): Ignores the parameters and returns a keyRequest() array.
(WebCore::MockCDMSession::releaseKeys): No-op.
(WebCore::MockCDMSession::addKey): Checks that the key starts with the keyPrefix() array.
* testing/MockCDM.h: Added.
(WebCore::MockCDM::create):
(WebCore::MockCDM::~MockCDM): Simple destructor.
(WebCore::MockCDM::MockCDM): Simple constructor.

Add the new classes to the built system:
* Configurations/FeatureDefines.xcconfig:
* DerivedSources.make:
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:

Miscelaneous changes:
* dom/EventNames.in: Add the two new event types, MediaKeyMessageEvent and MediaKeyNeededEvent.
* dom/EventTargetFactory.in: Add the new EventTarget, MediaKeySession.
* page/DOMWindow.idl: Add constructors for the new classes to the window object.

Source/WTF:

Define the ENABLE_ENCRYPTED_MEDIA_V2 setting.

* wtf/Platform.h:

LayoutTests:

Added new tests for the updated Encrypted Media Extensions spec.

* media/encrypted-media/encrypted-media-v2-events-expected.txt: Added.
* media/encrypted-media/encrypted-media-v2-events.html: Added.
* media/encrypted-media/encrypted-media-v2-syntax-expected.txt: Added.
* media/encrypted-media/encrypted-media-v2-syntax.html: Added.
* platform/Chromium/TestExpectations: Skip the new media/encrypted-media/ v2 tests.
* platform/mac/media/encrypted-media/encrypted-media-can-play-type-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 579b892b
2013-02-08 Jer Noble <jer.noble@apple.com>
Bring WebKit up to speed with latest Encrypted Media spec.
https://bugs.webkit.org/show_bug.cgi?id=97037
Reviewed by Eric Carlson.
Added new tests for the updated Encrypted Media Extensions spec.
* media/encrypted-media/encrypted-media-v2-events-expected.txt: Added.
* media/encrypted-media/encrypted-media-v2-events.html: Added.
* media/encrypted-media/encrypted-media-v2-syntax-expected.txt: Added.
* media/encrypted-media/encrypted-media-v2-syntax.html: Added.
* platform/Chromium/TestExpectations: Skip the new media/encrypted-media/ v2 tests.
* platform/mac/media/encrypted-media/encrypted-media-can-play-type-expected.txt: Added.
2013-02-08 Stephen Chenney <schenney@chromium.org>
[Chromium] Expectations as a result of removing Skia code suppressions
This tests the events created by MediaKeys.
RUN(mediaKeys = new MediaKeys("com.webcore.mock"))
RUN(mediaKeySession = mediaKeys.createSession("video/mock", initData))
EVENT(webkitkeymessage)
RUN(mediaKeySession.addKey(invalidKey))
EVENT(webkitkeyerror)
RUN(mediaKeySession.addKey(validKey))
EVENT(webkitkeyadded)
END OF TEST
<!DOCTYPE html>
<html>
<head>
<title>MediaKeys</title>
<script src=../video-test.js></script>
<script>
function stringToUint8Array(str)
{
var arr=[];
for(var i=0,j=str.length;i<j;++i)
arr[i]=str.charCodeAt(i);
return new Uint8Array(arr);
}
var mediaKeys;
var mediaKeySession;
var initData = stringToUint8Array('mock');
var invalidKey = stringToUint8Array('invalid');
var validKey = stringToUint8Array('key');
function runTest()
{
// Initialize the MockCDM. It supports the key system 'com.apple.mock', the
// mime type 'video/mock'. It requires init data to begin with 'mock', and
// keys to begin with 'key'.
if (internals)
internals.initializeMockCDM();
run('mediaKeys = new MediaKeys("com.webcore.mock")');
run('mediaKeySession = mediaKeys.createSession("video/mock", initData)');
waitForEvent('webkitkeymessage', keyMessage, false, false, mediaKeySession);
waitForEvent('webkitkeyerror', keyError, false, false, mediaKeySession);
waitForEvent('webkitkeyadded', null, true, false, mediaKeySession);
}
function keyMessage(event)
{
run('mediaKeySession.addKey(invalidKey)');
}
function keyError(event)
{
run('mediaKeySession.addKey(validKey)');
}
</script>
</head>
<body onload="runTest()">
<p>This tests the events created by MediaKeys.</p>
</html>
\ No newline at end of file
This tests the basic API of MediaKeys and MediaKeySession.
Test MediaKeys.
EXPECTED (typeof window.MediaKeys == 'object') OK
TEST(new MediaKeys("")) THROWS(DOMException.INVALID_ACCESS_ERR) OK
TEST(new MediaKeys("unsupported")) THROWS(DOMException.NOT_SUPPORTED_ERR) OK
RUN(mediaKeys = new MediaKeys("com.webcore.mock"))
EXPECTED (mediaKeys.keySystem == 'com.webcore.mock') OK
EXPECTED (typeof mediaKeys.createSession == 'function') OK
TEST(mediaKeys.createSession("", new Uint8Array(1))) THROWS(DOMException.INVALID_ACCESS_ERR) OK
TEST(mediaKeys.createSession("unsupported/type")) THROWS(DOMException.NOT_SUPPORTED_ERR) OK
Test MediaKeySession.
RUN(mediaKeySession = mediaKeys.createSession("video/mock", initData))
EXPECTED (typeof mediaKeySession == 'object') OK
EXPECTED (typeof mediaKeySession.addEventListener == 'function') OK
EXPECTED (typeof mediaKeySession.addKey == 'function') OK
EXPECTED (mediaKeySession.error == 'null') OK
EXPECTED (mediaKeySession.keySystem == 'com.webcore.mock') OK
EXPECTED (mediaKeySession.sessionId != 'null') OK
EXPECTED (mediaKeySession.onwebkitkeyadded == 'null') OK
EXPECTED (mediaKeySession.onwebkitkeyerror == 'null') OK
EXPECTED (mediaKeySession.onwebkitkeymessage == 'null') OK
TEST(mediaKeySession.addKey(null)) THROWS(DOMException.INVALID_ACCESS_ERR) OK
END OF TEST
<!DOCTYPE html>
<html>
<head>
<title>MediaKeys</title>
<script src=../video-test.js></script>
<script>
function stringToUint8Array(str)
{
var arr=[];
for(var i=0,j=str.length;i<j;++i)
arr[i]=str.charCodeAt(i);
return new Uint8Array(arr);
}
var mediaKeys;
var mediaKeySession;
var initData = stringToUint8Array('mock');
function runTest()
{
// Initialize the MockCDM. It supports the key system 'com.apple.mock', the
// mime type 'video/mock'. It requires init data to begin with 'mock', and
// keys to begin with 'key'.
if (internals)
internals.initializeMockCDM();
consoleWrite("Test MediaKeys.");
testExpected('typeof window.MediaKeys', 'object');
testException('new MediaKeys("")', "DOMException.INVALID_ACCESS_ERR");
testException('new MediaKeys("unsupported")', "DOMException.NOT_SUPPORTED_ERR");
run('mediaKeys = new MediaKeys("com.webcore.mock")');
testExpected('mediaKeys.keySystem', 'com.webcore.mock');
testExpected('typeof mediaKeys.createSession', 'function');
testException('mediaKeys.createSession("", new Uint8Array(1))', "DOMException.INVALID_ACCESS_ERR");
testException('mediaKeys.createSession("unsupported/type")', "DOMException.NOT_SUPPORTED_ERR");
consoleWrite("");
consoleWrite("Test MediaKeySession.");
run('mediaKeySession = mediaKeys.createSession("video/mock", initData)');
testExpected('typeof mediaKeySession', 'object');
testExpected('typeof mediaKeySession.addEventListener', 'function');
testExpected('typeof mediaKeySession.addKey', 'function');
testExpected('mediaKeySession.error', null);
testExpected('mediaKeySession.keySystem', 'com.webcore.mock');
testExpected('mediaKeySession.sessionId', null, '!=');
testExpected('mediaKeySession.onwebkitkeyadded', null);
testExpected('mediaKeySession.onwebkitkeyerror', null);
testExpected('mediaKeySession.onwebkitkeymessage', null);
testException('mediaKeySession.addKey(null)', "DOMException.INVALID_ACCESS_ERR");
endTest();
}
</script>
</head>
<body onload="runTest()">
<p>This tests the basic API of MediaKeys and MediaKeySession.</p>
</body>
</html>
\ No newline at end of file
......@@ -4354,3 +4354,5 @@ webkit.org/b/109262 [ Debug SnowLeopard ] fast/table/table-cell-before-after-con
webkit.org/b/109312 [ Win ] fast/canvas/canvas-drawImage-shadow.html [ Pass Failure ]
webkit.org/b/109312 [ Win ] platform/chromium/virtual/gpu/fast/canvas/canvas-drawImage-shadow.html [ Pass Failure ]
webkit.org/b/97037 media/encrypted-media/encrypted-media-v2-events.html [ Failure ]
webkit.org/b/97037 media/encrypted-media/encrypted-media-v2-syntax.html [ Failure ]
Test Encrypted Media extension of HTMLMediaElement canPlayType() method.
The test is designed to pass with any implementation regardless of supported media types and relies on the expected log to detect the expected results for some types. To get sufficient coverage, it is important that an implementation support clearkey encryption of at least one of the types below.
Always return the empty string for no type.
EXPECTED (video.canPlayType() == '') OK
Always return the empty string for an empty type.
EXPECTED (video.canPlayType('') == '') OK
EXPECTED (video.canPlayType('', '') == '') OK
EXPECTED (video.canPlayType('', null) == '') OK
EXPECTED (video.canPlayType('', undefined) == '') OK
EXPECTED (video.canPlayType('', 'webkit-org.w3.clearkey') == '') OK
EXPECTED (video.canPlayType('', 'WeBkIt-OrG.W3.ClEaRkEy') == '') OK
EXPECTED (video.canPlayType('', 'com.example.invalid') == '') OK
Always return the empty string for when no container is specified.
EXPECTED (video.canPlayType('video/') == '') OK
EXPECTED (video.canPlayType('video/', '') == '') OK
EXPECTED (video.canPlayType('video/', null) == '') OK
EXPECTED (video.canPlayType('video/', undefined) == '') OK
EXPECTED (video.canPlayType('video/', 'webkit-org.w3.clearkey') == '') OK
EXPECTED (video.canPlayType('video/', 'WeBkIt-OrG.W3.ClEaRkEy') == '') OK
EXPECTED (video.canPlayType('video/', 'com.example.invalid') == '') OK
Always return the empty string for an unsupported container.
EXPECTED (video.canPlayType('video/blahblah') == '') OK
EXPECTED (video.canPlayType('video/blahblah', '') == '') OK
EXPECTED (video.canPlayType('video/blahblah', null) == '') OK
EXPECTED (video.canPlayType('video/blahblah', undefined) == '') OK
EXPECTED (video.canPlayType('video/blahblah', 'webkit-org.w3.clearkey') == '') OK
EXPECTED (video.canPlayType('video/blahblah', 'WeBkIt-OrG.W3.ClEaRkEy') == '') OK
EXPECTED (video.canPlayType('video/blahblah', 'com.example.invalid') == '') OK
Empty key system parameters should not affect the result of video/mp4 types.
Result of video.canPlayType('video/mp4; Codecs="avc1.4D400C"'): 'probably'
EXPECTED (video.canPlayType('video/mp4; Codecs="avc1.4D400C"', '') == 'probably') OK
EXPECTED (video.canPlayType('video/mp4; Codecs="avc1.4D400C"', null) == 'probably') OK
EXPECTED (video.canPlayType('video/mp4; Codecs="avc1.4D400C"', undefined) == 'probably') OK
There are currently no implementations supporting encryption of video/mp4.
EXPECTED (video.canPlayType('video/mp4; Codecs="avc1.4D400C"', 'webkit-org.w3.clearkey') == '') OK
EXPECTED (video.canPlayType('video/mp4; Codecs="avc1.4D400C"', 'WeBkIt-OrG.W3.ClEaRkEy') == '') OK
EXPECTED (video.canPlayType('video/mp4; Codecs="avc1.4D400C"', 'com.example.invalid') == '') OK
Empty key system parameters should not affect the result of audio/mpeg types.
Result of video.canPlayType('audio/mpeg'): 'maybe'
EXPECTED (video.canPlayType('audio/mpeg', '') == 'maybe') OK
EXPECTED (video.canPlayType('audio/mpeg', null) == 'maybe') OK
EXPECTED (video.canPlayType('audio/mpeg', undefined) == 'maybe') OK
There are currently no implementations supporting encryption of audio/mpeg.
EXPECTED (video.canPlayType('audio/mpeg', 'webkit-org.w3.clearkey') == '') OK
EXPECTED (video.canPlayType('audio/mpeg', 'WeBkIt-OrG.W3.ClEaRkEy') == '') OK
EXPECTED (video.canPlayType('audio/mpeg', 'com.example.invalid') == '') OK
Empty key system parameters should not affect the result of audio/wav types.
Result of video.canPlayType('audio/wav'): 'maybe'
EXPECTED (video.canPlayType('audio/wav', '') == 'maybe') OK
EXPECTED (video.canPlayType('audio/wav', null) == 'maybe') OK
EXPECTED (video.canPlayType('audio/wav', undefined) == 'maybe') OK
There are currently no implementations supporting encryption of audio/wav.
EXPECTED (video.canPlayType('audio/wav', 'webkit-org.w3.clearkey') == '') OK
EXPECTED (video.canPlayType('audio/wav', 'WeBkIt-OrG.W3.ClEaRkEy') == '') OK
EXPECTED (video.canPlayType('audio/wav', 'com.example.invalid') == '') OK
Empty key system parameters should not affect the result of video/webm types.
Result of video.canPlayType('video/webm'): ''
EXPECTED (video.canPlayType('video/webm', '') == '') OK
EXPECTED (video.canPlayType('video/webm', null) == '') OK
EXPECTED (video.canPlayType('video/webm', undefined) == '') OK
All implementations that support WebM and Encrypted Media support encrypted WebM.
EXPECTED (video.canPlayType('video/webm', 'webkit-org.w3.clearkey') == '') OK
EXPECTED (video.canPlayType('video/webm', 'WeBkIt-OrG.W3.ClEaRkEy') == '') OK
EXPECTED (video.canPlayType('video/webm', 'com.example.invalid') == '') OK
END OF TEST
2013-02-08 Jer Noble <jer.noble@apple.com>
Bring WebKit up to speed with latest Encrypted Media spec.
https://bugs.webkit.org/show_bug.cgi?id=97037
Reviewed by Eric Carlson.
Define the ENABLE_ENCRYPTED_MEDIA_V2 setting.
* Configurations/FeatureDefines.xcconfig:
2013-02-08 Gavin Barraclough <barraclough@apple.com>
Objective-C API for JavaScriptCore
......
......@@ -65,11 +65,11 @@ ENABLE_DIALOG_ELEMENT = ;
ENABLE_DIRECTORY_UPLOAD = ;
ENABLE_DOM4_EVENTS_CONSTRUCTOR = ENABLE_DOM4_EVENTS_CONSTRUCTOR;
ENABLE_DRAGGABLE_REGION = ;
ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(PLATFORM_NAME));
ENABLE_ENCRYPTED_MEDIA_macosx = $(ENABLE_ENCRYPTED_MEDIA_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
ENABLE_ENCRYPTED_MEDIA_macosx_1070 = ;
ENABLE_ENCRYPTED_MEDIA_macosx_1080 = ;
ENABLE_ENCRYPTED_MEDIA_macosx_1090 = ENABLE_ENCRYPTED_MEDIA;
ENABLE_ENCRYPTED_MEDIA_V2 = $(ENABLE_ENCRYPTED_MEDIA_V2_$(REAL_PLATFORM_NAME));
ENABLE_ENCRYPTED_MEDIA_V2_macosx = $(ENABLE_ENCRYPTED_MEDIA_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
ENABLE_ENCRYPTED_MEDIA_V2_macosx_1070 = ;
ENABLE_ENCRYPTED_MEDIA_V2_macosx_1080 = ;
ENABLE_ENCRYPTED_MEDIA_V2_macosx_1090 = ENABLE_ENCRYPTED_MEDIA_V2;
ENABLE_FILE_SYSTEM = ;
ENABLE_FILTERS = ENABLE_FILTERS;
ENABLE_FULLSCREEN_API = $(ENABLE_FULLSCREEN_API_$(PLATFORM_NAME));
......@@ -167,4 +167,4 @@ ENABLE_WORKERS = ENABLE_WORKERS;
ENABLE_XHR_TIMEOUT = ENABLE_XHR_TIMEOUT;
ENABLE_XSLT = ENABLE_XSLT;
FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_BLOB) $(ENABLE_CANVAS_PATH) $(ENABLE_CANVAS_PROXY) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_STICKY_POSITION) $(ENABLE_CSS_TRANSFORMS_ANIMATIONS_UNPREFIXED) $(ENABLE_CSS_VARIABLES) $(ENABLE_CSS3_CONDITIONAL_RULES) $(ENABLE_CSS3_TEXT) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DOM4_EVENTS_CONSTRUCTOR) $(ENABLE_DRAGGABLE_REGION) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LEGACY_VENDOR_PREFIXES) $(ENABLE_LEGACY_WEB_AUDIO) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MICRODATA) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_CONTENT_UTILS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_PLUGIN_PROXY_FOR_VIDEO) $(ENABLE_PROGRESS_ELEMENT) $(ENABLE_PROXIMITY_EVENTS) $(ENABLE_QUOTA) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SUBPIXEL_LAYOUT) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEMPLATE_ELEMENT) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_USERSELECT_ALL) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XHR_TIMEOUT) $(ENABLE_XSLT) $(FEATURE_DEFINES_$(PLATFORM_NAME));
FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_BLOB) $(ENABLE_CANVAS_PATH) $(ENABLE_CANVAS_PROXY) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_STICKY_POSITION) $(ENABLE_CSS_TRANSFORMS_ANIMATIONS_UNPREFIXED) $(ENABLE_CSS_VARIABLES) $(ENABLE_CSS3_CONDITIONAL_RULES) $(ENABLE_CSS3_TEXT) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DOM4_EVENTS_CONSTRUCTOR) $(ENABLE_DRAGGABLE_REGION) $(ENABLE_ENCRYPTED_MEDIA_V2) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LEGACY_VENDOR_PREFIXES) $(ENABLE_LEGACY_WEB_AUDIO) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MICRODATA) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_CONTENT_UTILS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_PLUGIN_PROXY_FOR_VIDEO) $(ENABLE_PROGRESS_ELEMENT) $(ENABLE_PROXIMITY_EVENTS) $(ENABLE_QUOTA) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SUBPIXEL_LAYOUT) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEMPLATE_ELEMENT) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_USERSELECT_ALL) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XHR_TIMEOUT) $(ENABLE_XSLT) $(FEATURE_DEFINES_$(PLATFORM_NAME));
2013-02-08 Jer Noble <jer.noble@apple.com>
Bring WebKit up to speed with latest Encrypted Media spec.
https://bugs.webkit.org/show_bug.cgi?id=97037
Reviewed by Eric Carlson.
Define the ENABLE_ENCRYPTED_MEDIA_V2 setting.
* wtf/Platform.h:
2013-02-08 Adam Barth <abarth@webkit.org>
Use WeakPtrs to communicate between the HTMLDocumentParser and the BackgroundHTMLParser
......
......@@ -1168,6 +1168,7 @@
#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
#define HAVE_AVFOUNDATION_TEXT_TRACK_SUPPORT 1
#define ENABLE_ENCRYPTED_MEDIA_V2 1
#endif
#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY)
......
2013-02-08 Jer Noble <jer.noble@apple.com>
Bring WebKit up to speed with latest Encrypted Media spec.
https://bugs.webkit.org/show_bug.cgi?id=97037
Reviewed by Eric Carlson.
The most recent version of the Encrypted Media Extensions spec breaks functionality out of the
HTMLMediaElement and into new MediaKeys and MediaKeySession classes. Since the CDM functionality
has been pulled out of the media element, we create a proxy CDM class and factory system for
creating specific CDM key system implementations. The spec also breaks out MediaKeyEvent
into distinct event classes, MediaKeyNeededEvent and MediaKeyMessageEvent, for needkey and
keymessage events, respectively.
Tests: media/encrypted-media/encrypted-media-v2-events.html
media/encrypted-media/encrypted-media-v2-syntax.html
CDM is a proxy class (a la MediaPlayer) for a specific CDMPrivateInterface implementation. A CDM
implementation is registered with the CDMFactory and will be created if that implementation supports
the key system passed into the MediaKeys constructor. CDMSession is a pure-virtual interface exposed
by concrete CDMPrivate subclasses. Its lifetime is owned by MediaKeySession.
* Modules/encryptedmedia/CDM.cpp: Added.
(WebCore::installedCDMFactories): Initialize all the known CDM subtypes. Ports will add CDM implementations here.
(WebCore::CDM::registerCDMFactory): Registers a new CDMFactory using the passed in function pointers.
(WebCore::CDMFactoryForKeySystem): Return the first CDM factory which supports the requested key system.
(WebCore::CDM::supportsKeySystem): Walk the installed CDMs and ask if the given key system is supported.
(WebCore::CDM::supportsKeySystemMIMETypeAndCodec): Ditto, with an additional MIME type and codec string.
(WebCore::CDM::create): Simple constructor wrapper.
(WebCore::CDM::CDM): Simple constructor; calls bestCDMForKeySystem() to create it's private implementation.
(WebCore::CDM::~CDM): Simple destructor.
(WebCore::CDM::createSession): Creates a new CDMSession.
* Modules/encryptedmedia/CDM.h: Added.
(WebCore::CDM::keySystem): Simple accessor for m_keySystem.
(WebCore::CDMSession::CDMSession): Simple constructor.
(WebCore::CDMSession::~CDMSession): Simple destructor.
* Modules/encryptedmedia/CDMPrivate.h: Added.
(WebCore::CDMPrivateInterface::CDMPrivateInterface): Simple constructor.
(WebCore::CDMPrivateInterface::~CDMPrivateInterface): Simple destructor.
The new classes, MediaKeyMessageEvent and MediaKeyNeededEvent, take distinct subsets of the initializers of
the original MediaKeyMessageEvent.
* Modules/encryptedmedia/MediaKeyMessageEvent.cpp: Copied from Source/WebCore/html/MediaKeyEvent.cpp.
(WebCore::MediaKeyMessageEventInit::MediaKeyMessageEventInit): Initializer now only takes message and destinationURL
parameters.
(WebCore::MediaKeyMessageEvent::MediaKeyMessageEvent): Simple constructor.
(WebCore::MediaKeyMessageEvent::~MediaKeyMessageEvent): Simple destructor.
(WebCore::MediaKeyMessageEvent::interfaceName): Standard interfaceName.
* Modules/encryptedmedia/MediaKeyMessageEvent.h: Copied from Source/WebCore/html/MediaKeyEvent.h.
(WebCore::MediaKeyMessageEvent::create): Simple construction wrapper.
(WebCore::MediaKeyMessageEvent::message): Simple accessor for m_message.
(WebCore::MediaKeyMessageEvent::destinationURL): Simple accessor for m_destinationURL.
* Modules/encryptedmedia/MediaKeyMessageEvent.idl: Copied from Source/WebCore/html/MediaKeyEvent.idl.
* Modules/encryptedmedia/MediaKeyNeededEvent.cpp: Copied from Source/WebCore/html/MediaKeyEvent.h.
(WebCore::MediaKeyNeededEventInit::MediaKeyNeededEventInit): Initializer now only takes initData parameter.
(WebCore::MediaKeyNeededEvent::MediaKeyNeededEvent): Simple constructor.
(WebCore::MediaKeyNeededEvent::~MediaKeyNeededEvent): Simple destructor.
(WebCore::MediaKeyNeededEvent::interfaceName): Standard interfaceName.
* Modules/encryptedmedia/MediaKeyNeededEvent.h: Copied from Source/WebCore/html/MediaKeyEvent.h.
(WebCore::MediaKeyNeededEvent::create): Simple construction wrapper.
(WebCore::MediaKeyNeededEvent::initData): Simple accessor for m_initData.
* Modules/encryptedmedia/MediaKeyNeededEvent.idl: Copied from Source/WebCore/html/MediaKeyEvent.idl.
MediaKeySession is a new class that maps keys and key requests to a given session ID:
* Modules/encryptedmedia/MediaKeySession.cpp: Added.
(WebCore::MediaKeySession::create): Simple construction wrapper.
(WebCore::MediaKeySession::MediaKeySession): Simple constructor.
(WebCore::MediaKeySession::~MediaKeySession): Simple destructor; calls close().
(WebCore::MediaKeySession::setError): Simple setter for m_error;
(WebCore::MediaKeySession::close): Tell the CDM to clear any saved session keys.
(WebCore::MediaKeySession::generateKeyRequest): Start a one-shot timer, handled in keyRequestTimerFired.
(WebCore::MediaKeySession::keyRequestTimerFired): Follow the steps in the spec; ask the CDM to generate a key request.
(WebCore::MediaKeySession::addKey): Start a one-shot timer, handled in addKeyTimerFired.
(WebCore::MediaKeySession::addKeyTimerFired): Follow the steps in the spec; provide the key data to the CDM.
* Modules/encryptedmedia/MediaKeySession.h: Added.
(WebCore::MediaKeySession::keySystem): Simple accessor for m_keySystem.
(WebCore::MediaKeySession::sessionId): Simple accessor for m_sessionId.
(WebCore::MediaKeySession::error): Simple accessor for m_error;
* Modules/encryptedmedia/MediaKeySession.idl:
MediaKeySession inherits from EventTarget, and must override the pure virtual functions in that class:
* Modules/encryptedmedia/MediaKeySession.cpp: Added.
(WebCore::MediaKeySession::interfaceName):
* Modules/encryptedmedia/MediaKeySession.h: Added.
(WebCore::MediaKeySession::refEventTarget):
(WebCore::MediaKeySession::derefEventTarget):
(WebCore::MediaKeySession::eventTargetData):
(WebCore::MediaKeySession::ensureEventTargetData):
(WebCore::MediaKeySession::scriptExecutionContext):
MediaKeys is a new class that encapsulates a CDM and a number of key sessions:
* Modules/encryptedmedia/MediaKeys.cpp: Added.
(WebCore::MediaKeys::create): Throw an exception if the key system parameter is unsupported; create a CDM object
and a new MediaKeys session.
(WebCore::MediaKeys::MediaKeys): Simple constructor.
(WebCore::MediaKeys::~MediaKeys): Simple destructor.
(WebCore::MediaKeys::createSession): Follow the spec and create a new key session.
* Modules/encryptedmedia/MediaKeys.h: Added.
* Modules/encryptedmedia/MediaKeys.idl: Copied from Source/WebCore/html/MediaError.idl.
Provide a new interface to HTMLMediaElement for MediaPlayer which does not require a sessionId or a key system:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerKeyNeeded):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::keyNeeded):
MediaKeyError now has a systemCode parameter and member variable.
* html/MediaKeyError.h:
(WebCore::MediaKeyError::create): Take a systemCode parameter with a default (0) value.
(WebCore::MediaKeyError::MediaKeyError): Ditto.
(WebCore::MediaKeyError::systemCode): Simple accessor for m_systemCode.
* html/MediaKeyError.idl:
Add new methods to HTMLMediaElement to support MediaKeys. Support different initializer
for the MediaKeyNeededEvent.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setMediaKeys): Simple setter for m_mediaKeys.
(WebCore::HTMLMediaElement::mediaPlayerKeyNeeded): This version takes fewer parameters
than the deprecated version.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::mediaKeys): Simple accessor for m_mediaKeys.
* html/HTMLMediaElement.idl: Add the mediaKeys attribute.
Add an ENABLE(ENCRYPTED_MEDIA_V2) check to the existing ENABLE(ENCRYPTED_MEDIA) one:
* html/MediaError.h:
* html/MediaError.idl:
* platform/graphics/MediaPlayer.cpp:
(WebCore::bestMediaEngineForTypeAndCodecs):
(WebCore::MediaPlayer::supportsType):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayer::keyNeeded): This version takes fewer parameters than the
deprecated version.
Support the new version of canPlayType which takes an extra parameter:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine):
(WebCore::MediaPlayerPrivateAVFoundationObjC::extendedSupportsType):
* platform/graphics/mac/MediaPlayerPrivateQTKit.h:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::registerMediaEngine):
(WebCore::MediaPlayerPrivateQTKit::extendedSupportsType):
Add a mock CDM for use within DRT and WKTR to test the MediaKeys and MediaKeySession
APIs and events:
* testing/Internals.cpp:
(WebCore::Internals::initializeMockCDM): Add the MockCDM class to the CDM factories.
* testing/Internals.h:
* testing/Internals.idl: Add the initializeMockCDM() method.
* testing/MockCDM.cpp: Added.
(WebCore::MockCDM::supportsKeySystem): Only supports the 'com.webcore.mock' key system.
(WebCore::MockCDM::supportsMIMEType): Only supports the 'video/mock' mime type.
(WebCore::initDataPrefix): Static method which returns a Uint8Array containing 'mock'.
(WebCore::keyPrefix): Static method which returns a Uint8Array containing 'key'.
(WebCore::keyRequest): Static method which returns a Uint8Array containing 'request'.
(WebCore::generateSessionId): Return a monotonically increasing number.
(WebCore::MockCDMSession::MockCDMSession): Simple constructor.
(WebCore::MockCDMSession::generateKeyRequest): Ignores the parameters and returns a keyRequest() array.
(WebCore::MockCDMSession::releaseKeys): No-op.
(WebCore::MockCDMSession::addKey): Checks that the key starts with the keyPrefix() array.
* testing/MockCDM.h: Added.
(WebCore::MockCDM::create):
(WebCore::MockCDM::~MockCDM): Simple destructor.
(WebCore::MockCDM::MockCDM): Simple constructor.
Add the new classes to the built system:
* Configurations/FeatureDefines.xcconfig:
* DerivedSources.make:
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
Miscelaneous changes:
* dom/EventNames.in: Add the two new event types, MediaKeyMessageEvent and MediaKeyNeededEvent.
* dom/EventTargetFactory.in: Add the new EventTarget, MediaKeySession.
* page/DOMWindow.idl: Add constructors for the new classes to the window object.
2013-02-08 Chris Fleizach <cfleizach@apple.com>
Refactor platform-specific code in SpeechSynthesis
......@@ -65,11 +65,11 @@ ENABLE_DIALOG_ELEMENT = ;
ENABLE_DIRECTORY_UPLOAD = ;
ENABLE_DOM4_EVENTS_CONSTRUCTOR = ENABLE_DOM4_EVENTS_CONSTRUCTOR;
ENABLE_DRAGGABLE_REGION = ;
ENABLE_ENCRYPTED_MEDIA = $(ENABLE_ENCRYPTED_MEDIA_$(PLATFORM_NAME));
ENABLE_ENCRYPTED_MEDIA_macosx = $(ENABLE_ENCRYPTED_MEDIA_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
ENABLE_ENCRYPTED_MEDIA_macosx_1070 = ;
ENABLE_ENCRYPTED_MEDIA_macosx_1080 = ;
ENABLE_ENCRYPTED_MEDIA_macosx_1090 = ENABLE_ENCRYPTED_MEDIA;
ENABLE_ENCRYPTED_MEDIA_V2 = $(ENABLE_ENCRYPTED_MEDIA_V2_$(REAL_PLATFORM_NAME));
ENABLE_ENCRYPTED_MEDIA_V2_macosx = $(ENABLE_ENCRYPTED_MEDIA_V2_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR));
ENABLE_ENCRYPTED_MEDIA_V2_macosx_1070 = ;
ENABLE_ENCRYPTED_MEDIA_V2_macosx_1080 = ;
ENABLE_ENCRYPTED_MEDIA_V2_macosx_1090 = ENABLE_ENCRYPTED_MEDIA_V2;
ENABLE_FILE_SYSTEM = ;
ENABLE_FILTERS = ENABLE_FILTERS;
ENABLE_FULLSCREEN_API = $(ENABLE_FULLSCREEN_API_$(PLATFORM_NAME));
......@@ -167,4 +167,4 @@ ENABLE_WORKERS = ENABLE_WORKERS;
ENABLE_XHR_TIMEOUT = ENABLE_XHR_TIMEOUT;
ENABLE_XSLT = ENABLE_XSLT;
FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_BLOB) $(ENABLE_CANVAS_PATH) $(ENABLE_CANVAS_PROXY) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_STICKY_POSITION) $(ENABLE_CSS_TRANSFORMS_ANIMATIONS_UNPREFIXED) $(ENABLE_CSS_VARIABLES) $(ENABLE_CSS3_CONDITIONAL_RULES) $(ENABLE_CSS3_TEXT) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DOM4_EVENTS_CONSTRUCTOR) $(ENABLE_DRAGGABLE_REGION) $(ENABLE_ENCRYPTED_MEDIA) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LEGACY_VENDOR_PREFIXES) $(ENABLE_LEGACY_WEB_AUDIO) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MICRODATA) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_CONTENT_UTILS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_PLUGIN_PROXY_FOR_VIDEO) $(ENABLE_PROGRESS_ELEMENT) $(ENABLE_PROXIMITY_EVENTS) $(ENABLE_QUOTA) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SUBPIXEL_LAYOUT) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEMPLATE_ELEMENT) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_USERSELECT_ALL) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XHR_TIMEOUT) $(ENABLE_XSLT) $(FEATURE_DEFINES_$(PLATFORM_NAME));
FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_ACCELERATED_2D_CANVAS) $(ENABLE_BLOB) $(ENABLE_CANVAS_PATH) $(ENABLE_CANVAS_PROXY) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CSP_NEXT) $(ENABLE_CSS_BOX_DECORATION_BREAK) $(ENABLE_CSS_DEVICE_ADAPTATION) $(ENABLE_CSS_EXCLUSIONS) $(ENABLE_CSS_FILTERS) $(ENABLE_CSS_IMAGE_ORIENTATION) $(ENABLE_CSS_IMAGE_RESOLUTION) $(ENABLE_CSS_REGIONS) $(ENABLE_CSS_SHADERS) $(ENABLE_CSS_COMPOSITING) $(ENABLE_CSS_STICKY_POSITION) $(ENABLE_CSS_TRANSFORMS_ANIMATIONS_UNPREFIXED) $(ENABLE_CSS_VARIABLES) $(ENABLE_CSS3_CONDITIONAL_RULES) $(ENABLE_CSS3_TEXT) $(ENABLE_CUSTOM_SCHEME_HANDLER) $(ENABLE_DASHBOARD_SUPPORT) $(ENABLE_DATALIST_ELEMENT) $(ENABLE_DATA_TRANSFER_ITEMS) $(ENABLE_DETAILS_ELEMENT) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DIALOG_ELEMENT) $(ENABLE_DIRECTORY_UPLOAD) $(ENABLE_DOM4_EVENTS_CONSTRUCTOR) $(ENABLE_DRAGGABLE_REGION) $(ENABLE_ENCRYPTED_MEDIA_V2) $(ENABLE_FILE_SYSTEM) $(ENABLE_FILTERS) $(ENABLE_FULLSCREEN_API) $(ENABLE_GAMEPAD) $(ENABLE_GEOLOCATION) $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING) $(ENABLE_HIGH_DPI_CANVAS) $(ENABLE_ICONDATABASE) $(ENABLE_IFRAME_SEAMLESS) $(ENABLE_INDEXED_DATABASE) $(ENABLE_INPUT_SPEECH) $(ENABLE_INPUT_TYPE_COLOR) $(ENABLE_INPUT_TYPE_DATE) $(ENABLE_INPUT_TYPE_DATETIME) $(ENABLE_INPUT_TYPE_DATETIMELOCAL) $(ENABLE_INPUT_TYPE_MONTH) $(ENABLE_INPUT_TYPE_TIME) $(ENABLE_INPUT_TYPE_WEEK) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) $(ENABLE_LEGACY_NOTIFICATIONS) $(ENABLE_LEGACY_VENDOR_PREFIXES) $(ENABLE_LEGACY_WEB_AUDIO) $(ENABLE_LINK_PREFETCH) $(ENABLE_LINK_PRERENDER) $(ENABLE_MATHML) $(ENABLE_MEDIA_SOURCE) $(ENABLE_MEDIA_STATISTICS) $(ENABLE_METER_ELEMENT) $(ENABLE_MHTML) $(ENABLE_MICRODATA) $(ENABLE_MOUSE_CURSOR_SCALE) $(ENABLE_NAVIGATOR_CONTENT_UTILS) $(ENABLE_NOTIFICATIONS) $(ENABLE_PAGE_VISIBILITY_API) $(ENABLE_PDFKIT_PLUGIN) $(ENABLE_PLUGIN_PROXY_FOR_VIDEO) $(ENABLE_PROGRESS_ELEMENT) $(ENABLE_PROXIMITY_EVENTS) $(ENABLE_QUOTA) $(ENABLE_REQUEST_ANIMATION_FRAME) $(ENABLE_RESOLUTION_MEDIA_QUERY) $(ENABLE_SCRIPTED_SPEECH) $(ENABLE_SHADOW_DOM) $(ENABLE_SHARED_WORKERS) $(ENABLE_SPEECH_SYNTHESIS) $(ENABLE_SQL_DATABASE) $(ENABLE_STYLE_SCOPED) $(ENABLE_SUBPIXEL_LAYOUT) $(ENABLE_SVG) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_TEMPLATE_ELEMENT) $(ENABLE_TEXT_AUTOSIZING) $(ENABLE_TEXT_NOTIFICATIONS_ONLY) $(ENABLE_TOUCH_ICON_LOADING) $(ENABLE_USERSELECT_ALL) $(ENABLE_VIDEO) $(ENABLE_VIDEO_TRACK) $(ENABLE_WEBGL) $(ENABLE_WEB_AUDIO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WEB_TIMING) $(ENABLE_WORKERS) $(ENABLE_XHR_TIMEOUT) $(ENABLE_XSLT) $(FEATURE_DEFINES_$(PLATFORM_NAME));
......@@ -28,6 +28,7 @@
VPATH = \
$(WebCore) \
$(WebCore)/Modules/encryptedmedia \
$(WebCore)/Modules/filesystem \
$(WebCore)/Modules/geolocation \
$(WebCore)/Modules/indexeddb \
......@@ -62,6 +63,10 @@ VPATH = \
#
BINDING_IDLS = \
$(WebCore)/Modules/encryptedmedia/MediaKeyMessageEvent.idl \
$(WebCore)/Modules/encryptedmedia/MediaKeyNeededEvent.idl \
$(WebCore)/Modules/encryptedmedia/MediaKeySession.idl \
$(WebCore)/Modules/encryptedmedia/MediaKeys.idl \
$(WebCore)/Modules/filesystem/DOMFileSystem.idl \
$(WebCore)/Modules/filesystem/DOMFileSystemSync.idl \
$(WebCore)/Modules/filesystem/DOMWindowFileSystem.idl \
......@@ -366,8 +371,8 @@ BINDING_IDLS = \
$(WebCore)/html/ImageData.idl \
$(WebCore)/html/MediaController.idl \
$(WebCore)/html/MediaError.idl \
$(WebCore)/html/MediaKeyError.idl \
$(WebCore)/html/MediaKeyEvent.idl \
$(WebCore)/html/MediaKeyError.idl \
$(WebCore)/html/MediaKeyEvent.idl \
$(WebCore)/html/MicroDataItemValue.idl \
$(WebCore)/html/RadioNodeList.idl \
$(WebCore)/html/TextMetrics.idl \
......@@ -839,6 +844,10 @@ ifeq ($(findstring ENABLE_DETAILS_ELEMENT,$(FEATURE_DEFINES)), ENABLE_DETAILS_EL
HTML_FLAGS := $(HTML_FLAGS) ENABLE_DETAILS_ELEMENT=1
endif
ifeq ($(findstring ENABLE_ENCRYPTED_MEDIA_V2,$(FEATURE_DEFINES)), ENABLE_ENCRYPTED_MEDIA_V2)
HTML_FLAGS := $(HTML_FLAGS) ENABLE_ENCRYPTED_MEDIA_V2=1
endif
ifeq ($(findstring ENABLE_METER_ELEMENT,$(FEATURE_DEFINES)), ENABLE_METER_ELEMENT)
HTML_FLAGS := $(HTML_FLAGS) ENABLE_METER_ELEMENT=1
endif
......@@ -963,6 +972,7 @@ preprocess_idls_script = perl $(addprefix -I $(WebCore)/, $(sort $(dir $(1)))) $
IDL_INCLUDES = \
$(WebCore)/Modules/battery \
$(WebCore)/Modules/encryptedmedia \
$(WebCore)/Modules/filesystem \
$(WebCore)/Modules/gamepad \
$(WebCore)/Modules/geolocation \
......
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(ENCRYPTED_MEDIA_V2)
#include "CDM.h"
#include "CDMPrivate.h"
#include "MediaKeyError.h"
#include "MediaKeys.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
struct CDMFactory {
WTF_MAKE_NONCOPYABLE(CDMFactory); WTF_MAKE_FAST_ALLOCATED;
public:
CDMFactory(CreateCDM constructor, CDMSupportsKeySystem supportsKeySystem)
: constructor(constructor)