Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/tests/amstream.c | 249 ++++++++++++++++++++++++++++++--- 1 file changed, 228 insertions(+), 21 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index a6ec84fbdea..eaa1073532d 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1231,8 +1231,8 @@ static HRESULT WINAPI testsource_seeking_GetStopPosition(IMediaSeeking *iface, L
static HRESULT WINAPI testsource_seeking_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *current) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + *current = 0; + return S_OK; }
static HRESULT WINAPI testsource_seeking_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *target, @@ -4071,30 +4071,47 @@ static void test_audiostream_initialize(void) static void test_audiostream_begin_flush_end_flush(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); + static const MSPID mspid = {0x88888888, 1}; IAudioStreamSample *stream_sample; IAudioMediaStream *audio_stream; + IMediaStreamFilter *filter; IMediaSample *media_sample; + struct testfilter source2; struct testfilter source; + IAMMediaStream *stream2; IAudioData *audio_data; - IGraphBuilder *graph; IMediaStream *stream; + struct graph graph; HRESULT hr; + IPin *pin2; ULONG ref; IPin *pin;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + graph_init(&graph); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, (IGraphBuilder *)&graph.IFilterGraph2_iface); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream2, NULL, 0, &mspid, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream2, &mspid, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + hr = IAMMediaStream_QueryInterface(stream2, &IID_IPin, (void **)&pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(graph != NULL, "Expected non-NULL graph.\n"); testfilter_init(&source); - hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + testfilter_init(&source2); + source.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source2.filter.IBaseFilter_iface, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, &IID_IAudioData, (void **)&audio_data); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -4103,7 +4120,12 @@ static void test_audiostream_begin_flush_end_flush(void) hr = IAudioMediaStream_CreateSample(audio_stream, audio_data, 0, &stream_sample); ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &audio_mt); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface, pin, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface, pin2, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_SupportSeeking(filter, TRUE); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); @@ -4154,9 +4176,88 @@ static void test_audiostream_begin_flush_end_flush(void)
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr);
- IGraphBuilder_Disconnect(graph, pin); - IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin2); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface);
ref = IAudioStreamSample_Release(stream_sample); ok(!ref, "Got outstanding refcount %d.\n", ref); @@ -4164,12 +4265,16 @@ static void test_audiostream_begin_flush_end_flush(void) ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref); - ref = IGraphBuilder_Release(graph); + graph_destroy(&graph); + ref = IMediaStreamFilter_Release(filter); ok(!ref, "Got outstanding refcount %d.\n", ref); IPin_Release(pin); IAudioMediaStream_Release(audio_stream); ref = IMediaStream_Release(stream); ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin2); + ref = IAMMediaStream_Release(stream2); + ok(!ref, "Got outstanding refcount %d.\n", ref); }
static IMediaSample *ammediastream_allocate_sample(struct testfilter *source, const BYTE *input_data, DWORD input_length) @@ -5548,35 +5653,52 @@ static void test_ddrawstream_receive(void) static void test_ddrawstream_begin_flush_end_flush(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); + static const MSPID mspid = {0x88888888, 1}; IDirectDrawStreamSample *stream_sample; IDirectDrawMediaStream *ddraw_stream; + IMediaStreamFilter *filter; IMediaSample *media_sample; IMediaFilter *media_filter; + struct testfilter source2; struct testfilter source; - IGraphBuilder *graph; + IAMMediaStream *stream2; IMediaStream *stream; VIDEOINFO video_info; + struct graph graph; AM_MEDIA_TYPE mt; HANDLE thread; HRESULT hr; + IPin *pin2; ULONG ref; IPin *pin;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + graph_init(&graph); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, (IGraphBuilder *)&graph.IFilterGraph2_iface); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMDirectDrawStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream2, NULL, 0, &mspid, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream2, &mspid, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + hr = IAMMediaStream_QueryInterface(stream2, &IID_IPin, (void **)&pin2); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(graph != NULL, "Expected non-NULL graph.\n"); - hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaFilter, (void **)&media_filter); + hr = IFilterGraph2_QueryInterface(&graph.IFilterGraph2_iface, &IID_IMediaFilter, (void **)&media_filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); ok(hr == S_OK, "Got hr %#x.\n", hr); testfilter_init(&source); - hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + testfilter_init(&source2); + source.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source2.filter.IBaseFilter_iface, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaFilter_SetSyncSource(media_filter, NULL); @@ -5587,7 +5709,12 @@ static void test_ddrawstream_begin_flush_end_flush(void) video_info.bmiHeader.biHeight = 1; mt = rgb32_mt; mt.pbFormat = (BYTE *)&video_info; - hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &mt); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface, pin, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface, pin2, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_SupportSeeking(filter, TRUE); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &stream_sample); @@ -5643,16 +5770,96 @@ static void test_ddrawstream_begin_flush_end_flush(void)
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr);
- IGraphBuilder_Disconnect(graph, pin); - IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin2); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface);
ref = IDirectDrawStreamSample_Release(stream_sample); ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref); IMediaFilter_Release(media_filter); - ref = IGraphBuilder_Release(graph); + graph_destroy(&graph); + ref = IMediaStreamFilter_Release(filter); ok(!ref, "Got outstanding refcount %d.\n", ref); IPin_Release(pin); IDirectDrawMediaStream_Release(ddraw_stream);