Changeset 143259 in webkit
- Timestamp:
- Feb 18, 2013 1:37:54 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r143257 r143259 1 2013-02-18 Jer Noble <jer.noble@apple.com> 2 3 EME: Add a CDMPrivate implementation using AVFoundation. 4 https://bugs.webkit.org/show_bug.cgi?id=109739 5 6 Reviewed by Eric Carlson. 7 8 Add a CDMPrivate implementation using AVFoundation, similar to the EME v1 implementation 9 in MediaPlayerPrivateAVFoundationObjC. This requires passing the AVAssetResourceLoadingRequest 10 from the MediaPlayerPrivateAVFoundationObjC instance to CDMSessionAVFoundation. To do so 11 without adding platform-specific API to MediaPlayer, add a static map from MediaPlayer -> 12 MediaPlayerPrivateAVFoundationObjC instances to be used to vend the AVAssetResourceLoadingRequest 13 to CDMSessionAVFoundation. 14 15 * Modules/encryptedmedia/CDM.cpp: 16 (WebCore::installedCDMFactories): Add the factory for CDMPrivateAVFoundation. 17 * Modules/encryptedmedia/CDM.h: 18 * Modules/encryptedmedia/CDMPrivateAVFoundation.h: Added. 19 (WebCore::CDMPrivateAVFoundation::create): Simple factory method. 20 (WebCore::CDMPrivateAVFoundation::~CDMPrivateAVFoundation): Simple virtual destructor. 21 (WebCore::CDMPrivateAVFoundation::cdm): Simple getter. 22 (WebCore::CDMPrivateAVFoundation::CDMPrivateAVFoundation): Simple constructor. 23 * Modules/encryptedmedia/CDMPrivateAVFoundation.mm: Added. 24 (WebCore::CDMSessionAVFoundation::~CDMSessionAVFoundation): Simple destructor. 25 (WebCore::CDMPrivateAVFoundation::supportsKeySytem): Check whether the given key system is supported. 26 (WebCore::CDMPrivateAVFoundation::supportsMIMEType): Check whether the given MIME type is supported. 27 (WebCore::CDMPrivateAVFoundation::createSession): Return a new CDMSessionAVFoundation. 28 (WebCore::CDMSessionAVFoundation::CDMSessionAVFoundation): Simple constructor. 29 (WebCore::CDMSessionAVFoundation::generateKeyRequest): Retrieve the AVAssetResourceLoadingRequest 30 from the MediaPlayer, and use it to generate a key request. 31 (WebCore::CDMSessionAVFoundation::releaseKeys): No-op. 32 (WebCore::CDMSessionAVFoundation::update): Add the passed in key to the AVAssetResourceLoadingRequest. 33 * WebCore.xcodeproj/project.pbxproj: 34 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 35 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 36 (WebCore::playerToPrivateMap): Lazily instantiate static map. 37 (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Register with the playerToPrivateMap. 38 (WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC): Unregister from same. 39 (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Also send keyNeeded event in ENCRYPTED_MEDIA_V2. 40 (WebCore::MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData): Convert this 41 method from file-static to class static. 42 (WebCore::MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI): Pull the AVAssetResourceLoadingRequest 43 from m_keyURIToRequestMap and return it, if present. 44 1 45 2013-02-18 Philip Rogers <pdr@google.com> 2 46 -
trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp
r143072 r143259 35 35 #include <wtf/text/WTFString.h> 36 36 37 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 38 #include "CDMPrivateAVFoundation.h" 39 #endif 40 37 41 namespace WebCore { 38 42 … … 58 62 59 63 // FIXME: initialize specific UA CDMs. http://webkit.org/b/109318, http://webkit.org/b/109320 64 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 65 cdms.append(new CDMFactory(CDMPrivateAVFoundation::create, CDMPrivateAVFoundation::supportsKeySytem)); 66 #endif 67 60 68 } 61 69 -
trunk/Source/WebCore/Modules/encryptedmedia/CDM.h
r143072 r143259 64 64 class CDM { 65 65 public: 66 67 enum CDMErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError }; 66 68 static bool supportsKeySystem(const String&); 67 69 static PassOwnPtr<CDM> create(const String& keySystem); -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r143230 r143259 6003 6003 CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; }; 6004 6004 CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */; }; 6005 CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */; }; 6005 6006 CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; }; 6006 6007 CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */; }; … … 13612 13613 CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiagnosticLoggingKeys.cpp; sourceTree = "<group>"; }; 13613 13614 CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingKeys.h; sourceTree = "<group>"; }; 13615 CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDMPrivateAVFoundation.h; path = Modules/encryptedmedia/CDMPrivateAVFoundation.h; sourceTree = "<group>"; }; 13616 CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMPrivateAVFoundation.mm; path = Modules/encryptedmedia/CDMPrivateAVFoundation.mm; sourceTree = "<group>"; }; 13614 13617 CD4AC5281496AE2F0087C4EF /* Composite.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = Composite.wav; path = platform/audio/resources/Composite.wav; sourceTree = SOURCE_ROOT; }; 13615 13618 CD4E0AFA11F7BC27009D3811 /* fullscreen.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = fullscreen.css; sourceTree = "<group>"; }; … … 21713 21716 CDA98E091603CD5900FEA3B1 /* CDM.cpp */, 21714 21717 CDA98E0A1603CD5900FEA3B1 /* CDM.h */, 21718 CDA98E0C1603CF3C00FEA3B1 /* CDMPrivate.h */, 21719 CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */, 21720 CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */, 21715 21721 CDA98DD516025BED00FEA3B1 /* MediaKeyMessageEvent.cpp */, 21716 21722 CDA98DD616025BED00FEA3B1 /* MediaKeyMessageEvent.h */, … … 21725 21731 CDA98DC816014F2C00FEA3B1 /* MediaKeySession.h */, 21726 21732 CDA98DC916014F4000FEA3B1 /* MediaKeySession.idl */, 21727 CDA98E0C1603CF3C00FEA3B1 /* Modules/encryptedmedia/CDMPrivate.h */,21728 21733 ); 21729 21734 name = encryptedmedia; … … 27489 27494 8502AB490AD438C000378540 /* DOMSVGFEDiffuseLightingElement.mm in Sources */, 27490 27495 8502AB4B0AD438C000378540 /* DOMSVGFEDisplacementMapElement.mm in Sources */, 27496 CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */, 27491 27497 8502AB4D0AD438C000378540 /* DOMSVGFEDistantLightElement.mm in Sources */, 27492 27498 4358E86B1360A21600E4748C /* DOMSVGFEDropShadowElement.mm in Sources */, -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r142327 r143259 75 75 #endif 76 76 77 #if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2) 78 static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate); 79 #endif 80 81 #if ENABLE(ENCRYPTED_MEDIA_V2) 82 static RetainPtr<AVAssetResourceLoadingRequest> takeRequestForPlayerAndKeyURI(MediaPlayer*, const String&); 83 #endif 84 77 85 private: 78 86 MediaPlayerPrivateAVFoundationObjC(MediaPlayer*); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r142375 r143259 187 187 #endif 188 188 189 #if ENABLE(ENCRYPTED_MEDIA_V2) 190 typedef HashMap<MediaPlayer*, MediaPlayerPrivateAVFoundationObjC*> PlayerToPrivateMapType; 191 static PlayerToPrivateMapType& playerToPrivateMap() 192 { 193 DEFINE_STATIC_LOCAL(PlayerToPrivateMapType, map, ()); 194 return map; 195 }; 196 #endif 197 198 189 199 PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationObjC::create(MediaPlayer* player) 190 200 { … … 214 224 #endif 215 225 { 226 #if ENABLE(ENCRYPTED_MEDIA_V2) 227 playerToPrivateMap().set(player, this); 228 #endif 216 229 } 217 230 218 231 MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC() 219 232 { 233 #if ENABLE(ENCRYPTED_MEDIA_V2) 234 playerToPrivateMap().remove(player()); 235 #endif 220 236 cancelLoad(); 221 237 } … … 871 887 String keyURI = [[[avRequest request] URL] absoluteString]; 872 888 873 #if ENABLE(ENCRYPTED_MEDIA) 889 #if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2) 874 890 if (scheme == "skd") { 875 891 // Create an initData with the following layout: … … 883 899 keyURIArray->setRange(keyURI.characters(), keyURI.length() / sizeof(unsigned char), 0); 884 900 901 #if ENABLE(ENCRYPTED_MEDIA) 885 902 if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength())) 903 #elif ENABLE(ENCRYPTED_MEDIA_V2) 904 RefPtr<Uint8Array> initData = Uint8Array::create(initDataBuffer, 0, initDataBuffer->byteLength()); 905 if (!player()->keyNeeded(initData.get())) 906 #endif 886 907 return false; 887 908 … … 1117 1138 #endif 1118 1139 1119 #if ENABLE(ENCRYPTED_MEDIA) 1120 1121 static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate) 1140 #if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2) 1141 bool MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate) 1122 1142 { 1123 1143 // initData should have the following layout: … … 1168 1188 return true; 1169 1189 } 1170 1190 #endif 1191 1192 #if ENABLE(ENCRYPTED_MEDIA) 1171 1193 MediaPlayer::MediaKeyException MediaPlayerPrivateAVFoundationObjC::generateKeyRequest(const String& keySystem, const unsigned char* initDataPtr, unsigned initDataLength) 1172 1194 { … … 1242 1264 m_sessionIDToRequestMap.remove(sessionID); 1243 1265 return MediaPlayer::NoError; 1266 } 1267 #endif 1268 1269 #if ENABLE(ENCRYPTED_MEDIA_V2) 1270 RetainPtr<AVAssetResourceLoadingRequest> MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI(MediaPlayer* player, const String& keyURI) 1271 { 1272 MediaPlayerPrivateAVFoundationObjC* _this = playerToPrivateMap().get(player); 1273 if (!_this) 1274 return nullptr; 1275 1276 return _this->m_keyURIToRequestMap.take(keyURI); 1277 1244 1278 } 1245 1279 #endif
Note: See TracChangeset
for help on using the changeset viewer.