Changeset 195410 in webkit


Ignore:
Timestamp:
Jan 21, 2016 9:15:16 AM (8 years ago)
Author:
jer.noble@apple.com
Message:

[EME] Correctly report errors when generating key requests from AVContentKeySession.
https://bugs.webkit.org/show_bug.cgi?id=151963

Reviewed by Eric Carlson.

WebIDL's "unsigned long" is a 32-bit unsigned integer, and C++'s "unsigned long" is (or, can
be) a 64-bit integer on 64-bit platforms. Casting a negative integer to a 64-bit integer
results in a number which cannot be accurately stored in a double-length floating point
number. Previously, the mac CDM code would work around this issue by returning the absolute
value of NSError code returned by media frameworks. Instead, fix the underlying problem by
storing the MediaKeyError's systemCode as a uint32_t (which more accurately represents the
size of a WebIDL "unsigned long" on all platforms.)

Check the error code issued by -contentKeyRequestDataForApp:contentIdentifier:options:error:.

  • Modules/encryptedmedia/CDM.h:
  • Modules/encryptedmedia/CDMSessionClearKey.cpp:

(WebCore::CDMSessionClearKey::generateKeyRequest):
(WebCore::CDMSessionClearKey::update):

  • Modules/encryptedmedia/CDMSessionClearKey.h:
  • Modules/encryptedmedia/MediaKeySession.cpp:

(WebCore::MediaKeySession::keyRequestTimerFired):
(WebCore::MediaKeySession::addKeyTimerFired):
(WebCore::MediaKeySession::sendError):

  • Modules/encryptedmedia/MediaKeySession.h:
  • Modules/mediacontrols/mediaControlsApple.js:

(Controller.prototype.handleReadyStateChange):

  • WebCore.xcodeproj/project.pbxproj:
  • html/MediaKeyError.h:

(WebCore::MediaKeyError::create):
(WebCore::MediaKeyError::systemCode):

  • html/MediaKeyEvent.h:
  • platform/graphics/CDMSession.h:
  • platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:

(WebCore::CDMSessionAVFoundationCF::generateKeyRequest):
(WebCore::CDMSessionAVFoundationCF::update):

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

(WebCore::CDMSessionAVContentKeySession::generateKeyRequest):
(WebCore::CDMSessionAVContentKeySession::update):
(WebCore::CDMSessionAVContentKeySession::generateKeyReleaseMessage):

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

(WebCore::CDMSessionAVFoundationObjC::generateKeyRequest):
(WebCore::CDMSessionAVFoundationObjC::update):

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

(WebCore::CDMSessionAVStreamSession::generateKeyRequest):
(WebCore::CDMSessionAVStreamSession::update):
(WebCore::CDMSessionAVStreamSession::generateKeyReleaseMessage):

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

(WebCore::CDMSessionMediaSourceAVFObjC::layerDidReceiveError):
(WebCore::CDMSessionMediaSourceAVFObjC::rendererDidReceiveError):
(WebCore::CDMSessionMediaSourceAVFObjC::systemCodeForError): Deleted.

  • testing/MockCDM.cpp:

(WebCore::MockCDMSession::generateKeyRequest):
(WebCore::MockCDMSession::update):2016-01-15 Simon Fraser <Simon Fraser>

