Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mf/tests/mf.c | 6 --- dlls/winegstreamer/wma_decoder.c | 77 +++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 8 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 683de3e5b3e..96d8b972de7 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5779,7 +5779,6 @@ static void test_wma_decoder(void) ok(hr == S_OK, "MFCreateMediaType returned %#x\n", hr); init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "SetOutputType returned %#x.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %u\n", ret); @@ -5832,22 +5831,18 @@ static void test_wma_decoder(void) hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#x\n", hr); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#x.\n", hr); init_media_type(media_type, output_type_desc, 1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#x.\n", hr); init_media_type(media_type, output_type_desc, 2); for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) { hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#x.\n", hr); init_media_type(media_type, output_type_desc, i + 1); } hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetOutputType returned %#x.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %u\n", ret); @@ -5894,7 +5889,6 @@ static void test_wma_decoder(void)
init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetInputType returned %#x.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %u\n", ret); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index a99df59e8a0..4fae787679d 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -52,6 +52,7 @@ struct wma_decoder IUnknown *outer; LONG refcount; IMFMediaType *input_type; + IMFMediaType *output_type; };
static inline struct wma_decoder *impl_from_IUnknown(IUnknown *iface) @@ -105,6 +106,8 @@ static ULONG WINAPI unknown_Release(IUnknown *iface) { if (decoder->input_type) IMFMediaType_Release(decoder->input_type); + if (decoder->output_type) + IMFMediaType_Release(decoder->output_type); free(decoder); }
@@ -324,6 +327,12 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM if (!decoder->input_type && FAILED(hr = MFCreateMediaType(&decoder->input_type))) return hr;
+ if (decoder->output_type) + { + IMFMediaType_Release(decoder->output_type); + decoder->output_type = NULL; + } + if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->input_type))) { IMFMediaType_Release(decoder->input_type); @@ -335,8 +344,72 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) { - FIXME("iface %p, id %u, type %p, flags %#x stub!\n", iface, id, type, flags); - return E_NOTIMPL; + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + MF_ATTRIBUTE_TYPE item_type; + ULONG i, sample_size; + GUID major, subtype; + HRESULT hr; + + TRACE("iface %p, id %u, type %p, flags %#x.\n", iface, id, type, flags); + + if (!decoder->input_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) || + FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) + return hr; + + if (!IsEqualGUID(&major, &MFMediaType_Audio)) + return MF_E_INVALIDMEDIATYPE; + + for (i = 0; i < ARRAY_SIZE(wma_decoder_output_types); ++i) + if (IsEqualGUID(&subtype, wma_decoder_output_types[i])) + break; + if (i == ARRAY_SIZE(wma_decoder_output_types)) + return MF_E_INVALIDMEDIATYPE; + + if (IsEqualGUID(&subtype, &MFAudioFormat_Float)) + sample_size = 32; + else if (IsEqualGUID(&subtype, &MFAudioFormat_PCM)) + sample_size = 16; + else + { + FIXME("Subtype %s not implemented!\n", debugstr_guid(&subtype)); + hr = E_NOTIMPL; + return hr; + } + + if (FAILED(IMFMediaType_SetUINT32(decoder->input_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, sample_size))) + return MF_E_INVALIDMEDIATYPE; + + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_NUM_CHANNELS, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) || + item_type != MF_ATTRIBUTE_UINT32) + return MF_E_INVALIDMEDIATYPE; + + if (!decoder->output_type && FAILED(hr = MFCreateMediaType(&decoder->output_type))) + return hr; + + if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->output_type))) + goto failed; + + return S_OK; + +failed: + IMFMediaType_Release(decoder->output_type); + decoder->output_type = NULL; + return hr; }
static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)