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

Changeset 242720 in webkit


Ignore:
Timestamp:
Mar 11, 2019, 11:30:11 AM (7 years ago)
Author:
jer.noble@apple.com
Message:

Use AVContentKeySession for "com.apple.fps.2_0" CDM version when AVStreamSession is absent
https://bugs.webkit.org/show_bug.cgi?id=195462
<rdar://problem/48712306>

Reviewed by Eric Carlson.

The difference between "com.apple.fps.2_0" and "3_0" is a protocol difference more than an
implementation difference. In "2_0", the "EME nitialization" data comes in the form of a "content
identifier", while the true initialization data is retrieved through a side channel directly from
the attached element. In "3_0", the "EME initialization data" is the exact initialization data
given by the parser, with no "content identifier" at all.

In the original implementation, the "2_0" used AVStreamSession, and "3_0" used AVContentKeySession,
but in the absense of AVStreamSession, those protocol differences are minor and can be implemented
using AVContentKeySession.

Changes:

  • Add a new helper struct in CDMPrivateMediaSourceAVFObjC that represents the parsed parameters of the CDM string.
  • Add an "initData()" accessor to SourceBufferPrivateAVFObjC so that the "2_0" path can implement the side channel access to the necessary initialization data.
  • Refactor some of the SPI code to not re-declare unnecessary APIs.
  • In CDMSessionAVContentKeySession::generateKeyRequest(), this function can never be called twice so it is a logical impossibility to have a certificate at this point. Remove all this if() code.
  • Modules/encryptedmedia/legacy/LegacyCDM.cpp:
  • platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h:
  • platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:

(WebCore::CDMPrivateMediaSourceAVFObjC::parseKeySystem):
(WebCore::queryDecoderAvailability):
(WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystem):
(WebCore::CDMPrivateMediaSourceAVFObjC::createSession):
(WebCore::validKeySystemRE): Deleted.

  • platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h:
  • platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:

(WebCore::CDMSessionAVContentKeySession::CDMSessionAVContentKeySession):
(WebCore::CDMSessionAVContentKeySession::generateKeyRequest):
(WebCore::CDMSessionAVContentKeySession::update):
(WebCore::CDMSessionAVContentKeySession::addParser):
(WebCore::CDMSessionAVContentKeySession::removeParser):
(WebCore::CDMSessionAVContentKeySession::contentKeySession):

  • platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h:
  • platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:

(WebCore::CDMSessionAVStreamSession::CDMSessionAVStreamSession):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession):

  • platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
  • platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:

(WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242714 r242720  
     12019-03-11  Jer Noble  <jer.noble@apple.com>
     2
     3        Use AVContentKeySession for "com.apple.fps.2_0" CDM version when AVStreamSession is absent
     4        https://bugs.webkit.org/show_bug.cgi?id=195462
     5        <rdar://problem/48712306>
     6
     7        Reviewed by Eric Carlson.
     8
     9        The difference between "com.apple.fps.2_0" and "3_0" is a protocol difference more than an
     10        implementation difference. In "2_0", the "EME nitialization" data comes in the form of a "content
     11        identifier", while the true initialization data is retrieved through a side channel directly from
     12        the attached element. In "3_0", the "EME initialization data" is the exact initialization data
     13        given by the parser, with no "content identifier" at all.
     14
     15        In the original implementation, the "2_0" used AVStreamSession, and "3_0" used AVContentKeySession,
     16        but in the absense of AVStreamSession, those protocol differences are minor and can be implemented
     17        using AVContentKeySession.
     18
     19        Changes:
     20
     21        - Add a new helper struct in CDMPrivateMediaSourceAVFObjC that represents the parsed parameters
     22          of the CDM string.
     23        - Add an "initData()" accessor to SourceBufferPrivateAVFObjC so that the "2_0" path can implement
     24          the side channel access to the necessary initialization data.
     25        - Refactor some of the SPI code to not re-declare unnecessary APIs.
     26        - In CDMSessionAVContentKeySession::generateKeyRequest(), this function can never be called twice
     27          so it is a logical impossibility to have a certificate at this point. Remove all this if() code.
     28
     29        * Modules/encryptedmedia/legacy/LegacyCDM.cpp:
     30        * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h:
     31        * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
     32        (WebCore::CDMPrivateMediaSourceAVFObjC::parseKeySystem):
     33        (WebCore::queryDecoderAvailability):
     34        (WebCore::CDMPrivateMediaSourceAVFObjC::supportsKeySystem):
     35        (WebCore::CDMPrivateMediaSourceAVFObjC::createSession):
     36        (WebCore::validKeySystemRE): Deleted.
     37        * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h:
     38        * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
     39        (WebCore::CDMSessionAVContentKeySession::CDMSessionAVContentKeySession):
     40        (WebCore::CDMSessionAVContentKeySession::generateKeyRequest):
     41        (WebCore::CDMSessionAVContentKeySession::update):
     42        (WebCore::CDMSessionAVContentKeySession::addParser):
     43        (WebCore::CDMSessionAVContentKeySession::removeParser):
     44        (WebCore::CDMSessionAVContentKeySession::contentKeySession):
     45        * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h:
     46        * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
     47        (WebCore::CDMSessionAVStreamSession::CDMSessionAVStreamSession):
     48        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     49        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     50        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession):
     51        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
     52        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
     53        (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID):
     54
    1552019-03-11  Ryan Haddad  <ryanhaddad@apple.com>
    256
  • trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.cpp

    r223728 r242720  
    3838#include <wtf/text/WTFString.h>
    3939
    40 #if PLATFORM(MAC) && ENABLE(MEDIA_SOURCE)
     40#if (HAVE(AVCONTENTKEYSESSION) || HAVE(AVSTREAMSESSION)) && ENABLE(MEDIA_SOURCE)
    4141#include "CDMPrivateMediaSourceAVFObjC.h"
    4242#endif
     
    6969            CDMPrivateMediaPlayer::supportsKeySystem, CDMPrivateMediaPlayer::supportsKeySystemAndMimeType),
    7070
    71 #if PLATFORM(MAC) && ENABLE(MEDIA_SOURCE)
     71#if (HAVE(AVCONTENTKEYSESSION) || HAVE(AVSTREAMSESSION)) && ENABLE(MEDIA_SOURCE)
    7272        new CDMFactory([](LegacyCDM* cdm) { return std::make_unique<CDMPrivateMediaSourceAVFObjC>(cdm); },
    7373            CDMPrivateMediaSourceAVFObjC::supportsKeySystem, CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType),
  • trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h

    r222946 r242720  
    5353
    5454    void invalidateSession(CDMSessionMediaSourceAVFObjC*);
    55 
    5655protected:
     56    struct KeySystemParameters {
     57        int version;
     58        Vector<int> protocols;
     59    };
     60    static Optional<KeySystemParameters> parseKeySystem(const String& keySystem);
     61   
    5762    LegacyCDM* m_cdm;
    5863    Vector<CDMSessionMediaSourceAVFObjC*> m_sessions;
  • trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm

    r240592 r242720  
    4444namespace WebCore {
    4545
    46 static RegularExpression& validKeySystemRE()
     46auto CDMPrivateMediaSourceAVFObjC::parseKeySystem(const String& keySystem) -> Optional<KeySystemParameters>
    4747{
    4848    static NeverDestroyed<RegularExpression> keySystemRE("^com\\.apple\\.fps\\.[23]_\\d+(?:,\\d+)*$", JSC::Yarr::TextCaseInsensitive);
    49     return keySystemRE;
     49
     50    if (keySystem.isEmpty())
     51        return WTF::nullopt;
     52   
     53    if (keySystemRE.get().match(keySystem) < 0)
     54        return WTF::nullopt;
     55   
     56    StringView keySystemView { keySystem };
     57
     58    int cdmVersion = keySystemView.substring(14, 1).toInt();
     59   
     60    Vector<int> protocolVersions;
     61    for (StringView protocolVersionString : keySystemView.substring(16).split(','))
     62        protocolVersions.append(protocolVersionString.toInt());
     63   
     64    return {{ cdmVersion, WTFMove(protocolVersions) }};
    5065}
    5166
     
    5974{
    6075    if (!canLoad_VideoToolbox_VTGetGVADecoderAvailability())
     76#if HAVE(AVSTREAMSESSION)
    6177        return false;
     78#else
     79        return true;
     80#endif
    6281    uint32_t totalInstanceCount = 0;
    6382    OSStatus status = VTGetGVADecoderAvailability(&totalInstanceCount, nullptr);
     
    7089        return false;
    7190
    72     if (!keySystem.isEmpty() && validKeySystemRE().match(keySystem) < 0)
     91    auto parameters = parseKeySystem(keySystem);
     92    if (!parameters)
    7393        return false;
    7494
    75     if (keySystem.substring(14, 1).toInt() == 3 && !CDMSessionAVContentKeySession::isAvailable())
     95    if (parameters.value().version == 3 && !CDMSessionAVContentKeySession::isAvailable())
    7696        return false;
    7797
     
    114134{
    115135    String keySystem = m_cdm->keySystem(); // Local copy for StringView usage
    116     StringView keySystemStringView { keySystem };
    117     ASSERT(validKeySystemRE().match(keySystem) >= 0);
    118 
    119     Vector<int> protocolVersions;
    120     for (StringView protocolVersionString : keySystemStringView.substring(16).split(','))
    121         protocolVersions.append(protocolVersionString.toInt());
     136    auto parameters = parseKeySystem(m_cdm->keySystem());
     137    ASSERT(parameters);
     138    if (!parameters)
     139        return nullptr;
    122140
    123141    std::unique_ptr<CDMSessionMediaSourceAVFObjC> session;
    124     if (keySystemStringView.substring(14, 1).toInt() == 3 && CDMSessionAVContentKeySession::isAvailable())
    125         session = std::make_unique<CDMSessionAVContentKeySession>(protocolVersions, *this, client);
     142   
     143#if HAVE(AVSTREAMSESSION)
     144    bool shouldUseAVContentKeySession = parameters.value().version == 3;
     145#else
     146    bool shouldUseAVContentKeySession = true;
     147#endif
     148   
     149    if (shouldUseAVContentKeySession && CDMSessionAVContentKeySession::isAvailable())
     150        session = std::make_unique<CDMSessionAVContentKeySession>(WTFMove(parameters.value().protocols), parameters.value().version, *this, client);
    126151    else
    127 #if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
    128         session = std::make_unique<CDMSessionAVStreamSession>(protocolVersions, *this, client);
     152#if HAVE(AVSTREAMSESSION)
     153        session = std::make_unique<CDMSessionAVStreamSession>(WTFMove(parameters.value().protocols), *this, client);
    129154#else
    130155        return nullptr;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h

    r241183 r242720  
    4444    WTF_MAKE_FAST_ALLOCATED;
    4545public:
    46     CDMSessionAVContentKeySession(const Vector<int>& protocolVersions, CDMPrivateMediaSourceAVFObjC&, LegacyCDMSessionClient*);
     46    CDMSessionAVContentKeySession(Vector<int>&& protocolVersions, int cdmVersion, CDMPrivateMediaSourceAVFObjC&, LegacyCDMSessionClient*);
    4747    virtual ~CDMSessionAVContentKeySession();
    4848
     
    7070    RetainPtr<WebCDMSessionAVContentKeySessionDelegate> m_contentKeySessionDelegate;
    7171    RetainPtr<AVContentKeyRequest> m_keyRequest;
     72    RefPtr<Uint8Array> m_identifier;
    7273    RefPtr<Uint8Array> m_initData;
    7374    RetainPtr<NSData> m_expiredSession;
    7475    Vector<int> m_protocolVersions;
     76    int m_cdmVersion;
    7577    int32_t m_protectedTrackID { 1 };
    7678    enum { Normal, KeyRelease } m_mode;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm

    r240437 r242720  
    3939#import <JavaScriptCore/TypedArrayInlines.h>
    4040#import <objc/objc-runtime.h>
     41#import <pal/spi/mac/AVFoundationSPI.h>
    4142#import <wtf/FileSystem.h>
    4243#import <wtf/SoftLinking.h>
     
    4546SOFT_LINK_CLASS(AVFoundation, AVStreamDataParser);
    4647SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVContentKeySession);
     48SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVContentKeyResponse);
    4749SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVContentKeyRequestProtocolVersionsKey, NSString *)
    4850SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVContentKeySystemFairPlayStreaming, NSString *)
     
    5052typedef NSString *AVContentKeySystem;
    5153
    52 @interface AVContentKeySession : NSObject
    53 + (instancetype)contentKeySessionWithKeySystem:(AVContentKeySystem)keySystem;
     54@interface AVContentKeySession (WebCorePrivate)
    5455- (instancetype)initWithStorageDirectoryAtURL:(NSURL *)storageURL;
    5556@property (assign) id delegate;
    5657- (void)addStreamDataParser:(AVStreamDataParser *)streamDataParser;
    5758- (void)removeStreamDataParser:(AVStreamDataParser *)streamDataParser;
    58 @property (readonly) NSArray *streamDataParsers;
    59 - (void)expire;
    60 @property (readonly) NSData *contentProtectionSessionIdentifier;
    6159- (void)processContentKeyRequestInitializationData:(NSData *)initializationData options:(NSDictionary *)options;
    62 + (NSArray *)pendingExpiredSessionReportsWithAppIdentifier:(NSData *)appIdentifier storageDirectoryAtURL:(NSURL *)storageURL;
    63 + (void)removePendingExpiredSessionReports:(NSArray *)expiredSessionReports withAppIdentifier:(NSData *)appIdentifier storageDirectoryAtURL:(NSURL *)storageURL;
    6460@end
    6561
    66 typedef NS_ENUM(NSInteger, AVContentKeyRequestStatus) {
    67     AVContentKeySessionStatusNoKey,
    68     AVContentKeySessionStatusRequestingKey,
    69     AVContentKeySessionStatusKeyPresent,
    70     AVContentKeySessionStatusExpired,
    71     AVContentKeySessionStatusFailed
    72 };
    73 
    74 @interface AVContentKeyRequest : NSObject
    75 @property (readonly) AVContentKeyRequestStatus status;
    76 @property (readonly) NSError *error;
    77 @property (readonly) NSData *initializationData;
     62@interface AVContentKeyRequest (WebCorePrivate)
    7863- (NSData *)contentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier options:(NSDictionary *)options error:(NSError **)outError;
    7964- (void)processContentKeyResponseData:(NSData *)contentKeyResponseData;
    80 - (void)processContentKeyResponseError:(NSError *)error;
    8165- (void)renewExpiringContentKeyResponseData;
    8266@end
    8367
    84 @interface WebCDMSessionAVContentKeySessionDelegate : NSObject {
     68@interface WebCDMSessionAVContentKeySessionDelegate : NSObject<AVContentKeySessionDelegate> {
    8569    WebCore::CDMSessionAVContentKeySession *m_parent;
    8670}
     
    125109namespace WebCore {
    126110
    127 CDMSessionAVContentKeySession::CDMSessionAVContentKeySession(const Vector<int>& protocolVersions, CDMPrivateMediaSourceAVFObjC& cdm, LegacyCDMSessionClient* client)
     111CDMSessionAVContentKeySession::CDMSessionAVContentKeySession(Vector<int>&& protocolVersions, int cdmVersion, CDMPrivateMediaSourceAVFObjC& cdm, LegacyCDMSessionClient* client)
    128112    : CDMSessionMediaSourceAVFObjC(cdm, client)
    129113    , m_contentKeySessionDelegate(adoptNS([[WebCDMSessionAVContentKeySessionDelegate alloc] initWithParent:this]))
    130     , m_protocolVersions(protocolVersions)
     114    , m_protocolVersions(WTFMove(protocolVersions))
     115    , m_cdmVersion(cdmVersion)
    131116    , m_mode(Normal)
    132117{
     
    157142    systemCode = 0;
    158143
    159     m_initData = initData;
    160 
    161144    if (equalLettersIgnoringASCIICase(mimeType, "keyrelease")) {
    162145        m_mode = KeyRelease;
     146        m_certificate = initData;
    163147        return generateKeyReleaseMessage(errorCode, systemCode);
    164148    }
    165149
    166     if (!m_certificate) {
    167         String certificateString("certificate"_s);
    168         auto array = Uint8Array::create(certificateString.length());
    169         for (unsigned i = 0, length = certificateString.length(); i < length; ++i)
    170             array->set(i, certificateString[i]);
    171         return WTFMove(array);
    172     }
    173 
    174     if (!m_keyRequest) {
    175         NSData* nsInitData = [NSData dataWithBytes:m_initData->data() length:m_initData->length()];
    176         [contentKeySession() processContentKeyRequestInitializationData:nsInitData options:nil];
    177     }
    178 
    179     return nullptr;
     150    if (m_cdmVersion == 2)
     151        m_identifier = initData;
     152    else
     153        m_initData = initData;
     154
     155    ASSERT(!m_certificate);
     156    String certificateString("certificate"_s);
     157    auto array = Uint8Array::create(certificateString.length());
     158    for (unsigned i = 0, length = certificateString.length(); i < length; ++i)
     159        array->set(i, certificateString[i]);
     160    return WTFMove(array);
    180161}
    181162
     
    269250    if (m_mode == KeyRelease)
    270251        return false;
     252   
     253    if (m_cdmVersion == 2) {
     254        // In the com.apple.fps.2_0 communication protocol, the client must first attach the
     255        // session to the protected SourceBuffer in order to get access to the initialization
     256        // data.
     257        RefPtr<SourceBufferPrivateAVFObjC> protectedSourceBuffer;
     258        for (auto& sourceBuffer : m_sourceBuffers) {
     259            if (sourceBuffer->protectedTrackID() != -1) {
     260                protectedSourceBuffer = sourceBuffer;
     261                break;
     262            }
     263        }
     264
     265        if (!protectedSourceBuffer) {
     266            errorCode = MediaPlayer::InvalidPlayerState;
     267            return false;
     268        }
     269       
     270        m_initData = protectedSourceBuffer->initData();
     271    }
    271272
    272273    if (!m_keyRequest) {
    273         NSData* nsInitData = [NSData dataWithBytes:m_initData->data() length:m_initData->length()];
    274         [contentKeySession() processContentKeyRequestInitializationData:nsInitData options:nil];
     274        NSData* nsInitData = m_initData ? [NSData dataWithBytes:m_initData->data() length:m_initData->length()] : nil;
     275        NSData* nsIdentifier = m_identifier ? [NSData dataWithBytes:m_identifier->data() length:m_identifier->length()] : nil;
     276        if ([contentKeySession() respondsToSelector:@selector(processContentKeyRequestWithIdentifier:initializationData:options:)])
     277            [contentKeySession() processContentKeyRequestWithIdentifier:nsIdentifier initializationData:nsInitData options:nil];
     278        else
     279            [contentKeySession() processContentKeyRequestInitializationData:nsInitData options:nil];
    275280    }
    276281
     
    294299        systemCode = 0;
    295300        NSError* error = nil;
    296         NSData* requestData = [m_keyRequest contentKeyRequestDataForApp:certificateData.get() contentIdentifier:nil options:options.get() error:&error];
     301        NSData* nsIdentifier = m_identifier ? [NSData dataWithBytes:m_identifier->data() length:m_identifier->length()] : m_keyRequest.get().identifier;
     302
     303        NSData* requestData = [m_keyRequest contentKeyRequestDataForApp:certificateData.get() contentIdentifier:nsIdentifier options:options.get() error:&error];
    297304        if (error) {
    298305            errorCode = LegacyCDM::DomainError;
     
    309316    systemCode = 0;
    310317    RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->data() length:key->length()]);
    311     [m_keyRequest processContentKeyResponseData:keyData.get()];
     318   
     319    if ([m_keyRequest respondsToSelector:@selector(processContentKeyResponse:)] && [getAVContentKeyResponseClass() respondsToSelector:@selector(contentKeyResponseWithFairPlayStreamingKeyResponseData:)])
     320        [m_keyRequest processContentKeyResponse:[getAVContentKeyResponseClass() contentKeyResponseWithFairPlayStreamingKeyResponseData:keyData.get()]];
     321    else
     322        [m_keyRequest processContentKeyResponseData:keyData.get()];
    312323
    313324    return true;
     
    316327void CDMSessionAVContentKeySession::addParser(AVStreamDataParser* parser)
    317328{
    318     [contentKeySession() addStreamDataParser:parser];
     329    if ([contentKeySession() respondsToSelector:@selector(addContentKeyRecipient:)])
     330        [contentKeySession() addContentKeyRecipient:parser];
     331    else
     332        [contentKeySession() addStreamDataParser:parser];
    319333}
    320334
    321335void CDMSessionAVContentKeySession::removeParser(AVStreamDataParser* parser)
    322336{
    323     [contentKeySession() removeStreamDataParser:parser];
     337    if ([contentKeySession() respondsToSelector:@selector(removeContentKeyRecipient:)])
     338        [contentKeySession() removeContentKeyRecipient:parser];
     339    else
     340        [contentKeySession() removeStreamDataParser:parser];
    324341}
    325342
     
    327344{
    328345    ASSERT(m_mode == KeyRelease);
    329     m_certificate = m_initData;
    330346    RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
    331347
     
    378394        }
    379395
    380         m_contentKeySession = adoptNS([allocAVContentKeySessionInstance() initWithStorageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]]);
     396        auto url = [NSURL fileURLWithPath:storagePath];
     397        if ([getAVContentKeySessionClass() respondsToSelector:@selector(contentKeySessionWithKeySystem:storageDirectoryAtURL:)] && canLoadAVContentKeySystemFairPlayStreaming())
     398            m_contentKeySession = [getAVContentKeySessionClass() contentKeySessionWithKeySystem:getAVContentKeySystemFairPlayStreaming() storageDirectoryAtURL:url];
     399        else
     400            m_contentKeySession = adoptNS([allocAVContentKeySessionInstance() initWithStorageDirectoryAtURL:url]);
    381401    }
    382402
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h

    r241183 r242720  
    4444    WTF_MAKE_FAST_ALLOCATED;
    4545public:
    46     CDMSessionAVStreamSession(const Vector<int>& protocolVersions, CDMPrivateMediaSourceAVFObjC&, LegacyCDMSessionClient*);
     46    CDMSessionAVStreamSession(Vector<int>&& protocolVersions, CDMPrivateMediaSourceAVFObjC&, LegacyCDMSessionClient*);
    4747    virtual ~CDMSessionAVStreamSession();
    4848
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm

    r240592 r242720  
    8888namespace WebCore {
    8989
    90 CDMSessionAVStreamSession::CDMSessionAVStreamSession(const Vector<int>& protocolVersions, CDMPrivateMediaSourceAVFObjC& cdm, LegacyCDMSessionClient* client)
     90CDMSessionAVStreamSession::CDMSessionAVStreamSession(Vector<int>&& protocolVersions, CDMPrivateMediaSourceAVFObjC& cdm, LegacyCDMSessionClient* client)
    9191    : CDMSessionMediaSourceAVFObjC(cdm, client)
    9292    , m_dataParserObserver(adoptNS([[WebCDMSessionAVStreamSessionObserver alloc] initWithParent:this]))
    93     , m_protocolVersions(protocolVersions)
     93    , m_protocolVersions(WTFMove(protocolVersions))
    9494    , m_mode(Normal)
    9595{
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r241148 r242720  
    116116    void syncTextTrackBounds() override;
    117117   
    118 #if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
     118#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     119#if HAVE(AVSTREAMSESSION)
    119120    bool hasStreamSession() { return m_streamSession; }
    120121    AVStreamSession *streamSession();
     122#endif
    121123    void setCDMSession(LegacyCDMSession*) override;
    122124    CDMSessionMediaSourceAVFObjC* cdmSession() const { return m_session.get(); }
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r241148 r242720  
    934934}
    935935
    936 #if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
     936#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     937#if HAVE(AVSTREAMSESSION)
    937938AVStreamSession* MediaPlayerPrivateMediaSourceAVFObjC::streamSession()
    938939{
     
    955956    return m_streamSession.get();
    956957}
     958#endif
    957959
    958960void MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession(LegacyCDMSession* session)
     
    965967    m_session = makeWeakPtr(toCDMSessionMediaSourceAVFObjC(session));
    966968
     969#if HAVE(AVSTREAMSESSION)
    967970    if (CDMSessionAVStreamSession* cdmStreamSession = toCDMSessionAVStreamSession(m_session.get()))
    968971        cdmStreamSession->setStreamSession(streamSession());
     972#endif
     973
    969974    for (auto& sourceBuffer : m_mediaSourcePrivate->sourceBuffers())
    970975        sourceBuffer->setCDMSession(m_session.get());
    971976}
    972 #endif // HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
     977#endif // ENABLE(LEGACY_ENCRYPTED_MEDIA)
    973978
    974979#if ENABLE(LEGACY_ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h

    r241148 r242720  
    134134
    135135    void bufferWasConsumed();
     136   
     137#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     138    Uint8Array* initData() { return m_initData.get(); }
     139#endif
    136140
    137141#if !RELEASE_LOG_DISABLED
     
    197201    SourceBufferPrivateClient* m_client { nullptr };
    198202#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     203    RefPtr<Uint8Array> m_initData;
    199204    WeakPtr<CDMSessionMediaSourceAVFObjC> m_session { nullptr };
    200205#endif
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm

    r242631 r242720  
    662662        return;
    663663
    664 #if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
     664#if HAVE(AVCONTENTKEYSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
    665665    ALWAYS_LOG(LOGIDENTIFIER, "track = ", trackID);
    666666
    667667    m_protectedTrackID = trackID;
    668     auto initDataArray = Uint8Array::create([initData length]);
    669     [initData getBytes:initDataArray->data() length:initDataArray->length()];
    670     m_mediaSource->sourceBufferKeyNeeded(this, initDataArray.ptr());
     668    m_initData = Uint8Array::create([initData length]);
     669    [initData getBytes:m_initData->data() length:m_initData->length()];
     670    m_mediaSource->sourceBufferKeyNeeded(this, m_initData.get());
    671671    if (auto session = m_mediaSource->player()->cdmSession()) {
    672672        session->addParser(m_parser.get());
Note: See TracChangeset for help on using the changeset viewer.