[Win] Implement parts of the AVFOUNDATION_LOADER_DELEGATE logic for Windows
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jun 2014 00:19:41 +0000 (00:19 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jun 2014 00:19:41 +0000 (00:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134418

Reviewed by Eric Carlson.

../WebCore:
Land an initial implementation of AVFOUNDATION_LOADER_DELEGATE for
Windows.

* DerivedSources.cpp: Add new IDL files
* DerivedSources.make: Add check for AVFOUNDATION_LOADER_DELEGATE.
* Modules/encryptedmedia/CDMPrivateMediaPlayer.cpp: Added (ported from
Objective C.)
* WebCore.vcxproj/WebCore.vcxproj: Update for new files.
* WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
* WebCore.vcxproj/WebCoreCommon.props: Add new search paths.
* WebCore.vcxproj/WebCoreTestSupport.vcxproj: Update for new files.
* WebCore.vcxproj/WebCoreTestSupport.vcxproj.filters: Ditto.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::extractKeyURIKeyIDAndCertificateFromInitData):
Moved from MediaPlayerPrivateAVFoundationObjC.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
* platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h:
Update for new API calls.
* platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp: Added.
* platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h: Added.
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
Updated for new AVFOUNDATION_LOADER_DELEGATE methods.
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
* platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp: Added.
* platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.h: Added.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
Remove method that was moved to base class.

../WebKit:
* WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: Add new
export.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170562 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/encryptedmedia/CDMPrivateMediaPlayer.cpp
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.vcxproj/WebCoreCommon.props
Source/WebCore/WebCore.vcxproj/WebCoreTestSupport.vcxproj
Source/WebCore/WebCore.vcxproj/WebCoreTestSupport.vcxproj.filters
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h
Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h
Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebKit/ChangeLog
Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in

index 1a689f3..9228df3 100644 (file)
@@ -1,3 +1,39 @@
+2014-06-27  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Implement parts of the AVFOUNDATION_LOADER_DELEGATE logic for Windows
+        https://bugs.webkit.org/show_bug.cgi?id=134418
+
+        Reviewed by Eric Carlson.
+
+        Land an initial implementation of AVFOUNDATION_LOADER_DELEGATE for
+        Windows.
+
+        * DerivedSources.cpp: Add new IDL files
+        * DerivedSources.make: Add check for AVFOUNDATION_LOADER_DELEGATE.
+        * Modules/encryptedmedia/CDMPrivateMediaPlayer.cpp: Added (ported from
+        Objective C.)
+        * WebCore.vcxproj/WebCore.vcxproj: Update for new files.
+        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
+        * WebCore.vcxproj/WebCoreCommon.props: Add new search paths.
+        * WebCore.vcxproj/WebCoreTestSupport.vcxproj: Update for new files.
+        * WebCore.vcxproj/WebCoreTestSupport.vcxproj.filters: Ditto.
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::extractKeyURIKeyIDAndCertificateFromInitData):
+        Moved from MediaPlayerPrivateAVFoundationObjC.
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+        * platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h:
+        Update for new API calls.
+        * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp: Added.
+        * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h: Added.
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        Updated for new AVFOUNDATION_LOADER_DELEGATE methods.
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
+        * platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp: Added.
+        * platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.h: Added.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        Remove method that was moved to base class.
+
 2014-06-27  Benjamin Poulain  <benjamin@webkit.org>
 
         Remove BufferForAppendingHyphen
index 5ced86d..74a52bf 100644 (file)
 #endif
 #include "JSMediaError.cpp"
 #include "JSMediaList.cpp"
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+#include "JSMediaKeyError.cpp"
+#include "JSMediaKeyMessageEvent.cpp"
+#include "JSMediaKeyNeededEvent.cpp"
+#include "JSMediaKeySession.cpp"
+#include "JSMediaKeys.cpp"
+#endif
 #include "JSMediaQueryList.cpp"
 #include "JSMediaQueryListListener.cpp"
 #include "JSMessageChannel.cpp"
index 9c90cb0..a2f1e8e 100644 (file)
@@ -1309,5 +1309,6 @@ WebCoreHeaderDetection.h : DerivedSources.make
        echo "/* Identifying AVFoundation Support */" > $@
        if [ -f "$(WEBKIT_LIBRARIES)/include/AVFoundationCF/AVCFBase.h" ]||[ -f "$(WEBKITLIBRARIESDIR)/include/AVFoundationCF/AVCFBase.h" ]; then echo "#define HAVE_AVCF 1" >> $@; else echo >> $@; fi
        if [ -f "$(WEBKIT_LIBRARIES)/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h" ]||[ -f "$(WEBKITLIBRARIESDIR)/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h" ]; then echo "#define HAVE_AVCF_LEGIBLE_OUTPUT 1" >> $@; else echo >> $@; fi
+       if [ -f "$(WEBKIT_LIBRARIES)/include/AVFoundationCF/AVCFAssetResourceLoader.h" ]||[ -f "$(WEBKITLIBRARIESDIR)/include/AVFoundationCF/AVCFAssetResourceLoader.h" ]; then echo "#define HAVE_AVFOUNDATION_LOADER_DELEGATE 1" >> $@; else echo >> $@; fi
 
 endif # Windows_NT
index d362140..8de74b6 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "config.h"
-#import "CDMPrivateMediaPlayer.h"
+#include "config.h"
+#include "CDMPrivateMediaPlayer.h"
 
 #if ENABLE(ENCRYPTED_MEDIA_V2)
 
