Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/avidec.c | 11 ++++++++--- dlls/quartz/tests/avidec.c | 18 +++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/dlls/quartz/avidec.c b/dlls/quartz/avidec.c index 72f69ef7c5a..4995276dbfc 100644 --- a/dlls/quartz/avidec.c +++ b/dlls/quartz/avidec.c @@ -565,6 +565,9 @@ static HRESULT avi_decompressor_init_stream(struct strmbase_filter *iface) LRESULT res; HRESULT hr;
+ if (!filter->source.pin.peer) + return S_OK; + filter->late = -1;
source_format = (VIDEOINFOHEADER *)filter->sink.pin.mt.pbFormat; @@ -574,7 +577,7 @@ static HRESULT avi_decompressor_init_stream(struct strmbase_filter *iface) return E_FAIL; }
- if (filter->source.pin.peer && FAILED(hr = IMemAllocator_Commit(filter->source.pAllocator))) + if (FAILED(hr = IMemAllocator_Commit(filter->source.pAllocator))) ERR("Failed to commit allocator, hr %#x.\n", hr);
return S_OK; @@ -585,14 +588,16 @@ static HRESULT avi_decompressor_cleanup_stream(struct strmbase_filter *iface) struct avi_decompressor *filter = impl_from_strmbase_filter(iface); LRESULT res;
+ if (!filter->source.pin.peer) + return S_OK; + if (filter->hvid && (res = ICDecompressEnd(filter->hvid))) { ERR("ICDecompressEnd() failed, error %ld.\n", res); return E_FAIL; }
- if (filter->source.pin.peer) - IMemAllocator_Decommit(filter->source.pAllocator); + IMemAllocator_Decommit(filter->source.pAllocator);
return S_OK; } diff --git a/dlls/quartz/tests/avidec.c b/dlls/quartz/tests/avidec.c index ddfe22ed797..8717e107106 100644 --- a/dlls/quartz/tests/avidec.c +++ b/dlls/quartz/tests/avidec.c @@ -692,25 +692,25 @@ static void test_unconnected_filter_state(void) ok(state == State_Stopped, "Got state %u.\n", state);
hr = IBaseFilter_Pause(filter); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IBaseFilter_GetState(filter, 0, &state); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(state == State_Paused, "Got state %u.\n", state); + ok(state == State_Paused, "Got state %u.\n", state);
hr = IBaseFilter_Run(filter, 0); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IBaseFilter_GetState(filter, 0, &state); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(state == State_Running, "Got state %u.\n", state); + ok(state == State_Running, "Got state %u.\n", state);
hr = IBaseFilter_Pause(filter); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IBaseFilter_GetState(filter, 0, &state); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(state == State_Paused, "Got state %u.\n", state); + ok(state == State_Paused, "Got state %u.\n", state);
hr = IBaseFilter_Stop(filter); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -720,11 +720,11 @@ static void test_unconnected_filter_state(void) ok(state == State_Stopped, "Got state %u.\n", state);
hr = IBaseFilter_Run(filter, 0); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IBaseFilter_GetState(filter, 0, &state); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(state == State_Running, "Got state %u.\n", state); + ok(state == State_Running, "Got state %u.\n", state);
hr = IBaseFilter_Stop(filter); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -956,7 +956,7 @@ static void test_connect_pin(void) ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
hr = IMediaControl_Pause(control); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); ok(hr == VFW_E_NOT_STOPPED, "Got hr %#x.\n", hr); hr = IMediaControl_Stop(control);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/avidec.c | 220 +++++++++++++++++++++++++++++++++++-- 1 file changed, 212 insertions(+), 8 deletions(-)
diff --git a/dlls/quartz/tests/avidec.c b/dlls/quartz/tests/avidec.c index 8717e107106..ac1e245c9e6 100644 --- a/dlls/quartz/tests/avidec.c +++ b/dlls/quartz/tests/avidec.c @@ -28,6 +28,8 @@ static const DWORD test_handler = mmioFOURCC('w','t','s','t'); static const GUID test_subtype = {mmioFOURCC('w','t','s','t'),0x0000,0x0010,{0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71}};
+static int testmode; + static IBaseFilter *create_avi_dec(void) { IBaseFilter *filter = NULL; @@ -50,11 +52,13 @@ static ULONG get_refcount(void *iface) return IUnknown_Release(unknown); }
-static BITMAPINFOHEADER sink_bih; +static BITMAPINFOHEADER sink_bitmap_info, source_bitmap_info;
static LRESULT CALLBACK vfw_driver_proc(DWORD_PTR id, HDRVR driver, UINT msg, LPARAM lparam1, LPARAM lparam2) { + static int in_begin; + if (winetest_debug > 1) trace("id %#lx, driver %p, msg %#x, lparam1 %#lx, lparam2 %#lx.\n", id, driver, msg, lparam1, lparam2); @@ -77,7 +81,7 @@ static LRESULT CALLBACK vfw_driver_proc(DWORD_PTR id, HDRVR driver, UINT msg, if (!out) return sizeof(BITMAPINFOHEADER);
- ok(!memcmp(in, &sink_bih, sizeof(BITMAPINFOHEADER)), "Input types didn't match.\n"); + ok(!memcmp(in, &sink_bitmap_info, sizeof(BITMAPINFOHEADER)), "Input types didn't match.\n");
out->biSize = sizeof(BITMAPINFOHEADER); out->biCompression = mmioFOURCC('I','4','2','0'); @@ -108,8 +112,57 @@ static LRESULT CALLBACK vfw_driver_proc(DWORD_PTR id, HDRVR driver, UINT msg, return ICERR_UNSUPPORTED;
case ICM_DECOMPRESS_BEGIN: + { + BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lparam2; + BITMAPINFOHEADER *in = (BITMAPINFOHEADER *)lparam1; + + ok(!memcmp(in, &sink_bitmap_info, sizeof(BITMAPINFOHEADER)), + "Input types didn't match.\n"); + todo_wine ok(!memcmp(out, &source_bitmap_info, sizeof(BITMAPINFOHEADER)), + "Output types didn't match.\n"); + ok(!in_begin, "Got multiple ICM_DECOMPRESS_BEGIN messages.\n"); + in_begin = 1; + return ICERR_OK; + } + case ICM_DECOMPRESS_END: + ok(in_begin, "Got unmatched ICM_DECOMPRESS_END message.\n"); + in_begin = 0; + return ICERR_OK; + + case ICM_DECOMPRESS: + { + BITMAPINFOHEADER expect_sink_format = sink_bitmap_info; + ICDECOMPRESS *params = (ICDECOMPRESS *)lparam1; + BYTE *output = params->lpOutput, expect[200]; + unsigned int i; + + ok(in_begin, "Got ICM_DECOMPRESS without ICM_DECOMPRESS_BEGIN.\n"); + + ok(lparam2 == sizeof(ICDECOMPRESS), "Got size %Iu.\n", lparam2); + + if (testmode == 5 || testmode == 6) + ok(params->dwFlags == ICDECOMPRESS_NOTKEYFRAME, "Got flags %#x.\n", params->dwFlags); + else if (testmode == 3) + ok(params->dwFlags == ICDECOMPRESS_PREROLL, "Got flags %#x.\n", params->dwFlags); + else + ok(params->dwFlags == 0, "Got flags %#x.\n", params->dwFlags); + + expect_sink_format.biSizeImage = 200; + ok(!memcmp(params->lpbiInput, &expect_sink_format, sizeof(BITMAPINFOHEADER)), + "Input types didn't match.\n"); + ok(!memcmp(params->lpbiOutput, &source_bitmap_info, sizeof(BITMAPINFOHEADER)), + "Output types didn't match.\n"); + ok(!params->ckid, "Got chunk id %#x.\n", params->ckid); + + for (i = 0; i < 200; ++i) + expect[i] = i; + ok(!memcmp(params->lpInput, expect, 200), "Data didn't match.\n"); + for (i = 0; i < 32 * 24 * 12 / 8; ++i) + output[i] = 111 - i; + return ICERR_OK; + }
case ICM_GETINFO: { @@ -743,6 +796,7 @@ struct testfilter struct strmbase_source source; struct strmbase_sink sink; const AM_MEDIA_TYPE *mt; + unsigned int got_sample; };
static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface) @@ -821,16 +875,49 @@ static HRESULT testsink_get_media_type(struct strmbase_pin *iface, unsigned int static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample *sample) { struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter); - Quality q = {Famine, 500, 100 * 10000, 240 * 10000}; - IQualityControl *qc; + BYTE *data, expect[32 * 24 * 12 / 8]; + REFERENCE_TIME start, stop; + LONG size, i; HRESULT hr;
- IPin_QueryInterface(filter->sink.pin.peer, &IID_IQualityControl, (void **)&qc); + ++filter->got_sample; + + size = IMediaSample_GetSize(sample); + ok(size == 32 * 24 * 12 / 8, "Got size %u.\n", size); + size = IMediaSample_GetActualDataLength(sample); + ok(size == 32 * 24 * 12 / 8, "Got valid size %u.\n", size);
- hr = IQualityControl_Notify(qc, &filter->filter.IBaseFilter_iface, q); + hr = IMediaSample_GetPointer(sample, &data); ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < size; ++i) + expect[i] = 111 - i; + ok(!memcmp(data, expect, size), "Data didn't match.\n"); + + hr = IMediaSample_GetTime(sample, &start, &stop); + if (testmode == 0) + { + ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#x.\n", hr); + } + else if (testmode == 1) + { + ok(hr == VFW_S_NO_STOP_TIME, "Got hr %#x.\n", hr); + ok(start == 20000, "Got start time %s.\n", wine_dbgstr_longlong(start)); + } + else + { + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(start == 20000, "Got start time %s.\n", wine_dbgstr_longlong(start)); + ok(stop == 30000, "Got stop time %s.\n", wine_dbgstr_longlong(stop)); + }
- IQualityControl_Release(qc); + hr = IMediaSample_GetMediaTime(sample, &start, &stop); + todo_wine ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#x.\n", hr); + hr = IMediaSample_IsDiscontinuity(sample); + todo_wine_if (testmode == 5) ok(hr == (testmode == 4) ? S_OK : S_FALSE, "Got hr %#x.\n", hr); + hr = IMediaSample_IsPreroll(sample); + todo_wine_if (testmode == 3) ok(hr == S_FALSE, "Got hr %#x.\n", hr); + hr = IMediaSample_IsSyncPoint(sample); + todo_wine_if (testmode == 5 || testmode == 6) ok(hr == S_OK, "Got hr %#x.\n", hr);
return S_OK; } @@ -902,6 +989,119 @@ static void test_sink_allocator(IMemInputPin *input) IMemAllocator_Release(ret_allocator); }
+static void test_sample_processing(IMediaControl *control, IMemInputPin *input, struct testfilter *sink) +{ + REFERENCE_TIME start, stop; + IMemAllocator *allocator; + IMediaSample *sample; + LONG size, i; + HRESULT hr; + BYTE *data; + + hr = IMemInputPin_ReceiveCanBlock(input); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemInputPin_GetAllocator(input, &allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_Pause(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr); + + hr = IMemAllocator_Commit(allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaSample_GetPointer(sample, &data); + ok(hr == S_OK, "Got hr %#x.\n", hr); + size = IMediaSample_GetSize(sample); + ok(size == 256, "Got size %d.\n", size); + for (i = 0; i < 200; ++i) + data[i] = i; + hr = IMediaSample_SetActualDataLength(sample, 200); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + start = 10000; + stop = 20000; + hr = IMediaSample_SetMediaTime(sample, &start, &stop); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaSample_SetSyncPoint(sample, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testmode = 0; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(sink->got_sample == 1, "Got %u calls to Receive().\n", sink->got_sample); + sink->got_sample = 0; + + start = 20000; + hr = IMediaSample_SetTime(sample, &start, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testmode = 1; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(sink->got_sample == 1, "Got %u calls to Receive().\n", sink->got_sample); + sink->got_sample = 0; + + stop = 30000; + hr = IMediaSample_SetTime(sample, &start, &stop); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testmode = 2; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(sink->got_sample == 1, "Got %u calls to Receive().\n", sink->got_sample); + sink->got_sample = 0; + + hr = IMediaSample_SetPreroll(sample, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testmode = 3; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(!sink->got_sample, "Got %u calls to Receive().\n", sink->got_sample); + + hr = IMediaSample_SetPreroll(sample, FALSE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaSample_SetDiscontinuity(sample, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testmode = 4; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(sink->got_sample == 1, "Got %u calls to Receive().\n", sink->got_sample); + sink->got_sample = 0; + + hr = IMediaSample_SetSyncPoint(sample, FALSE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testmode = 5; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(!sink->got_sample, "Got %u calls to Receive().\n", sink->got_sample); + + hr = IMediaSample_SetDiscontinuity(sample, FALSE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + testmode = 6; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(!sink->got_sample, "Got %u calls to Receive().\n", sink->got_sample); + + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemInputPin_Receive(input, sample); + ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr); + + IMediaSample_Release(sample); + IMemAllocator_Release(allocator); +} + static void test_connect_pin(void) { VIDEOINFOHEADER req_format = @@ -988,7 +1188,7 @@ static void test_connect_pin(void) hr = IMediaControl_Stop(control); ok(hr == S_OK, "Got hr %#x.\n", hr);
- sink_bih = req_format.bmiHeader; + sink_bitmap_info = req_format.bmiHeader;
hr = IPin_EnumMediaTypes(source, &enummt); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1102,6 +1302,8 @@ static void test_connect_pin(void) ok(compare_media_types(&testsink.sink.pin.mt, &req_mt), "Media types didn't match.\n"); FreeMediaType(&mt);
+ source_bitmap_info = ((VIDEOINFOHEADER *)req_mt.pbFormat)->bmiHeader; + hr = IMediaControl_Pause(control); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IFilterGraph2_Disconnect(graph, source); @@ -1109,6 +1311,8 @@ static void test_connect_pin(void) hr = IMediaControl_Stop(control); ok(hr == S_OK, "Got hr %#x.\n", hr);
+ test_sample_processing(control, meminput, &testsink); + hr = IFilterGraph2_Disconnect(graph, source); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IFilterGraph2_Disconnect(graph, source);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/avidec.c | 5 ----- dlls/quartz/tests/avidec.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/dlls/quartz/avidec.c b/dlls/quartz/avidec.c index 4995276dbfc..77d2b5e2aa5 100644 --- a/dlls/quartz/avidec.c +++ b/dlls/quartz/avidec.c @@ -204,11 +204,6 @@ static HRESULT WINAPI avi_decompressor_sink_Receive(struct strmbase_sink *iface, else IMediaSample_SetTime(pOutSample, NULL, NULL);
- if (IMediaSample_GetMediaTime(pSample, &tStart, &tStop) == S_OK) - IMediaSample_SetMediaTime(pOutSample, &tStart, &tStop); - else - IMediaSample_SetMediaTime(pOutSample, NULL, NULL); - hr = IMemInputPin_Receive(This->source.pMemInputPin, pOutSample); if (hr != S_OK && hr != VFW_E_NOT_CONNECTED) ERR("Error sending sample (%x)\n", hr); diff --git a/dlls/quartz/tests/avidec.c b/dlls/quartz/tests/avidec.c index ac1e245c9e6..b9bca9b02ef 100644 --- a/dlls/quartz/tests/avidec.c +++ b/dlls/quartz/tests/avidec.c @@ -911,7 +911,7 @@ static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample }
hr = IMediaSample_GetMediaTime(sample, &start, &stop); - todo_wine ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#x.\n", hr); + ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#x.\n", hr); hr = IMediaSample_IsDiscontinuity(sample); todo_wine_if (testmode == 5) ok(hr == (testmode == 4) ? S_OK : S_FALSE, "Got hr %#x.\n", hr); hr = IMediaSample_IsPreroll(sample);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/avidec.c | 120 ++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 3 deletions(-)
diff --git a/dlls/quartz/tests/avidec.c b/dlls/quartz/tests/avidec.c index b9bca9b02ef..71f974806ea 100644 --- a/dlls/quartz/tests/avidec.c +++ b/dlls/quartz/tests/avidec.c @@ -116,8 +116,9 @@ static LRESULT CALLBACK vfw_driver_proc(DWORD_PTR id, HDRVR driver, UINT msg, BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lparam2; BITMAPINFOHEADER *in = (BITMAPINFOHEADER *)lparam1;
- ok(!memcmp(in, &sink_bitmap_info, sizeof(BITMAPINFOHEADER)), - "Input types didn't match.\n"); + todo_wine_if (in->biSizeImage != sink_bitmap_info.biSizeImage) + ok(!memcmp(in, &sink_bitmap_info, sizeof(BITMAPINFOHEADER)), + "Input types didn't match.\n"); todo_wine ok(!memcmp(out, &source_bitmap_info, sizeof(BITMAPINFOHEADER)), "Output types didn't match.\n"); ok(!in_begin, "Got multiple ICM_DECOMPRESS_BEGIN messages.\n"); @@ -796,7 +797,7 @@ struct testfilter struct strmbase_source source; struct strmbase_sink sink; const AM_MEDIA_TYPE *mt; - unsigned int got_sample; + unsigned int got_sample, got_new_segment, got_eos, got_begin_flush, got_end_flush; };
static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface) @@ -922,12 +923,48 @@ static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample return S_OK; }
+static HRESULT testsink_new_segment(struct strmbase_sink *iface, + REFERENCE_TIME start, REFERENCE_TIME stop, double rate) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter); + ++filter->got_new_segment; + ok(start == 10000, "Got start %s.\n", wine_dbgstr_longlong(start)); + ok(stop == 20000, "Got stop %s.\n", wine_dbgstr_longlong(stop)); + ok(rate == 1.0, "Got rate %.16e.\n", rate); + return S_OK; +} + +static HRESULT testsink_eos(struct strmbase_sink *iface) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter); + ++filter->got_eos; + return S_OK; +} + +static HRESULT testsink_begin_flush(struct strmbase_sink *iface) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter); + ++filter->got_begin_flush; + return S_OK; +} + +static HRESULT testsink_end_flush(struct strmbase_sink *iface) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter); + ++filter->got_end_flush; + return S_OK; +} + static const struct strmbase_sink_ops testsink_ops = { .base.pin_query_interface = testsink_query_interface, .base.pin_query_accept = testsink_query_accept, .base.pin_get_media_type = testsink_get_media_type, .pfnReceive = testsink_Receive, + .sink_new_segment = testsink_new_segment, + .sink_eos = testsink_eos, + .sink_begin_flush = testsink_begin_flush, + .sink_end_flush = testsink_end_flush, };
static void testfilter_init(struct testfilter *filter) @@ -1102,6 +1139,82 @@ static void test_sample_processing(IMediaControl *control, IMemInputPin *input, IMemAllocator_Release(allocator); }
+static void test_streaming_events(IMediaControl *control, IPin *sink, + IMemInputPin *input, struct testfilter *testsink) +{ + IMemAllocator *allocator; + IMediaSample *sample; + HRESULT hr; + BYTE *data; + LONG i; + + hr = IMediaControl_Pause(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemInputPin_GetAllocator(input, &allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMemAllocator_Commit(allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaSample_GetPointer(sample, &data); + ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < 200; ++i) + data[i] = i; + hr = IMediaSample_SetActualDataLength(sample, 200); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaSample_SetSyncPoint(sample, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(!testsink->got_new_segment, "Got %u calls to IPin::NewSegment().\n", testsink->got_new_segment); + hr = IPin_NewSegment(sink, 10000, 20000, 1.0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(testsink->got_new_segment == 1, "Got %u calls to IPin::NewSegment().\n", testsink->got_new_segment); + + ok(!testsink->got_eos, "Got %u calls to IPin::EndOfStream().\n", testsink->got_eos); + hr = IPin_EndOfStream(sink); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(!testsink->got_sample, "Got %u calls to Receive().\n", testsink->got_sample); + ok(testsink->got_eos == 1, "Got %u calls to IPin::EndOfStream().\n", testsink->got_eos); + testsink->got_eos = 0; + + hr = IPin_EndOfStream(sink); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(testsink->got_eos == 1, "Got %u calls to IPin::EndOfStream().\n", testsink->got_eos); + + testmode = 0; + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(testsink->got_sample == 1, "Got %u calls to Receive().\n", testsink->got_sample); + testsink->got_sample = 0; + + ok(!testsink->got_begin_flush, "Got %u calls to IPin::BeginFlush().\n", testsink->got_begin_flush); + hr = IPin_BeginFlush(sink); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(testsink->got_begin_flush == 1, "Got %u calls to IPin::BeginFlush().\n", testsink->got_begin_flush); + + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(sink); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + ok(!testsink->got_end_flush, "Got %u calls to IPin::EndFlush().\n", testsink->got_end_flush); + hr = IPin_EndFlush(sink); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(testsink->got_end_flush == 1, "Got %u calls to IPin::EndFlush().\n", testsink->got_end_flush); + + hr = IMemInputPin_Receive(input, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(testsink->got_sample == 1, "Got %u calls to Receive().\n", testsink->got_sample); + testsink->got_sample = 0; + + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IMediaSample_Release(sample); + IMemAllocator_Release(allocator); +} + static void test_connect_pin(void) { VIDEOINFOHEADER req_format = @@ -1312,6 +1425,7 @@ static void test_connect_pin(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
test_sample_processing(control, meminput, &testsink); + test_streaming_events(control, sink, meminput, &testsink);
hr = IFilterGraph2_Disconnect(graph, source); ok(hr == S_OK, "Got hr %#x.\n", hr);