Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/mfreadwrite/tests/mfplat.c | 222 ++++++++++++++++++++++++++
dlls/mfreadwrite/tests/resource.rc | 4 +
dlls/mfreadwrite/tests/test-48000.wav | Bin 0 -> 2104 bytes
3 files changed, 226 insertions(+)
create mode 100644 dlls/mfreadwrite/tests/test-48000.wav
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c
index e3ff7f6e7aa..8c2aab6714d 100644
--- a/dlls/mfreadwrite/tests/mfplat.c
+++ b/dlls/mfreadwrite/tests/mfplat.c
@@ -1230,6 +1230,227 @@ done:
DestroyWindow(window);
}
+struct audio_format
+{
+ GUID subtype;
+ UINT32 bits;
+ UINT32 rate;
+};
+
+static void test_audio_media_type(const char *resource_name, IMFMediaType *media_type, struct audio_format *expect)
+{
+ UINT32 uint32_value, buffer_value_size;
+ BYTE buffer_value[512];
+ double double_value;
+ GUID guid_value;
+ HRESULT hr;
+
+ memset(&guid_value, 0xcd, sizeof(guid_value));
+ hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid_value);
+ ok(hr == S_OK, "missing MF_MT_MAJOR_TYPE, hr %#x\n", hr);
+ ok(IsEqualGUID(&guid_value, &MFMediaType_Audio), "got MF_MT_MAJOR_TYPE %s\n", debugstr_guid(&guid_value));
+
+ memset(&guid_value, 0xcd, sizeof(guid_value));
+ hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid_value);
+ ok(hr == S_OK, "missing MF_MT_SUBTYPE, hr %#x\n", hr);
+ ok(IsEqualGUID(&guid_value, &expect->subtype), "got MF_MT_SUBTYPE %s\n", debugstr_guid(&guid_value));
+
+ uint32_value = 0xdeadbeef;
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &uint32_value);
+ ok(hr == S_OK, "missing MF_MT_ALL_SAMPLES_INDEPENDENT, hr %#x\n", hr);
+ ok(uint32_value == 1, "got MF_MT_ALL_SAMPLES_INDEPENDENT %u\n", uint32_value);
+
+ hr = IMFMediaType_GetGUID(media_type, &MF_MT_AM_FORMAT_TYPE, &guid_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AM_FORMAT_TYPE, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_COMPRESSED, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_COMPRESSED, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_FIXED_SIZE_SAMPLES, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_SAMPLE_SIZE, hr %#x\n", hr);
+ hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, buffer_value, sizeof(buffer_value), &buffer_value_size);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_USER_DATA, hr %#x\n", hr);
+ hr = IMFMediaType_GetBlob(media_type, &MF_MT_WRAPPED_TYPE, buffer_value, sizeof(buffer_value), &buffer_value_size);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_WRAPPED_TYPE, hr %#x\n", hr);
+
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AAC_PAYLOAD_TYPE, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AAC_PAYLOAD_TYPE, hr %#x\n", hr);
+
+ uint32_value = 0xdeadbeef;
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &uint32_value);
+ todo_wine
+ ok(hr == S_OK, "missing MF_MT_AUDIO_AVG_BYTES_PER_SECOND, hr %#x\n", hr);
+ todo_wine
+ ok(uint32_value == expect->rate * expect->bits / 8, "got MF_MT_AUDIO_AVG_BYTES_PER_SECOND %u\n", uint32_value);
+
+ uint32_value = 0xdeadbeef;
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &uint32_value);
+ ok(hr == S_OK, "missing MF_MT_AUDIO_BITS_PER_SAMPLE, hr %#x\n", hr);
+ ok(uint32_value == expect->bits, "got MF_MT_AUDIO_BITS_PER_SAMPLE %u\n", uint32_value);
+
+ uint32_value = 0xdeadbeef;
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &uint32_value);
+ todo_wine
+ ok(hr == S_OK, "missing MF_MT_AUDIO_BLOCK_ALIGNMENT, hr %#x\n", hr);
+ todo_wine
+ ok(uint32_value == expect->bits / 8, "got MF_MT_AUDIO_BLOCK_ALIGNMENT %u\n", uint32_value);
+
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_CHANNEL_MASK, &uint32_value);
+ todo_wine
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_CHANNEL_MASK, hr %#x\n", hr);
+ hr = IMFMediaType_GetDouble(media_type, &MF_MT_AUDIO_FLOAT_SAMPLES_PER_SECOND, &double_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_FLOAT_SAMPLES_PER_SECOND, hr %#x\n", hr);
+ hr = IMFMediaType_GetBlob(media_type, &MF_MT_AUDIO_FOLDDOWN_MATRIX, buffer_value, sizeof(buffer_value), &buffer_value_size);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_FOLDDOWN_MATRIX, hr %#x\n", hr);
+
+ uint32_value = 0xdeadbeef;
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, &uint32_value);
+ ok(hr == S_OK, "missing MF_MT_AUDIO_NUM_CHANNELS, hr %#x\n", hr);
+ ok(uint32_value == 1, "got MF_MT_AUDIO_NUM_CHANNELS %u\n", uint32_value);
+
+ uint32_value = 0xdeadbeef;
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, &uint32_value);
+ todo_wine
+ ok(hr == S_OK, "missing MF_MT_AUDIO_PREFER_WAVEFORMATEX, hr %#x\n", hr);
+ todo_wine
+ ok(uint32_value == 1, "got MF_MT_AUDIO_PREFER_WAVEFORMATEX %u\n", uint32_value);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_BLOCK, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_SAMPLES_PER_BLOCK, hr %#x\n", hr);
+
+ uint32_value = 0xdeadbeef;
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &uint32_value);
+ ok(hr == S_OK, "missing MF_MT_AUDIO_SAMPLES_PER_SECOND, hr %#x\n", hr);
+ ok(uint32_value == expect->rate, "got MF_MT_AUDIO_SAMPLES_PER_SECOND %u\n", uint32_value);
+
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_WMADRC_AVGREF, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_WMADRC_AVGREF, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_WMADRC_AVGTARGET, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_WMADRC_AVGTARGET, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_WMADRC_PEAKREF, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_WMADRC_PEAKREF, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_WMADRC_PEAKTARGET, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_AUDIO_WMADRC_PEAKTARGET, hr %#x\n", hr);
+ hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ORIGINAL_WAVE_FORMAT_TAG, &uint32_value);
+ ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_ORIGINAL_WAVE_FORMAT_TAG, hr %#x\n", hr);
+}
+
+struct test_media_types_params
+{
+ const char *resource;
+ BOOL has_audio;
+ struct audio_format audio_format;
+};
+
+static void test_media_types(void)
+{
+ struct test_media_types_params tests[] =
+ {
+ {.resource = "test.wav", .has_audio = TRUE, .audio_format =
+ {.subtype = MFAudioFormat_PCM, .bits = 8, .rate = 44100}
+ },
+ {.resource = "test-48000.wav", .has_audio = TRUE, .audio_format =
+ {.subtype = MFAudioFormat_PCM, .bits = 16, .rate = 48000}
+ },
+ };
+
+ struct audio_format test_audio_formats[] =
+ {
+ {.subtype = MFAudioFormat_PCM, .bits = 8, .rate = 44100},
+ {.subtype = MFAudioFormat_Float, .bits = 32, .rate = 44100},
+ {.subtype = MFAudioFormat_PCM, .bits = 8, .rate = 48000},
+ {.subtype = MFAudioFormat_Float, .bits = 32, .rate = 48000},
+ };
+
+ int i, j, old_mute_threshold;
+ IMFMediaType *media_type;
+ IMFSourceReader *reader;
+ IMFByteStream *stream;
+ HRESULT hr;
+
+ if (!pMFCreateMFByteStreamOnStream)
+ {
+ win_skip("MFCreateMFByteStreamOnStream() not found\n");
+ return;
+ }
+
+ /* FIXME: remove this when enough todo_wine are fixed */
+ old_mute_threshold = winetest_mute_threshold;
+ winetest_mute_threshold = 1;
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ winetest_push_context(tests[i].resource);
+
+ for (j = 0; tests[i].has_audio && j < ARRAY_SIZE(test_audio_formats); ++j)
+ {
+ stream = get_resource_stream(tests[i].resource);
+ if (FAILED(hr = MFCreateSourceReaderFromByteStream(stream, NULL, &reader)))
+ {
+ todo_wine
+ win_skip("MFCreateSourceReaderFromByteStream() failed\n");
+ IMFByteStream_Release(stream);
+ continue;
+ }
+ ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_GetNativeMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, &media_type);
+ ok(hr == S_OK, "Failed to get native mediatype, hr %#x.\n", hr);
+ winetest_push_context("native audio");
+ test_audio_media_type(tests[i].resource, media_type, &tests[i].audio_format);
+ IMFMediaType_Release(media_type);
+ winetest_pop_context();
+
+ hr = IMFSourceReader_GetNativeMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 1, &media_type);
+ todo_wine
+ ok(hr == MF_E_NO_MORE_TYPES, "Expected only one native mediatype, hr %#x.\n", hr);
+ if (hr == S_OK) IMFMediaType_Release(media_type);
+
+ hr = IMFSourceReader_SetStreamSelection(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = MFCreateMediaType(&media_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &test_audio_formats[j].subtype);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, test_audio_formats[j].bits);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, test_audio_formats[j].rate);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, test_audio_formats[j].bits / 8);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, test_audio_formats[j].rate * test_audio_formats[j].bits / 8);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+
+ hr = IMFSourceReader_SetCurrentMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, NULL, media_type);
+ todo_wine
+ ok(hr == S_OK || broken(hr == MF_E_TOPO_CODEC_NOT_FOUND) /* <= win7 */, "Failed setting current media type %u, hr %#x.\n", j, hr);
+ IMFMediaType_Release(media_type);
+ if (hr != S_OK) continue;
+
+ hr = IMFSourceReader_GetCurrentMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, &media_type);
+ ok(hr == S_OK, "Failed to get current mediatype, hr %#x.\n", hr);
+ winetest_push_context("current audio %u", j);
+ test_audio_media_type(tests[i].resource, media_type, &test_audio_formats[j]);
+ winetest_pop_context();
+ IMFMediaType_Release(media_type);
+
+ IMFSourceReader_Release(reader);
+ IMFByteStream_Release(stream);
+ }
+
+ winetest_pop_context();
+ }
+
+ winetest_mute_threshold = old_mute_threshold;
+}
+
START_TEST(mfplat)
{
HRESULT hr;
@@ -1242,6 +1463,7 @@ START_TEST(mfplat)
test_factory();
test_source_reader();
test_source_reader_from_media_source();
+ test_media_types();
test_reader_d3d9();
hr = MFShutdown();
diff --git a/dlls/mfreadwrite/tests/resource.rc b/dlls/mfreadwrite/tests/resource.rc
index f54212a8c8f..5b3269fef1d 100644
--- a/dlls/mfreadwrite/tests/resource.rc
+++ b/dlls/mfreadwrite/tests/resource.rc
@@ -20,3 +20,7 @@
/* @makedep: test.wav */
test.wav RCDATA test.wav
+
+/* @makedep: test-48000.wav */
+test-48000.wav RCDATA test-48000.wav
+
diff --git a/dlls/mfreadwrite/tests/test-48000.wav b/dlls/mfreadwrite/tests/test-48000.wav
new file mode 100644
index 0000000000000000000000000000000000000000..dedd660bb9a97a9cacedabaddc1b1bafd2f4a176
GIT binary patch
literal 2104
zcmV-82*>wQNk&F62mk<AK~_a(ZFC?I000010097iy8r+HcL4wb01yCVVRT^t2mk=&
z1;h)Q5n&e<9j_uRD2FY(GQ>BYJVimYMdwM}O^;FiR3ljZT8mxDU$$XSW0houWgli@
zW=>|~Wg=w@WS?T-V9s7_T)SDmR(DhBPZ&%FNVh{SKX5vLHDfRwE3qXeAb=Xf6!i`o
z2{!{${crb^@x$u{=3L;;+F;cd(Dljz#y-KYyj-|Mv~952tc<CMrqH8ip-rELof4e$
znk$;PnVgx}nQEF+n~<C$o(G^lqQs<_r?;veuFJ8ywdlE0zVpJ#$Ii_D(N@>c+-Tw%
z=-%zK^ON~^|62t-3lkCC7Lgn-BCaP4EkrU=H!nQfKu<-8NrO#1QLt3pSH4<PU6@~t
zVJ>5PWOHQ{W?yDgX7Ob=Whi9CVhmvcU#49ASq4|eQ$J92OlL?QM4CU~I`uW&Fqtbc
zCaE9=8%h;@526Xc1Kj=i_Z#v`?1|>z;7;4!)sWC@%W}r6!5F>1xS_Peuqmz8smrDe
zq?@67pRAoQoC=#cn!lNwna`P7nmL<qocf*Dp9i9bq*JGBs?4o&v0Sx;x#_)y!dAyu
z%!JX{)=%8!;gsiB?JM&N`R@MG1hfi_5LOlq9IPQPCy*@6G2J%6J8(eiL?}rqP3TZ#
zRF+qMS{hwuUt(bkV_;-pWeH|nW>{wZWlUv6Waw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