-#import "CDM.h"
-#import "CDMSession.h"
-#import "ContentType.h"
-#import "ExceptionCode.h"
-#import "MediaPlayer.h"
-#import "SoftLinking.h"
+#include "CDM.h"
+#include "CDMSession.h"
+#include "ContentType.h"
+#include "ExceptionCode.h"
+#include "MediaPlayer.h"
+#include "SoftLinking.h"
 
 namespace WebCore {
 
index f883ffd..65e5a30 100644 (file)
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyError.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyMessageEvent.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyNeededEvent.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeys.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeySession.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaList.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\Modules\encryptedmedia\CDM.cpp" />
+    <ClCompile Include="..\Modules\encryptedmedia\CDMPrivateMediaPlayer.cpp" />
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeyMessageEvent.cpp" />
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeyNeededEvent.cpp" />
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeys.cpp" />
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeySession.cpp" />
     <ClCompile Include="..\Modules\gamepad\Gamepad.cpp" />
     <ClCompile Include="..\Modules\gamepad\GamepadButton.cpp" />
     <ClCompile Include="..\Modules\gamepad\GamepadEvent.cpp" />
     <ClCompile Include="..\platform\FileChooser.cpp" />
     <ClCompile Include="..\platform\FileStream.cpp" />
     <ClCompile Include="..\platform\FileSystem.cpp" />
+    <ClCompile Include="..\platform\graphics\avfoundation\cf\CDMSessionAVFoundationCF.cpp" />
+    <ClCompile Include="..\platform\graphics\avfoundation\cf\WebCoreAVCFResourceLoader.cpp" />
     <ClCompile Include="..\platform\graphics\ISOVTTCue.cpp" />
     <ClCompile Include="..\platform\audio\AudioSession.cpp" />
     <ClCompile Include="..\platform\audio\MediaSession.cpp" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSLocation.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaControlsHost.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaError.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyError.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaMessageEvent.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaNeededEvent.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeys.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeySession.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaList.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaQueryList.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaQueryListListener.h" />
     <ClInclude Include="..\html\track\VTTRegion.h" />
     <ClInclude Include="..\html\track\VTTRegionList.h" />
     <ClInclude Include="..\html\track\WebVTTElement.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\CDM.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\CDMPrivate.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\CDMPrivateMediaPlayer.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeyMessageEvent.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeyNeededEvent.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeys.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeySession.h" />
     <ClInclude Include="..\Modules\gamepad\Gamepad.h" />
     <ClInclude Include="..\Modules\gamepad\GamepadButton.h" />
     <ClInclude Include="..\Modules\gamepad\GamepadEvent.h" />
     <ClInclude Include="..\platform\audio\MediaSessionManager.h" />
     <ClInclude Include="..\platform\graphics\ANGLEWebKitBridge.h" />
     <ClInclude Include="..\platform\graphics\AudioTrackPrivate.h" />
+    <ClInclude Include="..\platform\graphics\avfoundation\cf\CDMSessionAVFoundationCF.h" />
     <ClInclude Include="..\platform\graphics\avfoundation\cf\InbandTextTrackPrivateAVCF.h" />
     <ClInclude Include="..\platform\graphics\avfoundation\cf\InbandTextTrackPrivateLegacyAVCF.h" />
+    <ClInclude Include="..\platform\graphics\avfoundation\cf\WebCoreAVCFResourceLoader.h" />
     <ClInclude Include="..\platform\graphics\avfoundation\InbandTextTrackPrivateAVF.h" />
     <ClInclude Include="..\platform\graphics\cairo\TileCairo.h" />
     <ClInclude Include="..\platform\graphics\ca\LayerPool.h" />
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
index 2bc6205..d0e482a 100644 (file)
     <Filter Include="platform\soup">
       <UniqueIdentifier>{b353479a-a6bf-41ad-b655-876165789b99}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Modules\encryptedmedia">
+      <UniqueIdentifier>{f9aa953b-e2a1-4d9e-a049-c34b10c81b4e}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\DerivedSources.cpp">
     <ClCompile Include="..\platform\graphics\ca\TileCoverageMap.cpp">
       <Filter>platform\graphics\ca</Filter>
     </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepad.cpp" />
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepadButton.cpp" />
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepadEvent.cpp" />
+    <ClCompile Include="..\Modules\gamepad\Gamepad.cpp" />
+    <ClCompile Include="..\Modules\gamepad\GamepadButton.cpp" />
+    <ClCompile Include="..\Modules\gamepad\GamepadEvent.cpp" />
+    <ClCompile Include="..\Modules\gamepad\NavigatorGamepad.cpp" />
+    <ClCompile Include="..\platform\graphics\ISOVTTCue.cpp" />
+    <ClCompile Include="..\Modules\encryptedmedia\CDM.cpp">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClCompile>
+    <ClCompile Include="..\Modules\encryptedmedia\CDMPrivateMediaPlayer.cpp">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClCompile>
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeyMessageEvent.cpp">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClCompile>
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeyNeededEvent.cpp">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClCompile>
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeys.cpp">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClCompile>
+    <ClCompile Include="..\Modules\encryptedmedia\MediaKeySession.cpp">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyMessageEvent.cpp">
+      <Filter>DerivedSources</Filter>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyNeededEvent.cpp">
+      <Filter>DerivedSources</Filter>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeys.cpp">
+      <Filter>DerivedSources</Filter>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeySession.cpp">
+      <Filter>DerivedSources</Filter>
+    </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyError.cpp">
+      <Filter>DerivedSources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\platform\graphics\avfoundation\cf\CDMSessionAVFoundationCF.cpp">
+      <Filter>platform\graphics\avfoundation\cf</Filter>
+    </ClCompile>
+    <ClCompile Include="..\platform\graphics\avfoundation\cf\WebCoreAVCFResourceLoader.cpp">
+      <Filter>platform\graphics\avfoundation\cf</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\Modules\geolocation\Coordinates.h">
     <ClInclude Include="..\platform\graphics\ca\TileCoverageMap.h">
       <Filter>platform\graphics\ca</Filter>
     </ClInclude>
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepad.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepadButton.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepadEvent.h" />
+    <ClInclude Include="..\Modules\gamepad\Gamepad.h" />
+    <ClInclude Include="..\Modules\gamepad\GamepadButton.h" />
+    <ClInclude Include="..\Modules\gamepad\GamepadEvent.h" />
+    <ClInclude Include="..\Modules\gamepad\NavigatorGamepad.h" />
+    <ClInclude Include="..\platform\graphics\ISOVTTCue.h" />
+    <ClInclude Include="..\Modules\encryptedmedia\CDM.h">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClInclude>
+    <ClInclude Include="..\Modules\encryptedmedia\CDMPrivate.h">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClInclude>
+    <ClInclude Include="..\Modules\encryptedmedia\CDMPrivateMediaPlayer.h">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClInclude>
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeyMessageEvent.h">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClInclude>
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeyNeededEvent.h">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClInclude>
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeys.h">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClInclude>
+    <ClInclude Include="..\Modules\encryptedmedia\MediaKeySession.h">
+      <Filter>Modules\encryptedmedia</Filter>
+    </ClInclude>
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaNeededEvent.h">
+      <Filter>DerivedSources</Filter>
+    </ClInclude>
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeys.h">
+      <Filter>DerivedSources</Filter>
+    </ClInclude>
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeySession.h">
+      <Filter>DerivedSources</Filter>
+    </ClInclude>
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaMessageEvent.h">
+      <Filter>DerivedSources</Filter>
+    </ClInclude>
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSMediaKeyError.h">
+      <Filter>DerivedSources</Filter>
+    </ClInclude>
+    <ClInclude Include="..\platform\graphics\avfoundation\cf\CDMSessionAVFoundationCF.h">
+      <Filter>platform\graphics\avfoundation\cf</Filter>
+    </ClInclude>
+    <ClInclude Include="..\platform\graphics\avfoundation\cf\WebCoreAVCFResourceLoader.h">
+      <Filter>platform\graphics\avfoundation\cf</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\css\CSSGrammar.y.in">
       <Filter>platform\win</Filter>
     </MASM>
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
index be8d416..4d5053a 100644 (file)
@@ -7,11 +7,11 @@
   </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
-      <AdditionalIncludeDirectories>$(ProjectDir)..;$(ProjectDir)..\Modules\mediacontrols;$(ProjectDir)..\Modules\mediastream;$(ProjectDir)..\Modules\filesystem;$(ProjectDir)..\Modules\gamepad;$(ProjectDir)..\Modules\geolocation;$(ProjectDir)..\Modules\indexeddb;$(ProjectDir)..\Modules\mediasource;$(ProjectDir)..\Modules\navigatorcontentutils;$(ProjectDir)..\Modules\plugins;$(ProjectDir)..\Modules\speech;$(ProjectDir)..\Modules\proximity;$(ProjectDir)..\Modules\quota;$(ProjectDir)..\Modules\notifications;$(ProjectDir)..\Modules\webdatabase;$(ProjectDir)..\Modules\websockets;$(ProjectDir)..\accessibility;$(ProjectDir)..\accessibility\win;$(ProjectDir)..\bridge;$(ProjectDir)..\bridge\c;$(ProjectDir)..\bridge\jsc;$(ProjectDir)..\css;$(ProjectDir)..\cssjit;$(ProjectDir)..\editing;$(ProjectDir)..\fileapi;$(ProjectDir)..\rendering;$(ProjectDir)..\rendering\line;$(ProjectDir)..\rendering\mathml;$(ProjectDir)..\rendering\shapes;$(ProjectDir)..\rendering\style;$(ProjectDir)..\rendering\svg;$(ProjectDir)..\bindings;$(ProjectDir)..\bindings\generic;$(ProjectDir)..\bindings\js;$(ProjectDir)..\bindings\js\specialization;$(ProjectDir)..\dom;$(ProjectDir)..\dom\default;$(ProjectDir)..\history;$(ProjectDir)..\html;$(ProjectDir)..\html\canvas;$(ProjectDir)..\html\forms;$(ProjectDir)..\html\parser;$(ProjectDir)..\html\shadow;$(ProjectDir)..\html\track;$(ProjectDir)..\inspector;$(ProjectDir)..\loader;$(ProjectDir)..\loader\appcache;$(ProjectDir)..\loader\archive;$(ProjectDir)..\loader\archive\cf;$(ProjectDir)..\loader\cache;$(ProjectDir)..\loader\icon;$(ProjectDir)..\mathml;$(ProjectDir)..\page;$(ProjectDir)..\page\animation;$(ProjectDir)..\page\scrolling;$(ProjectDir)..\page\win;$(ProjectDir)..\platform;$(ProjectDir)..\platform\animation;$(ProjectDir)..\platform\audio;$(ProjectDir)..\platform\mock;$(ProjectDir)..\platform\sql;$(ProjectDir)..\platform\win;$(ProjectDir)..\platform\network;$(ProjectDir)..\platform\network\win;$(ProjectDir)..\platform\cf;$(ProjectDir)..\platform\graphics;$(ProjectDir)..\platform\graphics\ca;$(ProjectDir)..\platform\graphics\cpu\arm\filters;$(ProjectDir)..\platform\graphics\filters;$(ProjectDir)..\platform\graphics\filters\arm;$(ProjectDir)..\platform\graphics\opentype;$(ProjectDir)..\platform\graphics\transforms;$(ProjectDir)..\platform\text;$(ProjectDir)..\platform\text\icu;$(ProjectDir)..\platform\text\transcoder;$(ProjectDir)..\platform\graphics\win;$(ProjectDir)..\xml;$(ProjectDir)..\xml\parser;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources;$(ProjectDir)..\plugins;$(ProjectDir)..\plugins\win;$(ProjectDir)..\replay;$(ProjectDir)..\svg\animation;$(ProjectDir)..\svg\graphics;$(ProjectDir)..\svg\properties;$(ProjectDir)..\svg\graphics\filters;$(ProjectDir)..\svg;$(ProjectDir)..\testing;$(ProjectDir)..\crypto;$(ProjectDir)..\crypto\keys;$(ProjectDir)..\wml;$(ProjectDir)..\storage;$(ProjectDir)..\style;$(ProjectDir)..\websockets;$(ProjectDir)..\workers;$(ConfigurationBuildDir)\include;$(ConfigurationBuildDir)\include\private;$(ConfigurationBuildDir)\include\JavaScriptCore;$(ConfigurationBuildDir)\include\private\JavaScriptCore;$(ProjectDir)..\ForwardingHeaders;$(ProjectDir)..\platform\graphics\gpu;$(ProjectDir)..\platform\graphics\egl;$(ProjectDir)..\platform\graphics\surfaces;$(ProjectDir)..\platform\graphics\surfaces\egl;$(ProjectDir)..\platform\graphics\opengl;$(WebKit_Libraries)\include;$(WebKit_Libraries)\include\private;$(WebKit_Libraries)\include\private\JavaScriptCore;$(WebKit_Libraries)\include\sqlite;$(WebKit_Libraries)\include\JavaScriptCore;$(WebKit_Libraries)\include\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(ProjectDir)..;$(ProjectDir)..\Modules\mediacontrols;$(ProjectDir)..\Modules\mediastream;$(ProjectDir)..\Modules\encryptedmedia;$(ProjectDir)..\Modules\filesystem;$(ProjectDir)..\Modules\gamepad;$(ProjectDir)..\Modules\geolocation;$(ProjectDir)..\Modules\indexeddb;$(ProjectDir)..\Modules\mediasource;$(ProjectDir)..\Modules\navigatorcontentutils;$(ProjectDir)..\Modules\plugins;$(ProjectDir)..\Modules\speech;$(ProjectDir)..\Modules\proximity;$(ProjectDir)..\Modules\quota;$(ProjectDir)..\Modules\notifications;$(ProjectDir)..\Modules\webdatabase;$(ProjectDir)..\Modules\websockets;$(ProjectDir)..\accessibility;$(ProjectDir)..\accessibility\win;$(ProjectDir)..\bridge;$(ProjectDir)..\bridge\c;$(ProjectDir)..\bridge\jsc;$(ProjectDir)..\css;$(ProjectDir)..\cssjit;$(ProjectDir)..\editing;$(ProjectDir)..\fileapi;$(ProjectDir)..\rendering;$(ProjectDir)..\rendering\line;$(ProjectDir)..\rendering\mathml;$(ProjectDir)..\rendering\shapes;$(ProjectDir)..\rendering\style;$(ProjectDir)..\rendering\svg;$(ProjectDir)..\bindings;$(ProjectDir)..\bindings\generic;$(ProjectDir)..\bindings\js;$(ProjectDir)..\bindings\js\specialization;$(ProjectDir)..\dom;$(ProjectDir)..\dom\default;$(ProjectDir)..\history;$(ProjectDir)..\html;$(ProjectDir)..\html\canvas;$(ProjectDir)..\html\forms;$(ProjectDir)..\html\parser;$(ProjectDir)..\html\shadow;$(ProjectDir)..\html\track;$(ProjectDir)..\inspector;$(ProjectDir)..\loader;$(ProjectDir)..\loader\appcache;$(ProjectDir)..\loader\archive;$(ProjectDir)..\loader\archive\cf;$(ProjectDir)..\loader\cache;$(ProjectDir)..\loader\icon;$(ProjectDir)..\mathml;$(ProjectDir)..\page;$(ProjectDir)..\page\animation;$(ProjectDir)..\page\scrolling;$(ProjectDir)..\page\win;$(ProjectDir)..\platform;$(ProjectDir)..\platform\animation;$(ProjectDir)..\platform\audio;$(ProjectDir)..\platform\mock;$(ProjectDir)..\platform\sql;$(ProjectDir)..\platform\win;$(ProjectDir)..\platform\network;$(ProjectDir)..\platform\network\win;$(ProjectDir)..\platform\cf;$(ProjectDir)..\platform\graphics;$(ProjectDir)..\platform\graphics\ca;$(ProjectDir)..\platform\graphics\cpu\arm\filters;$(ProjectDir)..\platform\graphics\filters;$(ProjectDir)..\platform\graphics\filters\arm;$(ProjectDir)..\platform\graphics\opentype;$(ProjectDir)..\platform\graphics\transforms;$(ProjectDir)..\platform\text;$(ProjectDir)..\platform\text\icu;$(ProjectDir)..\platform\text\transcoder;$(ProjectDir)..\platform\graphics\win;$(ProjectDir)..\xml;$(ProjectDir)..\xml\parser;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources;$(ProjectDir)..\plugins;$(ProjectDir)..\plugins\win;$(ProjectDir)..\replay;$(ProjectDir)..\svg\animation;$(ProjectDir)..\svg\graphics;$(ProjectDir)..\svg\properties;$(ProjectDir)..\svg\graphics\filters;$(ProjectDir)..\svg;$(ProjectDir)..\testing;$(ProjectDir)..\crypto;$(ProjectDir)..\crypto\keys;$(ProjectDir)..\wml;$(ProjectDir)..\storage;$(ProjectDir)..\style;$(ProjectDir)..\websockets;$(ProjectDir)..\workers;$(ConfigurationBuildDir)\include;$(ConfigurationBuildDir)\include\private;$(ConfigurationBuildDir)\include\JavaScriptCore;$(ConfigurationBuildDir)\include\private\JavaScriptCore;$(ProjectDir)..\ForwardingHeaders;$(ProjectDir)..\platform\graphics\gpu;$(ProjectDir)..\platform\graphics\egl;$(ProjectDir)..\platform\graphics\surfaces;$(ProjectDir)..\platform\graphics\surfaces\egl;$(ProjectDir)..\platform\graphics\opengl;$(WebKit_Libraries)\include;$(WebKit_Libraries)\include\private;$(WebKit_Libraries)\include\private\JavaScriptCore;$(WebKit_Libraries)\include\sqlite;$(WebKit_Libraries)\include\JavaScriptCore;$(WebKit_Libraries)\include\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>DISABLE_3D_RENDERING;WEBCORE_CONTEXT_MENUS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>Use</PrecompiledHeader>
       <PrecompiledHeaderFile>WebCorePrefix.h</PrecompiledHeaderFile>
       <ForcedIncludeFiles>WebCorePrefix.h;ICUVersion.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
     </ClCompile>
   </ItemDefinitionGroup>
-</Project>
\ No newline at end of file
+</Project>
index 65c6211..5d3ede9 100644 (file)
       <ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Production|x64'">
       </ForcedIncludeFiles>
     </ClCompile>
+    <ClCompile Include="..\testing\MockCDM.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">NotUsing</PrecompiledHeader>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\InternalSettingsGenerated.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSInternalSettingsGenerated.h" />
     <ClInclude Include="..\testing\MallocStatistics.h" />
     <ClInclude Include="..\testing\MemoryInfo.h" />
+    <ClInclude Include="..\testing\MockCDM.h" />
     <ClInclude Include="..\testing\TypeConversions.h" />
     <ClInclude Include="..\testing\Internals.h" />
     <ClInclude Include="..\testing\InternalSettings.h" />
index 545053b..af7e863 100644 (file)
@@ -39,6 +39,9 @@
     <ClCompile Include="..\testing\js\WebCoreTestSupport.cpp">
       <Filter>testing</Filter>
     </ClCompile>
+    <ClCompile Include="..\testing\MockCDM.cpp">
+      <Filter>testing</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\InternalSettingsGenerated.h">
@@ -81,5 +84,8 @@
       <Filter>testing</Filter>
     </ClInclude>
     <ClInclude Include="..\config.h" />
+    <ClInclude Include="..\testing\MockCDM.h">
+      <Filter>testing</Filter>
+    </ClInclude>
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
index d4abc0b..fb22318 100644 (file)
@@ -42,6 +42,8 @@
 #include "Settings.h"
 #include "SoftLinking.h"
 #include <CoreMedia/CoreMedia.h>
+#include <runtime/DataView.h>
+#include <runtime/Uint16Array.h>
 #include <wtf/MainThread.h>
 #include <wtf/text/CString.h>
 
@@ -1003,6 +1005,59 @@ void MediaPlayerPrivateAVFoundation::playbackTargetIsWirelessChanged()
         m_player->currentPlaybackTargetIsWirelessChanged();
 }
 #endif
