Changeset 143259 in webkit


Ignore:
Timestamp:
Feb 18, 2013 1:37:54 PM (11 years ago)
Author:
jer.noble@apple.com
Message:

EME: Add a CDMPrivate implementation using AVFoundation.
https://bugs.webkit.org/show_bug.cgi?id=109739

Reviewed by Eric Carlson.

Add a CDMPrivate implementation using AVFoundation, similar to the EME v1 implementation
in MediaPlayerPrivateAVFoundationObjC. This requires passing the AVAssetResourceLoadingRequest
from the MediaPlayerPrivateAVFoundationObjC instance to CDMSessionAVFoundation. To do so
without adding platform-specific API to MediaPlayer, add a static map from MediaPlayer ->
MediaPlayerPrivateAVFoundationObjC instances to be used to vend the AVAssetResourceLoadingRequest
to CDMSessionAVFoundation.

  • Modules/encryptedmedia/CDM.cpp:

(WebCore::installedCDMFactories): Add the factory for CDMPrivateAVFoundation.

  • Modules/encryptedmedia/CDM.h:
  • Modules/encryptedmedia/CDMPrivateAVFoundation.h: Added.

(WebCore::CDMPrivateAVFoundation::create): Simple factory method.
(WebCore::CDMPrivateAVFoundation::~CDMPrivateAVFoundation): Simple virtual destructor.
(WebCore::CDMPrivateAVFoundation::cdm): Simple getter.
(WebCore::CDMPrivateAVFoundation::CDMPrivateAVFoundation): Simple constructor.

  • Modules/encryptedmedia/CDMPrivateAVFoundation.mm: Added.

(WebCore::CDMSessionAVFoundation::~CDMSessionAVFoundation): Simple destructor.
(WebCore::CDMPrivateAVFoundation::supportsKeySytem): Check whether the given key system is supported.
(WebCore::CDMPrivateAVFoundation::supportsMIMEType): Check whether the given MIME type is supported.
(WebCore::CDMPrivateAVFoundation::createSession): Return a new CDMSessionAVFoundation.
(WebCore::CDMSessionAVFoundation::CDMSessionAVFoundation): Simple constructor.
(WebCore::CDMSessionAVFoundation::generateKeyRequest): Retrieve the AVAssetResourceLoadingRequest

from the MediaPlayer, and use it to generate a key request.

(WebCore::CDMSessionAVFoundation::releaseKeys): No-op.
(WebCore::CDMSessionAVFoundation::update): Add the passed in key to the AVAssetResourceLoadingRequest.

  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::playerToPrivateMap): Lazily instantiate static map.
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Register with the playerToPrivateMap.
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC): Unregister from same.
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Also send keyNeeded event in ENCRYPTED_MEDIA_V2.
(WebCore::MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData): Convert this

method from file-static to class static.

(WebCore::MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI): Pull the AVAssetResourceLoadingRequest

from m_keyURIToRequestMap and return it, if present.

