Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mfplat/tests/mfplat.c | 161 ++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 4 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index a2aa082fbbb..ffc939f54af 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -644,13 +644,14 @@ static void test_source_resolver(void) IMFGetService *get_service; IMFRateSupport *rate_support; WCHAR pathW[MAX_PATH]; - int i, sample_count; + int i, sample_count, pause_count, while_paused_count, restart_count, seek_count, last_seen; WCHAR *filename; PROPVARIANT var; HRESULT hr; GUID guid; float rate; UINT32 rotation; + BOOL ret, pause_seen;
if (!pMFCreateSourceResolver) { @@ -864,9 +865,19 @@ todo_wine expect_no_event((IMFMediaEventGenerator *)video_stream);
sample_count = 10; + pause_count = 2; + while_paused_count = 6; + restart_count = 7; + seek_count = 3;
- for (i = 0; i < sample_count; ++i) + for (i = 0; i < while_paused_count; ++i) { + if (i == pause_count) + { + hr = IMFMediaSource_Pause(mediasource); + ok(hr == S_OK, "Could not pause media source, hr %#x.\n", hr); + } + hr = IMFMediaStream_RequestSample(video_stream, NULL); if (i == sample_count) break; @@ -875,13 +886,84 @@ todo_wine break; }
- for (i = 0; i < sample_count; ++i) + pause_seen = FALSE; + + for (i = 0; ; ++i) + { + static const LONGLONG MILLI_TO_100_NANO = 10000; + LONGLONG duration, time; + DWORD buffer_count; + IMFSample *sample; + MediaEventType met; + + ret = get_event((IMFMediaEventGenerator *)video_stream, &met, &var); + if (!ret) + break; + + if (met == MEStreamPaused) + { + ok(!pause_seen, "Pause seen twice\n"); + pause_seen = TRUE; + i--; + continue; + } + + ok(i < while_paused_count, "Too many samples: %d\n", i); + ok(met == MEMediaSample, "wrong type %d\n", met); + + ok(var.vt == VT_UNKNOWN, "Unexpected value type %u from MEMediaSample event.\n", var.vt); + sample = (IMFSample *)var.punkVal; + + hr = IMFSample_GetBufferCount(sample, &buffer_count); + ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr); + ok(buffer_count == 1, "Unexpected buffer count %u.\n", buffer_count); + + hr = IMFSample_GetSampleDuration(sample, &duration); + ok(hr == S_OK, "Failed to get sample duration, hr %#x.\n", hr); + ok(duration == 40 * MILLI_TO_100_NANO, "Unexpected duration %s.\n", wine_dbgstr_longlong(duration)); + + hr = IMFSample_GetSampleTime(sample, &time); + ok(hr == S_OK, "Failed to get sample time, hr %#x.\n", hr); + ok(time == i * 40 * MILLI_TO_100_NANO, "Unexpected time %s.\n", wine_dbgstr_longlong(time)); + + IMFSample_Release(sample); + } + + last_seen = i; + + ok(pause_seen, "Pause not seen\n"); + + expect_event((IMFMediaEventGenerator *)mediasource, MESourcePaused, &var); + expect_no_event((IMFMediaEventGenerator *)mediasource); + expect_no_event((IMFMediaEventGenerator *)video_stream); + + for (i = while_paused_count; i < restart_count; ++i) + { + hr = IMFMediaStream_RequestSample(video_stream, NULL); + if (i == sample_count) + break; + ok(hr == S_OK, "Failed to request sample %u, hr %#x.\n", i + 1, hr); + if (hr != S_OK) + break; + } + + expect_no_event((IMFMediaEventGenerator *)mediasource); + expect_no_event((IMFMediaEventGenerator *)video_stream); + + var.vt = VT_EMPTY; + hr = IMFMediaSource_Start(mediasource, descriptor, &GUID_NULL, &var); + ok(hr == S_OK, "Failed to restart the media source, hr %#x.\n", hr); + + expect_event((IMFMediaEventGenerator *)mediasource, MEUpdatedStream, &var); + expect_event((IMFMediaEventGenerator *)mediasource, MESourceStarted, &var); + expect_event((IMFMediaEventGenerator *)video_stream, MEStreamStarted, &var); + + for (i = last_seen; i < restart_count; ++i) { static const LONGLONG MILLI_TO_100_NANO = 10000; LONGLONG duration, time; DWORD buffer_count; IMFSample *sample; - BOOL ret;
ret = expect_event((IMFMediaEventGenerator *)video_stream, MEMediaSample, &var); ok(ret, "Sample %u not received.\n", i + 1); @@ -906,6 +988,77 @@ todo_wine IMFSample_Release(sample); }
+ expect_no_event((IMFMediaEventGenerator *)mediasource); + expect_no_event((IMFMediaEventGenerator *)video_stream); + + hr = IMFMediaSource_Pause(mediasource); + ok(hr == S_OK, "cannot pause %#x\n", hr); + + expect_event((IMFMediaEventGenerator *)mediasource, MESourcePaused, &var); + expect_event((IMFMediaEventGenerator *)video_stream, MEStreamPaused, &var); + expect_no_event((IMFMediaEventGenerator *)mediasource); + expect_no_event((IMFMediaEventGenerator *)video_stream); + + for (i = 0; i < 200; i++) + { + hr = IMFMediaStream_RequestSample(video_stream, NULL); + ok(hr == S_OK, "Failed to request sample %u, hr %#x.\n", i + 1, hr); + } + + expect_no_event((IMFMediaEventGenerator *)mediasource); + expect_no_event((IMFMediaEventGenerator *)video_stream); + + var.vt = VT_I8; + var.hVal.QuadPart = seek_count * 40 * 10000; + hr = IMFMediaSource_Start(mediasource, descriptor, &GUID_NULL, &var); + ok(hr == S_OK, "Failed to restart the media source, hr %#x.\n", hr); + + expect_event((IMFMediaEventGenerator *)mediasource, MEUpdatedStream, &var); + expect_event((IMFMediaEventGenerator *)mediasource, MESourceSeeked, &var); + expect_event((IMFMediaEventGenerator *)video_stream, MEStreamSeeked, &var); + expect_no_event((IMFMediaEventGenerator *)mediasource); + expect_no_event((IMFMediaEventGenerator *)video_stream); + + for (i = seek_count; i < sample_count; ++i) + { + hr = IMFMediaStream_RequestSample(video_stream, NULL); + if (i == sample_count) + break; + ok(hr == S_OK, "Failed to request sample %u, hr %#x.\n", i + 1, hr); + if (hr != S_OK) + break; + } + + for (i = seek_count; i < sample_count; ++i) + { + static const LONGLONG MILLI_TO_100_NANO = 10000; + LONGLONG duration, time; + DWORD buffer_count; + IMFSample *sample; + + ret = expect_event((IMFMediaEventGenerator *)video_stream, MEMediaSample, &var); + ok(ret, "Sample %u not received.\n", i + 1); + if (!ret) + break; + + ok(var.vt == VT_UNKNOWN, "Unexpected value type %u from MEMediaSample event.\n", var.vt); + sample = (IMFSample *)var.punkVal; + + hr = IMFSample_GetBufferCount(sample, &buffer_count); + ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr); + ok(buffer_count == 1, "Unexpected buffer count %u.\n", buffer_count); + + hr = IMFSample_GetSampleDuration(sample, &duration); + ok(hr == S_OK, "Failed to get sample duration, hr %#x.\n", hr); + ok(duration == 40 * MILLI_TO_100_NANO, "Unexpected duration %s.\n", wine_dbgstr_longlong(duration)); + + hr = IMFSample_GetSampleTime(sample, &time); + ok(hr == S_OK, "Failed to get sample time, hr %#x.\n", hr); + ok(time == i * 40 * MILLI_TO_100_NANO, "Unexpected time %s %s %d %d.\n", wine_dbgstr_longlong(time), wine_dbgstr_longlong(i * 40 * MILLI_TO_100_NANO), i, (int)(time / (40 * MILLI_TO_100_NANO))); + + IMFSample_Release(sample); + } + if (i == sample_count) { /* MEEndOfStream isn't queued until after a one request beyond the last frame is submitted */