Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qedit/samplegrabber.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c index f0fa70708a1..322cbf04001 100644 --- a/dlls/qedit/samplegrabber.c +++ b/dlls/qedit/samplegrabber.c @@ -254,7 +254,7 @@ SampleGrabber_ISampleGrabber_GetConnectedMediaType(ISampleGrabber *iface, AM_MED if (!filter->sink.pin.peer) return VFW_E_NOT_CONNECTED;
- CopyMediaType(mt, &filter->filter_mt); + CopyMediaType(mt, &filter->sink.pin.mt); return S_OK; }
@@ -519,9 +519,6 @@ static HRESULT sample_grabber_sink_connect(struct strmbase_sink *iface, && !IsEqualGUID(&filter->filter_mt.formattype, &mt->formattype)) return VFW_E_TYPE_NOT_ACCEPTED;
- FreeMediaType(&filter->filter_mt); - CopyMediaType(&filter->filter_mt, mt); - return S_OK; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qedit/samplegrabber.c | 38 ++++---- dlls/qedit/tests/samplegrabber.c | 154 +++++++++++++------------------ 2 files changed, 85 insertions(+), 107 deletions(-)
diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c index 322cbf04001..696053b1d58 100644 --- a/dlls/qedit/samplegrabber.c +++ b/dlls/qedit/samplegrabber.c @@ -547,6 +547,28 @@ static HRESULT sample_grabber_source_query_interface(struct strmbase_pin *iface,
static HRESULT sample_grabber_source_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt) { + SG_Impl *filter = impl_from_source_pin(iface); + + if (filter->sink.pin.peer && IPin_QueryAccept(filter->sink.pin.peer, mt) != S_OK) + return S_FALSE; + + strmbase_dump_media_type(&filter->filter_mt); + + if (IsEqualGUID(&filter->filter_mt.majortype, &GUID_NULL)) + return S_OK; + if (!IsEqualGUID(&filter->filter_mt.majortype, &mt->majortype)) + return S_FALSE; + + if (IsEqualGUID(&filter->filter_mt.subtype, &GUID_NULL)) + return S_OK; + if (!IsEqualGUID(&filter->filter_mt.subtype, &mt->subtype)) + return S_FALSE; + + if (IsEqualGUID(&filter->filter_mt.formattype, &GUID_NULL)) + return S_OK; + if (!IsEqualGUID(&filter->filter_mt.formattype, &mt->formattype)) + return S_FALSE; + return S_OK; }
@@ -566,22 +588,6 @@ static HRESULT sample_grabber_source_get_media_type(struct strmbase_pin *iface, static HRESULT WINAPI sample_grabber_source_DecideAllocator(struct strmbase_source *iface, IMemInputPin *peer, IMemAllocator **allocator) { - SG_Impl *filter = impl_from_source_pin(&iface->pin); - const AM_MEDIA_TYPE *mt = &iface->pin.mt; - - if (!IsEqualGUID(&mt->majortype, &filter->filter_mt.majortype)) - return VFW_E_TYPE_NOT_ACCEPTED; - if (!IsEqualGUID(&mt->subtype, &filter->filter_mt.subtype)) - return VFW_E_TYPE_NOT_ACCEPTED; - if (!IsEqualGUID(&mt->formattype, &FORMAT_None) - && !IsEqualGUID(&mt->formattype, &GUID_NULL) - && !IsEqualGUID(&mt->formattype, &filter->filter_mt.formattype)) - return VFW_E_TYPE_NOT_ACCEPTED; - if (!IsEqualGUID(&mt->formattype, &FORMAT_None) - && !IsEqualGUID(&mt->formattype, &GUID_NULL) - && !mt->pbFormat) - return VFW_E_TYPE_NOT_ACCEPTED; - return S_OK; }
diff --git a/dlls/qedit/tests/samplegrabber.c b/dlls/qedit/tests/samplegrabber.c index 6404e053886..e8ab1073fb0 100644 --- a/dlls/qedit/tests/samplegrabber.c +++ b/dlls/qedit/tests/samplegrabber.c @@ -517,13 +517,13 @@ static void test_media_types(void) hr = IPin_QueryAccept(sink, &mt); todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); hr = IPin_QueryAccept(source, &mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr);
mt.majortype = GUID_NULL; hr = IPin_QueryAccept(sink, &mt); todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); hr = IPin_QueryAccept(source, &mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); mt.majortype = match_mt.majortype; hr = IPin_QueryAccept(sink, &mt); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -537,13 +537,13 @@ static void test_media_types(void) hr = IPin_QueryAccept(sink, &mt); todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); hr = IPin_QueryAccept(source, &mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr);
mt.subtype = GUID_NULL; hr = IPin_QueryAccept(sink, &mt); todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); hr = IPin_QueryAccept(source, &mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); mt.subtype = match_mt.subtype; hr = IPin_QueryAccept(sink, &mt); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -556,13 +556,13 @@ static void test_media_types(void) hr = IPin_QueryAccept(sink, &mt); todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); hr = IPin_QueryAccept(source, &mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr);
mt.formattype = GUID_NULL; hr = IPin_QueryAccept(sink, &mt); todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); hr = IPin_QueryAccept(source, &mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); mt.formattype = match_mt.formattype; hr = IPin_QueryAccept(sink, &mt); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -841,7 +841,7 @@ static void test_connect_pin(void) hr = IPin_QueryAccept(sink, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IPin_QueryAccept(source, &req_mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); req_mt.bTemporalCompression = TRUE; hr = IPin_QueryAccept(source, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -852,12 +852,12 @@ static void test_connect_pin(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_QueryAccept(source, &req_mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr);
req_mt.majortype = MEDIATYPE_Midi; req_mt.bTemporalCompression = FALSE; hr = IPin_QueryAccept(source, &req_mt); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr);
req_mt.bTemporalCompression = TRUE; hr = IPin_QueryAccept(source, &req_mt); @@ -885,81 +885,72 @@ static void test_connect_pin(void)
req_mt.bTemporalCompression = TRUE; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr);
- if (hr == S_OK) - { - 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); - IPin_Release(peer); + 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); + 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(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + 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"); + todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.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); - } + 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);
/* Connection with wildcards. */
hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr);
testsource.source_mt.bTemporalCompression = TRUE; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + } IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
req_mt.majortype = GUID_NULL; req_mt.bTemporalCompression = FALSE; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + } IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
req_mt.subtype = MEDIASUBTYPE_RGB32; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + 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); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + } IFilterGraph2_Disconnect(graph, source); 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); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr);
req_mt.majortype = MEDIATYPE_Video; req_mt.subtype = MEDIASUBTYPE_RGB8; @@ -980,68 +971,49 @@ static void test_connect_pin(void)
req_mt.subtype = GUID_NULL; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + } IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
req_mt.majortype = MEDIATYPE_Audio; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr);
testsource.source_mt.majortype = testsource.source_mt.subtype = testsource.source_mt.formattype = GUID_NULL; req_mt.majortype = req_mt.subtype = req_mt.formattype = GUID_NULL; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + } IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
req_mt.majortype = MEDIATYPE_Video; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); req_mt.majortype = GUID_NULL;
req_mt.subtype = MEDIASUBTYPE_RGB8; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); req_mt.subtype = GUID_NULL;
req_mt.formattype = FORMAT_None; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); req_mt.formattype = GUID_NULL;
testsink.sink_mt = &req_mt; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); - todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - IFilterGraph2_Disconnect(graph, source); - IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); - } + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr);
req_mt.bTemporalCompression = TRUE; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qedit/samplegrabber.c | 18 ++++++- dlls/qedit/tests/samplegrabber.c | 81 +++++++++++++++++--------------- 2 files changed, 58 insertions(+), 41 deletions(-)
diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c index 696053b1d58..4e9d5157cf0 100644 --- a/dlls/qedit/samplegrabber.c +++ b/dlls/qedit/samplegrabber.c @@ -576,12 +576,26 @@ static HRESULT sample_grabber_source_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt) { SG_Impl *filter = impl_from_source_pin(iface); + IEnumMediaTypes *enummt; + AM_MEDIA_TYPE *pmt; + HRESULT hr;
- if (!index) + if (!filter->sink.pin.peer) + return VFW_E_NOT_CONNECTED; + + if (FAILED(hr = IPin_EnumMediaTypes(filter->sink.pin.peer, &enummt))) + return hr; + + if ((!index || IEnumMediaTypes_Skip(enummt, index) == S_OK) + && IEnumMediaTypes_Next(enummt, 1, &pmt, NULL) == S_OK) { - CopyMediaType(mt, &filter->filter_mt); + CopyMediaType(mt, pmt); + DeleteMediaType(pmt); + IEnumMediaTypes_Release(enummt); return S_OK; } + + IEnumMediaTypes_Release(enummt); return VFW_S_NO_MORE_ITEMS; }
diff --git a/dlls/qedit/tests/samplegrabber.c b/dlls/qedit/tests/samplegrabber.c index e8ab1073fb0..6c084d3a492 100644 --- a/dlls/qedit/tests/samplegrabber.c +++ b/dlls/qedit/tests/samplegrabber.c @@ -486,8 +486,7 @@ static void test_media_types(void) if (hr == S_OK) IEnumMediaTypes_Release(enummt);
hr = IPin_EnumMediaTypes(source, &enummt); - todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); - if (hr == S_OK) IEnumMediaTypes_Release(enummt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
hr = IPin_QueryAccept(sink, &mt); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -502,8 +501,7 @@ static void test_media_types(void) if (hr == S_OK) IEnumMediaTypes_Release(enummt);
hr = IPin_EnumMediaTypes(source, &enummt); - todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); - if (hr == S_OK) IEnumMediaTypes_Release(enummt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
hr = IPin_QueryAccept(sink, &mt); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -832,7 +830,7 @@ static void test_connect_pin(void) ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(compare_media_types(pmt, &testsource.source_mt), "Media types didn't match.\n"); + ok(compare_media_types(pmt, &testsource.source_mt), "Media types didn't match.\n"); IEnumMediaTypes_Release(enummt);
req_mt.majortype = MEDIATYPE_Video; @@ -912,24 +910,18 @@ static void test_connect_pin(void)
testsource.source_mt.bTemporalCompression = TRUE; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); - if (hr == S_OK) - { - ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); - ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); - } + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
req_mt.majortype = GUID_NULL; req_mt.bTemporalCompression = FALSE; 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, &testsource.source_mt), "Media types didn't match.\n"); - ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); - } + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
@@ -939,18 +931,20 @@ static void test_connect_pin(void)
req_mt.subtype = GUID_NULL; 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, &testsource.source_mt), "Media types didn't match.\n"); - ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); - } + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); 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); - ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + }
req_mt.majortype = MEDIATYPE_Video; req_mt.subtype = MEDIASUBTYPE_RGB8; @@ -971,12 +965,9 @@ static void test_connect_pin(void)
req_mt.subtype = GUID_NULL; 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, &testsource.source_mt), "Media types didn't match.\n"); - ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); - } + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
@@ -987,28 +978,40 @@ static void test_connect_pin(void) testsource.source_mt.majortype = testsource.source_mt.subtype = testsource.source_mt.formattype = GUID_NULL; req_mt.majortype = req_mt.subtype = req_mt.formattype = GUID_NULL; 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, &testsource.source_mt), "Media types didn't match.\n"); - ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); - } + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &testsource.source_mt), "Media types didn't match.\n"); + todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
req_mt.majortype = MEDIATYPE_Video; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + } req_mt.majortype = GUID_NULL;
req_mt.subtype = MEDIASUBTYPE_RGB8; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + } req_mt.subtype = GUID_NULL;
req_mt.formattype = FORMAT_None; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); - ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + todo_wine ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + } req_mt.formattype = GUID_NULL;
testsink.sink_mt = &req_mt;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qedit/samplegrabber.c | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c index 4e9d5157cf0..c82f2045eea 100644 --- a/dlls/qedit/samplegrabber.c +++ b/dlls/qedit/samplegrabber.c @@ -503,10 +503,6 @@ static HRESULT sample_grabber_sink_connect(struct strmbase_sink *iface, { SG_Impl *filter = impl_from_sink_pin(&iface->pin);
- if (!IsEqualGUID(&mt->formattype, &FORMAT_None) - && !IsEqualGUID(&mt->formattype, &GUID_NULL) && !mt->pbFormat) - return VFW_E_INVALIDMEDIATYPE; - if (!IsEqualGUID(&filter->filter_mt.majortype, &GUID_NULL) && !IsEqualGUID(&filter->filter_mt.majortype, &mt->majortype)) return VFW_E_TYPE_NOT_ACCEPTED;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qedit/samplegrabber.c | 26 ++++++++++++++++++++++++++ dlls/qedit/tests/samplegrabber.c | 14 +++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c index c82f2045eea..3ec440d155c 100644 --- a/dlls/qedit/samplegrabber.c +++ b/dlls/qedit/samplegrabber.c @@ -595,9 +595,35 @@ static HRESULT sample_grabber_source_get_media_type(struct strmbase_pin *iface, return VFW_S_NO_MORE_ITEMS; }
+static inline BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b) +{ + return !memcmp(a, b, offsetof(AM_MEDIA_TYPE, pbFormat)) + && !memcmp(a->pbFormat, b->pbFormat, a->cbFormat); +} + static HRESULT WINAPI sample_grabber_source_DecideAllocator(struct strmbase_source *iface, IMemInputPin *peer, IMemAllocator **allocator) { + SG_Impl *filter = impl_from_source_pin(&iface->pin); + const AM_MEDIA_TYPE *mt = &iface->pin.mt; + + if (!compare_media_types(mt, &filter->sink.pin.mt)) + { + IFilterGraph2 *graph; + HRESULT hr; + + if (FAILED(hr = IFilterGraph_QueryInterface(filter->filter.graph, + &IID_IFilterGraph2, (void **)&graph))) + { + ERR("Failed to get IFilterGraph2 interface, hr %#x.\n", hr); + return hr; + } + + hr = IFilterGraph2_ReconnectEx(graph, &filter->sink.pin.IPin_iface, mt); + IFilterGraph2_Release(graph); + return hr; + } + return S_OK; }
diff --git a/dlls/qedit/tests/samplegrabber.c b/dlls/qedit/tests/samplegrabber.c index 6c084d3a492..04842211414 100644 --- a/dlls/qedit/tests/samplegrabber.c +++ b/dlls/qedit/tests/samplegrabber.c @@ -894,7 +894,7 @@ static void test_connect_pin(void) 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"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n");
hr = IFilterGraph2_Disconnect(graph, source); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -912,7 +912,7 @@ static void test_connect_pin(void) 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, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
@@ -921,7 +921,7 @@ static void test_connect_pin(void) 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, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
@@ -933,7 +933,7 @@ static void test_connect_pin(void) 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, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
@@ -967,7 +967,7 @@ static void test_connect_pin(void) 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, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
@@ -980,7 +980,7 @@ static void test_connect_pin(void) 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, &testsource.source_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
@@ -1022,7 +1022,7 @@ static void test_connect_pin(void) 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, &req_mt), "Media types didn't match.\n"); - todo_wine ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);