From: Ziqing Hui zhui@codeweavers.com
--- dlls/mf/tests/transform.c | 240 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 231 insertions(+), 9 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 8d01a7480a2..0e1b7fe2a97 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -202,6 +202,18 @@ static DWORD subtype_to_bpp(const GUID *subtype) return 0; }
+static DWORD subtype_to_extra_bytes(const GUID *subtype) +{ + if (IsEqualGUID(subtype, &MEDIASUBTYPE_MSAUDIO1)) + return MSAUDIO1_WFX_EXTRA_BYTES; + else if (IsEqualGUID(subtype, &MEDIASUBTYPE_WMAUDIO2)) + return WMAUDIO2_WFX_EXTRA_BYTES; + else if (IsEqualGUID(subtype, &MEDIASUBTYPE_WMAUDIO3)) + return WMAUDIO3_WFX_EXTRA_BYTES; + else + return 0; +} + static void load_resource(const WCHAR *filename, const BYTE **data, DWORD *length) { HRSRC resource = FindResourceW(NULL, filename, (const WCHAR *)RT_RCDATA); @@ -445,6 +457,33 @@ static void init_dmo_media_type_video(DMO_MEDIA_TYPE *media_type, media_type->pbFormat = (BYTE *)header; }
+static void init_dmo_media_type_audio(DMO_MEDIA_TYPE *media_type, + const GUID *subtype, UINT channel_count, UINT rate, UINT bits_per_sample) +{ + WAVEFORMATEX *format = (WAVEFORMATEX *)(media_type + 1); + DWORD extra_bytes = subtype_to_extra_bytes(subtype); + + memset(media_type, 0, sizeof(*media_type) + sizeof(*format) + extra_bytes); + + media_type->majortype = MEDIATYPE_Audio; + media_type->subtype = *subtype; + media_type->bFixedSizeSamples = TRUE; + media_type->bTemporalCompression = FALSE; + media_type->lSampleSize = 0; + media_type->formattype = FORMAT_WaveFormatEx; + media_type->pUnk = NULL; + media_type->cbFormat = sizeof(*format) + extra_bytes; + media_type->pbFormat = (BYTE *)format; + + format->wFormatTag = subtype->Data1; + format->nChannels = channel_count; + format->nSamplesPerSec = rate; + format->wBitsPerSample = bits_per_sample; + format->nBlockAlign = channel_count * bits_per_sample / 8; + format->nAvgBytesPerSec = format->nBlockAlign * rate; + format->cbSize = extra_bytes; +} + static void check_mft_optional_methods(IMFTransform *transform, DWORD output_count) { DWORD in_id, out_id, in_count, out_count, in_min, in_max, out_min, out_max; @@ -1329,15 +1368,18 @@ static void check_dmo_media_type_(int line, DMO_MEDIA_TYPE *media_type, const DM ok_(__FILE__, line)(IsEqualGUID(&media_type->subtype, &expected->subtype), "Got unexpected subtype %s, expected %s.\n", debugstr_guid(&media_type->subtype), debugstr_guid(&expected->subtype)); - ok_(__FILE__, line)(media_type->bFixedSizeSamples == expected->bFixedSizeSamples, - "Got unexpected bFixedSizeSamples %d, expected %d.\n", - media_type->bFixedSizeSamples, expected->bFixedSizeSamples); - ok_(__FILE__, line)(media_type->bTemporalCompression == expected->bTemporalCompression, - "Got unexpected bTemporalCompression %d, expected %d.\n", - media_type->bTemporalCompression, expected->bTemporalCompression); - ok_(__FILE__, line)(media_type->lSampleSize == expected->lSampleSize, - "Got unexpected lSampleSize %lu, expected %lu.\n", - media_type->lSampleSize, expected->lSampleSize); + if (IsEqualGUID(&expected->majortype, &MEDIATYPE_Video)) + { + ok_(__FILE__, line)(media_type->bFixedSizeSamples == expected->bFixedSizeSamples, + "Got unexpected bFixedSizeSamples %d, expected %d.\n", + media_type->bFixedSizeSamples, expected->bFixedSizeSamples); + ok_(__FILE__, line)(media_type->bTemporalCompression == expected->bTemporalCompression, + "Got unexpected bTemporalCompression %d, expected %d.\n", + media_type->bTemporalCompression, expected->bTemporalCompression); + ok_(__FILE__, line)(media_type->lSampleSize == expected->lSampleSize, + "Got unexpected lSampleSize %lu, expected %lu.\n", + media_type->lSampleSize, expected->lSampleSize); + } ok_(__FILE__, line)(IsEqualGUID(&media_type->formattype, &expected->formattype), "Got unexpected formattype %s.\n", debugstr_guid(&media_type->formattype)); @@ -3391,6 +3433,185 @@ failed: CoUninitialize(); }
+static void test_wma_decoder_dmo_input_type(void) +{ + const DMO_MEDIA_TYPE expected_input_types[] = + { + {MEDIATYPE_Audio, MEDIASUBTYPE_MSAUDIO1 }, + {MEDIATYPE_Audio, MEDIASUBTYPE_WMAUDIO2 }, + {MEDIATYPE_Audio, MEDIASUBTYPE_WMAUDIO3 }, + {MEDIATYPE_Audio, MEDIASUBTYPE_WMAUDIO_LOSSLESS}, + }; + + DMO_MEDIA_TYPE *good_input_type, *bad_input_type, type; + char buffer_good[1024], buffer_bad[1024]; + DWORD count, i, ret; + IMediaObject *dmo; + HRESULT hr; + + winetest_push_context("wmadec"); + + if (!has_video_processor) + { + win_skip("Skipping WMA decoder DMO tests on Win7.\n"); + winetest_pop_context(); + return; + } + + hr = CoInitialize(NULL); + ok(hr == S_OK, "CoInitialize failed, hr %#lx.\n", hr); + + if (FAILED(hr = CoCreateInstance(&CLSID_CWMADecMediaObject, NULL, CLSCTX_INPROC_SERVER, &IID_IMediaObject, (void **)&dmo))) + { + CoUninitialize(); + winetest_pop_context(); + return; + } + + good_input_type = (void *)buffer_good; + bad_input_type = (void *)buffer_bad; + + /* Test GetInputType. */ + todo_wine + { + count = ARRAY_SIZE(expected_input_types); + hr = IMediaObject_GetInputType(dmo, 1, 0, NULL); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputType(dmo, 1, 0, &type); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputType(dmo, 1, count, &type); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputType(dmo, 0, count, &type); + ok(hr == DMO_E_NO_MORE_ITEMS, "GetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputType(dmo, 0, count, NULL); + ok(hr == DMO_E_NO_MORE_ITEMS, "GetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputType(dmo, 0, 0xdeadbeef, NULL); + ok(hr == DMO_E_NO_MORE_ITEMS, "GetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputType(dmo, 0, count - 1, NULL); + ok(hr == S_OK, "GetInputType returned %#lx.\n", hr); + } + + i = -1; + while (SUCCEEDED(hr = IMediaObject_GetInputType(dmo, 0, ++i, &type))) + { + winetest_push_context("type %lu", i); + check_dmo_media_type(&type, &expected_input_types[i]); + MoFreeMediaType(&type); + winetest_pop_context(); + } + todo_wine + ok(hr == DMO_E_NO_MORE_ITEMS, "GetInputType returned %#lx.\n", hr); + todo_wine + ok(i == count, "%lu types.\n", i); + + /* Test SetInputType. */ + init_dmo_media_type_audio(good_input_type, &MEDIASUBTYPE_WMAUDIO2, 2, 22050, 32); + memset(bad_input_type, 0, sizeof(buffer_bad)); + + todo_wine + { + hr = IMediaObject_SetInputType(dmo, 1, NULL, 0); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, bad_input_type, 0); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, good_input_type, 0); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, NULL, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, bad_input_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, good_input_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, NULL, DMO_SET_TYPEF_CLEAR); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, bad_input_type, DMO_SET_TYPEF_CLEAR); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, good_input_type, DMO_SET_TYPEF_CLEAR); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, NULL, 0x4); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, bad_input_type, 0x4); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, good_input_type, 0x4); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetInputType returned %#lx.\n", hr); + + hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR | DMO_SET_TYPEF_TEST_ONLY); + ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR | 0x4); + ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, NULL, 0); + ok(hr == E_POINTER, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == E_POINTER, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, NULL, 0x4); + ok(hr == E_POINTER, "SetInputType returned %#lx.\n", hr); + + hr = IMediaObject_SetInputType(dmo, 0, bad_input_type, 0); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, bad_input_type, DMO_SET_TYPEF_CLEAR); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, bad_input_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, bad_input_type, 0x4); + ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); + + hr = IMediaObject_SetInputType(dmo, 0, good_input_type, 0); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, good_input_type, DMO_SET_TYPEF_CLEAR); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, good_input_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, good_input_type, 0x4); + ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); + } + + /* Test GetInputCurrentType. */ + hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 1, NULL); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetInputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 0, NULL); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "GetInputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 1, &type); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetInputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 0, &type); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "GetInputCurrentType returned %#lx.\n", hr); + + hr = IMediaObject_SetInputType(dmo, 0, good_input_type, 0); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 1, NULL); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetInputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 0, NULL); + todo_wine + ok(hr == E_POINTER, "GetInputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 1, &type); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetInputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetInputCurrentType(dmo, 0, &type); + todo_wine + ok(hr == S_OK, "GetInputCurrentType returned %#lx.\n", hr); + if (hr == S_OK) + { + check_dmo_media_type(&type, good_input_type); + MoFreeMediaType(&type); + } + + /* Cleanup. */ + ret = IMediaObject_Release(dmo); + ok(ret == 0, "Release returned %lu\n", ret); + CoUninitialize(); + winetest_pop_context(); +} + #define next_h264_sample(a, b) next_h264_sample_(__LINE__, a, b) static IMFSample *next_h264_sample_(int line, const BYTE **h264_buf, ULONG *h264_len) { @@ -7887,6 +8108,7 @@ START_TEST(transform) test_aac_decoder(); test_wma_encoder(); test_wma_decoder(); + test_wma_decoder_dmo_input_type(); test_h264_decoder(); test_wmv_encoder(); test_wmv_decoder();
From: Ziqing Hui zhui@codeweavers.com
--- dlls/mf/tests/transform.c | 266 +++++++++++++++++++++++++++++++++++++- 1 file changed, 263 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 0e1b7fe2a97..52f25c933b4 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -165,7 +165,7 @@ static BOOL is_compressed_subtype(const GUID *subtype) return FALSE; }
-static DWORD subtype_to_compression(const GUID *subtype) +static DWORD subtype_to_tag(const GUID *subtype) { if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB32) || IsEqualGUID(subtype, &MEDIASUBTYPE_RGB24) @@ -174,6 +174,8 @@ static DWORD subtype_to_compression(const GUID *subtype) return BI_RGB; else if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB565)) return BI_BITFIELDS; + else if (IsEqualGUID(subtype, &MEDIASUBTYPE_PCM)) + return WAVE_FORMAT_PCM; else return subtype->Data1; } @@ -444,7 +446,7 @@ static void init_dmo_media_type_video(DMO_MEDIA_TYPE *media_type, header->bmiHeader.biHeight = height; header->bmiHeader.biPlanes = 1; header->bmiHeader.biBitCount = subtype_to_bpp(subtype); - header->bmiHeader.biCompression = subtype_to_compression(subtype); + header->bmiHeader.biCompression = subtype_to_tag(subtype);
media_type->majortype = MEDIATYPE_Video; media_type->subtype = *subtype; @@ -475,7 +477,7 @@ static void init_dmo_media_type_audio(DMO_MEDIA_TYPE *media_type, media_type->cbFormat = sizeof(*format) + extra_bytes; media_type->pbFormat = (BYTE *)format;
- format->wFormatTag = subtype->Data1; + format->wFormatTag = subtype_to_tag(subtype); format->nChannels = channel_count; format->nSamplesPerSec = rate; format->wBitsPerSample = bits_per_sample; @@ -1359,6 +1361,32 @@ static void check_video_info_header_(int line, VIDEOINFOHEADER *info, const VIDE info->bmiHeader.biClrImportant, expected->bmiHeader.biClrImportant); }
+#define check_wave_format(a, b) check_wave_format_(__LINE__, a, b) +static void check_wave_format_(int line, WAVEFORMATEX *info, const WAVEFORMATEX *expected) +{ + ok_(__FILE__, line)(info->wFormatTag == expected->wFormatTag, + "Got unexpected wFormatTag %#x, expected %#x.\n", + info->wFormatTag, expected->wFormatTag); + ok_(__FILE__, line)(info->nChannels == expected->nChannels, + "Got unexpected nChannels %u, expected %u.\n", + info->nChannels, expected->nChannels); + ok_(__FILE__, line)(info->nSamplesPerSec == expected->nSamplesPerSec, + "Got unexpected nSamplesPerSec %lu, expected %lu.\n", + info->nSamplesPerSec, expected->nSamplesPerSec); + ok_(__FILE__, line)(info->nAvgBytesPerSec == expected->nAvgBytesPerSec, + "Got unexpected nAvgBytesPerSec %lu, expected %lu.\n", + info->nAvgBytesPerSec, expected->nAvgBytesPerSec); + ok_(__FILE__, line)(info->nBlockAlign == expected->nBlockAlign, + "Got unexpected nBlockAlign %u, expected %u.\n", + info->nBlockAlign, expected->nBlockAlign); + ok_(__FILE__, line)(info->wBitsPerSample == expected->wBitsPerSample, + "Got unexpected wBitsPerSample %u, expected %u.\n", + info->wBitsPerSample, expected->wBitsPerSample); + ok_(__FILE__, line)(info->cbSize == expected->cbSize, + "Got unexpected cbSize %u, expected %u.\n", + info->cbSize, expected->cbSize); +} + #define check_dmo_media_type(a, b) check_dmo_media_type_(__LINE__, a, b) static void check_dmo_media_type_(int line, DMO_MEDIA_TYPE *media_type, const DMO_MEDIA_TYPE *expected) { @@ -1398,6 +1426,9 @@ static void check_dmo_media_type_(int line, DMO_MEDIA_TYPE *media_type, const DM if (IsEqualGUID(&media_type->formattype, &FORMAT_VideoInfo) && IsEqualGUID(&expected->formattype, &FORMAT_VideoInfo)) check_video_info_header((VIDEOINFOHEADER *)media_type->pbFormat, (VIDEOINFOHEADER *)expected->pbFormat); + else if (IsEqualGUID(&media_type->formattype, &FORMAT_WaveFormatEx) + && IsEqualGUID(&expected->formattype, &FORMAT_WaveFormatEx)) + check_wave_format((WAVEFORMATEX *)media_type->pbFormat, (WAVEFORMATEX *)expected->pbFormat); } }
@@ -3612,6 +3643,234 @@ static void test_wma_decoder_dmo_input_type(void) winetest_pop_context(); }
+static void test_wma_decoder_dmo_output_type(void) +{ + const UINT channel_count = 2, rate = 22050, bits_per_sample = WMAUDIO_BITS_PER_SAMPLE; + const GUID* input_type = &MEDIASUBTYPE_WMAUDIO2; + const WAVEFORMATEX expected_output_info = + { + WAVE_FORMAT_PCM, channel_count, rate, bits_per_sample * rate * channel_count / 8, + bits_per_sample * channel_count / 8, WMAUDIO_BITS_PER_SAMPLE, 0 + }; + const DMO_MEDIA_TYPE expected_output_type = + { + MEDIATYPE_Audio, MEDIASUBTYPE_PCM, TRUE, FALSE, 0, FORMAT_WaveFormatEx, NULL, + sizeof(expected_output_info), (BYTE *)&expected_output_info + }; + + DMO_MEDIA_TYPE *good_type, *bad_type, type; + char buffer_good[1024], buffer_bad[1024]; + DWORD count, i, ret; + IMediaObject *dmo; + HRESULT hr; + + winetest_push_context("wmadec"); + + if (!has_video_processor) + { + win_skip("Skipping WMA decoder DMO tests on Win7.\n"); + winetest_pop_context(); + return; + } + + hr = CoInitialize(NULL); + ok(hr == S_OK, "CoInitialize failed, hr %#lx.\n", hr); + + if (FAILED(hr = CoCreateInstance(&CLSID_CWMADecMediaObject, NULL, CLSCTX_INPROC_SERVER, &IID_IMediaObject, (void **)&dmo))) + { + CoUninitialize(); + winetest_pop_context(); + return; + } + + good_type = (void *)buffer_good; + bad_type = (void *)buffer_bad; + + /* Test GetOutputType. */ + hr = IMediaObject_GetOutputType(dmo, 1, 0, NULL); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputType(dmo, 0, 0, NULL); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "GetOutputType returned %#lx.\n", hr); + + init_dmo_media_type_audio(good_type, input_type, channel_count, rate, 32); + hr = IMediaObject_SetInputType(dmo, 0, good_type, 0); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + + todo_wine + { + count = 1; + hr = IMediaObject_GetOutputType(dmo, 1, 0, NULL); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputType(dmo, 1, 0, &type); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputType(dmo, 1, count, &type); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputType(dmo, 0, count, &type); + ok(hr == DMO_E_NO_MORE_ITEMS, "GetOutputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputType(dmo, 0, count, NULL); + ok(hr == DMO_E_NO_MORE_ITEMS, "GetOutputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputType(dmo, 0, 0xdeadbeef, NULL); + ok(hr == DMO_E_NO_MORE_ITEMS, "GetOutputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputType(dmo, 0, count - 1, NULL); + ok(hr == S_OK, "GetOutputType returned %#lx.\n", hr); + } + + i = -1; + while (SUCCEEDED(hr = IMediaObject_GetOutputType(dmo, 0, ++i, &type))) + { + winetest_push_context("type %lu", i); + check_dmo_media_type(&type, &expected_output_type); + MoFreeMediaType(&type); + winetest_pop_context(); + } + todo_wine + ok(hr == DMO_E_NO_MORE_ITEMS, "GetInputType returned %#lx.\n", hr); + todo_wine + ok(i == count, "%lu types.\n", i); + + /* Test SetOutputType. */ + hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, NULL, 0); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, NULL, 0); + todo_wine + ok(hr == E_POINTER, "SetOutputType returned %#lx.\n", hr); + + init_dmo_media_type_audio(good_type, input_type, channel_count, rate, 32); + hr = IMediaObject_SetInputType(dmo, 0, good_type, 0); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + init_dmo_media_type_audio(good_type, &MEDIASUBTYPE_PCM, channel_count, rate, bits_per_sample); + memset(bad_type, 0, sizeof(buffer_bad)); + + todo_wine + { + hr = IMediaObject_SetOutputType(dmo, 1, NULL, 0); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, bad_type, 0); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, good_type, 0); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, NULL, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, bad_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, good_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, NULL, DMO_SET_TYPEF_CLEAR); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, bad_type, DMO_SET_TYPEF_CLEAR); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, good_type, DMO_SET_TYPEF_CLEAR); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, NULL, 0x4); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, bad_type, 0x4); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 1, good_type, 0x4); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr); + + hr = IMediaObject_SetOutputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR); + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR | DMO_SET_TYPEF_TEST_ONLY); + ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR | 0x4); + ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, NULL, 0); + ok(hr == E_POINTER, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, NULL, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == E_POINTER, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, NULL, 0x4); + ok(hr == E_POINTER, "SetOutputType returned %#lx.\n", hr); + + hr = IMediaObject_SetOutputType(dmo, 0, bad_type, 0); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, bad_type, DMO_SET_TYPEF_CLEAR); + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, bad_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, bad_type, 0x4); + ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); + + hr = IMediaObject_SetOutputType(dmo, 0, good_type, 0); + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, good_type, DMO_SET_TYPEF_CLEAR); + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, good_type, DMO_SET_TYPEF_TEST_ONLY); + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, good_type, 0x4); + ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); + } + + /* Test GetOutputCurrentType. */ + init_dmo_media_type_audio(good_type, input_type, channel_count, rate, 32); + hr = IMediaObject_SetInputType(dmo, 0, good_type, 0); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + todo_wine + { + hr = IMediaObject_GetOutputCurrentType(dmo, 1, NULL); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, NULL); + ok(hr == DMO_E_TYPE_NOT_SET, "GetOutputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 1, &type); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &type); + ok(hr == DMO_E_TYPE_NOT_SET, "GetOutputCurrentType returned %#lx.\n", hr); + } + + init_dmo_media_type_audio(good_type, &MEDIASUBTYPE_PCM, channel_count, rate, bits_per_sample); + hr = IMediaObject_SetOutputType(dmo, 0, good_type, 0); + todo_wine + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + todo_wine + { + hr = IMediaObject_GetOutputCurrentType(dmo, 1, NULL); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, NULL); + ok(hr == E_POINTER, "GetOutputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 1, &type); + ok(hr == DMO_E_INVALIDSTREAMINDEX, "GetOutputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &type); + ok(hr == S_OK, "GetOutputCurrentType returned %#lx.\n", hr); + } + if (hr == S_OK) + { + check_dmo_media_type(&type, good_type); + MoFreeMediaType(&type); + } + + hr = IMediaObject_GetInputCurrentType(dmo, 0, good_type); + todo_wine + ok(hr == S_OK, "GetInputCurrentType returned %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 0, good_type, 0); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &type); + todo_wine + ok(hr == S_OK, "GetOutputCurrentType returned %#lx.\n", hr); + + init_dmo_media_type_audio(good_type, input_type, channel_count, rate * 2, 32); + hr = IMediaObject_SetInputType(dmo, 0, good_type, 0); + todo_wine + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &type); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "GetOutputCurrentType returned %#lx.\n", hr); + + /* Cleanup. */ + ret = IMediaObject_Release(dmo); + ok(ret == 0, "Release returned %lu\n", ret); + CoUninitialize(); + winetest_pop_context(); +} + #define next_h264_sample(a, b) next_h264_sample_(__LINE__, a, b) static IMFSample *next_h264_sample_(int line, const BYTE **h264_buf, ULONG *h264_len) { @@ -8109,6 +8368,7 @@ START_TEST(transform) test_wma_encoder(); test_wma_decoder(); test_wma_decoder_dmo_input_type(); + test_wma_decoder_dmo_output_type(); test_h264_decoder(); test_wmv_encoder(); test_wmv_decoder();
Rémi Bernon (@rbernon) commented about dlls/mf/tests/transform.c:
info->nChannels, expected->nChannels);
- ok_(__FILE__, line)(info->nSamplesPerSec == expected->nSamplesPerSec,
"Got unexpected nSamplesPerSec %lu, expected %lu.\n",
info->nSamplesPerSec, expected->nSamplesPerSec);
- ok_(__FILE__, line)(info->nAvgBytesPerSec == expected->nAvgBytesPerSec,
"Got unexpected nAvgBytesPerSec %lu, expected %lu.\n",
info->nAvgBytesPerSec, expected->nAvgBytesPerSec);
- ok_(__FILE__, line)(info->nBlockAlign == expected->nBlockAlign,
"Got unexpected nBlockAlign %u, expected %u.\n",
info->nBlockAlign, expected->nBlockAlign);
- ok_(__FILE__, line)(info->wBitsPerSample == expected->wBitsPerSample,
"Got unexpected wBitsPerSample %u, expected %u.\n",
info->wBitsPerSample, expected->wBitsPerSample);
- ok_(__FILE__, line)(info->cbSize == expected->cbSize,
"Got unexpected cbSize %u, expected %u.\n",
info->cbSize, expected->cbSize);
I don't mind if you want to keep it like this, but FWIW I like check_member macro to save typing the field names and the test messages.
Rémi Bernon (@rbernon) commented about dlls/mf/tests/transform.c:
- }
- todo_wine
- ok(hr == DMO_E_NO_MORE_ITEMS, "GetInputType returned %#lx.\n", hr);
- todo_wine
- ok(i == count, "%lu types.\n", i);
- /* Test SetOutputType. */
- hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR);
- todo_wine
- ok(hr == S_OK, "SetInputType returned %#lx.\n", hr);
- hr = IMediaObject_SetOutputType(dmo, 1, NULL, 0);
- todo_wine
- ok(hr == DMO_E_INVALIDSTREAMINDEX, "SetOutputType returned %#lx.\n", hr);
- hr = IMediaObject_SetOutputType(dmo, 0, NULL, 0);
- todo_wine
- ok(hr == E_POINTER, "SetOutputType returned %#lx.\n", hr);
Probably you could also check if `IMediaObject_SetOutputType` with a valid type requires an input type to be set.
Rémi Bernon (@rbernon) commented about dlls/mf/tests/transform.c:
- };
- DMO_MEDIA_TYPE *good_type, *bad_type, type;
- char buffer_good[1024], buffer_bad[1024];
- DWORD count, i, ret;
- IMediaObject *dmo;
- HRESULT hr;
- winetest_push_context("wmadec");
- if (!has_video_processor)
- {
win_skip("Skipping WMA decoder DMO tests on Win7.\n");
winetest_pop_context();
return;
- }
Is this really required? They don't seem to be failing on W7. Same for input type tests.