Skip to content

Commit

Permalink
Fea #90, 为Chromium添加MF相关API
Browse files Browse the repository at this point in the history
- 添加 MFCreateDeviceSource
- 添加 MFEnumDeviceSources
- 添加 MFCreateAlignedMemoryBuffer
- 添加 MFCreateAsyncResult
- 添加 MFCreateAttributes
- 添加 MFCreateEventQueue
- 添加 MFCreateMediaBufferWrapper
- 添加 MFCreateMediaEvent
- 添加 MFCreateMediaType
- 添加 MFCreateMemoryBuffer
- 添加 MFCreatePresentationDescriptor
- 添加 MFCreateSample
- 添加 MFCreateStreamDescriptor
- 添加 MFCreateWaveFormatExFromMFMediaType
- 添加 MFFrameRateToAverageTimePerFrame
- 添加 MFGetSystemTime
- 添加 MFInitMediaTypeFromWaveFormatEx
- 添加 MFShutdown
- 添加 MFStartup
- 添加 MFTEnumEx
- 添加 MFCreateSourceReaderFromMediaSource
  • Loading branch information
mingkuang-Chuyu committed Jun 22, 2024
1 parent d1cf4f6 commit bf520c2
Show file tree
Hide file tree
Showing 10 changed files with 677 additions and 4 deletions.
29 changes: 29 additions & 0 deletions ThunksList.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,42 @@
| Wow64GetThreadContext | 不存在时,调用GetThreadContext或者返回ERROR_INVALID_PARAMETER。
| SetDefaultDllDirectories | 不存在时,手工控制LoadLibrary加载顺序。

## mfplat.dll
| 函数 | Fallback
| ---- | -----------
| MFCreateDeviceSource | 不存在时,返回E_NOTIMPL。
| MFEnumDeviceSources | 不存在时,返回E_NOTIMPL。

## mfplat.dll
| 函数 | Fallback
| ---- | -----------
| MFCreateDXGIDeviceManager | 不存在时,返回E_NOTIMPL。
| MFCreateDXGISurfaceBuffer | 不存在时,返回E_NOTIMPL。
| MFLockDXGIDeviceManager | 不存在时,返回E_NOTIMPL。
| MFUnlockDXGIDeviceManager | 不存在时,返回E_NOTIMPL。
| MFCreateAlignedMemoryBuffer | 不存在时,返回E_NOTIMPL。
| MFCreateAsyncResult | 不存在时,返回E_NOTIMPL。
| MFCreateAttributes | 不存在时,返回E_NOTIMPL。
| MFCreateEventQueue | 不存在时,返回E_NOTIMPL。
| MFCreateMediaBufferWrapper | 不存在时,返回E_NOTIMPL。
| MFCreateMediaEvent | 不存在时,返回E_NOTIMPL。
| MFCreateMediaType | 不存在时,返回E_NOTIMPL。
| MFCreateMemoryBuffer | 不存在时,返回E_NOTIMPL。
| MFCreatePresentationDescriptor | 不存在时,返回E_NOTIMPL。
| MFCreateSample | 不存在时,返回E_NOTIMPL。
| MFCreateStreamDescriptor | 不存在时,返回E_NOTIMPL。
| MFCreateWaveFormatExFromMFMediaType | 不存在时,返回E_NOTIMPL。
| MFFrameRateToAverageTimePerFrame | 不存在时,返回E_NOTIMPL。
| MFGetSystemTime | 不存在时,调用GetSystemTimeAsFileTime。
| MFInitMediaTypeFromWaveFormatEx | 不存在时,返回E_NOTIMPL。
| MFShutdown | 不存在时,返回E_NOTIMPL。
| MFStartup | 不存在时,返回E_NOTIMPL。
| MFTEnumEx | 不存在时,返回E_NOTIMPL。

## mfreadwrite.dll
| 函数 | Fallback
| ---- | -----------
| MFCreateSourceReaderFromMediaSource | 不存在时,返回E_NOTIMPL。

## ndfapi.dll
| 函数 | Fallback
Expand Down
4 changes: 2 additions & 2 deletions src/Build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ goto:eof
:BuildObj
echo BuildObj %1 %2 %3

cl /O1 /Os /Oi /GS- /std:c++17 /arch:IA32 /Z7 /MT /Fo"objs\\%Platform%\\%1" /Zl /c /D "NDEBUG" /D "YY_Thunks_Support_Version=%2" "%~dp0Thunks\YY_Thunks.cpp"
cl /O1 /Os /Oi /GS- /std:c++17 /execution-charset:utf-8 /arch:IA32 /Z7 /MT /Fo"objs\\%Platform%\\%1" /Zl /c /D "NDEBUG" /D "YY_Thunks_Support_Version=%2" "%~dp0Thunks\YY_Thunks.cpp"
if %ErrorLevel% NEQ 0 exit /b %ErrorLevel%

