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

Changeset 290153 in webkit


Ignore:
Timestamp:
Feb 18, 2022, 12:30:09 PM (5 years ago)
Author:
jer.noble@apple.com
Message:

[Cocoa] Make AVFoundationSPI.h robust against changes in system headers
​https://bugs.webkit.org/show_bug.cgi?id=236787
<rdar://89076606>

Reviewed by Eric Carlson.

Source/WebCore:

Wrap call-sites in #if HAVE() macros.

  • platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:

(WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::sessionForRequest const):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup):

Source/WebCore/PAL:

Follow-up: build problems still persist on certain platforms, so the "robustness"
changes made previously were not robust enough. The guards in AVFoundationSPI.h were
intended to ensure the definitions were present even on builds where the official API
is not supported. However, just because the API is not supported does not mean it's not
present, which leads to duplicate-interface build errors.

Fix the AVFoundationSPI.h pragmas to only define the classes and methods where those
objects are supported, and in parallel, wrap implementations which use those objects
in those same guards (making these checks compile-time in addition to runtime).

Move the declarations inside the #else (IOW, !USE(APPLE_INTERNAL_SDK)) block above,
and wrap each declaration in the correct HAVE() macro.

  • pal/spi/cocoa/AVFoundationSPI.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r290152 r290153  
     12022-02-18  Jer Noble  <jer.noble@apple.com>
     2
     3        [Cocoa] Make AVFoundationSPI.h robust against changes in system headers
     4        https://bugs.webkit.org/show_bug.cgi?id=236787
     5        <rdar://89076606>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Wrap call-sites in #if HAVE() macros.
     10
     11        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
     12        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
     13        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::sessionForRequest const):
     14        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
     15        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
     16        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
     17        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
     18        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup):
     19
    1202022-02-18  Gabriel Nava Marino  <gnavamarino@apple.com>
    221
  • trunk/Source/WebCore/PAL/ChangeLog

    r290149 r290153  
     12022-02-18  Jer Noble  <jer.noble@apple.com>
     2
     3        [Cocoa] Make AVFoundationSPI.h robust against changes in system headers
     4        https://bugs.webkit.org/show_bug.cgi?id=236787
     5        <rdar://89076606>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Follow-up: build problems still persist on certain platforms, so the "robustness"
     10        changes made previously were not robust enough. The guards in AVFoundationSPI.h were
     11        intended to ensure the definitions were present even on builds where the official API
     12        is not supported. However, just because the API is not supported does not mean it's not
     13        present, which leads to duplicate-interface build errors.
     14
     15        Fix the AVFoundationSPI.h pragmas to only define the classes and methods where those
     16        objects are supported, and in parallel, wrap implementations which use those objects
     17        in those same guards (making these checks compile-time in addition to runtime).
     18
     19        Move the declarations inside the #else (IOW, !USE(APPLE_INTERNAL_SDK)) block above,
     20        and wrap each declaration in the correct HAVE() macro.
     21
     22        * pal/spi/cocoa/AVFoundationSPI.h:
     23
    1242022-02-18  Brandon Stewart  <brandonstewart@apple.com>
    225
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h

    r290076 r290153  
    221221NS_ASSUME_NONNULL_END
    222222
    223 #endif // USE(APPLE_INTERNAL_SDK)
    224 
    225 #import <AVFoundation/AVPlayerLayer.h>
    226 
    227223#if HAVE(AVCONTENTKEYSESSION)
    228224
    229 #if !USE(APPLE_INTERNAL_SDK) || !HAVE(AVCONTENTKEYREPORTGROUP)
     225#if HAVE(AVCONTENTKEYREPORTGROUP)
    230226@interface AVContentKeyReportGroup : NSObject
    231227@property (readonly, nullable) NSData *contentProtectionSessionIdentifier;
    … …  
    241237#endif
    242238
    243 #if !USE(APPLE_INTERNAL_SDK) || !HAVE(AVCONTENTKEYSESSIONWILLOUTPUTBEOBSCURED)
     239#if HAVE(AVCONTENTKEYSESSIONWILLOUTPUTBEOBSCURED)
    244240@interface AVContentKeyRequest (OutputObscured)
    245241NS_ASSUME_NONNULL_BEGIN
    … …  
    249245#endif
    250246
    251 #if !USE(APPLE_INTERNAL_SDK) || !HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
     247#if HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
    252248typedef NS_ENUM(NSInteger, AVExternalContentProtectionStatus) {
    253249    AVExternalContentProtectionStatusPending      = 0,
    … …  
    262258
    263259#endif // HAVE(AVCONTENTKEYSESSION)
     260
     261#endif // USE(APPLE_INTERNAL_SDK)
     262
     263#import <AVFoundation/AVPlayerLayer.h>
    264264
    265265#if ENABLE(MEDIA_SOURCE) && !USE(APPLE_INTERNAL_SDK)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm

    r290108 r290153  
    5151
    5252static NSString * const InitializationDataTypeKey = @"InitializationDataType";
     53#if HAVE(AVCONTENTKEYREPORTGROUP)
    5354static NSString * const ContentKeyReportGroupKey = @"ContentKeyReportGroup";
     55#endif
    5456static const NSInteger SecurityLevelError = -42811;
    5557
    … …  
    147149}
    148150
     151#if HAVE(AVCONTENTKEYREPORTGROUP)
    149152- (void)contentKeySession:(AVContentKeySession *)session contentProtectionSessionIdentifierDidChangeForKeyGroup:(nullable AVContentKeyReportGroup *)reportGroup
    150153{
    … …  
    159162        _parent->groupSessionIdentifierChanged(reportGroup, reportGroup.contentProtectionSessionIdentifier);
    160163}
     164#endif
    161165
    162166- (void)contentKeySession:(AVContentKeySession *)session externalProtectionStatusDidChangeForContentKeyRequest:(AVContentKeyRequest *)keyRequest
    … …  
    248252        return nullptr;
    249253
     254#if HAVE(AVCONTENTKEYREPORTGROUP)
    250255    if (!PAL::getAVContentKeyReportGroupClass())
    251256        return nullptr;
     257#endif
    252258
    253259    auto storageURL = this->storageURL();
    … …  
    441447}
    442448
     449#if HAVE(AVCONTENTKEYREPORTGROUP)
    443450static AVContentKeyReportGroup* groupForRequest(AVContentKeyRequest* request)
    444451{
    … …  
    449456    return group;
    450457}
     458#endif
    451459
    452460void CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest(AVContentKeyRequest *request)
    … …  
    545553void CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup* group, NSData *sessionIdentifier)
    546554{
     555#if HAVE(AVCONTENTKEYREPORTGROUP)
    547556    if (group == [m_session defaultContentKeyGroup]) {
    548557        INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- default unused group identifier changed; dropping");
    … …  
    557566    ASSERT_NOT_REACHED();
    558567    ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- no responsible session; dropping");
     568#else
     569    UNUSED_PARAM(group);
     570    UNUSED_PARAM(sessionIdentifier);
     571#endif
    559572}
    560573
    … …  
    604617        return m_sessions[index].get();
    605618
     619#if HAVE(AVCONTENTKEYREPORTGROUP)
    606620    return sessionForGroup(groupForRequest(request));
    607 }
    608 
     621#else
     622    return nullptr;
     623#endif
     624}
     625
     626#if HAVE(AVCONTENTKEYREPORTGROUP)
    609627CDMInstanceSessionFairPlayStreamingAVFObjC* CDMInstanceFairPlayStreamingAVFObjC::sessionForGroup(AVContentKeyReportGroup* group) const
    610628{
    … …  
    617635    return nullptr;
    618636}
     637#endif
    619638
    620639bool CDMInstanceFairPlayStreamingAVFObjC::isAnyKeyUsable(const Keys& keys) const
    … …  
    726745    if (auto unexpectedRequest = m_instance->takeUnexpectedKeyRequestForInitializationData(initDataType, initData)) {
    727746        DEBUG_LOG_IF_POSSIBLE(LOGIDENTIFIER, " found unexpectedRequest matching initData");
     747#if HAVE(AVCONTENTKEYREPORTGROUP)
    728748        if (m_group) {
    729749            ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN
    … …  
    731751            ALLOW_NEW_API_WITHOUT_GUARDS_END
    732752        }
     753#endif
    733754        m_requestLicenseCallback = WTFMove(callback);
    734755        didProvideRequest(unexpectedRequest.get());
    … …  
    758779    m_requestLicenseCallback = WTFMove(callback);
    759780
     781#if HAVE(AVCONTENTKEYREPORTGROUP)
    760782    if (m_group) {
    761783        auto* options = @{ ContentKeyReportGroupKey: m_group.get(), InitializationDataTypeKey: (NSString*)initDataType };
    762784        [m_group processContentKeyRequestWithIdentifier:identifier.get() initializationData:initializationData.get() options:options];
    763     } else {
    764         auto* options = @{ InitializationDataTypeKey: (NSString*)initDataType };
    765         [m_session processContentKeyRequestWithIdentifier:identifier.get() initializationData:initializationData.get() options:options];
    766     }
     785        return;
     786    }
     787#endif
     788
     789    auto* options = @{ InitializationDataTypeKey: (NSString*)initDataType };
     790    [m_session processContentKeyRequestWithIdentifier:identifier.get() initializationData:initializationData.get() options:options];
    767791}
    768792
    … …  
    10121036void CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData(const String& sessionId, LicenseType licenseType, RemoveSessionDataCallback&& callback)
    10131037{
     1038#if HAVE(AVCONTENTKEYREPORTGROUP)
    10141039    if (m_group)
    10151040        [m_group expire];
    10161041    else
     1042#endif
    10171043        [m_session expire];
    10181044
    … …  
    11331159
    11341160                if (m_sessionId.isEmpty()) {
    1135                     auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier;
     1161                    NSData *sessionID = nullptr;
     1162#if HAVE(AVCONTENTKEYREPORTGROUP)
     1163                    if (m_group)
     1164                        sessionID = m_group.get().contentProtectionSessionIdentifier;
     1165                    else
     1166#endif
     1167                        sessionID = m_session.get().contentProtectionSessionIdentifier;
    11361168                    sessionIdentifierChanged(sessionID);
    11371169                }
    … …  
    14181450void CDMInstanceSessionFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup*, NSData *sessionIdentifier)
    14191451{
     1452#if HAVE(AVCONTENTKEYREPORTGROUP)
    14201453    sessionIdentifierChanged(sessionIdentifier);
     1454#else
     1455    UNUSED_PARAM(sessionIdentifier);
     1456#endif
    14211457}
    14221458
    … …  
    15081544#endif
    15091545
     1546#if HAVE(AVCONTENTKEYSESSIONWILLOUTPUTBEOBSCURED)
    15101547    // FIXME: AVFoundation requires a connection to the WindowServer in order to query the HDCP status of individual
    15111548    // displays. Passing in an empty NSArray will cause AVFoundation to fall back to a "minimum supported HDCP level"
    … …  
    15261563        return obscured ? CDMKeyStatus::OutputRestricted : CDMKeyStatus::Usable;
    15271564    }
     1565#endif
    15281566
    15291567    // Only use the non-request-specific "outputObscuredDueToInsufficientExternalProtection" status if
    … …  
    15491587bool CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup()
    15501588{
    1551     if (m_session || m_group)
     1589    if (m_session)
     1590        return true;
     1591
     1592#if HAVE(AVCONTENTKEYREPORTGROUP)
     1593    if (m_group)
    15521594        return true;
    15531595
    … …  
    15561598        return true;
    15571599    }
     1600#endif
    15581601
    15591602    auto storageURL = m_instance->storageURL();
Note: See TracChangeset for help on using the changeset viewer.