From: Akihiro Sagawa Subject: [RFC PATCH 1/5] quartz/tests: Factor out MP3 audio tests. Message-Id: <20200621154023.8721.375B48EC@gmail.com> Date: Sun, 21 Jun 2020 15:40:56 +0900 Prepare the code before adding MPEG video tests. Signed-off-by: Akihiro Sagawa --- dlls/quartz/tests/mpegsplit.c | 357 +++++++++++++++++++--------------- 1 file changed, 199 insertions(+), 158 deletions(-) diff --git a/dlls/quartz/tests/mpegsplit.c b/dlls/quartz/tests/mpegsplit.c index e407fe44ee..e9cb779de2 100644 --- a/dlls/quartz/tests/mpegsplit.c +++ b/dlls/quartz/tests/mpegsplit.c @@ -119,9 +119,9 @@ static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOO IUnknown_Release(unk); } -static void test_interfaces(void) +static void test_interfaces(const WCHAR* resource) { - const WCHAR *filename = load_resource(L"test.mp3"); + const WCHAR *filename = load_resource(resource); IBaseFilter *filter = create_mpeg_splitter(); IFilterGraph2 *graph = connect_input(filter, filename); IPin *pin; @@ -270,9 +270,9 @@ static void test_aggregation(void) ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref); } -static void test_enum_pins(void) +static void test_enum_pins(const WCHAR *resource) { - const WCHAR *filename = load_resource(L"test.mp3"); + const WCHAR *filename = load_resource(resource); IBaseFilter *filter = create_mpeg_splitter(); IEnumPins *enum1, *enum2; IFilterGraph2 *graph; @@ -396,9 +396,9 @@ static void test_enum_pins(void) ok(ret, "Failed to delete file, error %u.\n", GetLastError()); } -static void test_find_pin(void) +static void test_find_pin(const WCHAR* resource) { - const WCHAR *filename = load_resource(L"test.mp3"); + const WCHAR *filename = load_resource(resource); IBaseFilter *filter = create_mpeg_splitter(); IFilterGraph2 *graph; IEnumPins *enum_pins; @@ -407,16 +407,6 @@ static void test_find_pin(void) ULONG ref; BOOL ret; - hr = IBaseFilter_FindPin(filter, L"input pin", &pin); - ok(hr == VFW_E_NOT_FOUND, "Got hr %#x.\n", hr); - - hr = IBaseFilter_FindPin(filter, L"Input", &pin); - ok(hr == S_OK, "Got hr %#x.\n", hr); - IPin_Release(pin); - - hr = IBaseFilter_FindPin(filter, L"Audio", &pin); - ok(hr == VFW_E_NOT_FOUND, "Got hr %#x.\n", hr); - graph = connect_input(filter, filename); hr = IBaseFilter_EnumPins(filter, &enum_pins); @@ -448,9 +438,33 @@ static void test_find_pin(void) ok(ret, "Failed to delete file, error %u.\n", GetLastError()); } -static void test_pin_info(void) +static void test_find_pin_unconnected(void) { - const WCHAR *filename = load_resource(L"test.mp3"); + IBaseFilter *filter = create_mpeg_splitter(); + HRESULT hr; + ULONG ref; + IPin *pin; + + hr = IBaseFilter_FindPin(filter, L"input pin", &pin); + ok(hr == VFW_E_NOT_FOUND, "Got hr %#x.\n", hr); + + hr = IBaseFilter_FindPin(filter, L"Input", &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IPin_Release(pin); + + hr = IBaseFilter_FindPin(filter, L"Audio", &pin); + ok(hr == VFW_E_NOT_FOUND, "Got hr %#x.\n", hr); + + hr = IBaseFilter_FindPin(filter, L"Video", &pin); + ok(hr == VFW_E_NOT_FOUND, "Got hr %#x.\n", hr); + + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_pin_info(const WCHAR* resource) +{ + const WCHAR *filename = load_resource(resource); IBaseFilter *filter = create_mpeg_splitter(); ULONG ref, expect_ref; IFilterGraph2 *graph; @@ -519,30 +533,13 @@ static void test_pin_info(void) ok(ret, "Failed to delete file, error %u.\n", GetLastError()); } -static void test_media_types(void) +static void test_sink_media_types(void) { - MPEG1WAVEFORMAT expect_wfx = - { - {WAVE_FORMAT_MPEG, 1, 48000, 4000, 96, 0, sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX)}, - ACM_MPEG_LAYER3, 32000, ACM_MPEG_SINGLECHANNEL, 4096, 1, ACM_MPEG_ORIGINALHOME | ACM_MPEG_PROTECTIONBIT | ACM_MPEG_ID_MPEG1, 0, 0 - }; - static const MPEGLAYER3WAVEFORMAT expect_mp3_wfx = - { - {WAVE_FORMAT_MPEGLAYER3, 1, 48000, 4000, 1, 0, sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX)}, - MPEGLAYER3_ID_MPEG, 0, 96, 1, 0 - }; - - const WCHAR *filename = load_resource(L"test.mp3"); AM_MEDIA_TYPE mt = {{0}}, *pmt, expect_mt = {{0}}; IBaseFilter *filter = create_mpeg_splitter(); - MPEGLAYER3WAVEFORMAT *mp3wfx; IEnumMediaTypes *enummt; - MPEG1WAVEFORMAT *wfx; - IFilterGraph2 *graph; HRESULT hr; - ULONG ref; IPin *pin; - BOOL ret; IBaseFilter_FindPin(filter, L"Input", &pin); @@ -647,7 +644,43 @@ static void test_media_types(void) hr = IPin_QueryAccept(pin, &mt); ok(hr == S_OK, "Got hr %#x.\n", hr); + IPin_Release(pin); + IBaseFilter_Release(filter); +} + +static void test_audio_media_types(void) +{ + MPEG1WAVEFORMAT expect_wfx = + { + {WAVE_FORMAT_MPEG, 1, 48000, 4000, 96, 0, sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX)}, + ACM_MPEG_LAYER3, 32000, ACM_MPEG_SINGLECHANNEL, 4096, 1, ACM_MPEG_ORIGINALHOME | ACM_MPEG_PROTECTIONBIT | ACM_MPEG_ID_MPEG1, 0, 0 + }; + static const MPEGLAYER3WAVEFORMAT expect_mp3_wfx = + { + {WAVE_FORMAT_MPEGLAYER3, 1, 48000, 4000, 1, 0, sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX)}, + MPEGLAYER3_ID_MPEG, 0, 96, 1, 0 + }; + + const WCHAR *filename = load_resource(L"test.mp3"); + AM_MEDIA_TYPE *pmt, expect_mt = { + .majortype = MEDIATYPE_Stream, + .subtype = MEDIASUBTYPE_MPEG1System, + .bFixedSizeSamples = TRUE, + .bTemporalCompression = TRUE, + .lSampleSize = 1, + }; + IBaseFilter *filter = create_mpeg_splitter(); + MPEGLAYER3WAVEFORMAT *mp3wfx; + IEnumMediaTypes *enummt; + MPEG1WAVEFORMAT *wfx; + IFilterGraph2 *graph; + HRESULT hr; + ULONG ref; + IPin *pin; + BOOL ret; + graph = connect_input(filter, filename); + IBaseFilter_FindPin(filter, L"Input", &pin); /* Connecting input doesn't change the reported media types. */ hr = IPin_EnumMediaTypes(pin, &enummt); @@ -655,7 +688,6 @@ static void test_media_types(void) hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); - expect_mt.subtype = MEDIASUBTYPE_MPEG1System; if (hr == S_OK) { ok(!memcmp(pmt, &expect_mt, sizeof(AM_MEDIA_TYPE)), "Media types didn't match.\n"); @@ -844,9 +876,9 @@ done: ok(ret, "Failed to delete file, error %u.\n", GetLastError()); } -static void test_enum_media_types(void) +static void test_enum_media_types(const WCHAR *resource) { - const WCHAR *filename = load_resource(L"test.mp3"); + const WCHAR *filename = load_resource(resource); IBaseFilter *filter = create_mpeg_splitter(); IFilterGraph2 *graph = connect_input(filter, filename); IEnumMediaTypes *enum1, *enum2; @@ -1297,83 +1329,12 @@ static void testfilter_init(struct testfilter *filter) filter->IAsyncReader_iface.lpVtbl = &async_reader_vtbl; } -static void test_connect_pin(void) +static void test_audio_source_connect_pin(IFilterGraph2 *graph, IPin *source, struct testfilter *testsink) { - AM_MEDIA_TYPE req_mt = - { - .majortype = MEDIATYPE_Stream, - .subtype = MEDIASUBTYPE_MPEG1Audio, - .formattype = FORMAT_WaveFormatEx, - .lSampleSize = 888, - }; - IBaseFilter *filter = create_mpeg_splitter(), *reader; - const WCHAR *filename = load_resource(L"test.mp3"); - struct testfilter testsource, testsink; - IFileSourceFilter *filesource; - AM_MEDIA_TYPE mt, *source_mt; - IPin *sink, *source, *peer; + AM_MEDIA_TYPE req_mt, mt, *source_mt; IEnumMediaTypes *enummt; - IMediaControl *control; - IFilterGraph2 *graph; + IPin *peer; HRESULT hr; - ULONG ref; - BOOL ret; - - CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, - &IID_IFilterGraph2, (void **)&graph); - testfilter_init(&testsource); - testfilter_init(&testsink); - IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink"); - IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source"); - IFilterGraph2_AddFilter(graph, filter, L"splitter"); - IBaseFilter_FindPin(filter, L"Input", &sink); - IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control); - - CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, - &IID_IBaseFilter, (void **)&reader); - IBaseFilter_QueryInterface(reader, &IID_IFileSourceFilter, (void **)&filesource); - IFileSourceFilter_Load(filesource, filename, NULL); - IFileSourceFilter_Release(filesource); - IBaseFilter_FindPin(reader, L"Output", &source); - IPin_QueryInterface(source, &IID_IAsyncReader, (void **)&testsource.reader); - IPin_Release(source); - - /* Test sink connection. */ - - peer = (IPin *)0xdeadbeef; - hr = IPin_ConnectedTo(sink, &peer); - ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); - ok(!peer, "Got peer %p.\n", peer); - - hr = IPin_ConnectionMediaType(sink, &mt); - ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); - - req_mt.majortype = MEDIATYPE_Video; - hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); - ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); - req_mt.majortype = MEDIATYPE_Stream; - - req_mt.subtype = MEDIASUBTYPE_RGB8; - hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); - ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); - req_mt.subtype = MEDIASUBTYPE_MPEG1Audio; - - hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); - ok(hr == S_OK, "Got hr %#x.\n", hr); - - hr = IPin_ConnectedTo(sink, &peer); - ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(peer == &testsource.source.pin.IPin_iface, "Got peer %p.\n", peer); - IPin_Release(peer); - - hr = IPin_ConnectionMediaType(sink, &mt); - ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n"); - ok(compare_media_types(&testsource.source.pin.mt, &req_mt), "Media types didn't match.\n"); - - /* Test source connection. */ - - IBaseFilter_FindPin(filter, L"Audio", &source); peer = (IPin *)0xdeadbeef; hr = IPin_ConnectedTo(source, &peer); @@ -1390,113 +1351,196 @@ static void test_connect_pin(void) IEnumMediaTypes_Release(enummt); CopyMediaType(&req_mt, source_mt); - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IPin_ConnectedTo(source, &peer); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(peer == &testsink.sink.pin.IPin_iface, "Got peer %p.\n", peer); + ok(peer == &testsink->sink.pin.IPin_iface, "Got peer %p.\n", peer); IPin_Release(peer); hr = IPin_ConnectionMediaType(source, &mt); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n"); - ok(compare_media_types(&testsink.sink.pin.mt, &req_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsink->sink.pin.mt, &req_mt), "Media types didn't match.\n"); hr = IFilterGraph2_Disconnect(graph, source); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IFilterGraph2_Disconnect(graph, source); ok(hr == S_FALSE, "Got hr %#x.\n", hr); - ok(testsink.sink.pin.peer == source, "Got peer %p.\n", testsink.sink.pin.peer); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + ok(testsink->sink.pin.peer == source, "Got peer %p.\n", testsink->sink.pin.peer); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); req_mt.lSampleSize = 999; req_mt.bTemporalCompression = req_mt.bFixedSizeSamples = TRUE; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(compare_media_types(&testsink.sink.pin.mt, &req_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsink->sink.pin.mt, &req_mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); req_mt.majortype = MEDIATYPE_Stream; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); req_mt.majortype = MEDIATYPE_Audio; req_mt.subtype = MEDIASUBTYPE_PCM; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); req_mt.subtype = GUID_NULL; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); req_mt.subtype = MEDIASUBTYPE_MPEG1AudioPayload; /* Connection with wildcards. */ - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(compare_media_types(&testsink.sink.pin.mt, source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsink->sink.pin.mt, source_mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); req_mt.majortype = GUID_NULL; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); if (hr == S_OK) - ok(compare_media_types(&testsink.sink.pin.mt, source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsink->sink.pin.mt, source_mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); req_mt.subtype = MEDIASUBTYPE_PCM; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); req_mt.subtype = GUID_NULL; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(compare_media_types(&testsink.sink.pin.mt, source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsink->sink.pin.mt, source_mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); req_mt.formattype = FORMAT_None; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); req_mt.majortype = MEDIATYPE_Audio; req_mt.subtype = MEDIASUBTYPE_MPEG1AudioPayload; req_mt.formattype = GUID_NULL; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); if (hr == S_OK) - ok(compare_media_types(&testsink.sink.pin.mt, source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsink->sink.pin.mt, source_mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); req_mt.subtype = MEDIASUBTYPE_PCM; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); req_mt.subtype = GUID_NULL; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(compare_media_types(&testsink.sink.pin.mt, source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsink->sink.pin.mt, source_mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); req_mt.majortype = MEDIATYPE_Stream; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - testsink.mt = &req_mt; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); + testsink->mt = &req_mt; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, NULL); ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); req_mt.majortype = MEDIATYPE_Audio; req_mt.subtype = MEDIASUBTYPE_MPEG1AudioPayload; req_mt.formattype = FORMAT_WaveFormatEx; - hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, NULL); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + FreeMediaType(&req_mt); + DeleteMediaType(source_mt); +} + +static void test_audio_connect_pin(void) +{ + AM_MEDIA_TYPE req_mt = + { + .majortype = MEDIATYPE_Stream, + .subtype = MEDIASUBTYPE_MPEG1Audio, + .formattype = FORMAT_WaveFormatEx, + .lSampleSize = 888, + }; + IBaseFilter *filter = create_mpeg_splitter(), *reader; + const WCHAR *filename = load_resource(L"test.mp3"); + struct testfilter testsource, testsink; + IFileSourceFilter *filesource; + IPin *sink, *source, *peer; + IMediaControl *control; + IFilterGraph2 *graph; + AM_MEDIA_TYPE mt; + HRESULT hr; + ULONG ref; + BOOL ret; + + CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, + &IID_IFilterGraph2, (void **)&graph); + testfilter_init(&testsource); + testfilter_init(&testsink); + IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink"); + IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source"); + IFilterGraph2_AddFilter(graph, filter, L"splitter"); + IBaseFilter_FindPin(filter, L"Input", &sink); + IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control); + + CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, + &IID_IBaseFilter, (void **)&reader); + IBaseFilter_QueryInterface(reader, &IID_IFileSourceFilter, (void **)&filesource); + IFileSourceFilter_Load(filesource, filename, NULL); + IFileSourceFilter_Release(filesource); + IBaseFilter_FindPin(reader, L"Output", &source); + IPin_QueryInterface(source, &IID_IAsyncReader, (void **)&testsource.reader); + IPin_Release(source); + + /* Test sink connection. */ + + peer = (IPin *)0xdeadbeef; + hr = IPin_ConnectedTo(sink, &peer); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + ok(!peer, "Got peer %p.\n", peer); + + hr = IPin_ConnectionMediaType(sink, &mt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + req_mt.majortype = MEDIATYPE_Video; + hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + req_mt.majortype = MEDIATYPE_Stream; + + req_mt.subtype = MEDIASUBTYPE_RGB8; + hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + req_mt.subtype = MEDIASUBTYPE_MPEG1Audio; + + hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_ConnectedTo(sink, &peer); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(peer == &testsource.source.pin.IPin_iface, "Got peer %p.\n", peer); + IPin_Release(peer); + + hr = IPin_ConnectionMediaType(sink, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &req_mt), "Media types didn't match.\n"); + + /* Test source connection. */ + + IBaseFilter_FindPin(filter, L"Audio", &source); + + test_audio_source_connect_pin(graph, source, &testsink); + IPin_Release(source); hr = IFilterGraph2_Disconnect(graph, sink); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1505,10 +1549,6 @@ static void test_connect_pin(void) ok(testsource.source.pin.peer == sink, "Got peer %p.\n", testsource.source.pin.peer); IFilterGraph2_Disconnect(graph, &testsource.source.pin.IPin_iface); - CoTaskMemFree(req_mt.pbFormat); - CoTaskMemFree(source_mt->pbFormat); - CoTaskMemFree(source_mt); - IAsyncReader_Release(testsource.reader); IPin_Release(sink); IMediaControl_Release(control); @@ -1539,16 +1579,17 @@ START_TEST(mpegsplit) return; } IBaseFilter_Release(filter); - - test_interfaces(); + test_interfaces(L"test.mp3"); test_aggregation(); - test_enum_pins(); - test_find_pin(); - test_pin_info(); - test_media_types(); - test_enum_media_types(); + test_enum_pins(L"test.mp3"); + test_find_pin_unconnected(); + test_find_pin(L"test.mp3"); + test_pin_info(L"test.mp3"); + test_sink_media_types(); + test_audio_media_types(); + test_enum_media_types(L"test.mp3"); test_unconnected_filter_state(); - test_connect_pin(); + test_audio_connect_pin(); CoUninitialize(); }