Diff
Modified: tags/Safari-537.31.10/Source/WebCore/ChangeLog (144094 => 144095)
--- tags/Safari-537.31.10/Source/WebCore/ChangeLog 2013-02-26 21:04:11 UTC (rev 144094)
+++ tags/Safari-537.31.10/Source/WebCore/ChangeLog 2013-02-26 21:07:15 UTC (rev 144095)
@@ -1,5 +1,41 @@
2013-02-26 Lucas Forschler <[email protected]>
+ Merge r143072
+
+ 2013-02-13 Jer Noble <[email protected]>
+
+ Add a CDMClient class which allows the CDM to query for the currently attached MediaPlayer.
+ https://bugs.webkit.org/show_bug.cgi?id=109702
+
+ Reviewed by Eric Carlson.
+
+ Some CDM implementations will need to work closely with an associated
+ MediaPlayer in order to generate key requests and provide keys. Add a
+ client protocol to be implemented by the MediaKeys object which can
+ provide access to the associated MediaPlayer if present.
+
+ * Modules/encryptedmedia/CDM.cpp:
+ (WebCore::CDM::CDM): Initialize the m_client ivar.
+ (WebCore::CDM::mediaPlayer): Pass to the client, if present.
+ * Modules/encryptedmedia/CDM.h:
+ (WebCore::CDM::client): Simple getter.
+ (WebCore::CDM::setClient): Simple setter.
+ * Modules/encryptedmedia/MediaKeys.cpp:
+ (WebCore::MediaKeys::MediaKeys): Initialize the m_mediaElement ivar
+ and call setClient() on the passed in CDM.
+ (WebCore::MediaKeys::setMediaElement): Simple setter.
+ (WebCore::MediaKeys::cdmMediaPlayer): Retrieve the MediaPlayer from
+ the m_mediaElement if present.
+ * Modules/encryptedmedia/MediaKeys.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::~HTMLMediaElement): Call setMediaKeys(0)
+ to clear the mediaElement in any associated MediaKeys.
+ (WebCore::HTMLMediaElement::setMediaKeys): Clear the mediaElement on
+ any associated MediaKeys, and set the mediaElement on the newly
+ associated MediaKeys.
+
+2013-02-26 Lucas Forschler <[email protected]>
+
Merge r142918
2013-02-14 Jer Noble <[email protected]>
Modified: tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.cpp (144094 => 144095)
--- tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2013-02-26 21:04:11 UTC (rev 144094)
+++ tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2013-02-26 21:07:15 UTC (rev 144095)
@@ -92,6 +92,7 @@
CDM::CDM(const String& keySystem)
: m_keySystem(keySystem)
+ , m_client(0)
{
m_private = CDMFactoryForKeySystem(keySystem)->constructor(this);
}
@@ -100,7 +101,7 @@
{
}
-bool CDM::supportsMIMEType(const String& mimeType)
+bool CDM::supportsMIMEType(const String& mimeType) const
{
return m_private->supportsMIMEType(mimeType);
}
@@ -110,6 +111,13 @@
return m_private->createSession();
}
+MediaPlayer* CDM::mediaPlayer() const
+{
+ if (!m_client)
+ return 0;
+ return m_client->cdmMediaPlayer(this);
}
+}
+
#endif // ENABLE(ENCRYPTED_MEDIA_V2)
Modified: tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.h (144094 => 144095)
--- tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.h 2013-02-26 21:04:11 UTC (rev 144094)
+++ tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.h 2013-02-26 21:07:15 UTC (rev 144095)
@@ -38,19 +38,24 @@
class CDM;
class CDMPrivateInterface;
class CDMSession;
-class MediaKeyError;
-class MediaKeySession;
-class MediaKeys;
+class MediaPlayer;
typedef PassOwnPtr<CDMPrivateInterface> (*CreateCDM)(CDM*);
typedef bool (*CDMSupportsKeySystem)(const String&);
+class CDMClient {
+public:
+ virtual ~CDMClient() { }
+
+ virtual MediaPlayer* cdmMediaPlayer(const CDM*) const = 0;
+};
+
class CDMSession {
public:
CDMSession() { }
virtual ~CDMSession() { }
- virtual const String& sessionId() = 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;
virtual void releaseKeys() = 0;
virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) = 0;
@@ -63,16 +68,22 @@
static void registerCDMFactory(CreateCDM, CDMSupportsKeySystem);
~CDM();
- bool supportsMIMEType(const String&);
+ bool supportsMIMEType(const String&) const;
PassOwnPtr<CDMSession> createSession();
const String& keySystem() const { return m_keySystem; }
+ CDMClient* client() const { return m_client; }
+ void setClient(CDMClient* client) { m_client = client; }
+
+ MediaPlayer* mediaPlayer() const;
+
private:
CDM(const String& keySystem);
String m_keySystem;
OwnPtr<CDMPrivateInterface> m_private;
+ CDMClient* m_client;
};
}
Modified: tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp (144094 => 144095)
--- tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp 2013-02-26 21:04:11 UTC (rev 144094)
+++ tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp 2013-02-26 21:07:15 UTC (rev 144095)
@@ -30,6 +30,7 @@
#include "CDM.h"
#include "EventNames.h"
+#include "HTMLMediaElement.h"
#include "MediaKeyMessageEvent.h"
#include "MediaKeySession.h"
#include "UUID.h"
@@ -65,9 +66,11 @@
}
MediaKeys::MediaKeys(const String& keySystem, PassOwnPtr<CDM> cdm)
- : m_keySystem(keySystem)
+ : m_mediaElement(0)
+ , m_keySystem(keySystem)
, m_cdm(cdm)
{
+ m_cdm->setClient(this);
}
MediaKeys::~MediaKeys()
@@ -115,6 +118,18 @@
return session;
}
+void MediaKeys::setMediaElement(HTMLMediaElement* element)
+{
+ m_mediaElement = element;
}
+MediaPlayer* MediaKeys::cdmMediaPlayer(const CDM*) const
+{
+ if (m_mediaElement)
+ return m_mediaElement->player();
+ return 0;
+}
+
+}
+
#endif
Modified: tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.h (144094 => 144095)
--- tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.h 2013-02-26 21:04:11 UTC (rev 144094)
+++ tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.h 2013-02-26 21:07:15 UTC (rev 144095)
@@ -28,6 +28,7 @@
#if ENABLE(ENCRYPTED_MEDIA_V2)
+#include "CDM.h"
#include "EventTarget.h"
#include "ExceptionCode.h"
#include <wtf/OwnPtr.h>
@@ -39,10 +40,10 @@
namespace WebCore {
-class CDM;
class MediaKeySession;
+class HTMLMediaElement;
-class MediaKeys : public RefCounted<MediaKeys> {
+class MediaKeys : public RefCounted<MediaKeys>, public CDMClient {
public:
static PassRefPtr<MediaKeys> create(const String& keySystem, ExceptionCode&);
~MediaKeys();
@@ -52,11 +53,18 @@
const String& keySystem() const { return m_keySystem; }
CDM* cdm() { return m_cdm.get(); }
+ HTMLMediaElement* mediaElement() const { return m_mediaElement; }
+ void setMediaElement(HTMLMediaElement*);
+
protected:
+ // CDMClient:
+ virtual MediaPlayer* cdmMediaPlayer(const CDM*) const OVERRIDE;
+
MediaKeys(const String& keySystem, PassOwnPtr<CDM>);
Vector<RefPtr<MediaKeySession> > m_sessions;
+ HTMLMediaElement* m_mediaElement;
String m_keySystem;
OwnPtr<CDM> m_cdm;
};
Modified: tags/Safari-537.31.10/Source/WebCore/html/HTMLMediaElement.cpp (144094 => 144095)
--- tags/Safari-537.31.10/Source/WebCore/html/HTMLMediaElement.cpp 2013-02-26 21:04:11 UTC (rev 144094)
+++ tags/Safari-537.31.10/Source/WebCore/html/HTMLMediaElement.cpp 2013-02-26 21:07:15 UTC (rev 144095)
@@ -348,6 +348,10 @@
setSourceState(MediaSource::closedKeyword());
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ setMediaKeys(0);
+#endif
+
removeElementFromDocumentMap(this, document());
}
@@ -1994,7 +1998,14 @@
void HTMLMediaElement::setMediaKeys(MediaKeys* mediaKeys)
{
+ if (m_mediaKeys == mediaKeys)
+ return;
+
+ if (m_mediaKeys)
+ m_mediaKeys->setMediaElement(0);
m_mediaKeys = mediaKeys;
+ if (m_mediaKeys)
+ m_mediaKeys->setMediaElement(this);
}
#endif
Modified: tags/Safari-537.31.10/Source/WebCore/testing/MockCDM.cpp (144094 => 144095)
--- tags/Safari-537.31.10/Source/WebCore/testing/MockCDM.cpp 2013-02-26 21:04:11 UTC (rev 144094)
+++ tags/Safari-537.31.10/Source/WebCore/testing/MockCDM.cpp 2013-02-26 21:07:15 UTC (rev 144095)
@@ -39,7 +39,7 @@
static PassOwnPtr<MockCDMSession> create() { return adoptPtr(new MockCDMSession()); }
virtual ~MockCDMSession() { }
- virtual const String& sessionId() OVERRIDE { return m_sessionId; }
+ virtual const String& sessionId() const OVERRIDE { return m_sessionId; }
virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) OVERRIDE;
virtual void releaseKeys() OVERRIDE;
virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) OVERRIDE;