Changeset 143072 in webkit
- Timestamp:
- Feb 15, 2013, 5:03:29 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
Modules/encryptedmedia/CDM.cpp (modified) (3 diffs)
-
Modules/encryptedmedia/CDM.h (modified) (4 diffs)
-
Modules/encryptedmedia/MediaKeys.cpp (modified) (3 diffs)
-
Modules/encryptedmedia/MediaKeys.h (modified) (3 diffs)
-
html/HTMLMediaElement.cpp (modified) (2 diffs)
-
testing/MockCDM.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r143070 r143072 1 2013-02-13 Jer Noble <jer.noble@apple.com> 2 3 Add a CDMClient class which allows the CDM to query for the currently attached MediaPlayer. 4 https://bugs.webkit.org/show_bug.cgi?id=109702 5 6 Reviewed by Eric Carlson. 7 8 Some CDM implementations will need to work closely with an associated 9 MediaPlayer in order to generate key requests and provide keys. Add a 10 client protocol to be implemented by the MediaKeys object which can 11 provide access to the associated MediaPlayer if present. 12 13 * Modules/encryptedmedia/CDM.cpp: 14 (WebCore::CDM::CDM): Initialize the m_client ivar. 15 (WebCore::CDM::mediaPlayer): Pass to the client, if present. 16 * Modules/encryptedmedia/CDM.h: 17 (WebCore::CDM::client): Simple getter. 18 (WebCore::CDM::setClient): Simple setter. 19 * Modules/encryptedmedia/MediaKeys.cpp: 20 (WebCore::MediaKeys::MediaKeys): Initialize the m_mediaElement ivar 21 and call setClient() on the passed in CDM. 22 (WebCore::MediaKeys::setMediaElement): Simple setter. 23 (WebCore::MediaKeys::cdmMediaPlayer): Retrieve the MediaPlayer from 24 the m_mediaElement if present. 25 * Modules/encryptedmedia/MediaKeys.h: 26 * html/HTMLMediaElement.cpp: 27 (WebCore::HTMLMediaElement::~HTMLMediaElement): Call setMediaKeys(0) 28 to clear the mediaElement in any associated MediaKeys. 29 (WebCore::HTMLMediaElement::setMediaKeys): Clear the mediaElement on 30 any associated MediaKeys, and set the mediaElement on the newly 31 associated MediaKeys. 32 1 33 2013-02-15 Simon Fraser <simon.fraser@apple.com> 2 34 -
trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp
r142327 r143072 93 93 CDM::CDM(const String& keySystem) 94 94 : m_keySystem(keySystem) 95 , m_client(0) 95 96 { 96 97 m_private = CDMFactoryForKeySystem(keySystem)->constructor(this); … … 101 102 } 102 103 103 bool CDM::supportsMIMEType(const String& mimeType) 104 bool CDM::supportsMIMEType(const String& mimeType) const 104 105 { 105 106 return m_private->supportsMIMEType(mimeType); … … 111 112 } 112 113 114 MediaPlayer* CDM::mediaPlayer() const 115 { 116 if (!m_client) 117 return 0; 118 return m_client->cdmMediaPlayer(this); 119 } 120 113 121 } 114 122 -
trunk/Source/WebCore/Modules/encryptedmedia/CDM.h
r142918 r143072 39 39 class CDMPrivateInterface; 40 40 class CDMSession; 41 class MediaKeyError; 42 class MediaKeySession; 43 class MediaKeys; 41 class MediaPlayer; 44 42 45 43 typedef PassOwnPtr<CDMPrivateInterface> (*CreateCDM)(CDM*); 46 44 typedef bool (*CDMSupportsKeySystem)(const String&); 45 46 class CDMClient { 47 public: 48 virtual ~CDMClient() { } 49 50 virtual MediaPlayer* cdmMediaPlayer(const CDM*) const = 0; 51 }; 47 52 48 53 class CDMSession { … … 51 56 virtual ~CDMSession() { } 52 57 53 virtual const String& sessionId() = 0;58 virtual const String& sessionId() const = 0; 54 59 virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) = 0; 55 60 virtual void releaseKeys() = 0; … … 64 69 ~CDM(); 65 70 66 bool supportsMIMEType(const String&) ;71 bool supportsMIMEType(const String&) const; 67 72 PassOwnPtr<CDMSession> createSession(); 68 73 69 74 const String& keySystem() const { return m_keySystem; } 75 76 CDMClient* client() const { return m_client; } 77 void setClient(CDMClient* client) { m_client = client; } 78 79 MediaPlayer* mediaPlayer() const; 70 80 71 81 private: … … 74 84 String m_keySystem; 75 85 OwnPtr<CDMPrivateInterface> m_private; 86 CDMClient* m_client; 76 87 }; 77 88 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp
r142327 r143072 31 31 #include "CDM.h" 32 32 #include "EventNames.h" 33 #include "HTMLMediaElement.h" 33 34 #include "MediaKeyMessageEvent.h" 34 35 #include "MediaKeySession.h" … … 66 67 67 68 MediaKeys::MediaKeys(const String& keySystem, PassOwnPtr<CDM> cdm) 68 : m_keySystem(keySystem) 69 : m_mediaElement(0) 70 , m_keySystem(keySystem) 69 71 , m_cdm(cdm) 70 72 { 73 m_cdm->setClient(this); 71 74 } 72 75 … … 116 119 } 117 120 121 void MediaKeys::setMediaElement(HTMLMediaElement* element) 122 { 123 m_mediaElement = element; 124 } 125 126 MediaPlayer* MediaKeys::cdmMediaPlayer(const CDM*) const 127 { 128 if (m_mediaElement) 129 return m_mediaElement->player(); 130 return 0; 131 } 132 118 133 } 119 134 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h
r142327 r143072 29 29 #if ENABLE(ENCRYPTED_MEDIA_V2) 30 30 31 #include "CDM.h" 31 32 #include "EventTarget.h" 32 33 #include "ExceptionCode.h" … … 40 41 namespace WebCore { 41 42 42 class CDM;43 43 class MediaKeySession; 44 class HTMLMediaElement; 44 45 45 class MediaKeys : public RefCounted<MediaKeys> {46 class MediaKeys : public RefCounted<MediaKeys>, public CDMClient { 46 47 public: 47 48 static PassRefPtr<MediaKeys> create(const String& keySystem, ExceptionCode&); … … 53 54 CDM* cdm() { return m_cdm.get(); } 54 55 56 HTMLMediaElement* mediaElement() const { return m_mediaElement; } 57 void setMediaElement(HTMLMediaElement*); 58 55 59 protected: 60 // CDMClient: 61 virtual MediaPlayer* cdmMediaPlayer(const CDM*) const OVERRIDE; 62 56 63 MediaKeys(const String& keySystem, PassOwnPtr<CDM>); 57 64 58 65 Vector<RefPtr<MediaKeySession> > m_sessions; 59 66 67 HTMLMediaElement* m_mediaElement; 60 68 String m_keySystem; 61 69 OwnPtr<CDM> m_cdm; -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r143021 r143072 350 350 #endif 351 351 352 #if ENABLE(ENCRYPTED_MEDIA_V2) 353 setMediaKeys(0); 354 #endif 355 352 356 removeElementFromDocumentMap(this, document()); 353 357 } … … 1996 2000 void HTMLMediaElement::setMediaKeys(MediaKeys* mediaKeys) 1997 2001 { 2002 if (m_mediaKeys == mediaKeys) 2003 return; 2004 2005 if (m_mediaKeys) 2006 m_mediaKeys->setMediaElement(0); 1998 2007 m_mediaKeys = mediaKeys; 2008 if (m_mediaKeys) 2009 m_mediaKeys->setMediaElement(this); 1999 2010 } 2000 2011 #endif -
trunk/Source/WebCore/testing/MockCDM.cpp
r142918 r143072 40 40 virtual ~MockCDMSession() { } 41 41 42 virtual const String& sessionId() OVERRIDE { return m_sessionId; }42 virtual const String& sessionId() const OVERRIDE { return m_sessionId; } 43 43 virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) OVERRIDE; 44 44 virtual void releaseKeys() OVERRIDE;
Note:
See TracChangeset
for help on using the changeset viewer.