Changeset 195410 in webkit
- Timestamp:
- Jan 21, 2016 9:15:16 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 21 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r195406 r195410 1 2016-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 1 63 2016-01-21 Carlos Garcia Campos <cgarcia@igalia.com> 2 64 -
trunk/Source/WebCore/Modules/encryptedmedia/CDM.h
r195335 r195410 56 56 explicit CDM(const String& keySystem); 57 57 58 enum CDMErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError };58 enum CDMErrorCode { NoError, UnknownError, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError }; 59 59 static bool supportsKeySystem(const String&); 60 60 static bool keySystemSupportsMimeType(const String& keySystem, const String& mimeType); -
trunk/Source/WebCore/Modules/encryptedmedia/CDMSessionClearKey.cpp
r195335 r195410 70 70 } 71 71 72 RefPtr<Uint8Array> CDMSessionClearKey::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode)72 RefPtr<Uint8Array> CDMSessionClearKey::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) 73 73 { 74 74 UNUSED_PARAM(mimeType); … … 97 97 } 98 98 99 bool CDMSessionClearKey::update(Uint8Array* rawKeysData, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode)99 bool CDMSessionClearKey::update(Uint8Array* rawKeysData, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) 100 100 { 101 101 UNUSED_PARAM(nextMessage); -
trunk/Source/WebCore/Modules/encryptedmedia/CDMSessionClearKey.h
r195335 r195410 43 43 virtual void setClient(CDMSessionClient* client) override { m_client = client; } 44 44 virtual const String& sessionId() const override { return m_sessionId; } 45 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array*, String&, unsigned short&, u nsigned long&) override;45 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array*, String&, unsigned short&, uint32_t&) override; 46 46 virtual void releaseKeys() override; 47 virtual bool update(Uint8Array*, RefPtr<Uint8Array>&, unsigned short&, u nsigned long&) override;47 virtual bool update(Uint8Array*, RefPtr<Uint8Array>&, unsigned short&, uint32_t&) override; 48 48 virtual RefPtr<ArrayBuffer> cachedKeyForKeyID(const String&) const override; 49 49 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
r195335 r195410 112 112 String destinationURL; 113 113 MediaKeyError::Code errorCode = 0; 114 u nsigned longsystemCode = 0;114 uint32_t systemCode = 0; 115 115 116 116 // 3. Use cdm to generate a key request and follow the steps for the first matching condition from the following list: … … 164 164 RefPtr<Uint8Array> pendingKey = m_pendingKeys.takeFirst(); 165 165 unsigned short errorCode = 0; 166 u nsigned longsystemCode = 0;166 uint32_t systemCode = 0; 167 167 168 168 // NOTE: Continued from step 2. of MediaKeySession::update() … … 220 220 } 221 221 222 void MediaKeySession::sendError(CDMSessionClient::MediaKeyErrorCode errorCode, u nsigned longsystemCode)222 void MediaKeySession::sendError(CDMSessionClient::MediaKeyErrorCode errorCode, uint32_t systemCode) 223 223 { 224 224 Ref<MediaKeyError> error = MediaKeyError::create(errorCode, systemCode).get(); -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
r195335 r195410 87 87 // CDMSessionClient 88 88 virtual void sendMessage(Uint8Array*, String destinationURL) override; 89 virtual void sendError(MediaKeyErrorCode, u nsigned longsystemCode) override;89 virtual void sendError(MediaKeyErrorCode, uint32_t systemCode) override; 90 90 virtual String mediaKeysStorageDirectory() const override; 91 91 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r195356 r195410 6068 6068 CDC8B5AB18047FF10016E685 /* SourceBufferPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */; }; 6069 6069 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 */; }; 6070 6072 CDCA82961679100F00875714 /* TextTrackRepresentationIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCA82941679100F00875714 /* TextTrackRepresentationIOS.mm */; }; 6071 6073 CDCA98EB18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDCA98EA18B2C8EB00C12FF9 /* CDMPrivateMediaPlayer.cpp */; }; … … 13946 13948 CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivateAVFObjC.h; sourceTree = "<group>"; }; 13947 13949 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>"; }; 13948 13952 CDCA82941679100F00875714 /* TextTrackRepresentationIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextTrackRepresentationIOS.mm; sourceTree = "<group>"; }; 13949 13953 CDCA98E918B2C8D000C12FF9 /* CDMPrivateMediaPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMPrivateMediaPlayer.h; sourceTree = "<group>"; }; … … 19747 19751 310D71941B335C9D009C7B73 /* ThemeCocoa.h */, 19748 19752 46DB7D561B20FE3C005651B2 /* VNodeTrackerCocoa.cpp */, 19753 CDC979F21C498C0900DB50D4 /* WebCoreNSErrorExtras.mm */, 19754 CDC979F31C498C0900DB50D4 /* WebCoreNSErrorExtras.h */, 19749 19755 ); 19750 19756 path = cocoa; … … 26634 26640 BC5EBA110E823E4700B25965 /* KeyframeList.h in Headers */, 26635 26641 E15FF7D518C9553800FE4C87 /* KeypressCommand.h in Headers */, 26642 CDC979F51C498C0900DB50D4 /* WebCoreNSErrorExtras.h in Headers */, 26636 26643 521D46F811AEC9B100514613 /* KillRing.h in Headers */, 26637 26644 450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */, … … 28837 28844 BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */, 28838 28845 49AE2D8E134EE50C0072920A /* CSSCalculationValue.cpp in Sources */, 28846 CDC979F41C498C0900DB50D4 /* WebCoreNSErrorExtras.mm in Sources */, 28839 28847 BC604A430DB5634E00204739 /* CSSCanvasValue.cpp in Sources */, 28840 28848 E1EBBBD40AAC9B87001FE8E2 /* CSSCharsetRule.cpp in Sources */, -
trunk/Source/WebCore/html/MediaKeyError.h
r195335 r195410 47 47 typedef unsigned short Code; 48 48 49 static Ref<MediaKeyError> create(Code code, u nsigned longsystemCode = 0) { return adoptRef(*new MediaKeyError(code, systemCode)); }49 static Ref<MediaKeyError> create(Code code, uint32_t systemCode = 0) { return adoptRef(*new MediaKeyError(code, systemCode)); } 50 50 51 51 Code code() const { return m_code; } 52 u nsigned longsystemCode() { return m_systemCode; }52 uint32_t systemCode() { return m_systemCode; } 53 53 54 54 private: -
trunk/Source/WebCore/html/MediaKeyEvent.h
r195335 r195410 43 43 String defaultURL; 44 44 RefPtr<MediaKeyError> errorCode; 45 u nsigned short systemCode;45 uint32_t systemCode; 46 46 }; 47 47 -
trunk/Source/WebCore/platform/cocoa/WebCoreNSErrorExtras.h
r195409 r195410 1 1 /* 2 * Copyright (C) 201 5Apple Inc. All rights reserved.2 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 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 33 28 34 29 namespace WebCore { 35 30 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 }; 31 WEBCORE_EXPORT long mediaKeyErrorSystemCode(NSError *); 56 32 57 33 } 58 34 59 #endif // ENABLE(ENCRYPTED_MEDIA_V2) 60 61 #endif // CDMSessionClearKey_h 35 #endif // WebCoreNSErrorExtras_h -
trunk/Source/WebCore/platform/cocoa/WebCoreNSErrorExtras.mm
r195409 r195410 1 1 /* 2 * Copyright (C) 201 5Apple Inc. All rights reserved.3 * 2 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions … … 24 24 */ 25 25 26 #i fndef CDMSessionClearKey_h27 # define CDMSessionClearKey_h26 #import "config.h" 27 #import "WebCoreNSErrorExtras.h" 28 28 29 #include "CDMSession.h" 30 #include <wtf/HashMap.h> 31 32 #if ENABLE(ENCRYPTED_MEDIA_V2) 29 #import <AVFoundation/AVError.h> 33 30 34 31 namespace WebCore { 35 32 36 class CDMSessionClearKey : public CDMSession { 37 public: 38 CDMSessionClearKey(CDMSessionClient*); 39 virtual ~CDMSessionClearKey(); 33 long mediaKeyErrorSystemCode(NSError *error) 34 { 35 NSInteger code = [error code]; 40 36 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 } 49 42 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 } 56 45 57 46 } 58 59 #endif // ENABLE(ENCRYPTED_MEDIA_V2)60 61 #endif // CDMSessionClearKey_h -
trunk/Source/WebCore/platform/graphics/CDMSession.h
r195335 r195410 50 50 }; 51 51 typedef unsigned short MediaKeyErrorCode; 52 virtual void sendError(MediaKeyErrorCode, u nsigned longsystemCode) = 0;52 virtual void sendError(MediaKeyErrorCode, uint32_t systemCode) = 0; 53 53 54 54 virtual String mediaKeysStorageDirectory() const = 0; … … 71 71 virtual void setClient(CDMSessionClient*) = 0; 72 72 virtual const String& sessionId() const = 0; 73 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode) = 0;73 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) = 0; 74 74 virtual void releaseKeys() = 0; 75 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode) = 0;75 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) = 0; 76 76 virtual RefPtr<ArrayBuffer> cachedKeyForKeyID(const String&) const { return nullptr; } 77 77 }; -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp
r193482 r195410 52 52 } 53 53 54 RefPtr<Uint8Array> CDMSessionAVFoundationCF::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode)54 RefPtr<Uint8Array> CDMSessionAVFoundationCF::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) 55 55 { 56 56 UNUSED_PARAM(mimeType); … … 108 108 } 109 109 110 bool CDMSessionAVFoundationCF::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode)110 bool CDMSessionAVFoundationCF::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) 111 111 { 112 112 RetainPtr<CFMutableDataRef> keyData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, key->byteLength())); -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h
r193482 r195410 45 45 virtual void setClient(CDMSessionClient* client) override { m_client = client; } 46 46 virtual const String& sessionId() const override { return m_sessionId; } 47 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode) override;47 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override; 48 48 virtual void releaseKeys() override; 49 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode) override;49 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override; 50 50 51 51 protected: -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h
r195335 r195410 50 50 // CDMSession 51 51 virtual CDMSessionType type() override { return CDMSessionTypeAVContentKeySession; } 52 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode) override;52 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override; 53 53 virtual void releaseKeys() override; 54 virtual bool update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode) override;54 virtual bool update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override; 55 55 56 56 // CDMSessionMediaSourceAVFObjC … … 61 61 62 62 protected: 63 PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, u nsigned long& systemCode);63 PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, uint32_t& systemCode); 64 64 65 65 bool hasContentKeySession() const { return m_contentKeySession; } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm
r195335 r195410 38 38 #import "SourceBufferPrivateAVFObjC.h" 39 39 #import "UUID.h" 40 #import "WebCoreNSErrorExtras.h" 40 41 #import <AVFoundation/AVError.h> 41 42 #import <CoreMedia/CMBase.h> 42 #import <cstdlib>43 43 #import <objc/objc-runtime.h> 44 44 #import <runtime/TypedArrayInlines.h> … … 145 145 } 146 146 147 RefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode)147 RefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) 148 148 { 149 149 UNUSED_PARAM(mimeType); … … 229 229 } 230 230 231 bool CDMSessionAVContentKeySession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode)231 bool CDMSessionAVContentKeySession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) 232 232 { 233 233 UNUSED_PARAM(nextMessage); … … 282 282 errorCode = MediaPlayer::NoError; 283 283 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 285 292 nextMessage = Uint8Array::create(static_cast<const uint8_t*>([requestData bytes]), [requestData length]); 286 287 293 return false; 288 294 } … … 307 313 } 308 314 309 PassRefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyReleaseMessage(unsigned short& errorCode, u nsigned long& systemCode)315 PassRefPtr<Uint8Array> CDMSessionAVContentKeySession::generateKeyReleaseMessage(unsigned short& errorCode, uint32_t& systemCode) 310 316 { 311 317 ASSERT(m_mode == KeyRelease); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h
r195335 r195410 46 46 virtual void setClient(CDMSessionClient* client) override { m_client = client; } 47 47 virtual const String& sessionId() const override { return m_sessionId; } 48 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode) override;48 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override; 49 49 virtual void releaseKeys() override; 50 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode) override;50 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override; 51 51 52 52 protected: -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm
r195335 r195410 36 36 #import "SoftLinking.h" 37 37 #import "UUID.h" 38 #import "WebCoreNSErrorExtras.h" 38 39 #import <AVFoundation/AVFoundation.h> 39 40 #import <objc/objc-runtime.h> … … 54 55 } 55 56 56 RefPtr<Uint8Array> CDMSessionAVFoundationObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode)57 RefPtr<Uint8Array> CDMSessionAVFoundationObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) 57 58 { 58 59 UNUSED_PARAM(mimeType); … … 62 63 RefPtr<Uint8Array> certificate; 63 64 if (!MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(initData, keyURI, keyID, certificate)) { 64 errorCode = MediaPlayer::InvalidPlayerState;65 errorCode = CDM::UnknownError; 65 66 return nullptr; 66 67 } … … 68 69 m_request = m_parent->takeRequestForKeyURI(keyURI); 69 70 if (!m_request) { 70 errorCode = MediaPlayer::InvalidPlayerState;71 errorCode = CDM::UnknownError; 71 72 return nullptr; 72 73 } … … 79 80 80 81 if (!keyRequest) { 81 NSError* underlyingError = [[nsError userInfo] objectForKey:NSUnderlyingErrorKey];82 systemCode = [underlyingError code];82 errorCode = CDM::DomainError; 83 systemCode = mediaKeyErrorSystemCode(nsError); 83 84 return nullptr; 84 85 } … … 96 97 } 97 98 98 bool CDMSessionAVFoundationObjC::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode)99 bool CDMSessionAVFoundationObjC::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) 99 100 { 100 101 RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:key->baseAddress() length:key->byteLength()]); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h
r195335 r195410 48 48 // CDMSession 49 49 virtual CDMSessionType type() override { return CDMSessionTypeAVStreamSession; } 50 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode) override;50 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override; 51 51 virtual void releaseKeys() override; 52 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode) override;52 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override; 53 53 54 54 // CDMSessionMediaSourceAVFObjC … … 59 59 60 60 protected: 61 PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, u nsigned long&systemCode);61 PassRefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, uint32_t systemCode); 62 62 63 63 WeakPtrFactory<CDMSessionAVStreamSession> m_weakPtrFactory; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm
r195335 r195410 38 38 #import "SourceBufferPrivateAVFObjC.h" 39 39 #import "UUID.h" 40 #import "WebCoreNSErrorExtras.h" 40 41 #import <AVFoundation/AVError.h> 41 42 #import <CoreMedia/CMBase.h> 42 #import <cstdlib>43 43 #import <objc/objc-runtime.h> 44 44 #import <runtime/TypedArrayInlines.h> … … 113 113 } 114 114 115 RefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode)115 RefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) 116 116 { 117 117 UNUSED_PARAM(mimeType); … … 188 188 } 189 189 190 bool CDMSessionAVStreamSession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode)190 bool CDMSessionAVStreamSession::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) 191 191 { 192 192 bool shouldGenerateKeyRequest = !m_certificate || isEqual(key, "renew"); … … 256 256 LOG(Media, "CDMSessionAVStreamSession::update(%p) - error:%@", this, [error description]); 257 257 errorCode = MediaPlayer::InvalidPlayerState; 258 systemCode = std::abs(systemCodeForError(error));258 systemCode = mediaKeyErrorSystemCode(error); 259 259 return false; 260 260 } … … 305 305 } 306 306 307 PassRefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyReleaseMessage(unsigned short& errorCode, u nsigned long&systemCode)307 PassRefPtr<Uint8Array> CDMSessionAVStreamSession::generateKeyReleaseMessage(unsigned short& errorCode, uint32_t systemCode) 308 308 { 309 309 ASSERT(m_mode == KeyRelease); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h
r195335 r195410 64 64 65 65 protected: 66 static long systemCodeForError(NSError *);67 66 String storagePath() const; 68 67 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm
r195335 r195410 31 31 #import "CDMPrivateMediaSourceAVFObjC.h" 32 32 #import "FileSystem.h" 33 #import "WebCoreNSErrorExtras.h" 33 34 #import <AVFoundation/AVError.h> 34 #import <cstdlib>35 35 36 36 namespace WebCore { … … 53 53 return; 54 54 55 unsigned long code = std::abs(systemCodeForError(error));55 unsigned long code = mediaKeyErrorSystemCode(error); 56 56 57 57 // FIXME(142246): Remove the following once <rdar://problem/20027434> is resolved. … … 66 66 return; 67 67 68 unsigned long code = std::abs(systemCodeForError(error));68 unsigned long code = mediaKeyErrorSystemCode(error); 69 69 70 70 // FIXME(142246): Remove the following once <rdar://problem/20027434> is resolved. … … 97 97 } 98 98 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 112 99 String CDMSessionMediaSourceAVFObjC::storagePath() const 113 100 { -
trunk/Source/WebCore/testing/MockCDM.cpp
r195335 r195410 45 45 virtual void setClient(CDMSessionClient* client) override { m_client = client; } 46 46 virtual const String& sessionId() const override { return m_sessionId; } 47 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, u nsigned long& systemCode) override;47 virtual RefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode) override; 48 48 virtual void releaseKeys() override; 49 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, u nsigned long& systemCode) override;49 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override; 50 50 51 51 protected: … … 113 113 } 114 114 115 RefPtr<Uint8Array> MockCDMSession::generateKeyRequest(const String&, Uint8Array* initData, String&, unsigned short& errorCode, u nsigned long&)115 RefPtr<Uint8Array> MockCDMSession::generateKeyRequest(const String&, Uint8Array* initData, String&, unsigned short& errorCode, uint32_t&) 116 116 { 117 117 for (unsigned i = 0; i < initDataPrefix()->length(); ++i) { … … 129 129 } 130 130 131 bool MockCDMSession::update(Uint8Array* key, RefPtr<Uint8Array>&, unsigned short& errorCode, u nsigned long&)131 bool MockCDMSession::update(Uint8Array* key, RefPtr<Uint8Array>&, unsigned short& errorCode, uint32_t&) 132 132 { 133 133 for (unsigned i = 0; i < keyPrefix()->length(); ++i) {
Note: See TracChangeset
for help on using the changeset viewer.