Diff
Modified: trunk/Source/WebCore/ChangeLog (143258 => 143259)
--- trunk/Source/WebCore/ChangeLog 2013-02-18 21:36:57 UTC (rev 143258)
+++ trunk/Source/WebCore/ChangeLog 2013-02-18 21:37:54 UTC (rev 143259)
@@ -1,3 +1,47 @@
+2013-02-18 Jer Noble <[email protected]>
+
+ EME: Add a CDMPrivate implementation using AVFoundation.
+ https://bugs.webkit.org/show_bug.cgi?id=109739
+
+ Reviewed by Eric Carlson.
+
+ Add a CDMPrivate implementation using AVFoundation, similar to the EME v1 implementation
+ in MediaPlayerPrivateAVFoundationObjC. This requires passing the AVAssetResourceLoadingRequest
+ from the MediaPlayerPrivateAVFoundationObjC instance to CDMSessionAVFoundation. To do so
+ without adding platform-specific API to MediaPlayer, add a static map from MediaPlayer ->
+ MediaPlayerPrivateAVFoundationObjC instances to be used to vend the AVAssetResourceLoadingRequest
+ to CDMSessionAVFoundation.
+
+ * Modules/encryptedmedia/CDM.cpp:
+ (WebCore::installedCDMFactories): Add the factory for CDMPrivateAVFoundation.
+ * Modules/encryptedmedia/CDM.h:
+ * Modules/encryptedmedia/CDMPrivateAVFoundation.h: Added.
+ (WebCore::CDMPrivateAVFoundation::create): Simple factory method.
+ (WebCore::CDMPrivateAVFoundation::~CDMPrivateAVFoundation): Simple virtual destructor.
+ (WebCore::CDMPrivateAVFoundation::cdm): Simple getter.
+ (WebCore::CDMPrivateAVFoundation::CDMPrivateAVFoundation): Simple constructor.
+ * Modules/encryptedmedia/CDMPrivateAVFoundation.mm: Added.
+ (WebCore::CDMSessionAVFoundation::~CDMSessionAVFoundation): Simple destructor.
+ (WebCore::CDMPrivateAVFoundation::supportsKeySytem): Check whether the given key system is supported.
+ (WebCore::CDMPrivateAVFoundation::supportsMIMEType): Check whether the given MIME type is supported.
+ (WebCore::CDMPrivateAVFoundation::createSession): Return a new CDMSessionAVFoundation.
+ (WebCore::CDMSessionAVFoundation::CDMSessionAVFoundation): Simple constructor.
+ (WebCore::CDMSessionAVFoundation::generateKeyRequest): Retrieve the AVAssetResourceLoadingRequest
+ from the MediaPlayer, and use it to generate a key request.
+ (WebCore::CDMSessionAVFoundation::releaseKeys): No-op.
+ (WebCore::CDMSessionAVFoundation::update): Add the passed in key to the AVAssetResourceLoadingRequest.
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::playerToPrivateMap): Lazily instantiate static map.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Register with the playerToPrivateMap.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC): Unregister from same.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Also send keyNeeded event in ENCRYPTED_MEDIA_V2.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData): Convert this
+ method from file-static to class static.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI): Pull the AVAssetResourceLoadingRequest
+ from m_keyURIToRequestMap and return it, if present.
+
2013-02-18 Philip Rogers <[email protected]>
Fix scaling of tiled SVG backgrounds on high-dpi displays
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp (143258 => 143259)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2013-02-18 21:36:57 UTC (rev 143258)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2013-02-18 21:37:54 UTC (rev 143259)
@@ -34,6 +34,10 @@
#include "MediaKeys.h"
#include <wtf/text/WTFString.h>
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#include "CDMPrivateAVFoundation.h"
+#endif
+
namespace WebCore {
struct CDMFactory {
@@ -57,6 +61,10 @@
queriedCDMs = true;
// FIXME: initialize specific UA CDMs. http://webkit.org/b/109318, http://webkit.org/b/109320
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ cdms.append(new CDMFactory(CDMPrivateAVFoundation::create, CDMPrivateAVFoundation::supportsKeySytem));
+#endif
+
}
return cdms;
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.h (143258 => 143259)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.h 2013-02-18 21:36:57 UTC (rev 143258)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.h 2013-02-18 21:37:54 UTC (rev 143259)
@@ -63,6 +63,8 @@
class CDM {
public:
+
+ enum CDMErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError };
static bool supportsKeySystem(const String&);
static PassOwnPtr<CDM> create(const String& keySystem);
static void registerCDMFactory(CreateCDM, CDMSupportsKeySystem);
Added: trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.h (0 => 143259)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.h (rev 0)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.h 2013-02-18 21:37:54 UTC (rev 143259)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#ifndef CDMPrivateAVFoundation_h
+#define CDMPrivateAVFoundation_h
+
+#include "CDMPrivate.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+namespace WebCore {
+
+class CDM;
+
+class CDMPrivateAVFoundation : public CDMPrivateInterface {
+public:
+ // CDMFactory support:
+ static PassOwnPtr<CDMPrivateInterface> create(CDM* cdm) { return adoptPtr(new CDMPrivateAVFoundation(cdm)); }
+ static bool supportsKeySytem(const String&);
+
+ virtual ~CDMPrivateAVFoundation() { }
+
+ virtual bool supportsMIMEType(const String& mimeType) OVERRIDE;
+ virtual PassOwnPtr<CDMSession> createSession() OVERRIDE;
+
+ CDM* cdm() const { return m_cdm; }
+
+protected:
+ CDMPrivateAVFoundation(CDM* cdm) : m_cdm(cdm) { }
+ CDM* m_cdm;
+};
+
+}
+
+#endif
+
+#endif // CDMPrivateAVFoundation_h
Added: trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.mm (0 => 143259)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.mm (rev 0)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.mm 2013-02-18 21:37:54 UTC (rev 143259)
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#import "config.h"
+#import "CDMPrivateAVFoundation.h"
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+#import "CDM.h"
+#import "ExceptionCode.h"
+#import "MediaPlayer.h"
+#import "MediaPlayerPrivateAVFoundationObjC.h"
+#import "SoftLinking.h"
+#import "UUID.h"
+#import <AVFoundation/AVFoundation.h>
+#import <objc/objc-runtime.h>
+#import <wtf/UnusedParam.h>
+
+namespace WebCore {
+
+class CDMSessionAVFoundation : public CDMSession {
+public:
+ CDMSessionAVFoundation(CDMPrivateAVFoundation* parent);
+ virtual ~CDMSessionAVFoundation() { }
+
+ virtual const String& sessionId() const OVERRIDE { return m_sessionId; }
+ virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) OVERRIDE;
+ virtual void releaseKeys() OVERRIDE;
+ virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) OVERRIDE;
+
+protected:
+ CDMPrivateAVFoundation* m_parent;
+ String m_sessionId;
+ RetainPtr<AVAssetResourceLoadingRequest> m_request;
+};
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVURLAsset)
+SOFT_LINK_CLASS(AVFoundation, AVAssetResourceLoadingRequest)
+#define AVURLAsset getAVURLAssetClass()
+#define AVAssetResourceLoadingRequest getAVAssetResourceLoadingRequest()
+
+
+bool CDMPrivateAVFoundation::supportsKeySytem(const String& keySystem)
+{
+ return equalIgnoringCase(keySystem, "com.apple.fps") || equalIgnoringCase(keySystem, "com.apple.fps.1_0");
+}
+
+bool CDMPrivateAVFoundation::supportsMIMEType(const String& mimeType)
+{
+ return [AVURLAsset isPlayableExtendedMIMEType:mimeType];
+}
+
+PassOwnPtr<CDMSession> CDMPrivateAVFoundation::createSession()
+{
+ return adoptPtr(new CDMSessionAVFoundation(this));
+}
+
+CDMSessionAVFoundation::CDMSessionAVFoundation(CDMPrivateAVFoundation* parent)
+ : m_parent(parent)
+ , m_sessionId(createCanonicalUUIDString())
+{
+}
+
+PassRefPtr<Uint8Array> CDMSessionAVFoundation::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
+{
+ UNUSED_PARAM(mimeType);
+
+ MediaPlayer* mediaPlayer = m_parent->cdm()->mediaPlayer();
+ if (!mediaPlayer) {
+ errorCode = NOT_SUPPORTED_ERR;
+ return 0;
+ }
+
+ String keyURI;
+ String keyID;
+ RefPtr<Uint8Array> certificate;
+ if (!MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(initData, keyURI, keyID, certificate)) {
+ errorCode = INVALID_STATE_ERR;
+ return 0;
+ }
+
+ m_request = MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI(mediaPlayer, keyURI);
+ if (!m_request) {
+ errorCode = INVALID_STATE_ERR;
+ return 0;
+ }
+
+ m_sessionId = createCanonicalUUIDString();
+
+ RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:certificate->baseAddress() length:certificate->byteLength()]);
+ NSString* assetStr = keyID;
+ RetainPtr<NSData> assetID = [NSData dataWithBytes: [assetStr cStringUsingEncoding:NSUTF8StringEncoding] length:[assetStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
+ NSError* error = 0;
+ RetainPtr<NSData> keyRequest = [m_request.get() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:assetID.get() options:nil error:&error];
+
+ if (!keyRequest) {
+ NSError* underlyingError = [[error userInfo] objectForKey:NSUnderlyingErrorKey];
+ errorCode = CDM::DomainError;
+ systemCode = [underlyingError code];
+ return 0;
+ }
+
+ errorCode = 0;
+ systemCode = 0;
+ destinationURL = String();
+
+ RefPtr<ArrayBuffer> keyRequestBuffer = ArrayBuffer::create([keyRequest.get() bytes], [keyRequest.get() length]);
+ return Uint8Array::create(keyRequestBuffer, 0, keyRequestBuffer->byteLength());
+}
+
+void CDMSessionAVFoundation::releaseKeys()
+{
+}
+
+bool CDMSessionAVFoundation::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
+{
+ if (!key)
+ return false;
+
+ RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->baseAddress() length:key->byteLength()]);
+ [[m_request.get() dataRequest] respondWithData:keyData.get()];
+ [m_request.get() finishLoading];
+ errorCode = 0;
+ systemCode = 0;
+ nextMessage = nullptr;
+
+ return true;
+}
+
+}
+
+#endif
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (143258 => 143259)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-02-18 21:36:57 UTC (rev 143258)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-02-18 21:37:54 UTC (rev 143259)
@@ -6002,6 +6002,7 @@
CD27F6E51457685A0078207D /* JSMediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E2145767580078207D /* JSMediaController.cpp */; };
CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; };
CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */; };
+ CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */; };
CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; };
CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */; };
CD82030A1395AB6A00F956C6 /* WebVideoFullscreenController.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13611,6 +13612,8 @@
CD27F6E6145770D30078207D /* MediaController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaController.cpp; sourceTree = "<group>"; };
CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiagnosticLoggingKeys.cpp; sourceTree = "<group>"; };
CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingKeys.h; sourceTree = "<group>"; };
+ CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDMPrivateAVFoundation.h; path = Modules/encryptedmedia/CDMPrivateAVFoundation.h; sourceTree = "<group>"; };
+ CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMPrivateAVFoundation.mm; path = Modules/encryptedmedia/CDMPrivateAVFoundation.mm; sourceTree = "<group>"; };
CD4AC5281496AE2F0087C4EF /* Composite.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = Composite.wav; path = platform/audio/resources/Composite.wav; sourceTree = SOURCE_ROOT; };
CD4E0AFA11F7BC27009D3811 /* fullscreen.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = fullscreen.css; sourceTree = "<group>"; };
CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebCoreAVFResourceLoader.h; path = objc/WebCoreAVFResourceLoader.h; sourceTree = "<group>"; };
@@ -21712,6 +21715,9 @@
children = (
CDA98E091603CD5900FEA3B1 /* CDM.cpp */,
CDA98E0A1603CD5900FEA3B1 /* CDM.h */,
+ CDA98E0C1603CF3C00FEA3B1 /* CDMPrivate.h */,
+ CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */,
+ CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */,
CDA98DD516025BED00FEA3B1 /* MediaKeyMessageEvent.cpp */,
CDA98DD616025BED00FEA3B1 /* MediaKeyMessageEvent.h */,
CDA98DD716025BEE00FEA3B1 /* MediaKeyMessageEvent.idl */,
@@ -21724,7 +21730,6 @@
CDA98DC716014F2C00FEA3B1 /* MediaKeySession.cpp */,
CDA98DC816014F2C00FEA3B1 /* MediaKeySession.h */,
CDA98DC916014F4000FEA3B1 /* MediaKeySession.idl */,
- CDA98E0C1603CF3C00FEA3B1 /* Modules/encryptedmedia/CDMPrivate.h */,
);
name = encryptedmedia;
sourceTree = "<group>";
@@ -27488,6 +27493,7 @@
19BFF64C11C0F2AC00B8C04D /* DOMSVGFEConvolveMatrixElement.mm in Sources */,
8502AB490AD438C000378540 /* DOMSVGFEDiffuseLightingElement.mm in Sources */,
8502AB4B0AD438C000378540 /* DOMSVGFEDisplacementMapElement.mm in Sources */,
+ CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */,
8502AB4D0AD438C000378540 /* DOMSVGFEDistantLightElement.mm in Sources */,
4358E86B1360A21600E4748C /* DOMSVGFEDropShadowElement.mm in Sources */,
8502AB4F0AD438C000378540 /* DOMSVGFEFloodElement.mm in Sources */,
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (143258 => 143259)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2013-02-18 21:36:57 UTC (rev 143258)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2013-02-18 21:37:54 UTC (rev 143259)
@@ -74,6 +74,14 @@
void didCancelLoadingRequest(AVAssetResourceLoadingRequest*);
#endif
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+ static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate);
+#endif
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ static RetainPtr<AVAssetResourceLoadingRequest> takeRequestForPlayerAndKeyURI(MediaPlayer*, const String&);
+#endif
+
private:
MediaPlayerPrivateAVFoundationObjC(MediaPlayer*);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (143258 => 143259)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2013-02-18 21:36:57 UTC (rev 143258)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2013-02-18 21:37:54 UTC (rev 143259)
@@ -186,6 +186,16 @@
}
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+typedef HashMap<MediaPlayer*, MediaPlayerPrivateAVFoundationObjC*> PlayerToPrivateMapType;
+static PlayerToPrivateMapType& playerToPrivateMap()
+{
+ DEFINE_STATIC_LOCAL(PlayerToPrivateMapType, map, ());
+ return map;
+};
+#endif
+
+
PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationObjC::create(MediaPlayer* player)
{
return adoptPtr(new MediaPlayerPrivateAVFoundationObjC(player));
@@ -213,10 +223,16 @@
, m_currentTrack(0)
#endif
{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ playerToPrivateMap().set(player, this);
+#endif
}
MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC()
{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ playerToPrivateMap().remove(player());
+#endif
cancelLoad();
}
@@ -870,7 +886,7 @@
String scheme = [[[avRequest request] URL] scheme];
String keyURI = [[[avRequest request] URL] absoluteString];
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
if (scheme == "skd") {
// Create an initData with the following layout:
// [4 bytes: keyURI size], [keyURI size bytes: keyURI]
@@ -882,7 +898,12 @@
RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
keyURIArray->setRange(keyURI.characters(), keyURI.length() / sizeof(unsigned char), 0);
+#if ENABLE(ENCRYPTED_MEDIA)
if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
+#elif ENABLE(ENCRYPTED_MEDIA_V2)
+ RefPtr<Uint8Array> initData = Uint8Array::create(initDataBuffer, 0, initDataBuffer->byteLength());
+ if (!player()->keyNeeded(initData.get()))
+#endif
return false;
m_keyURIToRequestMap.set(keyURI, avRequest);
@@ -1116,9 +1137,8 @@
#endif
-#if ENABLE(ENCRYPTED_MEDIA)
-
-static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+bool MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
{
// initData should have the following layout:
// [4 bytes: keyURI length][N bytes: keyURI][4 bytes: contentID length], [N bytes: contentID], [4 bytes: certificate length][N bytes: certificate]
@@ -1167,7 +1187,9 @@
return true;
}
+#endif
+#if ENABLE(ENCRYPTED_MEDIA)
MediaPlayer::MediaKeyException MediaPlayerPrivateAVFoundationObjC::generateKeyRequest(const String& keySystem, const unsigned char* initDataPtr, unsigned initDataLength)
{
if (!keySystemIsSupported(keySystem))
@@ -1244,6 +1266,18 @@
}
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+RetainPtr<AVAssetResourceLoadingRequest> MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI(MediaPlayer* player, const String& keyURI)
+{
+ MediaPlayerPrivateAVFoundationObjC* _this = playerToPrivateMap().get(player);
+ if (!_this)
+ return nullptr;
+
+ return _this->m_keyURIToRequestMap.take(keyURI);
+
+}
+#endif
+
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
void MediaPlayerPrivateAVFoundationObjC::clearTextTracks()