[EME][Mac] Refactor CDMPrivateMediaSourceAVFObjC to allow sessions to be created...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Sep 2014 01:28:33 +0000 (01:28 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Sep 2014 01:28:33 +0000 (01:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136016

Reviewed by Eric Carlson.

The CDMPrivateMediaPlayer class will delegate creation of CDMSession instances to the current MediaPlayer. This
of course requires the MediaKeys object owning the CDM to be attached to a HTMLMediaElement, and specifically to
one with a valid src attribute or source node which has sucessfully begun loading. For certain CDM operations,
it would be better if a given MediaKeys could create a session without actually being connected to a
HTMLMediaElement (yet).

To facilitate this for CDMSessionPrivateMediaSourceAVFObjC, add a new class, CDMPrivateMediaSourceAVFObjC, which
is the primary factory for CDMSessionPrivateMediaSOurceAVFObjC. Disclaim responsibility for creating these sessions
in MediaPlayerPrivateMediaSourceAVFObjC by not passing the "supportsKeySystem" method when registering itself.

Add methods to CDMSessionPrivateMediaSourceAVFObjC to allow SourceBuffers to be added and removed from the session,
to support adding the session to the HTMLMediaElement after the session has been created.

Since MediaPlayerPrivate instance and  CDMSession instances must be able to communicate with one another, add a type()
enum and virtual method to allow CDMSession instnaces to be distinguisted from (and casted to) one another.

* Modules/encryptedmedia/CDM.cpp:
(WebCore::installedCDMFactories): Register CDMPrivateMediaSourceAVFObjC.
(WebCore::CDM::createSession): Notify the MediaPlayer of the new CDMSession.
* Modules/encryptedmedia/MediaKeySession.h:
* Modules/encryptedmedia/MediaKeys.cpp:
(WebCore::MediaKeys::setMediaElement): Notify the HTMLMediaElement of any existing sessions.
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/CDMSession.h:
(WebCore::CDMSession::type): Added.
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::setCDMSession): Pass through to the MediaPlayerPrivate.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setCDMSession): Added. Default no-op.
* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h: Added.
(WebCore::CDMPrivateMediaSourceAVFObjC::CDMPrivateMediaSourceAVFObjC): Simple constructor.
(WebCore::CDMPrivateMediaSourceAVFObjC::~CDMPrivateMediaSourceAVFObjC): Simple destructor.
(WebCore::CDMPrivateMediaSourceAVFObjC::create): Simple factory.
(WebCore::CDMPrivateMediaSourceAVFObjC::cdm): Simple accessor.
* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
(WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystem): Moved from MediaPlayerPrivateMediaSourceAVFObjC.
(WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType): Ditto.
(WebCore::CDMPrivateMediaSourceAVFObjC::supportsMIMEType): Ditto.
(WebCore::CDMPrivateMediaSourceAVFObjC::createSession): Returns new CDMSessionMediaSourceAVFObjC.
* platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h:
(WebCore::CDMSessionAVFoundationObjC::type): Added.
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h:
(WebCore::CDMSessionMediaSourceAVFObjC::type): Added.
(WebCore::toCDMSessionMediaSourceAVFObjC): Throw assertion if type() is not correct.
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
(WebCore::CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC): Removed m_parent ivar.
(WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC): Ditto.
(WebCore::CDMSessionMediaSourceAVFObjC::update): Determing which SourceBuffer is protected.
(WebCore::CDMSessionMediaSourceAVFObjC::addSourceBuffer): Added.
(WebCore::CDMSessionMediaSourceAVFObjC::removeSourceBuffer): Added.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Remove supportsKeyType parameter.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Remove keyType check.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession): Tell the CDMSession about outstanding SourceBuffers.
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173197 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/CDM.cpp
Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/CDMSession.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm

index a07315b..0a34b40 100644 (file)
@@ -1,3 +1,70 @@
+2014-09-02  Jer Noble  <jer.noble@apple.com>
+
+        [EME][Mac] Refactor CDMPrivateMediaSourceAVFObjC to allow sessions to be created without being attached to an AVStreamDataParser.
+        https://bugs.webkit.org/show_bug.cgi?id=136016
+
+        Reviewed by Eric Carlson.
+
+        The CDMPrivateMediaPlayer class will delegate creation of CDMSession instances to the current MediaPlayer. This
+        of course requires the MediaKeys object owning the CDM to be attached to a HTMLMediaElement, and specifically to
+        one with a valid src attribute or source node which has sucessfully begun loading. For certain CDM operations,
+        it would be better if a given MediaKeys could create a session without actually being connected to a
+        HTMLMediaElement (yet).
+
+        To facilitate this for CDMSessionPrivateMediaSourceAVFObjC, add a new class, CDMPrivateMediaSourceAVFObjC, which
+        is the primary factory for CDMSessionPrivateMediaSOurceAVFObjC. Disclaim responsibility for creating these sessions
+        in MediaPlayerPrivateMediaSourceAVFObjC by not passing the "supportsKeySystem" method when registering itself.
+
+        Add methods to CDMSessionPrivateMediaSourceAVFObjC to allow SourceBuffers to be added and removed from the session,
+        to support adding the session to the HTMLMediaElement after the session has been created.
+
+        Since MediaPlayerPrivate instance and  CDMSession instances must be able to communicate with one another, add a type()
+        enum and virtual method to allow CDMSession instnaces to be distinguisted from (and casted to) one another.
+
+        * Modules/encryptedmedia/CDM.cpp:
+        (WebCore::installedCDMFactories): Register CDMPrivateMediaSourceAVFObjC.
+        (WebCore::CDM::createSession): Notify the MediaPlayer of the new CDMSession.
+        * Modules/encryptedmedia/MediaKeySession.h:
+        * Modules/encryptedmedia/MediaKeys.cpp:
+        (WebCore::MediaKeys::setMediaElement): Notify the HTMLMediaElement of any existing sessions.
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/CDMSession.h:
+        (WebCore::CDMSession::type): Added.
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::setCDMSession): Pass through to the MediaPlayerPrivate.
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::setCDMSession): Added. Default no-op.
+        * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h: Added.
+        (WebCore::CDMPrivateMediaSourceAVFObjC::CDMPrivateMediaSourceAVFObjC): Simple constructor.
+        (WebCore::CDMPrivateMediaSourceAVFObjC::~CDMPrivateMediaSourceAVFObjC): Simple destructor.
+        (WebCore::CDMPrivateMediaSourceAVFObjC::create): Simple factory.
+        (WebCore::CDMPrivateMediaSourceAVFObjC::cdm): Simple accessor.
+        * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm: 
+        (WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystem): Moved from MediaPlayerPrivateMediaSourceAVFObjC.
+        (WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType): Ditto.
+        (WebCore::CDMPrivateMediaSourceAVFObjC::supportsMIMEType): Ditto.
+        (WebCore::CDMPrivateMediaSourceAVFObjC::createSession): Returns new CDMSessionMediaSourceAVFObjC.
+        * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h:
+        (WebCore::CDMSessionAVFoundationObjC::type): Added.
+        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h:
+        (WebCore::CDMSessionMediaSourceAVFObjC::type): Added.
+        (WebCore::toCDMSessionMediaSourceAVFObjC): Throw assertion if type() is not correct.
+        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
+        (WebCore::CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC): Removed m_parent ivar.
+        (WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC): Ditto.
+        (WebCore::CDMSessionMediaSourceAVFObjC::update): Determing which SourceBuffer is protected.
+        (WebCore::CDMSessionMediaSourceAVFObjC::addSourceBuffer): Added.
+        (WebCore::CDMSessionMediaSourceAVFObjC::removeSourceBuffer): Added.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Remove supportsKeyType parameter.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Remove keyType check.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession): Tell the CDMSession about outstanding SourceBuffers.
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+
 2014-09-02  Daniel Bates  <dabates@apple.com>
 
         [Win] Attempt to fix the Windows build after <http://trac.webkit.org/changeset/173192>
index 967c23e..5651b91 100644 (file)
 #include "CDMSession.h"
 #include "MediaKeyError.h"
 #include "MediaKeys.h"
+#include "MediaPlayer.h"
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/WTFString.h>
 