+
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+bool MediaPlayerPrivateAVFoundation::extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
+{
+    // initData should have the following layout:
+    // [4 bytes: keyURI length][N bytes: keyURI][4 bytes: contentID length], [N bytes: contentID], [4 bytes: certificate length][N bytes: certificate]
+    if (initData->byteLength() < 4)
+        return false;
+
+    RefPtr<ArrayBuffer> initDataBuffer = initData->buffer();
+
+    // Use a DataView to read uint32 values from the buffer, as Uint32Array requires the reads be aligned on 4-byte boundaries. 
+    RefPtr<JSC::DataView> initDataView = JSC::DataView::create(initDataBuffer, 0, initDataBuffer->byteLength());
+    uint32_t offset = 0;
+    bool status = true;
+
+    uint32_t keyURILength = initDataView->get<uint32_t>(offset, true, &status);
+    offset += 4;
+    if (!status || offset + keyURILength > initData->length())
+        return false;
+
+    RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, offset, keyURILength);
+    if (!keyURIArray)
+        return false;
+
+    keyURI = String(reinterpret_cast<UChar*>(keyURIArray->data()), keyURILength / sizeof(unsigned short));
+    offset += keyURILength;
+
+    uint32_t keyIDLength = initDataView->get<uint32_t>(offset, true, &status);
+    offset += 4;
+    if (!status || offset + keyIDLength > initData->length())
+        return false;
+
+    RefPtr<Uint16Array> keyIDArray = Uint16Array::create(initDataBuffer, offset, keyIDLength);
+    if (!keyIDArray)
+        return false;
+
+    keyID = String(reinterpret_cast<UChar*>(keyIDArray->data()), keyIDLength / sizeof(unsigned short));
+    offset += keyIDLength;
+
+    uint32_t certificateLength = initDataView->get<uint32_t>(offset, true, &status);
+    offset += 4;
+    if (!status || offset + certificateLength > initData->length())
+        return false;
+
+    certificate = Uint8Array::create(initDataBuffer, offset, certificateLength);
+    if (!certificate)
+        return false;
+
+    return true;
+}
+#endif
+
 } // namespace WebCore
 
 #endif
