winegstreamer: Implement WMA decoder SetOutputType.

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>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-02-02 13:28:18 +01:00 committed by Alexandre Julliard
parent 22472a3feb
commit 1541d6b6d8
2 changed files with 75 additions and 8 deletions

View File

@ -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);

View File

@ -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)