+#if PLATFORM(MAC) && ENABLE(MEDIA_SOURCE)
+#include "CDMPrivateMediaSourceAVFObjC.h"
+#endif
+
 namespace WebCore {
 
 struct CDMFactory {
@@ -62,6 +67,10 @@ static Vector<CDMFactory*>& installedCDMFactories()
 
         // FIXME: initialize specific UA CDMs. http://webkit.org/b/109318, http://webkit.org/b/109320
         cdms.get().append(new CDMFactory(CDMPrivateMediaPlayer::create, CDMPrivateMediaPlayer::supportsKeySystem, CDMPrivateMediaPlayer::supportsKeySystemAndMimeType));
+
+#if PLATFORM(MAC) && ENABLE(MEDIA_SOURCE)
+        cdms.get().append(new CDMFactory(CDMPrivateMediaSourceAVFObjC::create, CDMPrivateMediaSourceAVFObjC::supportsKeySystem, CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType));
+#endif
     }
 
     return cdms;
@@ -120,7 +129,10 @@ bool CDM::supportsMIMEType(const String& mimeType) const
 
 std::unique_ptr<CDMSession> CDM::createSession()
 {
-    return m_private->createSession();
+    std::unique_ptr<CDMSession> session = m_private->createSession();
+    if (mediaPlayer())
+        mediaPlayer()->setCDMSession(session.get());
+    return session;
 }
 
 MediaPlayer* CDM::mediaPlayer() const
index b5f4146..048c019 100644 (file)
@@ -51,6 +51,7 @@ public:
     ~MediaKeySession();
 
     const String& keySystem() const { return m_keySystem; }
+    CDMSession* session() { return m_session.get(); }
     const String& sessionId() const;
 
     void setError(MediaKeyError*);
index f3c212f..f3e37b1 100644 (file)
@@ -144,7 +144,13 @@ bool MediaKeys::isTypeSupported(const String& keySystem, const String& mimeType)
 
 void MediaKeys::setMediaElement(HTMLMediaElement* element)
 {
+    if (m_mediaElement)
+        m_mediaElement->player()->setCDMSession(nullptr);
+
     m_mediaElement = element;
+
+    if (m_mediaElement && !m_sessions.isEmpty())
+        m_mediaElement->player()->setCDMSession(m_sessions.last()->session());
 }
 
 MediaPlayer* MediaKeys::cdmMediaPlayer(const CDM*) const
index 6ac0b49..ecec8e3 100644 (file)
                CD2F4A2418D89F700063746D /* AudioHardwareListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2218D89F700063746D /* AudioHardwareListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CD2F4A2718D8A3490063746D /* AudioHardwareListenerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2F4A2518D8A3490063746D /* AudioHardwareListenerMac.cpp */; };
                CD2F4A2818D8A3490063746D /* AudioHardwareListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */; };
+               CD318622199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */; };
+               CD318623199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD318621199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h */; };
                CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */; };
                CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */; };
                CD336F6417FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6317FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h */; };
                CD2F4A2218D89F700063746D /* AudioHardwareListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioHardwareListener.h; sourceTree = "<group>"; };
                CD2F4A2518D8A3490063746D /* AudioHardwareListenerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioHardwareListenerMac.cpp; sourceTree = "<group>"; };
                CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioHardwareListenerMac.h; sourceTree = "<group>"; };
+               CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDMPrivateMediaSourceAVFObjC.mm; sourceTree = "<group>"; };
+               CD318621199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMPrivateMediaSourceAVFObjC.h; sourceTree = "<group>"; };
                CD32A189184EB46A0029B1BB /* mediaControlsiOS.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = mediaControlsiOS.js; sourceTree = "<group>"; };
                CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVTrackPrivateAVFObjCImpl.mm; sourceTree = "<group>"; };
                CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVTrackPrivateAVFObjCImpl.h; sourceTree = "<group>"; };
                                CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */,
                                CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */,
                                CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
+                               CD318621199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h */,
+                               CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */,
                                CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */,
                                CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */,
                                CDDE02EE18B564FA00CF7FF1 /* CDMSessionMediaSourceAVFObjC.h */,
                                B27535710B053814002CE64F /* ImageSource.h in Headers */,
                                4B3480940EEF50D400AC1B41 /* ImageSourceCG.h in Headers */,
                                316FE1180E6E1DA700BF6088 /* ImplicitAnimation.h in Headers */,
+                               CD318623199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h in Headers */,
                                BE16C59317CFE17200852C04 /* InbandGenericTextTrack.h in Headers */,
                                07941792166E855F009416C2 /* InbandTextTrack.h in Headers */,
                                07941794166EA04E009416C2 /* InbandTextTrackPrivate.h in Headers */,
                                85BA4CDE0AA6861B0088052D /* DOMHTMLButtonElement.mm in Sources */,
                                93F9B6570BA0F35E00854064 /* DOMHTMLCanvasElement.mm in Sources */,
                                85DF2F8F0AA3C88100AD64C5 /* DOMHTMLCollection.mm in Sources */,