Location:
trunk/Source/WebCore
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143257 r143259  
     12013-02-18  Jer Noble  <jer.noble@apple.com>
     2
     3        EME: Add a CDMPrivate implementation using AVFoundation.
     4        https://bugs.webkit.org/show_bug.cgi?id=109739
     5
     6        Reviewed by Eric Carlson.
     7
     8        Add a CDMPrivate implementation using AVFoundation, similar to the EME v1 implementation
     9        in MediaPlayerPrivateAVFoundationObjC. This requires passing the AVAssetResourceLoadingRequest
     10        from the MediaPlayerPrivateAVFoundationObjC instance to CDMSessionAVFoundation. To do so
     11        without adding platform-specific API to MediaPlayer, add a static map from MediaPlayer ->
     12        MediaPlayerPrivateAVFoundationObjC instances to be used to vend the AVAssetResourceLoadingRequest
     13        to CDMSessionAVFoundation.
     14
     15        * Modules/encryptedmedia/CDM.cpp:
     16        (WebCore::installedCDMFactories): Add the factory for CDMPrivateAVFoundation.
     17        * Modules/encryptedmedia/CDM.h:
     18        * Modules/encryptedmedia/CDMPrivateAVFoundation.h: Added.
     19        (WebCore::CDMPrivateAVFoundation::create): Simple factory method.
     20        (WebCore::CDMPrivateAVFoundation::~CDMPrivateAVFoundation): Simple virtual destructor.
     21        (WebCore::CDMPrivateAVFoundation::cdm): Simple getter.
     22        (WebCore::CDMPrivateAVFoundation::CDMPrivateAVFoundation): Simple constructor.
     23        * Modules/encryptedmedia/CDMPrivateAVFoundation.mm: Added.
     24        (WebCore::CDMSessionAVFoundation::~CDMSessionAVFoundation): Simple destructor.
     25        (WebCore::CDMPrivateAVFoundation::supportsKeySytem): Check whether the given key system is supported.
     26        (WebCore::CDMPrivateAVFoundation::supportsMIMEType): Check whether the given MIME type is supported.
     27        (WebCore::CDMPrivateAVFoundation::createSession): Return a new CDMSessionAVFoundation.
     28        (WebCore::CDMSessionAVFoundation::CDMSessionAVFoundation): Simple constructor.
     29        (WebCore::CDMSessionAVFoundation::generateKeyRequest): Retrieve the AVAssetResourceLoadingRequest
     30            from the MediaPlayer, and use it to generate a key request.
     31        (WebCore::CDMSessionAVFoundation::releaseKeys): No-op.
     32        (WebCore::CDMSessionAVFoundation::update): Add the passed in key to the AVAssetResourceLoadingRequest.
     33        * WebCore.xcodeproj/project.pbxproj:
     34        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     35        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     36        (WebCore::playerToPrivateMap): Lazily instantiate static map.
     37        (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Register with the playerToPrivateMap.
     38        (WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC): Unregister from same.
     39        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Also send keyNeeded event in ENCRYPTED_MEDIA_V2.
     40        (WebCore::MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData): Convert this
     41            method from file-static to class static.
     42        (WebCore::MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI): Pull the AVAssetResourceLoadingRequest
     43            from m_keyURIToRequestMap and return it, if present.
     44
    1452013-02-18  Philip Rogers  <pdr@google.com>
    246
  • trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp

    r143072 r143259  
    3535#include <wtf/text/WTFString.h>
    3636
     37#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     38#include "CDMPrivateAVFoundation.h"
     39#endif
     40
    3741namespace WebCore {
    3842
     
    5862
    5963        // FIXME: initialize specific UA CDMs. http://webkit.org/b/109318, http://webkit.org/b/109320
     64#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     65        cdms.append(new CDMFactory(CDMPrivateAVFoundation::create, CDMPrivateAVFoundation::supportsKeySytem));
     66#endif
     67
    6068    }
    6169
  • trunk/Source/WebCore/Modules/encryptedmedia/CDM.h

    r143072 r143259  
    6464class CDM {
    6565public:
     66
     67    enum CDMErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError };
    6668    static bool supportsKeySystem(const String&);
    6769    static PassOwnPtr<CDM> create(const String& keySystem);
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r143230 r143259  
    60036003                CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; };
    60046004                CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */; };
     6005                CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */; };
    60056006                CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; };
    60066007                CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */; };
     
    1361213613                CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiagnosticLoggingKeys.cpp; sourceTree = "<group>"; };
    1361313614                CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingKeys.h; sourceTree = "<group>"; };
     13615                CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDMPrivateAVFoundation.h; path = Modules/encryptedmedia/CDMPrivateAVFoundation.h; sourceTree = "<group>"; };
     13616                CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMPrivateAVFoundation.mm; path = Modules/encryptedmedia/CDMPrivateAVFoundation.mm; sourceTree = "<group>"; };
    1361413617                CD4AC5281496AE2F0087C4EF /* Composite.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = Composite.wav; path = platform/audio/resources/Composite.wav; sourceTree = SOURCE_ROOT; };
    1361513618                CD4E0AFA11F7BC27009D3811 /* fullscreen.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = fullscreen.css; sourceTree = "<group>"; };
     
    2171321716                                CDA98E091603CD5900FEA3B1 /* CDM.cpp */,
    2171421717                                CDA98E0A1603CD5900FEA3B1 /* CDM.h */,
     21718                                CDA98E0C1603CF3C00FEA3B1 /* CDMPrivate.h */,
     21719                                CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */,
     21720                                CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */,
    2171521721                                CDA98DD516025BED00FEA3B1 /* MediaKeyMessageEvent.cpp */,
    2171621722                                CDA98DD616025BED00FEA3B1 /* MediaKeyMessageEvent.h */,
     
    2172521731                                CDA98DC816014F2C00FEA3B1 /* MediaKeySession.h */,
    2172621732                                CDA98DC916014F4000FEA3B1 /* MediaKeySession.idl */,
    21727                                 CDA98E0C1603CF3C00FEA3B1 /* Modules/encryptedmedia/CDMPrivate.h */,
    2172821733                        );
    2172921734                        name = encryptedmedia;
     
    2748927494                                8502AB490AD438C000378540 /* DOMSVGFEDiffuseLightingElement.mm in Sources */,
    2749027495                                8502AB4B0AD438C000378540 /* DOMSVGFEDisplacementMapElement.mm in Sources */,
     27496                                CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */,
    2749127497                                8502AB4D0AD438C000378540 /* DOMSVGFEDistantLightElement.mm in Sources */,
    2749227498                                4358E86B1360A21600E4748C /* DOMSVGFEDropShadowElement.mm in Sources */,
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r142327 r143259  
    7575#endif
    7676
     77#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
     78    static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate);
     79#endif
     80
     81#if ENABLE(ENCRYPTED_MEDIA_V2)
     82    static RetainPtr<AVAssetResourceLoadingRequest> takeRequestForPlayerAndKeyURI(MediaPlayer*, const String&);
     83#endif
     84
    7785private:
    7886    MediaPlayerPrivateAVFoundationObjC(MediaPlayer*);
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r142375 r143259  
    187187#endif
    188188
     189#if ENABLE(ENCRYPTED_MEDIA_V2)
     190typedef HashMap<MediaPlayer*, MediaPlayerPrivateAVFoundationObjC*> PlayerToPrivateMapType;
     191static PlayerToPrivateMapType& playerToPrivateMap()
     192{
     193    DEFINE_STATIC_LOCAL(PlayerToPrivateMapType, map, ());
     194    return map;
     195};
     196#endif
     197
     198
    189199PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationObjC::create(MediaPlayer* player)
    190200{
     
    214224#endif
    215225{
     226#if ENABLE(ENCRYPTED_MEDIA_V2)
     227    playerToPrivateMap().set(player, this);
     228#endif
    216229}
    217230
    218231MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC()
    219232{
     233#if ENABLE(ENCRYPTED_MEDIA_V2)
     234    playerToPrivateMap().remove(player());
     235#endif
    220236    cancelLoad();
    221237}
     
    871887    String keyURI = [[[avRequest request] URL] absoluteString];
    872888
    873 #if ENABLE(ENCRYPTED_MEDIA)
     889#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
    874890    if (scheme == "skd") {
    875891        // Create an initData with the following layout:
     
    883899        keyURIArray->setRange(keyURI.characters(), keyURI.length() / sizeof(unsigned char), 0);
    884900
     901#if ENABLE(ENCRYPTED_MEDIA)
    885902        if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
     903#elif ENABLE(ENCRYPTED_MEDIA_V2)
     904        RefPtr<Uint8Array> initData = Uint8Array::create(initDataBuffer, 0, initDataBuffer->byteLength());
     905        if (!player()->keyNeeded(initData.get()))
     906#endif
    886907            return false;
    887908
     
    11171138#endif
    11181139
    1119 #if ENABLE(ENCRYPTED_MEDIA)
    1120 
    1121 static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
     1140#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
     1141bool MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
    11221142{
    11231143    // initData should have the following layout:
     
    11681188    return true;
    11691189}
    1170 
     1190#endif
     1191
     1192#if ENABLE(ENCRYPTED_MEDIA)
    11711193MediaPlayer::MediaKeyException MediaPlayerPrivateAVFoundationObjC::generateKeyRequest(const String& keySystem, const unsigned char* initDataPtr, unsigned initDataLength)
    11721194{
     
    12421264    m_sessionIDToRequestMap.remove(sessionID);
    12431265    return MediaPlayer::NoError;
     1266}
     1267#endif
     1268
     1269#if ENABLE(ENCRYPTED_MEDIA_V2)
     1270RetainPtr<AVAssetResourceLoadingRequest> MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI(MediaPlayer* player, const String& keyURI)
     1271{
     1272    MediaPlayerPrivateAVFoundationObjC* _this = playerToPrivateMap().get(player);
     1273    if (!_this)
     1274        return nullptr;
     1275
     1276    return _this->m_keyURIToRequestMap.take(keyURI);
     1277
    12441278}
    12451279#endif
Note: See TracChangeset for help on using the changeset viewer.