index f70347c..6372038 100644 (file)
@@ -142,6 +142,10 @@ public:
     void dispatchNotification();
     void clearMainThreadPendingFlag();
 
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+    static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate);
+#endif
+
 protected:
     MediaPlayerPrivateAVFoundation(MediaPlayer*);
     virtual ~MediaPlayerPrivateAVFoundation();
index 9eb9ae4..f9d14af 100644 (file)
 
 #include "SoftLinking.h"
 
+#if HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+#include <AVFoundationCF/AVCFPlayerItemLegibleOutput.h>
+#endif
+
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+#include <AVFoundationCF/AVCFAssetResourceLoader.h>
+#endif
+
+#include <d3d9.h>
+
 // Soft-link against AVFoundationCF functions and variables required by MediaPlayerPrivateAVFoundationCF.cpp.
 
 #ifdef DEBUG_ALL
@@ -216,10 +226,11 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFURLAssetCreateWithURLAndOptions, AVCFUR
 #define AVCFURLAssetCreateWithURLAndOptions softLink_AVCFURLAssetCreateWithURLAndOptions
 
 SOFT_LINK_DLL_IMPORT_OPTIONAL(AVFoundationCF, AVCFPlayerSetDirect3DDevice, void, __cdecl, (AVCFPlayerRef player, IDirect3DDevice9* d3dDevice))
+#define AVCFPlayerSetDirect3DDevice softLink_AVCFPlayerSetDirect3DDevice
 
 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
 
-SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetGetSelectionGroupForMediaCharacteristic , AVCFMediaSelectionGroupRef, __cdecl, (AVCFAssetRef asset, CFStringRef mediaCharacteristic), (asset, mediaCharacteristic))
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetGetSelectionGroupForMediaCharacteristic, AVCFMediaSelectionGroupRef, __cdecl, (AVCFAssetRef asset, CFStringRef mediaCharacteristic), (asset, mediaCharacteristic))
 #define AVCFAssetGetSelectionGroupForMediaCharacteristic  softLink_AVCFAssetGetSelectionGroupForMediaCharacteristic 
 
 SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionCopyPlayableOptionsFromArray, CFArrayRef, __cdecl, (CFArrayRef selectionOptions), (selectionOptions))
@@ -270,6 +281,27 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemRemoveOutput, void, __cdecl,
 SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup, void, __cdecl, (AVCFPlayerItemRef playerItem, AVCFMediaSelectionOptionRef selectionOption, AVCFMediaSelectionGroupRef selectionGroup), (playerItem, selectionOption, selectionGroup))
 #define AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup softLink_AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup
 
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFURLAssetCopyURL, CFURLRef, __cdecl, (AVCFURLAssetRef asset), (asset))
+#define AVCFURLAssetCopyURL softLink_AVCFURLAssetCopyURL
+
+#endif
+
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFURLAssetGetResourceLoader, AVCFAssetResourceLoaderRef, __cdecl, (AVCFURLAssetRef asset), (asset))
+#define AVCFURLAssetGetResourceLoader softLink_AVCFURLAssetGetResourceLoader
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetResourceLoaderSetCallbacks, void, __cdecl, (AVCFAssetResourceLoaderRef resourceLoader, const AVCFAssetResourceLoaderCallbacks *callbacks, dispatch_queue_t callbackQueue), (resourceLoader, callbacks, callbackQueue))
+#define AVCFAssetResourceLoaderSetCallbacks  softLink_AVCFAssetResourceLoaderSetCallbacks 
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetResourceLoadingRequestCreateStreamingContentKeyRequestDataForApp, CFDataRef, __cdecl, (AVCFAssetResourceLoadingRequestRef loadingRequest, CFDataRef appIdentifier, CFDataRef contentIdentifier, CFDictionaryRef options, CFErrorRef *outError), (loadingRequest, appIdentifier, contentIdentifier, options, outError))
+#define AVCFAssetResourceLoadingRequestCreateStreamingContentKeyRequestDataForApp  softLink_AVCFAssetResourceLoadingRequestCreateStreamingContentKeyRequestDataForApp 
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetResourceLoadingRequestFinishLoadingWithError, void, __cdecl, (AVCFAssetResourceLoadingRequestRef loadingRequest, CFErrorRef error), (loadingRequest, error))
+#define AVCFAssetResourceLoadingRequestFinishLoadingWithError  softLink_AVCFAssetResourceLoadingRequestFinishLoadingWithError 
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetResourceLoadingRequestGetURLRequest, CFURLRequestRef, __cdecl, (AVCFAssetResourceLoadingRequestRef loadingRequest), (loadingRequest))
+#define AVCFAssetResourceLoadingRequestGetURLRequest  softLink_AVCFAssetResourceLoadingRequestGetURLRequest 
+
 #endif
 
 // Variables
@@ -357,6 +389,9 @@ SOFT_LINK_VARIABLE_DLL_IMPORT_OPTIONAL(AVFoundationCF, AVCFPlayerEnableHardwareA
 SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions, const CFStringRef);
 #define AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions  getAVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions()
 
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey, const CFStringRef);
+#define AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey  getAVCFURLAssetInheritURIQueryComponentFromReferencingURIKey()
+
 SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicEasyToRead, const CFStringRef);
 #define AVCFMediaCharacteristicEasyToRead getAVCFMediaCharacteristicEasyToRead()
 
@@ -384,7 +419,4 @@ SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerAppliesMediaSelectionCri
 SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly, const CFStringRef);
 #define AVCFPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly getAVCFPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly()
 
-SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey, const CFStringRef);
-#define AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey getAVCFURLAssetInheritURIQueryComponentFromReferencingURIKey()
-
 #endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp b/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp
new file mode 100644 (file)
index 0000000..3d6f6c9
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CDMSessionAVFoundationCF.h"
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+
+#include "CDM.h"
+#include "CDMSession.h"
+#include "ExceptionCode.h"
+#include "MediaPlayer.h"
+#include "MediaPlayerPrivateAVFoundationCF.h"
+#include "NotImplemented.h"
+#include "SoftLinking.h"
+#include "UUID.h"
+#include <AVFoundationCF/AVFoundationCF.h>
+#include <wtf/text/CString.h>
+
+// The softlink header files must be included after the AVCF and CoreMedia header files.
+#include "AVFoundationCFSoftLinking.h"
+
+namespace WebCore {
+
+CDMSessionAVFoundationCF::CDMSessionAVFoundationCF(MediaPlayerPrivateAVFoundationCF* parent)
+    : m_parent(parent)
+    , m_client(nullptr)
+    , m_sessionId(createCanonicalUUIDString())
+{
+}
+
+PassRefPtr<Uint8Array> CDMSessionAVFoundationCF::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
+{
+    UNUSED_PARAM(mimeType);
+
+    String keyURI;
+    String keyID;
+    RefPtr<Uint8Array> certificate;
+    if (!MediaPlayerPrivateAVFoundationCF::extractKeyURIKeyIDAndCertificateFromInitData(initData, keyURI, keyID, certificate)) {
+        errorCode = MediaPlayer::InvalidPlayerState;
+        return nullptr;
+    }
+
+    m_request = m_parent->takeRequestForKeyURI(keyURI);
+    if (!m_request) {
+        errorCode = MediaPlayer::InvalidPlayerState;
+        return nullptr;
+    }
+
+    RetainPtr<CFMutableDataRef> certificateData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, certificate->byteLength()));
+    CFDataAppendBytes(certificateData.get(), reinterpret_cast<const UInt8*>(certificate->baseAddress()), certificate->byteLength());
+
+    CString assetStr = keyID.utf8();
+    RetainPtr<CFMutableDataRef> assetID = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, assetStr.length()));
+    CFDataAppendBytes(assetID.get(), reinterpret_cast<const UInt8*>(assetStr.data()), assetStr.length());
+
+    CFErrorRef cfError = nullptr;
+    RetainPtr<CFDataRef> keyRequest = AVCFAssetResourceLoadingRequestCreateStreamingContentKeyRequestDataForApp(m_request.get(), certificateData.get(), assetID.get(), nullptr, &cfError);
+
+    if (!keyRequest) {
+        RetainPtr<CFDictionaryRef> userInfo;
+        if (cfError) {
+            userInfo = adoptCF(CFErrorCopyUserInfo(cfError));
+
+            if (userInfo) {
+                CFErrorRef underlyingError = (CFErrorRef)CFDictionaryGetValue(userInfo.get(), kCFErrorUnderlyingErrorKey);
+                if (underlyingError)
+                    systemCode = CFErrorGetCode(underlyingError);
+            }
+
+            CFRelease(cfError);
+        }
+
+        return nullptr;
+    }
+
+    errorCode = MediaPlayer::NoError;
+    systemCode = 0;
+    destinationURL = String();
+
+    RefPtr<ArrayBuffer> keyRequestBuffer = ArrayBuffer::create(CFDataGetBytePtr(keyRequest.get()), CFDataGetLength(keyRequest.get()));
+    return Uint8Array::create(keyRequestBuffer, 0, keyRequestBuffer->byteLength());
+}
+
+void CDMSessionAVFoundationCF::releaseKeys()
+{
+}
+
+bool CDMSessionAVFoundationCF::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
+{
+    RetainPtr<CFMutableDataRef> keyData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, key->byteLength()));
+    CFDataAppendBytes(keyData.get(), reinterpret_cast<const UInt8*>(key->baseAddress()), key->byteLength());
+
+    // TODO: AVCFAssetResourceLoadingDataRequestRespondWithData(m_request.get(), keyData.get());
+    // TODO: AVCFAssetResourceLoadingRequestFinishedLoading(m_request.get());
+    notImplemented();
+
+    errorCode = MediaPlayer::NoError;
+    systemCode = 0;
+    nextMessage = nullptr;
+
+    return true;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h b/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.h
new file mode 100644 (file)
index 0000000..860b50b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CDMSessionAVFoundationCF_h
+#define CDMSessionAVFoundationCF_h
+
+#include "CDMSession.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+
+typedef struct OpaqueAVCFAssetResourceLoadingRequest* AVCFAssetResourceLoadingRequestRef;
+
+namespace WebCore {
+
+class MediaPlayerPrivateAVFoundationCF;
+
+class CDMSessionAVFoundationCF : public CDMSession {
+public:
+    CDMSessionAVFoundationCF(MediaPlayerPrivateAVFoundationCF* parent);
+    virtual ~CDMSessionAVFoundationCF() { }
+
+    virtual void setClient(CDMSessionClient* client) override { m_client = client; }
+    virtual const String& sessionId() const override { return m_sessionId; }
+    virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode) override;
+    virtual void releaseKeys() override;
+    virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override;
+
+protected:
+    MediaPlayerPrivateAVFoundationCF* m_parent;
+    CDMSessionClient* m_client;
+    String m_sessionId;
+    RetainPtr<AVCFAssetResourceLoadingRequestRef> m_request;
+};
+
+}
+
+#endif
+
+#endif // CDMSessionAVFoundationCF_h
index 0bead9f..fd29590 100644 (file)
@@ -32,6 +32,7 @@
 #include "MediaPlayerPrivateAVFoundationCF.h"
 
 #include "ApplicationCacheResource.h"
+#include "CDMSessionAVFoundationCF.h"
 #include "COMPtr.h"
 #include "FloatConversion.h"
 #include "FrameView.h"
 #include "PlatformCALayerWin.h"
 #include "SoftLinking.h"
 #include "TimeRanges.h"
+#include "WebCoreAVCFResourceLoader.h"
 
 #include <AVFoundationCF/AVCFPlayerItem.h>
 #if HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
 #include <AVFoundationCF/AVCFPlayerItemLegibleOutput.h>
 #endif
 #include <AVFoundationCF/AVCFPlayerLayer.h>
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE) || HAVE(ENCRYPTED_MEDIA_V2)
+#include <AVFoundationCF/AVCFAssetResourceLoader.h>
+#endif
 #include <AVFoundationCF/AVFoundationCF.h>
 #include <CoreMedia/CoreMedia.h>
 #include <d3d9.h>
 #include <delayimp.h>
 #include <dispatch/dispatch.h>
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+#include <runtime/DataView.h>
+#include <runtime/Uint16Array.h>
+#endif
 #include <wtf/HashMap.h>
 #include <wtf/Threading.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringView.h>
 
 // The softlink header files must be included after the AVCF and CoreMedia header files.
 #include "AVFoundationCFSoftLinking.h"
@@ -117,6 +127,9 @@ public:
     static void legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef, CFArrayRef attributedString, CFArrayRef nativeSampleBuffers, CMTime itemTime);
     static void processCue(void* context);
 #endif
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+    static Boolean resourceLoaderShouldWaitForLoadingOfRequestedResource(AVCFAssetResourceLoaderRef, AVCFAssetResourceLoadingRequestRef, void* context);
+#endif
     static void loadMetadataCompletionCallback(AVCFAssetRef, void*);
     static void loadPlayableCompletionCallback(AVCFAssetRef, void*);
     static void periodicTimeObserverCallback(AVCFPlayerRef, CMTime, void*);
@@ -136,6 +149,10 @@ public:
 #endif
     inline dispatch_queue_t dispatchQueue() const { return m_notificationQueue; }
 
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    RetainPtr<AVCFAssetResourceLoadingRequestRef> takeRequestForKeyURI(const String&);
+#endif
+
 private:
     inline void* callbackContext() const { return reinterpret_cast<void*>(m_objectID); }
 
@@ -144,6 +161,10 @@ private:
     static AVFWrapper* avfWrapperForCallbackContext(void*);
     void addToMap();
     void removeFromMap() const;
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+    bool shouldWaitForLoadingOfResource(AVCFAssetResourceLoadingRequestRef avRequest);
+    static void processShouldWaitForLoadingOfResource(void* context);
+#endif
 
     static void disconnectAndDeleteAVFWrapper(void*);
 
