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

mf/tests: Add required SAR media type attributes tests.

parent c86955d3
...@@ -4434,6 +4434,29 @@ static void check_sar_rate_support(IMFMediaSink *sink) ...@@ -4434,6 +4434,29 @@ static void check_sar_rate_support(IMFMediaSink *sink)
static void test_sar(void) static void test_sar(void)
{ {
static const struct attribute_desc input_type_desc_48000[] =
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio),
ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float),
ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 48000),
ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2),
ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32),
ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 8),
ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 8 * 48000),
{0},
};
static const struct attribute_desc input_type_desc_44100[] =
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio),
ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float),
ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100),
ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2),
ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32),
ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 8),
ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 8 * 44100),
{0},
};
IMFPresentationClock *present_clock, *present_clock2; IMFPresentationClock *present_clock, *present_clock2;
IMFMediaType *mediatype, *mediatype2, *mediatype3; IMFMediaType *mediatype, *mediatype2, *mediatype3;
IMFClockStateSink *state_sink, *state_sink2; IMFClockStateSink *state_sink, *state_sink2;
...@@ -4443,17 +4466,16 @@ static void test_sar(void) ...@@ -4443,17 +4466,16 @@ static void test_sar(void)
IMFAudioStreamVolume *stream_volume; IMFAudioStreamVolume *stream_volume;
IMFMediaSink *sink, *sink2; IMFMediaSink *sink, *sink2;
IMFStreamSink *stream_sink; IMFStreamSink *stream_sink;
UINT32 channel_count, rate;
IMFAttributes *attributes; IMFAttributes *attributes;
DWORD i, id, flags, count; DWORD id, flags, count;
IMFActivate *activate; IMFActivate *activate;
UINT32 channel_count;
MFCLOCK_STATE state; MFCLOCK_STATE state;
IMFClock *clock; IMFClock *clock;
IUnknown *unk; IUnknown *unk;
HRESULT hr; HRESULT hr;
GUID guid; GUID guid;
BOOL mute; BOOL mute;
int found;
LONG ref; LONG ref;
hr = CoInitialize(NULL); hr = CoInitialize(NULL);
...@@ -4613,21 +4635,40 @@ if (SUCCEEDED(hr)) ...@@ -4613,21 +4635,40 @@ if (SUCCEEDED(hr))
ok(hr == S_OK, "Failed to get type count, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to get type count, hr %#lx.\n", hr);
ok(!!count, "Unexpected type count %lu.\n", count); ok(!!count, "Unexpected type count %lu.\n", count);
/* A number of same major/subtype entries are returned, with different degrees of finer format hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count, &mediatype);
details. Some incomplete types are not accepted, check that at least one of them is considered supported. */ todo_wine
ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr);
for (i = 0, found = -1; i < count; ++i)
{
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, i, &mediatype);
ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr);
if (SUCCEEDED(IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL))) hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &mediatype);
found = i; ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &rate);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(rate == 48000 || rate == 44100, "got rate %u.\n", rate);
IMFMediaType_Release(mediatype); IMFMediaType_Release(mediatype);
if (found != -1) break;
/* check required output media type attributes */
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);
} }
ok(found != -1, "Haven't found a supported type.\n"); hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
init_media_type(mediatype, rate == 44100 ? input_type_desc_44100 : input_type_desc_48000, -1);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IMFMediaType_Release(mediatype);
hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype); hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype);
ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
...@@ -4652,10 +4693,9 @@ if (SUCCEEDED(hr)) ...@@ -4652,10 +4693,9 @@ if (SUCCEEDED(hr))
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype); hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype);
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr); ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, found, &mediatype2); hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count - 1, &mediatype2);
ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count - 1, &mediatype3);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, found, &mediatype3);
ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr);
ok(mediatype2 == mediatype3, "Unexpected instance.\n"); ok(mediatype2 == mediatype3, "Unexpected instance.\n");
IMFMediaType_Release(mediatype3); IMFMediaType_Release(mediatype3);
......
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