evr/tests: Add a test for MF_SA_REQUIRED_SAMPLE_COUNT.
[wine.git] / dlls / evr / tests / evr.c
blob72642110a78f1f1b3e3f092f1f40fc795e11d8d3
1 /*
2 * Enhanced Video Renderer filter unit tests
4 * Copyright 2018 Zebediah Figura
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "dshow.h"
24 #include "wine/test.h"
25 #include "d3d9.h"
26 #include "evr.h"
27 #include "mferror.h"
28 #include "mfapi.h"
29 #include "initguid.h"
30 #include "evr9.h"
32 static const WCHAR sink_id[] = {'E','V','R',' ','I','n','p','u','t','0',0};
34 static HRESULT (WINAPI *pMFCreateVideoMediaTypeFromSubtype)(const GUID *subtype, IMFVideoMediaType **video_type);
36 static void set_rect(MFVideoNormalizedRect *rect, float left, float top, float right, float bottom)
38 rect->left = left;
39 rect->top = top;
40 rect->right = right;
41 rect->bottom = bottom;
44 static HWND create_window(void)
46 RECT r = {0, 0, 640, 480};
48 AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW | WS_VISIBLE, FALSE);
50 return CreateWindowA("static", "evr_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
51 0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
54 static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window)
56 D3DPRESENT_PARAMETERS present_parameters = {0};
57 IDirect3DDevice9 *device = NULL;
59 present_parameters.BackBufferWidth = 640;
60 present_parameters.BackBufferHeight = 480;
61 present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
62 present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
63 present_parameters.hDeviceWindow = focus_window;
64 present_parameters.Windowed = TRUE;
65 present_parameters.EnableAutoDepthStencil = TRUE;
66 present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
68 IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, focus_window,
69 D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
71 return device;
74 static IBaseFilter *create_evr(void)
76 IBaseFilter *filter = NULL;
77 HRESULT hr = CoCreateInstance(&CLSID_EnhancedVideoRenderer, NULL, CLSCTX_INPROC_SERVER,
78 &IID_IBaseFilter, (void **)&filter);
79 ok(hr == S_OK, "Got hr %#x.\n", hr);
80 return filter;
83 static ULONG get_refcount(void *iface)
85 IUnknown *unknown = iface;
86 IUnknown_AddRef(unknown);
87 return IUnknown_Release(unknown);
90 static const GUID test_iid = {0x33333333};
91 static LONG outer_ref = 1;
93 static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
95 if (IsEqualGUID(iid, &IID_IUnknown)
96 || IsEqualGUID(iid, &IID_IBaseFilter)
97 || IsEqualGUID(iid, &test_iid))
99 *out = (IUnknown *)0xdeadbeef;
100 return S_OK;
102 ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
103 return E_NOINTERFACE;
106 static ULONG WINAPI outer_AddRef(IUnknown *iface)
108 return InterlockedIncrement(&outer_ref);
111 static ULONG WINAPI outer_Release(IUnknown *iface)
113 return InterlockedDecrement(&outer_ref);
116 static const IUnknownVtbl outer_vtbl =
118 outer_QueryInterface,
119 outer_AddRef,
120 outer_Release,
123 static IUnknown test_outer = {&outer_vtbl};
125 static void test_aggregation(void)
127 IBaseFilter *filter, *filter2;
128 IMFVideoPresenter *presenter;
129 IUnknown *unk, *unk2;
130 IMFTransform *mixer;
131 HRESULT hr;
132 ULONG ref;
134 filter = (IBaseFilter *)0xdeadbeef;
135 hr = CoCreateInstance(&CLSID_EnhancedVideoRenderer, &test_outer, CLSCTX_INPROC_SERVER,
136 &IID_IBaseFilter, (void **)&filter);
137 ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
138 ok(!filter, "Got interface %p.\n", filter);
140 hr = CoCreateInstance(&CLSID_EnhancedVideoRenderer, &test_outer, CLSCTX_INPROC_SERVER,
141 &IID_IUnknown, (void **)&unk);
142 ok(hr == S_OK, "Got hr %#x.\n", hr);
143 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
144 ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
145 ref = get_refcount(unk);
146 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
148 ref = IUnknown_AddRef(unk);
149 ok(ref == 2, "Got unexpected refcount %d.\n", ref);
150 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
152 ref = IUnknown_Release(unk);
153 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
154 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
156 hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
157 ok(hr == S_OK, "Got hr %#x.\n", hr);
158 ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
159 IUnknown_Release(unk2);
161 hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
162 ok(hr == S_OK, "Got hr %#x.\n", hr);
164 hr = IBaseFilter_QueryInterface(filter, &IID_IUnknown, (void **)&unk2);
165 ok(hr == S_OK, "Got hr %#x.\n", hr);
166 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
168 hr = IBaseFilter_QueryInterface(filter, &IID_IBaseFilter, (void **)&filter2);
169 ok(hr == S_OK, "Got hr %#x.\n", hr);
170 ok(filter2 == (IBaseFilter *)0xdeadbeef, "Got unexpected IBaseFilter %p.\n", filter2);
172 hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
173 ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
174 ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
176 hr = IBaseFilter_QueryInterface(filter, &test_iid, (void **)&unk2);
177 ok(hr == S_OK, "Got hr %#x.\n", hr);
178 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
180 IBaseFilter_Release(filter);
181 ref = IUnknown_Release(unk);
182 ok(!ref, "Got unexpected refcount %d.\n", ref);
183 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
185 /* Default presenter. */
186 presenter = (void *)0xdeadbeef;
187 hr = CoCreateInstance(&CLSID_MFVideoPresenter9, &test_outer, CLSCTX_INPROC_SERVER, &IID_IMFVideoPresenter,
188 (void **)&presenter);
189 ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
190 ok(!presenter, "Got interface %p.\n", presenter);
192 hr = CoCreateInstance(&CLSID_MFVideoPresenter9, &test_outer, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk);
193 ok(hr == S_OK || broken(hr == E_FAIL) /* WinXP */, "Unexpected hr %#x.\n", hr);
194 if (SUCCEEDED(hr))
196 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
197 ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
198 ref = get_refcount(unk);
199 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
201 IUnknown_Release(unk);
204 /* Default mixer. */
205 presenter = (void *)0xdeadbeef;
206 hr = CoCreateInstance(&CLSID_MFVideoMixer9, &test_outer, CLSCTX_INPROC_SERVER, &IID_IMFTransform,
207 (void **)&mixer);
208 ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
209 ok(!mixer, "Got interface %p.\n", mixer);
211 hr = CoCreateInstance(&CLSID_MFVideoMixer9, &test_outer, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk);
212 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
213 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
214 ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
215 ref = get_refcount(unk);
216 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
218 IUnknown_Release(unk);
221 #define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
222 static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
224 IUnknown *iface = iface_ptr;
225 HRESULT hr, expected_hr;
226 IUnknown *unk;
228 expected_hr = supported ? S_OK : E_NOINTERFACE;
230 hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
231 ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr);
232 if (SUCCEEDED(hr))
233 IUnknown_Release(unk);
236 static void test_interfaces(void)
238 IBaseFilter *filter = create_evr();
239 ULONG ref;
241 todo_wine check_interface(filter, &IID_IAMFilterMiscFlags, TRUE);
242 check_interface(filter, &IID_IBaseFilter, TRUE);
243 check_interface(filter, &IID_IMediaFilter, TRUE);
244 check_interface(filter, &IID_IMediaPosition, TRUE);
245 check_interface(filter, &IID_IMediaSeeking, TRUE);
246 check_interface(filter, &IID_IPersist, TRUE);
247 check_interface(filter, &IID_IUnknown, TRUE);
249 check_interface(filter, &IID_IBasicAudio, FALSE);
250 check_interface(filter, &IID_IBasicVideo, FALSE);
251 check_interface(filter, &IID_IDirectXVideoMemoryConfiguration, FALSE);
252 check_interface(filter, &IID_IMemInputPin, FALSE);
253 check_interface(filter, &IID_IPersistPropertyBag, FALSE);
254 check_interface(filter, &IID_IPin, FALSE);
255 check_interface(filter, &IID_IReferenceClock, FALSE);
256 check_interface(filter, &IID_IVideoWindow, FALSE);
258 ref = IBaseFilter_Release(filter);
259 ok(!ref, "Got unexpected refcount %d.\n", ref);
262 static void test_enum_pins(void)
264 IBaseFilter *filter = create_evr();
265 IEnumPins *enum1, *enum2;
266 ULONG count, ref;
267 IPin *pins[2];
268 HRESULT hr;
270 ref = get_refcount(filter);
271 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
273 hr = IBaseFilter_EnumPins(filter, NULL);
274 ok(hr == E_POINTER, "Got hr %#x.\n", hr);
276 hr = IBaseFilter_EnumPins(filter, &enum1);
277 ok(hr == S_OK, "Got hr %#x.\n", hr);
278 ref = get_refcount(filter);
279 ok(ref == 2, "Got unexpected refcount %d.\n", ref);
280 ref = get_refcount(enum1);
281 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
283 hr = IEnumPins_Next(enum1, 1, NULL, NULL);
284 ok(hr == E_POINTER, "Got hr %#x.\n", hr);
286 hr = IEnumPins_Next(enum1, 1, pins, NULL);
287 ok(hr == S_OK, "Got hr %#x.\n", hr);
288 ref = get_refcount(filter);
289 ok(ref == 3, "Got unexpected refcount %d.\n", ref);
290 ref = get_refcount(pins[0]);
291 ok(ref == 3, "Got unexpected refcount %d.\n", ref);
292 ref = get_refcount(enum1);
293 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
294 IPin_Release(pins[0]);
295 ref = get_refcount(filter);
296 ok(ref == 2, "Got unexpected refcount %d.\n", ref);
298 hr = IEnumPins_Next(enum1, 1, pins, NULL);
299 ok(hr == S_FALSE, "Got hr %#x.\n", hr);
301 hr = IEnumPins_Reset(enum1);
302 ok(hr == S_OK, "Got hr %#x.\n", hr);
304 hr = IEnumPins_Next(enum1, 1, pins, &count);
305 ok(hr == S_OK, "Got hr %#x.\n", hr);
306 ok(count == 1, "Got count %u.\n", count);
307 IPin_Release(pins[0]);
309 hr = IEnumPins_Next(enum1, 1, pins, &count);
310 ok(hr == S_FALSE, "Got hr %#x.\n", hr);
311 ok(!count, "Got count %u.\n", count);
313 hr = IEnumPins_Reset(enum1);
314 ok(hr == S_OK, "Got hr %#x.\n", hr);
316 hr = IEnumPins_Next(enum1, 2, pins, NULL);
317 ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
319 hr = IEnumPins_Next(enum1, 2, pins, &count);
320 ok(hr == S_FALSE, "Got hr %#x.\n", hr);
321 ok(count == 1, "Got count %u.\n", count);
322 IPin_Release(pins[0]);
324 hr = IEnumPins_Reset(enum1);
325 ok(hr == S_OK, "Got hr %#x.\n", hr);
327 hr = IEnumPins_Clone(enum1, &enum2);
328 ok(hr == S_OK, "Got hr %#x.\n", hr);
330 hr = IEnumPins_Skip(enum1, 2);
331 ok(hr == S_FALSE, "Got hr %#x.\n", hr);
333 hr = IEnumPins_Skip(enum1, 1);
334 ok(hr == S_OK, "Got hr %#x.\n", hr);
336 hr = IEnumPins_Skip(enum1, 1);
337 ok(hr == S_FALSE, "Got hr %#x.\n", hr);
339 hr = IEnumPins_Next(enum1, 1, pins, NULL);
340 ok(hr == S_FALSE, "Got hr %#x.\n", hr);
342 hr = IEnumPins_Next(enum2, 1, pins, NULL);
343 ok(hr == S_OK, "Got hr %#x.\n", hr);
344 IPin_Release(pins[0]);
346 IEnumPins_Release(enum2);
347 IEnumPins_Release(enum1);
348 ref = IBaseFilter_Release(filter);
349 ok(!ref, "Got outstanding refcount %d.\n", ref);
352 static void test_find_pin(void)
354 IBaseFilter *filter = create_evr();
355 IEnumPins *enum_pins;
356 IPin *pin, *pin2;
357 HRESULT hr;
358 ULONG ref;
360 hr = IBaseFilter_EnumPins(filter, &enum_pins);
361 ok(hr == S_OK, "Got hr %#x.\n", hr);
363 hr = IBaseFilter_FindPin(filter, sink_id, &pin);
364 ok(hr == S_OK, "Got hr %#x.\n", hr);
365 hr = IEnumPins_Next(enum_pins, 1, &pin2, NULL);
366 ok(hr == S_OK, "Got hr %#x.\n", hr);
367 ok(pin2 == pin, "Expected pin %p, got %p.\n", pin, pin2);
368 IPin_Release(pin2);
369 IPin_Release(pin);
371 IEnumPins_Release(enum_pins);
372 ref = IBaseFilter_Release(filter);
373 ok(!ref, "Got outstanding refcount %d.\n", ref);
376 static void test_pin_info(void)
378 IBaseFilter *filter = create_evr();
379 PIN_DIRECTION dir;
380 PIN_INFO info;
381 HRESULT hr;
382 WCHAR *id;
383 ULONG ref;
384 IPin *pin;
386 hr = IBaseFilter_FindPin(filter, sink_id, &pin);
387 ok(hr == S_OK, "Got hr %#x.\n", hr);
388 ref = get_refcount(filter);
389 ok(ref == 2, "Got unexpected refcount %d.\n", ref);
390 ref = get_refcount(pin);
391 ok(ref == 2, "Got unexpected refcount %d.\n", ref);
393 hr = IPin_QueryPinInfo(pin, &info);
394 ok(hr == S_OK, "Got hr %#x.\n", hr);
395 ok(info.pFilter == filter, "Expected filter %p, got %p.\n", filter, info.pFilter);
396 ok(info.dir == PINDIR_INPUT, "Got direction %d.\n", info.dir);
397 ok(!lstrcmpW(info.achName, sink_id), "Got name %s.\n", wine_dbgstr_w(info.achName));
398 ref = get_refcount(filter);
399 ok(ref == 3, "Got unexpected refcount %d.\n", ref);
400 ref = get_refcount(pin);
401 ok(ref == 3, "Got unexpected refcount %d.\n", ref);
402 IBaseFilter_Release(info.pFilter);
404 hr = IPin_QueryDirection(pin, &dir);
405 ok(hr == S_OK, "Got hr %#x.\n", hr);
406 ok(dir == PINDIR_INPUT, "Got direction %d.\n", dir);
408 hr = IPin_QueryId(pin, &id);
409 ok(hr == S_OK, "Got hr %#x.\n", hr);
410 ok(!lstrcmpW(id, sink_id), "Got id %s.\n", wine_dbgstr_w(id));
411 CoTaskMemFree(id);
413 hr = IPin_QueryInternalConnections(pin, NULL, NULL);
414 ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr);
416 IPin_Release(pin);
417 ref = IBaseFilter_Release(filter);
418 ok(!ref, "Got outstanding refcount %d.\n", ref);
421 static void test_default_mixer(void)
423 DWORD input_min, input_max, output_min, output_max;
424 IMFAttributes *attributes, *attributes2;
425 IMFVideoMixerControl2 *mixer_control2;
426 MFT_OUTPUT_STREAM_INFO output_info;
427 MFT_INPUT_STREAM_INFO input_info;
428 DWORD input_count, output_count;
429 IMFVideoProcessor *processor;
430 IMFVideoDeviceID *deviceid;
431 MFVideoNormalizedRect rect;
432 DWORD input_id, output_id;
433 IMFTransform *transform;
434 DXVA2_ValueRange range;
435 DXVA2_Fixed32 dxva_value;
436 DWORD flags, value, count;
437 IMFGetService *gs;
438 COLORREF color;
439 unsigned int i;
440 DWORD ids[16];
441 IUnknown *unk;
442 GUID *guids;
443 HRESULT hr;
444 IID iid;
446 hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&transform);
447 ok(hr == S_OK, "Failed to create default mixer, hr %#x.\n", hr);
449 hr = IMFTransform_QueryInterface(transform, &IID_IMFQualityAdvise, (void **)&unk);
450 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
451 IUnknown_Release(unk);
453 hr = IMFTransform_QueryInterface(transform, &IID_IMFTopologyServiceLookupClient, (void **)&unk);
454 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
455 IUnknown_Release(unk);
457 hr = IMFTransform_QueryInterface(transform, &IID_IMFGetService, (void **)&gs);
458 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
460 hr = IMFGetService_GetService(gs, &MR_VIDEO_MIXER_SERVICE, &IID_IMFVideoMixerBitmap, (void **)&unk);
461 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
462 IUnknown_Release(unk);
464 hr = IMFGetService_GetService(gs, &MR_VIDEO_MIXER_SERVICE, &IID_IMFVideoProcessor, (void **)&processor);
465 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
467 hr = IMFGetService_GetService(gs, &MR_VIDEO_MIXER_SERVICE, &IID_IMFVideoMixerControl, (void **)&unk);
468 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
469 IUnknown_Release(unk);
471 if (SUCCEEDED(IMFGetService_GetService(gs, &MR_VIDEO_MIXER_SERVICE, &IID_IMFVideoMixerControl2, (void **)&mixer_control2)))
473 hr = IMFVideoMixerControl2_GetMixingPrefs(mixer_control2, NULL);
474 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
476 hr = IMFVideoMixerControl2_GetMixingPrefs(mixer_control2, &flags);
477 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
478 ok(!flags, "Unexpected flags %#x.\n", flags);
480 IMFVideoMixerControl2_Release(mixer_control2);
483 hr = IMFVideoProcessor_GetBackgroundColor(processor, NULL);
484 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
486 color = 1;
487 hr = IMFVideoProcessor_GetBackgroundColor(processor, &color);
488 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
489 ok(!color, "Unexpected color %#x.\n", color);
491 hr = IMFVideoProcessor_SetBackgroundColor(processor, 0x00121212);
492 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
494 hr = IMFVideoProcessor_GetBackgroundColor(processor, &color);
495 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
496 ok(color == 0x121212, "Unexpected color %#x.\n", color);
498 hr = IMFVideoProcessor_GetFilteringRange(processor, DXVA2_DetailFilterChromaLevel, &range);
499 todo_wine
500 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
502 hr = IMFVideoProcessor_GetFilteringValue(processor, DXVA2_DetailFilterChromaLevel, &dxva_value);
503 todo_wine
504 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
506 hr = IMFVideoProcessor_GetAvailableVideoProcessorModes(processor, &count, &guids);
507 todo_wine
508 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
510 IMFVideoProcessor_Release(processor);
512 hr = IMFGetService_GetService(gs, &MR_VIDEO_MIXER_SERVICE, &IID_IMFVideoPositionMapper, (void **)&unk);
513 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
514 IUnknown_Release(unk);
516 IMFGetService_Release(gs);
518 hr = IMFTransform_QueryInterface(transform, &IID_IMFVideoMixerBitmap, (void **)&unk);
519 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
520 IUnknown_Release(unk);
522 hr = IMFTransform_QueryInterface(transform, &IID_IMFVideoPositionMapper, (void **)&unk);
523 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
524 IUnknown_Release(unk);
526 hr = IMFTransform_QueryInterface(transform, &IID_IMFVideoProcessor, (void **)&unk);
527 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
528 IUnknown_Release(unk);
530 hr = IMFTransform_QueryInterface(transform, &IID_IMFVideoMixerControl, (void **)&unk);
531 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
532 IUnknown_Release(unk);
534 hr = IMFTransform_SetOutputBounds(transform, 100, 10);
535 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
537 hr = IMFTransform_QueryInterface(transform, &IID_IMFVideoDeviceID, (void **)&deviceid);
538 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
540 hr = IMFTransform_GetAttributes(transform, NULL);
541 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
543 hr = IMFTransform_GetAttributes(transform, &attributes);
544 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
546 hr = IMFTransform_GetAttributes(transform, &attributes2);
547 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
548 ok(attributes == attributes2, "Unexpected attributes instance.\n");
549 IMFAttributes_Release(attributes2);
551 hr = IMFTransform_QueryInterface(transform, &IID_IMFAttributes, (void **)&attributes2);
552 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
553 ok(attributes != attributes2, "Unexpected attributes instance.\n");
555 hr = IMFAttributes_QueryInterface(attributes2, &IID_IMFTransform, (void **)&unk);
556 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
557 IUnknown_Release(unk);
559 hr = IMFAttributes_GetCount(attributes2, &count);
560 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
561 ok(count == 1, "Unexpected attribute count %u.\n", count);
563 value = 0;
564 hr = IMFAttributes_GetUINT32(attributes2, &MF_SA_D3D_AWARE, &value);
565 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
566 ok(value == 1, "Unexpected value %d.\n", value);
568 IMFAttributes_Release(attributes2);
570 hr = IMFAttributes_GetCount(attributes, &count);
571 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
572 ok(count == 1, "Unexpected attribute count %u.\n", count);
574 memset(&rect, 0, sizeof(rect));
575 hr = IMFAttributes_GetBlob(attributes, &VIDEO_ZOOM_RECT, (UINT8 *)&rect, sizeof(rect), NULL);
576 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
577 ok(rect.left == 0.0f && rect.top == 0.0f && rect.right == 1.0f && rect.bottom == 1.0f,
578 "Unexpected zoom rect (%f, %f) - (%f, %f).\n", rect.left, rect.top, rect.right, rect.bottom);
580 IMFAttributes_Release(attributes);
582 hr = IMFVideoDeviceID_GetDeviceID(deviceid, NULL);
583 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
585 hr = IMFVideoDeviceID_GetDeviceID(deviceid, &iid);
586 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
587 ok(IsEqualIID(&iid, &IID_IDirect3DDevice9), "Unexpected id %s.\n", wine_dbgstr_guid(&iid));
589 IMFVideoDeviceID_Release(deviceid);
591 /* Stream configuration. */
592 input_count = output_count = 0;
593 hr = IMFTransform_GetStreamCount(transform, &input_count, &output_count);
594 ok(hr == S_OK, "Failed to get stream count, hr %#x.\n", hr);
595 ok(input_count == 1 && output_count == 1, "Unexpected stream count %u/%u.\n", input_count, output_count);
597 hr = IMFTransform_GetStreamLimits(transform, &input_min, &input_max, &output_min, &output_max);
598 ok(hr == S_OK, "Failed to get stream limits, hr %#x.\n", hr);
599 ok(input_min == 1 && input_max == 16 && output_min == 1 && output_max == 1, "Unexpected stream limits %u/%u, %u/%u.\n",
600 input_min, input_max, output_min, output_max);
602 hr = IMFTransform_GetInputStreamInfo(transform, 1, &input_info);
603 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
605 hr = IMFTransform_GetOutputStreamInfo(transform, 1, &output_info);
606 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
608 memset(&input_info, 0xcc, sizeof(input_info));
609 hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info);
610 ok(hr == S_OK, "Failed to get input info, hr %#x.\n", hr);
612 memset(&output_info, 0xcc, sizeof(output_info));
613 hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info);
614 ok(hr == S_OK, "Failed to get input info, hr %#x.\n", hr);
615 ok(!(output_info.dwFlags & (MFT_OUTPUT_STREAM_PROVIDES_SAMPLES | MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES)),
616 "Unexpected output flags %#x.\n", output_info.dwFlags);
618 hr = IMFTransform_GetStreamIDs(transform, 1, &input_id, 1, &output_id);
619 ok(hr == S_OK, "Failed to get input info, hr %#x.\n", hr);
620 ok(input_id == 0 && output_id == 0, "Unexpected stream ids.\n");
622 hr = IMFTransform_GetInputStreamAttributes(transform, 1, &attributes);
623 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
625 hr = IMFTransform_GetOutputStreamAttributes(transform, 1, &attributes);
626 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
628 hr = IMFTransform_GetOutputStreamAttributes(transform, 0, &attributes);
629 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
631 hr = IMFTransform_AddInputStreams(transform, 16, NULL);
632 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
634 hr = IMFTransform_AddInputStreams(transform, 16, ids);
635 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
637 memset(ids, 0, sizeof(ids));
638 hr = IMFTransform_AddInputStreams(transform, 15, ids);
639 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
641 for (i = 0; i < ARRAY_SIZE(ids); ++i)
642 ids[i] = i + 1;
644 hr = IMFTransform_AddInputStreams(transform, 15, ids);
645 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
647 input_count = output_count = 0;
648 hr = IMFTransform_GetStreamCount(transform, &input_count, &output_count);
649 ok(hr == S_OK, "Failed to get stream count, hr %#x.\n", hr);
650 ok(input_count == 16 && output_count == 1, "Unexpected stream count %u/%u.\n", input_count, output_count);
652 memset(&input_info, 0, sizeof(input_info));
653 hr = IMFTransform_GetInputStreamInfo(transform, 1, &input_info);
654 ok(hr == S_OK, "Failed to get input info, hr %#x.\n", hr);
655 ok((input_info.dwFlags & (MFT_INPUT_STREAM_REMOVABLE | MFT_INPUT_STREAM_OPTIONAL)) ==
656 (MFT_INPUT_STREAM_REMOVABLE | MFT_INPUT_STREAM_OPTIONAL), "Unexpected flags %#x.\n", input_info.dwFlags);
658 attributes = NULL;
659 hr = IMFTransform_GetInputStreamAttributes(transform, 0, &attributes);
660 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
661 hr = IMFAttributes_GetCount(attributes, &count);
662 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
663 ok(count == 1, "Unexpected count %u.\n", count);
664 hr = IMFAttributes_GetUINT32(attributes, &MF_SA_REQUIRED_SAMPLE_COUNT, &count);
665 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
666 ok(count == 1, "Unexpected count %u.\n", count);
667 ok(!!attributes, "Unexpected attributes.\n");
669 attributes2 = NULL;
670 hr = IMFTransform_GetInputStreamAttributes(transform, 0, &attributes2);
671 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
672 ok(attributes == attributes2, "Unexpected instance.\n");
674 IMFAttributes_Release(attributes2);
675 IMFAttributes_Release(attributes);
677 attributes = NULL;
678 hr = IMFTransform_GetInputStreamAttributes(transform, 1, &attributes);
679 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
680 ok(!!attributes, "Unexpected attributes.\n");
681 IMFAttributes_Release(attributes);
683 hr = IMFTransform_DeleteInputStream(transform, 0);
684 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
686 hr = IMFTransform_DeleteInputStream(transform, 1);
687 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
689 input_count = output_count = 0;
690 hr = IMFTransform_GetStreamCount(transform, &input_count, &output_count);
691 ok(hr == S_OK, "Failed to get stream count, hr %#x.\n", hr);
692 ok(input_count == 15 && output_count == 1, "Unexpected stream count %u/%u.\n", input_count, output_count);
694 IMFTransform_Release(transform);
696 hr = MFCreateVideoMixer(NULL, &IID_IMFTransform, &IID_IMFTransform, (void **)&transform);
697 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
699 hr = CoCreateInstance(&CLSID_MFVideoMixer9, NULL, CLSCTX_INPROC_SERVER, &IID_IMFTransform, (void **)&transform);
700 ok(hr == S_OK, "Failed to create default mixer, hr %#x.\n", hr);
701 IMFTransform_Release(transform);
704 static void test_surface_sample(void)
706 IDirect3DSurface9 *backbuffer = NULL;
707 IMFDesiredSample *desired_sample;
708 IMFMediaBuffer *buffer, *buffer2;
709 IDirect3DSwapChain9 *swapchain;
710 IDirect3DDevice9 *device;
711 DWORD count, length;
712 IMFSample *sample;
713 LONGLONG duration;
714 IDirect3D9 *d3d;
715 IUnknown *unk;
716 HWND window;
717 HRESULT hr;
718 BYTE *data;
720 window = create_window();
721 d3d = Direct3DCreate9(D3D_SDK_VERSION);
722 ok(!!d3d, "Failed to create a D3D object.\n");
723 if (!(device = create_device(d3d, window)))
725 skip("Failed to create a D3D device, skipping tests.\n");
726 goto done;
729 hr = IDirect3DDevice9_GetSwapChain(device, 0, &swapchain);
730 ok(SUCCEEDED(hr), "Failed to get the implicit swapchain (%08x)\n", hr);
732 hr = IDirect3DSwapChain9_GetBackBuffer(swapchain, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
733 ok(SUCCEEDED(hr), "Failed to get the back buffer (%08x)\n", hr);
734 ok(backbuffer != NULL, "The back buffer is NULL\n");
736 IDirect3DSwapChain9_Release(swapchain);
738 hr = MFCreateVideoSampleFromSurface((IUnknown *)backbuffer, &sample);
739 todo_wine
740 ok(hr == S_OK, "Failed to create surface sample, hr %#x.\n", hr);
741 if (FAILED(hr)) goto done;
743 hr = IMFSample_QueryInterface(sample, &IID_IMFTrackedSample, (void **)&unk);
744 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
745 IUnknown_Release(unk);
747 hr = IMFSample_QueryInterface(sample, &IID_IMFDesiredSample, (void **)&desired_sample);
748 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
750 hr = IMFSample_GetCount(sample, &count);
751 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
752 ok(!count, "Unexpected attribute count %u.\n", count);
754 IMFDesiredSample_SetDesiredSampleTimeAndDuration(desired_sample, 123, 456);
756 hr = IMFSample_GetCount(sample, &count);
757 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
758 ok(!count, "Unexpected attribute count %u.\n", count);
760 IMFDesiredSample_Release(desired_sample);
762 hr = IMFSample_GetCount(sample, &count);
763 ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
764 ok(!count, "Unexpected attribute count.\n");
766 hr = IMFSample_GetBufferCount(sample, &count);
767 ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr);
768 ok(count == 1, "Unexpected attribute count.\n");
770 hr = IMFSample_GetTotalLength(sample, &length);
771 ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr);
772 ok(!length, "Unexpected length %u.\n", length);
774 hr = IMFSample_GetSampleDuration(sample, &duration);
775 ok(hr == MF_E_NO_SAMPLE_DURATION, "Unexpected hr %#x.\n", hr);
777 hr = IMFSample_GetSampleTime(sample, &duration);
778 ok(hr == MF_E_NO_SAMPLE_TIMESTAMP, "Unexpected hr %#x.\n", hr);
780 hr = IMFSample_GetBufferByIndex(sample, 0, &buffer);
781 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
783 hr = IMFMediaBuffer_GetMaxLength(buffer, &length);
784 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
786 hr = IMFMediaBuffer_GetCurrentLength(buffer, &length);
787 ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr);
788 ok(!length, "Unexpected length %u.\n", length);
790 hr = IMFMediaBuffer_Lock(buffer, &data, NULL, NULL);
791 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
793 hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&unk);
794 ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
796 hr = IMFSample_AddBuffer(sample, buffer);
797 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
799 hr = IMFSample_GetBufferCount(sample, &count);
800 ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr);
801 ok(count == 2, "Unexpected attribute count.\n");
803 hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer2);
804 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
806 hr = IMFSample_CopyToBuffer(sample, buffer);
807 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
809 hr = IMFSample_RemoveAllBuffers(sample);
810 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
812 hr = IMFSample_GetBufferCount(sample, &count);
813 ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr);
814 ok(!count, "Unexpected attribute count.\n");
816 IMFMediaBuffer_Release(buffer);
818 IMFSample_Release(sample);
820 done:
821 if (backbuffer)
822 IDirect3DSurface9_Release(backbuffer);
823 IDirect3D9_Release(d3d);
824 DestroyWindow(window);
827 static void test_default_mixer_type_negotiation(void)
829 IMFMediaType *media_type, *media_type2;
830 IDirect3DDeviceManager9 *manager;
831 DXVA2_VideoProcessorCaps caps;
832 IMFVideoMediaType *video_type;
833 IMFVideoProcessor *processor;
834 IDirect3DDevice9 *device;
835 IMFTransform *transform;
836 GUID guid, *guids;
837 IDirect3D9 *d3d;
838 IUnknown *unk;
839 HWND window;
840 DWORD count;
841 HRESULT hr;
842 UINT token;
844 if (!pMFCreateVideoMediaTypeFromSubtype)
846 win_skip("Skipping mixer types tests.\n");
847 return;
850 hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&transform);
851 ok(hr == S_OK, "Failed to create default mixer, hr %#x.\n", hr);
853 hr = IMFTransform_GetInputAvailableType(transform, 0, 0, &media_type);
854 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
856 hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type);
857 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
859 hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type);
860 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
862 hr = MFCreateMediaType(&media_type);
863 ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
865 hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
866 ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
868 hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_RGB32);
869 ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
871 hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
872 ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
874 hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY);
875 ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
877 /* Now try with device manager. */
879 window = create_window();
880 d3d = Direct3DCreate9(D3D_SDK_VERSION);
881 ok(!!d3d, "Failed to create a D3D object.\n");
882 if (!(device = create_device(d3d, window)))
884 skip("Failed to create a D3D device, skipping tests.\n");
885 goto done;
888 hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager);
889 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
891 hr = IMFTransform_ProcessMessage(transform, MFT_MESSAGE_SET_D3D_MANAGER, (ULONG_PTR)manager);
892 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
894 /* Now manager is not initialized. */
895 hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
896 ok(hr == DXVA2_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
898 hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY);
899 ok(hr == DXVA2_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
901 hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token);
902 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
904 /* And now type description is incomplete. */
905 hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
906 ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
907 IMFMediaType_Release(media_type);
909 hr = pMFCreateVideoMediaTypeFromSubtype(&MFVideoFormat_RGB32, &video_type);
910 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
912 /* Partially initialized type. */
913 hr = IMFTransform_SetInputType(transform, 0, (IMFMediaType *)video_type, 0);
914 ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
916 /* Only required data - frame size and uncompressed marker. */
917 hr = IMFVideoMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64)640 << 32 | 480);
918 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
919 hr = IMFVideoMediaType_SetUINT32(video_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
920 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
922 hr = IMFTransform_SetInputType(transform, 0, (IMFMediaType *)video_type, MFT_SET_TYPE_TEST_ONLY);
923 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
925 hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type);
926 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
928 hr = IMFTransform_SetInputType(transform, 0, (IMFMediaType *)video_type, 0);
929 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
931 hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type);
932 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
933 ok(media_type != (IMFMediaType *)video_type, "Unexpected media type instance.\n");
935 hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type2);
936 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
937 ok(media_type == media_type2, "Unexpected media type instance.\n");
938 IMFMediaType_Release(media_type);
939 IMFMediaType_Release(media_type2);
941 hr = IMFTransform_QueryInterface(transform, &IID_IMFVideoProcessor, (void **)&processor);
942 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
944 hr = IMFVideoProcessor_GetVideoProcessorMode(processor, &guid);
945 todo_wine
946 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
948 hr = IMFVideoProcessor_GetVideoProcessorCaps(processor, (GUID *)&DXVA2_VideoProcSoftwareDevice, &caps);
949 todo_wine
950 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
952 hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type);
953 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
954 ok(media_type != (IMFMediaType *)video_type, "Unexpected pointer.\n");
955 hr = IMFMediaType_QueryInterface(media_type, &IID_IMFVideoMediaType, (void **)&unk);
956 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
957 IUnknown_Release(unk);
958 IMFMediaType_Release(media_type);
960 hr = IMFVideoProcessor_GetAvailableVideoProcessorModes(processor, &count, &guids);
961 todo_wine
962 ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#x.\n", hr);
964 hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type);
965 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
967 hr = IMFTransform_SetOutputType(transform, 1, media_type, 0);
968 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
970 hr = IMFTransform_SetOutputType(transform, 0, media_type, 0);
971 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
973 hr = IMFVideoProcessor_GetVideoProcessorMode(processor, &guid);
974 todo_wine
975 ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
977 hr = IMFVideoProcessor_GetAvailableVideoProcessorModes(processor, &count, &guids);
978 todo_wine
979 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
980 if (SUCCEEDED(hr))
981 CoTaskMemFree(guids);
983 hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type2);
984 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
985 ok(media_type == media_type2, "Unexpected media type instance.\n");
986 IMFMediaType_Release(media_type2);
987 IMFMediaType_Release(media_type);
989 IMFVideoProcessor_Release(processor);
991 IMFVideoMediaType_Release(video_type);
993 IDirect3DDeviceManager9_Release(manager);
995 IDirect3DDevice9_Release(device);
997 done:
998 IMFTransform_Release(transform);
999 IDirect3D9_Release(d3d);
1000 DestroyWindow(window);
1003 static void test_default_presenter(void)
1005 D3DDEVICE_CREATION_PARAMETERS device_params = { 0 };
1006 D3DPRESENT_PARAMETERS present_params = { 0 };
1007 IMFVideoDisplayControl *display_control;
1008 IDirect3DSwapChain9 *swapchain;
1009 IMFVideoPresenter *presenter;
1010 IMFRateSupport *rate_support;
1011 IDirect3DDevice9 *d3d_device;
1012 IDirect3DDeviceManager9 *dm;
1013 IMFVideoDeviceID *deviceid;
1014 IMFGetService *gs;
1015 HWND hwnd, hwnd2;
1016 HANDLE handle;
1017 IUnknown *unk;
1018 DWORD flags;
1019 float rate;
1020 HRESULT hr;
1021 GUID iid;
1023 hr = MFCreateVideoPresenter(NULL, &IID_IMFVideoPresenter, &IID_IMFVideoPresenter, (void **)&presenter);
1024 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1026 hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter);
1027 ok(hr == S_OK || broken(hr == E_FAIL) /* WinXP */, "Failed to create default presenter, hr %#x.\n", hr);
1028 if (FAILED(hr))
1029 return;
1031 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDeviceID, (void **)&deviceid);
1032 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1034 hr = IMFVideoDeviceID_GetDeviceID(deviceid, NULL);
1035 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1037 hr = IMFVideoDeviceID_GetDeviceID(deviceid, &iid);
1038 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1039 ok(IsEqualIID(&iid, &IID_IDirect3DDevice9), "Unexpected id %s.\n", wine_dbgstr_guid(&iid));
1041 IMFVideoDeviceID_Release(deviceid);
1043 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFTopologyServiceLookupClient, (void **)&unk);
1044 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1045 IUnknown_Release(unk);
1047 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&unk);
1048 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1049 IUnknown_Release(unk);
1051 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFGetService, (void **)&gs);
1052 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1054 hr = IMFGetService_GetService(gs, &MR_VIDEO_RENDER_SERVICE, &IID_IMFVideoDisplayControl, (void **)&display_control);
1055 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1057 hr = IMFVideoDisplayControl_GetRenderingPrefs(display_control, NULL);
1058 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1060 flags = 123;
1061 hr = IMFVideoDisplayControl_GetRenderingPrefs(display_control, &flags);
1062 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1063 ok(!flags, "Unexpected rendering flags %#x.\n", flags);
1065 IMFVideoDisplayControl_Release(display_control);
1067 hr = IMFGetService_GetService(gs, &MR_VIDEO_ACCELERATION_SERVICE, &IID_IDirect3DDeviceManager9, (void **)&dm);
1068 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1070 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control);
1071 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1073 hr = IDirect3DDeviceManager9_OpenDeviceHandle(dm, &handle);
1074 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1076 hr = IDirect3DDeviceManager9_LockDevice(dm, handle, &d3d_device, FALSE);
1077 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1079 hr = IDirect3DDevice9_GetCreationParameters(d3d_device, &device_params);
1080 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1081 ok(device_params.hFocusWindow == GetDesktopWindow(), "Unexpected window %p.\n", device_params.hFocusWindow);
1083 hr = IDirect3DDevice9_GetSwapChain(d3d_device, 0, &swapchain);
1084 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1086 hr = IDirect3DSwapChain9_GetPresentParameters(swapchain, &present_params);
1087 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1089 ok(present_params.hDeviceWindow == GetDesktopWindow(), "Unexpected device window.\n");
1090 ok(present_params.Windowed, "Unexpected windowed mode.\n");
1091 ok(present_params.SwapEffect == D3DSWAPEFFECT_COPY, "Unexpected swap effect.\n");
1092 ok(present_params.Flags & D3DPRESENTFLAG_VIDEO, "Unexpected flags %#x.\n", present_params.Flags);
1093 ok(present_params.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE, "Unexpected present interval.\n");
1095 IDirect3DDevice9_Release(d3d_device);
1097 hr = IDirect3DDeviceManager9_UnlockDevice(dm, handle, FALSE);
1098 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1100 /* Video window */
1101 hwnd = create_window();
1102 ok(!!hwnd, "Failed to create a test window.\n");
1104 hr = IMFVideoDisplayControl_GetVideoWindow(display_control, NULL);
1105 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1107 hwnd2 = hwnd;
1108 hr = IMFVideoDisplayControl_GetVideoWindow(display_control, &hwnd2);
1109 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1110 ok(hwnd2 == NULL, "Unexpected window %p.\n", hwnd2);
1112 hr = IMFVideoDisplayControl_SetVideoWindow(display_control, NULL);
1113 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1115 hr = IMFVideoDisplayControl_SetVideoWindow(display_control, (HWND)0x1);
1116 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1118 hr = IMFVideoDisplayControl_SetVideoWindow(display_control, hwnd);
1119 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1121 hwnd2 = NULL;
1122 hr = IMFVideoDisplayControl_GetVideoWindow(display_control, &hwnd2);
1123 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1124 ok(hwnd2 == hwnd, "Unexpected window %p.\n", hwnd2);
1126 /* Video position */
1127 hr = IDirect3DDeviceManager9_CloseDeviceHandle(dm, handle);
1128 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1130 IDirect3DDeviceManager9_Release(dm);
1132 IMFVideoDisplayControl_Release(display_control);
1133 IMFGetService_Release(gs);
1135 /* Rate support. */
1136 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFRateSupport, (void **)&rate_support);
1137 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1139 rate = 1.0f;
1140 hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate);
1141 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1142 ok(rate == 0.0f, "Unexpected rate %f.\n", rate);
1144 rate = 1.0f;
1145 hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, TRUE, &rate);
1146 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1147 ok(rate == 0.0f, "Unexpected rate %f.\n", rate);
1149 rate = 1.0f;
1150 hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, FALSE, &rate);
1151 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1152 ok(rate == 0.0f, "Unexpected rate %f.\n", rate);
1154 rate = 1.0f;
1155 hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, TRUE, &rate);
1156 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1157 ok(rate == 0.0f, "Unexpected rate %f.\n", rate);
1159 IMFRateSupport_Release(rate_support);
1161 IMFVideoPresenter_Release(presenter);
1163 DestroyWindow(hwnd);
1166 static void test_MFCreateVideoMixerAndPresenter(void)
1168 IUnknown *mixer, *presenter;
1169 HRESULT hr;
1171 hr = MFCreateVideoMixerAndPresenter(NULL, NULL, &IID_IUnknown, (void **)&mixer, &IID_IUnknown, (void **)&presenter);
1172 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1174 IUnknown_Release(mixer);
1175 IUnknown_Release(presenter);
1178 static HRESULT WINAPI test_notify_callback_QueryInterface(IMFVideoSampleAllocatorNotify *iface,
1179 REFIID riid, void **obj)
1181 if (IsEqualIID(riid, &IID_IMFVideoSampleAllocatorNotify) ||
1182 IsEqualIID(riid, &IID_IUnknown))
1184 *obj = iface;
1185 IMFVideoSampleAllocatorNotify_AddRef(iface);
1186 return S_OK;
1189 *obj = NULL;
1190 return E_NOINTERFACE;
1193 static ULONG WINAPI test_notify_callback_AddRef(IMFVideoSampleAllocatorNotify *iface)
1195 return 2;
1198 static ULONG WINAPI test_notify_callback_Release(IMFVideoSampleAllocatorNotify *iface)
1200 return 1;
1203 static HRESULT WINAPI test_notify_callback_NotifyRelease(IMFVideoSampleAllocatorNotify *iface)
1205 return E_NOTIMPL;
1208 static const IMFVideoSampleAllocatorNotifyVtbl test_notify_callback_vtbl =
1210 test_notify_callback_QueryInterface,
1211 test_notify_callback_AddRef,
1212 test_notify_callback_Release,
1213 test_notify_callback_NotifyRelease,
1216 static void test_MFCreateVideoSampleAllocator(void)
1218 IMFVideoSampleAllocatorNotify test_notify = { &test_notify_callback_vtbl };
1219 IMFVideoSampleAllocatorCallback *allocator_cb;
1220 IMFVideoSampleAllocator *allocator;
1221 IMFVideoMediaType *video_type;
1222 IMFSample *sample, *sample2;
1223 IDirect3DSurface9 *surface;
1224 IMFMediaType *media_type;
1225 IMFMediaBuffer *buffer;
1226 IMFGetService *gs;
1227 IUnknown *unk;
1228 HRESULT hr;
1229 LONG count;
1231 hr = MFCreateVideoSampleAllocator(&IID_IUnknown, (void **)&unk);
1232 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1233 IUnknown_Release(unk);
1235 hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocator, (void **)&allocator);
1236 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1238 hr = IMFVideoSampleAllocator_QueryInterface(allocator, &IID_IMFVideoSampleAllocatorCallback, (void **)&allocator_cb);
1239 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1241 hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, NULL);
1242 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1244 hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, &test_notify);
1245 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1247 hr = IMFVideoSampleAllocatorCallback_SetCallback(allocator_cb, NULL);
1248 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1250 hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, NULL);
1251 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1253 count = 10;
1254 hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
1255 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1256 ok(!count, "Unexpected count %d.\n", count);
1258 hr = IMFVideoSampleAllocator_UninitializeSampleAllocator(allocator);
1259 todo_wine
1260 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1262 hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
1263 todo_wine
1264 ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
1266 hr = MFCreateMediaType(&media_type);
1267 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1269 /* It expects IMFVideoMediaType. */
1270 hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 2, media_type);
1271 todo_wine
1272 ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
1274 hr = MFCreateVideoMediaTypeFromSubtype(&MFVideoFormat_RGB32, &video_type);
1275 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1277 hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 2, (IMFMediaType *)video_type);
1278 todo_wine
1279 ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
1281 /* Frame size is required. */
1282 hr = IMFVideoMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64) 320 << 32 | 240);
1283 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1284 hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 0, (IMFMediaType *)video_type);
1285 todo_wine
1286 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1288 hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
1289 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1290 todo_wine
1291 ok(count == 1, "Unexpected count %d.\n", count);
1293 sample = NULL;
1294 hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
1295 todo_wine
1296 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1297 if (SUCCEEDED(hr))
1298 ok(get_refcount(sample) == 3, "Unexpected refcount %u.\n", get_refcount(sample));
1300 hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample2);
1301 todo_wine
1302 ok(hr == MF_E_SAMPLEALLOCATOR_EMPTY, "Unexpected hr %#x.\n", hr);
1304 /* Reinitialize with active sample. */
1305 hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 4, (IMFMediaType *)video_type);
1306 todo_wine
1307 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1308 if (sample)
1309 ok(get_refcount(sample) == 3, "Unexpected refcount %u.\n", get_refcount(sample));
1311 hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
1312 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1313 todo_wine
1314 ok(count == 4, "Unexpected count %d.\n", count);
1316 if (sample)
1318 hr = IMFSample_QueryInterface(sample, &IID_IMFDesiredSample, (void **)&unk);
1319 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1320 IUnknown_Release(unk);
1322 hr = IMFSample_QueryInterface(sample, &IID_IMFTrackedSample, (void **)&unk);
1323 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1324 IUnknown_Release(unk);
1326 hr = IMFSample_GetBufferByIndex(sample, 0, &buffer);
1327 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1329 hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&gs);
1330 ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Win7 */, "Unexpected hr %#x.\n", hr);
1332 /* Device manager wasn't set, sample gets regular memory buffers. */
1333 if (SUCCEEDED(hr))
1335 hr = IMFGetService_GetService(gs, &MR_BUFFER_SERVICE, &IID_IDirect3DSurface9, (void **)&surface);
1336 ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
1337 IMFGetService_Release(gs);
1340 IMFMediaBuffer_Release(buffer);
1342 IMFSample_Release(sample);
1345 IMFVideoSampleAllocatorCallback_Release(allocator_cb);
1347 IMFMediaType_Release(media_type);
1349 IMFVideoSampleAllocator_Release(allocator);
1351 hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocatorCallback, (void **)&unk);
1352 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1353 IUnknown_Release(unk);
1356 struct test_host
1358 IMFTopologyServiceLookup IMFTopologyServiceLookup_iface;
1359 IMediaEventSink IMediaEventSink_iface;
1360 IMFTransform *mixer;
1361 IMFVideoPresenter *presenter;
1364 static struct test_host *impl_from_test_host(IMFTopologyServiceLookup *iface)
1366 return CONTAINING_RECORD(iface, struct test_host, IMFTopologyServiceLookup_iface);
1369 static struct test_host *impl_from_test_host_events(IMediaEventSink *iface)
1371 return CONTAINING_RECORD(iface, struct test_host, IMediaEventSink_iface);
1374 static HRESULT WINAPI test_host_QueryInterface(IMFTopologyServiceLookup *iface, REFIID riid, void **obj)
1376 if (IsEqualIID(riid, &IID_IMFTopologyServiceLookup) ||
1377 IsEqualIID(riid, &IID_IUnknown))
1379 *obj = iface;
1380 IMFTopologyServiceLookup_AddRef(iface);
1381 return S_OK;
1384 *obj = NULL;
1385 return E_NOINTERFACE;
1388 static ULONG WINAPI test_host_AddRef(IMFTopologyServiceLookup *iface)
1390 return 2;
1393 static ULONG WINAPI test_host_Release(IMFTopologyServiceLookup *iface)
1395 return 1;
1398 static HRESULT WINAPI test_host_LookupService(IMFTopologyServiceLookup *iface,
1399 MF_SERVICE_LOOKUP_TYPE lookup_type, DWORD index, REFGUID service,
1400 REFIID riid, void **objects, DWORD *num_objects)
1402 struct test_host *host = impl_from_test_host(iface);
1404 ok(*num_objects == 1, "Unexpected number of requested objects %u\n", *num_objects);
1406 memset(objects, 0, *num_objects * sizeof(*objects));
1408 if (IsEqualGUID(service, &MR_VIDEO_RENDER_SERVICE))
1410 if (IsEqualIID(riid, &IID_IMFClock)) return E_FAIL;
1411 if (IsEqualIID(riid, &IID_IMediaEventSink))
1413 *objects = &host->IMediaEventSink_iface;
1414 IMediaEventSink_AddRef(&host->IMediaEventSink_iface);
1415 return S_OK;
1418 ok(0, "Unexpected interface %s.\n", wine_dbgstr_guid(riid));
1419 return E_UNEXPECTED;
1422 if (IsEqualGUID(service, &MR_VIDEO_MIXER_SERVICE))
1424 if (IsEqualIID(riid, &IID_IMFTransform))
1426 *objects = host->mixer;
1427 IMFTransform_AddRef(host->mixer);
1428 return S_OK;
1430 ok(0, "Unexpected interface %s.\n", wine_dbgstr_guid(riid));
1431 return E_UNEXPECTED;
1434 return E_NOTIMPL;
1437 static const IMFTopologyServiceLookupVtbl test_host_vtbl =
1439 test_host_QueryInterface,
1440 test_host_AddRef,
1441 test_host_Release,
1442 test_host_LookupService,
1445 static HRESULT WINAPI test_host_events_QueryInterface(IMediaEventSink *iface, REFIID riid, void **obj)
1447 struct test_host *host = impl_from_test_host_events(iface);
1448 return IMFTopologyServiceLookup_QueryInterface(&host->IMFTopologyServiceLookup_iface, riid, obj);
1451 static ULONG WINAPI test_host_events_AddRef(IMediaEventSink *iface)
1453 struct test_host *host = impl_from_test_host_events(iface);
1454 return IMFTopologyServiceLookup_AddRef(&host->IMFTopologyServiceLookup_iface);
1457 static ULONG WINAPI test_host_events_Release(IMediaEventSink *iface)
1459 struct test_host *host = impl_from_test_host_events(iface);
1460 return IMFTopologyServiceLookup_Release(&host->IMFTopologyServiceLookup_iface);
1463 static HRESULT WINAPI test_host_events_Notify(IMediaEventSink *iface, LONG code, LONG_PTR param1, LONG_PTR param2)
1465 return S_OK;
1468 static const IMediaEventSinkVtbl test_host_events_vtbl =
1470 test_host_events_QueryInterface,
1471 test_host_events_AddRef,
1472 test_host_events_Release,
1473 test_host_events_Notify,
1476 static void init_test_host(struct test_host *host, IMFTransform *mixer, IMFVideoPresenter *presenter)
1478 host->IMFTopologyServiceLookup_iface.lpVtbl = &test_host_vtbl;
1479 host->IMediaEventSink_iface.lpVtbl = &test_host_events_vtbl;
1480 /* No need to keep references. */
1481 host->mixer = mixer;
1482 host->presenter = presenter;
1485 static void test_presenter_video_position(void)
1487 IMFTopologyServiceLookupClient *lookup_client;
1488 IMFVideoDisplayControl *display_control;
1489 IMFAttributes *mixer_attributes;
1490 MFVideoNormalizedRect src_rect;
1491 IMFVideoPresenter *presenter;
1492 struct test_host host;
1493 IMFTransform *mixer;
1494 RECT dst_rect;
1495 HRESULT hr;
1496 DWORD count;
1497 HWND hwnd;
1499 hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&mixer);
1500 ok(hr == S_OK, "Failed to create a mixer, hr %#x.\n", hr);
1502 hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter);
1503 ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr);
1505 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client);
1506 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1508 init_test_host(&host, mixer, presenter);
1510 /* Clear default mixer attributes, then attach presenter. */
1511 hr = IMFTransform_GetAttributes(mixer, &mixer_attributes);
1512 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1514 hr = IMFAttributes_DeleteAllItems(mixer_attributes);
1515 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1517 hr = IMFTopologyServiceLookupClient_InitServicePointers(lookup_client, &host.IMFTopologyServiceLookup_iface);
1518 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1520 hr = IMFAttributes_GetCount(mixer_attributes, &count);
1521 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1522 ok(count == 1, "Unexpected count %u.\n", count);
1524 memset(&src_rect, 0, sizeof(src_rect));
1525 hr = IMFAttributes_GetBlob(mixer_attributes, &VIDEO_ZOOM_RECT, (UINT8 *)&src_rect, sizeof(src_rect), NULL);
1526 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1527 ok(src_rect.left == 0.0f && src_rect.top == 0.0f && src_rect.right == 1.0f &&
1528 src_rect.bottom == 1.0f, "Unexpected source rectangle.\n");
1530 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control);
1531 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1533 hr = IMFVideoDisplayControl_GetVideoPosition(display_control, NULL, &dst_rect);
1534 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1536 hr = IMFVideoDisplayControl_GetVideoPosition(display_control, &src_rect, NULL);
1537 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1539 SetRect(&dst_rect, 1, 2, 3, 4);
1540 hr = IMFVideoDisplayControl_GetVideoPosition(display_control, &src_rect, &dst_rect);
1541 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1542 ok(src_rect.left == 0.0f && src_rect.top == 0.0f && src_rect.right == 1.0f &&
1543 src_rect.bottom == 1.0f, "Unexpected source rectangle.\n");
1544 ok(dst_rect.left == 0 && dst_rect.right == 0 && dst_rect.top == 0 && dst_rect.bottom == 0,
1545 "Unexpected destination rectangle %s.\n", wine_dbgstr_rect(&dst_rect));
1547 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, NULL);
1548 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1550 /* Setting position requires a window. */
1551 hwnd = create_window();
1552 ok(!!hwnd, "Failed to create a test window.\n");
1554 SetRect(&dst_rect, 0, 0, 10, 10);
1555 memset(&src_rect, 0, sizeof(src_rect));
1556 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, &dst_rect);
1557 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1559 hr = IMFVideoDisplayControl_SetVideoWindow(display_control, hwnd);
1560 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1562 SetRect(&dst_rect, 0, 0, 10, 10);
1563 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
1564 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1566 SetRect(&dst_rect, 1, 2, 3, 4);
1567 hr = IMFVideoDisplayControl_GetVideoPosition(display_control, &src_rect, &dst_rect);
1568 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1569 ok(dst_rect.left == 0 && dst_rect.right == 10 && dst_rect.top == 0 && dst_rect.bottom == 10,
1570 "Unexpected destination rectangle %s.\n", wine_dbgstr_rect(&dst_rect));
1572 set_rect(&src_rect, 0.0f, 0.0f, 2.0f, 1.0f);
1573 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
1574 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1576 set_rect(&src_rect, -0.1f, 0.0f, 0.9f, 1.0f);
1577 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
1578 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1580 /* Flipped source rectangle. */
1581 set_rect(&src_rect, 0.5f, 0.0f, 0.4f, 1.0f);
1582 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
1583 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1585 set_rect(&src_rect, 0.0f, 0.5f, 0.4f, 0.1f);
1586 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
1587 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1589 set_rect(&src_rect, 0.1f, 0.2f, 0.8f, 0.9f);
1590 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, &src_rect, NULL);
1591 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1593 /* Presenter updates mixer attribute. */
1594 memset(&src_rect, 0, sizeof(src_rect));
1595 hr = IMFAttributes_GetBlob(mixer_attributes, &VIDEO_ZOOM_RECT, (UINT8 *)&src_rect, sizeof(src_rect), NULL);
1596 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1597 ok(src_rect.left == 0.1f && src_rect.top == 0.2f && src_rect.right == 0.8f &&
1598 src_rect.bottom == 0.9f, "Unexpected source rectangle.\n");
1600 hr = IMFVideoDisplayControl_GetVideoPosition(display_control, &src_rect, &dst_rect);
1601 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1602 ok(src_rect.left == 0.1f && src_rect.top == 0.2f && src_rect.right == 0.8f &&
1603 src_rect.bottom == 0.9f, "Unexpected source rectangle.\n");
1605 SetRect(&dst_rect, 1, 2, 999, 1000);
1606 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
1607 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1609 SetRect(&dst_rect, 0, 1, 3, 4);
1610 hr = IMFVideoDisplayControl_GetVideoPosition(display_control, &src_rect, &dst_rect);
1611 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1612 ok(dst_rect.left == 1 && dst_rect.right == 999 && dst_rect.top == 2 && dst_rect.bottom == 1000,
1613 "Unexpected destination rectangle %s.\n", wine_dbgstr_rect(&dst_rect));
1615 /* Flipped destination rectangle. */
1616 SetRect(&dst_rect, 100, 1, 50, 1000);
1617 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
1618 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1620 SetRect(&dst_rect, 1, 100, 100, 50);
1621 hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst_rect);
1622 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1624 IMFVideoDisplayControl_Release(display_control);
1626 IMFTopologyServiceLookupClient_Release(lookup_client);
1627 IMFVideoPresenter_Release(presenter);
1628 IMFAttributes_Release(mixer_attributes);
1629 IMFTransform_Release(mixer);
1631 DestroyWindow(hwnd);
1634 static void test_presenter_native_video_size(void)
1636 IMFTopologyServiceLookupClient *lookup_client;
1637 IMFVideoDisplayControl *display_control;
1638 IMFVideoPresenter *presenter;
1639 struct test_host host;
1640 IMFTransform *mixer;
1641 SIZE size, ratio;
1642 HRESULT hr;
1643 IMFVideoMediaType *video_type;
1644 IDirect3DDeviceManager9 *dm;
1646 hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&mixer);
1647 ok(hr == S_OK, "Failed to create a mixer, hr %#x.\n", hr);
1649 hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter);
1650 ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr);
1652 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client);
1653 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1655 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control);
1656 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1658 hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, NULL, NULL);
1659 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1661 memset(&size, 0xcc, sizeof(size));
1662 hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, &size, NULL);
1663 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1664 ok(size.cx == 0 && size.cy == 0, "Unexpected size.\n");
1666 memset(&ratio, 0xcc, sizeof(ratio));
1667 hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, NULL, &ratio);
1668 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1669 ok(ratio.cx == 0 && ratio.cy == 0, "Unexpected ratio.\n");
1671 hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client);
1672 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1674 /* Configure mixer primary stream. */
1675 hr = MFGetService((IUnknown *)presenter, &MR_VIDEO_ACCELERATION_SERVICE, &IID_IDirect3DDeviceManager9, (void **)&dm);
1676 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1678 hr = IMFTransform_ProcessMessage(mixer, MFT_MESSAGE_SET_D3D_MANAGER, (ULONG_PTR)dm);
1679 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1681 IDirect3DDeviceManager9_Release(dm);
1683 hr = pMFCreateVideoMediaTypeFromSubtype(&MFVideoFormat_RGB32, &video_type);
1684 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1686 hr = IMFVideoMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64)640 << 32 | 480);
1687 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1688 hr = IMFVideoMediaType_SetUINT32(video_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
1689 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1691 hr = IMFTransform_SetInputType(mixer, 0, (IMFMediaType *)video_type, 0);
1692 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1694 /* Native video size is cached on initialization. */
1695 init_test_host(&host, mixer, presenter);
1697 hr = IMFTopologyServiceLookupClient_InitServicePointers(lookup_client, &host.IMFTopologyServiceLookup_iface);
1698 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1700 hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, &size, &ratio);
1701 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1702 ok(size.cx == 640 && size.cy == 480, "Unexpected size %u x %u.\n", size.cx, size.cy);
1703 ok((ratio.cx == 4 && ratio.cy == 3) || broken(!memcmp(&ratio, &size, sizeof(ratio))) /* < Win10 */,
1704 "Unexpected ratio %u x %u.\n", ratio.cx, ratio.cy);
1706 /* Update input type. */
1707 hr = IMFVideoMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64)320 << 32 | 240);
1708 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1710 hr = IMFTransform_SetInputType(mixer, 0, (IMFMediaType *)video_type, 0);
1711 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1713 hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, &size, &ratio);
1714 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1715 ok(size.cx == 640 && size.cy == 480, "Unexpected size %u x %u.\n", size.cx, size.cy);
1716 ok((ratio.cx == 4 && ratio.cy == 3) || broken(!memcmp(&ratio, &size, sizeof(ratio))) /* < Win10 */,
1717 "Unexpected ratio %u x %u.\n", ratio.cx, ratio.cy);
1719 /* Negotiating types updates native video size. */
1720 hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_INVALIDATEMEDIATYPE, 0);
1721 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1723 hr = IMFVideoDisplayControl_GetNativeVideoSize(display_control, &size, &ratio);
1724 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1725 ok(size.cx == 320 && size.cy == 240, "Unexpected size %u x %u.\n", size.cx, size.cy);
1726 ok((ratio.cx == 4 && ratio.cy == 3) || broken(!memcmp(&ratio, &size, sizeof(ratio))) /* < Win10 */,
1727 "Unexpected ratio %u x %u.\n", ratio.cx, ratio.cy);
1729 IMFVideoMediaType_Release(video_type);
1730 IMFVideoDisplayControl_Release(display_control);
1731 IMFVideoPresenter_Release(presenter);
1732 IMFTransform_Release(mixer);
1735 static void test_presenter_ar_mode(void)
1737 IMFVideoDisplayControl *display_control;
1738 HRESULT hr;
1739 DWORD mode;
1741 hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoDisplayControl, (void **)&display_control);
1742 ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr);
1744 hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, NULL);
1745 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1747 mode = 0;
1748 hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, &mode);
1749 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1750 ok(mode == (MFVideoARMode_PreservePicture | MFVideoARMode_PreservePixel), "Unexpected mode %#x.\n", mode);
1752 hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, 0x100);
1753 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1755 hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, MFVideoARMode_Mask);
1756 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1758 mode = 0;
1759 hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, &mode);
1760 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1761 ok(mode == MFVideoARMode_Mask, "Unexpected mode %#x.\n", mode);
1763 IMFVideoDisplayControl_Release(display_control);
1766 static void test_mixer_output_rectangle(void)
1768 IMFVideoMixerControl *mixer_control;
1769 MFVideoNormalizedRect rect;
1770 IMFTransform *mixer;
1771 HRESULT hr;
1773 hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&mixer);
1774 ok(hr == S_OK, "Failed to create a mixer, hr %#x.\n", hr);
1776 hr = IMFTransform_QueryInterface(mixer, &IID_IMFVideoMixerControl, (void **)&mixer_control);
1777 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1779 hr = IMFVideoMixerControl_GetStreamOutputRect(mixer_control, 0, NULL);
1780 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1782 set_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f);
1783 hr = IMFVideoMixerControl_GetStreamOutputRect(mixer_control, 0, &rect);
1784 ok(hr == S_OK, "Failed to get output rect, hr %#x.\n", hr);
1785 ok(rect.left == 0.0f && rect.top == 0.0f && rect.right == 1.0f && rect.bottom == 1.0f,
1786 "Unexpected rectangle.\n");
1788 hr = IMFVideoMixerControl_GetStreamOutputRect(mixer_control, 1, &rect);
1789 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
1791 hr = IMFVideoMixerControl_GetStreamOutputRect(mixer_control, 1, NULL);
1792 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1794 hr = IMFVideoMixerControl_SetStreamOutputRect(mixer_control, 1, &rect);
1795 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
1797 hr = IMFVideoMixerControl_SetStreamOutputRect(mixer_control, 1, NULL);
1798 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1800 /* Wrong bounds. */
1801 set_rect(&rect, 0.0f, 0.0f, 1.1f, 1.0f);
1802 hr = IMFVideoMixerControl_SetStreamOutputRect(mixer_control, 0, &rect);
1803 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1805 set_rect(&rect, -0.1f, 0.0f, 0.5f, 1.0f);
1806 hr = IMFVideoMixerControl_SetStreamOutputRect(mixer_control, 0, &rect);
1807 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1809 /* Flipped. */
1810 set_rect(&rect, 1.0f, 0.0f, 0.0f, 1.0f);
1811 hr = IMFVideoMixerControl_SetStreamOutputRect(mixer_control, 0, &rect);
1812 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1814 set_rect(&rect, 0.0f, 1.0f, 1.0f, 0.5f);
1815 hr = IMFVideoMixerControl_SetStreamOutputRect(mixer_control, 0, &rect);
1816 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1818 hr = IMFVideoMixerControl_SetStreamOutputRect(mixer_control, 0, NULL);
1819 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1821 IMFVideoMixerControl_Release(mixer_control);
1822 IMFTransform_Release(mixer);
1825 static void test_mixer_zorder(void)
1827 IMFVideoMixerControl *mixer_control;
1828 IMFTransform *mixer;
1829 DWORD ids[2];
1830 DWORD value;
1831 HRESULT hr;
1833 hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&mixer);
1834 ok(hr == S_OK, "Failed to create a mixer, hr %#x.\n", hr);
1836 hr = IMFTransform_QueryInterface(mixer, &IID_IMFVideoMixerControl, (void **)&mixer_control);
1837 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1839 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 0, NULL);
1840 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1842 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 1, NULL);
1843 ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
1845 value = 1;
1846 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 0, &value);
1847 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1848 ok(!value, "Unexpected value %u.\n", value);
1850 value = 1;
1851 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 1, &value);
1852 ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
1854 hr = IMFVideoMixerControl_SetStreamZOrder(mixer_control, 0, 1);
1855 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1857 hr = IMFVideoMixerControl_SetStreamZOrder(mixer_control, 1, 1);
1858 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1860 /* Exceeds maximum stream number. */
1861 hr = IMFVideoMixerControl_SetStreamZOrder(mixer_control, 0, 20);
1862 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1864 value = 1;
1865 hr = IMFTransform_AddInputStreams(mixer, 1, &value);
1866 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1868 value = 0;
1869 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 1, &value);
1870 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1871 ok(value == 1, "Unexpected zorder %u.\n", value);
1873 hr = IMFVideoMixerControl_SetStreamZOrder(mixer_control, 1, 0);
1874 ok(hr == MF_E_INVALIDREQUEST, "Unexpected hr %#x.\n", hr);
1876 hr = IMFVideoMixerControl_SetStreamZOrder(mixer_control, 1, 2);
1877 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
1879 hr = IMFVideoMixerControl_SetStreamZOrder(mixer_control, 0, 0);
1880 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1882 value = 2;
1883 hr = IMFTransform_AddInputStreams(mixer, 1, &value);
1884 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1886 value = 0;
1887 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 2, &value);
1888 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1889 ok(value == 2, "Unexpected zorder %u.\n", value);
1891 hr = IMFVideoMixerControl_SetStreamZOrder(mixer_control, 2, 1);
1892 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1894 value = 3;
1895 hr = IMFTransform_AddInputStreams(mixer, 1, &value);
1896 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1898 value = 0;
1899 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 3, &value);
1900 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1901 ok(value == 3, "Unexpected zorder %u.\n", value);
1903 hr = IMFTransform_DeleteInputStream(mixer, 1);
1904 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1905 hr = IMFTransform_DeleteInputStream(mixer, 2);
1906 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1907 hr = IMFTransform_DeleteInputStream(mixer, 3);
1908 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1910 ids[0] = 2;
1911 ids[1] = 1;
1912 hr = IMFTransform_AddInputStreams(mixer, 2, ids);
1913 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1915 value = 0;
1916 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 1, &value);
1917 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1918 ok(value == 2, "Unexpected zorder %u.\n", value);
1920 value = 0;
1921 hr = IMFVideoMixerControl_GetStreamZOrder(mixer_control, 2, &value);
1922 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
1923 ok(value == 1, "Unexpected zorder %u.\n", value);
1925 IMFVideoMixerControl_Release(mixer_control);
1926 IMFTransform_Release(mixer);
1929 START_TEST(evr)
1931 CoInitialize(NULL);
1933 pMFCreateVideoMediaTypeFromSubtype = (void *)GetProcAddress(GetModuleHandleA("mfplat.dll"), "MFCreateVideoMediaTypeFromSubtype");
1935 test_aggregation();
1936 test_interfaces();
1937 test_enum_pins();
1938 test_find_pin();
1939 test_pin_info();
1940 test_default_mixer();
1941 test_default_mixer_type_negotiation();
1942 test_surface_sample();
1943 test_default_presenter();
1944 test_MFCreateVideoMixerAndPresenter();
1945 test_MFCreateVideoSampleAllocator();
1946 test_presenter_video_position();
1947 test_presenter_native_video_size();
1948 test_presenter_ar_mode();
1949 test_mixer_output_rectangle();
1950 test_mixer_zorder();
1952 CoUninitialize();