⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 144095 in webkit


Ignore:
Timestamp:
Feb 26, 2013, 1:07:15 PM (14 years ago)
Author:
Lucas Forschler
Message:

Merged r143072. <rdar://problem/13254985>

Location:
tags/Safari-537.31.10/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • tags/Safari-537.31.10/Source/WebCore/ChangeLog

    r144094 r144095  
     12013-02-26  Lucas Forschler  <lforschler@apple.com>
     2
     3        Merge r143072
     4
     5    2013-02-13  Jer Noble  <jer.noble@apple.com>
     6
     7            Add a CDMClient class which allows the CDM to query for the currently attached MediaPlayer.
     8            https://bugs.webkit.org/show_bug.cgi?id=109702
     9
     10            Reviewed by Eric Carlson.
     11
     12            Some CDM implementations will need to work closely with an associated
     13            MediaPlayer in order to generate key requests and provide keys. Add a
     14            client protocol to be implemented by the MediaKeys object which can
     15            provide access to the associated MediaPlayer if present.
     16
     17            * Modules/encryptedmedia/CDM.cpp:
     18            (WebCore::CDM::CDM): Initialize the m_client ivar.
     19            (WebCore::CDM::mediaPlayer): Pass to the client, if present.
     20            * Modules/encryptedmedia/CDM.h:
     21            (WebCore::CDM::client): Simple getter.
     22            (WebCore::CDM::setClient): Simple setter.
     23            * Modules/encryptedmedia/MediaKeys.cpp:
     24            (WebCore::MediaKeys::MediaKeys): Initialize the m_mediaElement ivar
     25                and call setClient() on the passed in CDM.
     26            (WebCore::MediaKeys::setMediaElement): Simple setter.
     27            (WebCore::MediaKeys::cdmMediaPlayer): Retrieve the MediaPlayer from
     28                the m_mediaElement if present.
     29            * Modules/encryptedmedia/MediaKeys.h:
     30            * html/HTMLMediaElement.cpp:
     31            (WebCore::HTMLMediaElement::~HTMLMediaElement): Call setMediaKeys(0)
     32                to clear the mediaElement in any associated MediaKeys.
     33            (WebCore::HTMLMediaElement::setMediaKeys): Clear the mediaElement on
     34                any associated MediaKeys, and set the mediaElement on the newly
     35                associated MediaKeys.
     36
    1372013-02-26  Lucas Forschler  <lforschler@apple.com>
    238
  • tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.cpp

    r142327 r144095  
    9393CDM::CDM(const String& keySystem)
    9494    : m_keySystem(keySystem)
     95    , m_client(0)
    9596{
    9697    m_private = CDMFactoryForKeySystem(keySystem)->constructor(this);
     
    101102}
    102103
    103 bool CDM::supportsMIMEType(const String& mimeType)
     104bool CDM::supportsMIMEType(const String& mimeType) const
    104105{
    105106    return m_private->supportsMIMEType(mimeType);
     
    111112}
    112113
     114MediaPlayer* CDM::mediaPlayer() const
     115{
     116    if (!m_client)
     117        return 0;
     118    return m_client->cdmMediaPlayer(this);
     119}
     120
    113121}
    114122
  • tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/CDM.h

    r144094 r144095  
    3939class CDMPrivateInterface;
    4040class CDMSession;
    41 class MediaKeyError;
    42 class MediaKeySession;
    43 class MediaKeys;
     41class MediaPlayer;
    4442
    4543typedef PassOwnPtr<CDMPrivateInterface> (*CreateCDM)(CDM*);
    4644typedef bool (*CDMSupportsKeySystem)(const String&);
     45
     46class CDMClient {
     47public:
     48    virtual ~CDMClient() { }
     49
     50    virtual MediaPlayer* cdmMediaPlayer(const CDM*) const = 0;
     51};
    4752
    4853class CDMSession {
     
    5156    virtual ~CDMSession() { }
    5257
    53     virtual const String& sessionId() = 0;
     58    virtual const String& sessionId() const = 0;
    5459    virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) = 0;
    5560    virtual void releaseKeys() = 0;
     
    6469    ~CDM();
    6570
    66     bool supportsMIMEType(const String&);
     71    bool supportsMIMEType(const String&) const;
    6772    PassOwnPtr<CDMSession> createSession();
    6873
    6974    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;
    7080
    7181private:
     
    7484    String m_keySystem;
    7585    OwnPtr<CDMPrivateInterface> m_private;
     86    CDMClient* m_client;
    7687};
    7788
  • tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp

    r142327 r144095  
    3131#include "CDM.h"
    3232#include "EventNames.h"
     33#include "HTMLMediaElement.h"
    3334#include "MediaKeyMessageEvent.h"
    3435#include "MediaKeySession.h"
     
    6667
    6768MediaKeys::MediaKeys(const String& keySystem, PassOwnPtr<CDM> cdm)
    68     : m_keySystem(keySystem)
     69    : m_mediaElement(0)
     70    , m_keySystem(keySystem)
    6971    , m_cdm(cdm)
    7072{
     73    m_cdm->setClient(this);
    7174}
    7275
     
    116119}
    117120
     121void MediaKeys::setMediaElement(HTMLMediaElement* element)
     122{
     123    m_mediaElement = element;
     124}
     125
     126MediaPlayer* MediaKeys::cdmMediaPlayer(const CDM*) const
     127{
     128    if (m_mediaElement)
     129        return m_mediaElement->player();
     130    return 0;
     131}
     132
    118133}
    119134
  • tags/Safari-537.31.10/Source/WebCore/Modules/encryptedmedia/MediaKeys.h

    r142327 r144095  
    2929#if ENABLE(ENCRYPTED_MEDIA_V2)
    3030
     31#include "CDM.h"
    3132#include "EventTarget.h"
    3233#include "ExceptionCode.h"
     
    4041namespace WebCore {
    4142
    42 class CDM;
    4343class MediaKeySession;
     44class HTMLMediaElement;
    4445
    45 class MediaKeys : public RefCounted<MediaKeys> {
     46class MediaKeys : public RefCounted<MediaKeys>, public CDMClient {
    4647public:
    4748    static PassRefPtr<MediaKeys> create(const String& keySystem, ExceptionCode&);
     
    5354    CDM* cdm() { return m_cdm.get(); }
    5455
     56    HTMLMediaElement* mediaElement() const { return m_mediaElement; }
     57    void setMediaElement(HTMLMediaElement*);
     58
    5559protected:
     60    // CDMClient:
     61    virtual MediaPlayer* cdmMediaPlayer(const CDM*) const OVERRIDE;
     62
    5663    MediaKeys(const String& keySystem, PassOwnPtr<CDM>);
    5764
    5865    Vector<RefPtr<MediaKeySession> > m_sessions;
    5966
     67    HTMLMediaElement* m_mediaElement;
    6068    String m_keySystem;
    6169    OwnPtr<CDM> m_cdm;
  • tags/Safari-537.31.10/Source/WebCore/html/HTMLMediaElement.cpp

    r144094 r144095  
    349349#endif
    350350
     351#if ENABLE(ENCRYPTED_MEDIA_V2)
     352    setMediaKeys(0);
     353#endif
     354
    351355    removeElementFromDocumentMap(this, document());
    352356}
     
    19951999void HTMLMediaElement::setMediaKeys(MediaKeys* mediaKeys)
    19962000{
     2001    if (m_mediaKeys == mediaKeys)
     2002        return;
     2003
     2004    if (m_mediaKeys)
     2005        m_mediaKeys->setMediaElement(0);
    19972006    m_mediaKeys = mediaKeys;
     2007    if (m_mediaKeys)
     2008        m_mediaKeys->setMediaElement(this);
    19982009}
    19992010#endif
  • tags/Safari-537.31.10/Source/WebCore/testing/MockCDM.cpp

    r144094 r144095  
    4040    virtual ~MockCDMSession() { }
    4141
    42     virtual const String& sessionId() OVERRIDE { return m_sessionId; }
     42    virtual const String& sessionId() const OVERRIDE { return m_sessionId; }
    4343    virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) OVERRIDE;
    4444    virtual void releaseKeys() OVERRIDE;
Note: See TracChangeset for help on using the changeset viewer.