+                               CD318622199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm in Sources */,
                                F5C041E40FFCA96D00839D4A /* DOMHTMLDataListElement.mm in Sources */,
                                D359D792129CA3C00006E5D2 /* DOMHTMLDetailsElement.mm in Sources */,
                                85BA4D0C0AA688680088052D /* DOMHTMLDirectoryElement.mm in Sources */,
index fbb4317..80a85e3 100644 (file)
@@ -52,11 +52,18 @@ public:
     virtual void sendError(MediaKeyErrorCode, unsigned long systemCode) = 0;
 };
 
+enum CDMSessionType {
+    CDMSessionTypeUnknown,
+    CDMSessionTypeAVFoundationObjC,
+    CDMSessionTypeMediaSourceAVFObjC,
+};
+
 class CDMSession {
 public:
     CDMSession() { }
     virtual ~CDMSession() { }
 
+    virtual CDMSessionType type() { return CDMSessionTypeUnknown; }
     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;
index 3092ef6..07889c9 100644 (file)
@@ -510,6 +510,11 @@ std::unique_ptr<CDMSession> MediaPlayer::createSession(const String& keySystem)
 {
     return m_private->createSession(keySystem);
 }
+
+void MediaPlayer::setCDMSession(CDMSession* session)
+{
+    m_private->setCDMSession(session);
+}
 #endif
     
 double MediaPlayer::duration() const
index 22c8ef6..a5dc22f 100644 (file)
@@ -359,6 +359,7 @@ public:
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     std::unique_ptr<CDMSession> createSession(const String& keySystem);
+    void setCDMSession(CDMSession*);
 #endif
 
     bool paused() const;
index 5a7eba7..eaae5f2 100644 (file)
@@ -221,6 +221,7 @@ public:
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     virtual std::unique_ptr<CDMSession> createSession(const String&) { return nullptr; }
+    virtual void setCDMSession(CDMSession*) { }
 #endif
 
 #if ENABLE(VIDEO_TRACK)
diff --git a/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h
new file mode 100644 (file)
index 0000000..f560918
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 CDMPrivateMediaSourceAVFObjC_h
+#define CDMPrivateMediaSourceAVFObjC_h
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE)
+
+#include "CDMPrivate.h"
+
+namespace WebCore {
+
+class CDM;
+
+class CDMPrivateMediaSourceAVFObjC : public CDMPrivateInterface {
+public:
+    explicit CDMPrivateMediaSourceAVFObjC(CDM* cdm)
+        : m_cdm(cdm)
+    { }
+    virtual ~CDMPrivateMediaSourceAVFObjC() { }
+
+    static std::unique_ptr<CDMPrivateInterface> create(CDM* cdm) { return std::make_unique<CDMPrivateMediaSourceAVFObjC>(cdm); }
+    static bool supportsKeySystem(const String&);
+    static bool supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType);
+
+    virtual bool supportsMIMEType(const String& mimeType) override;
+    virtual std::unique_ptr<CDMSession> createSession() override;
+
+    CDM* cdm() const { return m_cdm; }
+
+protected:
+    CDM* m_cdm;
+};
+
+}
+
+#endif // ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE)
+
+#endif // CDMPrivateMediaSourceAVFObjC_h
diff --git a/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm
new file mode 100644 (file)
index 0000000..afa09f6
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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 "CDMPrivateMediaSourceAVFObjC.h"
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE)
+
+#import "CDM.h"
+#import "CDMSessionMediaSourceAVFObjC.h"
+#import "ContentType.h"
+#import "ExceptionCode.h"
+#import "MediaPlayerPrivateMediaSourceAVFObjC.h"
+#import "WebCoreSystemInterface.h"
+
+namespace WebCore {
+
+bool CDMPrivateMediaSourceAVFObjC::supportsKeySystem(const String& keySystem)
+{
+    if (!wkQueryDecoderAvailability())
+        return false;
+
+    if (!keySystem.isEmpty() && !equalIgnoringCase(keySystem, "com.apple.fps.2_0"))
+        return false;
+
+    return true;
+}
+
+bool CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType)
+{
+    if (!supportsKeySystem(keySystem))
+        return false;
+
+    if (!mimeType.isEmpty()) {
+        MediaEngineSupportParameters parameters;
+        parameters.isMediaSource = true;
+        parameters.type = mimeType;
+
+        return MediaPlayerPrivateMediaSourceAVFObjC::supportsType(parameters) != MediaPlayer::IsNotSupported;
+    }
+
+    return true;
+}
+
+bool CDMPrivateMediaSourceAVFObjC::supportsMIMEType(const String& mimeType)
+{
+    MediaEngineSupportParameters parameters;
+    parameters.isMediaSource = true;
+    parameters.type = mimeType;
+
+    return MediaPlayerPrivateMediaSourceAVFObjC::supportsType(parameters) != MediaPlayer::IsNotSupported;
+}
+
+std::unique_ptr<CDMSession> CDMPrivateMediaSourceAVFObjC::createSession()
+{
+    return std::make_unique<CDMSessionMediaSourceAVFObjC>();
+}
+
+}
+
+#endif // ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE)
index 5760107..6a64556 100644 (file)
@@ -43,6 +43,7 @@ public:
     CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent);
     virtual ~CDMSessionAVFoundationObjC() { }
 