@@ -162,6 +183,7 @@ private:
     RetainPtr<AVCFPlayerItemLegibleOutputRef> m_legibleOutput;
     RetainPtr<AVCFMediaSelectionGroupRef> m_selectionGroup;
 #endif
+
     dispatch_queue_t m_notificationQueue;
 
     mutable RetainPtr<CACFLayerRef> m_caVideoLayer;
@@ -171,6 +193,10 @@ private:
     COMPtr<IDirect3DDevice9Ex> m_d3dDevice;
 
     InbandTextTrackPrivateAVF* m_currentTextTrack;
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    HashMap<String, RetainPtr<AVCFAssetResourceLoadingRequestRef>> m_keyURIToRequestMap;
+#endif
 };
 
 uintptr_t AVFWrapper::s_nextAVFWrapperObjectID;
@@ -288,6 +314,24 @@ inline AVCFMediaSelectionGroupRef safeMediaSelectionGroupForLegibleMedia(AVFWrap
 }
 #endif
 
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+static dispatch_queue_t globalQueue = nullptr;
+
+static void initGlobalLoaderDelegateQueue(void* ctx)
+{
+    globalQueue = dispatch_queue_create("WebCoreAVFLoaderDelegate queue", DISPATCH_QUEUE_SERIAL);
+}
+
+static dispatch_queue_t globalLoaderDelegateQueue()
+{
+    static dispatch_once_t onceToken;
+
+    dispatch_once_f(&onceToken, nullptr, initGlobalLoaderDelegateQueue);
+
+    return globalQueue;
+}
+#endif
+
 PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationCF::create(MediaPlayer* player) 
 { 
     return adoptPtr(new MediaPlayerPrivateAVFoundationCF(player));
@@ -310,6 +354,10 @@ MediaPlayerPrivateAVFoundationCF::MediaPlayerPrivateAVFoundationCF(MediaPlayer*
 MediaPlayerPrivateAVFoundationCF::~MediaPlayerPrivateAVFoundationCF()
 {
     LOG(Media, "MediaPlayerPrivateAVFoundationCF::~MediaPlayerPrivateAVFoundationCF(%p)", this);
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+    for (auto& pair : m_resourceLoaderMap)
+        pair.value->invalidate();
+#endif
     cancelLoad();
 }
 
@@ -842,6 +890,15 @@ void MediaPlayerPrivateAVFoundationCF::getSupportedTypes(HashSet<String>& suppor
     supportedTypes = mimeTypeCache();
 } 
 
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+static bool keySystemIsSupported(const String& keySystem)
+{
+    if (equalIgnoringCase(keySystem, "com.apple.fps") || equalIgnoringCase(keySystem, "com.apple.fps.1_0"))
+        return true;
+    return false;
+}
+#endif
+
 MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationCF::supportsType(const MediaEngineSupportParameters& parameters)
 {
     // Only return "IsSupported" if there is no codecs parameter for now as there is no way to ask if it supports an
@@ -858,6 +915,21 @@ bool MediaPlayerPrivateAVFoundationCF::isAvailable()
     return AVFoundationCFLibrary() && CoreMediaLibrary();
 }
 
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+void MediaPlayerPrivateAVFoundationCF::didCancelLoadingRequest(AVCFAssetResourceLoadingRequestRef avRequest)
+{
+    WebCoreAVCFResourceLoader* resourceLoader = m_resourceLoaderMap.get(avRequest);
+
+    if (resourceLoader)
+        resourceLoader->stopLoading();
+}
+
+void MediaPlayerPrivateAVFoundationCF::didStopLoadingRequest(AVCFAssetResourceLoadingRequestRef avRequest)
+{
+    m_resourceLoaderMap.remove(avRequest);
+}
+#endif
+
 float MediaPlayerPrivateAVFoundationCF::mediaTimeForTimeValue(float timeValue) const
 {
     if (!metaDataAvailable())
@@ -1005,6 +1077,24 @@ bool MediaPlayerPrivateAVFoundationCF::requiresImmediateCompositing() const
     return true;
 }
 
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+RetainPtr<AVCFAssetResourceLoadingRequestRef> MediaPlayerPrivateAVFoundationCF::takeRequestForKeyURI(const String& keyURI)
+{
+    if (!m_avfWrapper)
+        return nullptr;
+
+    return m_avfWrapper->takeRequestForKeyURI(keyURI);
+}
+
+std::unique_ptr<CDMSession> MediaPlayerPrivateAVFoundationCF::createSession(const String& keySystem)
+{
+    if (!keySystemIsSupported(keySystem))
+        return nullptr;
+
+    return std::make_unique<CDMSessionAVFoundationCF>(this);
+}
+#endif
+
 #if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
 void MediaPlayerPrivateAVFoundationCF::processLegacyClosedCaptionsTracks()
 {
@@ -1336,8 +1426,18 @@ void AVFWrapper::createAssetForURL(const String& url, bool inheritURI)
     if (inheritURI)
         CFDictionarySetValue(optionsRef.get(), AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey, kCFBooleanTrue);
 
-    AVCFURLAssetRef assetRef = AVCFURLAssetCreateWithURLAndOptions(kCFAllocatorDefault, urlRef.get(), optionsRef.get(), m_notificationQueue);
-    m_avAsset = adoptCF(assetRef);
+    m_avAsset = adoptCF(AVCFURLAssetCreateWithURLAndOptions(kCFAllocatorDefault, urlRef.get(), optionsRef.get(), m_notificationQueue));
+
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+    AVCFAssetResourceLoaderCallbacks loaderCallbacks;
+    loaderCallbacks.version = kAVCFAssetResourceLoader_CallbacksVersion_1;
+    ASSERT(callbackContext());
+    loaderCallbacks.context = callbackContext();
+    loaderCallbacks.resourceLoaderShouldWaitForLoadingOfRequestedResource = AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource;
+
+    RetainPtr<AVCFAssetResourceLoaderRef> resourceLoader = adoptCF(AVCFURLAssetGetResourceLoader(m_avAsset.get()));
+    AVCFAssetResourceLoaderSetCallbacks(resourceLoader.get(), &loaderCallbacks, globalLoaderDelegateQueue());
+#endif
 }
 
 void AVFWrapper::createPlayer(IDirect3DDevice9* d3dDevice)
@@ -1612,7 +1712,7 @@ void AVFWrapper::processCue(void* context)
     if (!context)
         return;
 
-    OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(reinterpret_cast<LegibleOutputData*>(context));
+    std::unique_ptr<LegibleOutputData> legibleOutputData(reinterpret_cast<LegibleOutputData*>(context));
 
     MutexLocker locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(legibleOutputData->m_context);
@@ -1641,9 +1741,100 @@ void AVFWrapper::legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutpu
 
     ASSERT(legibleOutput == self->m_legibleOutput);
 
-    OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(new LegibleOutputData(attributedStrings, nativeSampleBuffers, CMTimeGetSeconds(itemTime), context));
+    auto legibleOutputData = std::make_unique<LegibleOutputData>(attributedStrings, nativeSampleBuffers, CMTimeGetSeconds(itemTime), context);
+
+    dispatch_async_f(dispatch_get_main_queue(), legibleOutputData.release(), processCue);
+}
+#endif
+
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+struct LoadRequestData {
+    RetainPtr<AVCFAssetResourceLoadingRequestRef> m_request;
+    void* m_context;
+
+    LoadRequestData(AVCFAssetResourceLoadingRequestRef request, void* context)
+        : m_request(request), m_context(context)
+    {
+    }
+};
+
+void AVFWrapper::processShouldWaitForLoadingOfResource(void* context)
+{
+    ASSERT(dispatch_get_main_queue() == dispatch_get_current_queue());
+    ASSERT(context);
+
+    if (!context)
+        return;
 
-    dispatch_async_f(dispatch_get_main_queue(), legibleOutputData.leakPtr(), processCue);
+    std::unique_ptr<LoadRequestData> loadRequestData(reinterpret_cast<LoadRequestData*>(context));
+
+    MutexLocker locker(mapLock());
+    AVFWrapper* self = avfWrapperForCallbackContext(loadRequestData->m_context);
+    if (!self) {
+        LOG(Media, "AVFWrapper::processShouldWaitForLoadingOfResource invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
+        AVCFAssetResourceLoadingRequestFinishLoadingWithError(loadRequestData->m_request.get(), nullptr);
+        return;
+    }
+
+    if (!self->shouldWaitForLoadingOfResource(loadRequestData->m_request.get()))
+        AVCFAssetResourceLoadingRequestFinishLoadingWithError(loadRequestData->m_request.get(), nullptr);
+}
+
+bool AVFWrapper::shouldWaitForLoadingOfResource(AVCFAssetResourceLoadingRequestRef avRequest)
+{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    RetainPtr<CFURLRequestRef> urlRequest = AVCFAssetResourceLoadingRequestGetURLRequest(avRequest);
+    RetainPtr<CFURLRef> requestURL = CFURLRequestGetURL(urlRequest.get());
+    RetainPtr<CFStringRef> schemeRef = adoptCF(CFURLCopyScheme(requestURL.get()));
+    String scheme = schemeRef.get();
+
+    if (scheme == "skd") {
+        RetainPtr<CFURLRef> absoluteURL = adoptCF(CFURLCopyAbsoluteURL(requestURL.get()));
+        RetainPtr<CFStringRef> keyURIRef = CFURLGetString(absoluteURL.get());
+        String keyURI = keyURIRef.get();
+
+        // Create an initData with the following layout:
+        // [4 bytes: keyURI size], [keyURI size bytes: keyURI]
+        unsigned keyURISize = keyURI.length() * sizeof(UChar);
+        RefPtr<ArrayBuffer> initDataBuffer = ArrayBuffer::create(4 + keyURISize, 1);
+        RefPtr<JSC::DataView> initDataView = JSC::DataView::create(initDataBuffer, 0, initDataBuffer->byteLength());
+        initDataView->set<uint32_t>(0, keyURISize, true);
+
+        RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
+        keyURIArray->setRange(reinterpret_cast<const uint16_t*>(StringView(keyURI).upconvertedCharacters().get()), keyURI.length() / sizeof(unsigned char), 0);
+
+        RefPtr<Uint8Array> initData = Uint8Array::create(initDataBuffer, 0, initDataBuffer->byteLength());
+        if (!m_owner->player()->keyNeeded(initData.get()))
+            return false;
+
+        m_keyURIToRequestMap.set(keyURI, avRequest);
+        return true;
+    }
+#endif
+
+    RefPtr<WebCoreAVCFResourceLoader> resourceLoader = WebCoreAVCFResourceLoader::create(m_owner, avRequest);
+    m_owner->m_resourceLoaderMap.add(avRequest, resourceLoader);
+    resourceLoader->startLoading();
+    return true;
+}
+
+Boolean AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource(AVCFAssetResourceLoaderRef resourceLoader, AVCFAssetResourceLoadingRequestRef loadingRequest, void *context)
+{
+    ASSERT(dispatch_get_main_queue() != dispatch_get_current_queue());
+    MutexLocker locker(mapLock());
+    AVFWrapper* self = avfWrapperForCallbackContext(context);
+    if (!self) {
+        LOG(Media, "AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
+        return false;
+    }
+
+    LOG(Media, "AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource(%p)", self);
+
+    auto loadRequestData = std::make_unique<LoadRequestData>(loadingRequest, context);
+
+    dispatch_async_f(dispatch_get_main_queue(), loadRequestData.release(), processShouldWaitForLoadingOfResource);
+
+    return true;
 }
 #endif
 
@@ -1787,6 +1978,13 @@ void AVFWrapper::updateVideoLayerGravity()
     // FIXME: <rdar://problem/14884340>
 }
 
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+RetainPtr<AVCFAssetResourceLoadingRequestRef> AVFWrapper::takeRequestForKeyURI(const String& keyURI)
+{
+    return m_keyURIToRequestMap.take(keyURI);
+}
+#endif
+
 void LayerClient::platformCALayerLayoutSublayersOfLayer(PlatformCALayer* wrapperLayer)
 {
     ASSERT(m_parent);
index a546674..bc99ce6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2013-2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #include "MediaPlayerPrivateAVFoundation.h"
 
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE) || HAVE(ENCRYPTED_MEDIA_V2)
+typedef struct OpaqueAVCFAssetResourceLoadingRequest* AVCFAssetResourceLoadingRequestRef;
+#endif
+
 namespace WebCore {
 
 class AVFWrapper;
+class WebCoreAVCFResourceLoader;
 
 class MediaPlayerPrivateAVFoundationCF : public MediaPlayerPrivateAVFoundation {
 public:
@@ -40,6 +45,16 @@ public:
 
     virtual void tracksChanged() override;
 
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+    bool shouldWaitForLoadingOfResource(AVCFAssetResourceLoadingRequestRef);
+    void didCancelLoadingRequest(AVCFAssetResourceLoadingRequestRef);
+    void didStopLoadingRequest(AVCFAssetResourceLoadingRequestRef);
+#endif
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    RetainPtr<AVCFAssetResourceLoadingRequestRef> takeRequestForKeyURI(const String&);
+#endif
+
     static void registerMediaEngine(MediaEngineRegistrar);
 
 private:
@@ -102,6 +117,10 @@ private:
 
     virtual void contentsNeedsDisplay();
 
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    virtual std::unique_ptr<CDMSession> createSession(const String&) override;
+#endif
+
     virtual String languageOfPrimaryAudioTrack() const override;
 
 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
@@ -117,8 +136,14 @@ private:
 
     friend class AVFWrapper;
     AVFWrapper* m_avfWrapper;
-    
+
     mutable String m_languageOfPrimaryAudioTrack;
+
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
+    friend class WebCoreAVCFResourceLoader;
+    HashMap<RetainPtr<AVCFAssetResourceLoadingRequestRef>, RefPtr<WebCoreAVCFResourceLoader>> m_resourceLoaderMap;
+#endif
+
     bool m_videoFrameHasDrawn;
 };
 
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp b/Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp
new file mode 100644 (file)
index 0000000..84ea3e9
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCoreAVCFResourceLoader.h"
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && HAVE(AVFOUNDATION_LOADER_DELEGATE)
+
+#include "CachedRawResource.h"
+#include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
+#include "MediaPlayerPrivateAVFoundationCF.h"
+#include "NotImplemented.h"
+#include "ResourceBuffer.h"
+#include "ResourceLoaderOptions.h"
+#include "SharedBuffer.h"
+#include "SoftLinking.h"
+#include <AVFoundationCF/AVFoundationCF.h>
+#include <AVFoundationCF/AVCFAssetResourceLoader.h>
+#include <wtf/text/CString.h>
+
+// The softlink header files must be included after the AVCF and CoreMedia header files.
+#include "AVFoundationCFSoftLinking.h"
+
+namespace WebCore {
+
+PassRefPtr<WebCoreAVCFResourceLoader> WebCoreAVCFResourceLoader::create(MediaPlayerPrivateAVFoundationCF* parent, AVCFAssetResourceLoadingRequestRef avRequest)
+{
+    ASSERT(avRequest);
+    ASSERT(parent);
+    return adoptRef(new WebCoreAVCFResourceLoader(parent, avRequest));
+}
+
+WebCoreAVCFResourceLoader::WebCoreAVCFResourceLoader(MediaPlayerPrivateAVFoundationCF* parent, AVCFAssetResourceLoadingRequestRef avRequest)
+    : m_parent(parent)
+    , m_avRequest(avRequest)
+{
+}
+
+WebCoreAVCFResourceLoader::~WebCoreAVCFResourceLoader()
+{
+    stopLoading();
+}
+
+void WebCoreAVCFResourceLoader::startLoading()
+{
+    if (m_resource || !m_parent)
+        return;
+
+    RetainPtr<CFURLRequestRef> urlRequest = AVCFAssetResourceLoadingRequestGetURLRequest(m_avRequest.get());
+    URL requestURL = CFURLRequestGetURL(urlRequest.get());
+
+    CachedResourceRequest request(ResourceRequest(requestURL), ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType));
+
+    request.mutableResourceRequest().setPriority(ResourceLoadPriorityLow);
+    CachedResourceLoader* loader = m_parent->player()->cachedResourceLoader();
+    m_resource = loader ? loader->requestRawResource(request) : 0;
+    if (m_resource)
+        m_resource->addClient(this);
+    else {
+        LOG_ERROR("Failed to start load for media at url %s", requestURL.string().ascii().data());
+        AVCFAssetResourceLoadingRequestFinishLoadingWithError(m_avRequest.get(), nullptr);
+    }
+}
+
+void WebCoreAVCFResourceLoader::stopLoading()
+{
+    if (!m_resource)
+        return;
+
+    m_resource->removeClient(this);
+    m_resource = 0;
+
+    if (m_parent)
+        m_parent->didStopLoadingRequest(m_avRequest.get());
+}
+
+void WebCoreAVCFResourceLoader::invalidate()
+{
+    m_parent = nullptr;
+    stopLoading();
+}
+
+void WebCoreAVCFResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse& response)
+{
+    ASSERT(resource == m_resource);
+    UNUSED_PARAM(resource);
+
+    int status = response.httpStatusCode();
+    if (status && (status < 200 || status > 299)) {
+        AVCFAssetResourceLoadingRequestFinishLoadingWithError(m_avRequest.get(), nullptr);
+        return;
+    }
+
+    notImplemented();
+}
+
+void WebCoreAVCFResourceLoader::dataReceived(CachedResource* resource, const char*, int)
+{
+    fulfillRequestWithResource(resource);
+}
+
+void WebCoreAVCFResourceLoader::notifyFinished(CachedResource* resource)
+{
+    if (resource->loadFailedOrCanceled()) {
+        // <rdar://problem/13987417> Set the contentType of the contentInformationRequest to an empty
+        // string to trigger AVAsset's playable value to complete loading.
+        // FIXME: if ([m_avRequest.get() contentInformationRequest] && ![[m_avRequest.get() contentInformationRequest] contentType])
+        // FIXME:    [[m_avRequest.get() contentInformationRequest] setContentType:@""];
+        notImplemented();
+
+        AVCFAssetResourceLoadingRequestFinishLoadingWithError(m_avRequest.get(), nullptr);
+    } else {
+        fulfillRequestWithResource(resource);
+        // FIXME: [m_avRequest.get() finishLoading];
+        notImplemented();
+    }
+    stopLoading();
+}
+
+void WebCoreAVCFResourceLoader::fulfillRequestWithResource(CachedResource* resource)
+{
+    ASSERT(resource == m_resource);
+    notImplemented();
+}
+
+}
+
+#endif // ENABLE(VIDEO) && USE(AVFOUNDATION)
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.h b/Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.h
new file mode 100644 (file)
index 0000000..d2bef84
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebCoreAVCFResourceLoader_h
+#define WebCoreAVCFResourceLoader_h
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && HAVE(AVFOUNDATION_LOADER_DELEGATE)
+
+#include "CachedRawResourceClient.h"
+#include "CachedResourceHandle.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+
+typedef struct OpaqueAVCFAssetResourceLoadingRequest* AVCFAssetResourceLoadingRequestRef;
+
+namespace WebCore {
+
+class CachedRawResource;
+class CachedResourceLoader;
+class MediaPlayerPrivateAVFoundationCF;
+
+class WebCoreAVCFResourceLoader : public RefCounted<WebCoreAVCFResourceLoader>, CachedRawResourceClient {
+    WTF_MAKE_NONCOPYABLE(WebCoreAVCFResourceLoader); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static PassRefPtr<WebCoreAVCFResourceLoader> create(MediaPlayerPrivateAVFoundationCF* parent, AVCFAssetResourceLoadingRequestRef);
+    virtual ~WebCoreAVCFResourceLoader();
+
+    void startLoading();
+    void stopLoading();
+    void invalidate();
+
+    CachedRawResource* resource();
+
+private:
+    // CachedResourceClient
+    virtual void responseReceived(CachedResource*, const ResourceResponse&) override;
+    virtual void dataReceived(CachedResource*, const char*, int) override;
+    virtual void notifyFinished(CachedResource*) override;
+
+    void fulfillRequestWithResource(CachedResource*);
+
+    WebCoreAVCFResourceLoader(MediaPlayerPrivateAVFoundationCF* parent, AVCFAssetResourceLoadingRequestRef);
+    MediaPlayerPrivateAVFoundationCF* m_parent;
+    RetainPtr<AVCFAssetResourceLoadingRequestRef> m_avRequest;
+    CachedResourceHandle<CachedRawResource> m_resource;
+};
+
+}
+
+#endif // ENABLE(VIDEO) && USE(AVFOUNDATION) 
+
+#endif // WebCoreAVFResourceLoader_h
index 720678e..3493ecf 100644 (file)
@@ -87,10 +87,6 @@ public:
     void didStopLoadingRequest(AVAssetResourceLoadingRequest *);
 #endif
 
-#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
-    static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate);
-#endif
-
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     RetainPtr<AVAssetResourceLoadingRequest> takeRequestForKeyURI(const String&);
 #endif
