2014-02-21 Jer Noble <jer.noble@apple.com>
+ Make a generic CDMPrivateMediaPlayer and move its CDMSession into platform/.
+ https://bugs.webkit.org/show_bug.cgi?id=129164
+
+ Reviewed by Eric Carlson.
+
+ Move the session created by CDMPrivateAVFoundation into platform, and rename
+ CDMPrivateAVFoundation to CDMPrivateMediaPlayer. Future media engines who want
+ to support a keysystem from within the media engine can create their own
+ CDMSession as part of the MediaPlayerPrivate interface.
+
+ * Modules/encryptedmedia/CDM.cpp:
+ (WebCore::installedCDMFactories):
+ (WebCore::CDM::createSession):
+ * Modules/encryptedmedia/CDM.h:
+ * Modules/encryptedmedia/CDMPrivate.h:
+ * Modules/encryptedmedia/MediaKeySession.cpp:
+ * Modules/encryptedmedia/MediaKeySession.h:
+ * Modules/encryptedmedia/CDMPrivateAVFoundation.mm: Removed.
+ * Modules/encryptedmedia/CDMPrivateMediaPlayer.cpp: Renamed from Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.cpp.
+ (WebCore::CDMPrivateMediaPlayer::supportsKeySystem):
+ (WebCore::CDMPrivateMediaPlayer::supportsKeySystemAndMimeType):
+ (WebCore::CDMPrivateMediaPlayer::supportsMIMEType):
+ (WebCore::CDMPrivateMediaPlayer::createSession):
+ * Modules/encryptedmedia/CDMPrivateMediaPlayer.h: Renamed from Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.h.
+ (WebCore::CDMPrivateMediaPlayer::create):
+ (WebCore::CDMPrivateMediaPlayer::~CDMPrivateMediaPlayer):
+ (WebCore::CDMPrivateMediaPlayer::cdm):
+ (WebCore::CDMPrivateMediaPlayer::CDMPrivateMediaPlayer):
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/CDMSession.h: Extracted from CDMPrivateAVFoundation.h.
+ (WebCore::CDMSessionClient::~CDMSessionClient):
+ (WebCore::CDMSession::CDMSession):
+ (WebCore::CDMSession::~CDMSession):
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::createSession):
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/MediaPlayerPrivate.h:
+ (WebCore::MediaPlayerPrivateInterface::createSession):
+ * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h: Renamed from Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.h.
+ (WebCore::CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC):
+ * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: Renamed from Source/WebCore/Modules/encryptedmedia/CDMPrivateAVFoundation.mm.
+ (WebCore::CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC):
+ (WebCore::CDMSessionAVFoundationObjC::generateKeyRequest):
+ (WebCore::CDMSessionAVFoundationObjC::releaseKeys):
+ (WebCore::CDMSessionAVFoundationObjC::update):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createSession):
+ * testing/MockCDM.cpp:
+ (WebCore::MockCDMSession::setClient):
+ (WebCore::MockCDM::createSession):
+ * testing/MockCDM.h:
+
+2014-02-21 Jer Noble <jer.noble@apple.com>
+
Add a supportsKeySystem media engine factory parameter.
https://bugs.webkit.org/show_bug.cgi?id=129161
#include "CDM.h"
-#include "CDMPrivate.h"
+#include "CDMPrivateMediaPlayer.h"
+#include "CDMSession.h"
#include "MediaKeyError.h"
#include "MediaKeys.h"
#include <wtf/text/WTFString.h>
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-#include "CDMPrivateAVFoundation.h"
-#endif
-
namespace WebCore {
struct CDMFactory {
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::supportsKeySystem, CDMPrivateAVFoundation::supportsKeySystemAndMimeType));
-#endif
-
+ cdms.append(new CDMFactory(CDMPrivateMediaPlayer::create, CDMPrivateMediaPlayer::supportsKeySystem, CDMPrivateMediaPlayer::supportsKeySystemAndMimeType));
}
return cdms;
return m_private->supportsMIMEType(mimeType);
}
-PassOwnPtr<CDMSession> CDM::createSession()
+std::unique_ptr<CDMSession> CDM::createSession()
{
return m_private->createSession();
}
#if ENABLE(ENCRYPTED_MEDIA_V2)
+#include "CDMSession.h"
#include <runtime/Uint8Array.h>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
class CDM;
class CDMPrivateInterface;
-class CDMSession;
class MediaPlayer;
typedef PassOwnPtr<CDMPrivateInterface> (*CreateCDM)(CDM*);
virtual MediaPlayer* cdmMediaPlayer(const CDM*) const = 0;
};
-class CDMSession {
-public:
- CDMSession() { }
- virtual ~CDMSession() { }
-
- virtual const String& sessionId() const = 0;
- virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) = 0;
- virtual void releaseKeys() = 0;
- virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) = 0;
-};
-
class CDM {
public:
~CDM();
bool supportsMIMEType(const String&) const;
- PassOwnPtr<CDMSession> createSession();
+ std::unique_ptr<CDMSession> createSession();
const String& keySystem() const { return m_keySystem; }
virtual bool supportsMIMEType(const String&) = 0;
- virtual PassOwnPtr<CDMSession> createSession() = 0;
+ virtual std::unique_ptr<CDMSession> createSession() = 0;
};
}
+++ /dev/null
-/*
- * 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>
-
-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::supportsKeySystem(const String& keySystem)
-{
- return equalIgnoringCase(keySystem, "com.apple.fps") || equalIgnoringCase(keySystem, "com.apple.fps.1_0");
-}
-
-bool CDMPrivateAVFoundation::supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType)
-{
- if (!supportsKeySystem(keySystem))
- return false;
- return [AVURLAsset isPlayableExtendedMIMEType:mimeType];
-}
-
-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())
-{
-}
-
-static unsigned short MediaKeyExceptionToErrorCode(MediaPlayer::MediaKeyException error)
-{
- switch (error) {
- case MediaPlayer::NoError:
- return 0;
- case MediaPlayer::InvalidPlayerState:
- return INVALID_STATE_ERR;
- case MediaPlayer::KeySystemNotSupported:
- return NOT_SUPPORTED_ERR;
- default:
- ASSERT_NOT_REACHED();
- return 0;
- }
-}
-
-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 nullptr;
- }
-
- m_sessionId = createCanonicalUUIDString();
-
- MediaPlayer::MediaKeyException error;
- RefPtr<Uint8Array> request = mediaPlayer->generateKeyRequest(m_sessionId, mimeType, initData, destinationURL, error, systemCode);
- errorCode = MediaKeyExceptionToErrorCode(error);
- return request;
-}
-
-void CDMSessionAVFoundation::releaseKeys()
-{
- MediaPlayer* mediaPlayer = m_parent->cdm()->mediaPlayer();
- if (!mediaPlayer)
- return;
-
- mediaPlayer->releaseKeys(m_sessionId);
-}
-
-bool CDMSessionAVFoundation::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
-{
- if (!key)
- return false;
-
- MediaPlayer* mediaPlayer = m_parent->cdm()->mediaPlayer();
- if (!mediaPlayer) {
- errorCode = NOT_SUPPORTED_ERR;
- return nullptr;
- }
-
- MediaPlayer::MediaKeyException error;
- bool succeeded = mediaPlayer->update(m_sessionId, key, nextMessage, error, systemCode);
- errorCode = MediaKeyExceptionToErrorCode(error);
- return succeeded;
-}
-
-}
-
-#endif
--- /dev/null
+/*
+ * Copyright (C) 2014 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 "CDMPrivateMediaPlayer.h"
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+
+#import "CDM.h"
+#import "CDMSession.h"
+#import "ContentType.h"
+#import "ExceptionCode.h"
+#import "MediaPlayer.h"
+#import "SoftLinking.h"
+
+namespace WebCore {
+
+bool CDMPrivateMediaPlayer::supportsKeySystem(const String& keySystem)
+{
+ return MediaPlayer::supportsKeySystem(keySystem, emptyString());
+}
+
+bool CDMPrivateMediaPlayer::supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType)
+{
+ return MediaPlayer::supportsKeySystem(keySystem, mimeType);
+}
+
+bool CDMPrivateMediaPlayer::supportsMIMEType(const String& mimeType)
+{
+ return MediaPlayer::supportsKeySystem(m_cdm->keySystem(), mimeType);
+}
+
+std::unique_ptr<CDMSession> CDMPrivateMediaPlayer::createSession()
+{
+ MediaPlayer* mediaPlayer = m_cdm->mediaPlayer();
+ if (!mediaPlayer)
+ return nullptr;
+
+ return mediaPlayer->createSession(m_cdm->keySystem());
+}
+
+}
+
+#endif
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef CDMPrivateAVFoundation_h
-#define CDMPrivateAVFoundation_h
+#ifndef CDMPrivateMediaPlayer_h
+#define CDMPrivateMediaPlayer_h
#include "CDMPrivate.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/RetainPtr.h>
-#if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if ENABLE(ENCRYPTED_MEDIA_V2)
namespace WebCore {
class CDM;
-class CDMPrivateAVFoundation : public CDMPrivateInterface {
+class CDMPrivateMediaPlayer : public CDMPrivateInterface {
public:
- // CDMFactory support:
- static PassOwnPtr<CDMPrivateInterface> create(CDM* cdm) { return adoptPtr(new CDMPrivateAVFoundation(cdm)); }
+ static PassOwnPtr<CDMPrivateInterface> create(CDM* cdm) { return adoptPtr(new CDMPrivateMediaPlayer(cdm)); }
static bool supportsKeySystem(const String&);
static bool supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType);
- virtual ~CDMPrivateAVFoundation() { }
+ virtual ~CDMPrivateMediaPlayer() { }
virtual bool supportsMIMEType(const String& mimeType) override;
- virtual PassOwnPtr<CDMSession> createSession() override;
+ virtual std::unique_ptr<CDMSession> createSession() override;
CDM* cdm() const { return m_cdm; }
protected:
- CDMPrivateAVFoundation(CDM* cdm) : m_cdm(cdm) { }
+ CDMPrivateMediaPlayer(CDM* cdm) : m_cdm(cdm) { }
CDM* m_cdm;
};
#endif
-#endif // CDMPrivateAVFoundation_h
+#endif // CDMPriavateMediaPlayer_h
#if ENABLE(ENCRYPTED_MEDIA_V2)
#include "CDM.h"
+#include "CDMSession.h"
#include "Event.h"
#include "GenericEventQueue.h"
#include "MediaKeyError.h"
String m_sessionId;
RefPtr<MediaKeyError> m_error;
GenericEventQueue m_asyncEventQueue;
- OwnPtr<CDMSession> m_session;
+ std::unique_ptr<CDMSession> m_session;
struct PendingKeyRequest {
PendingKeyRequest(const String& mimeType, Uint8Array* initData) : mimeType(mimeType), initData(initData) { }
CD3E251C18046B0600E27F56 /* GridCoordinate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD3E251B18046B0600E27F56 /* GridCoordinate.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD3E252318046BCD00E27F56 /* CSSGridTemplateAreasValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3E252118046BCD00E27F56 /* CSSGridTemplateAreasValue.cpp */; };
CD3E252418046BCD00E27F56 /* CSSGridTemplateAreasValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD3E252218046BCD00E27F56 /* CSSGridTemplateAreasValue.h */; };
- CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */; };
CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; };
CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */; };
CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5393D2175E018600C07123 /* JSMemoryInfo.h */; };
CDC8B5AB18047FF10016E685 /* SourceBufferPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */; };
CDC8B5AD1804AE5D0016E685 /* SourceBufferPrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */; };
CDCA82961679100F00875714 /* TextTrackRepresentationIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCA82941679100F00875714 /* TextTrackRepresentationIOS.mm */; };
+ CDCA98EB18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDCA98EA18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp */; };
CDD525D7145B6DD0008D204D /* JSHTMLMediaElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDF65CCC145B6AFE00C4C7AA /* JSHTMLMediaElementCustom.cpp */; };
CDD7089618359F6F002B3DC6 /* SampleMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDD7089418359F6E002B3DC6 /* SampleMap.cpp */; };
CDD7089718359F6F002B3DC6 /* SampleMap.h in Headers */ = {isa = PBXBuildFile; fileRef = CDD7089518359F6F002B3DC6 /* SampleMap.h */; };
CDDC1E7A18A952F30027A9D4 /* MediaSourcePrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CDDC1E7918A952F30027A9D4 /* MediaSourcePrivateClient.h */; };
+ CDDD571518B57A8200A94FCB /* CDMSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CDDE02E918B3DFC700CF7FF1 /* CDMSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ CDDE02ED18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */; };
CDE3A85417F5FCE600C5BE20 /* AudioTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE3A85217F5FCE600C5BE20 /* AudioTrackPrivateAVF.h */; };
CDE3A85717F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */; };
CDE3A85817F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */; };
CD3E251B18046B0600E27F56 /* GridCoordinate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridCoordinate.h; path = style/GridCoordinate.h; sourceTree = "<group>"; };
CD3E252118046BCD00E27F56 /* CSSGridTemplateAreasValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSGridTemplateAreasValue.cpp; sourceTree = "<group>"; };
CD3E252218046BCD00E27F56 /* CSSGridTemplateAreasValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGridTemplateAreasValue.h; sourceTree = "<group>"; };
- CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMPrivateAVFoundation.h; sourceTree = "<group>"; };
- CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = 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>"; };
CD5393CB175DCCE600C07123 /* MemoryInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInfo.h; sourceTree = "<group>"; };
CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceBufferPrivateAVFObjC.h; path = objc/SourceBufferPrivateAVFObjC.h; sourceTree = "<group>"; };
CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivateClient.h; sourceTree = "<group>"; };
CDCA82941679100F00875714 /* TextTrackRepresentationIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextTrackRepresentationIOS.mm; sourceTree = "<group>"; };
+ CDCA98E918B2C8D000C12FF9 /* CDMPrivateMediaPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMPrivateMediaPlayer.h; sourceTree = "<group>"; };
+ CDCA98EA18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CDMPrivateMediaPlayer.cpp; sourceTree = "<group>"; };
CDCE5CD014633BC900D47CCA /* EventTargetFactory.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventTargetFactory.in; sourceTree = "<group>"; };
CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackRepresentation.h; sourceTree = "<group>"; };
CDD7089418359F6E002B3DC6 /* SampleMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SampleMap.cpp; sourceTree = "<group>"; };
CDD7089518359F6F002B3DC6 /* SampleMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleMap.h; sourceTree = "<group>"; };
CDDC1E7918A952F30027A9D4 /* MediaSourcePrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivateClient.h; sourceTree = "<group>"; };
+ CDDE02E918B3DFC700CF7FF1 /* CDMSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDMSession.h; sourceTree = "<group>"; };
+ CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDMSessionAVFoundationObjC.h; path = objc/CDMSessionAVFoundationObjC.h; sourceTree = "<group>"; };
+ CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMSessionAVFoundationObjC.mm; path = objc/CDMSessionAVFoundationObjC.mm; sourceTree = "<group>"; };
CDE3A85217F5FCE600C5BE20 /* AudioTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioTrackPrivateAVF.h; sourceTree = "<group>"; };
CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AudioTrackPrivateAVFObjC.mm; path = objc/AudioTrackPrivateAVFObjC.mm; sourceTree = "<group>"; };
CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioTrackPrivateAVFObjC.h; path = objc/AudioTrackPrivateAVFObjC.h; sourceTree = "<group>"; };
BEF29EE91715DD0900C4B4C9 /* AudioTrackPrivate.h */,
A89943270B42338700D7C802 /* BitmapImage.cpp */,
A89943260B42338700D7C802 /* BitmapImage.h */,
+ CDDE02E918B3DFC700CF7FF1 /* CDMSession.h */,
B27535380B053814002CE64F /* Color.cpp */,
B27535390B053814002CE64F /* Color.h */,
9382DF5710A8D5C900925652 /* ColorSpace.h */,
CDA98E091603CD5900FEA3B1 /* CDM.cpp */,
CDA98E0A1603CD5900FEA3B1 /* CDM.h */,
CDA98E0C1603CF3C00FEA3B1 /* CDMPrivate.h */,
- CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */,
- CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */,
+ CDCA98E918B2C8D000C12FF9 /* CDMPrivateMediaPlayer.h */,
+ CDCA98EA18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp */,
CDA98DD516025BED00FEA3B1 /* MediaKeyMessageEvent.cpp */,
CDA98DD616025BED00FEA3B1 /* MediaKeyMessageEvent.h */,
CDA98DD716025BEE00FEA3B1 /* MediaKeyMessageEvent.idl */,
CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */,
CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */,
CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
+ CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */,
+ CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */,
07AA6B69166D019500D45671 /* InbandTextTrackPrivateAVFObjC.h */,
07AA6B6A166D019500D45671 /* InbandTextTrackPrivateAVFObjC.mm */,
07367DDD172CA67F00D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.h */,
1ABA80001897341200DCE9D6 /* VisitedLinkProvider.h in Headers */,
2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */,
E1C36C030EB076D6007410BC /* JSDOMGlobalObject.h in Headers */,
+ CDDD571518B57A8200A94FCB /* CDMSession.h in Headers */,
65DF31F809D1CC60000BE325 /* JSDOMImplementation.h in Headers */,
A9D248070D757E7D00FDF959 /* JSDOMMimeType.h in Headers */,
A9D248090D757E7D00FDF959 /* JSDOMMimeTypeArray.h in Headers */,
6550B69D099DF0270090D781 /* CDATASection.cpp in Sources */,
078E090917D14CEE00420AA1 /* RTCIceCandidate.cpp in Sources */,
CDA98E0B1603CD6000FEA3B1 /* CDM.cpp in Sources */,
- CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */,
990A1A0418ADA48400183FD1 /* ReplayInputTypes.cpp in Sources */,
E1A8E56617552B2A007488E7 /* CFURLExtras.cpp in Sources */,
97BC69DC1505F076001B74AC /* ChangeVersionWrapper.cpp in Sources */,
977B3866122883E900B81FF8 /* HTMLDocumentParser.cpp in Sources */,
93309DE7099E64920056E581 /* htmlediting.cpp in Sources */,
A516E8B8136E04DB0076C3C0 /* LocalizedDateCache.mm in Sources */,
+ CDDE02ED18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm in Sources */,
93F19A9208245E59001E9ABC /* HTMLElement.cpp in Sources */,
E157A8F018185425009F821D /* JSCryptoAlgorithmBuilder.cpp in Sources */,
A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */,
B27B28270CEF0C0700D39D54 /* JSSVGGlyphElement.cpp in Sources */,
070363E1181A1CDC00C074A5 /* AVAudioCaptureSource.mm in Sources */,
24D9129813CA96DE00D21915 /* JSSVGGlyphRefElement.cpp in Sources */,
+ CDCA98EB18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp in Sources */,
B2FA3D9C0AB75A6F000E5AC4 /* JSSVGGradientElement.cpp in Sources */,
85174EC2BCCAF17EAE3F46F8 /* JSSVGGraphicsElement.cpp in Sources */,
8485227B1190162C006EDC7F /* JSSVGHKernElement.cpp in Sources */,
--- /dev/null
+/*
+ * Copyright (C) 2014 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 CDMSession_h
+#define CDMSession_h
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+
+#include <runtime/Uint8Array.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class CDMSessionClient {
+public:
+ virtual ~CDMSessionClient() { };
+ virtual void sendMessage(Uint8Array*, String destinationURL) = 0;
+};
+
+class CDMSession {
+public:
+ CDMSession() { }
+ virtual ~CDMSession() { }
+
+ virtual void setClient(CDMSessionClient*) = 0;
+ virtual const String& sessionId() const = 0;
+ virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) = 0;
+ virtual void releaseKeys() = 0;
+ virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) = 0;
+};
+
+}
+
+#endif // ENABLE(ENCRYPTED_MEDIA_V2)
+
+#endif // CDMSession_h
#endif
#if ENABLE(ENCRYPTED_MEDIA_V2)
-PassRefPtr<Uint8Array> MediaPlayer::generateKeyRequest(const String& sessionID, const String& mimeType, Uint8Array* initData, String& destinationURL, MediaKeyException& error, unsigned long& systemCode)
+std::unique_ptr<CDMSession> MediaPlayer::createSession(const String& keySystem)
{
- return m_private->generateKeyRequest(sessionID, mimeType, initData, destinationURL, error, systemCode);
-}
-
-void MediaPlayer::releaseKeys(const String& sessionID)
-{
- m_private->releaseKeys(sessionID);
-}
-
-bool MediaPlayer::update(const String& sessionID, Uint8Array* key, RefPtr<Uint8Array>& nextMessage, MediaKeyException& error, unsigned long& systemCode)
-{
- return m_private->update(sessionID, key, nextMessage, error, systemCode);
+ return m_private->createSession(keySystem);
}
#endif
#endif
#include "AudioTrackPrivate.h"
+#include "CDMSession.h"
#include "InbandTextTrackPrivate.h"
#include "IntRect.h"
#include "URL.h"
#endif
#if ENABLE(ENCRYPTED_MEDIA_V2)
- PassRefPtr<Uint8Array> generateKeyRequest(const String& sessionID, const String& mimeType, Uint8Array* initData, String& destinationURL, MediaKeyException& error, unsigned long& systemCode);
- void releaseKeys(const String& sessionID);
- bool update(const String& sessionID, Uint8Array* key, RefPtr<Uint8Array>& nextMessage, MediaKeyException& error, unsigned long& systemCode);
+ std::unique_ptr<CDMSession> createSession(const String& keySystem);
#endif
bool paused() const;
#endif
#if ENABLE(ENCRYPTED_MEDIA_V2)
- virtual PassRefPtr<Uint8Array> generateKeyRequest(const String&, const String&, Uint8Array*, String&, MediaPlayer::MediaKeyException&, unsigned long&) { return nullptr; }
- virtual void releaseKeys(const String&) { }
- virtual bool update(const String&, Uint8Array*, RefPtr<Uint8Array>&, MediaPlayer::MediaKeyException&, unsigned long&) { return false; }
+ virtual std::unique_ptr<CDMSession> createSession(const String&) { return nullptr; }
#endif
#if ENABLE(VIDEO_TRACK)
--- /dev/null
+/*
+ * Copyright (C) 2014 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 CDMSessionAVFoundationObjC_h
+#define CDMSessionAVFoundationObjC_h
+
+#include "CDMSession.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+OBJC_CLASS AVAssetResourceLoadingRequest;
+
+namespace WebCore {
+
+class MediaPlayerPrivateAVFoundationObjC;
+
+class CDMSessionAVFoundationObjC : public CDMSession {
+public:
+ CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent);
+ virtual ~CDMSessionAVFoundationObjC() { }
+
+ virtual void setClient(CDMSessionClient* client) override { m_client = client; }
+ 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:
+ MediaPlayerPrivateAVFoundationObjC* m_parent;
+ CDMSessionClient* m_client;
+ String m_sessionId;
+ RetainPtr<AVAssetResourceLoadingRequest> m_request;
+};
+
+}
+
+#endif
+
+#endif // CDMSessionAVFoundationObjC_h
--- /dev/null
+/*
+ * Copyright (C) 2014 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 "CDMSessionAVFoundationObjC.h"
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+#import "CDM.h"
+#import "CDMSession.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>
+
+namespace WebCore {
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVURLAsset)
+SOFT_LINK_CLASS(AVFoundation, AVAssetResourceLoadingRequest)
+#define AVURLAsset getAVURLAssetClass()
+#define AVAssetResourceLoadingRequest getAVAssetResourceLoadingRequest()
+
+CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent)
+ : m_parent(parent)
+ , m_client(nullptr)
+ , m_sessionId(createCanonicalUUIDString())
+{
+}
+
+PassRefPtr<Uint8Array> CDMSessionAVFoundationObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
+{
+ UNUSED_PARAM(mimeType);
+
+ String keyURI;
+ String keyID;
+ RefPtr<Uint8Array> certificate;
+ if (!MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(initData, keyURI, keyID, certificate)) {
+ errorCode = MediaPlayer::InvalidPlayerState;
+ return nullptr;
+ }
+
+ m_request = m_parent->takeRequestForKeyURI(keyURI);
+ if (!m_request) {
+ errorCode = MediaPlayer::InvalidPlayerState;
+ return nullptr;
+ }
+
+ 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* nsError = 0;
+ RetainPtr<NSData> keyRequest = [m_request streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:assetID.get() options:nil error:&nsError];
+
+ if (!keyRequest) {
+ NSError* underlyingError = [[nsError userInfo] objectForKey:NSUnderlyingErrorKey];
+ systemCode = [underlyingError code];
+ return nullptr;
+ }
+
+ errorCode = MediaPlayer::NoError;
+ systemCode = 0;
+ destinationURL = String();
+
+ RefPtr<ArrayBuffer> keyRequestBuffer = ArrayBuffer::create([keyRequest.get() bytes], [keyRequest.get() length]);
+ return Uint8Array::create(keyRequestBuffer, 0, keyRequestBuffer->byteLength());
+}
+
+void CDMSessionAVFoundationObjC::releaseKeys()
+{
+}
+
+bool CDMSessionAVFoundationObjC::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
+{
+ RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->baseAddress() length:key->byteLength()]);
+ [[m_request dataRequest] respondWithData:keyData.get()];
+ [m_request finishLoading];
+ errorCode = MediaPlayer::NoError;
+ systemCode = 0;
+ nextMessage = nullptr;
+
+ return true;
+}
+
+}
+
+#endif
#endif
#if ENABLE(ENCRYPTED_MEDIA_V2)
- static RetainPtr<AVAssetResourceLoadingRequest> takeRequestForPlayerAndKeyURI(MediaPlayer*, const String&);
+ RetainPtr<AVAssetResourceLoadingRequest> takeRequestForKeyURI(const String&);
#endif
void playerItemStatusDidChange(int);
#endif
#if ENABLE(ENCRYPTED_MEDIA_V2)
- PassRefPtr<Uint8Array> generateKeyRequest(const String& sessionId, const String& mimeType, Uint8Array* initData, String& destinationURL, MediaPlayer::MediaKeyException& error, unsigned long& systemCode);
- void releaseKeys(const String& sessionId);
- bool update(const String& sessionId, Uint8Array* key, RefPtr<Uint8Array>& nextMessage, MediaPlayer::MediaKeyException& error, unsigned long& systemCode);
+ std::unique_ptr<CDMSession> createSession(const String& keySystem);
#endif
virtual String languageOfPrimaryAudioTrack() const override;
#import "AudioTrackPrivateAVFObjC.h"
#import "AuthenticationChallenge.h"
#import "BlockExceptions.h"
+#import "CDMSessionAVFoundationObjC.h"
#import "ExceptionCodePlaceholder.h"
#import "FloatConversion.h"
#import "FloatConversion.h"
#endif
#if ENABLE(ENCRYPTED_MEDIA_V2)
-PassRefPtr<Uint8Array> MediaPlayerPrivateAVFoundationObjC::generateKeyRequest(const String& sessionId, const String& mimeType, Uint8Array* initData, String& destinationURL, MediaPlayer::MediaKeyException& error, unsigned long& systemCode)
+RetainPtr<AVAssetResourceLoadingRequest> MediaPlayerPrivateAVFoundationObjC::takeRequestForKeyURI(const String& keyURI)
{
- UNUSED_PARAM(mimeType);
-
- String keyURI;
- String keyID;
- RefPtr<Uint8Array> certificate;
- if (!MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(initData, keyURI, keyID, certificate)) {
- error = MediaPlayer::InvalidPlayerState;
- return 0;
- }
-
- RetainPtr<AVAssetResourceLoadingRequest> request = m_keyURIToRequestMap.take(keyURI);
- if (!request) {
- error = MediaPlayer::InvalidPlayerState;
- return 0;
- }
-
- m_sessionIDToRequestMap.add(sessionId, request);
-
- 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* nsError = 0;
- RetainPtr<NSData> keyRequest = [request streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:assetID.get() options:nil error:&nsError];
-
- if (!keyRequest) {
- NSError* underlyingError = [[nsError userInfo] objectForKey:NSUnderlyingErrorKey];
- systemCode = [underlyingError code];
- return 0;
- }
-
- error = MediaPlayer::NoError;
- systemCode = 0;
- destinationURL = String();
-
- RefPtr<ArrayBuffer> keyRequestBuffer = ArrayBuffer::create([keyRequest.get() bytes], [keyRequest.get() length]);
- return Uint8Array::create(keyRequestBuffer, 0, keyRequestBuffer->byteLength());
+ return m_keyURIToRequestMap.take(keyURI);
}
-void MediaPlayerPrivateAVFoundationObjC::releaseKeys(const String& sessionId)
+std::unique_ptr<CDMSession> MediaPlayerPrivateAVFoundationObjC::createSession(const String& keySystem)
{
- UNUSED_PARAM(sessionId);
-}
-
-bool MediaPlayerPrivateAVFoundationObjC::update(const String& sessionId, Uint8Array* key, RefPtr<Uint8Array>& nextMessage, MediaPlayer::MediaKeyException& error, unsigned long& systemCode)
-{
- ASSERT(key);
-
- RetainPtr<AVAssetResourceLoadingRequest> request = m_sessionIDToRequestMap.get(sessionId);
- if (!request) {
- error = MediaPlayer::InvalidPlayerState;
- return false;
- }
-
- RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->baseAddress() length:key->byteLength()]);
- [[request dataRequest] respondWithData:keyData.get()];
- [request finishLoading];
- error = MediaPlayer::NoError;
- systemCode = 0;
- nextMessage = nullptr;
+ if (!keySystemIsSupported(keySystem))
+ return nullptr;
- return true;
+ return std::make_unique<CDMSessionAVFoundationObjC>(this);
}
#endif
#if ENABLE(ENCRYPTED_MEDIA_V2)
#include "CDM.h"
+#include "CDMSession.h"
#include "MediaKeyError.h"
#include <runtime/JSCInlines.h>
#include <runtime/TypedArrayInlines.h>
class MockCDMSession : public CDMSession {
public:
- static PassOwnPtr<MockCDMSession> create() { return adoptPtr(new MockCDMSession()); }
+ MockCDMSession();
virtual ~MockCDMSession() { }
+ virtual void setClient(CDMSessionClient* client) { m_client = client; }
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:
- MockCDMSession();
-
+ CDMSessionClient* m_client;
String m_sessionId;
};
return equalIgnoringCase(mimeType, "video/mock");
}
-PassOwnPtr<CDMSession> MockCDM::createSession()
+std::unique_ptr<CDMSession> MockCDM::createSession()
{
- return MockCDMSession::create();
+ return std::make_unique<MockCDMSession>();
}
static Uint8Array* initDataPrefix()
virtual ~MockCDM() { }
virtual bool supportsMIMEType(const String& mimeType) override;
- virtual PassOwnPtr<CDMSession> createSession() override;
+ virtual std::unique_ptr<CDMSession> createSession() override;
protected:
MockCDM(CDM* cdm) : m_cdm(cdm) { }