+    virtual CDMSessionType type() { return CDMSessionTypeAVFoundationObjC; }
     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;
index 2be244f..532724c 100644 (file)
@@ -39,9 +39,10 @@ namespace WebCore {
 
 class CDMSessionMediaSourceAVFObjC : public CDMSession, public SourceBufferPrivateAVFObjCErrorClient {
 public:
-    CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent);
+    CDMSessionMediaSourceAVFObjC();
     virtual ~CDMSessionMediaSourceAVFObjC();
 
+    virtual CDMSessionType type() { return CDMSessionTypeMediaSourceAVFObjC; }
     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;
@@ -51,8 +52,11 @@ public:
     virtual void layerDidReceiveError(AVSampleBufferDisplayLayer *, NSError *);
     virtual void rendererDidReceiveError(AVSampleBufferAudioRenderer *, NSError *);
 
+    void addSourceBuffer(SourceBufferPrivateAVFObjC*);
+    void removeSourceBuffer(SourceBufferPrivateAVFObjC*);
+
 protected:
-    RefPtr<SourceBufferPrivateAVFObjC> m_parent;
+    Vector<RefPtr<SourceBufferPrivateAVFObjC>> m_sourceBuffers;
     CDMSessionClient* m_client;
     RetainPtr<AVStreamSession> m_streamSession;
     RefPtr<Uint8Array> m_initData;
@@ -60,6 +64,13 @@ protected:
     String m_sessionId;
 };
 
+inline CDMSessionMediaSourceAVFObjC* toCDMSessionMediaSourceAVFObjC(CDMSession* session)
+{
+    if (!session || session->type() != CDMSessionTypeMediaSourceAVFObjC)
+        return nullptr;
+    return static_cast<CDMSessionMediaSourceAVFObjC*>(session);
+}
+
 }
 
 #endif
index 51e8872..7377a8b 100644 (file)
@@ -62,23 +62,19 @@ SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVStreamSession);
 
 namespace WebCore {
 
-CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent)
-    : m_parent(parent)
-    , m_client(nullptr)
+CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC()
+    : m_client(nullptr)
     , m_sessionId(createCanonicalUUIDString())
 {
-    ASSERT(parent);
-    parent->registerForErrorNotifications(this);
 }
 
 CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC()
 {
     if (m_streamSession) {
-        [m_streamSession removeStreamDataParser:m_parent->parser()];
+        for (auto& sourceBuffer : m_sourceBuffers)
+            [m_streamSession removeStreamDataParser:sourceBuffer->parser()];
         m_streamSession = nil;
     }
-    m_parent->unregisterForErrorNotifications(this);
-    m_client = nullptr;
 }
 
 PassRefPtr<Uint8Array> CDMSessionMediaSourceAVFObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
@@ -134,18 +130,33 @@ bool CDMSessionMediaSourceAVFObjC::update(Uint8Array* key, RefPtr<Uint8Array>& n
         m_certificate = key;
     }
 
+    RefPtr<SourceBufferPrivateAVFObjC> protectedSourceBuffer;
+    for (auto& sourceBuffer : m_sourceBuffers) {
+        if (sourceBuffer->protectedTrackID() != -1) {
+            protectedSourceBuffer = sourceBuffer;
+            break;
+        }
+    }
+
     if (shouldGenerateKeyRequest) {
         RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
         if (getAVStreamSessionClass()) {
             m_streamSession = adoptNS([[getAVStreamSessionClass() alloc] initWithAppIdentifier:certificateData.get()]);
-            [m_streamSession addStreamDataParser:m_parent->parser()];
+            for (auto& sourceBuffer : m_sourceBuffers)
+                [m_streamSession addStreamDataParser:sourceBuffer->parser()];
             LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - created stream session %p", this, m_streamSession.get());
         }
 
+        if (m_sourceBuffers.isEmpty())
+            return true;
+
+        if (!protectedSourceBuffer)
+            return true;
+
         RetainPtr<NSData> initData = adoptNS([[NSData alloc] initWithBytes:m_initData->data() length:m_initData->length()]);
 
         NSError* error = nil;
-        RetainPtr<NSData> request = [m_parent->parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:m_parent->protectedTrackID() options:nil error:&error];
+        RetainPtr<NSData> request = [protectedSourceBuffer->parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:protectedSourceBuffer->protectedTrackID() options:nil error:&error];
 
         if (error) {
             LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - error:%@", this, [error description]);
@@ -159,11 +170,12 @@ bool CDMSessionMediaSourceAVFObjC::update(Uint8Array* key, RefPtr<Uint8Array>& n
         return false;
     }
 
+    ASSERT(!m_sourceBuffers.isEmpty());
     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()];
+    [protectedSourceBuffer->parser() processContentKeyResponseData:keyData.get() forTrackID:protectedSourceBuffer->protectedTrackID()];
     return true;
 }
 
@@ -183,6 +195,30 @@ void CDMSessionMediaSourceAVFObjC::rendererDidReceiveError(AVSampleBufferAudioRe
     m_client->sendError(CDMSessionClient::MediaKeyErrorDomain, abs([error code]));
 }
 
+void CDMSessionMediaSourceAVFObjC::addSourceBuffer(SourceBufferPrivateAVFObjC* sourceBuffer)
+{
+    ASSERT(!m_sourceBuffers.contains(sourceBuffer));
+    ASSERT(sourceBuffer);
+
+    m_sourceBuffers.append(sourceBuffer);
+    sourceBuffer->registerForErrorNotifications(this);
+
+    if (m_streamSession)
+        [m_streamSession addStreamDataParser:sourceBuffer->parser()];
+}
+
+void CDMSessionMediaSourceAVFObjC::removeSourceBuffer(SourceBufferPrivateAVFObjC* sourceBuffer)
+{
+    ASSERT(m_sourceBuffers.contains(sourceBuffer));
+    ASSERT(sourceBuffer);
+
+    if (m_streamSession)
+        [m_streamSession removeStreamDataParser:sourceBuffer->parser()];
+
+    sourceBuffer->unregisterForErrorNotifications(this);
+    m_sourceBuffers.remove(m_sourceBuffers.find(sourceBuffer));
+}
+
 }
 
 #endif