::生成weak符号,一些非必须符号安排为weak可以避免链接失败
Expand All @@ -52,7 +52,7 @@ echo BuildLib %1 %2 %3

md "Lib\\%1\\%Platform%"

cl /O1 /Os /Oi /GS- /std:c++17 /arch:IA32 /Z7 /MT /Fo"Lib\\%1\\%Platform%\\YY_Thunks_for_%1.obj" /Zl /c /D "__APPLY_CHROMIUM_WORKAROUNDS" /D "__USING_NTDLL_LIB" /D "NDEBUG" /D "YY_Thunks_Support_Version=%2" /D "__FALLBACK_PREFIX=YY_Thunks_" "%~dp0Thunks\YY_Thunks.cpp"
cl /O1 /Os /Oi /GS- /std:c++17 /execution-charset:utf-8 /arch:IA32 /Z7 /MT /Fo"Lib\\%1\\%Platform%\\YY_Thunks_for_%1.obj" /Zl /c /D "__APPLY_CHROMIUM_WORKAROUNDS" /D "__USING_NTDLL_LIB" /D "NDEBUG" /D "YY_Thunks_Support_Version=%2" /D "__FALLBACK_PREFIX=YY_Thunks_" "%~dp0Thunks\YY_Thunks.cpp"

if %ErrorLevel% NEQ 0 exit /b %ErrorLevel%

Expand Down
4 changes: 2 additions & 2 deletions src/Thunks/PropSys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ namespace YY::Thunks::internal
{
case VT_I8:
{
LONG64 _Tmp = _Left.dblVal;
LONG64 _Tmp = LONG64(_Left.dblVal);
if (_Tmp < _Rigth.llVal)
{
return -1;
Expand All @@ -248,7 +248,7 @@ namespace YY::Thunks::internal
}
else
{
ULONG64 _Tmp = _Left.dblVal;
ULONG64 _Tmp = LONG64(_Left.dblVal);
if (_Tmp < _Rigth.ullVal)
{
return -1;
Expand Down
2 changes: 2 additions & 0 deletions src/Thunks/YY_Thunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ YY-Thunks支持的控制宏:
_APPLY(ole32, "ole32" , 0 ) \
_APPLY(iphlpapi, "iphlpapi" , 0 ) \
_APPLY(userenv, "userenv" , 0 ) \
_APPLY(mf, "mf" , 0 ) \
_APPLY(mfplat, "mfplat" , 0 ) \
_APPLY(mfreadwrite, "mfreadwrite" , 0 ) \
_APPLY(ndfapi, "ndfapi" , 0 ) \
_APPLY(bluetoothapis, "bluetoothapis" , 0 ) \
_APPLY(netapi32, "netapi32" , 0 ) \
Expand Down
65 changes: 65 additions & 0 deletions src/Thunks/mf.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#if (YY_Thunks_Support_Version < NTDDI_WIN7)
#include <mfidl.h>
#endif

namespace YY::Thunks
{
#if (YY_Thunks_Support_Version < NTDDI_WIN7)

// Minimum supported client Windows 7 [desktop apps only]
// Minimum supported server Windows Server 2008 R2[desktop apps only]
__DEFINE_THUNK(
mf,
8,
HRESULT,
STDAPICALLTYPE,
MFCreateDeviceSource,
_In_ IMFAttributes* pAttributes,
_Outptr_ IMFMediaSource** ppSource
)
{
if (const auto _pfnMFCreateDeviceSource = try_get_MFCreateDeviceSource())
{
return _pfnMFCreateDeviceSource(pAttributes, ppSource);
}

if (!ppSource)
return E_POINTER;

*ppSource = nullptr;
return E_NOTIMPL;
}
#endif


#if (YY_Thunks_Support_Version < NTDDI_WIN7)

// Minimum supported client Windows 7 [desktop apps only]
// Minimum supported server Windows Server 2008 R2[desktop apps only]
__DEFINE_THUNK(
mf,
12,
HRESULT,
STDAPICALLTYPE,
MFEnumDeviceSources,
_In_ IMFAttributes* pAttributes,
_Outptr_result_buffer_(*pcSourceActivate) IMFActivate*** pppSourceActivate,
_Out_ UINT32* pcSourceActivate
)
{
if (const auto _pfnMFEnumDeviceSources = try_get_MFEnumDeviceSources())
{
return _pfnMFEnumDeviceSources(pAttributes, pppSourceActivate, pcSourceActivate);
}

if (!pcSourceActivate)
return E_POINTER;
*pcSourceActivate = 0;

if (!pppSourceActivate)
return E_POINTER;
*pppSourceActivate = nullptr;
return E_NOTIMPL;
}
#endif
}
Loading

0 comments on commit bf520c2

Please sign in to comment.