quartz/tests: Add some tests for IBasicVideo::GetCurrentImage().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ca2ad6acbf
commit
309f0a0d6c
|
@ -1071,6 +1071,81 @@ static void test_eos(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
|
|||
IMediaControl_Release(control);
|
||||
}
|
||||
|
||||
static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
|
||||
IFilterGraph2 *graph, const BITMAPINFOHEADER *expect_bih)
|
||||
{
|
||||
LONG buffer[(sizeof(BITMAPINFOHEADER) + 32 * 16 * 2) / 4];
|
||||
const BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)buffer;
|
||||
IMediaControl *control;
|
||||
OAFilterState state;
|
||||
IBasicVideo *video;
|
||||
unsigned int i;
|
||||
HANDLE thread;
|
||||
HRESULT hr;
|
||||
LONG size;
|
||||
|
||||
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
|
||||
IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video);
|
||||
|
||||
hr = IBasicVideo_GetCurrentImage(video, NULL, NULL);
|
||||
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IBasicVideo_GetCurrentImage(video, NULL, buffer);
|
||||
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
|
||||
|
||||
size = 0xdeadbeef;
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 2, "Got size %d.\n", size);
|
||||
|
||||
size = 0xdeadbeef;
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == VFW_E_NOT_PAUSED, "Got hr %#x.\n", hr);
|
||||
ok(size == 0xdeadbeef, "Got size %d.\n", size);
|
||||
|
||||
hr = IMediaControl_Pause(control);
|
||||
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
|
||||
|
||||
size = 0xdeadbeef;
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == E_UNEXPECTED, "Got hr %#x.\n", hr);
|
||||
ok(size == 0xdeadbeef, "Got size %d.\n", size);
|
||||
|
||||
thread = send_frame(input);
|
||||
hr = IMediaControl_GetState(control, 1000, &state);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1;
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
todo_wine ok(hr == E_OUTOFMEMORY, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1, "Got size %d.\n", size);
|
||||
|
||||
size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2;
|
||||
memset(buffer, 0xcc, sizeof(buffer));
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 2, "Got size %d.\n", size);
|
||||
ok(!memcmp(bih, expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
for (i = 0; i < 32 * 16 * 2; ++i)
|
||||
{
|
||||
const unsigned char *data = (unsigned char *)buffer + sizeof(BITMAPINFOHEADER);
|
||||
ok(data[i] == 0x55, "Got unexpected byte %02x at %u.\n", data[i], i);
|
||||
}
|
||||
|
||||
hr = IMediaControl_Run(control);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
join_thread(thread);
|
||||
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == VFW_E_NOT_PAUSED, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IMediaControl_Stop(control);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
IBasicVideo_Release(video);
|
||||
IMediaControl_Release(control);
|
||||
}
|
||||
|
||||
static void test_connect_pin(void)
|
||||
{
|
||||
VIDEOINFOHEADER vih =
|
||||
|
@ -1178,6 +1253,7 @@ static void test_connect_pin(void)
|
|||
test_flushing(pin, input, graph);
|
||||
test_sample_time(pin, input, graph);
|
||||
test_eos(pin, input, graph);
|
||||
test_current_image(filter, input, graph, &vih.bmiHeader);
|
||||
|
||||
hr = IFilterGraph2_Disconnect(graph, pin);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
|
|
@ -1223,6 +1223,106 @@ static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
|
|||
IMediaControl_Release(control);
|
||||
}
|
||||
|
||||
static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
|
||||
IFilterGraph2 *graph, const BITMAPINFOHEADER *req_bih)
|
||||
{
|
||||
LONG buffer[(sizeof(BITMAPINFOHEADER) + 32 * 16 * 4) / 4];
|
||||
const BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)buffer;
|
||||
const DWORD *data = (DWORD *)((char *)buffer + sizeof(BITMAPINFOHEADER));
|
||||
BITMAPINFOHEADER expect_bih = *req_bih;
|
||||
IMemAllocator *allocator;
|
||||
IMediaControl *control;
|
||||
OAFilterState state;
|
||||
IBasicVideo *video;
|
||||
unsigned int i;
|
||||
HANDLE thread;
|
||||
HRESULT hr;
|
||||
LONG size;
|
||||
|
||||
/* Note that the bitmap returned by GetCurrentImage() has a bit depth of
|
||||
* 32 regardless of the format used for pin connection. */
|
||||
expect_bih.biBitCount = 32;
|
||||
expect_bih.biSizeImage = 32 * 16 * 4;
|
||||
|
||||
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
|
||||
IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video);
|
||||
|
||||
hr = IBasicVideo_GetCurrentImage(video, NULL, NULL);
|
||||
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IBasicVideo_GetCurrentImage(video, NULL, buffer);
|
||||
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
|
||||
|
||||
size = 0xdeadbeef;
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 4, "Got size %d.\n", size);
|
||||
|
||||
size = sizeof(buffer);
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
todo_wine ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
/* The contents seem to reflect the last frame rendered. */
|
||||
|
||||
hr = IMemInputPin_GetAllocator(input, &allocator);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IMemAllocator_Commit(allocator);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
IMemAllocator_Release(allocator);
|
||||
|
||||
hr = IMediaControl_Pause(control);
|
||||
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
|
||||
|
||||
size = sizeof(buffer);
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
todo_wine ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
/* The contents seem to reflect the last frame rendered. */
|
||||
|
||||
thread = send_frame(input);
|
||||
hr = IMediaControl_GetState(control, 1000, &state);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
size = 1;
|
||||
memset(buffer, 0xcc, sizeof(buffer));
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(size == 1, "Got size %d.\n", size);
|
||||
|
||||
size = sizeof(buffer);
|
||||
memset(buffer, 0xcc, sizeof(buffer));
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
todo_wine ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
for (i = 0; i < 32 * 16; ++i)
|
||||
ok((data[i] & 0xffffff) == 0x555555, "Got unexpected color %08x at %u.\n", data[i], i);
|
||||
|
||||
hr = IMediaControl_Run(control);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
join_thread(thread);
|
||||
|
||||
size = sizeof(buffer);
|
||||
memset(buffer, 0xcc, sizeof(buffer));
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
for (i = 0; i < 32 * 16; ++i)
|
||||
ok((data[i] & 0xffffff) == 0x555555, "Got unexpected color %08x at %u.\n", data[i], i);
|
||||
}
|
||||
|
||||
hr = IMediaControl_Stop(control);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
IBasicVideo_Release(video);
|
||||
IMediaControl_Release(control);
|
||||
}
|
||||
|
||||
static void test_connect_pin(void)
|
||||
{
|
||||
VIDEOINFOHEADER vih =
|
||||
|
@ -1361,6 +1461,7 @@ static void test_connect_pin(void)
|
|||
|
||||
test_filter_state(input, graph);
|
||||
test_flushing(pin, input, graph);
|
||||
test_current_image(filter, input, graph, &vih.bmiHeader);
|
||||
|
||||
hr = IFilterGraph2_Disconnect(graph, pin);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
|
|
@ -1227,6 +1227,103 @@ static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
|
|||
IMediaControl_Release(control);
|
||||
}
|
||||
|
||||
static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
|
||||
IFilterGraph2 *graph, const BITMAPINFOHEADER *req_bih)
|
||||
{
|
||||
LONG buffer[(sizeof(BITMAPINFOHEADER) + 32 * 16 * 4) / 4];
|
||||
const BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)buffer;
|
||||
const DWORD *data = (DWORD *)((char *)buffer + sizeof(BITMAPINFOHEADER));
|
||||
BITMAPINFOHEADER expect_bih = *req_bih;
|
||||
IMemAllocator *allocator;
|
||||
IMediaControl *control;
|
||||
OAFilterState state;
|
||||
IBasicVideo *video;
|
||||
unsigned int i;
|
||||
HANDLE thread;
|
||||
HRESULT hr;
|
||||
LONG size;
|
||||
|
||||
expect_bih.biSizeImage = 32 * 16 * 4;
|
||||
|
||||
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
|
||||
IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video);
|
||||
|
||||
hr = IBasicVideo_GetCurrentImage(video, NULL, NULL);
|
||||
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IBasicVideo_GetCurrentImage(video, NULL, buffer);
|
||||
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
|
||||
|
||||
size = 0xdeadbeef;
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, NULL);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 4, "Got size %d.\n", size);
|
||||
|
||||
size = sizeof(buffer);
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
todo_wine ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
/* The contents seem to reflect the last frame rendered. */
|
||||
|
||||
hr = IMemInputPin_GetAllocator(input, &allocator);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IMemAllocator_Commit(allocator);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
IMemAllocator_Release(allocator);
|
||||
|
||||
hr = IMediaControl_Pause(control);
|
||||
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
|
||||
|
||||
size = sizeof(buffer);
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
todo_wine ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
/* The contents seem to reflect the last frame rendered. */
|
||||
|
||||
thread = send_frame(input);
|
||||
hr = IMediaControl_GetState(control, 1000, &state);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
size = 1;
|
||||
memset(buffer, 0xcc, sizeof(buffer));
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
todo_wine ok(size == 1, "Got size %d.\n", size);
|
||||
|
||||
size = sizeof(buffer);
|
||||
memset(buffer, 0xcc, sizeof(buffer));
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
todo_wine ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
for (i = 0; i < 32 * 16; ++i)
|
||||
ok((data[i] & 0xffffff) == 0x555555, "Got unexpected color %08x at %u.\n", data[i], i);
|
||||
|
||||
hr = IMediaControl_Run(control);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
join_thread(thread);
|
||||
|
||||
size = sizeof(buffer);
|
||||
memset(buffer, 0xcc, sizeof(buffer));
|
||||
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
|
||||
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(size == sizeof(buffer), "Got size %d.\n", size);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
ok(!memcmp(bih, &expect_bih, sizeof(BITMAPINFOHEADER)), "Bitmap headers didn't match.\n");
|
||||
for (i = 0; i < 32 * 16; ++i)
|
||||
ok((data[i] & 0xffffff) == 0x555555, "Got unexpected color %08x at %u.\n", data[i], i);
|
||||
}
|
||||
|
||||
hr = IMediaControl_Stop(control);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
IBasicVideo_Release(video);
|
||||
IMediaControl_Release(control);
|
||||
}
|
||||
|
||||
static void test_connect_pin(void)
|
||||
{
|
||||
VIDEOINFOHEADER vih =
|
||||
|
@ -1364,6 +1461,7 @@ static void test_connect_pin(void)
|
|||
|
||||
test_filter_state(input, graph);
|
||||
test_flushing(pin, input, graph);
|
||||
test_current_image(filter, input, graph, &vih.bmiHeader);
|
||||
|
||||
hr = IFilterGraph2_Disconnect(graph, pin);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
|
Loading…
Reference in New Issue