Location:
trunk/Source/WebCore
Files:
21 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195406 r195410  
     12016-01-21  Jer Noble  <jer.noble@apple.com>
     2
     3        [EME] Correctly report errors when generating key requests from AVContentKeySession.
     4        https://bugs.webkit.org/show_bug.cgi?id=151963
     5
     6        Reviewed by Eric Carlson.
     7
     8        WebIDL's "unsigned long" is a 32-bit unsigned integer, and C++'s "unsigned long" is (or, can
     9        be) a 64-bit integer on 64-bit platforms. Casting a negative integer to a 64-bit integer
     10        results in a number which cannot be accurately stored in a double-length floating point
     11        number. Previously, the mac CDM code would work around this issue by returning the absolute
     12        value of NSError code returned by media frameworks. Instead, fix the underlying problem by
     13        storing the MediaKeyError's systemCode as a uint32_t (which more accurately represents the
     14        size of a WebIDL "unsigned long" on all platforms.)
     15
     16        Check the error code issued by -contentKeyRequestDataForApp:contentIdentifier:options:error:.
     17
     18        * Modules/encryptedmedia/CDM.h:
     19        * Modules/encryptedmedia/CDMSessionClearKey.cpp:
     20        (WebCore::CDMSessionClearKey::generateKeyRequest):
     21        (WebCore::CDMSessionClearKey::update):
     22        * Modules/encryptedmedia/CDMSessionClearKey.h:
     23        * Modules/encryptedmedia/MediaKeySession.cpp:
     24        (WebCore::MediaKeySession::keyRequestTimerFired):
     25        (WebCore::MediaKeySession::addKeyTimerFired):
     26        (WebCore::MediaKeySession::sendError):
     27        * Modules/encryptedmedia/MediaKeySession.h:
     28        * Modules/mediacontrols/mediaControlsApple.js:
     29        (Controller.prototype.handleReadyStateChange):
     30        * WebCore.xcodeproj/project.pbxproj:
     31        * html/MediaKeyError.h:
     32        (WebCore::MediaKeyError::create):
     33        (WebCore::MediaKeyError::systemCode):
     34        * html/MediaKeyEvent.h:
     35        * platform/graphics/CDMSession.h:
     36        * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
     37        (WebCore::CDMSessionAVFoundationCF::generateKeyRequest):
     38        (WebCore::CDMSessionAVFoundationCF::update):
     39        * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h:
     40        * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h:
     41        * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
     42        (WebCore::CDMSessionAVContentKeySession::generateKeyRequest):
     43        (WebCore::CDMSessionAVContentKeySession::update):
     44        (WebCore::CDMSessionAVContentKeySession::generateKeyReleaseMessage):
     45        * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h:
     46        * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
     47        (WebCore::CDMSessionAVFoundationObjC::generateKeyRequest):
     48        (WebCore::CDMSessionAVFoundationObjC::update):
     49        * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h:
     50        * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
     51        (WebCore::CDMSessionAVStreamSession::generateKeyRequest):
     52        (WebCore::CDMSessionAVStreamSession::update):
     53        (WebCore::CDMSessionAVStreamSession::generateKeyReleaseMessage):
     54        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h:
     55        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
     56        (WebCore::CDMSessionMediaSourceAVFObjC::layerDidReceiveError):
     57        (WebCore::CDMSessionMediaSourceAVFObjC::rendererDidReceiveError):
     58        (WebCore::CDMSessionMediaSourceAVFObjC::systemCodeForError): Deleted.
     59        * testing/MockCDM.cpp:
     60        (WebCore::MockCDMSession::generateKeyRequest):
     61        (WebCore::MockCDMSession::update):2016-01-15  Simon Fraser  <simon.fraser@apple.com>
     62
    1632016-01-21  Carlos Garcia Campos  <cgarcia@igalia.com>
    264
  • trunk/Source/WebCore/Modules/encryptedmedia/CDM.h

    r195335 r195410  
    5656    explicit CDM(const String& keySystem);
    5757
    58     enum CDMErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError };
     58    enum CDMErrorCode { NoError, UnknownError, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError };
    5959    static bool supportsKeySystem(const String&);
    6060    static bool keySystemSupportsMimeType(const String& keySystem, const String& mimeType);
  • trunk/Source/WebCore/Modules/encryptedmedia/CDMSessionClearKey.cpp

    r195335 r195410  
    7070}
    7171
    72 RefPtr<Uint8Array> CDMSessionClearKey::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
     72RefPtr<Uint8Array> CDMSessionClearKey::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
    7373{
    7474    UNUSED_PARAM(mimeType);
     
    9797}
    9898
    99 bool CDMSessionClearKey::update(Uint8Array* rawKeysData, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
     99bool CDMSessionClearKey::update(Uint8Array* rawKeysData, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode)
    100100{
    101101    UNUSED_PARAM(nextMessage);
  • trunk/Source/WebCore/Modules/encryptedmedia/CDMSessionClearKey.h

    r195335 r195410  
    4343    virtual void setClient(CDMSessionClient* client) override { m_client = client; }
    4444    virtual const String& sessionId() const override { return m_sessionId; }
    45     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array*, String&, unsigned short&, unsigned long&) override;
     45    virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array*, String&, unsigned short&, uint32_t&) override;
    4646    virtual void releaseKeys() override;
    47     virtual bool update(Uint8Array*, RefPtr<Uint8Array>&, unsigned short&, unsigned long&) override;
     47    virtual bool update(Uint8Array*, RefPtr<Uint8Array>&, unsigned short&, uint32_t&) override;
    4848    virtual RefPtr<ArrayBuffer> cachedKeyForKeyID(const String&) const override;
    4949
  • trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp

    r195335 r195410  
    112112        String destinationURL;
    113113        MediaKeyError::Code errorCode = 0;
    114         unsigned long systemCode = 0;
     114        uint32_t systemCode = 0;
    115115
    116116        // 3. Use cdm to generate a key request and follow the steps for the first matching condition from the following list:
     
    164164        RefPtr<Uint8Array> pendingKey = m_pendingKeys.takeFirst();
    165165        unsigned short errorCode = 0;
    166         unsigned long systemCode = 0;
     166        uint32_t systemCode = 0;
    167167
    168168        // NOTE: Continued from step 2. of MediaKeySession::update()
     
    220220}
    221221
    222 void MediaKeySession::sendError(CDMSessionClient::MediaKeyErrorCode errorCode, unsigned long systemCode)
     222void MediaKeySession::sendError(CDMSessionClient::MediaKeyErrorCode errorCode, uint32_t systemCode)
    223223{
    224224    Ref<MediaKeyError> error = MediaKeyError::create(errorCode, systemCode).get();
  • trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h

    r195335 r195410  
    8787    // CDMSessionClient
    8888    virtual void sendMessage(Uint8Array*, String destinationURL) override;
    89     virtual void sendError(MediaKeyErrorCode, unsigned long systemCode) override;
     89    virtual void sendError(MediaKeyErrorCode, uint32_t systemCode) override;
    9090    virtual String mediaKeysStorageDirectory() const override;
    9191
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r195356 r195410  
    60686068                CDC8B5AB18047FF10016E685 /* SourceBufferPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */; };
    60696069                CDC8B5AD1804AE5D0016E685 /* SourceBufferPrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */; };
     6070                CDC979F41C498C0900DB50D4 /* WebCoreNSErrorExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC979F21C498C0900DB50D4 /* WebCoreNSErrorExtras.mm */; };
     6071                CDC979F51C498C0900DB50D4 /* WebCoreNSErrorExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC979F31C498C0900DB50D4 /* WebCoreNSErrorExtras.h */; };
    60706072                CDCA82961679100F00875714 /* TextTrackRepresentationIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCA82941679100F00875714 /* TextTrackRepresentationIOS.mm */; };
    60716073                CDCA98EB18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDCA98EA18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp */; };
     
    1394613948                CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivateAVFObjC.h; sourceTree = "<group>"; };
    1394713949                CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivateClient.h; sourceTree = "<group>"; };
     13950                CDC979F21C498C0900DB50D4 /* WebCoreNSErrorExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSErrorExtras.mm; sourceTree = "<group>"; };
     13951                CDC979F31C498C0900DB50D4 /* WebCoreNSErrorExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreNSErrorExtras.h; sourceTree = "<group>"; };
    1394813952                CDCA82941679100F00875714 /* TextTrackRepresentationIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextTrackRepresentationIOS.mm; sourceTree = "<group>"; };
    1394913953                CDCA98E918B2C8D000C12FF9 /* CDMPrivateMediaPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMPrivateMediaPlayer.h; sourceTree = "<group>"; };
     
    1974719751                                310D71941B335C9D009C7B73 /* ThemeCocoa.h */,
    1974819752                                46DB7D561B20FE3C005651B2 /* VNodeTrackerCocoa.cpp */,
     19753                                CDC979F21C498C0900DB50D4 /* WebCoreNSErrorExtras.mm */,
     19754                                CDC979F31C498C0900DB50D4 /* WebCoreNSErrorExtras.h */,
    1974919755                        );
    1975019756                        path = cocoa;
     
    2663426640                                BC5EBA110E823E4700B25965 /* KeyframeList.h in Headers */,
    2663526641                                E15FF7D518C9553800FE4C87 /* KeypressCommand.h in Headers */,
     26642                                CDC979F51C498C0900DB50D4 /* WebCoreNSErrorExtras.h in Headers */,
    2663626643                                521D46F811AEC9B100514613 /* KillRing.h in Headers */,
    2663726644                                450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */,
     
    2883728844                                BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */,
    2883828845                                49AE2D8E134EE50C0072920A /* CSSCalculationValue.cpp in Sources */,
     28846                                CDC979F41C498C0900DB50D4 /* WebCoreNSErrorExtras.mm in Sources */,
    2883928847                                BC604A430DB5634E00204739 /* CSSCanvasValue.cpp in Sources */,
    2884028848                                E1EBBBD40AAC9B87001FE8E2 /* CSSCharsetRule.cpp in Sources */,
  • trunk/Source/WebCore/html/MediaKeyError.h

    r195335 r195410  
    4747    typedef unsigned short Code;
    4848
    49     static Ref<MediaKeyError> create(Code code, unsigned long systemCode = 0) { return adoptRef(*new MediaKeyError(code, systemCode)); }
     49    static Ref<MediaKeyError> create(Code code, uint32_t systemCode = 0) { return adoptRef(*new MediaKeyError(code, systemCode)); }
    5050
    5151    Code code() const { return m_code; }
    52     unsigned long systemCode() { return m_systemCode; }
     52    uint32_t systemCode() { return m_systemCode; }
    5353
    5454private:
  • trunk/Source/WebCore/html/MediaKeyEvent.h

    r195335 r195410  
    4343    String defaultURL;
    4444    RefPtr<MediaKeyError> errorCode;
    45     unsigned short systemCode;
     45    uint32_t systemCode;
    4646};
    4747
  • trunk/Source/WebCore/platform/cocoa/WebCoreNSErrorExtras.h

    r195409 r195410  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef CDMSessionClearKey_h
    27 #define CDMSessionClearKey_h
    28 
    29 #include "CDMSession.h"
    30 #include <wtf/HashMap.h>
    31 
    32 #if ENABLE(ENCRYPTED_MEDIA_V2)
     26#ifndef WebCoreNSErrorExtras_h
     27#define WebCoreNSErrorExtras_h
    3328
    3429namespace WebCore {
    3530
    36 class CDMSessionClearKey : public CDMSession {
    37 public:
    38     CDMSessionClearKey(CDMSessionClient*);
    39     virtual ~CDMSessionClearKey();
    40 
    41     // CDMSessionPrivate
    42     virtual CDMSessionType type() override { return CDMSessionTypeClearKey; }
    43     virtual void setClient(CDMSessionClient* client) override { m_client = client; }
    44     virtual const String& sessionId() const override { return m_sessionId; }
    45     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array*, String&, unsigned short&, unsigned long&) override;
    46     virtual void releaseKeys() override;
    47     virtual bool update(Uint8Array*, RefPtr<Uint8Array>&, unsigned short&, unsigned long&) override;
    48     virtual RefPtr<ArrayBuffer> cachedKeyForKeyID(const String&) const override;
    49 
    50 protected:
    51     CDMSessionClient* m_client;
    52     RefPtr<Uint8Array> m_initData;
    53     HashMap<String, Vector<uint8_t>> m_cachedKeys;
    54     String m_sessionId;
    55 };
     31WEBCORE_EXPORT long mediaKeyErrorSystemCode(NSError *);
    5632
    5733}
    5834
    59 #endif // ENABLE(ENCRYPTED_MEDIA_V2)
    60 
    61 #endif // CDMSessionClearKey_h
     35#endif // WebCoreNSErrorExtras_h
  • trunk/Source/WebCore/platform/cocoa/WebCoreNSErrorExtras.mm

    r195409 r195410  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
    3  *
     2 * Copyright (C) 2016 Apple Inc. All rights reserved.
     3 * 
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions
     
    2424 */
    2525
    26 #ifndef CDMSessionClearKey_h
    27 #define CDMSessionClearKey_h
     26#import "config.h"
     27#import "WebCoreNSErrorExtras.h"
    2828
    29 #include "CDMSession.h"
    30 #include <wtf/HashMap.h>
    31 
    32 #if ENABLE(ENCRYPTED_MEDIA_V2)
     29#import <AVFoundation/AVError.h>
    3330
    3431namespace WebCore {
    3532
    36 class CDMSessionClearKey : public CDMSession {
    37 public:
    38     CDMSessionClearKey(CDMSessionClient*);
    39     virtual ~CDMSessionClearKey();
     33long mediaKeyErrorSystemCode(NSError *error)
     34{
     35    NSInteger code = [error code];
    4036
    41     // CDMSessionPrivate
    42     virtual CDMSessionType type() override { return CDMSessionTypeClearKey; }
    43     virtual void setClient(CDMSessionClient* client) override { m_client = client; }
    44     virtual const String& sessionId() const override { return m_sessionId; }
    45     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array*, String&, unsigned short&, unsigned long&) override;
    46     virtual void releaseKeys() override;
    47     virtual bool update(Uint8Array*, RefPtr<Uint8Array>&, unsigned short&, unsigned long&) override;
    48     virtual RefPtr<ArrayBuffer> cachedKeyForKeyID(const String&) const override;
     37    if (code == AVErrorUnknown) {
     38        NSError* underlyingError = [error.userInfo valueForKey:NSUnderlyingErrorKey];
     39        if (underlyingError && [underlyingError isKindOfClass:[NSError class]])
     40            return [underlyingError code];
     41    }
    4942
    50 protected:
    51     CDMSessionClient* m_client;
    52     RefPtr<Uint8Array> m_initData;
    53     HashMap<String, Vector<uint8_t>> m_cachedKeys;
    54     String m_sessionId;
    55 };
     43    return code;
     44}
    5645
    5746}
    58 
    59 #endif // ENABLE(ENCRYPTED_MEDIA_V2)
    60 
    61 #endif // CDMSessionClearKey_h
  • trunk/Source/WebCore/platform/graphics/CDMSession.h

    r195335 r195410  
    5050    };
    5151    typedef unsigned short MediaKeyErrorCode;
    52     virtual void sendError(MediaKeyErrorCode, unsigned long systemCode) = 0;
     52    virtual void sendError(MediaKeyErrorCode, uint32_t systemCode) = 0;
    5353
    5454    virtual String mediaKeysStorageDirectory() const = 0;
     
    7171    virtual void setClient(CDMSessionClient*) = 0;
    7272    virtual const String& sessionId() const = 0;
    73     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) = 0;
     73    virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) = 0;
    7474    virtual void releaseKeys() = 0;
    75     virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) = 0;
     75    virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) = 0;
    7676    virtual RefPtr<ArrayBuffer> cachedKeyForKeyID(const String&) const { return nullptr; }
    7777};
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp

    r193482 r195410  
    5252}
    5353
    54 RefPtr<Uint8Array> CDMSessionAVFoundationCF::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
     54RefPtr<Uint8Array> CDMSessionAVFoundationCF::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
    5555{
    5656    UNUSED_PARAM(mimeType);
     
    108108}
    109109
    110 bool CDMSessionAVFoundationCF::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
     110bool CDMSessionAVFoundationCF::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode)
    111111{
    112112    RetainPtr<CFMutableDataRef> keyData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, key->byteLength()));
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h

    r193482 r195410  
    4545    virtual void setClient(CDMSessionClient* client) override { m_client = client; }
    4646    virtual const String& sessionId() const override { return m_sessionId; }
    47     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) override;
     47    virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override;
    4848    virtual void releaseKeys() override;
    49     virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override;
     49    virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override;
    5050
    5151protected:
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h

    r195335 r195410  
    5050    // CDMSession
    5151    virtual CDMSessionType type() override { return CDMSessionTypeAVContentKeySession; }
    52     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) override;
     52    virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override;
    5353    virtual void releaseKeys() override;
    54     virtual bool update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override;
     54    virtual bool update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override;
    5555
    5656    // CDMSessionMediaSourceAVFObjC
     
    6161
    6262protected:
    63     PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, unsigned long& systemCode);
     63    PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, uint32_t& systemCode);
    6464
    6565    bool hasContentKeySession() const { return m_contentKeySession; }
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm

    r195335 r195410  
    3838#import "SourceBufferPrivateAVFObjC.h"
    3939#import "UUID.h"
     40#import "WebCoreNSErrorExtras.h"
    4041#import <AVFoundation/AVError.h>
    4142#import <CoreMedia/CMBase.h>
    42 #import <cstdlib>
    4343#import <objc/objc-runtime.h>
    4444#import <runtime/TypedArrayInlines.h>
     
    145145}
    146146
    147 RefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
     147RefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
    148148{
    149149    UNUSED_PARAM(mimeType);
     
    229229}
    230230
    231 bool CDMSessionAVContentKeySession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
     231bool CDMSessionAVContentKeySession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode)
    232232{
    233233    UNUSED_PARAM(nextMessage);
     
    282282        errorCode = MediaPlayer::NoError;
    283283        systemCode = 0;
    284         NSData* requestData = [m_keyRequest contentKeyRequestDataForApp:certificateData.get() contentIdentifier:nil options:options.get() error:nil];
     284        NSError* error = nil;
     285        NSData* requestData = [m_keyRequest contentKeyRequestDataForApp:certificateData.get() contentIdentifier:nil options:options.get() error:&error];
     286        if (error) {
     287            errorCode = MediaPlayerClient::DomainError;
     288            systemCode = mediaKeyErrorSystemCode(error);
     289            return false;
     290        }
     291
    285292        nextMessage = Uint8Array::create(static_cast<const uint8_t*>([requestData bytes]), [requestData length]);
    286 
    287293        return false;
    288294    }
     
    307313}
    308314
    309 PassRefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyReleaseMessage(unsigned short& errorCode, unsigned long& systemCode)
     315PassRefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyReleaseMessage(unsigned short& errorCode, uint32_t& systemCode)
    310316{
    311317    ASSERT(m_mode == KeyRelease);
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h

    r195335 r195410  
    4646    virtual void setClient(CDMSessionClient* client) override { m_client = client; }
    4747    virtual const String& sessionId() const override { return m_sessionId; }
    48     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) override;
     48    virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override;
    4949    virtual void releaseKeys() override;
    50     virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override;
     50    virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override;
    5151
    5252protected:
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm

    r195335 r195410  
    3636#import "SoftLinking.h"
    3737#import "UUID.h"
     38#import "WebCoreNSErrorExtras.h"
    3839#import <AVFoundation/AVFoundation.h>
    3940#import <objc/objc-runtime.h>
     
    5455}
    5556
    56 RefPtr<Uint8Array> CDMSessionAVFoundationObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
     57RefPtr<Uint8Array> CDMSessionAVFoundationObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
    5758{
    5859    UNUSED_PARAM(mimeType);
     
    6263    RefPtr<Uint8Array> certificate;
    6364    if (!MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(initData, keyURI, keyID, certificate)) {
    64         errorCode = MediaPlayer::InvalidPlayerState;
     65        errorCode = CDM::UnknownError;
    6566        return nullptr;
    6667    }
     
    6869    m_request = m_parent->takeRequestForKeyURI(keyURI);
    6970    if (!m_request) {
    70         errorCode = MediaPlayer::InvalidPlayerState;
     71        errorCode = CDM::UnknownError;
    7172        return nullptr;
    7273    }
     
    7980
    8081    if (!keyRequest) {
    81         NSError* underlyingError = [[nsError userInfo] objectForKey:NSUnderlyingErrorKey];
    82         systemCode = [underlyingError code];
     82        errorCode = CDM::DomainError;
     83        systemCode = mediaKeyErrorSystemCode(nsError);
    8384        return nullptr;
    8485    }
     
    9697}
    9798
    98 bool CDMSessionAVFoundationObjC::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
     99bool CDMSessionAVFoundationObjC::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode)
    99100{
    100101    RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->baseAddress() length:key->byteLength()]);
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h

    r195335 r195410  
    4848    // CDMSession
    4949    virtual CDMSessionType type() override { return CDMSessionTypeAVStreamSession; }
    50     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) override;
     50    virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override;
    5151    virtual void releaseKeys() override;
    52     virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override;
     52    virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override;
    5353
    5454    // CDMSessionMediaSourceAVFObjC
     
    5959
    6060protected:
    61     PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, unsigned long& systemCode);
     61    PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, uint32_t systemCode);
    6262
    6363    WeakPtrFactory<CDMSessionAVStreamSession> m_weakPtrFactory;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm

    r195335 r195410  
    3838#import "SourceBufferPrivateAVFObjC.h"
    3939#import "UUID.h"
     40#import "WebCoreNSErrorExtras.h"
    4041#import <AVFoundation/AVError.h>
    4142#import <CoreMedia/CMBase.h>
    42 #import <cstdlib>
    4343#import <objc/objc-runtime.h>
    4444#import <runtime/TypedArrayInlines.h>
     
    113113}
    114114
    115 RefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
     115RefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
    116116{
    117117    UNUSED_PARAM(mimeType);
     
    188188}
    189189
    190 bool CDMSessionAVStreamSession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
     190bool CDMSessionAVStreamSession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode)
    191191{
    192192    bool shouldGenerateKeyRequest = !m_certificate || isEqual(key, "renew");
     
    256256            LOG(Media, "CDMSessionAVStreamSession::update(%p) - error:%@", this, [error description]);
    257257            errorCode = MediaPlayer::InvalidPlayerState;
    258             systemCode = std::abs(systemCodeForError(error));
     258            systemCode = mediaKeyErrorSystemCode(error);
    259259            return false;
    260260        }
     
    305305}
    306306
    307 PassRefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyReleaseMessage(unsigned short& errorCode, unsigned long& systemCode)
     307PassRefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyReleaseMessage(unsigned short& errorCode, uint32_t systemCode)
    308308{
    309309    ASSERT(m_mode == KeyRelease);
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h

    r195335 r195410  
    6464
    6565protected:
    66     static long systemCodeForError(NSError *);
    6766    String storagePath() const;
    6867
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm

    r195335 r195410  
    3131#import "CDMPrivateMediaSourceAVFObjC.h"
    3232#import "FileSystem.h"
     33#import "WebCoreNSErrorExtras.h"
    3334#import <AVFoundation/AVError.h>
    34 #import <cstdlib>
    3535
    3636namespace WebCore {
     
    5353        return;
    5454
    55     unsigned long code = std::abs(systemCodeForError(error));
     55    unsigned long code = mediaKeyErrorSystemCode(error);
    5656
    5757    // FIXME(142246): Remove the following once <rdar://problem/20027434> is resolved.
     
    6666        return;
    6767
    68     unsigned long code = std::abs(systemCodeForError(error));
     68    unsigned long code = mediaKeyErrorSystemCode(error);
    6969
    7070    // FIXME(142246): Remove the following once <rdar://problem/20027434> is resolved.
     
    9797}
    9898
    99 long CDMSessionMediaSourceAVFObjC::systemCodeForError(NSError *error)
    100 {
    101     NSInteger code = [error code];
    102     if (code != AVErrorUnknown)
    103         return code;
    104 
    105     NSError* underlyingError = [error.userInfo valueForKey:NSUnderlyingErrorKey];
    106     if (!underlyingError || ![underlyingError isKindOfClass:[NSError class]])
    107         return code;
    108 
    109     return [underlyingError code];
    110 }
    111 
    11299String CDMSessionMediaSourceAVFObjC::storagePath() const
    113100{
  • trunk/Source/WebCore/testing/MockCDM.cpp

    r195335 r195410  
    4545    virtual void setClient(CDMSessionClient* client) override { m_client = client; }
    4646    virtual const String& sessionId() const override { return m_sessionId; }
    47     virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) override;
     47    virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override;
    4848    virtual void releaseKeys() override;
    49     virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override;
     49    virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override;
    5050
    5151protected:
     
    113113}
    114114
    115 RefPtr<Uint8Array> MockCDMSession::generateKeyRequest(const String&, Uint8Array* initData, String&, unsigned short& errorCode, unsigned long&)
     115RefPtr<Uint8Array> MockCDMSession::generateKeyRequest(const String&, Uint8Array* initData, String&, unsigned short& errorCode, uint32_t&)
    116116{
    117117    for (unsigned i = 0; i < initDataPrefix()->length(); ++i) {
     
    129129}
    130130
    131 bool MockCDMSession::update(Uint8Array* key, RefPtr<Uint8Array>&, unsigned short& errorCode, unsigned long&)
     131bool MockCDMSession::update(Uint8Array* key, RefPtr<Uint8Array>&, unsigned short& errorCode, uint32_t&)
    132132{
    133133    for (unsigned i = 0; i < keyPrefix()->length(); ++i) {
Note: See TracChangeset for help on using the changeset viewer.