[WinCairo][MediaFoundation] Stop using soft linking for Media Foundation
authorHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2019 02:10:09 +0000 (02:10 +0000)
committerHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2019 02:10:09 +0000 (02:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198783

Reviewed by Alex Christensen.

WinCairo is supporting Windows 7 or newer. It doesn't need soft
linking anymore.

No new tests because there is no behavior change.

* PlatformWinCairo.cmake: Added libraries to WebCore_LIBRARIES.
* platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
(WebCore::mimeTypeCache):
(WebCore::MediaPlayerPrivateMediaFoundation::setRate):
(WebCore::MediaPlayerPrivateMediaFoundation::setAllChannelVolumes):
(WebCore::MediaPlayerPrivateMediaFoundation::createSession):
(WebCore::MediaPlayerPrivateMediaFoundation::endSession):
(WebCore::MediaPlayerPrivateMediaFoundation::startCreateMediaSource):
(WebCore::MediaPlayerPrivateMediaFoundation::createTopologyFromSource):
(WebCore::MediaPlayerPrivateMediaFoundation::createOutputNode):
(WebCore::MediaPlayerPrivateMediaFoundation::createSourceStreamNode):
(WebCore::MediaPlayerPrivateMediaFoundation::updateReadyState):
(WebCore::MediaPlayerPrivateMediaFoundation::videoDisplay):
(WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::createOptimalVideoType):
(WebCore::MediaPlayerPrivateMediaFoundation::VideoScheduler::setFrameRate):
(WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::presentSample):
(WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::initializeD3D):
(WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::createD3DSample):

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

Source/WebCore/ChangeLog
Source/WebCore/PlatformWinCairo.cmake
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp

index c3a4bb7..fae0ed5 100644 (file)
@@ -1,3 +1,34 @@
+2019-06-27  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [WinCairo][MediaFoundation] Stop using soft linking for Media Foundation
+        https://bugs.webkit.org/show_bug.cgi?id=198783
+
+        Reviewed by Alex Christensen.
+
+        WinCairo is supporting Windows 7 or newer. It doesn't need soft
+        linking anymore.
+
+        No new tests because there is no behavior change.
+
+        * PlatformWinCairo.cmake: Added libraries to WebCore_LIBRARIES.
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
+        (WebCore::mimeTypeCache):
+        (WebCore::MediaPlayerPrivateMediaFoundation::setRate):
+        (WebCore::MediaPlayerPrivateMediaFoundation::setAllChannelVolumes):
+        (WebCore::MediaPlayerPrivateMediaFoundation::createSession):
+        (WebCore::MediaPlayerPrivateMediaFoundation::endSession):
+        (WebCore::MediaPlayerPrivateMediaFoundation::startCreateMediaSource):
+        (WebCore::MediaPlayerPrivateMediaFoundation::createTopologyFromSource):
+        (WebCore::MediaPlayerPrivateMediaFoundation::createOutputNode):
+        (WebCore::MediaPlayerPrivateMediaFoundation::createSourceStreamNode):
+        (WebCore::MediaPlayerPrivateMediaFoundation::updateReadyState):
+        (WebCore::MediaPlayerPrivateMediaFoundation::videoDisplay):
+        (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::createOptimalVideoType):
+        (WebCore::MediaPlayerPrivateMediaFoundation::VideoScheduler::setFrameRate):
+        (WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::presentSample):
+        (WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::initializeD3D):
+        (WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::createD3DSample):
+
 2019-06-27  Basuke Suzuki  <Basuke.Suzuki@sony.com>
 
          Fix build error on WebCore when disabling ENABLE_INDEXED_DATABASE.
index be04b83..e3e478a 100644 (file)
@@ -4,7 +4,6 @@ include(platform/ImageDecoders.cmake)
 include(platform/TextureMapper.cmake)
 
 list(APPEND WebCore_PRIVATE_INCLUDE_DIRECTORIES
-    "${DirectX_INCLUDE_DIRS}"
     "${WEBKIT_LIBRARIES_DIR}/include"
     "${WEBCORE_DIR}/loader/archive/cf"
     "${WEBCORE_DIR}/platform/cf"
@@ -38,9 +37,13 @@ list(APPEND WebCore_SOURCES
 )
 
 list(APPEND WebCore_LIBRARIES
-    ${DirectX_LIBRARIES}
+    D3d9
+    Mf
+    Mfplat
     comctl32
     crypt32
+    dxva2
+    evr
     iphlpapi
     rpcrt4
     shlwapi
index c6fa6d4..f48c077 100644 (file)
 #include "PlatformContextCairo.h"
 #include <cairo.h>
 #endif
-#include <wtf/SoftLinking.h>
 
 #if USE(MEDIA_FOUNDATION)
 
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
 
-SOFT_LINK_LIBRARY(Mf);
-SOFT_LINK_OPTIONAL(Mf, MFCreateSourceResolver, HRESULT, STDAPICALLTYPE, (IMFSourceResolver**));
-SOFT_LINK_OPTIONAL(Mf, MFCreateMediaSession, HRESULT, STDAPICALLTYPE, (IMFAttributes*, IMFMediaSession**));
-SOFT_LINK_OPTIONAL(Mf, MFCreateTopology, HRESULT, STDAPICALLTYPE, (IMFTopology**));
-SOFT_LINK_OPTIONAL(Mf, MFCreateTopologyNode, HRESULT, STDAPICALLTYPE, (MF_TOPOLOGY_TYPE, IMFTopologyNode**));
-SOFT_LINK_OPTIONAL(Mf, MFGetService, HRESULT, STDAPICALLTYPE, (IUnknown*, REFGUID, REFIID, LPVOID*));
-SOFT_LINK_OPTIONAL(Mf, MFCreateAudioRendererActivate, HRESULT, STDAPICALLTYPE, (IMFActivate**));
-SOFT_LINK_OPTIONAL(Mf, MFCreateVideoRendererActivate, HRESULT, STDAPICALLTYPE, (HWND, IMFActivate**));
-SOFT_LINK_OPTIONAL(Mf, MFGetSupportedMimeTypes, HRESULT, STDAPICALLTYPE, (PROPVARIANT*));
-
-SOFT_LINK_LIBRARY(Mfplat);
-SOFT_LINK_OPTIONAL(Mfplat, MFStartup, HRESULT, STDAPICALLTYPE, (ULONG, DWORD));
-SOFT_LINK_OPTIONAL(Mfplat, MFShutdown, HRESULT, STDAPICALLTYPE, ());
-SOFT_LINK_OPTIONAL(Mfplat, MFCreateMediaType, HRESULT, STDAPICALLTYPE, (IMFMediaType**));
-SOFT_LINK_OPTIONAL(Mfplat, MFFrameRateToAverageTimePerFrame, HRESULT, STDAPICALLTYPE, (UINT32, UINT32, UINT64*));
-
-SOFT_LINK_LIBRARY(evr);
-SOFT_LINK_OPTIONAL(evr, MFCreateVideoSampleFromSurface, HRESULT, STDAPICALLTYPE, (IUnknown*, IMFSample**));
-
-SOFT_LINK_LIBRARY(Dxva2);
-SOFT_LINK_OPTIONAL(Dxva2, DXVA2CreateDirect3DDeviceManager9, HRESULT, STDAPICALLTYPE, (UINT*, IDirect3DDeviceManager9**));
-
-SOFT_LINK_LIBRARY(D3d9);
-SOFT_LINK_OPTIONAL(D3d9, Direct3DCreate9Ex, HRESULT, STDAPICALLTYPE, (UINT, IDirect3D9Ex**));
-
 // MFSamplePresenterSampleCounter
 // Data type: UINT32
 //
@@ -127,13 +101,10 @@ static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
 
     cachedTypes.get().add(String("video/mp4"));
 
-    if (!MFGetSupportedMimeTypesPtr())
-        return cachedTypes;
-
     PROPVARIANT propVarMimeTypeArray;
     PropVariantInit(&propVarMimeTypeArray);
 
-    HRESULT hr = MFGetSupportedMimeTypesPtr()(&propVarMimeTypeArray);
+    HRESULT hr = MFGetSupportedMimeTypes(&propVarMimeTypeArray);
 
     if (SUCCEEDED(hr)) {
         CALPWSTR mimeTypeArray = propVarMimeTypeArray.calpwstr;
@@ -247,7 +218,7 @@ void MediaPlayerPrivateMediaFoundation::setRate(float rate)
 {
     COMPtr<IMFRateControl> rateControl;
 
-    HRESULT hr = MFGetServicePtr()(m_mediaSession.get(), MF_RATE_CONTROL_SERVICE, IID_IMFRateControl, (void**)&rateControl);
+    HRESULT hr = MFGetService(m_mediaSession.get(), MF_RATE_CONTROL_SERVICE, IID_IMFRateControl, (void**)&rateControl);
 
     if (!SUCCEEDED(hr))
         return;
@@ -289,11 +260,8 @@ bool MediaPlayerPrivateMediaFoundation::paused() const
 
 bool MediaPlayerPrivateMediaFoundation::setAllChannelVolumes(float volume)
 {
-    if (!MFGetServicePtr())
-        return false;
-
     COMPtr<IMFAudioStreamVolume> audioVolume;
-    if (!SUCCEEDED(MFGetServicePtr()(m_mediaSession.get(), MR_STREAM_VOLUME_SERVICE, __uuidof(IMFAudioStreamVolume), (void **)&audioVolume)))
+    if (!SUCCEEDED(MFGetService(m_mediaSession.get(), MR_STREAM_VOLUME_SERVICE, __uuidof(IMFAudioStreamVolume), (void **)&audioVolume)))
         return false;
 
     UINT32 channelsCount;
@@ -381,13 +349,10 @@ void MediaPlayerPrivateMediaFoundation::paint(GraphicsContext& context, const Fl
 
 bool MediaPlayerPrivateMediaFoundation::createSession()
 {
-    if (!MFStartupPtr() || !MFCreateMediaSessionPtr())
-        return false;
-
-    if (FAILED(MFStartupPtr()(MF_VERSION, MFSTARTUP_FULL)))
+    if (FAILED(MFStartup(MF_VERSION, MFSTARTUP_FULL)))
         return false;
 
-    if (FAILED(MFCreateMediaSessionPtr()(nullptr, &m_mediaSession)))
+    if (FAILED(MFCreateMediaSession(nullptr, &m_mediaSession)))
         return false;
 
     // Get next event.
@@ -422,10 +387,7 @@ bool MediaPlayerPrivateMediaFoundation::endSession()
         m_mediaSession = nullptr;
     }
 
-    if (!MFShutdownPtr())
-        return false;
-
-    HRESULT hr = MFShutdownPtr()();
+    HRESULT hr = MFShutdown();
     ASSERT_UNUSED(hr, SUCCEEDED(hr));
 
     return true;
@@ -433,10 +395,7 @@ bool MediaPlayerPrivateMediaFoundation::endSession()
 
 bool MediaPlayerPrivateMediaFoundation::startCreateMediaSource(const String& url)
 {
-    if (!MFCreateSourceResolverPtr())
-        return false;
-
-    if (FAILED(MFCreateSourceResolverPtr()(&m_sourceResolver)))
+    if (FAILED(MFCreateSourceResolver(&m_sourceResolver)))
         return false;
 
     COMPtr<IUnknown> cancelCookie;
@@ -564,11 +523,11 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult)
 
 bool MediaPlayerPrivateMediaFoundation::createTopologyFromSource()
 {
-    if (!MFCreateTopologyPtr())
+    if (!MFCreateTopology)
         return false;
 
     // Create a new topology.
-    if (FAILED(MFCreateTopologyPtr()(&m_topology)))
+    if (FAILED(MFCreateTopology(&m_topology)))
         return false;
 
     // Create the presentation descriptor for the media source.
@@ -677,9 +636,6 @@ void MediaPlayerPrivateMediaFoundation::setNaturalSize(const FloatSize& size)
 
 bool MediaPlayerPrivateMediaFoundation::createOutputNode(COMPtr<IMFStreamDescriptor> sourceSD, COMPtr<IMFTopologyNode>& node)
 {
-    if (!MFCreateTopologyNodePtr() || !MFCreateAudioRendererActivatePtr() || !MFCreateVideoRendererActivatePtr())
-        return false;
-
     if (!sourceSD)
         return false;
 
@@ -698,19 +654,19 @@ bool MediaPlayerPrivateMediaFoundation::createOutputNode(COMPtr<IMFStreamDescrip
         return false;
 
     // Create a downstream node.
-    if (FAILED(MFCreateTopologyNodePtr()(MF_TOPOLOGY_OUTPUT_NODE, &node)))
+    if (FAILED(MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &node)))
         return false;
 
     // Create an IMFActivate object for the renderer, based on the media type.
     COMPtr<IMFActivate> rendererActivate;
     if (MFMediaType_Audio == guidMajorType) {
         // Create the audio renderer.
-        if (FAILED(MFCreateAudioRendererActivatePtr()(&rendererActivate)))
+        if (FAILED(MFCreateAudioRendererActivate(&rendererActivate)))
             return false;
         m_hasAudio = true;
     } else if (MFMediaType_Video == guidMajorType) {
         // Create the video renderer.
-        if (FAILED(MFCreateVideoRendererActivatePtr()(nullptr, &rendererActivate)))
+        if (FAILED(MFCreateVideoRendererActivate(nullptr, &rendererActivate)))
             return false;
 
         m_presenter = new CustomVideoPresenter(this);
@@ -730,14 +686,11 @@ bool MediaPlayerPrivateMediaFoundation::createOutputNode(COMPtr<IMFStreamDescrip
 
 bool MediaPlayerPrivateMediaFoundation::createSourceStreamNode(COMPtr<IMFStreamDescriptor> sourceSD, COMPtr<IMFTopologyNode>& node)
 {
-    if (!MFCreateTopologyNodePtr())
-        return false;
-
     if (!m_mediaSource || !m_sourcePD || !sourceSD)
         return false;
 
     // Create the source-stream node.
-    HRESULT hr = MFCreateTopologyNodePtr()(MF_TOPOLOGY_SOURCESTREAM_NODE, &node);
+    HRESULT hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node);
     if (FAILED(hr))
         return false;
 
@@ -761,13 +714,10 @@ bool MediaPlayerPrivateMediaFoundation::createSourceStreamNode(COMPtr<IMFStreamD
 
 void MediaPlayerPrivateMediaFoundation::updateReadyState()
 {
-    if (!MFGetServicePtr())
-        return;
-
     COMPtr<IPropertyStore> prop;
 
     // Get the property store from the media session.
-    HRESULT hr = MFGetServicePtr()(m_mediaSession.get(), MFNETSOURCE_STATISTICS_SERVICE, IID_PPV_ARGS(&prop));
+    HRESULT hr = MFGetService(m_mediaSession.get(), MFNETSOURCE_STATISTICS_SERVICE, IID_PPV_ARGS(&prop));
 
     if (FAILED(hr))
         return;
@@ -807,10 +757,7 @@ COMPtr<IMFVideoDisplayControl> MediaPlayerPrivateMediaFoundation::videoDisplay()
     if (m_videoDisplay)
         return m_videoDisplay;
 
-    if (!MFGetServicePtr())
-        return nullptr;
-
-    MFGetServicePtr()(m_mediaSession.get(), MR_VIDEO_RENDER_SERVICE, IID_PPV_ARGS(&m_videoDisplay));
+    MFGetService(m_mediaSession.get(), MR_VIDEO_RENDER_SERVICE, IID_PPV_ARGS(&m_videoDisplay));
 
     return m_videoDisplay;
 }
@@ -1778,7 +1725,7 @@ HRESULT MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::isMediaTypeSupp
 HRESULT MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::createOptimalVideoType(IMFMediaType* proposedType, IMFMediaType** optimalType)
 {
     COMPtr<IMFMediaType> optimalVideoType;
-    HRESULT hr = MFCreateMediaTypePtr()(&optimalVideoType);
+    HRESULT hr = MFCreateMediaType(&optimalVideoType);
     if (FAILED(hr))
         return hr;
     hr = optimalVideoType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
@@ -2301,7 +2248,7 @@ enum ScheduleEvent {
 void MediaPlayerPrivateMediaFoundation::VideoScheduler::setFrameRate(const MFRatio& fps)
 {
     UINT64 avgTimePerFrame = 0;
-    MFFrameRateToAverageTimePerFramePtr()(fps.Numerator, fps.Denominator, &avgTimePerFrame);
+    MFFrameRateToAverageTimePerFrame(fps.Numerator, fps.Denominator, &avgTimePerFrame);
 
     m_frameDuration = (MFTIME)avgTimePerFrame;
 }
@@ -2799,7 +2746,7 @@ HRESULT MediaPlayerPrivateMediaFoundation::Direct3DPresenter::presentSample(IMFS
     if (sample) {
         COMPtr<IMFMediaBuffer> buffer;
         hr = sample->GetBufferByIndex(0, &buffer);
-        hr = MFGetServicePtr()(buffer.get(), MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&surface);
+        hr = MFGetService(buffer.get(), MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&surface);
     } else if (m_surfaceRepaint) {
         // Use the last surface.
         surface = m_surfaceRepaint;
@@ -2903,11 +2850,11 @@ HRESULT MediaPlayerPrivateMediaFoundation::Direct3DPresenter::initializeD3D()
     ASSERT(!m_direct3D9);
     ASSERT(!m_deviceManager);
 
-    HRESULT hr = Direct3DCreate9ExPtr()(D3D_SDK_VERSION, &m_direct3D9);
+    HRESULT hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &m_direct3D9);
     if (FAILED(hr))
         return hr;
 
-    return DXVA2CreateDirect3DDeviceManager9Ptr()(&m_deviceResetToken, &m_deviceManager);
+    return DXVA2CreateDirect3DDeviceManager9(&m_deviceResetToken, &m_deviceManager);
 }
 
 HRESULT MediaPlayerPrivateMediaFoundation::Direct3DPresenter::createD3DDevice()
@@ -2990,7 +2937,7 @@ HRESULT MediaPlayerPrivateMediaFoundation::Direct3DPresenter::createD3DSample(ID
     if (FAILED(hr))
         return hr;
 
-    return MFCreateVideoSampleFromSurfacePtr()(surface.get(), &videoSample);
+    return MFCreateVideoSampleFromSurface(surface.get(), &videoSample);
 }
 
 HRESULT MediaPlayerPrivateMediaFoundation::Direct3DPresenter::getSwapChainPresentParameters(IMFMediaType* type, D3DPRESENT_PARAMETERS* presentParams)