From: R��mi Bernon rbernon@codeweavers.com
--- dlls/mf/tests/mf.c | 2255 ++++++++++++++++++------------- dlls/mf/tests/resource.rc | 4 + dlls/mf/tests/rgb32frame-vp.bin | Bin 0 -> 36864 bytes 3 files changed, 1343 insertions(+), 916 deletions(-) create mode 100644 dlls/mf/tests/rgb32frame-vp.bin
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 6621a0f0674..96d37e0a6b9 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -3829,1002 +3829,619 @@ static BOOL is_supported_video_type(const GUID *guid) || IsEqualGUID(guid, &MFVideoFormat_ABGR32); }
-static void test_video_processor(void) +static void test_quality_manager(void) { - const GUID transform_inputs[22] = - { - MFVideoFormat_IYUV, - MFVideoFormat_YV12, - MFVideoFormat_NV12, - MFVideoFormat_YUY2, - MFVideoFormat_ARGB32, - MFVideoFormat_RGB32, - MFVideoFormat_NV11, - MFVideoFormat_AYUV, - MFVideoFormat_UYVY, - MEDIASUBTYPE_P208, - MFVideoFormat_RGB24, - MFVideoFormat_RGB555, - MFVideoFormat_RGB565, - MFVideoFormat_RGB8, - MFVideoFormat_I420, - MFVideoFormat_Y216, - MFVideoFormat_v410, - MFVideoFormat_Y41P, - MFVideoFormat_Y41T, - MFVideoFormat_Y42T, - MFVideoFormat_YVYU, - MFVideoFormat_420O, - }; - const GUID transform_outputs[21] = - { - MFVideoFormat_IYUV, - MFVideoFormat_YV12, - MFVideoFormat_NV12, - MFVideoFormat_YUY2, - MFVideoFormat_ARGB32, - MFVideoFormat_RGB32, - MFVideoFormat_NV11, - MFVideoFormat_AYUV, - MFVideoFormat_UYVY, - MEDIASUBTYPE_P208, - MFVideoFormat_RGB24, - MFVideoFormat_RGB555, - MFVideoFormat_RGB565, - MFVideoFormat_RGB8, - MFVideoFormat_I420, - MFVideoFormat_Y216, - MFVideoFormat_v410, - MFVideoFormat_Y41P, - MFVideoFormat_Y41T, - MFVideoFormat_Y42T, - MFVideoFormat_YVYU, - }; - MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; - MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_I420}; - DWORD input_count, output_count, input_id, output_id, flags; - DWORD input_min, input_max, output_min, output_max, i; - IMFAttributes *attributes, *attributes2; - IMFMediaType *media_type, *media_type2; - MFT_OUTPUT_DATA_BUFFER output_buffer; - MFT_OUTPUT_STREAM_INFO output_info; - MFT_INPUT_STREAM_INFO input_info; - IMFSample *sample, *sample2; - IMFTransform *transform; - IMFMediaBuffer *buffer; - IMFMediaEvent *event; - unsigned int value; - GUID class_id; - UINT32 count; + IMFPresentationClock *clock; + IMFQualityManager *manager; + IMFTopology *topology; HRESULT hr; - GUID guid; LONG ref;
- hr = CoInitialize(NULL); - ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr); + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr);
- if (!create_transform(MFT_CATEGORY_VIDEO_PROCESSOR, &input_type, &output_type, L"Microsoft Video Processor MFT", &MFMediaType_Video, - transform_inputs, ARRAY_SIZE(transform_inputs), transform_outputs, ARRAY_SIZE(transform_outputs), - &transform, &CLSID_VideoProcessorMFT, &class_id)) - goto failed; - has_video_processor = TRUE; + hr = MFCreatePresentationClock(&clock); + ok(hr == S_OK, "Failed to create presentation clock, hr %#lx.\n", hr);
- todo_wine - check_interface(transform, &IID_IMFVideoProcessorControl, TRUE); - todo_wine - check_interface(transform, &IID_IMFRealTimeClientEx, TRUE); - check_interface(transform, &IID_IMFMediaEventGenerator, FALSE); - check_interface(transform, &IID_IMFShutdown, FALSE); + hr = MFCreateStandardQualityManager(&manager); + ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr);
- /* Transform global attributes. */ - hr = IMFTransform_GetAttributes(transform, &attributes); - ok(hr == S_OK, "Failed to get attributes, hr %#lx.\n", hr); + check_interface(manager, &IID_IMFQualityManager, TRUE); + check_interface(manager, &IID_IMFClockStateSink, TRUE);
- hr = IMFAttributes_GetCount(attributes, &count); + hr = IMFQualityManager_NotifyPresentationClock(manager, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + hr = IMFQualityManager_NotifyTopology(manager, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine - ok(!!count, "Unexpected attribute count %u.\n", count);
- value = 0; - hr = IMFAttributes_GetUINT32(attributes, &MF_SA_D3D11_AWARE, &value); -todo_wine { + /* Set clock, then shutdown. */ + EXPECT_REF(clock, 1); + EXPECT_REF(manager, 1); + hr = IMFQualityManager_NotifyPresentationClock(manager, clock); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value == 1, "Unexpected attribute value %u.\n", value); -} - hr = IMFTransform_GetAttributes(transform, &attributes2); - ok(hr == S_OK, "Failed to get attributes, hr %#lx.\n", hr); - ok(attributes == attributes2, "Unexpected instance.\n"); - IMFAttributes_Release(attributes); - IMFAttributes_Release(attributes2); + EXPECT_REF(clock, 2); + EXPECT_REF(manager, 2);
- hr = IMFTransform_GetStreamLimits(transform, &input_min, &input_max, &output_min, &output_max); - ok(hr == S_OK, "Failed to get stream limits, hr %#lx.\n", hr); - ok(input_min == input_max && input_min == 1 && output_min == output_max && output_min == 1, - "Unexpected stream limits.\n"); + hr = IMFQualityManager_Shutdown(manager); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(clock, 1);
- hr = IMFTransform_GetStreamCount(transform, &input_count, &output_count); - ok(hr == S_OK, "Failed to get stream count, hr %#lx.\n", hr); - ok(input_count == 1 && output_count == 1, "Unexpected stream count %lu, %lu.\n", input_count, output_count); + hr = IMFQualityManager_NotifyPresentationClock(manager, clock); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_GetStreamIDs(transform, 1, &input_id, 1, &output_id); - ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + hr = IMFQualityManager_NotifyTopology(manager, NULL); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- input_id = 100; - hr = IMFTransform_AddInputStreams(transform, 1, &input_id); - ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + hr = IMFQualityManager_NotifyPresentationClock(manager, NULL); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_DeleteInputStream(transform, 0); - ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + hr = IMFQualityManager_Shutdown(manager); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_GetInputStatus(transform, 0, &flags); - todo_wine - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + ref = IMFQualityManager_Release(manager); + ok(ref == 0, "Release returned %ld\n", ref);
- hr = IMFTransform_GetInputStreamAttributes(transform, 0, &attributes); - ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + hr = MFCreateStandardQualityManager(&manager); + ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr);
- hr = IMFTransform_GetOutputStatus(transform, &flags); - todo_wine - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(clock, 1); + EXPECT_REF(manager, 1); + hr = IMFQualityManager_NotifyPresentationClock(manager, clock); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(manager, 2); + EXPECT_REF(clock, 2); + hr = IMFQualityManager_Shutdown(manager); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_GetOutputStreamAttributes(transform, 0, &attributes); - ok(hr == S_OK, "Failed to get output attributes, hr %#lx.\n", hr); - hr = IMFTransform_GetOutputStreamAttributes(transform, 0, &attributes2); - ok(hr == S_OK, "Failed to get output attributes, hr %#lx.\n", hr); - ok(attributes == attributes2, "Unexpected instance.\n"); - IMFAttributes_Release(attributes); - IMFAttributes_Release(attributes2); + ref = IMFQualityManager_Release(manager); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFPresentationClock_Release(clock); + ok(ref == 0, "Release returned %ld\n", ref);
- hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); - todo_wine - ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr); + /* Set topology. */ + hr = MFCreateStandardQualityManager(&manager); + ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr);
- hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type); - todo_wine - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + hr = MFCreateTopology(&topology); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_GetInputCurrentType(transform, 1, &media_type); - todo_wine - ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(topology, 1); + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(topology, 2);
- hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type); - todo_wine - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + hr = IMFQualityManager_NotifyTopology(manager, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(topology, 1);
- hr = IMFTransform_GetOutputCurrentType(transform, 1, &media_type); - todo_wine - ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_GetInputStreamInfo(transform, 1, &input_info); - todo_wine - ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(topology, 2); + hr = IMFQualityManager_Shutdown(manager); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(topology, 1);
- memset(&input_info, 0xcc, sizeof(input_info)); - hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); -todo_wine { - ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); - ok(input_info.dwFlags == 0, "Unexpected flag %#lx.\n", input_info.dwFlags); - ok(input_info.cbSize == 0, "Unexpected size %lu.\n", input_info.cbSize); - ok(input_info.cbMaxLookahead == 0, "Unexpected lookahead length %lu.\n", input_info.cbMaxLookahead); - ok(input_info.cbAlignment == 0, "Unexpected alignment %lu.\n", input_info.cbAlignment); -} - hr = MFCreateMediaEvent(MEUnknown, &GUID_NULL, S_OK, NULL, &event); - ok(hr == S_OK, "Failed to create event object, hr %#lx.\n", hr); - hr = IMFTransform_ProcessEvent(transform, 0, event); - ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); - hr = IMFTransform_ProcessEvent(transform, 1, event); - ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); - ref = IMFMediaEvent_Release(event); + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); + + ref = IMFQualityManager_Release(manager); ok(ref == 0, "Release returned %ld\n", ref);
- /* Configure stream types. */ - for (i = 0;;++i) - { - if (FAILED(hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type))) - { - todo_wine - ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr); - break; - } + hr = MFCreateStandardQualityManager(&manager); + ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr);
- hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type2); - ok(hr == S_OK, "Failed to get available type, hr %#lx.\n", hr); - ok(media_type != media_type2, "Unexpected instance.\n"); - ref = IMFMediaType_Release(media_type2); - ok(ref == 0, "Release returned %ld\n", ref); + EXPECT_REF(topology, 1); + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + EXPECT_REF(topology, 2);
- hr = IMFMediaType_GetMajorType(media_type, &guid); - ok(hr == S_OK, "Failed to get major type, hr %#lx.\n", hr); - ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected major type.\n"); + ref = IMFQualityManager_Release(manager); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFTopology_Release(topology); + ok(ref == 0, "Release returned %ld\n", ref);
- hr = IMFMediaType_GetCount(media_type, &count); - ok(hr == S_OK, "Failed to get attributes count, hr %#lx.\n", hr); - ok(count == 2, "Unexpected count %u.\n", count); - - hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); - ok(hr == S_OK, "Failed to get subtype, hr %#lx.\n", hr); - ok(is_supported_video_type(&guid), "Unexpected media type %s.\n", wine_dbgstr_guid(&guid)); + hr = MFShutdown(); + ok(hr == S_OK, "Shutdown failure, hr %#lx.\n", hr); +}
- hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); - ok(FAILED(hr), "Unexpected hr %#lx.\n", hr); +static void check_sar_rate_support(IMFMediaSink *sink) +{ + IMFRateSupport *rate_support; + IMFMediaTypeHandler *handler; + IMFStreamSink *stream_sink; + IMFMediaType *media_type; + HRESULT hr; + float rate;
- hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(FAILED(hr), "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSink_QueryInterface(sink, &IID_IMFRateSupport, (void **)&rate_support); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (FAILED(hr)) return;
- hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type2); - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink); + if (hr == MF_E_SHUTDOWN) + { + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
- /* FIXME: figure out if those require additional attributes or simply advertised but not supported */ - if (IsEqualGUID(&guid, &MFVideoFormat_L8) || IsEqualGUID(&guid, &MFVideoFormat_L16) - || IsEqualGUID(&guid, &MFVideoFormat_D16) || IsEqualGUID(&guid, &MFVideoFormat_420O) - || IsEqualGUID(&guid, &MFVideoFormat_A16B16G16R16F)) - { - ref = IMFMediaType_Release(media_type); - ok(ref == 0, "Release returned %ld\n", ref); - continue; - } + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, ((UINT64)16 << 32) | 16); - ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); - ok(hr == S_OK, "Failed to test input type %s, hr %#lx.\n", wine_dbgstr_guid(&guid), hr); + IMFRateSupport_Release(rate_support); + return; + } + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == S_OK, "Failed to test input type, hr %#lx.\n", hr); + hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &handler); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type2); - ok(hr == S_OK, "Failed to get current type, hr %#lx.\n", hr); - ok(media_type != media_type2, "Unexpected instance.\n"); - IMFMediaType_Release(media_type2); + IMFStreamSink_Release(stream_sink);
- hr = IMFTransform_GetInputStatus(transform, 0, &flags); - ok(hr == S_OK, "Failed to get input status, hr %#lx.\n", hr); - ok(flags == MFT_INPUT_STATUS_ACCEPT_DATA, "Unexpected input status %#lx.\n", flags); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); - ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); - ok(input_info.dwFlags == 0, "Unexpected flags %#lx.\n", input_info.dwFlags); - ok(input_info.cbMaxLookahead == 0, "Unexpected lookahead length %lu.\n", input_info.cbMaxLookahead); - ok(input_info.cbAlignment == 0, "Unexpected alignment %lu.\n", input_info.cbAlignment); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
- IMFMediaType_Release(media_type); - } + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &media_type); + if (SUCCEEDED(hr)) + { + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- /* IYUV -> RGB32 */ - hr = MFCreateMediaType(&media_type); - ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); - ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_IYUV); - ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, ((UINT64)16 << 32) | 16); - ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine - ok(hr == S_OK, "Failed to set input type, hr %#lx.\n", hr); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_RGB32); - ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine - ok(hr == S_OK, "Failed to set output type, hr %#lx.\n", hr); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- memset(&output_info, 0, sizeof(output_info)); - hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine - ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); - ok(output_info.dwFlags == 0, "Unexpected flags %#lx.\n", output_info.dwFlags); - todo_wine - ok(output_info.cbSize > 0, "Unexpected size %lu.\n", output_info.cbSize); - ok(output_info.cbAlignment == 0, "Unexpected alignment %lu.\n", output_info.cbAlignment); + IMFMediaType_Release(media_type); + } + else + { + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = MFCreateSample(&sample); - ok(hr == S_OK, "Failed to create a sample, hr %#lx.\n", hr); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = MFCreateSample(&sample2); - ok(hr == S_OK, "Failed to create a sample, hr %#lx.\n", hr); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- memset(&output_buffer, 0, sizeof(output_buffer)); - output_buffer.pSample = sample; - flags = 0; - hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); - todo_wine - ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "Unexpected hr %#lx.\n", hr); - ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); - ok(flags == 0, "Unexpected status %#lx.\n", flags); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_ProcessInput(transform, 0, sample2, 0); - todo_wine - ok(hr == S_OK, "Failed to push a sample, hr %#lx.\n", hr); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = IMFTransform_ProcessInput(transform, 0, sample2, 0); - todo_wine - ok(hr == MF_E_NOTACCEPTING, "Unexpected hr %#lx.\n", hr); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- memset(&output_buffer, 0, sizeof(output_buffer)); - output_buffer.pSample = sample; - flags = 0; - hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); - todo_wine - ok(hr == MF_E_NO_SAMPLE_TIMESTAMP, "Unexpected hr %#lx.\n", hr); - ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); - ok(flags == 0, "Unexpected status %#lx.\n", flags); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = IMFSample_SetSampleTime(sample2, 0); - ok(hr == S_OK, "Failed to set sample time, hr %#lx.\n", hr); - memset(&output_buffer, 0, sizeof(output_buffer)); - output_buffer.pSample = sample; - flags = 0; - hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); - todo_wine - ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); - ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); - ok(flags == 0, "Unexpected status %#lx.\n", flags); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + }
- hr = MFCreateMemoryBuffer(1024 * 1024, &buffer); - ok(hr == S_OK, "Failed to create a buffer, hr %#lx.\n", hr); + IMFMediaTypeHandler_Release(handler); + IMFRateSupport_Release(rate_support); +}
- hr = IMFSample_AddBuffer(sample2, buffer); - ok(hr == S_OK, "Failed to add a buffer, hr %#lx.\n", hr); +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}, + };
- hr = IMFSample_AddBuffer(sample, buffer); - ok(hr == S_OK, "Failed to add a buffer, hr %#lx.\n", hr); + IMFPresentationClock *present_clock, *present_clock2; + IMFMediaType *mediatype, *mediatype2, *mediatype3; + IMFClockStateSink *state_sink, *state_sink2; + IMFMediaTypeHandler *handler, *handler2; + IMFPresentationTimeSource *time_source; + IMFSimpleAudioVolume *simple_volume; + IMFAudioStreamVolume *stream_volume; + IMFMediaSink *sink, *sink2; + IMFStreamSink *stream_sink; + UINT32 channel_count, rate; + IMFAttributes *attributes; + DWORD id, flags, count; + IMFActivate *activate; + MFCLOCK_STATE state; + IMFClock *clock; + IUnknown *unk; + HRESULT hr; + GUID guid; + BOOL mute; + LONG ref;
- memset(&output_buffer, 0, sizeof(output_buffer)); - output_buffer.pSample = sample; - flags = 0; - hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); - todo_wine - ok(hr == S_OK || broken(FAILED(hr)) /* Win8 */, "Failed to get output buffer, hr %#lx.\n", hr); - ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); - ok(flags == 0, "Unexpected status %#lx.\n", flags); + hr = CoInitialize(NULL); + ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
- if (SUCCEEDED(hr)) + hr = MFCreateAudioRenderer(NULL, &sink); + if (hr == MF_E_NO_AUDIO_PLAYBACK_DEVICE) { - memset(&output_buffer, 0, sizeof(output_buffer)); - output_buffer.pSample = sample; - flags = 0; - hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); - ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "Unexpected hr %#lx.\n", hr); - ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); - ok(flags == 0, "Unexpected status %#lx.\n", flags); + skip("No audio playback device available.\n"); + CoUninitialize(); + return; } + ok(hr == S_OK, "Failed to create renderer, hr %#lx.\n", hr);
- ref = IMFTransform_Release(transform); - ok(ref == 0, "Release returned %ld\n", ref); + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr);
- ref = IMFMediaType_Release(media_type); - ok(ref == 0, "Release returned %ld\n", ref); - ref = IMFSample_Release(sample2); - ok(ref == 0, "Release returned %ld\n", ref); - ref = IMFSample_Release(sample); - ok(ref == 0, "Release returned %ld\n", ref); - ref = IMFMediaBuffer_Release(buffer); - ok(ref == 0, "Release returned %ld\n", ref); + hr = MFCreatePresentationClock(&present_clock); + ok(hr == S_OK, "Failed to create presentation clock, hr %#lx.\n", hr);
-failed: - CoUninitialize(); -} + hr = IMFMediaSink_QueryInterface(sink, &IID_IMFPresentationTimeSource, (void **)&time_source); + todo_wine + ok(hr == S_OK, "Failed to get time source interface, hr %#lx.\n", hr);
-static void test_quality_manager(void) +if (SUCCEEDED(hr)) { - IMFPresentationClock *clock; - IMFQualityManager *manager; - IMFTopology *topology; - HRESULT hr; - LONG ref; + hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&state_sink2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&state_sink); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(state_sink == state_sink2, "Unexpected clock sink.\n"); + IMFClockStateSink_Release(state_sink2); + IMFClockStateSink_Release(state_sink);
- hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); - ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr); + hr = IMFPresentationTimeSource_GetUnderlyingClock(time_source, &clock); + ok(hr == MF_E_NO_CLOCK, "Unexpected hr %#lx.\n", hr);
- hr = MFCreatePresentationClock(&clock); - ok(hr == S_OK, "Failed to create presentation clock, hr %#lx.\n", hr); + hr = IMFPresentationTimeSource_GetClockCharacteristics(time_source, &flags); + ok(hr == S_OK, "Failed to get flags, hr %#lx.\n", hr); + ok(flags == MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ, "Unexpected flags %#lx.\n", flags);
- hr = MFCreateStandardQualityManager(&manager); - ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr); + hr = IMFPresentationTimeSource_GetState(time_source, 0, &state); + ok(hr == S_OK, "Failed to get clock state, hr %#lx.\n", hr); + ok(state == MFCLOCK_STATE_INVALID, "Unexpected state %d.\n", state);
- check_interface(manager, &IID_IMFQualityManager, TRUE); - check_interface(manager, &IID_IMFClockStateSink, TRUE); + hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&state_sink); + ok(hr == S_OK, "Failed to get state sink, hr %#lx.\n", hr);
- hr = IMFQualityManager_NotifyPresentationClock(manager, NULL); + hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + + IMFClockStateSink_Release(state_sink); + + IMFPresentationTimeSource_Release(time_source); +} + hr = IMFMediaSink_AddStreamSink(sink, 123, NULL, &stream_sink); + ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaSink_RemoveStreamSink(sink, 0); + ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaSink_GetStreamSinkCount(sink, NULL); ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
- hr = IMFQualityManager_NotifyTopology(manager, NULL); + hr = IMFMediaSink_GetStreamSinkCount(sink, &count); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(count == 1, "Unexpected count %lu.\n", count);
- /* Set clock, then shutdown. */ - EXPECT_REF(clock, 1); - EXPECT_REF(manager, 1); - hr = IMFQualityManager_NotifyPresentationClock(manager, clock); + hr = IMFMediaSink_GetCharacteristics(sink, &flags); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - EXPECT_REF(clock, 2); - EXPECT_REF(manager, 2); + ok(flags == (MEDIASINK_FIXED_STREAMS | MEDIASINK_CAN_PREROLL), "Unexpected flags %#lx.\n", flags);
- hr = IMFQualityManager_Shutdown(manager); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - EXPECT_REF(clock, 1); + check_interface(sink, &IID_IMFMediaSinkPreroll, TRUE); + check_interface(sink, &IID_IMFMediaEventGenerator, TRUE); + check_interface(sink, &IID_IMFClockStateSink, TRUE); + check_interface(sink, &IID_IMFGetService, TRUE); + todo_wine check_interface(sink, &IID_IMFPresentationTimeSource, TRUE); + todo_wine check_service_interface(sink, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateSupport, TRUE); + check_service_interface(sink, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateControl, FALSE); + check_service_interface(sink, &MR_POLICY_VOLUME_SERVICE, &IID_IMFSimpleAudioVolume, TRUE); + check_service_interface(sink, &MR_STREAM_VOLUME_SERVICE, &IID_IMFAudioStreamVolume, TRUE);
- hr = IMFQualityManager_NotifyPresentationClock(manager, clock); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); + /* Clock */ + hr = IMFMediaSink_QueryInterface(sink, &IID_IMFClockStateSink, (void **)&state_sink); + ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
- hr = IMFQualityManager_NotifyTopology(manager, NULL); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = IMFQualityManager_NotifyPresentationClock(manager, NULL); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockPause(state_sink, 0); + ok(hr == MF_E_INVALID_STATE_TRANSITION, "Unexpected hr %#lx.\n", hr);
- hr = IMFQualityManager_Shutdown(manager); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockStop(state_sink, 0); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- ref = IMFQualityManager_Release(manager); - ok(ref == 0, "Release returned %ld\n", ref); + hr = IMFClockStateSink_OnClockRestart(state_sink, 0); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = MFCreateStandardQualityManager(&manager); - ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr); + IMFClockStateSink_Release(state_sink);
- EXPECT_REF(clock, 1); - EXPECT_REF(manager, 1); - hr = IMFQualityManager_NotifyPresentationClock(manager, clock); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - EXPECT_REF(manager, 2); - EXPECT_REF(clock, 2); - hr = IMFQualityManager_Shutdown(manager); + hr = IMFMediaSink_SetPresentationClock(sink, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- ref = IMFQualityManager_Release(manager); - ok(ref == 0, "Release returned %ld\n", ref); - ref = IMFPresentationClock_Release(clock); - ok(ref == 0, "Release returned %ld\n", ref); + hr = IMFMediaSink_SetPresentationClock(sink, present_clock); + todo_wine + ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#lx.\n", hr);
- /* Set topology. */ - hr = MFCreateStandardQualityManager(&manager); - ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr); + hr = MFCreateSystemTimeSource(&time_source); + ok(hr == S_OK, "Failed to create time source, hr %#lx.\n", hr);
- hr = MFCreateTopology(&topology); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFPresentationClock_SetTimeSource(present_clock, time_source); + ok(hr == S_OK, "Failed to set time source, hr %#lx.\n", hr); + IMFPresentationTimeSource_Release(time_source);
- EXPECT_REF(topology, 1); - hr = IMFQualityManager_NotifyTopology(manager, topology); + hr = IMFMediaSink_SetPresentationClock(sink, present_clock); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - EXPECT_REF(topology, 2);
- hr = IMFQualityManager_NotifyTopology(manager, NULL); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - EXPECT_REF(topology, 1); + hr = IMFMediaSink_GetPresentationClock(sink, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
- hr = IMFQualityManager_NotifyTopology(manager, topology); + hr = IMFMediaSink_GetPresentationClock(sink, &present_clock2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(present_clock == present_clock2, "Unexpected instance.\n"); + IMFPresentationClock_Release(present_clock2);
- EXPECT_REF(topology, 2); - hr = IMFQualityManager_Shutdown(manager); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - EXPECT_REF(topology, 1); + /* Stream */ + hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink); + ok(hr == S_OK, "Failed to get a stream, hr %#lx.\n", hr);
- hr = IMFQualityManager_NotifyTopology(manager, topology); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); + check_interface(stream_sink, &IID_IMFMediaEventGenerator, TRUE); + check_interface(stream_sink, &IID_IMFMediaTypeHandler, TRUE); + todo_wine check_interface(stream_sink, &IID_IMFGetService, TRUE);
- ref = IMFQualityManager_Release(manager); - ok(ref == 0, "Release returned %ld\n", ref); + hr = IMFStreamSink_GetIdentifier(stream_sink, &id); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!id, "Unexpected id.\n");
- hr = MFCreateStandardQualityManager(&manager); - ok(hr == S_OK, "Failed to create quality manager, hr %#lx.\n", hr); + hr = IMFStreamSink_GetMediaSink(stream_sink, &sink2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(sink == sink2, "Unexpected object.\n"); + IMFMediaSink_Release(sink2);
- EXPECT_REF(topology, 1); - hr = IMFQualityManager_NotifyTopology(manager, topology); + hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &handler); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - EXPECT_REF(topology, 2);
- ref = IMFQualityManager_Release(manager); - ok(ref == 0, "Release returned %ld\n", ref); - ref = IMFTopology_Release(topology); - ok(ref == 0, "Release returned %ld\n", ref); + hr = IMFStreamSink_QueryInterface(stream_sink, &IID_IMFMediaTypeHandler, (void **)&handler2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(handler2 == handler, "Unexpected instance.\n"); + IMFMediaTypeHandler_Release(handler2);
- hr = MFShutdown(); - ok(hr == S_OK, "Shutdown failure, hr %#lx.\n", hr); -} + hr = IMFMediaTypeHandler_GetMajorType(handler, &guid); + ok(hr == S_OK, "Failed to get major type, hr %#lx.\n", hr); + ok(IsEqualGUID(&guid, &MFMediaType_Audio), "Unexpected type %s.\n", wine_dbgstr_guid(&guid));
-static void check_sar_rate_support(IMFMediaSink *sink) -{ - IMFRateSupport *rate_support; - IMFMediaTypeHandler *handler; - IMFStreamSink *stream_sink; - IMFMediaType *media_type; - HRESULT hr; - float rate; + count = 0; + hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count); + ok(hr == S_OK, "Failed to get type count, hr %#lx.\n", hr); + ok(!!count, "Unexpected type count %lu.\n", count);
- hr = IMFMediaSink_QueryInterface(sink, &IID_IMFRateSupport, (void **)&rate_support); - todo_wine - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (FAILED(hr)) return; + hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count, &mediatype); + ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink); - if (hr == MF_E_SHUTDOWN) - { - hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &mediatype); + 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);
- hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); + /* check required output media type attributes */
- IMFRateSupport_Release(rate_support); - return; + hr = MFCreateMediaType(&mediatype); + ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); + 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); + 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); } + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &handler); + 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);
- IMFStreamSink_Release(stream_sink);
- hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + hr = MFCreateMediaType(&mediatype); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr);
- hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &media_type); - if (SUCCEEDED(hr)) - { - hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + /* Actual return value is MF_E_ATRIBUTENOTFOUND triggered by missing MF_MT_MAJOR_TYPE */ + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); + ok(FAILED(hr), "Unexpected hr %#lx.\n", hr);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); + ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); + ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype); + ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count - 1, &mediatype2); + ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count - 1, &mediatype3); + ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr); + ok(mediatype2 == mediatype3, "Unexpected instance.\n"); + IMFMediaType_Release(mediatype3);
- IMFMediaType_Release(media_type); - } - else - { - hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype2, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + IMFMediaType_Release(mediatype);
- hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + check_sar_rate_support(sink);
- hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype2); + ok(hr == S_OK, "Failed to set current type, hr %#lx.\n", hr);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + check_sar_rate_support(sink);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(mediatype == mediatype2, "Unexpected instance.\n"); + IMFMediaType_Release(mediatype);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + IMFMediaType_Release(mediatype2);
- hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); - } + /* Reset back to uninitialized state. */ + hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
IMFMediaTypeHandler_Release(handler); - IMFRateSupport_Release(rate_support); -}
-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}, - }; + /* State change with initialized stream. */ + hr = IMFMediaSink_QueryInterface(sink, &IID_IMFClockStateSink, (void **)&state_sink); + ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
- IMFPresentationClock *present_clock, *present_clock2; - IMFMediaType *mediatype, *mediatype2, *mediatype3; - IMFClockStateSink *state_sink, *state_sink2; - IMFMediaTypeHandler *handler, *handler2; - IMFPresentationTimeSource *time_source; - IMFSimpleAudioVolume *simple_volume; - IMFAudioStreamVolume *stream_volume; - IMFMediaSink *sink, *sink2; - IMFStreamSink *stream_sink; - UINT32 channel_count, rate; - IMFAttributes *attributes; - DWORD id, flags, count; - IMFActivate *activate; - MFCLOCK_STATE state; - IMFClock *clock; - IUnknown *unk; - HRESULT hr; - GUID guid; - BOOL mute; - LONG ref; + hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = CoInitialize(NULL); - ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = MFCreateAudioRenderer(NULL, &sink); - if (hr == MF_E_NO_AUDIO_PLAYBACK_DEVICE) - { - skip("No audio playback device available.\n"); - CoUninitialize(); - return; - } - ok(hr == S_OK, "Failed to create renderer, hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockPause(state_sink, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); - ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockStop(state_sink, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = MFCreatePresentationClock(&present_clock); - ok(hr == S_OK, "Failed to create presentation clock, hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockStop(state_sink, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFMediaSink_QueryInterface(sink, &IID_IMFPresentationTimeSource, (void **)&time_source); - todo_wine - ok(hr == S_OK, "Failed to get time source interface, hr %#lx.\n", hr); + hr = IMFClockStateSink_OnClockPause(state_sink, 0); + ok(hr == MF_E_INVALID_STATE_TRANSITION, "Unexpected hr %#lx.\n", hr);
-if (SUCCEEDED(hr)) -{ - hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&state_sink2); + hr = IMFClockStateSink_OnClockRestart(state_sink, 0); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&state_sink); + + hr = IMFClockStateSink_OnClockRestart(state_sink, 0); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(state_sink == state_sink2, "Unexpected clock sink.\n"); - IMFClockStateSink_Release(state_sink2); + + hr = IMFClockStateSink_OnClockStop(state_sink, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFClockStateSink_Release(state_sink);
- hr = IMFPresentationTimeSource_GetUnderlyingClock(time_source, &clock); - ok(hr == MF_E_NO_CLOCK, "Unexpected hr %#lx.\n", hr); + IMFStreamSink_Release(stream_sink);
- hr = IMFPresentationTimeSource_GetClockCharacteristics(time_source, &flags); - ok(hr == S_OK, "Failed to get flags, hr %#lx.\n", hr); - ok(flags == MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ, "Unexpected flags %#lx.\n", flags); + /* Volume control */ + hr = MFGetService((IUnknown *)sink, &MR_POLICY_VOLUME_SERVICE, &IID_IMFSimpleAudioVolume, (void **)&simple_volume); + ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
- hr = IMFPresentationTimeSource_GetState(time_source, 0, &state); - ok(hr == S_OK, "Failed to get clock state, hr %#lx.\n", hr); - ok(state == MFCLOCK_STATE_INVALID, "Unexpected state %d.\n", state); + hr = IMFSimpleAudioVolume_GetMute(simple_volume, &mute); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&state_sink); - ok(hr == S_OK, "Failed to get state sink, hr %#lx.\n", hr); + IMFSimpleAudioVolume_Release(simple_volume);
- hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + hr = MFGetService((IUnknown *)sink, &MR_STREAM_VOLUME_SERVICE, &IID_IMFAudioStreamVolume, (void **)&stream_volume); + ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
- IMFClockStateSink_Release(state_sink); + hr = IMFAudioStreamVolume_GetChannelCount(stream_volume, &channel_count); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFAudioStreamVolume_GetChannelCount(stream_volume, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + IMFAudioStreamVolume_Release(stream_volume); + + hr = MFGetService((IUnknown *)sink, &MR_AUDIO_POLICY_SERVICE, &IID_IMFAudioPolicy, (void **)&unk); + ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); + IUnknown_Release(unk); + + /* Shutdown */ + EXPECT_REF(present_clock, 2); + hr = IMFMediaSink_Shutdown(sink); + ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr); + EXPECT_REF(present_clock, 1); + + hr = IMFMediaSink_Shutdown(sink); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- IMFPresentationTimeSource_Release(time_source); -} hr = IMFMediaSink_AddStreamSink(sink, 123, NULL, &stream_sink); - ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_RemoveStreamSink(sink, 0); - ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetStreamSinkCount(sink, NULL); ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetStreamSinkCount(sink, &count); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(count == 1, "Unexpected count %lu.\n", count); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(flags == (MEDIASINK_FIXED_STREAMS | MEDIASINK_CAN_PREROLL), "Unexpected flags %#lx.\n", flags); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- check_interface(sink, &IID_IMFMediaSinkPreroll, TRUE); - check_interface(sink, &IID_IMFMediaEventGenerator, TRUE); - check_interface(sink, &IID_IMFClockStateSink, TRUE); - check_interface(sink, &IID_IMFGetService, TRUE); - todo_wine check_interface(sink, &IID_IMFPresentationTimeSource, TRUE); - todo_wine check_service_interface(sink, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateSupport, TRUE); - check_service_interface(sink, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateControl, FALSE); - check_service_interface(sink, &MR_POLICY_VOLUME_SERVICE, &IID_IMFSimpleAudioVolume, TRUE); - check_service_interface(sink, &MR_STREAM_VOLUME_SERVICE, &IID_IMFAudioStreamVolume, TRUE); + hr = IMFMediaSink_SetPresentationClock(sink, NULL); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- /* Clock */ - hr = IMFMediaSink_QueryInterface(sink, &IID_IMFClockStateSink, (void **)&state_sink); - ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); + hr = IMFMediaSink_SetPresentationClock(sink, present_clock); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSink_GetPresentationClock(sink, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
- hr = IMFClockStateSink_OnClockPause(state_sink, 0); - ok(hr == MF_E_INVALID_STATE_TRANSITION, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSink_GetPresentationClock(sink, &present_clock2); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
- hr = IMFClockStateSink_OnClockStop(state_sink, 0); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + check_sar_rate_support(sink);
- hr = IMFClockStateSink_OnClockRestart(state_sink, 0); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + ref = IMFMediaSink_Release(sink); + todo_wine + ok(ref == 0, "Release returned %ld\n", ref);
- IMFClockStateSink_Release(state_sink); - - hr = IMFMediaSink_SetPresentationClock(sink, NULL); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_SetPresentationClock(sink, present_clock); - todo_wine - ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#lx.\n", hr); - - hr = MFCreateSystemTimeSource(&time_source); - ok(hr == S_OK, "Failed to create time source, hr %#lx.\n", hr); - - hr = IMFPresentationClock_SetTimeSource(present_clock, time_source); - ok(hr == S_OK, "Failed to set time source, hr %#lx.\n", hr); - IMFPresentationTimeSource_Release(time_source); - - hr = IMFMediaSink_SetPresentationClock(sink, present_clock); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_GetPresentationClock(sink, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_GetPresentationClock(sink, &present_clock2); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(present_clock == present_clock2, "Unexpected instance.\n"); - IMFPresentationClock_Release(present_clock2); - - /* Stream */ - hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink); - ok(hr == S_OK, "Failed to get a stream, hr %#lx.\n", hr); - - check_interface(stream_sink, &IID_IMFMediaEventGenerator, TRUE); - check_interface(stream_sink, &IID_IMFMediaTypeHandler, TRUE); - todo_wine check_interface(stream_sink, &IID_IMFGetService, TRUE); - - hr = IMFStreamSink_GetIdentifier(stream_sink, &id); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!id, "Unexpected id.\n"); - - hr = IMFStreamSink_GetMediaSink(stream_sink, &sink2); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(sink == sink2, "Unexpected object.\n"); - IMFMediaSink_Release(sink2); - - hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &handler); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFStreamSink_QueryInterface(stream_sink, &IID_IMFMediaTypeHandler, (void **)&handler2); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(handler2 == handler, "Unexpected instance.\n"); - IMFMediaTypeHandler_Release(handler2); - - hr = IMFMediaTypeHandler_GetMajorType(handler, &guid); - ok(hr == S_OK, "Failed to get major type, hr %#lx.\n", hr); - ok(IsEqualGUID(&guid, &MFMediaType_Audio), "Unexpected type %s.\n", wine_dbgstr_guid(&guid)); - - count = 0; - hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count); - ok(hr == S_OK, "Failed to get type count, hr %#lx.\n", hr); - ok(!!count, "Unexpected type count %lu.\n", count); - - hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count, &mediatype); - ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &mediatype); - 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); - - - /* check required output media type attributes */ - - hr = MFCreateMediaType(&mediatype); - ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - 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); - 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); - } - 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); - ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); - - hr = MFCreateMediaType(&mediatype); - ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); - - /* Actual return value is MF_E_ATRIBUTENOTFOUND triggered by missing MF_MT_MAJOR_TYPE */ - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - ok(FAILED(hr), "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype); - ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count - 1, &mediatype2); - ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr); - hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count - 1, &mediatype3); - ok(hr == S_OK, "Failed to get media type, hr %#lx.\n", hr); - ok(mediatype2 == mediatype3, "Unexpected instance.\n"); - IMFMediaType_Release(mediatype3); - - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype2, NULL); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - IMFMediaType_Release(mediatype); - - check_sar_rate_support(sink); - - hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype2); - ok(hr == S_OK, "Failed to set current type, hr %#lx.\n", hr); - - check_sar_rate_support(sink); - - hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(mediatype == mediatype2, "Unexpected instance.\n"); - IMFMediaType_Release(mediatype); - - IMFMediaType_Release(mediatype2); - - /* Reset back to uninitialized state. */ - hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); - - IMFMediaTypeHandler_Release(handler); - - /* State change with initialized stream. */ - hr = IMFMediaSink_QueryInterface(sink, &IID_IMFClockStateSink, (void **)&state_sink); - ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockStart(state_sink, 0, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockPause(state_sink, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockStop(state_sink, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockStop(state_sink, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockPause(state_sink, 0); - ok(hr == MF_E_INVALID_STATE_TRANSITION, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockRestart(state_sink, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockRestart(state_sink, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFClockStateSink_OnClockStop(state_sink, 0); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - IMFClockStateSink_Release(state_sink); - - IMFStreamSink_Release(stream_sink); - - /* Volume control */ - hr = MFGetService((IUnknown *)sink, &MR_POLICY_VOLUME_SERVICE, &IID_IMFSimpleAudioVolume, (void **)&simple_volume); - ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); - - hr = IMFSimpleAudioVolume_GetMute(simple_volume, &mute); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - IMFSimpleAudioVolume_Release(simple_volume); - - hr = MFGetService((IUnknown *)sink, &MR_STREAM_VOLUME_SERVICE, &IID_IMFAudioStreamVolume, (void **)&stream_volume); - ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); - - hr = IMFAudioStreamVolume_GetChannelCount(stream_volume, &channel_count); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - - hr = IMFAudioStreamVolume_GetChannelCount(stream_volume, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); - - IMFAudioStreamVolume_Release(stream_volume); - - hr = MFGetService((IUnknown *)sink, &MR_AUDIO_POLICY_SERVICE, &IID_IMFAudioPolicy, (void **)&unk); - ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); - IUnknown_Release(unk); - - /* Shutdown */ - EXPECT_REF(present_clock, 2); - hr = IMFMediaSink_Shutdown(sink); - ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr); - EXPECT_REF(present_clock, 1); - - hr = IMFMediaSink_Shutdown(sink); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_AddStreamSink(sink, 123, NULL, &stream_sink); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_RemoveStreamSink(sink, 0); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_GetStreamSinkCount(sink, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_GetStreamSinkCount(sink, &count); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_GetCharacteristics(sink, &flags); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_SetPresentationClock(sink, NULL); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_SetPresentationClock(sink, present_clock); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_GetPresentationClock(sink, NULL); - ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); - - hr = IMFMediaSink_GetPresentationClock(sink, &present_clock2); - ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr); - - check_sar_rate_support(sink); - - ref = IMFMediaSink_Release(sink); - todo_wine - ok(ref == 0, "Release returned %ld\n", ref); - - /* Activation */ - hr = MFCreateAudioRendererActivate(&activate); - ok(hr == S_OK, "Failed to create activation object, hr %#lx.\n", hr); + /* Activation */ + hr = MFCreateAudioRendererActivate(&activate); + ok(hr == S_OK, "Failed to create activation object, hr %#lx.\n", hr);
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink); ok(hr == S_OK, "Failed to activate, hr %#lx.\n", hr); @@ -6420,6 +6037,7 @@ static void check_sample_rgb32_(int line, IMFSample *sample, const BYTE *expect_ for (i = 0; i < length; i++) { if (i % 4 == 3) continue; /* ignore alpha diff */ + if (!expect_buf[(i & ~3) + 3]) continue; /* ignore transparent pixels */ diff += abs((int)expect_buf[i] - (int)buffer[i]); } max_diff = length * 3 * 256; @@ -8479,143 +8097,919 @@ static void test_color_convert(void) {0}, };
- MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; - MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_I420}; - ULONG nv12frame_data_len, rgb32_data_len; - const BYTE *nv12frame_data, *rgb32_data; - MFT_OUTPUT_STREAM_INFO output_info; - MFT_INPUT_STREAM_INFO input_info; - MFT_OUTPUT_DATA_BUFFER output; - WCHAR output_path[MAX_PATH]; - IMFMediaType *media_type; - LONGLONG time, duration; - IMFTransform *transform; - DWORD length, status; - HANDLE output_file; - IMFSample *sample; - HRSRC resource; - GUID class_id; - ULONG i, ret; - HRESULT hr; + MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; + MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_I420}; + ULONG nv12frame_data_len, rgb32_data_len; + const BYTE *nv12frame_data, *rgb32_data; + MFT_OUTPUT_STREAM_INFO output_info; + MFT_INPUT_STREAM_INFO input_info; + MFT_OUTPUT_DATA_BUFFER output; + WCHAR output_path[MAX_PATH]; + IMFMediaType *media_type; + LONGLONG time, duration; + IMFTransform *transform; + DWORD length, status; + HANDLE output_file; + IMFSample *sample; + HRSRC resource; + GUID class_id; + ULONG i, ret; + HRESULT hr; + + hr = CoInitialize(NULL); + ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr); + + if (!create_transform(MFT_CATEGORY_VIDEO_EFFECT, &input_type, &output_type, L"Color Converter MFT", &MFMediaType_Video, + transform_inputs, ARRAY_SIZE(transform_inputs), transform_outputs, ARRAY_SIZE(transform_outputs), + &transform, &CLSID_CColorConvertDMO, &class_id)) + goto failed; + + check_dmo(&CLSID_CColorConvertDMO, L"Color Converter DMO", &MEDIATYPE_Video, dmo_inputs, ARRAY_SIZE(dmo_inputs), + dmo_outputs, ARRAY_SIZE(dmo_outputs)); + + check_interface(transform, &IID_IMFTransform, TRUE); + check_interface(transform, &IID_IMediaObject, TRUE); + check_interface(transform, &IID_IPropertyStore, TRUE); + todo_wine + check_interface(transform, &IID_IMFRealTimeClient, TRUE); + /* check_interface(transform, &IID_IWMColorConvProps, TRUE); */ + + /* check default media types */ + + hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetInputStreamInfo returned %#lx\n", hr); + hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#lx\n", hr); + + i = -1; + while (SUCCEEDED(hr = IMFTransform_GetOutputAvailableType(transform, 0, ++i, &media_type))) + { + winetest_push_context("out %lu", i); + ok(hr == S_OK, "GetOutputAvailableType returned %#lx\n", hr); + check_media_type(media_type, expect_available_common, -1); + check_media_type(media_type, expect_available_outputs[i], -1); + ret = IMFMediaType_Release(media_type); + ok(ret == 0, "Release returned %lu\n", ret); + winetest_pop_context(); + } + ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); + ok(i == 16, "%lu output media types\n", i); + + i = -1; + while (SUCCEEDED(hr = IMFTransform_GetInputAvailableType(transform, 0, ++i, &media_type))) + { + winetest_push_context("in %lu", i); + ok(hr == S_OK, "GetInputAvailableType returned %#lx\n", hr); + check_media_type(media_type, expect_available_common, -1); + check_media_type(media_type, expect_available_inputs[i], -1); + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + if (i == 12) + { + todo_wine + ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); + } + else + ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); + ret = IMFMediaType_Release(media_type); + ok(ret == 0, "Release returned %lu\n", ret); + winetest_pop_context(); + } + ok(hr == MF_E_NO_MORE_TYPES, "GetInputAvailableType returned %#lx\n", hr); + ok(i == 20, "%lu input media types\n", i); + + /* check required output media type attributes */ + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); + hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); + init_media_type(media_type, output_type_desc, 1); + hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\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); + ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); + init_media_type(media_type, output_type_desc, i + 1); + } + hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + ret = IMFMediaType_Release(media_type); + ok(ret == 0, "Release returned %lu\n", ret); + + /* check required input media type attributes */ + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); + init_media_type(media_type, input_type_desc, 1); + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); + init_media_type(media_type, input_type_desc, 2); + for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) + { + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); + init_media_type(media_type, input_type_desc, i + 1); + } + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + ret = IMFMediaType_Release(media_type); + ok(ret == 0, "Release returned %lu\n", ret); + + memset(&input_info, 0xcd, sizeof(input_info)); + hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); + ok(hr == S_OK, "GetInputStreamInfo returned %#lx\n", hr); + ok(input_info.hnsMaxLatency == 0, "got hnsMaxLatency %s\n", wine_dbgstr_longlong(input_info.hnsMaxLatency)); + ok(input_info.dwFlags == 0, "got dwFlags %#lx\n", input_info.dwFlags); + ok(input_info.cbSize == actual_width * actual_height * 3 / 2, "got cbSize %#lx\n", input_info.cbSize); + ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#lx\n", input_info.cbMaxLookahead); + ok(input_info.cbAlignment == 1, "got cbAlignment %#lx\n", input_info.cbAlignment); + + memset(&output_info, 0xcd, sizeof(output_info)); + hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); + ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); + ok(output_info.dwFlags == 0, "got dwFlags %#lx\n", output_info.dwFlags); + ok(output_info.cbSize == actual_width * actual_height * 4, "got cbSize %#lx\n", output_info.cbSize); + ok(output_info.cbAlignment == 1, "got cbAlignment %#lx\n", output_info.cbAlignment); + + resource = FindResourceW(NULL, L"nv12frame.bin", (const WCHAR *)RT_RCDATA); + ok(resource != 0, "FindResourceW failed, error %lu\n", GetLastError()); + nv12frame_data = LockResource(LoadResource(GetModuleHandleW(NULL), resource)); + nv12frame_data_len = SizeofResource(GetModuleHandleW(NULL), resource); + ok(nv12frame_data_len == 13824, "got length %lu\n", nv12frame_data_len); + + sample = create_sample(nv12frame_data, nv12frame_data_len); + hr = IMFSample_SetSampleTime(sample, 0); + ok(hr == S_OK, "SetSampleTime returned %#lx\n", hr); + hr = IMFSample_SetSampleDuration(sample, 10000000); + ok(hr == S_OK, "SetSampleDuration returned %#lx\n", hr); + hr = IMFTransform_ProcessInput(transform, 0, sample, 0); + ok(hr == S_OK, "ProcessInput returned %#lx\n", hr); + hr = IMFTransform_ProcessInput(transform, 0, sample, 0); + ok(hr == MF_E_NOTACCEPTING, "ProcessInput returned %#lx\n", hr); + hr = IMFTransform_ProcessMessage(transform, MFT_MESSAGE_COMMAND_DRAIN, 0); + ok(hr == S_OK, "ProcessMessage returned %#lx\n", hr); + ret = IMFSample_Release(sample); + ok(ret <= 1, "Release returned %ld\n", ret); + + resource = FindResourceW(NULL, L"rgb32frame.bin", (const WCHAR *)RT_RCDATA); + ok(resource != 0, "FindResourceW failed, error %lu\n", GetLastError()); + rgb32_data = LockResource(LoadResource(GetModuleHandleW(NULL), resource)); + rgb32_data_len = SizeofResource(GetModuleHandleW(NULL), resource); + ok(rgb32_data_len == output_info.cbSize, "got length %lu\n", rgb32_data_len); + + /* and generate a new one as well in a temporary directory */ + GetTempPathW(ARRAY_SIZE(output_path), output_path); + lstrcatW(output_path, L"rgb32frame.bin"); + output_file = CreateFileW(output_path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(output_file != INVALID_HANDLE_VALUE, "CreateFileW failed, error %lu\n", GetLastError()); + + status = 0xdeadbeef; + sample = create_sample(NULL, output_info.cbSize); + memset(&output, 0, sizeof(output)); + output.pSample = sample; + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); + ok(hr == S_OK, "ProcessOutput returned %#lx\n", hr); + ok(output.pSample == sample, "got pSample %p\n", output.pSample); + ok(output.dwStatus == 0 || broken(output.dwStatus == 6) /* win7 */, "got dwStatus %#lx\n", output.dwStatus); + ok(status == 0, "got status %#lx\n", status); + + hr = IMFSample_GetSampleTime(sample, &time); + ok(hr == S_OK, "GetSampleTime returned %#lx\n", hr); + ok(time == 0, "got time %I64d\n", time); + hr = IMFSample_GetSampleDuration(sample, &duration); + ok(hr == S_OK, "GetSampleDuration returned %#lx\n", hr); + ok(duration == 10000000, "got duration %I64d\n", duration); + hr = IMFSample_GetTotalLength(sample, &length); + ok(hr == S_OK, "GetTotalLength returned %#lx\n", hr); + ok(length == output_info.cbSize, "got length %lu\n", length); + check_sample_rgb32(sample, rgb32_data, output_file); + rgb32_data_len -= output_info.cbSize; + rgb32_data += output_info.cbSize; + + trace("created %s\n", debugstr_w(output_path)); + CloseHandle(output_file); + + ret = IMFSample_Release(sample); + ok(ret == 0, "Release returned %lu\n", ret); + + status = 0xdeadbeef; + sample = create_sample(NULL, output_info.cbSize); + memset(&output, 0, sizeof(output)); + output.pSample = sample; + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); + ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); + ok(output.pSample == sample, "got pSample %p\n", output.pSample); + ok(output.dwStatus == 0, "got dwStatus %#lx\n", output.dwStatus); + ok(status == 0, "got status %#lx\n", status); + hr = IMFSample_GetTotalLength(sample, &length); + ok(hr == S_OK, "GetTotalLength returned %#lx\n", hr); + ok(length == 0, "got length %lu\n", length); + ret = IMFSample_Release(sample); + ok(ret == 0, "Release returned %lu\n", ret); + + ret = IMFTransform_Release(transform); + ok(ret == 0, "Release returned %ld\n", ret); + +failed: + CoUninitialize(); +} + +static void test_video_processor(void) +{ + const GUID transform_inputs[22] = + { + MFVideoFormat_IYUV, + MFVideoFormat_YV12, + MFVideoFormat_NV12, + MFVideoFormat_YUY2, + MFVideoFormat_ARGB32, + MFVideoFormat_RGB32, + MFVideoFormat_NV11, + MFVideoFormat_AYUV, + MFVideoFormat_UYVY, + MEDIASUBTYPE_P208, + MFVideoFormat_RGB24, + MFVideoFormat_RGB555, + MFVideoFormat_RGB565, + MFVideoFormat_RGB8, + MFVideoFormat_I420, + MFVideoFormat_Y216, + MFVideoFormat_v410, + MFVideoFormat_Y41P, + MFVideoFormat_Y41T, + MFVideoFormat_Y42T, + MFVideoFormat_YVYU, + MFVideoFormat_420O, + }; + const GUID transform_outputs[21] = + { + MFVideoFormat_IYUV, + MFVideoFormat_YV12, + MFVideoFormat_NV12, + MFVideoFormat_YUY2, + MFVideoFormat_ARGB32, + MFVideoFormat_RGB32, + MFVideoFormat_NV11, + MFVideoFormat_AYUV, + MFVideoFormat_UYVY, + MEDIASUBTYPE_P208, + MFVideoFormat_RGB24, + MFVideoFormat_RGB555, + MFVideoFormat_RGB565, + MFVideoFormat_RGB8, + MFVideoFormat_I420, + MFVideoFormat_Y216, + MFVideoFormat_v410, + MFVideoFormat_Y41P, + MFVideoFormat_Y41T, + MFVideoFormat_Y42T, + MFVideoFormat_YVYU, + }; + const GUID expect_available_inputs_w8[] = + { + MFVideoFormat_IYUV, + MFVideoFormat_YV12, + MFVideoFormat_NV12, + MFVideoFormat_420O, + MFVideoFormat_UYVY, + MFVideoFormat_YUY2, + MFVideoFormat_P208, + MFVideoFormat_NV11, + MFVideoFormat_AYUV, + MFVideoFormat_ARGB32, + MFVideoFormat_RGB32, + MFVideoFormat_RGB24, + MFVideoFormat_I420, + MFVideoFormat_YVYU, + MFVideoFormat_RGB555, + MFVideoFormat_RGB565, + MFVideoFormat_RGB8, + MFVideoFormat_Y216, + MFVideoFormat_v410, + MFVideoFormat_Y41P, + MFVideoFormat_Y41T, + MFVideoFormat_Y42T, + }; + const GUID expect_available_inputs_w10[] = + { + MFVideoFormat_L8, + MFVideoFormat_L16, + MFAudioFormat_MPEG, + MFVideoFormat_IYUV, + MFVideoFormat_YV12, + MFVideoFormat_NV12, + MFVideoFormat_420O, + MFVideoFormat_P010, + MFVideoFormat_P016, + MFVideoFormat_UYVY, + MFVideoFormat_YUY2, + MFVideoFormat_P208, + MFVideoFormat_NV11, + MFVideoFormat_AYUV, + MFVideoFormat_ARGB32, + MFVideoFormat_ABGR32, + MFVideoFormat_RGB32, + MFVideoFormat_A2R10G10B10, + MFVideoFormat_A16B16G16R16F, + MFVideoFormat_RGB24, + MFVideoFormat_I420, + MFVideoFormat_YVYU, + MFVideoFormat_RGB555, + MFVideoFormat_RGB565, + MFVideoFormat_RGB8, + MFVideoFormat_Y216, + MFVideoFormat_v410, + MFVideoFormat_Y41P, + MFVideoFormat_Y41T, + MFVideoFormat_Y42T, + }; + const GUID expect_available_outputs[] = + { + MFVideoFormat_A2R10G10B10, /* enumerated with MFVideoFormat_P010 input */ + MFVideoFormat_P010, /* enumerated with MFVideoFormat_A2R10G10B10 input */ + MFVideoFormat_YUY2, + MFVideoFormat_IYUV, + MFVideoFormat_I420, + MFVideoFormat_NV12, + MFVideoFormat_RGB24, + MFVideoFormat_ARGB32, + MFVideoFormat_RGB32, + MFVideoFormat_YV12, + MFVideoFormat_Y216, /* enumerated with some input formats */ + MFVideoFormat_UYVY, /* enumerated with some input formats */ + MFVideoFormat_YVYU, /* enumerated with some input formats */ + MFVideoFormat_AYUV, + MFVideoFormat_RGB555, + MFVideoFormat_RGB565, + MFVideoFormat_AYUV, /* some inputs enumerate MFVideoFormat_AYUV after RGB565 */ + MFVideoFormat_NV12, /* P010 enumerates NV12 after (A)RGB32 formats */ + MFVideoFormat_A16B16G16R16F, /* enumerated with MFVideoFormat_P010 input */ + }; + static const media_type_desc expect_available_common = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), + }; + + static const MFVideoArea actual_aperture = {.Area={82,84}}; + static const DWORD actual_width = 96, actual_height = 96; + const struct attribute_desc input_type_desc[] = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12), + ATTR_BLOB(MF_MT_MINIMUM_DISPLAY_APERTURE, &actual_aperture, 16), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height), + {0}, + }; + const struct attribute_desc output_type_desc[] = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32), + ATTR_BLOB(MF_MT_MINIMUM_DISPLAY_APERTURE, &actual_aperture, 16), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height), + {0}, + }; + + MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; + MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_I420}; + DWORD input_count, output_count, input_id, output_id, flags; + DWORD input_min, input_max, output_min, output_max, i, j, k; + ULONG nv12frame_data_len, rgb32_data_len; + IMFMediaType *media_type, *media_type2; + IMFAttributes *attributes, *attributes2; + const BYTE *nv12frame_data, *rgb32_data; + MFT_OUTPUT_DATA_BUFFER output_buffer; + const GUID *expect_available_inputs; + MFT_OUTPUT_STREAM_INFO output_info; + MFT_INPUT_STREAM_INFO input_info; + MFT_OUTPUT_DATA_BUFFER output; + IMFSample *sample, *sample2; + WCHAR output_path[MAX_PATH]; + LONGLONG time, duration; + IMFTransform *transform; + IMFMediaBuffer *buffer; + IMFMediaEvent *event; + DWORD length, status; + unsigned int value; + HANDLE output_file; + HRSRC resource; + BYTE *ptr, tmp; + GUID class_id; + UINT32 count; + HRESULT hr; + ULONG ret; + GUID guid; + LONG ref; + + hr = CoInitialize(NULL); + ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr); + + if (!create_transform(MFT_CATEGORY_VIDEO_PROCESSOR, &input_type, &output_type, L"Microsoft Video Processor MFT", &MFMediaType_Video, + transform_inputs, ARRAY_SIZE(transform_inputs), transform_outputs, ARRAY_SIZE(transform_outputs), + &transform, &CLSID_VideoProcessorMFT, &class_id)) + goto failed; + has_video_processor = TRUE; + + todo_wine + check_interface(transform, &IID_IMFVideoProcessorControl, TRUE); + todo_wine + check_interface(transform, &IID_IMFRealTimeClientEx, TRUE); + check_interface(transform, &IID_IMFMediaEventGenerator, FALSE); + check_interface(transform, &IID_IMFShutdown, FALSE); + + /* Transform global attributes. */ + hr = IMFTransform_GetAttributes(transform, &attributes); + ok(hr == S_OK, "Failed to get attributes, hr %#lx.\n", hr); + + hr = IMFAttributes_GetCount(attributes, &count); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(!!count, "Unexpected attribute count %u.\n", count); + + value = 0; + hr = IMFAttributes_GetUINT32(attributes, &MF_SA_D3D11_AWARE, &value); +todo_wine { + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value == 1, "Unexpected attribute value %u.\n", value); +} + hr = IMFTransform_GetAttributes(transform, &attributes2); + ok(hr == S_OK, "Failed to get attributes, hr %#lx.\n", hr); + ok(attributes == attributes2, "Unexpected instance.\n"); + IMFAttributes_Release(attributes); + IMFAttributes_Release(attributes2); + + hr = IMFTransform_GetStreamLimits(transform, &input_min, &input_max, &output_min, &output_max); + ok(hr == S_OK, "Failed to get stream limits, hr %#lx.\n", hr); + ok(input_min == input_max && input_min == 1 && output_min == output_max && output_min == 1, + "Unexpected stream limits.\n"); + + hr = IMFTransform_GetStreamCount(transform, &input_count, &output_count); + ok(hr == S_OK, "Failed to get stream count, hr %#lx.\n", hr); + ok(input_count == 1 && output_count == 1, "Unexpected stream count %lu, %lu.\n", input_count, output_count); + + hr = IMFTransform_GetStreamIDs(transform, 1, &input_id, 1, &output_id); + ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + + input_id = 100; + hr = IMFTransform_AddInputStreams(transform, 1, &input_id); + ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_DeleteInputStream(transform, 0); + ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetInputStatus(transform, 0, &flags); + todo_wine + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetInputStreamAttributes(transform, 0, &attributes); + ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetOutputStatus(transform, &flags); + todo_wine + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetOutputStreamAttributes(transform, 0, &attributes); + ok(hr == S_OK, "Failed to get output attributes, hr %#lx.\n", hr); + hr = IMFTransform_GetOutputStreamAttributes(transform, 0, &attributes2); + ok(hr == S_OK, "Failed to get output attributes, hr %#lx.\n", hr); + ok(attributes == attributes2, "Unexpected instance.\n"); + IMFAttributes_Release(attributes); + IMFAttributes_Release(attributes2); + + hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); + todo_wine + ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type); + todo_wine + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetInputCurrentType(transform, 1, &media_type); + todo_wine + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type); + todo_wine + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetOutputCurrentType(transform, 1, &media_type); + todo_wine + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetInputStreamInfo(transform, 1, &input_info); + todo_wine + ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr); + + memset(&input_info, 0xcc, sizeof(input_info)); + hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); +todo_wine { + ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); + ok(input_info.dwFlags == 0, "Unexpected flag %#lx.\n", input_info.dwFlags); + ok(input_info.cbSize == 0, "Unexpected size %lu.\n", input_info.cbSize); + ok(input_info.cbMaxLookahead == 0, "Unexpected lookahead length %lu.\n", input_info.cbMaxLookahead); + ok(input_info.cbAlignment == 0, "Unexpected alignment %lu.\n", input_info.cbAlignment); +} + hr = MFCreateMediaEvent(MEUnknown, &GUID_NULL, S_OK, NULL, &event); + ok(hr == S_OK, "Failed to create event object, hr %#lx.\n", hr); + hr = IMFTransform_ProcessEvent(transform, 0, event); + ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + hr = IMFTransform_ProcessEvent(transform, 1, event); + ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr); + ref = IMFMediaEvent_Release(event); + ok(ref == 0, "Release returned %ld\n", ref); + + /* Configure stream types. */ + for (i = 0;;++i) + { + if (FAILED(hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type))) + { + todo_wine + ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr); + break; + } + + hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type2); + ok(hr == S_OK, "Failed to get available type, hr %#lx.\n", hr); + ok(media_type != media_type2, "Unexpected instance.\n"); + ref = IMFMediaType_Release(media_type2); + ok(ref == 0, "Release returned %ld\n", ref); + + hr = IMFMediaType_GetMajorType(media_type, &guid); + ok(hr == S_OK, "Failed to get major type, hr %#lx.\n", hr); + ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected major type.\n"); + + hr = IMFMediaType_GetCount(media_type, &count); + ok(hr == S_OK, "Failed to get attributes count, hr %#lx.\n", hr); + ok(count == 2, "Unexpected count %u.\n", count); + + hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "Failed to get subtype, hr %#lx.\n", hr); + ok(is_supported_video_type(&guid), "Unexpected media type %s.\n", wine_dbgstr_guid(&guid)); + + hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); + ok(FAILED(hr), "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + ok(FAILED(hr), "Unexpected hr %#lx.\n", hr); + + hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type2); + ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr); + + /* FIXME: figure out if those require additional attributes or simply advertised but not supported */ + if (IsEqualGUID(&guid, &MFVideoFormat_L8) || IsEqualGUID(&guid, &MFVideoFormat_L16) + || IsEqualGUID(&guid, &MFVideoFormat_D16) || IsEqualGUID(&guid, &MFVideoFormat_420O) + || IsEqualGUID(&guid, &MFVideoFormat_A16B16G16R16F)) + { + ref = IMFMediaType_Release(media_type); + ok(ref == 0, "Release returned %ld\n", ref); + continue; + } + + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, ((UINT64)16 << 32) | 16); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + + hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); + ok(hr == S_OK, "Failed to test input type %s, hr %#lx.\n", wine_dbgstr_guid(&guid), hr); + + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + ok(hr == S_OK, "Failed to test input type, hr %#lx.\n", hr); + + hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type2); + ok(hr == S_OK, "Failed to get current type, hr %#lx.\n", hr); + ok(media_type != media_type2, "Unexpected instance.\n"); + IMFMediaType_Release(media_type2); + + hr = IMFTransform_GetInputStatus(transform, 0, &flags); + ok(hr == S_OK, "Failed to get input status, hr %#lx.\n", hr); + ok(flags == MFT_INPUT_STATUS_ACCEPT_DATA, "Unexpected input status %#lx.\n", flags); + + hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); + ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); + ok(input_info.dwFlags == 0, "Unexpected flags %#lx.\n", input_info.dwFlags); + ok(input_info.cbMaxLookahead == 0, "Unexpected lookahead length %lu.\n", input_info.cbMaxLookahead); + ok(input_info.cbAlignment == 0, "Unexpected alignment %lu.\n", input_info.cbAlignment); + + IMFMediaType_Release(media_type); + } + + /* IYUV -> RGB32 */ + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_IYUV); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, ((UINT64)16 << 32) | 16); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + todo_wine + ok(hr == S_OK, "Failed to set input type, hr %#lx.\n", hr); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + + hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); + todo_wine + ok(hr == S_OK, "Failed to set output type, hr %#lx.\n", hr); + + memset(&output_info, 0, sizeof(output_info)); + hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); + todo_wine + ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); + ok(output_info.dwFlags == 0, "Unexpected flags %#lx.\n", output_info.dwFlags); + todo_wine + ok(output_info.cbSize > 0, "Unexpected size %lu.\n", output_info.cbSize); + ok(output_info.cbAlignment == 0, "Unexpected alignment %lu.\n", output_info.cbAlignment); + + hr = MFCreateSample(&sample); + ok(hr == S_OK, "Failed to create a sample, hr %#lx.\n", hr); + + hr = MFCreateSample(&sample2); + ok(hr == S_OK, "Failed to create a sample, hr %#lx.\n", hr); + + memset(&output_buffer, 0, sizeof(output_buffer)); + output_buffer.pSample = sample; + flags = 0; + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); + todo_wine + ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "Unexpected hr %#lx.\n", hr); + ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); + ok(flags == 0, "Unexpected status %#lx.\n", flags); + + hr = IMFTransform_ProcessInput(transform, 0, sample2, 0); + todo_wine + ok(hr == S_OK, "Failed to push a sample, hr %#lx.\n", hr); + + hr = IMFTransform_ProcessInput(transform, 0, sample2, 0); + todo_wine + ok(hr == MF_E_NOTACCEPTING, "Unexpected hr %#lx.\n", hr); + + memset(&output_buffer, 0, sizeof(output_buffer)); + output_buffer.pSample = sample; + flags = 0; + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); + todo_wine + ok(hr == MF_E_NO_SAMPLE_TIMESTAMP, "Unexpected hr %#lx.\n", hr); + ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); + ok(flags == 0, "Unexpected status %#lx.\n", flags);
- hr = CoInitialize(NULL); - ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr); + hr = IMFSample_SetSampleTime(sample2, 0); + ok(hr == S_OK, "Failed to set sample time, hr %#lx.\n", hr); + memset(&output_buffer, 0, sizeof(output_buffer)); + output_buffer.pSample = sample; + flags = 0; + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); + todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); + ok(flags == 0, "Unexpected status %#lx.\n", flags);
- if (!create_transform(MFT_CATEGORY_VIDEO_EFFECT, &input_type, &output_type, L"Color Converter MFT", &MFMediaType_Video, - transform_inputs, ARRAY_SIZE(transform_inputs), transform_outputs, ARRAY_SIZE(transform_outputs), - &transform, &CLSID_CColorConvertDMO, &class_id)) - goto failed; + hr = MFCreateMemoryBuffer(1024 * 1024, &buffer); + ok(hr == S_OK, "Failed to create a buffer, hr %#lx.\n", hr);
- check_dmo(&CLSID_CColorConvertDMO, L"Color Converter DMO", &MEDIATYPE_Video, dmo_inputs, ARRAY_SIZE(dmo_inputs), - dmo_outputs, ARRAY_SIZE(dmo_outputs)); + hr = IMFSample_AddBuffer(sample2, buffer); + ok(hr == S_OK, "Failed to add a buffer, hr %#lx.\n", hr);
- check_interface(transform, &IID_IMFTransform, TRUE); - check_interface(transform, &IID_IMediaObject, TRUE); - check_interface(transform, &IID_IPropertyStore, TRUE); + hr = IMFSample_AddBuffer(sample, buffer); + ok(hr == S_OK, "Failed to add a buffer, hr %#lx.\n", hr); + + memset(&output_buffer, 0, sizeof(output_buffer)); + output_buffer.pSample = sample; + flags = 0; + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); todo_wine - check_interface(transform, &IID_IMFRealTimeClient, TRUE); - /* check_interface(transform, &IID_IWMColorConvProps, TRUE); */ + ok(hr == S_OK || broken(FAILED(hr)) /* Win8 */, "Failed to get output buffer, hr %#lx.\n", hr); + ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); + ok(flags == 0, "Unexpected status %#lx.\n", flags); + + if (SUCCEEDED(hr)) + { + memset(&output_buffer, 0, sizeof(output_buffer)); + output_buffer.pSample = sample; + flags = 0; + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output_buffer, &flags); + ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "Unexpected hr %#lx.\n", hr); + ok(output_buffer.dwStatus == 0, "Unexpected buffer status, %#lx.\n", output_buffer.dwStatus); + ok(flags == 0, "Unexpected status %#lx.\n", flags); + } + + ref = IMFTransform_Release(transform); + ok(ref == 0, "Release returned %ld\n", ref); + + ref = IMFMediaType_Release(media_type); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFSample_Release(sample2); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFSample_Release(sample); + ok(ref == 0, "Release returned %ld\n", ref); + ref = IMFMediaBuffer_Release(buffer); + ok(ref == 0, "Release returned %ld\n", ref); + + + hr = CoCreateInstance(&class_id, NULL, CLSCTX_INPROC_SERVER, &IID_IMFTransform, (void **)&transform); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
/* check default media types */
+ memset(&input_info, 0xcd, sizeof(input_info)); hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetInputStreamInfo returned %#lx\n", hr); + todo_wine + ok(hr == S_OK, "GetInputStreamInfo returned %#lx\n", hr); + todo_wine + ok(input_info.hnsMaxLatency == 0, "got hnsMaxLatency %s\n", wine_dbgstr_longlong(input_info.hnsMaxLatency)); + todo_wine + ok(input_info.dwFlags == 0, "got dwFlags %#lx\n", input_info.dwFlags); + todo_wine + ok(input_info.cbSize == 0, "got cbSize %#lx\n", input_info.cbSize); + todo_wine + ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#lx\n", input_info.cbMaxLookahead); + todo_wine + ok(input_info.cbAlignment == 0, "got cbAlignment %#lx\n", input_info.cbAlignment); + + memset(&output_info, 0xcd, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#lx\n", hr); + todo_wine + ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); + todo_wine + ok(output_info.dwFlags == 0, "got dwFlags %#lx\n", output_info.dwFlags); + todo_wine + ok(output_info.cbSize == 0, "got cbSize %#lx\n", output_info.cbSize); + todo_wine + ok(output_info.cbAlignment == 0, "got cbAlignment %#lx\n", output_info.cbAlignment);
- i = -1; - while (SUCCEEDED(hr = IMFTransform_GetOutputAvailableType(transform, 0, ++i, &media_type))) + hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); + todo_wine + ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); + + hr = IMFTransform_GetInputAvailableType(transform, 0, 23, &media_type); + todo_wine + ok(hr == S_OK || hr == MF_E_NO_MORE_TYPES /* w8 */, "GetOutputAvailableType returned %#lx\n", hr); + if (hr == MF_E_NO_MORE_TYPES) + expect_available_inputs = expect_available_inputs_w8; + else { - winetest_push_context("out %lu", i); - ok(hr == S_OK, "GetOutputAvailableType returned %#lx\n", hr); - check_media_type(media_type, expect_available_common, -1); - check_media_type(media_type, expect_available_outputs[i], -1); - ret = IMFMediaType_Release(media_type); - ok(ret == 0, "Release returned %lu\n", ret); - winetest_pop_context(); + hr = IMFTransform_GetInputAvailableType(transform, 0, 27, &media_type); + todo_wine + ok(hr == S_OK || broken(hr == MF_E_NO_MORE_TYPES) /* w1064v1507 */, "GetOutputAvailableType returned %#lx\n", hr); + if (hr == MF_E_NO_MORE_TYPES) + expect_available_inputs = expect_available_inputs_w10 + 3; + else + expect_available_inputs = expect_available_inputs_w10; } - ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); - ok(i == 16, "%lu output media types\n", i);
i = -1; while (SUCCEEDED(hr = IMFTransform_GetInputAvailableType(transform, 0, ++i, &media_type))) { + /* FIXME: Skip exotic input types which aren't directly accepted */ + if (IsEqualGUID(&expect_available_inputs[i], &MFVideoFormat_L8) + || IsEqualGUID(&expect_available_inputs[i], &MFVideoFormat_L16) + || IsEqualGUID(&expect_available_inputs[i], &MFAudioFormat_MPEG) + || IsEqualGUID(&expect_available_inputs[i], &MFVideoFormat_420O) + || IsEqualGUID(&expect_available_inputs[i], &MFVideoFormat_A16B16G16R16F) /* w1064v1507 */) + continue; + winetest_push_context("in %lu", i); ok(hr == S_OK, "GetInputAvailableType returned %#lx\n", hr); check_media_type(media_type, expect_available_common, -1); - check_media_type(media_type, expect_available_inputs[i], -1); + + hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "GetGUID returned %#lx\n", hr); + + /* w1064v1507 doesn't expose MFVideoFormat_ABGR32 input */ + if (broken(IsEqualGUID(&expect_available_inputs[i], &MFVideoFormat_ABGR32) + && IsEqualGUID(&guid, &MFVideoFormat_RGB32))) + expect_available_inputs++; + + ok(IsEqualGUID(&expect_available_inputs[i], &guid), "got subtype %s\n", debugstr_guid(&guid)); + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - if (i == 12) + ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); + + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)actual_width << 32 | actual_height); + ok(hr == S_OK, "SetUINT64 returned %#lx.\n", hr); + hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + + hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type2); + ok(hr == S_OK, "GetOutputAvailableType returned %#lx.\n", hr); + hr = IMFMediaType_IsEqual(media_type, media_type2, &flags); + ok(hr == S_OK, "IsEqual returned %#lx.\n", hr); + + ret = IMFMediaType_Release(media_type); + ok(ret == 1, "Release returned %lu\n", ret); + + j = k = 0; + while (SUCCEEDED(hr = IMFTransform_GetOutputAvailableType(transform, 0, ++j, &media_type))) { - todo_wine - ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); + winetest_push_context("out %lu", j); + ok(hr == S_OK, "GetOutputAvailableType returned %#lx\n", hr); + check_media_type(media_type, expect_available_common, -1); + + hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "GetGUID returned %#lx\n", hr); + + for (; k < ARRAY_SIZE(expect_available_outputs); k++) + if (IsEqualGUID(&expect_available_outputs[k], &guid)) + break; + ok(k < ARRAY_SIZE(expect_available_outputs), "got subtype %s\n", debugstr_guid(&guid)); + + ret = IMFMediaType_Release(media_type); + ok(ret == 0, "Release returned %lu\n", ret); + winetest_pop_context(); } - else - ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); - ret = IMFMediaType_Release(media_type); - ok(ret == 0, "Release returned %lu\n", ret); + ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); + winetest_pop_context(); } + todo_wine ok(hr == MF_E_NO_MORE_TYPES, "GetInputAvailableType returned %#lx\n", hr); - ok(i == 20, "%lu input media types\n", i); - - /* check required output media type attributes */ - - hr = MFCreateMediaType(&media_type); - ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\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); - ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, i + 1); - } - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); - ret = IMFMediaType_Release(media_type); - ok(ret == 0, "Release returned %lu\n", ret); + todo_wine + ok(i == 22 || i == 30 || broken(i == 26) /* w1064v1507 */, "%lu input media types\n", i);
/* check required input media type attributes */
hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); + todo_wine + ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); init_media_type(media_type, input_type_desc, 1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); + todo_wine + ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); init_media_type(media_type, input_type_desc, 2); for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) { hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); + todo_wine + ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); init_media_type(media_type, input_type_desc, i + 1); } hr = IMFTransform_SetInputType(transform, 0, media_type, 0); + todo_wine ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); - ok(ret == 0, "Release returned %lu\n", ret); + todo_wine + ok(ret == 1, "Release returned %lu\n", ret); + + /* check required output media type attributes */ + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); + hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); + todo_wine + ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\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_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\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_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\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 %#lx.\n", hr); + ret = IMFMediaType_Release(media_type); + todo_wine + ok(ret == 1, "Release returned %lu\n", ret);
memset(&input_info, 0xcd, sizeof(input_info)); hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); + todo_wine ok(hr == S_OK, "GetInputStreamInfo returned %#lx\n", hr); + todo_wine ok(input_info.hnsMaxLatency == 0, "got hnsMaxLatency %s\n", wine_dbgstr_longlong(input_info.hnsMaxLatency)); + todo_wine ok(input_info.dwFlags == 0, "got dwFlags %#lx\n", input_info.dwFlags); + todo_wine ok(input_info.cbSize == actual_width * actual_height * 3 / 2, "got cbSize %#lx\n", input_info.cbSize); + todo_wine ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#lx\n", input_info.cbMaxLookahead); - ok(input_info.cbAlignment == 1, "got cbAlignment %#lx\n", input_info.cbAlignment); + todo_wine + ok(input_info.cbAlignment == 0, "got cbAlignment %#lx\n", input_info.cbAlignment);
memset(&output_info, 0xcd, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); + todo_wine ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); + todo_wine ok(output_info.dwFlags == 0, "got dwFlags %#lx\n", output_info.dwFlags); + todo_wine ok(output_info.cbSize == actual_width * actual_height * 4, "got cbSize %#lx\n", output_info.cbSize); - ok(output_info.cbAlignment == 1, "got cbAlignment %#lx\n", output_info.cbAlignment); + todo_wine + ok(output_info.cbAlignment == 0, "got cbAlignment %#lx\n", output_info.cbAlignment);
resource = FindResourceW(NULL, L"nv12frame.bin", (const WCHAR *)RT_RCDATA); ok(resource != 0, "FindResourceW failed, error %lu\n", GetLastError()); @@ -8629,35 +9023,47 @@ static void test_color_convert(void) hr = IMFSample_SetSampleDuration(sample, 10000000); ok(hr == S_OK, "SetSampleDuration returned %#lx\n", hr); hr = IMFTransform_ProcessInput(transform, 0, sample, 0); + todo_wine ok(hr == S_OK, "ProcessInput returned %#lx\n", hr); hr = IMFTransform_ProcessInput(transform, 0, sample, 0); + todo_wine ok(hr == MF_E_NOTACCEPTING, "ProcessInput returned %#lx\n", hr); hr = IMFTransform_ProcessMessage(transform, MFT_MESSAGE_COMMAND_DRAIN, 0); + todo_wine ok(hr == S_OK, "ProcessMessage returned %#lx\n", hr); ret = IMFSample_Release(sample); ok(ret <= 1, "Release returned %ld\n", ret);
- resource = FindResourceW(NULL, L"rgb32frame.bin", (const WCHAR *)RT_RCDATA); + resource = FindResourceW(NULL, L"rgb32frame-vp.bin", (const WCHAR *)RT_RCDATA); ok(resource != 0, "FindResourceW failed, error %lu\n", GetLastError()); rgb32_data = LockResource(LoadResource(GetModuleHandleW(NULL), resource)); rgb32_data_len = SizeofResource(GetModuleHandleW(NULL), resource); + todo_wine ok(rgb32_data_len == output_info.cbSize, "got length %lu\n", rgb32_data_len);
/* and generate a new one as well in a temporary directory */ GetTempPathW(ARRAY_SIZE(output_path), output_path); - lstrcatW(output_path, L"rgb32frame.bin"); + lstrcatW(output_path, L"rgb32frame-vp.bin"); output_file = CreateFileW(output_path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); ok(output_file != INVALID_HANDLE_VALUE, "CreateFileW failed, error %lu\n", GetLastError());
status = 0xdeadbeef; - sample = create_sample(NULL, output_info.cbSize); + sample = create_sample(NULL, rgb32_data_len); memset(&output, 0, sizeof(output)); output.pSample = sample; hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); - ok(hr == S_OK, "ProcessOutput returned %#lx\n", hr); + todo_wine + ok(hr == S_OK || broken(hr == MF_E_SHUTDOWN) /* w8 */, "ProcessOutput returned %#lx\n", hr); + if (hr != S_OK) + { + todo_wine + win_skip("ProcessOutput returned MF_E_SHUTDOWN, skipping tests.\n"); + CloseHandle(output_file); + goto skip_output; + } ok(output.pSample == sample, "got pSample %p\n", output.pSample); ok(output.dwStatus == 0 || broken(output.dwStatus == 6) /* win7 */, "got dwStatus %#lx\n", output.dwStatus); - ok(status == 0, "got status %#lx\n", status); + ok(status == 0xdeadbeef, "got status %#lx\n", status);
hr = IMFSample_GetSampleTime(sample, &time); ok(hr == S_OK, "GetSampleTime returned %#lx\n", hr); @@ -8668,7 +9074,22 @@ static void test_color_convert(void) hr = IMFSample_GetTotalLength(sample, &length); ok(hr == S_OK, "GetTotalLength returned %#lx\n", hr); ok(length == output_info.cbSize, "got length %lu\n", length); - check_sample_rgb32(sample, rgb32_data, output_file); + + hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer); + ok(hr == S_OK, "ConvertToContiguousBuffer returned %#lx\n", hr); + hr = IMFMediaBuffer_Lock(buffer, &ptr, NULL, &length); + ok(hr == S_OK, "Lock returned %#lx\n", hr); + tmp = *ptr; + hr = IMFMediaBuffer_Unlock(buffer); + ok(hr == S_OK, "Lock returned %#lx\n", hr); + IMFMediaBuffer_Release(buffer); + + /* w1064v1809 ignores MF_MT_MINIMUM_DISPLAY_APERTURE and resizes the frame */ + ok(tmp == 0xcd || broken(tmp == 0x00), "got %#x\n", tmp); + if (tmp == 0x00) + win_skip("Frame got resized, skipping output comparison\n"); + else + check_sample_rgb32(sample, rgb32_data, output_file); rgb32_data_len -= output_info.cbSize; rgb32_data += output_info.cbSize;
@@ -8686,10 +9107,12 @@ static void test_color_convert(void) ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); ok(output.pSample == sample, "got pSample %p\n", output.pSample); ok(output.dwStatus == 0, "got dwStatus %#lx\n", output.dwStatus); - ok(status == 0, "got status %#lx\n", status); + ok(status == 0xdeadbeef, "got status %#lx\n", status); hr = IMFSample_GetTotalLength(sample, &length); ok(hr == S_OK, "GetTotalLength returned %#lx\n", hr); ok(length == 0, "got length %lu\n", length); + +skip_output: ret = IMFSample_Release(sample); ok(ret == 0, "Release returned %lu\n", ret);
diff --git a/dlls/mf/tests/resource.rc b/dlls/mf/tests/resource.rc index 35cdc5d3ca9..e9a3cd0609c 100644 --- a/dlls/mf/tests/resource.rc +++ b/dlls/mf/tests/resource.rc @@ -52,3 +52,7 @@ i420frame.bin RCDATA i420frame.bin /* Generated from running the tests on Windows */ /* @makedep: rgb32frame.bin */ rgb32frame.bin RCDATA rgb32frame.bin + +/* Generated from running the tests on Windows */ +/* @makedep: rgb32frame-vp.bin */ +rgb32frame-vp.bin RCDATA rgb32frame-vp.bin diff --git a/dlls/mf/tests/rgb32frame-vp.bin b/dlls/mf/tests/rgb32frame-vp.bin new file mode 100644 index 0000000000000000000000000000000000000000..46d93a9c40b5d875c821580dd1db984d3b97217a GIT binary patch literal 36864 zcmeI&Q3}E^5Jl0r|FyX#V~aa@2~0B{p`T-%+d~oY{q|Bo0R<FLKmi35P(T3%6i`3` z1r+F9V2&|e>kU#P+ON028|uHOW9m_V{Zl&~=J@BogX44u{`pVsbeQ9x{|=7R9r!=f z{}`X^mb>x>zn{-i|M|J@*{_}cwTAT9|DT^l{PWMh?>|)rJbyfYs_Z@CT>klgg2SrM zu;%}B{cPo0Z;*cf(SE)C-BABM9aE3`>z~@`Fvmat9UP}S@Xvp0r^6io{C9Ai?!f<< z{$F!U*Ls80zxM0x?}qyC>6m)dU;orjhdKWF@8CGyfq(u}J00fu=f8vFbO-*=^nd+( zXu8%Lr2e&EZ+|z`e^1BMqyGA*b~?=Q&wmHU=??t!pW5j#$3Ooa9H%?*f2RN1Pn~Le z-dyTm|2_9o|2-X3kNWGM+UYRIKmQ#Zr#tY^e`=@09RK`xaGdVI|C#=;KmT}bD3JQ! saJ09$3g}<UK!5#f3)G&@zy7raYES21|Jnkzr}M9WZGqa;`9HJ&7dsQ;1ONa4
literal 0 HcmV?d00001