index 3122129..bcdfedf 100644 (file)
@@ -43,6 +43,7 @@ typedef struct OpaqueCMTimebase* CMTimebaseRef;
 
 namespace WebCore {
 
+class CDMSessionMediaSourceAVFObjC;
 class PlatformClockCM;
 class MediaSourcePrivateAVFObjC;
 
@@ -53,6 +54,12 @@ public:
 
     static void registerMediaEngine(MediaEngineRegistrar);
 
+    // MediaPlayer Factory Methods
+    static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
+    static bool isAvailable();
+    static void getSupportedTypes(HashSet<String>& types);
+    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
+
     void addDisplayLayer(AVSampleBufferDisplayLayer*);
     void removeDisplayLayer(AVSampleBufferDisplayLayer*);
 
@@ -75,7 +82,7 @@ public:
     void sizeChanged();
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
-    virtual std::unique_ptr<CDMSession> createSession(const String&);
+    virtual void setCDMSession(CDMSession*) override;
     void keyNeeded(Uint8Array*);
 #endif
 
@@ -161,13 +168,6 @@ private:
     bool shouldBePlaying() const;
     void seekTimerFired(Timer<MediaPlayerPrivateMediaSourceAVFObjC>&);
 
-    // MediaPlayer Factory Methods
-    static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
-    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;
 
     struct PendingSeek {
@@ -193,6 +193,7 @@ private:
     RetainPtr<id> m_timeJumpedObserver;
     RetainPtr<id> m_durationObserver;
     Timer<MediaPlayerPrivateMediaSourceAVFObjC> m_seekTimer;
+    CDMSessionMediaSourceAVFObjC* m_session;
     MediaPlayer::NetworkState m_networkState;
     MediaPlayer::ReadyState m_readyState;
     MediaTime m_lastSeekTime;
index d65af31..928420a 100644 (file)
@@ -28,7 +28,7 @@
 
 #if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
 
-#import "CDMSession.h"
+#import "CDMSessionMediaSourceAVFObjC.h"
 #import "Logging.h"
 #import "MediaSourcePrivateAVFObjC.h"
 #import "MediaSourcePrivateClient.h"
@@ -136,6 +136,7 @@ MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(Media
     , m_weakPtrFactory(this)
     , m_synchronizer(adoptNS([[getAVSampleBufferRenderSynchronizerClass() alloc] init]))
     , m_seekTimer(this, &MediaPlayerPrivateMediaSourceAVFObjC::seekTimerFired)
+    , m_session(nullptr)
     , m_networkState(MediaPlayer::Empty)
     , m_readyState(MediaPlayer::HaveNothing)
     , m_rate(1)
@@ -194,7 +195,7 @@ MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC()
 void MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(MediaEngineRegistrar registrar)
 {
     if (isAvailable())
-        registrar(create, getSupportedTypes, supportsType, 0, 0, 0, supportsKeySystem);
+        registrar(create, getSupportedTypes, supportsType, 0, 0, 0, 0);
 }
 
 PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateMediaSourceAVFObjC::create(MediaPlayer* player)
@@ -233,20 +234,8 @@ void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String>& ty
     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;
@@ -263,28 +252,6 @@ MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(con
     return [getAVURLAssetClass() isPlayableExtendedMIMEType:typeString] ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;;
 }
 
-bool MediaPlayerPrivateMediaSourceAVFObjC::supportsKeySystem(const String& keySystem, const String& mimeType)
-{
-#if ENABLE(ENCRYPTED_MEDIA_V2)
-    if (!wkQueryDecoderAvailability())
-        return false;
-
-    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
 
@@ -692,12 +659,20 @@ void MediaPlayerPrivateMediaSourceAVFObjC::sizeChanged()
 }
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
-std::unique_ptr<CDMSession> MediaPlayerPrivateMediaSourceAVFObjC::createSession(const String& keySystem)
+void MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession(CDMSession* session)
 {
-    if (!m_mediaSourcePrivate)
-        return nullptr;
+    if (m_session) {
+        for (auto& sourceBuffer : m_mediaSourcePrivate->sourceBuffers())
+            m_session->removeSourceBuffer(sourceBuffer.get());
+        m_session = nullptr;
+    }
 
-    return m_mediaSourcePrivate->createSession(keySystem);
+    m_session = toCDMSessionMediaSourceAVFObjC(session);
+
+    if (m_session) {
+        for (auto& sourceBuffer : m_mediaSourcePrivate->sourceBuffers())
+            m_session->addSourceBuffer(sourceBuffer.get());
+    }
 }
 
 void MediaPlayerPrivateMediaSourceAVFObjC::keyNeeded(Uint8Array* initData)
index cbd1d4e..5f9fa4d 100644 (file)
@@ -55,6 +55,7 @@ public:
     virtual ~MediaSourcePrivateAVFObjC();
 
     MediaPlayerPrivateMediaSourceAVFObjC* player() const { return m_player; }
+    const Vector<RefPtr<SourceBufferPrivateAVFObjC>>& sourceBuffers() const { return m_sourceBuffers; }
     const Vector<SourceBufferPrivateAVFObjC*>& activeSourceBuffers() const { return m_activeSourceBuffers; }
 
     virtual AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) override;
@@ -76,10 +77,6 @@ public:
     MediaTime fastSeekTimeForMediaTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold);
     IntSize naturalSize() const;
 
-#if ENABLE(ENCRYPTED_MEDIA_V2)
-    std::unique_ptr<CDMSession> createSession(const String&);
-#endif
-
 private:
     MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC*, MediaSourcePrivateClient*);
 
index f2a4b34..792ed98 100644 (file)
@@ -153,18 +153,6 @@ void MediaSourcePrivateAVFObjC::sourceBufferPrivateDidChangeActiveState(SourceBu
 }
 
 #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);