Sorry for sending a duplication. Blaming bad network...
Signed-off-by: Jactry Zeng <jzeng@codeweavers.com>
---
dlls/mfmediaengine/main.c | 482 ++++++++++++++++++++++-
dlls/mfmediaengine/tests/Makefile.in | 2 +-
dlls/mfmediaengine/tests/mfmediaengine.c | 152 +++++++
include/mfmediaengine.idl | 51 +++
4 files changed, 684 insertions(+), 3 deletions(-)
diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c
index 4bca0fe0ba..9e33b973d4 100644
--- a/dlls/mfmediaengine/main.c
+++ b/dlls/mfmediaengine/main.c
@@ -24,8 +24,11 @@
#include "winbase.h"
#include "mfmediaengine.h"
+#include "mferror.h"
+#include "dxgi.h"
#include "wine/debug.h"
+#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -43,6 +46,432 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
return TRUE;
}
+enum media_engine_mode
+{
+ MEDIA_ENGINE_INVIAL,
+ MEDIA_ENGINE_AUDIO_MODE,
+ MEDIA_ENGINE_RENDERING_MODE,
+ MEDIA_ENGINE_FRAME_SERVER_MODE,
+};
+
+struct media_engine_attributes
+{
+ IMFMediaEngineNotify *callback;
+ HWND playback_hwnd;
+ DXGI_FORMAT output_format;
+ IMFDXGIDeviceManager *dxgi_manager;
+ enum media_engine_mode mode;
+};
+
+struct media_engine
+{
+ IMFMediaEngine IMFMediaEngine_iface;
+ LONG refcount;
+ DWORD flags;
+ struct media_engine_attributes attributes;
+};
+
+static inline struct media_engine *impl_from_IMFMediaEngine(IMFMediaEngine *iface)
+{
+ return CONTAINING_RECORD(iface, struct media_engine, IMFMediaEngine_iface);
+}
+
+static HRESULT WINAPI media_engine_QueryInterface(IMFMediaEngine *iface, REFIID riid, void **obj)
+{
+ TRACE("(%p, %s, %p).\n", iface, debugstr_guid(riid), obj);
+
+ if (IsEqualIID(riid, &IID_IMFMediaEngine) ||
+ IsEqualIID(riid, &IID_IUnknown))
+ {
+ *obj = iface;
+ IMFMediaEngine_AddRef(iface);
+ return S_OK;
+ }
+
+ WARN("Unsupported interface %s.\n", debugstr_guid(riid));
+ *obj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI media_engine_AddRef(IMFMediaEngine *iface)
+{
+ struct media_engine *engine = impl_from_IMFMediaEngine(iface);
+ ULONG refcount = InterlockedIncrement(&engine->refcount);
+
+ TRACE("(%p) ref=%u.\n", iface, refcount);
+
+ return refcount;
+}
+
+static void free_media_engine_attributes(struct media_engine_attributes engine_attr)
+{
+ if (engine_attr.callback)
+ IMFMediaEngineNotify_Release(engine_attr.callback);
+ if (engine_attr.dxgi_manager)
+ IMFDXGIDeviceManager_Release(engine_attr.dxgi_manager);
+}
+
+static ULONG WINAPI media_engine_Release(IMFMediaEngine *iface)
+{
+ struct media_engine *engine = impl_from_IMFMediaEngine(iface);
+ ULONG refcount = InterlockedDecrement(&engine->refcount);
+
+ TRACE("(%p) ref=%u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ free_media_engine_attributes(engine->attributes);
+ HeapFree(GetProcessHeap(), 0, engine);
+ }
+
+ return refcount;
+}
+
+static HRESULT WINAPI media_engine_GetError(IMFMediaEngine *iface, IMFMediaError **error)
+{
+ FIXME("(%p, %p): stub.\n", iface, error);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_SetErrorCode(IMFMediaEngine *iface, MF_MEDIA_ENGINE_ERR error)
+{
+ FIXME("(%p, %d): stub.\n", iface, error);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_SetSourceElements(IMFMediaEngine *iface, IMFMediaEngineSrcElements *elements)
+{
+ FIXME("(%p, %p): stub.\n", iface, elements);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_SetSource(IMFMediaEngine *iface, BSTR url)
+{
+ FIXME("(%p, %s): stub.\n", iface, debugstr_w(url));
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_GetCurrentSource(IMFMediaEngine *iface, BSTR *url)
+{
+ FIXME("(%p, %p): stub.\n", iface, url);
+
+ return E_NOTIMPL;
+}
+
+static USHORT WINAPI media_engine_GetNetworkState(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static MF_MEDIA_ENGINE_PRELOAD WINAPI media_engine_GetPreload(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return MF_MEDIA_ENGINE_PRELOAD_NONE;
+}
+
+static HRESULT WINAPI media_engine_SetPreload(IMFMediaEngine *iface, MF_MEDIA_ENGINE_PRELOAD preload)
+{
+ FIXME("(%p, %d): stub.\n", iface, preload);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_GetBuffered(IMFMediaEngine *iface, IMFMediaTimeRange **buffered)
+{
+ FIXME("(%p, %p): stub.\n", iface, buffered);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_Load(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_CanPlayType(IMFMediaEngine *iface, BSTR type, MF_MEDIA_ENGINE_CANPLAY *answer)
+{
+ FIXME("(%p, %s, %p): stub.\n", iface, debugstr_w(type), answer);
+
+ return E_NOTIMPL;
+}
+
+static USHORT WINAPI media_engine_GetReadyState(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static BOOL WINAPI media_engine_IsSeeking(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return FALSE;
+}
+
+static double WINAPI media_engine_GetCurrentTime(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static HRESULT WINAPI media_engine_SetCurrentTime(IMFMediaEngine *iface, double time)
+{
+ FIXME("(%p, %f): stub.\n", iface, time);
+
+ return E_NOTIMPL;
+}
+
+static double WINAPI media_engine_GetStartTime(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static double WINAPI media_engine_GetDuration(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static BOOL WINAPI media_engine_IsPaused(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static double WINAPI media_engine_GetDefaultPlaybackRate(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static HRESULT WINAPI media_engine_SetDefaultPlaybackRate(IMFMediaEngine *iface, double rate)
+{
+ FIXME("(%p, %f): stub.\n", iface, rate);
+
+ return E_NOTIMPL;
+}
+
+static double WINAPI media_engine_GetPlaybackRate(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static HRESULT WINAPI media_engine_SetPlaybackRate(IMFMediaEngine *iface, double rate)
+{
+ FIXME("(%p, %f): stub.\n", iface, rate);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_GetPlayed(IMFMediaEngine *iface, IMFMediaTimeRange **played)
+{
+ FIXME("(%p, %p): stub.\n", iface, played);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_GetSeekable(IMFMediaEngine *iface, IMFMediaTimeRange **seekable)
+{
+ FIXME("(%p, %p): stub.\n", iface, seekable);
+
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI media_engine_IsEnded(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI media_engine_GetAutoPlay(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_SetAutoPlay(IMFMediaEngine *iface, BOOL autoplay)
+{
+ FIXME("(%p, %d): stub.\n", iface, autoplay);
+
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI media_engine_GetLoop(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return FALSE;
+}
+
+static HRESULT WINAPI media_engine_SetLoop(IMFMediaEngine *iface, BOOL loop)
+{
+ FIXME("(%p, %d): stub.\n", iface, loop);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_Play(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_Pause(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI media_engine_GetMuted(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return FALSE;
+}
+
+static HRESULT WINAPI media_engine_SetMuted(IMFMediaEngine *iface, BOOL muted)
+{
+ FIXME("(%p, %d): stub.\n", iface, muted);
+
+ return E_NOTIMPL;
+}
+
+static double WINAPI media_engine_GetVolume(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return 0;
+}
+
+static HRESULT WINAPI media_engine_SetVolume(IMFMediaEngine *iface, double volume)
+{
+ FIXME("(%p, %f): stub.\n", iface, volume);
+
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI media_engine_HasVideo(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return FALSE;
+}
+
+static BOOL WINAPI media_engine_HasAudio(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return FALSE;
+}
+
+static HRESULT WINAPI media_engine_GetNativeVideoSize(IMFMediaEngine *iface, DWORD *cx, DWORD *cy)
+{
+ FIXME("(%p, %p, %p): stub.\n", iface, cx, cy);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_GetVideoAspectRatio(IMFMediaEngine *iface, DWORD *cx, DWORD *cy)
+{
+ FIXME("(%p, %p, %p): stub.\n", iface, cx, cy);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_Shutdown(IMFMediaEngine *iface)
+{
+ FIXME("(%p): stub.\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_TransferVideoFrame(IMFMediaEngine *iface, IUnknown *surface,
+ const MFVideoNormalizedRect *src,
+ const RECT *dst, const MFARGB *color)
+{
+ FIXME("(%p, %p, %p, %p, %p): stub.\n", iface, surface, src, dst, color);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI media_engine_OnVideoStreamTick(IMFMediaEngine *iface, LONGLONG *time)
+{
+ FIXME("(%p, %p): stub.\n", iface, time);
+
+ return E_NOTIMPL;
+}
+
+static const IMFMediaEngineVtbl media_engine_vtbl =
+{
+ media_engine_QueryInterface,
+ media_engine_AddRef,
+ media_engine_Release,
+ media_engine_GetError,
+ media_engine_SetErrorCode,
+ media_engine_SetSourceElements,
+ media_engine_SetSource,
+ media_engine_GetCurrentSource,
+ media_engine_GetNetworkState,
+ media_engine_GetPreload,
+ media_engine_SetPreload,
+ media_engine_GetBuffered,
+ media_engine_Load,
+ media_engine_CanPlayType,
+ media_engine_GetReadyState,
+ media_engine_IsSeeking,
+ media_engine_GetCurrentTime,
+ media_engine_SetCurrentTime,
+ media_engine_GetStartTime,
+ media_engine_GetDuration,
+ media_engine_IsPaused,
+ media_engine_GetDefaultPlaybackRate,
+ media_engine_SetDefaultPlaybackRate,
+ media_engine_GetPlaybackRate,
+ media_engine_SetPlaybackRate,
+ media_engine_GetPlayed,
+ media_engine_GetSeekable,
+ media_engine_IsEnded,
+ media_engine_GetAutoPlay,
+ media_engine_SetAutoPlay,
+ media_engine_GetLoop,
+ media_engine_SetLoop,
+ media_engine_Play,
+ media_engine_Pause,
+ media_engine_GetMuted,
+ media_engine_SetMuted,
+ media_engine_GetVolume,
+ media_engine_SetVolume,
+ media_engine_HasVideo,
+ media_engine_HasAudio,
+ media_engine_GetNativeVideoSize,
+ media_engine_GetVideoAspectRatio,
+ media_engine_Shutdown,
+ media_engine_TransferVideoFrame,
+ media_engine_OnVideoStreamTick,
+};
+
static HRESULT WINAPI media_engine_factory_QueryInterface(IMFMediaEngineClassFactory *iface, REFIID riid, void **obj)
{
if (IsEqualIID(riid, &IID_IMFMediaEngineClassFactory) ||
@@ -68,12 +497,61 @@ static ULONG WINAPI media_engine_factory_Release(IMFMediaEngineClassFactory *ifa
return 1;
}
+static void init_media_engine_attributes(IMFAttributes *attributes, struct media_engine_attributes *engine_attr)
+{
+ HRESULT hr;
+
+ memset(engine_attr, 0, sizeof(*engine_attr));
+ hr = IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, &IID_IMFMediaEngineNotify,
+ (void **)&engine_attr->callback);
+ if (FAILED(hr))
+ return;
+
+ IMFAttributes_GetUINT64(attributes, &MF_MEDIA_ENGINE_PLAYBACK_HWND, (UINT64 *)&engine_attr->playback_hwnd);
+ IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_DXGI_MANAGER, &IID_IMFDXGIDeviceManager,
+ (void **)&engine_attr->dxgi_manager);
+ hr = IMFAttributes_GetUINT32(attributes, &MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, &engine_attr->output_format);
+ if (engine_attr->playback_hwnd) /* FIXME: handle MF_MEDIA_ENGINE_PLAYBACK_VISUAL */
+ engine_attr->mode = MEDIA_ENGINE_RENDERING_MODE;
+ else
+ {
+ if (SUCCEEDED(hr))
+ engine_attr->mode = MEDIA_ENGINE_FRAME_SERVER_MODE;
+ else
+ engine_attr->mode = MEDIA_ENGINE_AUDIO_MODE;
+ }
+}
+
static HRESULT WINAPI media_engine_factory_CreateInstance(IMFMediaEngineClassFactory *iface, DWORD flags,
IMFAttributes *attributes, IMFMediaEngine **engine)
{
- FIXME("(%p, %#x, %p, %p): stub.\n", iface, flags, attributes, engine);
+ struct media_engine_attributes engine_attr;
+ struct media_engine *object;
- return E_NOTIMPL;
+ FIXME("(%p, %#x, %p, %p): semi-stub.\n", iface, flags, attributes, engine);
+
+ if (!attributes || !engine)
+ return E_POINTER;
+
+ init_media_engine_attributes(attributes, &engine_attr);
+ if (!engine_attr.mode)
+ return MF_E_ATTRIBUTENOTFOUND;
+
+ object = heap_alloc_zero(sizeof(*object));
+ if (!object)
+ {
+ free_media_engine_attributes(engine_attr);
+ return E_OUTOFMEMORY;
+ }
+
+ object->IMFMediaEngine_iface.lpVtbl = &media_engine_vtbl;
+ object->refcount = 1;
+ object->flags = flags;
+ object->attributes = engine_attr;
+
+ *engine = &object->IMFMediaEngine_iface;
+
+ return S_OK;
}
static HRESULT WINAPI media_engine_factory_CreateTimeRange(IMFMediaEngineClassFactory *iface,
diff --git a/dlls/mfmediaengine/tests/Makefile.in b/dlls/mfmediaengine/tests/Makefile.in
index 3f2bb5a094..d508db9f6f 100644
--- a/dlls/mfmediaengine/tests/Makefile.in
+++ b/dlls/mfmediaengine/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = mfmediaengine.dll
-IMPORTS = ole32 mfplat mfmediaengine mfuuid
+IMPORTS = ole32 mfplat mfmediaengine mfuuid uuid
C_SRCS = \
mfmediaengine.c
diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c
index c7fc89f2b1..a264d0d033 100644
--- a/dlls/mfmediaengine/tests/mfmediaengine.c
+++ b/dlls/mfmediaengine/tests/mfmediaengine.c
@@ -24,11 +24,85 @@
#include "winbase.h"
#include "mfapi.h"
+#include "mfidl.h"
#include "mfmediaengine.h"
+#include "mferror.h"
+#include "dxgi.h"
+#include "initguid.h"
#include "wine/heap.h"
#include "wine/test.h"
+static HRESULT (WINAPI *pMFCreateDXGIDeviceManager)(UINT *token, IMFDXGIDeviceManager **manager);
+
+#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
+static void _expect_ref(IUnknown *obj, ULONG ref, int line)
+{
+ ULONG rc;
+ IUnknown_AddRef(obj);
+ rc = IUnknown_Release(obj);
+ ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d.\n", rc, ref);
+}
+
+static void init_functions(void)
+{
+ HMODULE mod = GetModuleHandleA("mfplat.dll");
+
+#define X(f) p##f = (void*)GetProcAddress(mod, #f)
+ X(MFCreateDXGIDeviceManager);
+#undef X
+}
+
+struct media_engine_notify
+{
+ IMFMediaEngineNotify IMFMediaEngineNotify_iface;
+ LONG refcount;
+};
+
+static inline struct media_engine_notify *impl_from_IMFMediaEngineNotify(IMFMediaEngineNotify *iface)
+{
+ return CONTAINING_RECORD(iface, struct media_engine_notify, IMFMediaEngineNotify_iface);
+}
+
+static HRESULT WINAPI media_engine_notify_QueryInterface(IMFMediaEngineNotify *iface, REFIID riid, void **obj)
+{
+ if (IsEqualIID(riid, &IID_IMFMediaEngineNotify) ||
+ IsEqualIID(riid, &IID_IUnknown))
+ {
+ *obj = iface;
+ IMFMediaEngineNotify_AddRef(iface);
+ return S_OK;
+ }
+
+ *obj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI media_engine_notify_AddRef(IMFMediaEngineNotify *iface)
+{
+ struct media_engine_notify *notify = impl_from_IMFMediaEngineNotify(iface);
+ return InterlockedIncrement(¬ify->refcount);
+}
+
+static ULONG WINAPI media_engine_notify_Release(IMFMediaEngineNotify *iface)
+{
+ struct media_engine_notify *notify = impl_from_IMFMediaEngineNotify(iface);
+ return InterlockedDecrement(¬ify->refcount);
+}
+
+static HRESULT WINAPI media_engine_notify_EventNotify(IMFMediaEngineNotify *iface, DWORD event, DWORD_PTR param1, DWORD param2)
+{
+ return S_OK;
+}
+
+static IMFMediaEngineNotifyVtbl media_engine_notify_vtbl =
+{
+ media_engine_notify_QueryInterface,
+ media_engine_notify_AddRef,
+ media_engine_notify_Release,
+ media_engine_notify_EventNotify,
+};
+
static void test_factory(void)
{
IMFMediaEngineClassFactory *factory, *factory2;
@@ -47,7 +121,83 @@ static void test_factory(void)
"Unexpected hr %#x.\n", hr);
if (factory)
+ {
+ struct media_engine_notify notify_impl = {{&media_engine_notify_vtbl}, 1};
+ IMFMediaEngineNotify *notify = ¬ify_impl.IMFMediaEngineNotify_iface;
+ IMFMediaEngine *media_engine, *media_engine2;
+ IMFDXGIDeviceManager *manager;
+ IMFAttributes *attributes;
+ UINT token;
+
+ hr = pMFCreateDXGIDeviceManager(&token, &manager);
+ ok(hr == S_OK, "MFCreateDXGIDeviceManager failed: %#x.\n", hr);
+ hr = MFCreateAttributes(&attributes, 3);
+ ok(hr == S_OK, "MFCreateAttributes failed: %#x.\n", hr);
+
+ if (0)
+ {
+ /* Crashed on Windows 8 */
+ hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE,
+ NULL, &media_engine);
+ ok(hr == E_POINTER, "IMFMediaEngineClassFactory_CreateInstance got %#x.\n", hr);
+
+ hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE,
+ NULL, NULL);
+ ok(hr == E_POINTER, "IMFMediaEngineClassFactory_CreateInstance got %#x.\n", hr);
+ }
+
+ hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE,
+ attributes, &media_engine);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "IMFMediaEngineClassFactory_CreateInstance got %#x.\n", hr);
+
+ hr = IMFAttributes_SetUnknown(attributes, &MF_MEDIA_ENGINE_OPM_HWND, NULL);
+ ok(hr == S_OK, "IMFAttributes_SetUnknown failed: %#x.\n", hr);
+ hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE,
+ attributes, &media_engine);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "IMFMediaEngineClassFactory_CreateInstance got %#x.\n", hr);
+
+ hr = IMFAttributes_SetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, (IUnknown *)notify);
+ ok(hr == S_OK, "IMFAttributes_SetUnknown failed: %#x.\n", hr);
+ hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE,
+ attributes, &media_engine);
+ ok(hr == S_OK || broken(hr == MF_E_ATTRIBUTENOTFOUND) /* pre win10v1809 */,
+ "IMFMediaEngineClassFactory_CreateInstance got %#x.\n", hr);
+ if (SUCCEEDED(hr))
+ IMFMediaEngine_Release(media_engine);
+
+ EXPECT_REF(factory, 1);
+ hr = IMFAttributes_SetUINT32(attributes, &MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, DXGI_FORMAT_UNKNOWN);
+ ok(hr == S_OK, "IMFAttributes_SetUINT32 failed: %#x.\n", hr);
+ hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE,
+ attributes, &media_engine);
+ ok(hr == S_OK, "IMFMediaEngineClassFactory_CreateInstance failed: %#x.\n", hr);
+ if (0)
+ {
+ /* Different version of Windows has different reference count behaviour, and I didn't
+ see their logics. So skipping these tests on Windows. */
+ EXPECT_REF(media_engine, 1);
+ EXPECT_REF(factory, 1);
+ }
+
+ hr = IMFMediaEngineClassFactory_CreateInstance(factory, MF_MEDIA_ENGINE_WAITFORSTABLE_STATE,
+ attributes, &media_engine2);
+ ok(hr == S_OK, "IMFMediaEngineClassFactory_CreateInstance failed: %#x.\n", hr);
+ if (0)
+ {
+ EXPECT_REF(media_engine, 1);
+ EXPECT_REF(media_engine2, 1);
+ EXPECT_REF(factory, 1);
+ }
+
+ IMFMediaEngine_Release(media_engine);
+ IMFMediaEngine_Release(media_engine2);
+ IMFAttributes_DeleteAllItems(attributes);
+ IMFAttributes_Release(attributes);
+ IMFDXGIDeviceManager_Release(manager);
IMFMediaEngineClassFactory_Release(factory);
+ }
+ else
+ win_skip("Not IMFMediaEngineClassFactory support.\n");
CoUninitialize();
}
@@ -56,6 +206,8 @@ START_TEST(mfmediaengine)
{
HRESULT hr;
+ init_functions();
+
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "MFStartup failed: %#x.\n", hr);
diff --git a/include/mfmediaengine.idl b/include/mfmediaengine.idl
index 940cacc9c1..556d2fba2b 100644
--- a/include/mfmediaengine.idl
+++ b/include/mfmediaengine.idl
@@ -20,6 +20,36 @@ import "mfidl.idl";
cpp_quote("EXTERN_GUID(CLSID_MFMediaEngineClassFactory, 0xb44392da, 0x499b, 0x446b, 0xa4, 0xcb, 0x00, 0x5f, 0xea, 0xd0, 0xe6, 0xd5);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_AUDIO_CATEGORY, 0xc8d4c51d, 0x350e, 0x41f2, 0xba, 0x46, 0xfa, 0xeb, 0xbb, 0x08, 0x57, 0xf6);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_AUDIO_ENDPOINT_ROLE, 0xd2cb93d1, 0x116a, 0x44f2, 0x93, 0x85, 0xf7, 0xd0, 0xfd, 0xa2, 0xfb, 0x46);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_BROWSER_COMPATIBILITY_MODE, 0x4e0212e2, 0xe18f, 0x41e1, 0x95, 0xe5, 0xc0, 0xe7, 0xe9, 0x23, 0x5b, 0xc3);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_BROWSER_COMPATIBILITY_MODE_IE9, 0x052c2d39, 0x40c0, 0x4188, 0xab, 0x86, 0xf8, 0x28, 0x27, 0x3b, 0x75, 0x22);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_BROWSER_COMPATIBILITY_MODE_IE10, 0x11a47afd, 0x6589, 0x4124, 0xb3, 0x12, 0x61, 0x58, 0xec, 0x51, 0x7f, 0xc3);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_BROWSER_COMPATIBILITY_MODE_IE11, 0x1cf1315f, 0xce3f, 0x4035, 0x93, 0x91, 0x16, 0x14, 0x2f, 0x77, 0x51, 0x89);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_BROWSER_COMPATIBILITY_MODE_IE_EDGE, 0xa6f3e465, 0x3aca, 0x442c, 0xa3, 0xf0, 0xad, 0x6d, 0xda, 0xd8, 0x39, 0xae);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_CALLBACK, 0xc60381b8, 0x83a4, 0x41f8, 0xa3, 0xd0, 0xde, 0x05, 0x07, 0x68, 0x49, 0xa9);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_COMPATIBILITY_MODE, 0x3ef26ad4, 0xdc54, 0x45de, 0xb9, 0xaf, 0x76, 0xc8, 0xc6, 0x6b, 0xfa, 0x8e);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_COMPATIBILITY_MODE_WIN10, 0x5b25e089, 0x6ca7, 0x4139, 0xa2, 0xcb, 0xfc, 0xaa, 0xb3, 0x95, 0x52, 0xa3);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_COMPATIBILITY_MODE_WWA_EDGE, 0x15b29098, 0x9f01, 0x4e4d, 0xb6, 0x5a, 0xc0, 0x6c, 0x6c, 0x89, 0xda, 0x2a);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_CONTENT_PROTECTION_FLAGS, 0xe0350223, 0x5aaf, 0x4d76, 0xa7, 0xc3, 0x06, 0xde, 0x70, 0x89, 0x4d, 0xb4);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_CONTENT_PROTECTION_MANAGER, 0xfdd6dfaa, 0xbd85, 0x4af3, 0x9e, 0x0f, 0xa0, 0x1d, 0x53, 0x9d, 0x87, 0x6a);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_CONTINUE_ON_CODEC_ERROR, 0xdbcdb7f9, 0x48e4, 0x4295, 0xb7, 0x0d, 0xd5, 0x18, 0x23, 0x4e, 0xeb, 0x38);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_COREWINDOW, 0xfccae4dc, 0x0b7f, 0x41c2, 0x9f, 0x96, 0x46, 0x59, 0x94, 0x8a, 0xcd, 0xdc);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_DXGI_MANAGER, 0x065702da, 0x1094, 0x486d, 0x86, 0x17, 0xee, 0x7c, 0xc4, 0xee, 0x46, 0x48);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_EME_CALLBACK, 0x494553a7, 0xa481, 0x4cb7, 0xbe, 0xc5, 0x38, 0x09, 0x03, 0x51, 0x37, 0x31);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_EXTENSION, 0x3109fd46, 0x060d, 0x4b62, 0x8d, 0xcf, 0xfa, 0xff, 0x81, 0x13, 0x18, 0xd2);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_MEDIA_PLAYER_MODE, 0x3ddd8d45, 0x5aa1, 0x4112, 0x82, 0xe5, 0x36, 0xf6, 0xa2, 0x19, 0x7e, 0x6e);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_NEEDKEY_CALLBACK, 0x7ea80843, 0xb6e4, 0x432c, 0x8e, 0xa4, 0x78, 0x48, 0xff, 0xe4, 0x22, 0x0e);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_OPM_HWND, 0xa0be8ee7, 0x0572, 0x4f2c, 0xa8, 0x01, 0x2a, 0x15, 0x1b, 0xd3, 0xe7, 0x26);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_PLAYBACK_HWND, 0xd988879b, 0x67c9, 0x4d92, 0xba, 0xa7, 0x6e, 0xad, 0xd4, 0x46, 0x03, 0x9d);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_PLAYBACK_VISUAL, 0x6debd26f, 0x6ab9, 0x4d7e, 0xb0, 0xee, 0xc6, 0x1a, 0x73, 0xff, 0xad, 0x15);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_SOURCE_RESOLVER_CONFIG_STORE, 0x0ac0c497, 0xb3c4, 0x48c9, 0x9c, 0xde, 0xbb, 0x8c, 0xa2, 0x44, 0x2c, 0xa3);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_STREAM_CONTAINS_ALPHA_CHANNEL, 0x5cbfaf44, 0xd2b2, 0x4cfb, 0x80, 0xa7, 0xd4, 0x29, 0xc7, 0x4c, 0x78, 0x9d);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_SYNCHRONOUS_CLOSE, 0xc3c2e12f, 0x7e0e, 0x4e43, 0xb9, 0x1c, 0xdc, 0x99, 0x2c, 0xcd, 0xfa, 0x5e);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_TELEMETRY_APPLICATION_ID, 0x1e7b273b, 0xa7e4, 0x402a, 0x8f, 0x51, 0xc4, 0x8e, 0x88, 0xa2, 0xca, 0xbc);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_TRACK_ID, 0x65bea312, 0x4043, 0x4815, 0x8e, 0xab, 0x44, 0xdc, 0xe2, 0xef, 0x8f, 0x2a);")
+cpp_quote("EXTERN_GUID(MF_MEDIA_ENGINE_VIDEO_OUTPUT_FORMAT, 0x5066893c, 0x8cf9, 0x42bc, 0x8b, 0x8a, 0x47, 0x22, 0x12, 0xe5, 0x27, 0x26);")
+
typedef enum MF_MEDIA_ENGINE_ERR
{
MF_MEDIA_ENGINE_ERR_NOERROR,
@@ -54,6 +84,16 @@ typedef struct MFVideoNormalizedRect
float bottom;
} MFVideoNormalizedRect;
+typedef enum MF_MEDIA_ENGINE_CREATEFLAGS
+{
+ MF_MEDIA_ENGINE_AUDIOONLY = 0x1,
+ MF_MEDIA_ENGINE_WAITFORSTABLE_STATE = 0x2,
+ MF_MEDIA_ENGINE_FORCEMUTE = 0x4,
+ MF_MEDIA_ENGINE_REAL_TIME_MODE = 0x8,
+ MF_MEDIA_ENGINE_DISABLE_LOCAL_PLUGINS = 0x10,
+ MF_MEDIA_ENGINE_CREATEFLAGS_MASK = 0x1f
+} MF_MEDIA_ENGINE_CREATEFLAGS;
+
[
object,
uuid(fc0e10d2-ab2a-4501-a951-06bb1075184c),
@@ -166,3 +206,14 @@ interface IMFMediaEngineClassFactory : IUnknown
HRESULT CreateTimeRange([out] IMFMediaTimeRange **range);
HRESULT CreateError([out] IMFMediaError **error);
}
+
+[
+ object,
+ uuid(fee7c112-e776-42b5-9bbf-0048524e2bd5),
+ local,
+ pointer_default(unique)
+]
+interface IMFMediaEngineNotify : IUnknown
+{
+ HRESULT EventNotify([in] DWORD event, [in] DWORD_PTR param1, [in] DWORD param2);
+}
--
2.23.0.rc1
--