evr/tests: Add sample allocator test with surface-backed buffers.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-10-29 18:03:25 +03:00 committed by Alexandre Julliard
parent 99c1f2a0a8
commit 7aad298f71
1 changed files with 94 additions and 32 deletions

View File

@ -1302,13 +1302,19 @@ static void test_MFCreateVideoSampleAllocator(void)
IMFVideoSampleAllocatorCallback *allocator_cb; IMFVideoSampleAllocatorCallback *allocator_cb;
IMFMediaType *media_type, *video_type; IMFMediaType *media_type, *video_type;
IMFVideoSampleAllocator *allocator; IMFVideoSampleAllocator *allocator;
IDirect3DDeviceManager9 *manager;
IMFSample *sample, *sample2; IMFSample *sample, *sample2;
IDirect3DSurface9 *surface; IDirect3DSurface9 *surface;
IDirect3DDevice9 *device;
IMFMediaBuffer *buffer; IMFMediaBuffer *buffer;
unsigned int token;
IMFGetService *gs; IMFGetService *gs;
IDirect3D9 *d3d;
IUnknown *unk; IUnknown *unk;
HWND window;
HRESULT hr; HRESULT hr;
LONG count; LONG count;
BYTE *data;
hr = MFCreateVideoSampleAllocator(&IID_IUnknown, (void **)&unk); hr = MFCreateVideoSampleAllocator(&IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@ -1387,48 +1393,104 @@ todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(count == 4, "Unexpected count %d.\n", count); ok(count == 4, "Unexpected count %d.\n", count);
if (sample) hr = IMFSample_QueryInterface(sample, &IID_IMFDesiredSample, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = IMFSample_QueryInterface(sample, &IID_IMFTrackedSample, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = IMFSample_GetBufferByIndex(sample, 0, &buffer);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&gs);
ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Win7 */, "Unexpected hr %#x.\n", hr);
/* Device manager wasn't set, sample gets regular memory buffers. */
if (SUCCEEDED(hr))
{ {
hr = IMFSample_QueryInterface(sample, &IID_IMFDesiredSample, (void **)&unk); hr = IMFGetService_GetService(gs, &MR_BUFFER_SERVICE, &IID_IDirect3DSurface9, (void **)&surface);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk); IMFGetService_Release(gs);
hr = IMFSample_QueryInterface(sample, &IID_IMFTrackedSample, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = IMFSample_GetBufferByIndex(sample, 0, &buffer);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&gs);
ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Win7 */, "Unexpected hr %#x.\n", hr);
/* Device manager wasn't set, sample gets regular memory buffers. */
if (SUCCEEDED(hr))
{
hr = IMFGetService_GetService(gs, &MR_BUFFER_SERVICE, &IID_IDirect3DSurface9, (void **)&surface);
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
IMFGetService_Release(gs);
}
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
IMFMediaBuffer_Release(buffer);
IMFSample_Release(sample);
} }
IMFVideoSampleAllocatorCallback_Release(allocator_cb); hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
IMFMediaType_Release(media_type); IMFMediaBuffer_Release(buffer);
IMFSample_Release(sample);
IMFVideoSampleAllocatorCallback_Release(allocator_cb);
IMFVideoSampleAllocator_Release(allocator); IMFVideoSampleAllocator_Release(allocator);
hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocatorCallback, (void **)&unk); hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocatorCallback, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk); IUnknown_Release(unk);
/* Using device manager */
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
}
hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token);
ok(hr == S_OK, "Failed to set a device, hr %#x.\n", hr);
hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocator, (void **)&allocator);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoSampleAllocator_SetDirectXManager(allocator, (IUnknown *)manager);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64) 320 << 32 | 240);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 0, video_type);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFSample_GetBufferByIndex(sample, 0, &buffer);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = MFGetService((IUnknown *)buffer, &MR_BUFFER_SERVICE, &IID_IDirect3DSurface9, (void **)&surface);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IDirect3DSurface9_Release(surface);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&unk);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
IUnknown_Release(unk);
hr = IMFMediaBuffer_Lock(buffer, &data, NULL, NULL);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMFMediaBuffer_Unlock(buffer);
todo_wine
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IMFSample_Release(sample);
IMFVideoSampleAllocator_Release(allocator);
IMFMediaType_Release(media_type);
IDirect3DDeviceManager9_Release(manager);
IDirect3DDevice9_Release(device);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
} }
struct test_host struct test_host