-- v3: mf: Add error cases for MFGetTopoNodeCurrentType. mf/tests: Add more MFGetTopoNodeCurrentType tests. winegstreamer: Fix ColorConvert transform GetCurrent(Input|Output)Type. winegstreamer: Fix Resampler transform GetCurrent(Input|Output)Type.
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/resampler.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/winegstreamer/resampler.c b/dlls/winegstreamer/resampler.c index ea000e3b96f..65a29d96794 100644 --- a/dlls/winegstreamer/resampler.c +++ b/dlls/winegstreamer/resampler.c @@ -435,7 +435,6 @@ failed: static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) { struct resampler *impl = impl_from_IMFTransform(iface); - IMFMediaType *ret; HRESULT hr;
TRACE("iface %p, id %#lx, type %p.\n", iface, id, type); @@ -446,16 +445,18 @@ static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD i if (!impl->input_type) return MF_E_TRANSFORM_TYPE_NOT_SET;
- if (FAILED(hr = MFCreateMediaType(&ret))) + if (FAILED(hr = MFCreateMediaType(type))) return hr;
- return IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)ret); + if (FAILED(hr = IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)*type))) + IMFMediaType_Release(*type); + + return hr; }
static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) { struct resampler *impl = impl_from_IMFTransform(iface); - IMFMediaType *ret; HRESULT hr;
TRACE("iface %p, id %#lx, type %p.\n", iface, id, type); @@ -466,10 +467,13 @@ static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD if (!impl->output_type) return MF_E_TRANSFORM_TYPE_NOT_SET;
- if (FAILED(hr = MFCreateMediaType(&ret))) + if (FAILED(hr = MFCreateMediaType(type))) return hr;
- return IMFMediaType_CopyAllItems(impl->output_type, (IMFAttributes *)ret); + if (FAILED(hr = IMFMediaType_CopyAllItems(impl->output_type, (IMFAttributes *)*type))) + IMFMediaType_Release(*type); + + return hr; }
static HRESULT WINAPI transform_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/color_convert.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/winegstreamer/color_convert.c b/dlls/winegstreamer/color_convert.c index 66a86aa4602..b47832b2c30 100644 --- a/dlls/winegstreamer/color_convert.c +++ b/dlls/winegstreamer/color_convert.c @@ -466,7 +466,6 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) { struct color_convert *impl = impl_from_IMFTransform(iface); - IMFMediaType *ret; HRESULT hr;
TRACE("iface %p, id %#lx, type %p.\n", iface, id, type); @@ -477,16 +476,18 @@ static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD i if (!impl->input_type) return MF_E_TRANSFORM_TYPE_NOT_SET;
- if (FAILED(hr = MFCreateMediaType(&ret))) + if (FAILED(hr = MFCreateMediaType(type))) return hr;
- return IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)ret); + if (FAILED(hr = IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)*type))) + IMFMediaType_Release(*type); + + return hr; }
static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) { struct color_convert *impl = impl_from_IMFTransform(iface); - IMFMediaType *ret; HRESULT hr;
TRACE("iface %p, id %#lx, type %p.\n", iface, id, type); @@ -497,10 +498,13 @@ static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD if (!impl->output_type) return MF_E_TRANSFORM_TYPE_NOT_SET;
- if (FAILED(hr = MFCreateMediaType(&ret))) + if (FAILED(hr = MFCreateMediaType(type))) return hr;
- return IMFMediaType_CopyAllItems(impl->output_type, (IMFAttributes *)ret); + if (FAILED(hr = IMFMediaType_CopyAllItems(impl->output_type, (IMFAttributes *)*type))) + IMFMediaType_Release(*type); + + return hr; }
static HRESULT WINAPI transform_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 351 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 321 insertions(+), 30 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 8d725a65515..c447bad59e2 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1301,6 +1301,131 @@ static void test_sequencer_source(void) ok(hr == S_OK, "Shutdown failure, hr %#lx.\n", hr); }
+struct test_stream_sink +{ + IMFStreamSink IMFStreamSink_iface; + IMFMediaTypeHandler *handler; +}; + +static struct test_stream_sink *impl_from_IMFStreamSink(IMFStreamSink *iface) +{ + return CONTAINING_RECORD(iface, struct test_stream_sink, IMFStreamSink_iface); +} + +static HRESULT WINAPI test_stream_sink_QueryInterface(IMFStreamSink *iface, REFIID riid, void **obj) +{ + if (IsEqualIID(riid, &IID_IMFStreamSink) + || IsEqualIID(riid, &IID_IMFMediaEventGenerator) + || IsEqualIID(riid, &IID_IUnknown)) + { + IMFStreamSink_AddRef((*obj = iface)); + return S_OK; + } + + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI test_stream_sink_AddRef(IMFStreamSink *iface) +{ + return 2; +} + +static ULONG WINAPI test_stream_sink_Release(IMFStreamSink *iface) +{ + return 1; +} + +static HRESULT WINAPI test_stream_sink_GetEvent(IMFStreamSink *iface, DWORD flags, IMFMediaEvent **event) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_BeginGetEvent(IMFStreamSink *iface, IMFAsyncCallback *callback, IUnknown *state) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_EndGetEvent(IMFStreamSink *iface, IMFAsyncResult *result, + IMFMediaEvent **event) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_QueueEvent(IMFStreamSink *iface, MediaEventType event_type, + REFGUID ext_type, HRESULT hr, const PROPVARIANT *value) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_GetMediaSink(IMFStreamSink *iface, IMFMediaSink **sink) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_GetIdentifier(IMFStreamSink *iface, DWORD *id) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_GetMediaTypeHandler(IMFStreamSink *iface, IMFMediaTypeHandler **handler) +{ + struct test_stream_sink *impl = impl_from_IMFStreamSink(iface); + + if (impl->handler) + { + IMFMediaTypeHandler_AddRef((*handler = impl->handler)); + return S_OK; + } + + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_ProcessSample(IMFStreamSink *iface, IMFSample *sample) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_PlaceMarker(IMFStreamSink *iface, MFSTREAMSINK_MARKER_TYPE marker_type, + const PROPVARIANT *marker_value, const PROPVARIANT *context) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_stream_sink_Flush(IMFStreamSink *iface) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static const IMFStreamSinkVtbl test_stream_sink_vtbl = +{ + test_stream_sink_QueryInterface, + test_stream_sink_AddRef, + test_stream_sink_Release, + test_stream_sink_GetEvent, + test_stream_sink_BeginGetEvent, + test_stream_sink_EndGetEvent, + test_stream_sink_QueueEvent, + test_stream_sink_GetMediaSink, + test_stream_sink_GetIdentifier, + test_stream_sink_GetMediaTypeHandler, + test_stream_sink_ProcessSample, + test_stream_sink_PlaceMarker, + test_stream_sink_Flush, +}; + +static const struct test_stream_sink test_stream_sink = {.IMFStreamSink_iface.lpVtbl = &test_stream_sink_vtbl}; + struct test_callback { IMFAsyncCallback IMFAsyncCallback_iface; @@ -5858,8 +5983,20 @@ static void test_sample_copier_output_processing(void)
static void test_MFGetTopoNodeCurrentType(void) { - IMFMediaType *media_type, *media_type2; + static const struct attribute_desc media_type_desc[] = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12), + ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080), + {0}, + }; + IMFMediaType *media_type, *input_types[2], *output_types[2]; + IMFStreamDescriptor *input_descriptor, *output_descriptor; + struct test_stream_sink stream_sink = test_stream_sink; + IMFMediaTypeHandler *input_handler, *output_handler; + IMFTransform *transform; IMFTopologyNode *node; + DWORD flags; HRESULT hr; LONG ref;
@@ -5869,80 +6006,234 @@ static void test_MFGetTopoNodeCurrentType(void) return; }
+ hr = CoInitialize(NULL); + ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr); + + hr = MFCreateMediaType(&input_types[0]); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + init_media_type(input_types[0], media_type_desc, -1); + hr = MFCreateMediaType(&input_types[1]); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + init_media_type(input_types[1], media_type_desc, -1); + hr = MFCreateMediaType(&output_types[0]); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + init_media_type(output_types[0], media_type_desc, -1); + hr = MFCreateMediaType(&output_types[1]); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + init_media_type(output_types[1], media_type_desc, -1); + + hr = MFCreateStreamDescriptor(0, 2, input_types, &input_descriptor); + ok(hr == S_OK, "Failed to create IMFStreamDescriptor hr %#lx.\n", hr); + hr = IMFStreamDescriptor_GetMediaTypeHandler(input_descriptor, &input_handler); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFCreateStreamDescriptor(0, 2, output_types, &output_descriptor); + ok(hr == S_OK, "Failed to create IMFStreamDescriptor hr %#lx.\n", hr); + hr = IMFStreamDescriptor_GetMediaTypeHandler(output_descriptor, &output_handler); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = CoCreateInstance(&CLSID_CColorConvertDMO, NULL, CLSCTX_INPROC_SERVER, &IID_IMFTransform, (void **)&transform); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + /* Tee node. */ hr = MFCreateTopologyNode(MF_TOPOLOGY_TEE_NODE, &node); ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr); - hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); - hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
- hr = MFCreateMediaType(&media_type2); - ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + /* Set second output. */ + hr = IMFTopologyNode_SetOutputPrefType(node, 1, output_types[1]); + ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, TRUE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, FALSE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaType_SetGUID(media_type2, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + /* Set first output. */ + hr = IMFTopologyNode_SetOutputPrefType(node, 0, output_types[0]); + ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == output_types[0], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type); + hr = pMFGetTopoNodeCurrentType(node, 1, TRUE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == output_types[0], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type); + hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == output_types[0], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type); + + /* Set primary output. */ + hr = IMFTopologyNode_SetOutputPrefType(node, 1, output_types[1]); + ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + hr = IMFTopologyNode_SetUINT32(node, &MF_TOPONODE_PRIMARYOUTPUT, 1); ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == output_types[1], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type); + hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == output_types[1], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type); + hr = pMFGetTopoNodeCurrentType(node, 1, FALSE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == output_types[1], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type);
/* Input type returned, if set. */ - hr = IMFTopologyNode_SetInputPrefType(node, 0, media_type2); + hr = IMFTopologyNode_SetInputPrefType(node, 0, input_types[0]); ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); - hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(media_type == media_type2, "Unexpected pointer.\n"); + ok(media_type == input_types[0], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == input_types[0], "Unexpected pointer.\n"); IMFMediaType_Release(media_type);
hr = IMFTopologyNode_SetInputPrefType(node, 0, NULL); ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + hr = IMFTopologyNode_SetOutputPrefType(node, 0, NULL); + ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + hr = IMFTopologyNode_SetOutputPrefType(node, 1, NULL); + ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + ref = IMFTopologyNode_Release(node); + ok(ref == 0, "Release returned %ld\n", ref);
+ + /* Source node. */ + hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node); + ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, TRUE, &media_type); + todo_wine + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); - ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
- /* Set second output. */ - hr = IMFTopologyNode_SetOutputPrefType(node, 1, media_type2); - ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + hr = IMFTopologyNode_SetUnknown(node, &MF_TOPONODE_STREAM_DESCRIPTOR, (IUnknown *)input_descriptor); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaTypeHandler_SetCurrentMediaType(input_handler, output_types[0]); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(media_type == output_types[0], "Unexpected pointer.\n"); + IMFMediaType_Release(media_type);
+ ref = IMFTopologyNode_Release(node); + ok(ref == 0, "Release returned %ld\n", ref); + + + /* Output node. */ + hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &node); + ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + todo_wine ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, FALSE, &media_type); + todo_wine + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + todo_wine + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
- hr = IMFTopologyNode_SetOutputPrefType(node, 1, NULL); - ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); - - /* Set first output. */ - hr = IMFTopologyNode_SetOutputPrefType(node, 0, media_type2); - ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + stream_sink.handler = output_handler; + hr = IMFTopologyNode_SetObject(node, (IUnknown *)&stream_sink.IMFStreamSink_iface); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
+ hr = IMFMediaTypeHandler_SetCurrentMediaType(output_handler, input_types[0]); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(media_type == media_type2, "Unexpected pointer.\n"); + ok(media_type == input_types[0], "Unexpected pointer.\n"); IMFMediaType_Release(media_type);
- hr = IMFTopologyNode_SetOutputPrefType(node, 0, NULL); - ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr); + ref = IMFTopologyNode_Release(node); + ok(ref == 0, "Release returned %ld\n", ref);
- /* Set primary output. */ - hr = IMFTopologyNode_SetOutputPrefType(node, 1, media_type2); - ok(hr == S_OK, "Failed to set media type, hr %#lx.\n", hr);
- hr = IMFTopologyNode_SetUINT32(node, &MF_TOPONODE_PRIMARYOUTPUT, 1); - ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + /* Transform node. */ + hr = MFCreateTopologyNode(MF_TOPOLOGY_TRANSFORM_NODE, &node); + ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, TRUE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, FALSE, &media_type); + ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr);
+ hr = IMFTopologyNode_SetObject(node, (IUnknown *)transform); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, TRUE, &media_type); + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 1, FALSE, &media_type); + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_SetInputType(transform, 0, input_types[0], 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_IsEqual(media_type, input_types[0], &flags); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(media_type == media_type2, "Unexpected pointer.\n"); IMFMediaType_Release(media_type);
+ hr = IMFTransform_SetOutputType(transform, 0, output_types[0], 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(media_type == media_type2, "Unexpected pointer.\n"); + hr = IMFMediaType_IsEqual(media_type, output_types[0], &flags); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); IMFMediaType_Release(media_type);
ref = IMFTopologyNode_Release(node); ok(ref == 0, "Release returned %ld\n", ref); - ref = IMFMediaType_Release(media_type2); + + + ref = IMFTransform_Release(transform); + ok(ref == 0, "Release returned %ld\n", ref); + + IMFMediaTypeHandler_Release(input_handler); + IMFMediaTypeHandler_Release(output_handler); + ref = IMFStreamDescriptor_Release(input_descriptor); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFStreamDescriptor_Release(output_descriptor); ok(ref == 0, "Release returned %ld\n", ref); + + ref = IMFMediaType_Release(input_types[0]); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFMediaType_Release(input_types[1]); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFMediaType_Release(output_types[0]); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFMediaType_Release(output_types[1]); + ok(ref == 0, "Release returned %ld\n", ref); + + CoUninitialize(); }
static void init_functions(void)
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 5 ----- dlls/mf/topology.c | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index c447bad59e2..fd4acf6dfbf 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -6117,10 +6117,8 @@ static void test_MFGetTopoNodeCurrentType(void) hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 1, TRUE, &media_type); - todo_wine ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); - todo_wine ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
hr = IMFTopologyNode_SetUnknown(node, &MF_TOPONODE_STREAM_DESCRIPTOR, (IUnknown *)input_descriptor); @@ -6143,13 +6141,10 @@ static void test_MFGetTopoNodeCurrentType(void) hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &node); ok(hr == S_OK, "Failed to create a node, hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, FALSE, &media_type); - todo_wine ok(hr == E_FAIL, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 1, FALSE, &media_type); - todo_wine ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); hr = pMFGetTopoNodeCurrentType(node, 0, TRUE, &media_type); - todo_wine ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
stream_sink.handler = output_handler; diff --git a/dlls/mf/topology.c b/dlls/mf/topology.c index 8d64c10b5c7..34c20dbc735 100644 --- a/dlls/mf/topology.c +++ b/dlls/mf/topology.c @@ -1841,7 +1841,10 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO switch (node_type) { case MF_TOPOLOGY_OUTPUT_NODE: - if (SUCCEEDED(topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink))) + if (output || stream) + return MF_E_INVALIDSTREAMNUMBER; + + if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink))) { hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &type_handler); IMFStreamSink_Release(stream_sink); @@ -1854,6 +1857,9 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO } break; case MF_TOPOLOGY_SOURCESTREAM_NODE: + if (!output || stream) + return MF_E_INVALIDSTREAMNUMBER; + if (FAILED(hr = IMFTopologyNode_GetUnknown(node, &MF_TOPONODE_STREAM_DESCRIPTOR, &IID_IMFStreamDescriptor, (void **)&sd))) {
On Mon Jul 4 19:24:01 2022 +0000, **** wrote:
Zebediah Figura replied on the mailing list:
On 7/4/22 14:05, Rémi Bernon wrote: > From: Rémi Bernon <rbernon@codeweavers.com> > > Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> > --- > dlls/winegstreamer/resampler.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/dlls/winegstreamer/resampler.c b/dlls/winegstreamer/resampler.c > index ea000e3b96f..5965a337f20 100644 > --- a/dlls/winegstreamer/resampler.c > +++ b/dlls/winegstreamer/resampler.c > @@ -435,7 +435,6 @@ failed: > static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) > { > struct resampler *impl = impl_from_IMFTransform(iface); > - IMFMediaType *ret; > HRESULT hr; > > TRACE("iface %p, id %#lx, type %p.\n", iface, id, type); > @@ -446,16 +445,15 @@ static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD i > if (!impl->input_type) > return MF_E_TRANSFORM_TYPE_NOT_SET; > > - if (FAILED(hr = MFCreateMediaType(&ret))) > + if (FAILED(hr = MFCreateMediaType(type))) > return hr; > > - return IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)ret); > + return IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)*type); > } Does this leak "*type" if IMFMediaType::CopyAllItems() fails? (Obviously this leak was present before, but now that I notice it...)
Thanks, I pushed a fix.
On Tue Jul 5 07:10:57 2022 +0000, Rémi Bernon wrote:
Thanks, I pushed a fix.
This could potentially use a helper to share across transforms. Also in unlikely event of CopyAllItems() failure it will return fresh freed pointer, instead of some initial value or NULL. This is just something to consider, I don't think it's critical.
This merge request was approved by Nikolay Sivov.
On Tue Jul 5 07:19:56 2022 +0000, Nikolay Sivov wrote:
This could potentially use a helper to share across transforms. Also in unlikely event of CopyAllItems() failure it will return fresh freed pointer, instead of some initial value or NULL. This is just something to consider, I don't think it's critical.
Yes, I'm starting to consider factoring the interface code across the transforms. I need to figure a way to support the various specifics they have wrt media type and sample validation.