Changeset 173197 in webkit
- Timestamp:
- Sep 2, 2014 6:28:33 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 16 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r173196 r173197 1 2014-09-02 Jer Noble <jer.noble@apple.com> 2 3 [EME][Mac] Refactor CDMPrivateMediaSourceAVFObjC to allow sessions to be created without being attached to an AVStreamDataParser. 4 https://bugs.webkit.org/show_bug.cgi?id=136016 5 6 Reviewed by Eric Carlson. 7 8 The CDMPrivateMediaPlayer class will delegate creation of CDMSession instances to the current MediaPlayer. This 9 of course requires the MediaKeys object owning the CDM to be attached to a HTMLMediaElement, and specifically to 10 one with a valid src attribute or source node which has sucessfully begun loading. For certain CDM operations, 11 it would be better if a given MediaKeys could create a session without actually being connected to a 12 HTMLMediaElement (yet). 13 14 To facilitate this for CDMSessionPrivateMediaSourceAVFObjC, add a new class, CDMPrivateMediaSourceAVFObjC, which 15 is the primary factory for CDMSessionPrivateMediaSOurceAVFObjC. Disclaim responsibility for creating these sessions 16 in MediaPlayerPrivateMediaSourceAVFObjC by not passing the "supportsKeySystem" method when registering itself. 17 18 Add methods to CDMSessionPrivateMediaSourceAVFObjC to allow SourceBuffers to be added and removed from the session, 19 to support adding the session to the HTMLMediaElement after the session has been created. 20 21 Since MediaPlayerPrivate instance and CDMSession instances must be able to communicate with one another, add a type() 22 enum and virtual method to allow CDMSession instnaces to be distinguisted from (and casted to) one another. 23 24 * Modules/encryptedmedia/CDM.cpp: 25 (WebCore::installedCDMFactories): Register CDMPrivateMediaSourceAVFObjC. 26 (WebCore::CDM::createSession): Notify the MediaPlayer of the new CDMSession. 27 * Modules/encryptedmedia/MediaKeySession.h: 28 * Modules/encryptedmedia/MediaKeys.cpp: 29 (WebCore::MediaKeys::setMediaElement): Notify the HTMLMediaElement of any existing sessions. 30 * WebCore.xcodeproj/project.pbxproj: 31 * platform/graphics/CDMSession.h: 32 (WebCore::CDMSession::type): Added. 33 * platform/graphics/MediaPlayer.cpp: 34 (WebCore::MediaPlayer::setCDMSession): Pass through to the MediaPlayerPrivate. 35 * platform/graphics/MediaPlayer.h: 36 * platform/graphics/MediaPlayerPrivate.h: 37 (WebCore::MediaPlayerPrivateInterface::setCDMSession): Added. Default no-op. 38 * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h: Added. 39 (WebCore::CDMPrivateMediaSourceAVFObjC::CDMPrivateMediaSourceAVFObjC): Simple constructor. 40 (WebCore::CDMPrivateMediaSourceAVFObjC::~CDMPrivateMediaSourceAVFObjC): Simple destructor. 41 (WebCore::CDMPrivateMediaSourceAVFObjC::create): Simple factory. 42 (WebCore::CDMPrivateMediaSourceAVFObjC::cdm): Simple accessor. 43 * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm: 44 (WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystem): Moved from MediaPlayerPrivateMediaSourceAVFObjC. 45 (WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType): Ditto. 46 (WebCore::CDMPrivateMediaSourceAVFObjC::supportsMIMEType): Ditto. 47 (WebCore::CDMPrivateMediaSourceAVFObjC::createSession): Returns new CDMSessionMediaSourceAVFObjC. 48 * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h: 49 (WebCore::CDMSessionAVFoundationObjC::type): Added. 50 * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h: 51 (WebCore::CDMSessionMediaSourceAVFObjC::type): Added. 52 (WebCore::toCDMSessionMediaSourceAVFObjC): Throw assertion if type() is not correct. 53 * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm: 54 (WebCore::CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC): Removed m_parent ivar. 55 (WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC): Ditto. 56 (WebCore::CDMSessionMediaSourceAVFObjC::update): Determing which SourceBuffer is protected. 57 (WebCore::CDMSessionMediaSourceAVFObjC::addSourceBuffer): Added. 58 (WebCore::CDMSessionMediaSourceAVFObjC::removeSourceBuffer): Added. 59 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: 60 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 61 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC): 62 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Remove supportsKeyType parameter. 63 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Remove keyType check. 64 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession): Tell the CDMSession about outstanding SourceBuffers. 65 * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h: 66 * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm: 67 1 68 2014-09-02 Daniel Bates <dabates@apple.com> 2 69 -
trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp
r170650 r173197 34 34 #include "MediaKeyError.h" 35 35 #include "MediaKeys.h" 36 #include "MediaPlayer.h" 36 37 #include <wtf/NeverDestroyed.h> 37 38 #include <wtf/text/WTFString.h> 39 40 #if PLATFORM(MAC) && ENABLE(MEDIA_SOURCE) 41 #include "CDMPrivateMediaSourceAVFObjC.h" 42 #endif 38 43 39 44 namespace WebCore { … … 63 68 // FIXME: initialize specific UA CDMs. http://webkit.org/b/109318, http://webkit.org/b/109320 64 69 cdms.get().append(new CDMFactory(CDMPrivateMediaPlayer::create, CDMPrivateMediaPlayer::supportsKeySystem, CDMPrivateMediaPlayer::supportsKeySystemAndMimeType)); 70 71 #if PLATFORM(MAC) && ENABLE(MEDIA_SOURCE) 72 cdms.get().append(new CDMFactory(CDMPrivateMediaSourceAVFObjC::create, CDMPrivateMediaSourceAVFObjC::supportsKeySystem, CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType)); 73 #endif 65 74 } 66 75 … … 121 130 std::unique_ptr<CDMSession> CDM::createSession() 122 131 { 123 return m_private->createSession(); 132 std::unique_ptr<CDMSession> session = m_private->createSession(); 133 if (mediaPlayer()) 134 mediaPlayer()->setCDMSession(session.get()); 135 return session; 124 136 } 125 137 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
r169830 r173197 52 52 53 53 const String& keySystem() const { return m_keySystem; } 54 CDMSession* session() { return m_session.get(); } 54 55 const String& sessionId() const; 55 56 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp
r170774 r173197 145 145 void MediaKeys::setMediaElement(HTMLMediaElement* element) 146 146 { 147 if (m_mediaElement) 148 m_mediaElement->player()->setCDMSession(nullptr); 149 147 150 m_mediaElement = element; 151 152 if (m_mediaElement && !m_sessions.isEmpty()) 153 m_mediaElement->player()->setCDMSession(m_sessions.last()->session()); 148 154 } 149 155 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r173192 r173197 5592 5592 CD2F4A2718D8A3490063746D /* AudioHardwareListenerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2F4A2518D8A3490063746D /* AudioHardwareListenerMac.cpp */; }; 5593 5593 CD2F4A2818D8A3490063746D /* AudioHardwareListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */; }; 5594 CD318622199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */; }; 5595 CD318623199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD318621199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h */; }; 5594 5596 CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */; }; 5595 5597 CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */; }; … … 13004 13006 CD2F4A2518D8A3490063746D /* AudioHardwareListenerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioHardwareListenerMac.cpp; sourceTree = "<group>"; }; 13005 13007 CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioHardwareListenerMac.h; sourceTree = "<group>"; }; 13008 CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDMPrivateMediaSourceAVFObjC.mm; sourceTree = "<group>"; }; 13009 CD318621199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMPrivateMediaSourceAVFObjC.h; sourceTree = "<group>"; }; 13006 13010 CD32A189184EB46A0029B1BB /* mediaControlsiOS.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = mediaControlsiOS.js; sourceTree = "<group>"; }; 13007 13011 CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVTrackPrivateAVFObjCImpl.mm; sourceTree = "<group>"; }; … … 21579 21583 CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */, 21580 21584 CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */, 21585 CD318621199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h */, 21586 CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */, 21581 21587 CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */, 21582 21588 CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */, … … 24517 24523 4B3480940EEF50D400AC1B41 /* ImageSourceCG.h in Headers */, 24518 24524 316FE1180E6E1DA700BF6088 /* ImplicitAnimation.h in Headers */, 24525 CD318623199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h in Headers */, 24519 24526 BE16C59317CFE17200852C04 /* InbandGenericTextTrack.h in Headers */, 24520 24527 07941792166E855F009416C2 /* InbandTextTrack.h in Headers */, … … 27446 27453 93F9B6570BA0F35E00854064 /* DOMHTMLCanvasElement.mm in Sources */, 27447 27454 85DF2F8F0AA3C88100AD64C5 /* DOMHTMLCollection.mm in Sources */, 27455 CD318622199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm in Sources */, 27448 27456 F5C041E40FFCA96D00839D4A /* DOMHTMLDataListElement.mm in Sources */, 27449 27457 D359D792129CA3C00006E5D2 /* DOMHTMLDetailsElement.mm in Sources */, -
trunk/Source/WebCore/platform/graphics/CDMSession.h
r169830 r173197 53 53 }; 54 54 55 enum CDMSessionType { 56 CDMSessionTypeUnknown, 57 CDMSessionTypeAVFoundationObjC, 58 CDMSessionTypeMediaSourceAVFObjC, 59 }; 60 55 61 class CDMSession { 56 62 public: … … 58 64 virtual ~CDMSession() { } 59 65 66 virtual CDMSessionType type() { return CDMSessionTypeUnknown; } 60 67 virtual void setClient(CDMSessionClient*) = 0; 61 68 virtual const String& sessionId() const = 0; -
trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp
r172868 r173197 511 511 return m_private->createSession(keySystem); 512 512 } 513 514 void MediaPlayer::setCDMSession(CDMSession* session) 515 { 516 m_private->setCDMSession(session); 517 } 513 518 #endif 514 519 -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r172868 r173197 360 360 #if ENABLE(ENCRYPTED_MEDIA_V2) 361 361 std::unique_ptr<CDMSession> createSession(const String& keySystem); 362 void setCDMSession(CDMSession*); 362 363 #endif 363 364 -
trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
r172868 r173197 222 222 #if ENABLE(ENCRYPTED_MEDIA_V2) 223 223 virtual std::unique_ptr<CDMSession> createSession(const String&) { return nullptr; } 224 virtual void setCDMSession(CDMSession*) { } 224 225 #endif 225 226 -
trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h
r173196 r173197 24 24 */ 25 25 26 #ifndef CDM SessionAVFoundationObjC_h27 #define CDM SessionAVFoundationObjC_h26 #ifndef CDMPrivateMediaSourceAVFObjC_h 27 #define CDMPrivateMediaSourceAVFObjC_h 28 28 29 #include "CDMSession.h" 30 #include <wtf/PassOwnPtr.h> 31 #include <wtf/RetainPtr.h> 29 #if ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE) 32 30 33 #if ENABLE(ENCRYPTED_MEDIA_V2) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 34 35 OBJC_CLASS AVAssetResourceLoadingRequest; 31 #include "CDMPrivate.h" 36 32 37 33 namespace WebCore { 38 34 39 class MediaPlayerPrivateAVFoundationObjC;35 class CDM; 40 36 41 class CDM SessionAVFoundationObjC : public CDMSession{37 class CDMPrivateMediaSourceAVFObjC : public CDMPrivateInterface { 42 38 public: 43 CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent); 44 virtual ~CDMSessionAVFoundationObjC() { } 39 explicit CDMPrivateMediaSourceAVFObjC(CDM* cdm) 40 : m_cdm(cdm) 41 { } 42 virtual ~CDMPrivateMediaSourceAVFObjC() { } 45 43 46 virtual void setClient(CDMSessionClient* client) override { m_client = client; } 47 virtual const String& sessionId() const override { return m_sessionId; } 48 virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) override; 49 virtual void releaseKeys() override; 50 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override; 44 static std::unique_ptr<CDMPrivateInterface> create(CDM* cdm) { return std::make_unique<CDMPrivateMediaSourceAVFObjC>(cdm); } 45 static bool supportsKeySystem(const String&); 46 static bool supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType); 47 48 virtual bool supportsMIMEType(const String& mimeType) override; 49 virtual std::unique_ptr<CDMSession> createSession() override; 50 51 CDM* cdm() const { return m_cdm; } 51 52 52 53 protected: 53 MediaPlayerPrivateAVFoundationObjC* m_parent; 54 CDMSessionClient* m_client; 55 String m_sessionId; 56 RetainPtr<AVAssetResourceLoadingRequest> m_request; 54 CDM* m_cdm; 57 55 }; 58 56 59 57 } 60 58 61 #endif 59 #endif // ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE) 62 60 63 #endif // CDM SessionAVFoundationObjC_h61 #endif // CDMPrivateMediaSourceAVFObjC_h -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h
r164514 r173197 44 44 virtual ~CDMSessionAVFoundationObjC() { } 45 45 46 virtual CDMSessionType type() { return CDMSessionTypeAVFoundationObjC; } 46 47 virtual void setClient(CDMSessionClient* client) override { m_client = client; } 47 48 virtual const String& sessionId() const override { return m_sessionId; } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h
r172651 r173197 40 40 class CDMSessionMediaSourceAVFObjC : public CDMSession, public SourceBufferPrivateAVFObjCErrorClient { 41 41 public: 42 CDMSessionMediaSourceAVFObjC( SourceBufferPrivateAVFObjC* parent);42 CDMSessionMediaSourceAVFObjC(); 43 43 virtual ~CDMSessionMediaSourceAVFObjC(); 44 44 45 virtual CDMSessionType type() { return CDMSessionTypeMediaSourceAVFObjC; } 45 46 virtual void setClient(CDMSessionClient* client) override { m_client = client; } 46 47 virtual const String& sessionId() const override { return m_sessionId; } … … 52 53 virtual void rendererDidReceiveError(AVSampleBufferAudioRenderer *, NSError *); 53 54 55 void addSourceBuffer(SourceBufferPrivateAVFObjC*); 56 void removeSourceBuffer(SourceBufferPrivateAVFObjC*); 57 54 58 protected: 55 RefPtr<SourceBufferPrivateAVFObjC> m_parent;59 Vector<RefPtr<SourceBufferPrivateAVFObjC>> m_sourceBuffers; 56 60 CDMSessionClient* m_client; 57 61 RetainPtr<AVStreamSession> m_streamSession; … … 61 65 }; 62 66 67 inline CDMSessionMediaSourceAVFObjC* toCDMSessionMediaSourceAVFObjC(CDMSession* session) 68 { 69 if (!session || session->type() != CDMSessionTypeMediaSourceAVFObjC) 70 return nullptr; 71 return static_cast<CDMSessionMediaSourceAVFObjC*>(session); 72 } 73 63 74 } 64 75 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm
r172651 r173197 63 63 namespace WebCore { 64 64 65 CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent) 66 : m_parent(parent) 67 , m_client(nullptr) 65 CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC() 66 : m_client(nullptr) 68 67 , m_sessionId(createCanonicalUUIDString()) 69 68 { 70 ASSERT(parent);71 parent->registerForErrorNotifications(this);72 69 } 73 70 … … 75 72 { 76 73 if (m_streamSession) { 77 [m_streamSession removeStreamDataParser:m_parent->parser()]; 74 for (auto& sourceBuffer : m_sourceBuffers) 75 [m_streamSession removeStreamDataParser:sourceBuffer->parser()]; 78 76 m_streamSession = nil; 79 77 } 80 m_parent->unregisterForErrorNotifications(this);81 m_client = nullptr;82 78 } 83 79 … … 135 131 } 136 132 133 RefPtr<SourceBufferPrivateAVFObjC> protectedSourceBuffer; 134 for (auto& sourceBuffer : m_sourceBuffers) { 135 if (sourceBuffer->protectedTrackID() != -1) { 136 protectedSourceBuffer = sourceBuffer; 137 break; 138 } 139 } 140 137 141 if (shouldGenerateKeyRequest) { 138 142 RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]); 139 143 if (getAVStreamSessionClass()) { 140 144 m_streamSession = adoptNS([[getAVStreamSessionClass() alloc] initWithAppIdentifier:certificateData.get()]); 141 [m_streamSession addStreamDataParser:m_parent->parser()]; 145 for (auto& sourceBuffer : m_sourceBuffers) 146 [m_streamSession addStreamDataParser:sourceBuffer->parser()]; 142 147 LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - created stream session %p", this, m_streamSession.get()); 143 148 } 144 149 150 if (m_sourceBuffers.isEmpty()) 151 return true; 152 153 if (!protectedSourceBuffer) 154 return true; 155 145 156 RetainPtr<NSData> initData = adoptNS([[NSData alloc] initWithBytes:m_initData->data() length:m_initData->length()]); 146 157 147 158 NSError* error = nil; 148 RetainPtr<NSData> request = [ m_parent->parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:m_parent->protectedTrackID() options:nil error:&error];159 RetainPtr<NSData> request = [protectedSourceBuffer->parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:protectedSourceBuffer->protectedTrackID() options:nil error:&error]; 149 160 150 161 if (error) { … … 160 171 } 161 172 173 ASSERT(!m_sourceBuffers.isEmpty()); 162 174 LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - key data", this); 163 175 errorCode = MediaPlayer::NoError; 164 176 systemCode = 0; 165 177 RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->data() length:key->length()]); 166 [ m_parent->parser() processContentKeyResponseData:keyData.get() forTrackID:m_parent->protectedTrackID()];178 [protectedSourceBuffer->parser() processContentKeyResponseData:keyData.get() forTrackID:protectedSourceBuffer->protectedTrackID()]; 167 179 return true; 168 180 } … … 184 196 } 185 197 198 void CDMSessionMediaSourceAVFObjC::addSourceBuffer(SourceBufferPrivateAVFObjC* sourceBuffer) 199 { 200 ASSERT(!m_sourceBuffers.contains(sourceBuffer)); 201 ASSERT(sourceBuffer); 202 203 m_sourceBuffers.append(sourceBuffer); 204 sourceBuffer->registerForErrorNotifications(this); 205 206 if (m_streamSession) 207 [m_streamSession addStreamDataParser:sourceBuffer->parser()]; 208 } 209 210 void CDMSessionMediaSourceAVFObjC::removeSourceBuffer(SourceBufferPrivateAVFObjC* sourceBuffer) 211 { 212 ASSERT(m_sourceBuffers.contains(sourceBuffer)); 213 ASSERT(sourceBuffer); 214 215 if (m_streamSession) 216 [m_streamSession removeStreamDataParser:sourceBuffer->parser()]; 217 218 sourceBuffer->unregisterForErrorNotifications(this); 219 m_sourceBuffers.remove(m_sourceBuffers.find(sourceBuffer)); 220 } 221 186 222 } 187 223 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r172507 r173197 44 44 namespace WebCore { 45 45 46 class CDMSessionMediaSourceAVFObjC; 46 47 class PlatformClockCM; 47 48 class MediaSourcePrivateAVFObjC; … … 53 54 54 55 static void registerMediaEngine(MediaEngineRegistrar); 56 57 // MediaPlayer Factory Methods 58 static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*); 59 static bool isAvailable(); 60 static void getSupportedTypes(HashSet<String>& types); 61 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 55 62 56 63 void addDisplayLayer(AVSampleBufferDisplayLayer*); … … 76 83 77 84 #if ENABLE(ENCRYPTED_MEDIA_V2) 78 virtual std::unique_ptr<CDMSession> createSession(const String&);85 virtual void setCDMSession(CDMSession*) override; 79 86 void keyNeeded(Uint8Array*); 80 87 #endif … … 161 168 bool shouldBePlaying() const; 162 169 void seekTimerFired(Timer<MediaPlayerPrivateMediaSourceAVFObjC>&); 163 164 // MediaPlayer Factory Methods165 static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);166 static bool isAvailable();167 static void getSupportedTypes(HashSet<String>& types);168 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);169 static bool supportsKeySystem(const String& keySystem, const String& mimeType);170 170 171 171 friend class MediaSourcePrivateAVFObjC; … … 194 194 RetainPtr<id> m_durationObserver; 195 195 Timer<MediaPlayerPrivateMediaSourceAVFObjC> m_seekTimer; 196 CDMSessionMediaSourceAVFObjC* m_session; 196 197 MediaPlayer::NetworkState m_networkState; 197 198 MediaPlayer::ReadyState m_readyState; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r172507 r173197 29 29 #if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION) 30 30 31 #import "CDMSession .h"31 #import "CDMSessionMediaSourceAVFObjC.h" 32 32 #import "Logging.h" 33 33 #import "MediaSourcePrivateAVFObjC.h" … … 137 137 , m_synchronizer(adoptNS([[getAVSampleBufferRenderSynchronizerClass() alloc] init])) 138 138 , m_seekTimer(this, &MediaPlayerPrivateMediaSourceAVFObjC::seekTimerFired) 139 , m_session(nullptr) 139 140 , m_networkState(MediaPlayer::Empty) 140 141 , m_readyState(MediaPlayer::HaveNothing) … … 195 196 { 196 197 if (isAvailable()) 197 registrar(create, getSupportedTypes, supportsType, 0, 0, 0, supportsKeySystem);198 registrar(create, getSupportedTypes, supportsType, 0, 0, 0, 0); 198 199 } 199 200 … … 234 235 } 235 236 236 #if ENABLE(ENCRYPTED_MEDIA_V2)237 static bool keySystemIsSupported(const String& keySystem)238 {239 return equalIgnoringCase(keySystem, "com.apple.fps.2_0");240 }241 #endif242 243 237 MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(const MediaEngineSupportParameters& parameters) 244 238 { 245 #if ENABLE(ENCRYPTED_MEDIA_V2)246 if (!parameters.keySystem.isEmpty() && !keySystemIsSupported(parameters.keySystem))247 return MediaPlayer::IsNotSupported;248 #endif249 250 239 // This engine does not support non-media-source sources. 251 240 if (!parameters.isMediaSource) … … 262 251 NSString *typeString = [NSString stringWithFormat:@"%@; codecs=\"%@\"", (NSString *)parameters.type, (NSString *)parameters.codecs]; 263 252 return [getAVURLAssetClass() isPlayableExtendedMIMEType:typeString] ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;; 264 }265 266 bool MediaPlayerPrivateMediaSourceAVFObjC::supportsKeySystem(const String& keySystem, const String& mimeType)267 {268 #if ENABLE(ENCRYPTED_MEDIA_V2)269 if (!wkQueryDecoderAvailability())270 return false;271 272 if (!keySystem.isEmpty()) {273 if (!keySystemIsSupported(keySystem))274 return false;275 276 if (!mimeType.isEmpty() && !mimeTypeCache().contains(mimeType))277 return false;278 279 return true;280 }281 #else282 UNUSED_PARAM(keySystem);283 UNUSED_PARAM(mimeType);284 #endif285 return false;286 253 } 287 254 … … 693 660 694 661 #if ENABLE(ENCRYPTED_MEDIA_V2) 695 std::unique_ptr<CDMSession> MediaPlayerPrivateMediaSourceAVFObjC::createSession(const String& keySystem) 696 { 697 if (!m_mediaSourcePrivate) 698 return nullptr; 699 700 return m_mediaSourcePrivate->createSession(keySystem); 662 void MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession(CDMSession* session) 663 { 664 if (m_session) { 665 for (auto& sourceBuffer : m_mediaSourcePrivate->sourceBuffers()) 666 m_session->removeSourceBuffer(sourceBuffer.get()); 667 m_session = nullptr; 668 } 669 670 m_session = toCDMSessionMediaSourceAVFObjC(session); 671 672 if (m_session) { 673 for (auto& sourceBuffer : m_mediaSourcePrivate->sourceBuffers()) 674 m_session->addSourceBuffer(sourceBuffer.get()); 675 } 701 676 } 702 677 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h
r171033 r173197 56 56 57 57 MediaPlayerPrivateMediaSourceAVFObjC* player() const { return m_player; } 58 const Vector<RefPtr<SourceBufferPrivateAVFObjC>>& sourceBuffers() const { return m_sourceBuffers; } 58 59 const Vector<SourceBufferPrivateAVFObjC*>& activeSourceBuffers() const { return m_activeSourceBuffers; } 59 60 … … 76 77 MediaTime fastSeekTimeForMediaTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold); 77 78 IntSize naturalSize() const; 78 79 #if ENABLE(ENCRYPTED_MEDIA_V2)80 std::unique_ptr<CDMSession> createSession(const String&);81 #endif82 79 83 80 private: -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm
r171033 r173197 154 154 155 155 #if ENABLE(ENCRYPTED_MEDIA_V2) 156 std::unique_ptr<CDMSession> MediaSourcePrivateAVFObjC::createSession(const String&)157 {158 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090159 if (m_sourceBuffersNeedingSessions.isEmpty())160 return nullptr;161 return std::make_unique<CDMSessionMediaSourceAVFObjC>(m_sourceBuffersNeedingSessions.takeFirst());162 #endif163 return nullptr;164 }165 #endif166 167 #if ENABLE(ENCRYPTED_MEDIA_V2)168 156 void MediaSourcePrivateAVFObjC::sourceBufferKeyNeeded(SourceBufferPrivateAVFObjC* buffer, Uint8Array* initData) 169 157 {
Note: See TracChangeset
for help on using the changeset viewer.