index dab21f4..9848d99 100644 (file)
@@ -1941,58 +1941,6 @@ void MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange(AVPlayerItemV
 }
 #endif
 
-#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
-bool MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
-{
-    // initData should have the following layout:
-    // [4 bytes: keyURI length][N bytes: keyURI][4 bytes: contentID length], [N bytes: contentID], [4 bytes: certificate length][N bytes: certificate]
-    if (initData->byteLength() < 4)
-        return false;
-
-    RefPtr<ArrayBuffer> initDataBuffer = initData->buffer();
-
-    // Use a DataView to read uint32 values from the buffer, as Uint32Array requires the reads be aligned on 4-byte boundaries. 
-    RefPtr<JSC::DataView> initDataView = JSC::DataView::create(initDataBuffer, 0, initDataBuffer->byteLength());
-    uint32_t offset = 0;
-    bool status = true;
-
-    uint32_t keyURILength = initDataView->get<uint32_t>(offset, true, &status);
-    offset += 4;
-    if (!status || offset + keyURILength > initData->length())
-        return false;
-
-    RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, offset, keyURILength);
-    if (!keyURIArray)
-        return false;
-
-    keyURI = String(keyURIArray->data(), keyURILength / sizeof(unsigned short));
-    offset += keyURILength;
-
-    uint32_t keyIDLength = initDataView->get<uint32_t>(offset, true, &status);
-    offset += 4;
-    if (!status || offset + keyIDLength > initData->length())
-        return false;
-
-    RefPtr<Uint16Array> keyIDArray = Uint16Array::create(initDataBuffer, offset, keyIDLength);
-    if (!keyIDArray)
-        return false;
-
-    keyID = String(keyIDArray->data(), keyIDLength / sizeof(unsigned short));
-    offset += keyIDLength;
-
-    uint32_t certificateLength = initDataView->get<uint32_t>(offset, true, &status);
-    offset += 4;
-    if (!status || offset + certificateLength > initData->length())
-        return false;
-
-    certificate = Uint8Array::create(initDataBuffer, offset, certificateLength);
-    if (!certificate)
-        return false;
-
-    return true;
-}
-#endif
-
 #if ENABLE(ENCRYPTED_MEDIA)
 MediaPlayer::MediaKeyException MediaPlayerPrivateAVFoundationObjC::generateKeyRequest(const String& keySystem, const unsigned char* initDataPtr, unsigned initDataLength)
 {
index 5be7dee..daa7bbc 100644 (file)
@@ -1,3 +1,13 @@
+2014-06-27  Brent Fulgham  <bfulgham@apple.com>
+
+        [Win] Implement parts of the AVFOUNDATION_LOADER_DELEGATE logic for Windows
+        https://bugs.webkit.org/show_bug.cgi?id=134418
+
+        Reviewed by Eric Carlson.
+
+        * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: Add new
+        export.
+
 2014-06-26  Brady Eidson  <beidson@apple.com>
 
         Remove use of PlatformStrategies for Gamepad API.
index ca51a87..758632f 100644 (file)
@@ -490,3 +490,6 @@ EXPORTS
         symbolWithPointer(?throwSequenceTypeError@WebCore@@YAXAAVExecState@JSC@@@Z, ?throwSequenceTypeError@WebCore@@YAXAEAVExecState@JSC@@@Z)
         symbolWithPointer(?throwSetterTypeError@WebCore@@YAXAAVExecState@JSC@@PBD1@Z, ?throwSetterTypeError@WebCore@@YAXAEAVExecState@JSC@@PEBD1@Z)
         symbolWithPointer(?throwThisTypeError@WebCore@@YA_JAAVExecState@JSC@@PBD1@Z, ?throwThisTypeError@WebCore@@YA_JAEAVExecState@JSC@@PEBD1@Z)
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+        symbolWithPointer(?registerCDMFactory@CDM@WebCore@@SAXP6A?AV?$unique_ptr@VCDMPrivateInterface@WebCore@@U?$default_delete@VCDMPrivateInterface@WebCore@@@std@@@std@@PAV12@@ZP6A_NABVString@WTF@@@ZP6A_N22@Z@Z,)
+#endif