-- v2: mf/tests: Test sample processing for MPEG4 media sink. mf/tests: Use IMFMediaEventGenerator interface in event wait helper.
From: Ziqing Hui zhui@codeweavers.com
--- dlls/mf/tests/mf.c | 92 +++++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 29 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 743946f7fba..ac491314b92 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1971,8 +1971,8 @@ static IMFAsyncCallback *create_test_callback(BOOL check_media_event) }
#define wait_media_event(a, b, c, d, e) wait_media_event_(__LINE__, a, b, c, d, e) -static HRESULT wait_media_event_(int line, IMFMediaSession *session, IMFAsyncCallback *callback, - MediaEventType expect_type, DWORD timeout, PROPVARIANT *value) +static HRESULT wait_media_event_(int line, IMFMediaEventGenerator *event_generator, + IMFAsyncCallback *callback, MediaEventType expect_type, DWORD timeout, PROPVARIANT *value) { struct test_callback *impl = impl_from_IMFAsyncCallback(callback); MediaEventType type; @@ -1982,7 +1982,8 @@ static HRESULT wait_media_event_(int line, IMFMediaSession *session, IMFAsyncCal
do { - hr = IMFMediaSession_BeginGetEvent(session, &impl->IMFAsyncCallback_iface, (IUnknown *)session); + hr = IMFMediaEventGenerator_BeginGetEvent(event_generator, + &impl->IMFAsyncCallback_iface, (IUnknown *)event_generator); ok_(__FILE__, line)(hr == S_OK, "Unexpected hr %#lx.\n", hr); ret = WaitForSingleObject(impl->event, timeout); ok_(__FILE__, line)(ret == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", ret); @@ -2006,8 +2007,8 @@ static HRESULT wait_media_event_(int line, IMFMediaSession *session, IMFAsyncCal }
#define wait_media_event_until_blocking(a, b, c, d, e) wait_media_event_until_blocking_(__LINE__, a, b, c, d, e) -static HRESULT wait_media_event_until_blocking_(int line, IMFMediaSession *session, IMFAsyncCallback *callback, - MediaEventType expect_type, DWORD timeout, PROPVARIANT *value) +static HRESULT wait_media_event_until_blocking_(int line, IMFMediaEventGenerator *event_generator, + IMFAsyncCallback *callback, MediaEventType expect_type, DWORD timeout, PROPVARIANT *value) { struct test_callback *impl = impl_from_IMFAsyncCallback(callback); MediaEventType type; @@ -2017,7 +2018,8 @@ static HRESULT wait_media_event_until_blocking_(int line, IMFMediaSession *sessi
do { - hr = IMFMediaSession_BeginGetEvent(session, &impl->IMFAsyncCallback_iface, (IUnknown *)session); + hr = IMFMediaEventGenerator_BeginGetEvent(event_generator, + &impl->IMFAsyncCallback_iface, (IUnknown *)event_generator); ok_(__FILE__, line)(hr == S_OK, "Unexpected hr %#lx.\n", hr); ret = WaitForSingleObject(impl->event, timeout); if (ret == WAIT_TIMEOUT) return WAIT_TIMEOUT; @@ -2112,6 +2114,7 @@ static void test_media_session_events(void) struct test_media_sink media_sink = test_media_sink; struct test_handler handler = test_handler; struct test_source *source_impl; + IMFMediaEventGenerator *event_generator; IMFAsyncCallback *callback, *callback2; IMFMediaType *input_type, *output_type; IMFTopologyNode *src_node, *sink_node; @@ -2192,49 +2195,51 @@ static void test_media_session_events(void)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
propvar.vt = VT_EMPTY; hr = IMFMediaSession_Start(session, &GUID_NULL, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionStarted, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionStarted, 1000, &propvar); ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
hr = IMFMediaSession_Stop(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionStopped, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionStopped, 1000, &propvar); todo_wine ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
hr = IMFMediaSession_Pause(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionPaused, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionPaused, 1000, &propvar); todo_wine ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
hr = IMFMediaSession_Close(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionClosed, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionClosed, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -2242,11 +2247,14 @@ static void test_media_session_events(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = MFCreateMediaType(&input_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -2287,7 +2295,7 @@ static void test_media_session_events(void)
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -2297,6 +2305,7 @@ static void test_media_session_events(void) media_sink.shutdown = FALSE;
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
if (handler.current_type) @@ -2308,12 +2317,14 @@ static void test_media_session_events(void)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IMFPresentationDescriptor_SelectStream(pd, 0);
hr = IMFMediaSession_SetTopology(session, MFSESSION_SETTOPOLOGY_NORESOLUTION, topology); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologySet, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_UNKNOWN, "got vt %u\n", propvar.vt); ok(propvar.punkVal == (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2325,7 +2336,7 @@ static void test_media_session_events(void)
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -2335,6 +2346,7 @@ static void test_media_session_events(void) media_sink.shutdown = FALSE;
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
if (handler.current_type) @@ -2346,10 +2358,12 @@ static void test_media_session_events(void)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSession_SetTopology(session, 0, topology); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologySet, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_UNKNOWN, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2362,7 +2376,7 @@ static void test_media_session_events(void)
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -2372,6 +2386,7 @@ static void test_media_session_events(void) media_sink.shutdown = FALSE;
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
if (handler.current_type) @@ -2385,10 +2400,12 @@ static void test_media_session_events(void)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSession_SetTopology(session, 0, topology); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologySet, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_UNKNOWN, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2400,7 +2417,7 @@ static void test_media_session_events(void)
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -2410,6 +2427,7 @@ static void test_media_session_events(void) media_sink.shutdown = FALSE;
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
if (handler.current_type) @@ -2424,10 +2442,12 @@ static void test_media_session_events(void)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSession_SetTopology(session, 0, topology); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologySet, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_UNKNOWN, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2439,7 +2459,7 @@ static void test_media_session_events(void)
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -2449,6 +2469,7 @@ static void test_media_session_events(void) media_sink.shutdown = FALSE;
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
if (handler.current_type) @@ -2463,10 +2484,12 @@ static void test_media_session_events(void)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSession_SetTopology(session, 0, topology); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologySet, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_UNKNOWN, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2478,7 +2501,7 @@ static void test_media_session_events(void)
hr = IMFMediaSession_ClearTopologies(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologiesCleared, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologiesCleared, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -2488,6 +2511,7 @@ static void test_media_session_events(void) media_sink.shutdown = FALSE;
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
@@ -2496,10 +2520,12 @@ static void test_media_session_events(void)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSession_SetTopology(session, 0, topology); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologySet, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_UNKNOWN, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2514,7 +2540,7 @@ static void test_media_session_events(void) propvar.vt = VT_EMPTY; hr = IMFMediaSession_Start(session, &GUID_NULL, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event_until_blocking(session, callback, MESessionStarted, 1000, &propvar); + hr = wait_media_event_until_blocking(event_generator, callback, MESessionStarted, 1000, &propvar); ok(hr == 0x80001234, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2538,16 +2564,19 @@ static void test_media_session_events(void) CLEAR_CALLED(test_source_Start);
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
/* test IMFMediaSession_Start when test source BeginGetEvent returns S_OK */ hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSession_SetTopology(session, 0, topology); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionTopologySet, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_UNKNOWN, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2563,7 +2592,7 @@ static void test_media_session_events(void) propvar.vt = VT_EMPTY; hr = IMFMediaSession_Start(session, &GUID_NULL, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event_until_blocking(session, callback, MESessionStarted, 1000, &propvar); + hr = wait_media_event_until_blocking(event_generator, callback, MESessionStarted, 1000, &propvar); ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt); ok(propvar.punkVal != (IUnknown *)topology, "got punkVal %p\n", propvar.punkVal); @@ -2587,6 +2616,7 @@ static void test_media_session_events(void) CLEAR_CALLED(test_source_Start);
/* sometimes briefly leaking */ + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session);
IMFAsyncCallback_Release(callback); @@ -4931,6 +4961,7 @@ static void test_sample_grabber_orientation(GUID subtype) };
struct test_grabber_callback *grabber_callback; + IMFMediaEventGenerator *event_generator; IMFTopologyNode *src_node, *sink_node; IMFPresentationDescriptor *pd; IMFAsyncCallback *callback; @@ -4964,6 +4995,8 @@ static void test_sample_grabber_orientation(GUID subtype)
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_QueryInterface(session, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &sink_node); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -5049,7 +5082,7 @@ static void test_sample_grabber_orientation(GUID subtype) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaSession_Close(session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = wait_media_event(session, callback, MESessionClosed, 1000, &propvar); + hr = wait_media_event(event_generator, callback, MESessionClosed, 1000, &propvar); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt);
@@ -5061,6 +5094,7 @@ static void test_sample_grabber_orientation(GUID subtype) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IMFActivate_Release(sink_activate); + IMFMediaEventGenerator_Release(event_generator); IMFMediaSession_Release(session); IMFMediaSource_Release(source);
From: Ziqing Hui zhui@codeweavers.com
--- dlls/mf/tests/Makefile.in | 2 +- dlls/mf/tests/mf.c | 214 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 208 insertions(+), 8 deletions(-)
diff --git a/dlls/mf/tests/Makefile.in b/dlls/mf/tests/Makefile.in index d6219219f67..6901b5a79a7 100644 --- a/dlls/mf/tests/Makefile.in +++ b/dlls/mf/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = mf.dll -IMPORTS = mf mfplat dmoguids mfuuid strmiids uuid wmcodecdspuuid ole32 user32 propsys msdmo d3d11 msvfw32 +IMPORTS = mf mfplat dmoguids mfuuid strmiids uuid wmcodecdspuuid ole32 user32 propsys msdmo d3d11 msvfw32 mfreadwrite
C_SRCS = \ mf.c \ diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index ac491314b92..30d73f7907e 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -33,6 +33,7 @@ #include "mmdeviceapi.h" #include "uuids.h" #include "wmcodecdsp.h" +#include "mfreadwrite.h"
#include "mf_test.h"
@@ -81,6 +82,44 @@ HRESULT (WINAPI *pMFGetTopoNodeCurrentType)(IMFTopologyNode *node, DWORD stream, HRESULT (WINAPI *pMFCreateDXGIDeviceManager)(UINT *token, IMFDXGIDeviceManager **manager); BOOL has_video_processor;
+const static BYTE test_h264_header[] = +{ + 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x14, 0xac, 0xd9, 0x46, 0x36, 0xc0, + 0x5a, 0x83, 0x03, 0x03, 0x52, 0x80, 0x00, 0x00, 0x03, 0x00, 0x80, 0x00, + 0x00, 0x03, 0x01, 0x47, 0x8a, 0x14, 0xcb, 0x00, 0x00, 0x01, 0x68, 0xeb, + 0xec, 0xb2, 0x2c, +}; + +const static BYTE test_h264_frame[] = +{ + 0x00, 0x00, 0x01, 0x65, 0x88, 0x84, 0x00, 0x17, 0xff, 0xe8, 0xff, 0xf2, + 0x3f, 0x9b, 0x0f, 0x5c, 0xdd, 0x08, 0x3f, 0xf5, 0xe8, 0xfc, 0xbb, 0xed, + 0x67, 0xbd, 0x22, 0xa1, 0xd7, 0xba, 0x21, 0xe6, 0x75, 0x8d, 0x3c, 0x11, + 0x12, 0x18, 0xd9, 0x81, 0x11, 0x75, 0x6a, 0x9b, 0x14, 0xcc, 0x50, 0x96, + 0x3f, 0x70, 0xd4, 0xf8, 0x3d, 0x17, 0xc9, 0x4e, 0x23, 0x96, 0x4e, 0x37, + 0xb9, 0xbe, 0x74, 0xf1, 0x53, 0x9f, 0xb4, 0x59, 0x57, 0x32, 0xee, 0x7f, + 0xfd, 0xea, 0x48, 0x2d, 0x80, 0x9e, 0x19, 0x61, 0x59, 0xcb, 0x14, 0xbd, + 0xcd, 0xb3, 0x3e, 0x81, 0x05, 0x56, 0x8e, 0x9c, 0xd9, 0x3f, 0x01, 0x6b, + 0x3e, 0x3c, 0x95, 0xcb, 0xc4, 0x1c, 0xfd, 0xb1, 0x72, 0x23, 0xbb, 0x7b, + 0xf8, 0xb8, 0x50, 0xda, 0x3c, 0x70, 0xc5, 0x7a, 0xc1, 0xe3, 0x13, 0x29, + 0x79, 0x7a, 0xbe, 0xff, 0x5a, 0x26, 0xc3, 0xb6, 0x56, 0xbb, 0x6a, 0x97, + 0x4d, 0xdc, 0x1e, 0x07, 0x4a, 0xaf, 0xff, 0x9e, 0x60, 0x20, 0x69, 0xf9, + 0xfc, 0xe8, 0xe0, 0xa6, 0x10, 0xa3, 0xab, 0x0f, 0xbe, 0x9c, 0x59, 0xa6, + 0xb4, 0x69, 0x4d, 0xc6, 0x09, 0xaa, 0xa8, 0xab, 0xbc, 0x64, 0xfd, 0x7e, + 0xde, 0x5f, 0x55, 0x06, 0xb9, 0xae, 0xce, 0x76, 0x5f, 0x63, 0x3a, 0x12, + 0x2e, 0x9e, 0xbd, 0x28, 0x71, 0x69, 0x34, 0xc9, 0xab, 0x20, 0x28, 0xb8, + 0x4b, 0x20, 0x1c, 0xe1, 0xc8, 0xc4, 0xa6, 0x7d, 0x73, 0x53, 0x73, 0xbf, + 0x21, 0x19, 0x9a, 0xd5, 0xa7, 0xcf, 0x47, 0x5a, 0xda, 0x34, 0x50, 0x7b, + 0x69, 0x8e, 0x52, 0xb2, 0x61, 0xda, 0x8e, 0x20, 0x95, 0x73, 0xc5, 0xb9, + 0x2b, 0x14, 0x48, 0xc1, 0x68, 0x3a, 0x7c, 0x78, 0x14, 0xe9, 0x92, 0xc7, + 0x89, 0xfc, 0x4f, 0x90, 0xaf, 0x54, 0x1e, 0xd0, 0xf0, 0x00, 0x25, 0x3e, + 0xcf, 0xbc, 0x18, 0xad, 0xc9, 0x6b, 0x9d, 0x77, 0x21, 0x6d, 0x5d, 0x2e, + 0xce, 0x09, 0xd9, 0xee, 0x79, 0xb6, 0xe7, 0xe4, 0xf4, 0x7f, 0x6e, 0x11, + 0x7b, 0x32, 0xfb, 0xf6, 0x8c, 0xbf, 0x05, 0xe1, 0x9a, 0x9c, 0x6c, 0x48, + 0x79, 0xac, 0x8f, 0x16, 0xb6, 0xf6, 0x3e, 0x76, 0xab, 0x40, 0x28, 0x61, + +}; + static BOOL is_vista(void) { return !pMFGetTopoNodeCurrentType; @@ -1866,7 +1905,7 @@ struct test_callback
HANDLE event; IMFMediaEvent *media_event; - BOOL check_media_event; + BOOL check_media_event, finalize_media_sink; };
static struct test_callback *impl_from_IMFAsyncCallback(IMFAsyncCallback *iface) @@ -1940,6 +1979,18 @@ static HRESULT WINAPI testcallback_Invoke(IMFAsyncCallback *iface, IMFAsyncResul IUnknown_Release(object); }
+ if (callback->finalize_media_sink) + { + hr = IMFAsyncResult_GetObject(result, &object); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + hr = IMFAsyncResult_GetState(result, &object); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFFinalizableMediaSink_EndFinalize((IMFFinalizableMediaSink *)object, result); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IUnknown_Release(object); + } + SetEvent(callback->event);
return S_OK; @@ -1954,7 +2005,7 @@ static const IMFAsyncCallbackVtbl testcallbackvtbl = testcallback_Invoke, };
-static IMFAsyncCallback *create_test_callback(BOOL check_media_event) +static IMFAsyncCallback *create_test_callback(BOOL check_media_event, BOOL finalize_media_sink) { struct test_callback *callback;
@@ -1963,6 +2014,7 @@ static IMFAsyncCallback *create_test_callback(BOOL check_media_event)
callback->refcount = 1; callback->check_media_event = check_media_event; + callback->finalize_media_sink = finalize_media_sink; callback->IMFAsyncCallback_iface.lpVtbl = &testcallbackvtbl; callback->event = CreateEventW(NULL, FALSE, FALSE, NULL); ok(!!callback->event, "CreateEventW failed, error %lu\n", GetLastError()); @@ -1970,6 +2022,26 @@ static IMFAsyncCallback *create_test_callback(BOOL check_media_event) return &callback->IMFAsyncCallback_iface; }
+static void test_callback_set(IMFAsyncCallback *iface, BOOL check_media_event, BOOL finalize_media_sink) +{ + struct test_callback *callback = CONTAINING_RECORD(iface, struct test_callback, IMFAsyncCallback_iface); + + callback->check_media_event = check_media_event; + callback->finalize_media_sink = finalize_media_sink; + + if (!callback->check_media_event && callback->media_event) + { + IMFMediaEvent_Release(callback->media_event); + callback->media_event = NULL; + } +} + +static DWORD test_callback_wait_event(IMFAsyncCallback *iface, DWORD time) +{ + struct test_callback *callback = CONTAINING_RECORD(iface, struct test_callback, IMFAsyncCallback_iface); + return WaitForSingleObject(callback->event, time); +} + #define wait_media_event(a, b, c, d, e) wait_media_event_(__LINE__, a, b, c, d, e) static HRESULT wait_media_event_(int line, IMFMediaEventGenerator *event_generator, IMFAsyncCallback *callback, MediaEventType expect_type, DWORD timeout, PROPVARIANT *value) @@ -2135,8 +2207,8 @@ static void test_media_session_events(void) hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr);
- callback = create_test_callback(TRUE); - callback2 = create_test_callback(TRUE); + callback = create_test_callback(TRUE, FALSE); + callback2 = create_test_callback(TRUE, FALSE);
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Failed to create media session, hr %#lx.\n", hr); @@ -2191,7 +2263,7 @@ static void test_media_session_events(void) IMFAsyncCallback_Release(callback2);
- callback = create_test_callback(TRUE); + callback = create_test_callback(TRUE, FALSE);
hr = MFCreateMediaSession(NULL, &session); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -4318,7 +4390,7 @@ static void test_presentation_clock(void) hr = IMFPresentationClock_GetCorrelatedTime(clock, 0, &time, &systime); ok(hr == S_OK, "got hr %#lx.\n", hr);
- callback = create_test_callback(FALSE); + callback = create_test_callback(FALSE, FALSE); timer_callback = impl_from_IMFAsyncCallback(callback); hr = IMFTimer_SetTimer(timer, 0, 100000, callback, NULL, &timer_cancel_key); ok(hr == S_OK, "got hr %#lx.\n", hr); @@ -4985,7 +5057,7 @@ static void test_sample_grabber_orientation(GUID subtype) goto done; }
- callback = create_test_callback(TRUE); + callback = create_test_callback(TRUE, FALSE); grabber_callback = impl_from_IMFSampleGrabberSinkCallback(create_test_grabber_callback());
grabber_callback->ready_event = CreateEventW(NULL, FALSE, FALSE, NULL); @@ -7085,6 +7157,133 @@ static void test_mpeg4_media_sink(void) IMFMediaType_Release(audio_type); }
+static void test_mpeg4_media_sink_process(void) +{ + DWORD width = 96, height = 96, fps = 1, ret; + IMFMediaEventGenerator *event_generator; + IMFMediaType *input_type, *output_type; + IMFClockStateSink *clock_sink; + IMFAsyncCallback *callback; + IMFStreamSink *stream_sink; + IMFByteStream *bytestream; + IMFMediaSink *media_sink; + WCHAR tmp_file[MAX_PATH]; + IMFSourceReader *reader; + IMFSample *input_sample; + PROPVARIANT variant; + BYTE buffer[1024]; + UINT64 value; + UINT32 size; + HRESULT hr; + GUID guid; + + hr = MFCreateMediaType(&input_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(input_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(input_type, &MF_MT_SUBTYPE, &MFVideoFormat_H264); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(input_type, &MF_MT_FRAME_SIZE, ((UINT64)width << 32) | height); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(input_type, &MF_MT_FRAME_RATE, ((UINT64)fps << 32) | 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetBlob(input_type, &MF_MT_MPEG_SEQUENCE_HEADER, test_h264_header, sizeof(test_h264_header)); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + GetTempPathW(ARRAY_SIZE(tmp_file), tmp_file); + wcscat(tmp_file, L"tmp.mp4"); + hr = MFCreateFile(MF_ACCESSMODE_READWRITE, MF_OPENMODE_DELETE_IF_EXIST, MF_FILEFLAGS_NONE, tmp_file, &bytestream); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = MFCreateMPEG4MediaSink(bytestream, input_type, NULL, &media_sink); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFMediaType_Release(input_type); + if (hr != S_OK) + { + IMFByteStream_Release(bytestream); + return; + } + hr = IMFMediaSink_QueryInterface(media_sink, &IID_IMFClockStateSink, (void **)&clock_sink); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + /* Start streaming. */ + callback = create_test_callback(TRUE, FALSE); + hr = IMFMediaSink_GetStreamSinkById(media_sink, 1, &stream_sink); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFStreamSink_QueryInterface(stream_sink, &IID_IMFMediaEventGenerator, (void **)&event_generator); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFClockStateSink_OnClockStart(clock_sink, MFGetSystemTime(), 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + wait_media_event(event_generator, callback, MEStreamSinkStarted, 3000, &variant); + + /* Process sample. */ + input_sample = create_sample(test_h264_frame, sizeof(test_h264_frame)); + hr = IMFSample_SetSampleTime(input_sample, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFSample_SetSampleDuration(input_sample, 10000000); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFStreamSink_ProcessSample(stream_sink, input_sample); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + /* Wait for stop event to make sure samples have been processed. */ + hr = IMFClockStateSink_OnClockStop(clock_sink, MFGetSystemTime()); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + wait_media_event(event_generator, callback, MEStreamSinkStopped, 3000, &variant); + + /* Finalize. */ + test_callback_set(callback, FALSE, TRUE); + hr = IMFFinalizableMediaSink_BeginFinalize((IMFFinalizableMediaSink *)media_sink, callback, (IUnknown *)media_sink); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ret = test_callback_wait_event(callback, 3000); + ok(ret == WAIT_OBJECT_0, "Unexpected ret %#lx\n", ret); + hr = IMFMediaSink_Shutdown(media_sink); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + IMFClockStateSink_Release(clock_sink); + ret = IMFMediaSink_Release(media_sink); + ok(ret == 0, "Release returned %lu.\n", ret); + + IMFAsyncCallback_Release(callback); + IMFMediaEventGenerator_Release(event_generator); + IMFStreamSink_Release(stream_sink); + IMFByteStream_Release(bytestream); + + /* Check reader output type. */ + hr = MFCreateSourceReaderFromURL(tmp_file, NULL, &reader); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFSourceReader_GetNativeMediaType(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, &output_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaType_GetGUID(output_type, &MF_MT_MAJOR_TYPE, &guid); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected major type %s.\n", debugstr_guid(&guid)); + + hr = IMFMediaType_GetGUID(output_type, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&guid, &MFVideoFormat_H264), "Unexpected sub type %s.\n", debugstr_guid(&guid)); + + hr = IMFMediaType_GetUINT64(output_type, &MF_MT_FRAME_SIZE, &value); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value == (((UINT64)width << 32) | height), "Unexpected frame size %I64x.\n", value); + + hr = IMFMediaType_GetUINT64(output_type, &MF_MT_FRAME_RATE, &value); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value == (((UINT64)fps << 32) | 1), "Unexpected frame rate %I64x.\n", value); + + hr = IMFMediaType_GetBlob(output_type, &MF_MT_MPEG_SEQUENCE_HEADER, buffer, sizeof(buffer), &size); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(size == sizeof(test_h264_header), "Unexpected sequence header size %u.\n", size); + ok(!memcmp(buffer, test_h264_header, size), "Unexpected sequence header.\n"); + + IMFSample_Release(input_sample); + IMFSourceReader_Release(reader); + IMFMediaType_Release(output_type); + DeleteFileW(tmp_file); +} + START_TEST(mf) { init_functions(); @@ -7119,4 +7318,5 @@ START_TEST(mf) test_MFGetTopoNodeCurrentType(); test_MFRequireProtectedEnvironment(); test_mpeg4_media_sink(); + test_mpeg4_media_sink_process(); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=135191
Your paranoid android.
=== w7u_adm (32 bit report) ===
mf: mf: Timeout
=== w1064_tsign (64 bit report) ===
mf: mf.c:1990: Test failed: Unexpected hr 0xc00d4a44. mf.c:7255: Test failed: Unexpected hr 0xc00d36c4.
Nikolay Sivov (@nsivov) commented about dlls/mf/tests/mf.c:
}
#define wait_media_event(a, b, c, d, e) wait_media_event_(__LINE__, a, b, c, d, e) -static HRESULT wait_media_event_(int line, IMFMediaSession *session, IMFAsyncCallback *callback,
MediaEventType expect_type, DWORD timeout, PROPVARIANT *value)
+static HRESULT wait_media_event_(int line, IMFMediaEventGenerator *event_generator,
IMFAsyncCallback *callback, MediaEventType expect_type, DWORD timeout, PROPVARIANT *value)
To get this diff down you could use "void *" for event_generator here, and query for it inside this helper. Note that it's not really necessary for session objects, because those are already event generators.
Nikolay Sivov (@nsivov) commented about dlls/mf/tests/Makefile.in:
TESTDLL = mf.dll -IMPORTS = mf mfplat dmoguids mfuuid strmiids uuid wmcodecdspuuid ole32 user32 propsys msdmo d3d11 msvfw32 +IMPORTS = mf mfplat dmoguids mfuuid strmiids uuid wmcodecdspuuid ole32 user32 propsys msdmo d3d11 msvfw32 mfreadwrite
I don't follow. Why do you need to use mfreadwrite from mf.dll tests?
On Wed Jul 26 15:25:18 2023 +0000, Nikolay Sivov wrote:
I don't follow. Why do you need to use mfreadwrite from mf.dll tests?
Becuase I'm using MFSourceReader in the tests to decode and test the file generated by media sink. Would it be better to avoid using source reader here?
On Wed Jul 26 15:25:18 2023 +0000, Nikolay Sivov wrote:
To get this diff down you could use "void *" for event_generator here, and query for it inside this helper. Note that it's not really necessary for session objects, because those are already event generators.
OK, I've changed this in next version.