Title: [173197] trunk/Source/WebCore
Revision
173197
Author
[email protected]
Date
2014-09-02 18:28:33 -0700 (Tue, 02 Sep 2014)

Log Message

[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:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173196 => 173197)


--- trunk/Source/WebCore/ChangeLog	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/ChangeLog	2014-09-03 01:28:33 UTC (rev 173197)
@@ -1,3 +1,70 @@
+2014-09-02  Jer Noble  <[email protected]>
+
+        [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  <[email protected]>
 
         [Win] Attempt to fix the Windows build after <http://trac.webkit.org/changeset/173192>

Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp (173196 => 173197)


--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp	2014-09-03 01:28:33 UTC (rev 173197)
@@ -33,9 +33,14 @@
 #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 @@
 
         // 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 @@
 
 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

Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h (173196 => 173197)


--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -51,6 +51,7 @@
     ~MediaKeySession();
 
     const String& keySystem() const { return m_keySystem; }
+    CDMSession* session() { return m_session.get(); }
     const String& sessionId() const;
 
     void setError(MediaKeyError*);

Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp (173196 => 173197)


--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp	2014-09-03 01:28:33 UTC (rev 173197)
@@ -144,7 +144,13 @@
 
 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

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (173196 => 173197)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-09-03 01:28:33 UTC (rev 173197)
@@ -5591,6 +5591,8 @@
 		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 */; };
@@ -13003,6 +13005,8 @@
 		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>"; };
@@ -21578,6 +21582,8 @@
 				CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */,
 				CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */,
 				CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
+				CD318621199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h */,
+				CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */,
 				CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */,
 				CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */,
 				CDDE02EE18B564FA00CF7FF1 /* CDMSessionMediaSourceAVFObjC.h */,
@@ -24516,6 +24522,7 @@
 				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 */,
@@ -27445,6 +27452,7 @@
 				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 */,

Modified: trunk/Source/WebCore/platform/graphics/CDMSession.h (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/CDMSession.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/CDMSession.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -52,11 +52,18 @@
     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;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2014-09-03 01:28:33 UTC (rev 173197)
@@ -510,6 +510,11 @@
 {
     return m_private->createSession(keySystem);
 }
+
+void MediaPlayer::setCDMSession(CDMSession* session)
+{
+    m_private->setCDMSession(session);
+}
 #endif
     
 double MediaPlayer::duration() const

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -359,6 +359,7 @@
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     std::unique_ptr<CDMSession> createSession(const String& keySystem);
+    void setCDMSession(CDMSession*);
 #endif
 
     bool paused() const;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -221,6 +221,7 @@
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     virtual std::unique_ptr<CDMSession> createSession(const String&) { return nullptr; }
+    virtual void setCDMSession(CDMSession*) { }
 #endif
 
 #if ENABLE(VIDEO_TRACK)

Copied: trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h (from rev 173196, trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h) (0 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -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

Added: trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm (0 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm	2014-09-03 01:28:33 UTC (rev 173197)
@@ -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)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -43,6 +43,7 @@
     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;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -39,9 +39,10 @@
 
 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 @@
     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,8 +64,15 @@
     String m_sessionId;
 };
 
+inline CDMSessionMediaSourceAVFObjC* toCDMSessionMediaSourceAVFObjC(CDMSession* session)
+{
+    if (!session || session->type() != CDMSessionTypeMediaSourceAVFObjC)
+        return nullptr;
+    return static_cast<CDMSessionMediaSourceAVFObjC*>(session);
 }
 
+}
+
 #endif
 
 #endif // CDMSessionMediaSourceAVFObjC_h

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm	2014-09-03 01:28:33 UTC (rev 173197)
@@ -62,23 +62,19 @@
 
 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 @@
         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 @@
         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 @@
     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

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -43,6 +43,7 @@
 
 namespace WebCore {
 
+class CDMSessionMediaSourceAVFObjC;
 class PlatformClockCM;
 class MediaSourcePrivateAVFObjC;
 
@@ -53,6 +54,12 @@
 
     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 @@
     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 @@
     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 @@
     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;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2014-09-03 01:28:33 UTC (rev 173197)
@@ -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 @@
     , 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 @@
 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 @@
     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 @@
     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 @@
 }
 
 #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)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h	2014-09-03 01:28:33 UTC (rev 173197)
@@ -55,6 +55,7 @@
     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 @@
     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*);
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm (173196 => 173197)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm	2014-09-03 00:51:44 UTC (rev 173196)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm	2014-09-03 01:28:33 UTC (rev 173197)
@@ -153,18 +153,6 @@
 }
 
 #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);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to