Diff
Modified: trunk/Source/WebCore/ChangeLog (164528 => 164529)
--- trunk/Source/WebCore/ChangeLog 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/ChangeLog 2014-02-22 06:17:53 UTC (rev 164529)
@@ -1,3 +1,46 @@
+2014-02-21 Jer Noble <[email protected]>
+
+ [EME] Add a CDMSession for MediaPlayerPrivateMediaSourceAVFObjC
+ https://bugs.webkit.org/show_bug.cgi?id=129166
+
+ Reviewed by Eric Carlson.
+
+ Add a new CDMSession, cerated by MediaPlayerPrivateMediaSourceAVFObjC allowing
+ media-source-backed media elements to play protected content.
+
+ Add a new CDMSessionMediaSourceAVFObjC class:
+ * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h: Added.
+ (WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC):
+ * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm: Added.
+ (WebCore::CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC):
+ (WebCore::CDMSessionMediaSourceAVFObjC::generateKeyRequest): Do not actually generate a
+ key request until the certificate data has been added via update();
+ (WebCore::CDMSessionMediaSourceAVFObjC::releaseKeys): No-op.
+ (WebCore::CDMSessionMediaSourceAVFObjC::update): If no certificate data has yet been
+ added, assume the incoming message contains it.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Add supportsKeySystem.
+ (WebCore::keySystemIsSupported): Use "com.apple.fps.2_0" to distinguish from the not-media-source scheme.
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Check the keySystem type.
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsKeySystem): Added.
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createSession): Added, pass through to MediaSourcePrivate.
+ * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+ (WebCore::MediaSourcePrivateAVFObjC::createSession): Added.
+ (WebCore::MediaSourcePrivateAVFObjC::sourceBufferKeyNeeded): Pass through to MediaPlayer.
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+ (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]):
+ Added, pass through to SourceBufferPrivate.
+ (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
+ (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): Remember
+ which track is requesting the key, and pass the request to MediaSourcePrivate.
+
+ Add new files to the project.
+ * WebCore.xcodeproj/project.pbxproj:
+
2014-02-21 Alexey Proskuryakov <[email protected]>
CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify contains seemingly accidental unreachable code
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (164528 => 164529)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-22 06:17:53 UTC (rev 164529)
@@ -5541,6 +5541,7 @@
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 */; };
+ CDDE02F018B5651300CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDDE02EF18B5651200CF7FF1 /* CDMSessionMediaSourceAVFObjC.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 */; };
@@ -12809,6 +12810,8 @@
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>"; };
+ CDDE02EE18B564FA00CF7FF1 /* CDMSessionMediaSourceAVFObjC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CDMSessionMediaSourceAVFObjC.h; path = objc/CDMSessionMediaSourceAVFObjC.h; sourceTree = "<group>"; };
+ CDDE02EF18B5651200CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMSessionMediaSourceAVFObjC.mm; path = objc/CDMSessionMediaSourceAVFObjC.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>"; };
@@ -21012,6 +21015,8 @@
CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */,
CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */,
+ CDDE02EE18B564FA00CF7FF1 /* CDMSessionMediaSourceAVFObjC.h */,
+ CDDE02EF18B5651200CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm */,
07AA6B69166D019500D45671 /* InbandTextTrackPrivateAVFObjC.h */,
07AA6B6A166D019500D45671 /* InbandTextTrackPrivateAVFObjC.mm */,
07367DDD172CA67F00D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.h */,
@@ -29015,6 +29020,7 @@
511EF2C617F0FD3500E4FA16 /* JSIDBKeyRange.cpp in Sources */,
49C7B9D41042D32F0009D447 /* WebGLObject.cpp in Sources */,
51D719D8181106E00016DC51 /* IDBIndex.cpp in Sources */,
+ CDDE02F018B5651300CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm in Sources */,
49C7B9D61042D32F0009D447 /* WebGLProgram.cpp in Sources */,
49C7B9D91042D32F0009D447 /* WebGLRenderbuffer.cpp in Sources */,
49C7B9DF1042D32F0009D447 /* WebGLRenderingContext.cpp in Sources */,
Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h (0 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h 2014-02-22 06:17:53 UTC (rev 164529)
@@ -0,0 +1,62 @@
+/*
+ * 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 CDMSessionMediaSourceAVFObjC_h
+#define CDMSessionMediaSourceAVFObjC_h
+
+#include "CDMSession.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+namespace WebCore {
+
+class SourceBufferPrivateAVFObjC;
+
+class CDMSessionMediaSourceAVFObjC : public CDMSession {
+public:
+ CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent);
+ virtual ~CDMSessionMediaSourceAVFObjC() { }
+
+ 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:
+ SourceBufferPrivateAVFObjC* m_parent;
+ CDMSessionClient* m_client;
+ RefPtr<Uint8Array> m_initData;
+ RefPtr<Uint8Array> m_certificate;
+ String m_sessionId;
+};
+
+}
+
+#endif
+
+#endif // CDMSessionMediaSourceAVFObjC_h
Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (0 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm 2014-02-22 06:17:53 UTC (rev 164529)
@@ -0,0 +1,118 @@
+/*
+ * 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 "CDMSessionMediaSourceAVFObjC.h"
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+#import "CDM.h"
+#import "CDMSession.h"
+#import "ExceptionCode.h"
+#import "Logging.h"
+#import "MediaPlayer.h"
+#import "SourceBufferPrivateAVFObjC.h"
+#import "SoftLinking.h"
+#import "UUID.h"
+#import <CoreMedia/CMBase.h>
+#import <objc/objc-runtime.h>
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVStreamDataParser);
+#define AVAssetResourceLoadingRequest getAVStreamDataParser()
+
+@interface AVStreamDataParser : NSObject
+- (void)processContentKeyResponseData:(NSData *)contentKeyResponseData forTrackID:(CMPersistentTrackID)trackID;
+- (void)processContentKeyResponseError:(NSError *)error forTrackID:(CMPersistentTrackID)trackID;
+- (void)renewExpiringContentKeyResponseDataForTrackID:(CMPersistentTrackID)trackID;
+- (NSData *)streamingContentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier trackID:(CMPersistentTrackID)trackID options:(NSDictionary *)options error:(NSError **)outError;
+@end
+
+namespace WebCore {
+
+CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent)
+ : m_parent(parent)
+ , m_client(nullptr)
+ , m_sessionId(createCanonicalUUIDString())
+{
+}
+
+PassRefPtr<Uint8Array> CDMSessionMediaSourceAVFObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
+{
+ UNUSED_PARAM(mimeType);
+ UNUSED_PARAM(destinationURL);
+ ASSERT(initData);
+
+ LOG(Media, "CDMSessionMediaSourceAVFObjC::generateKeyRequest(%p)", this);
+
+ errorCode = MediaPlayer::NoError;
+ systemCode = 0;
+
+ m_initData = initData;
+ String certificateString(ASCIILiteral("certificate"));
+ return Uint8Array::create((uint8_t*)certificateString.getCharactersWithUpconvert<UChar>(), certificateString.length() * sizeof(UChar));
+}
+
+void CDMSessionMediaSourceAVFObjC::releaseKeys()
+{
+ LOG(Media, "CDMSessionMediaSourceAVFObjC::releaseKeys(%p)", this);
+}
+
+bool CDMSessionMediaSourceAVFObjC::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
+{
+ if (!m_certificate) {
+ LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - certificate data", this);
+
+ m_certificate = key;
+
+ RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
+ RetainPtr<NSData> initData = adoptNS([[NSData alloc] initWithBytes:m_initData->data() length:m_initData->length()]);
+
+ NSError* error = nil;
+ RetainPtr<NSData> request = adoptNS([m_parent->parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:m_parent->protectedTrackID() options:nil error:&error]);
+
+ if (error) {
+ LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - error:%@", this, [error description]);
+ errorCode = MediaPlayer::InvalidPlayerState;
+ systemCode = [error code];
+ return false;
+ }
+
+ nextMessage = Uint8Array::create([request length]);
+ [request getBytes:nextMessage->data() length:nextMessage->length()];
+ return false;
+ }
+
+ LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - key data", this);
+ errorCode = MediaPlayer::NoError;
+ systemCode = 0;
+ RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->data() length:key->length()]);
+ [m_parent->parser() processContentKeyResponseData:keyData.get() forTrackID:m_parent->protectedTrackID()];
+ return true;
+}
+
+}
+
+#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (164528 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2014-02-22 06:17:53 UTC (rev 164529)
@@ -73,6 +73,7 @@
void sizeChanged();
#if ENABLE(ENCRYPTED_MEDIA_V2)
+ virtual std::unique_ptr<CDMSession> createSession(const String&);
void keyNeeded(Uint8Array*);
#endif
@@ -159,6 +160,7 @@
static bool isAvailable();
static void getSupportedTypes(HashSet<String>& types);
static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
+ static bool supportsKeySystem(const String& keySystem, const String& mimeType);
friend class MediaSourcePrivateAVFObjC;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (164528 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2014-02-22 06:17:53 UTC (rev 164529)
@@ -28,6 +28,7 @@
#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+#import "CDMSession.h"
#import "MediaSourcePrivateAVFObjC.h"
#import "MediaSourcePrivateClient.h"
#import "MediaTimeMac.h"
@@ -165,7 +166,7 @@
void MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(MediaEngineRegistrar registrar)
{
if (isAvailable())
- registrar(create, getSupportedTypes, supportsType, 0, 0, 0, 0);
+ registrar(create, getSupportedTypes, supportsType, 0, 0, 0, supportsKeySystem);
}
PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateMediaSourceAVFObjC::create(MediaPlayer* player)
@@ -204,8 +205,20 @@
types = mimeTypeCache();
}
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+static bool keySystemIsSupported(const String& keySystem)
+{
+ return equalIgnoringCase(keySystem, "com.apple.fps.2_0");
+}
+#endif
+
MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(const MediaEngineSupportParameters& parameters)
{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ if (!parameters.keySystem.isEmpty() && !keySystemIsSupported(parameters.keySystem))
+ return MediaPlayer::IsNotSupported;
+#endif
+
// This engine does not support non-media-source sources.
if (!parameters.isMediaSource)
return MediaPlayer::IsNotSupported;
@@ -222,6 +235,25 @@
return [getAVURLAssetClass() isPlayableExtendedMIMEType:typeString] ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;;
}
+bool MediaPlayerPrivateMediaSourceAVFObjC::supportsKeySystem(const String& keySystem, const String& mimeType)
+{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ if (!keySystem.isEmpty()) {
+ if (!keySystemIsSupported(keySystem))
+ return false;
+
+ if (!mimeType.isEmpty() && !mimeTypeCache().contains(mimeType))
+ return false;
+
+ return true;
+ }
+#else
+ UNUSED_PARAM(keySystem);
+ UNUSED_PARAM(mimeType);
+#endif
+ return false;
+}
+
#pragma mark -
#pragma mark MediaPlayerPrivateInterface Overrides
@@ -535,6 +567,14 @@
}
#if ENABLE(ENCRYPTED_MEDIA_V2)
+std::unique_ptr<CDMSession> MediaPlayerPrivateMediaSourceAVFObjC::createSession(const String& keySystem)
+{
+ if (!m_mediaSourcePrivate)
+ return nullptr;
+
+ return m_mediaSourcePrivate->createSession(keySystem);
+}
+
void MediaPlayerPrivateMediaSourceAVFObjC::keyNeeded(Uint8Array* initData)
{
m_player->keyNeeded(initData);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h (164528 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h 2014-02-22 06:17:53 UTC (rev 164529)
@@ -29,6 +29,7 @@
#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
#include "MediaSourcePrivate.h"
+#include <wtf/Deque.h>
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
@@ -42,6 +43,7 @@
namespace WebCore {
+class CDMSession;
class MediaPlayerPrivateMediaSourceAVFObjC;
class SourceBufferPrivateAVFObjC;
class TimeRanges;
@@ -68,11 +70,18 @@
MediaTime seekToTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
IntSize naturalSize() const;
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ std::unique_ptr<CDMSession> createSession(const String&);
+#endif
+
private:
MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC*);
void sourceBufferPrivateDidChangeActiveState(SourceBufferPrivateAVFObjC*, bool active);
void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivateAVFObjC*);
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ void sourceBufferKeyNeeded(SourceBufferPrivateAVFObjC*, Uint8Array*);
+#endif
void monitorSourceBuffers();
void removeSourceBuffer(SourceBufferPrivate*);
@@ -82,6 +91,7 @@
double m_duration;
Vector<RefPtr<SourceBufferPrivateAVFObjC>> m_sourceBuffers;
Vector<SourceBufferPrivateAVFObjC*> m_activeSourceBuffers;
+ Deque<SourceBufferPrivateAVFObjC*> m_sourceBuffersNeedingSessions;
bool m_isEnded;
};
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm (164528 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm 2014-02-22 06:17:53 UTC (rev 164529)
@@ -28,6 +28,7 @@
#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+#import "CDMSessionMediaSourceAVFObjC.h"
#import "ContentType.h"
#import "ExceptionCodePlaceholder.h"
#import "MediaPlayerPrivateMediaSourceAVFObjC.h"
@@ -137,6 +138,26 @@
}
}
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+std::unique_ptr<CDMSession> MediaSourcePrivateAVFObjC::createSession(const String&)
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ if (m_sourceBuffersNeedingSessions.isEmpty())
+ return nullptr;
+ return std::make_unique<CDMSessionMediaSourceAVFObjC>(m_sourceBuffersNeedingSessions.takeFirst());
+#endif
+ return nullptr;
+}
+#endif
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+void MediaSourcePrivateAVFObjC::sourceBufferKeyNeeded(SourceBufferPrivateAVFObjC* buffer, Uint8Array* initData)
+{
+ m_sourceBuffersNeedingSessions.append(buffer);
+ player()->keyNeeded(initData);
+}
+#endif
+
static bool MediaSourcePrivateAVFObjCHasAudio(PassRefPtr<SourceBufferPrivateAVFObjC> prpSourceBuffer)
{
RefPtr<SourceBufferPrivateAVFObjC> sourceBuffer = prpSourceBuffer;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (164528 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2014-02-22 06:17:53 UTC (rev 164529)
@@ -42,6 +42,7 @@
OBJC_CLASS AVStreamDataParser;
OBJC_CLASS AVSampleBufferAudioRenderer;
OBJC_CLASS AVSampleBufferDisplayLayer;
+OBJC_CLASS NSData;
OBJC_CLASS NSError;
OBJC_CLASS NSObject;
typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
@@ -68,6 +69,7 @@
void didFailToParseStreamDataWithError(NSError*);
void didProvideMediaDataForTrackID(int trackID, CMSampleBufferRef, const String& mediaType, unsigned flags);
void didReachEndOfTrackWithTrackID(int trackID, const String& mediaType);
+ void didProvideContentKeyRequestInitializationDataForTrackID(NSData*, int trackID);
bool processCodedFrame(int trackID, CMSampleBufferRef, const String& mediaType);
@@ -81,6 +83,9 @@
MediaTime fastSeekTimeForMediaTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
IntSize naturalSize();
+ int protectedTrackID() const { return m_protectedTrackID; }
+ AVStreamDataParser* parser() const { return m_parser.get(); }
+
private:
explicit SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC*);
@@ -119,6 +124,7 @@
bool m_parsingSucceeded;
int m_enabledVideoTrackID;
+ int m_protectedTrackID;
};
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (164528 => 164529)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2014-02-22 06:17:53 UTC (rev 164529)
@@ -115,6 +115,10 @@
- (void)appendStreamData:(NSData *)data;
- (void)setShouldProvideMediaData:(BOOL)shouldProvideMediaData forTrackID:(CMPersistentTrackID)trackID;
- (BOOL)shouldProvideMediaDataForTrackID:(CMPersistentTrackID)trackID;
+- (void)processContentKeyResponseData:(NSData *)contentKeyResponseData forTrackID:(CMPersistentTrackID)trackID;
+- (void)processContentKeyResponseError:(NSError *)error forTrackID:(CMPersistentTrackID)trackID;
+- (void)renewExpiringContentKeyResponseDataForTrackID:(CMPersistentTrackID)trackID;
+- (NSData *)streamingContentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier trackID:(CMPersistentTrackID)trackID options:(NSDictionary *)options error:(NSError **)outError;
@end
#pragma mark -
@@ -218,6 +222,15 @@
ASSERT(streamDataParser == _parser);
_parent->didReachEndOfTrackWithTrackID(trackID, mediaType);
}
+
+- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didProvideContentKeyRequestInitializationData:(NSData *)initData forTrackID:(CMPersistentTrackID)trackID
+{
+#if ASSERT_DISABLED
+ UNUSED_PARAM(streamDataParser);
+#endif
+ ASSERT(streamDataParser == _parser);
+ _parent->didProvideContentKeyRequestInitializationDataForTrackID(initData, trackID);
+}
@end
namespace WebCore {
@@ -327,6 +340,7 @@
, m_client(0)
, m_parsingSucceeded(true)
, m_enabledVideoTrackID(-1)
+ , m_protectedTrackID(-1)
{
}
@@ -412,6 +426,20 @@
notImplemented();
}
+void SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(NSData* initData, int trackID)
+{
+ UNUSED_PARAM(trackID);
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ LOG(Media, "SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(%p) - track:%d", this, trackID);
+ m_protectedTrackID = trackID;
+ RefPtr<Uint8Array> initDataArray = Uint8Array::create([initData length]);
+ [initData getBytes:initDataArray->data() length:initDataArray->length()];
+ m_mediaSource->sourceBufferKeyNeeded(this, initDataArray.get());
+#else
+ UNUSED_PARAM(initData);
+#endif
+}
+
void SourceBufferPrivateAVFObjC::setClient(SourceBufferPrivateClient* client)
{
m_client = client;