Commit c806c4ee authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

mf: Implement SAR media type required attributes checks.

parent e5a512eb
......@@ -1499,20 +1499,57 @@ static ULONG WINAPI audio_renderer_stream_type_handler_Release(IMFMediaTypeHandl
return IMFStreamSink_Release(&renderer->IMFStreamSink_iface);
}
static HRESULT check_media_type(IMFMediaType *type, IMFMediaType *current)
{
static const GUID *required_attrs[] =
{
&MF_MT_AUDIO_SAMPLES_PER_SECOND,
&MF_MT_AUDIO_NUM_CHANNELS,
&MF_MT_AUDIO_BITS_PER_SAMPLE,
&MF_MT_AUDIO_BLOCK_ALIGNMENT,
&MF_MT_AUDIO_AVG_BYTES_PER_SECOND,
};
PROPVARIANT value;
BOOL result;
HRESULT hr;
GUID major;
int i;
if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)))
return hr;
if (!IsEqualGUID(&major, &MFMediaType_Audio))
return MF_E_INVALIDMEDIATYPE;
for (i = 0; SUCCEEDED(hr) && i < ARRAY_SIZE(required_attrs); ++i)
{
PropVariantInit(&value);
hr = IMFMediaType_GetItem(type, required_attrs[i], &value);
if (SUCCEEDED(hr))
hr = IMFMediaType_CompareItem(current, required_attrs[i], &value, &result);
if (SUCCEEDED(hr) && !result)
hr = MF_E_INVALIDMEDIATYPE;
PropVariantClear(&value);
}
if (FAILED(hr))
return MF_E_INVALIDMEDIATYPE;
return S_OK;
}
static HRESULT WINAPI audio_renderer_stream_type_handler_IsMediaTypeSupported(IMFMediaTypeHandler *iface,
IMFMediaType *in_type, IMFMediaType **out_type)
{
struct audio_renderer *renderer = impl_from_IMFMediaTypeHandler(iface);
DWORD flags;
HRESULT hr;
TRACE("%p, %p, %p.\n", iface, in_type, out_type);
EnterCriticalSection(&renderer->cs);
hr = IMFMediaType_IsEqual(renderer->media_type, in_type, &flags);
hr = check_media_type(in_type, renderer->media_type);
LeaveCriticalSection(&renderer->cs);
return hr != S_OK ? MF_E_INVALIDMEDIATYPE : hr;
return hr;
}
static HRESULT WINAPI audio_renderer_stream_type_handler_GetMediaTypeCount(IMFMediaTypeHandler *iface, DWORD *count)
......@@ -1625,10 +1662,8 @@ static HRESULT WINAPI audio_renderer_stream_type_handler_SetCurrentMediaType(IMF
IMFMediaType *media_type)
{
struct audio_renderer *renderer = impl_from_IMFMediaTypeHandler(iface);
const unsigned int test_flags = MF_MEDIATYPE_EQUAL_MAJOR_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_TYPES;
BOOL compare_result;
HRESULT hr = S_OK;
DWORD flags;
TRACE("%p, %p.\n", iface, media_type);
......@@ -1636,7 +1671,7 @@ static HRESULT WINAPI audio_renderer_stream_type_handler_SetCurrentMediaType(IMF
return E_POINTER;
EnterCriticalSection(&renderer->cs);
if (SUCCEEDED(IMFMediaType_IsEqual(renderer->media_type, media_type, &flags)) && ((flags & test_flags) == test_flags))
if (SUCCEEDED(hr = check_media_type(media_type, renderer->media_type)))
{
if (renderer->current_media_type)
IMFMediaType_Release(renderer->current_media_type);
......@@ -1745,8 +1780,6 @@ static HRESULT audio_renderer_collect_supported_types(struct audio_renderer *ren
return hr;
}
IMFMediaType_DeleteItem(renderer->media_type, &MF_MT_AUDIO_PREFER_WAVEFORMATEX);
return hr;
}
......
......@@ -4651,13 +4651,11 @@ if (SUCCEEDED(hr))
hr = MFCreateMediaType(&mediatype);
ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL);
todo_wine
ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
init_media_type(mediatype, rate == 44100 ? input_type_desc_44100 : input_type_desc_48000, 2);
for (int i = 1; i < (rate == 44100 ? ARRAY_SIZE(input_type_desc_44100) : ARRAY_SIZE(input_type_desc_48000)) - 1; ++i)
{
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL);
todo_wine
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr);
init_media_type(mediatype, rate == 44100 ? input_type_desc_44100 : input_type_desc_48000, i + 1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment