Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/quartz_private.h | 2 -- dlls/quartz/videorenderer.c | 24 ------------------------ dlls/quartz/vmr9.c | 24 ------------------------ dlls/quartz/window.c | 7 +++++-- 4 files changed, 5 insertions(+), 52 deletions(-)
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index 7e49367a932..d3f3a8915ae 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -112,8 +112,6 @@ struct video_window_ops BOOL (*resize)(struct video_window *window, LONG height, LONG width);
HRESULT (*get_current_image)(struct video_window *window, LONG *size, LONG *image); - HRESULT (WINAPI *pfnSetDefaultSourceRect)(struct video_window *window); - HRESULT (WINAPI *pfnSetDefaultTargetRect)(struct video_window *window); };
void video_window_cleanup(struct video_window *window) DECLSPEC_HIDDEN; diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index ea5142e3213..8504a51d747 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -314,35 +314,11 @@ static HRESULT video_renderer_get_current_image(struct video_window *iface, LONG return S_OK; }
-static HRESULT WINAPI VideoRenderer_SetDefaultSourceRect(struct video_window *iface) -{ - struct video_renderer *This = impl_from_video_window(iface); - - SetRect(&This->window.src, 0, 0, This->VideoWidth, This->VideoHeight); - - return S_OK; -} - -static HRESULT WINAPI VideoRenderer_SetDefaultTargetRect(struct video_window *iface) -{ - struct video_renderer *This = impl_from_video_window(iface); - RECT rect; - - if (!GetClientRect(This->window.hwnd, &rect)) - return E_FAIL; - - SetRect(&This->window.dst, 0, 0, rect.right, rect.bottom); - - return S_OK; -} - static const struct video_window_ops window_ops = { .get_default_rect = video_renderer_get_default_rect, .resize = video_renderer_resize, .get_current_image = video_renderer_get_current_image, - .pfnSetDefaultSourceRect = VideoRenderer_SetDefaultSourceRect, - .pfnSetDefaultTargetRect = VideoRenderer_SetDefaultTargetRect, };
static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface, diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 4fb8ddc32f4..64ef4a53e3e 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -734,35 +734,11 @@ out: return hr; }
-static HRESULT WINAPI VMR9_SetDefaultSourceRect(struct video_window *iface) -{ - struct quartz_vmr *filter = impl_from_video_window(iface); - - SetRect(&filter->window.src, 0, 0, filter->VideoWidth, filter->VideoHeight); - - return S_OK; -} - -static HRESULT WINAPI VMR9_SetDefaultTargetRect(struct video_window *iface) -{ - RECT rect; - struct quartz_vmr *filter = impl_from_video_window(iface); - - if (!GetClientRect(filter->window.hwnd, &rect)) - return E_FAIL; - - SetRect(&filter->window.dst, 0, 0, rect.right, rect.bottom); - - return S_OK; -} - static const struct video_window_ops window_ops = { .get_default_rect = vmr_get_default_rect, .resize = vmr_resize, .get_current_image = vmr_get_current_image, - .pfnSetDefaultSourceRect = VMR9_SetDefaultSourceRect, - .pfnSetDefaultTargetRect = VMR9_SetDefaultTargetRect, };
static const IVideoWindowVtbl IVideoWindow_VTable = diff --git a/dlls/quartz/window.c b/dlls/quartz/window.c index ebd3ffe3024..d383370e5d8 100644 --- a/dlls/quartz/window.c +++ b/dlls/quartz/window.c @@ -1055,10 +1055,12 @@ static HRESULT WINAPI basic_video_GetSourcePosition(IBasicVideo *iface, static HRESULT WINAPI basic_video_SetDefaultSourcePosition(IBasicVideo *iface) { struct video_window *window = impl_from_IBasicVideo(iface); + const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(window);
TRACE("window %p.\n", window);
- return window->ops->pfnSetDefaultSourceRect(window); + SetRect(&window->src, 0, 0, bitmap_header->biWidth, bitmap_header->biHeight); + return S_OK; }
static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface, @@ -1098,7 +1100,8 @@ static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *ifa
TRACE("window %p.\n", window);
- return window->ops->pfnSetDefaultTargetRect(window); + GetClientRect(window->hwnd, &window->dst); + return S_OK; }
static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *width, LONG *height)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/quartz_private.h | 4 ---- dlls/quartz/videorenderer.c | 11 ----------- dlls/quartz/vmr9.c | 11 ----------- dlls/quartz/window.c | 4 ++-- 4 files changed, 2 insertions(+), 28 deletions(-)
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index d3f3a8915ae..33cfb5671f5 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -106,11 +106,7 @@ struct video_window
struct video_window_ops { - /* Required */ RECT (*get_default_rect)(struct video_window *window); - /* Optional, WinProc Related */ - BOOL (*resize)(struct video_window *window, LONG height, LONG width); - HRESULT (*get_current_image)(struct video_window *window, LONG *size, LONG *image); };
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 8504a51d747..e004d0fc214 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -245,16 +245,6 @@ static RECT video_renderer_get_default_rect(struct video_window *iface) return defRect; }
-static BOOL video_renderer_resize(struct video_window *iface, LONG Width, LONG Height) -{ - struct video_renderer *filter = impl_from_video_window(iface); - - TRACE("WM_SIZE %d %d\n", Width, Height); - GetClientRect(iface->hwnd, &filter->window.dst); - - return TRUE; -} - static const struct strmbase_renderer_ops renderer_ops = { .pfnCheckMediaType = VideoRenderer_CheckMediaType, @@ -317,7 +307,6 @@ static HRESULT video_renderer_get_current_image(struct video_window *iface, LONG static const struct video_window_ops window_ops = { .get_default_rect = video_renderer_get_default_rect, - .resize = video_renderer_resize, .get_current_image = video_renderer_get_current_image, };
diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 64ef4a53e3e..758ede61554 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -663,16 +663,6 @@ static RECT vmr_get_default_rect(struct video_window *This) return defRect; }
-static BOOL vmr_resize(struct video_window *This, LONG Width, LONG Height) -{ - struct quartz_vmr *pVMR9 = impl_from_video_window(This); - - TRACE("WM_SIZE %d %d\n", Width, Height); - GetClientRect(This->hwnd, &pVMR9->window.dst); - - return TRUE; -} - static HRESULT vmr_get_current_image(struct video_window *iface, LONG *size, LONG *image) { struct quartz_vmr *filter = impl_from_video_window(iface); @@ -737,7 +727,6 @@ out: static const struct video_window_ops window_ops = { .get_default_rect = vmr_get_default_rect, - .resize = vmr_resize, .get_current_image = vmr_get_current_image, };
diff --git a/dlls/quartz/window.c b/dlls/quartz/window.c index d383370e5d8..ada6b99ddb6 100644 --- a/dlls/quartz/window.c +++ b/dlls/quartz/window.c @@ -68,8 +68,8 @@ static LRESULT CALLBACK WndProcW(HWND hwnd, UINT message, WPARAM wparam, LPARAM } break; case WM_SIZE: - if (window->ops->resize) - return window->ops->resize(window, LOWORD(lparam), HIWORD(lparam)); + GetClientRect(window->hwnd, &window->dst); + break; }
return DefWindowProcW(hwnd, message, wparam, lparam);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/quartz_private.h | 3 ++- dlls/quartz/window.c | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index 33cfb5671f5..5c391481f25 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -94,9 +94,10 @@ struct video_window IBasicVideo IBasicVideo_iface;
RECT src, dst; + BOOL default_dst;
- HWND hwnd; BOOL AutoShow; + HWND hwnd; HWND hwndDrain; HWND hwndOwner; struct strmbase_filter *pFilter; diff --git a/dlls/quartz/window.c b/dlls/quartz/window.c index ada6b99ddb6..efafb70daa8 100644 --- a/dlls/quartz/window.c +++ b/dlls/quartz/window.c @@ -68,7 +68,8 @@ static LRESULT CALLBACK WndProcW(HWND hwnd, UINT message, WPARAM wparam, LPARAM } break; case WM_SIZE: - GetClientRect(window->hwnd, &window->dst); + if (window->default_dst) + GetClientRect(window->hwnd, &window->dst); break; }
@@ -926,6 +927,7 @@ static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG l
TRACE("window %p, left %d.\n", window, left);
+ window->default_dst = FALSE; OffsetRect(&window->dst, left - window->dst.left, 0); return S_OK; } @@ -952,6 +954,7 @@ static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG if (width <= 0) return E_INVALIDARG;
+ window->default_dst = FALSE; window->dst.right = window->dst.left + width; return S_OK; } @@ -975,6 +978,7 @@ static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG to
TRACE("window %p, top %d.\n", window, top);
+ window->default_dst = FALSE; OffsetRect(&window->dst, 0, top - window->dst.top); return S_OK; } @@ -1001,6 +1005,7 @@ static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG if (height <= 0) return E_INVALIDARG;
+ window->default_dst = FALSE; window->dst.bottom = window->dst.top + height; return S_OK; } @@ -1073,6 +1078,7 @@ static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface, if (width <= 0 || height <= 0) return E_INVALIDARG;
+ window->default_dst = FALSE; SetRect(&window->dst, left, top, left + width, top + height); return S_OK; } @@ -1100,6 +1106,7 @@ static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *ifa
TRACE("window %p.\n", window);
+ window->default_dst = TRUE; GetClientRect(window->hwnd, &window->dst); return S_OK; } @@ -1155,9 +1162,11 @@ static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface)
static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface) { - FIXME("iface %p, stub!\n", iface); + struct video_window *window = impl_from_IBasicVideo(iface);
- return S_OK; + TRACE("window %p.\n", window); + + return window->default_dst ? S_OK : S_FALSE; }
static const IBasicVideoVtbl basic_video_vtbl = @@ -1216,6 +1225,7 @@ void video_window_init(struct video_window *window, const IVideoWindowVtbl *vtbl window->ops = ops; window->IVideoWindow_iface.lpVtbl = vtbl; window->IBasicVideo_iface.lpVtbl = &basic_video_vtbl; + window->default_dst = TRUE; window->AutoShow = OATRUE; window->pFilter = owner; window->pPin = pin;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/window.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/quartz/window.c b/dlls/quartz/window.c index efafb70daa8..a5ff4979efc 100644 --- a/dlls/quartz/window.c +++ b/dlls/quartz/window.c @@ -1155,9 +1155,16 @@ static HRESULT WINAPI basic_video_GetCurrentImage(IBasicVideo *iface, LONG *size
static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface) { - FIXME("iface %p, stub!\n", iface); + struct video_window *window = impl_from_IBasicVideo(iface); + const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(window);
- return S_OK; + TRACE("window %p.\n", window); + + if (!window->src.left && !window->src.top + && window->src.right == bitmap_header->biWidth + && window->src.bottom == bitmap_header->biHeight) + return S_OK; + return S_FALSE; }
static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/videorenderer.c | 427 ++++++++++++++++++++++++++++ dlls/quartz/tests/vmr7.c | 450 ++++++++++++++++++++++++++++++ dlls/quartz/tests/vmr9.c | 450 ++++++++++++++++++++++++++++++ 3 files changed, 1327 insertions(+)
diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c index b116b044b4a..7330859466e 100644 --- a/dlls/quartz/tests/videorenderer.c +++ b/dlls/quartz/tests/videorenderer.c @@ -2306,6 +2306,432 @@ static void test_video_window(void) DestroyWindow(our_hwnd); }
+static void check_source_position_(int line, IBasicVideo *video, + LONG expect_left, LONG expect_top, LONG expect_width, LONG expect_height) +{ + LONG left, top, width, height, l; + HRESULT hr; + + left = top = width = height = 0xdeadbeef; + hr = IBasicVideo_GetSourcePosition(video, &left, &top, &width, &height); + ok_(__FILE__,line)(hr == S_OK, "Got hr %#x.\n", hr); + ok_(__FILE__,line)(left == expect_left, "Got left %d.\n", left); + ok_(__FILE__,line)(top == expect_top, "Got top %d.\n", top); + ok_(__FILE__,line)(width == expect_width, "Got width %d.\n", width); + ok_(__FILE__,line)(height == expect_height, "Got height %d.\n", height); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceLeft(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get left, hr %#x.\n", hr); + ok_(__FILE__,line)(l == left, "Got left %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceTop(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get top, hr %#x.\n", hr); + ok_(__FILE__,line)(l == top, "Got top %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceWidth(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get width, hr %#x.\n", hr); + ok_(__FILE__,line)(l == width, "Got width %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceHeight(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get height, hr %#x.\n", hr); + ok_(__FILE__,line)(l == height, "Got height %d.\n", l); +} +#define check_source_position(a,b,c,d,e) check_source_position_(__LINE__,a,b,c,d,e) + +static void test_basic_video_source(IBasicVideo *video) +{ + HRESULT hr; + + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceLeft(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceLeft(video, 10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceTop(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceTop(video, 10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceWidth(video, -500); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 700); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 500, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceHeight(video, -300); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 600); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceLeft(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceLeft(video, 10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 10, 0, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceTop(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceTop(video, 20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 10, 20, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 4, 5, 60, 40); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 0, 0, 600, 400); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBasicVideo_SetDefaultSourcePosition(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); +} + +static void check_destination_position_(int line, IBasicVideo *video, + LONG expect_left, LONG expect_top, LONG expect_width, LONG expect_height) +{ + LONG left, top, width, height, l; + HRESULT hr; + + left = top = width = height = 0xdeadbeef; + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, &width, &height); + ok_(__FILE__,line)(hr == S_OK, "Failed to get position, hr %#x.\n", hr); + ok_(__FILE__,line)(left == expect_left, "Got left %d.\n", left); + ok_(__FILE__,line)(top == expect_top, "Got top %d.\n", top); + ok_(__FILE__,line)(width == expect_width, "Got width %d.\n", width); + ok_(__FILE__,line)(height == expect_height, "Got height %d.\n", height); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationLeft(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get left, hr %#x.\n", hr); + ok_(__FILE__,line)(l == left, "Got left %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationTop(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get top, hr %#x.\n", hr); + ok_(__FILE__,line)(l == top, "Got top %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationWidth(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get width, hr %#x.\n", hr); + ok_(__FILE__,line)(l == width, "Got width %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationHeight(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get height, hr %#x.\n", hr); + ok_(__FILE__,line)(l == height, "Got height %d.\n", l); +} +#define check_destination_position(a,b,c,d,e) check_destination_position_(__LINE__,a,b,c,d,e) + +static void test_basic_video_destination(IBasicVideo *video) +{ + IVideoWindow *window; + HRESULT hr; + RECT rect; + + IBasicVideo_QueryInterface(video, &IID_IVideoWindow, (void **)&window); + + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationLeft(video, -10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, -10, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationLeft(video, 10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationTop(video, -20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, -20, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationTop(video, 20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationWidth(video, -700); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationWidth(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationWidth(video, 700); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 700, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationWidth(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationHeight(video, -500); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationHeight(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationHeight(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 500); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationHeight(video, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 4, 5, 60, 40); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 0, 0, 600, 400); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBasicVideo_SetDefaultDestinationPosition(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + SetRect(&rect, 100, 200, 500, 500); + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + hr = IVideoWindow_SetWindowPosition(window, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 0, 0, 400, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + SetRect(&rect, 100, 200, 600, 600); + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + hr = IVideoWindow_SetWindowPosition(window, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IVideoWindow_Release(window); +} + +static void test_basic_video(void) +{ + VIDEOINFOHEADER vih = + { + .AvgTimePerFrame = 200000, + .rcSource = {4, 6, 16, 12}, + .rcTarget = {40, 60, 120, 160}, + .bmiHeader.biSize = sizeof(BITMAPINFOHEADER), + .bmiHeader.biBitCount = 32, + .bmiHeader.biWidth = 600, + .bmiHeader.biHeight = 400, + .bmiHeader.biPlanes = 1, + .bmiHeader.biCompression = BI_RGB, + }; + AM_MEDIA_TYPE req_mt = + { + .majortype = MEDIATYPE_Video, + .subtype = MEDIASUBTYPE_RGB32, + .formattype = FORMAT_VideoInfo, + .cbFormat = sizeof(vih), + .pbFormat = (BYTE *)&vih, + }; + IBaseFilter *filter = create_video_renderer(); + IFilterGraph2 *graph = create_graph(); + LONG left, top, width, height, l; + struct testfilter source; + ITypeInfo *typeinfo; + IBasicVideo *video; + TYPEATTR *typeattr; + REFTIME reftime; + HRESULT hr; + UINT count; + ULONG ref; + IPin *pin; + + IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video); + IBaseFilter_FindPin(filter, L"In", &pin); + + hr = IBasicVideo_GetTypeInfoCount(video, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + + hr = IBasicVideo_GetTypeInfo(video, 0, 0, &typeinfo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(typeattr->typekind == TKIND_DISPATCH, "Got kind %u.\n", typeattr->typekind); + ok(IsEqualGUID(&typeattr->guid, &IID_IBasicVideo), "Got IID %s.\n", wine_dbgstr_guid(&typeattr->guid)); + ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr); + ITypeInfo_Release(typeinfo); + + hr = IBasicVideo_get_AvgTimePerFrame(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_AvgTimePerFrame(video, &reftime); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_BitRate(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_BitRate(video, &l); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_BitErrorRate(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_BitErrorRate(video, &l); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_VideoWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_VideoHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_SourceLeft(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceTop(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_DestinationLeft(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationTop(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetSourcePosition(video, NULL, &top, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, NULL, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, &top, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, &top, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetDestinationPosition(video, NULL, &top, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, NULL, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetVideoSize(video, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetVideoSize(video, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, NULL, &l); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, &l, NULL); + todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + testfilter_init(&source); + IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, L"vmr9"); + IFilterGraph2_AddFilter(graph, filter, L"source"); + hr = IFilterGraph2_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + reftime = 0.0; + hr = IBasicVideo_get_AvgTimePerFrame(video, &reftime); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(reftime == 0.02, "Got frame rate %.16e.\n", reftime); + + l = 0xdeadbeef; + hr = IBasicVideo_get_BitRate(video, &l); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!l, "Got bit rate %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_BitErrorRate(video, &l); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!l, "Got bit rate %d.\n", l); + + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, &l, NULL); + todo_wine ok(hr == VFW_E_NO_PALETTE_AVAILABLE, "Got hr %#x.\n", hr); + + width = height = 0xdeadbeef; + hr = IBasicVideo_GetVideoSize(video, &width, &height); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(width == 600, "Got width %d.\n", width); + ok(height == 400, "Got height %d.\n", height); + + test_basic_video_source(video); + test_basic_video_destination(video); + + ref = IFilterGraph2_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IBasicVideo_Release(video); + IPin_Release(pin); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(videorenderer) { CoInitialize(NULL); @@ -2321,6 +2747,7 @@ START_TEST(videorenderer) test_connect_pin(); test_overlay(); test_video_window(); + test_basic_video();
CoUninitialize(); } diff --git a/dlls/quartz/tests/vmr7.c b/dlls/quartz/tests/vmr7.c index c7e11593d23..1f0af817f0b 100644 --- a/dlls/quartz/tests/vmr7.c +++ b/dlls/quartz/tests/vmr7.c @@ -2294,6 +2294,455 @@ static void test_video_window(void) DestroyWindow(our_hwnd); }
+static void check_source_position_(int line, IBasicVideo *video, + LONG expect_left, LONG expect_top, LONG expect_width, LONG expect_height) +{ + LONG left, top, width, height, l; + HRESULT hr; + + left = top = width = height = 0xdeadbeef; + hr = IBasicVideo_GetSourcePosition(video, &left, &top, &width, &height); + ok_(__FILE__,line)(hr == S_OK, "Got hr %#x.\n", hr); + ok_(__FILE__,line)(left == expect_left, "Got left %d.\n", left); + ok_(__FILE__,line)(top == expect_top, "Got top %d.\n", top); + ok_(__FILE__,line)(width == expect_width, "Got width %d.\n", width); + ok_(__FILE__,line)(height == expect_height, "Got height %d.\n", height); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceLeft(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get left, hr %#x.\n", hr); + ok_(__FILE__,line)(l == left, "Got left %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceTop(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get top, hr %#x.\n", hr); + ok_(__FILE__,line)(l == top, "Got top %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceWidth(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get width, hr %#x.\n", hr); + ok_(__FILE__,line)(l == width, "Got width %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceHeight(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get height, hr %#x.\n", hr); + ok_(__FILE__,line)(l == height, "Got height %d.\n", l); +} +#define check_source_position(a,b,c,d,e) check_source_position_(__LINE__,a,b,c,d,e) + +static void test_basic_video_source(IBasicVideo *video) +{ + HRESULT hr; + + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceLeft(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceLeft(video, 10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceTop(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceTop(video, 10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceWidth(video, -500); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 700); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 500, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceHeight(video, -300); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 600); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceLeft(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceLeft(video, 10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 10, 0, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceTop(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceTop(video, 20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 10, 20, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 4, 5, 60, 40); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 0, 0, 600, 400); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBasicVideo_SetDefaultSourcePosition(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); +} + +static void check_destination_position_(int line, IBasicVideo *video, + LONG expect_left, LONG expect_top, LONG expect_width, LONG expect_height) +{ + LONG left, top, width, height, l; + HRESULT hr; + + left = top = width = height = 0xdeadbeef; + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, &width, &height); + ok_(__FILE__,line)(hr == S_OK, "Failed to get position, hr %#x.\n", hr); + ok_(__FILE__,line)(left == expect_left, "Got left %d.\n", left); + ok_(__FILE__,line)(top == expect_top, "Got top %d.\n", top); + ok_(__FILE__,line)(width == expect_width, "Got width %d.\n", width); + ok_(__FILE__,line)(height == expect_height, "Got height %d.\n", height); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationLeft(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get left, hr %#x.\n", hr); + ok_(__FILE__,line)(l == left, "Got left %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationTop(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get top, hr %#x.\n", hr); + ok_(__FILE__,line)(l == top, "Got top %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationWidth(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get width, hr %#x.\n", hr); + ok_(__FILE__,line)(l == width, "Got width %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationHeight(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get height, hr %#x.\n", hr); + ok_(__FILE__,line)(l == height, "Got height %d.\n", l); +} +#define check_destination_position(a,b,c,d,e) check_destination_position_(__LINE__,a,b,c,d,e) + +static void test_basic_video_destination(IBasicVideo *video) +{ + IVideoWindow *window; + HRESULT hr; + RECT rect; + + IBasicVideo_QueryInterface(video, &IID_IVideoWindow, (void **)&window); + + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationLeft(video, -10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, -10, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationLeft(video, 10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationTop(video, -20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, -20, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationTop(video, 20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationWidth(video, -700); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationWidth(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationWidth(video, 700); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 700, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationWidth(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationHeight(video, -500); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationHeight(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationHeight(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 500); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationHeight(video, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 4, 5, 60, 40); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 0, 0, 600, 400); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBasicVideo_SetDefaultDestinationPosition(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + SetRect(&rect, 100, 200, 500, 500); + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + hr = IVideoWindow_SetWindowPosition(window, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 0, 0, 400, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + SetRect(&rect, 100, 200, 600, 600); + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + hr = IVideoWindow_SetWindowPosition(window, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IVideoWindow_Release(window); +} + +static void test_basic_video(void) +{ + ALLOCATOR_PROPERTIES req_props = {1, 600 * 400 * 4, 1, 0}, ret_props; + VIDEOINFOHEADER vih = + { + .AvgTimePerFrame = 200000, + .rcSource = {4, 6, 16, 12}, + .rcTarget = {40, 60, 120, 160}, + .bmiHeader.biSize = sizeof(BITMAPINFOHEADER), + .bmiHeader.biBitCount = 32, + .bmiHeader.biWidth = 600, + .bmiHeader.biHeight = 400, + .bmiHeader.biPlanes = 1, + .bmiHeader.biCompression = BI_RGB, + }; + AM_MEDIA_TYPE req_mt = + { + .majortype = MEDIATYPE_Video, + .subtype = MEDIASUBTYPE_RGB32, + .formattype = FORMAT_VideoInfo, + .cbFormat = sizeof(vih), + .pbFormat = (BYTE *)&vih, + }; + IBaseFilter *filter = create_vmr7(VMR9Mode_Windowed); + IFilterGraph2 *graph = create_graph(); + LONG left, top, width, height, l; + struct testfilter source; + IMemAllocator *allocator; + IMemInputPin *input; + ITypeInfo *typeinfo; + IBasicVideo *video; + TYPEATTR *typeattr; + REFTIME reftime; + HRESULT hr; + UINT count; + ULONG ref; + IPin *pin; + + IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video); + IBaseFilter_FindPin(filter, L"VMR Input0", &pin); + IPin_QueryInterface(pin, &IID_IMemInputPin, (void **)&input); + + hr = IBasicVideo_GetTypeInfoCount(video, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + + hr = IBasicVideo_GetTypeInfo(video, 0, 0, &typeinfo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(typeattr->typekind == TKIND_DISPATCH, "Got kind %u.\n", typeattr->typekind); + ok(IsEqualGUID(&typeattr->guid, &IID_IBasicVideo), "Got IID %s.\n", wine_dbgstr_guid(&typeattr->guid)); + ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr); + ITypeInfo_Release(typeinfo); + + hr = IBasicVideo_get_AvgTimePerFrame(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_AvgTimePerFrame(video, &reftime); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_BitRate(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_BitRate(video, &l); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_BitErrorRate(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_BitErrorRate(video, &l); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_VideoWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_VideoHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_SourceLeft(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceTop(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_DestinationLeft(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationTop(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetSourcePosition(video, NULL, &top, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, NULL, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, &top, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, &top, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetDestinationPosition(video, NULL, &top, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, NULL, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetVideoSize(video, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetVideoSize(video, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, NULL, &l); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, &l, NULL); + todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + testfilter_init(&source); + IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, L"vmr9"); + IFilterGraph2_AddFilter(graph, filter, L"source"); + hr = IFilterGraph2_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &req_mt); + if (hr == E_FAIL) + { + skip("Got E_FAIL when connecting.\n"); + goto out; + } + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemInputPin_GetAllocator(input, &allocator); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!memcmp(&ret_props, &req_props, sizeof(req_props)), "Properties did not match.\n"); + hr = IMemAllocator_Commit(allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IMemAllocator_Release(allocator); + } + + reftime = 0.0; + hr = IBasicVideo_get_AvgTimePerFrame(video, &reftime); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(reftime == 0.02, "Got frame rate %.16e.\n", reftime); + + l = 0xdeadbeef; + hr = IBasicVideo_get_BitRate(video, &l); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!l, "Got bit rate %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_BitErrorRate(video, &l); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!l, "Got bit rate %d.\n", l); + + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, &l, NULL); + todo_wine ok(hr == VFW_E_NO_PALETTE_AVAILABLE, "Got hr %#x.\n", hr); + + width = height = 0xdeadbeef; + hr = IBasicVideo_GetVideoSize(video, &width, &height); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(width == 600, "Got width %d.\n", width); + ok(height == 400, "Got height %d.\n", height); + + test_basic_video_source(video); + test_basic_video_destination(video); + +out: + ref = IFilterGraph2_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IBasicVideo_Release(video); + IMemInputPin_Release(input); + IPin_Release(pin); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(vmr7) { CoInitialize(NULL); @@ -2310,6 +2759,7 @@ START_TEST(vmr7) test_connect_pin(); test_overlay(); test_video_window(); + test_basic_video();
CoUninitialize(); } diff --git a/dlls/quartz/tests/vmr9.c b/dlls/quartz/tests/vmr9.c index 003088f8d7d..656f943ca35 100644 --- a/dlls/quartz/tests/vmr9.c +++ b/dlls/quartz/tests/vmr9.c @@ -3280,6 +3280,455 @@ static void test_surface_allocator_notify_refcount(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void check_source_position_(int line, IBasicVideo *video, + LONG expect_left, LONG expect_top, LONG expect_width, LONG expect_height) +{ + LONG left, top, width, height, l; + HRESULT hr; + + left = top = width = height = 0xdeadbeef; + hr = IBasicVideo_GetSourcePosition(video, &left, &top, &width, &height); + ok_(__FILE__,line)(hr == S_OK, "Got hr %#x.\n", hr); + ok_(__FILE__,line)(left == expect_left, "Got left %d.\n", left); + ok_(__FILE__,line)(top == expect_top, "Got top %d.\n", top); + ok_(__FILE__,line)(width == expect_width, "Got width %d.\n", width); + ok_(__FILE__,line)(height == expect_height, "Got height %d.\n", height); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceLeft(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get left, hr %#x.\n", hr); + ok_(__FILE__,line)(l == left, "Got left %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceTop(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get top, hr %#x.\n", hr); + ok_(__FILE__,line)(l == top, "Got top %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceWidth(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get width, hr %#x.\n", hr); + ok_(__FILE__,line)(l == width, "Got width %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_SourceHeight(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get height, hr %#x.\n", hr); + ok_(__FILE__,line)(l == height, "Got height %d.\n", l); +} +#define check_source_position(a,b,c,d,e) check_source_position_(__LINE__,a,b,c,d,e) + +static void test_basic_video_source(IBasicVideo *video) +{ + HRESULT hr; + + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceLeft(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceLeft(video, 10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceTop(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceTop(video, 10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceWidth(video, -500); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 700); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceWidth(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 500, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceHeight(video, -300); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 600); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceHeight(video, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceLeft(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceLeft(video, 10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 10, 0, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_SourceTop(video, -10); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_SourceTop(video, 20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 10, 20, 500, 300); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 4, 5, 60, 40); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 0, 0, 600, 400); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetSourcePosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBasicVideo_SetDefaultSourcePosition(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_source_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultSource(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); +} + +static void check_destination_position_(int line, IBasicVideo *video, + LONG expect_left, LONG expect_top, LONG expect_width, LONG expect_height) +{ + LONG left, top, width, height, l; + HRESULT hr; + + left = top = width = height = 0xdeadbeef; + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, &width, &height); + ok_(__FILE__,line)(hr == S_OK, "Failed to get position, hr %#x.\n", hr); + ok_(__FILE__,line)(left == expect_left, "Got left %d.\n", left); + ok_(__FILE__,line)(top == expect_top, "Got top %d.\n", top); + ok_(__FILE__,line)(width == expect_width, "Got width %d.\n", width); + ok_(__FILE__,line)(height == expect_height, "Got height %d.\n", height); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationLeft(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get left, hr %#x.\n", hr); + ok_(__FILE__,line)(l == left, "Got left %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationTop(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get top, hr %#x.\n", hr); + ok_(__FILE__,line)(l == top, "Got top %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationWidth(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get width, hr %#x.\n", hr); + ok_(__FILE__,line)(l == width, "Got width %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_DestinationHeight(video, &l); + ok_(__FILE__,line)(hr == S_OK, "Failed to get height, hr %#x.\n", hr); + ok_(__FILE__,line)(l == height, "Got height %d.\n", l); +} +#define check_destination_position(a,b,c,d,e) check_destination_position_(__LINE__,a,b,c,d,e) + +static void test_basic_video_destination(IBasicVideo *video) +{ + IVideoWindow *window; + HRESULT hr; + RECT rect; + + IBasicVideo_QueryInterface(video, &IID_IVideoWindow, (void **)&window); + + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationLeft(video, -10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, -10, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationLeft(video, 10); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationTop(video, -20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, -20, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationTop(video, 20); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationWidth(video, -700); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationWidth(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationWidth(video, 700); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 700, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationWidth(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationHeight(video, -500); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationHeight(video, 0); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + hr = IBasicVideo_put_DestinationHeight(video, 500); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 500); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_put_DestinationHeight(video, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 10, 20, 500, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 4, 5, 60, 40); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 0, 0, 600, 400); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 4, 5, 60, 40); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IBasicVideo_SetDefaultDestinationPosition(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 600, 400); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + SetRect(&rect, 100, 200, 500, 500); + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + hr = IVideoWindow_SetWindowPosition(window, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBasicVideo_SetDestinationPosition(video, 0, 0, 400, 300); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + SetRect(&rect, 100, 200, 600, 600); + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + hr = IVideoWindow_SetWindowPosition(window, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top); + ok(hr == S_OK, "Got hr %#x.\n", hr); + check_destination_position(video, 0, 0, 400, 300); + hr = IBasicVideo_IsUsingDefaultDestination(video); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IVideoWindow_Release(window); +} + +static void test_basic_video(void) +{ + ALLOCATOR_PROPERTIES req_props = {1, 600 * 400 * 4, 1, 0}, ret_props; + VIDEOINFOHEADER vih = + { + .AvgTimePerFrame = 200000, + .rcSource = {4, 6, 16, 12}, + .rcTarget = {40, 60, 120, 160}, + .bmiHeader.biSize = sizeof(BITMAPINFOHEADER), + .bmiHeader.biBitCount = 32, + .bmiHeader.biWidth = 600, + .bmiHeader.biHeight = 400, + .bmiHeader.biPlanes = 1, + .bmiHeader.biCompression = BI_RGB, + }; + AM_MEDIA_TYPE req_mt = + { + .majortype = MEDIATYPE_Video, + .subtype = MEDIASUBTYPE_RGB32, + .formattype = FORMAT_VideoInfo, + .cbFormat = sizeof(vih), + .pbFormat = (BYTE *)&vih, + }; + IBaseFilter *filter = create_vmr9(VMR9Mode_Windowed); + IFilterGraph2 *graph = create_graph(); + LONG left, top, width, height, l; + struct testfilter source; + IMemAllocator *allocator; + IMemInputPin *input; + ITypeInfo *typeinfo; + IBasicVideo *video; + TYPEATTR *typeattr; + REFTIME reftime; + HRESULT hr; + UINT count; + ULONG ref; + IPin *pin; + + IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video); + IBaseFilter_FindPin(filter, L"VMR Input0", &pin); + IPin_QueryInterface(pin, &IID_IMemInputPin, (void **)&input); + + hr = IBasicVideo_GetTypeInfoCount(video, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + + hr = IBasicVideo_GetTypeInfo(video, 0, 0, &typeinfo); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(typeattr->typekind == TKIND_DISPATCH, "Got kind %u.\n", typeattr->typekind); + ok(IsEqualGUID(&typeattr->guid, &IID_IBasicVideo), "Got IID %s.\n", wine_dbgstr_guid(&typeattr->guid)); + ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr); + ITypeInfo_Release(typeinfo); + + hr = IBasicVideo_get_AvgTimePerFrame(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_AvgTimePerFrame(video, &reftime); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_BitRate(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_BitRate(video, &l); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_BitErrorRate(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_BitErrorRate(video, &l); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_VideoWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_VideoHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_SourceLeft(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceTop(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_SourceHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_get_DestinationLeft(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationWidth(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationTop(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_get_DestinationHeight(video, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetSourcePosition(video, NULL, &top, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, NULL, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, &top, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetSourcePosition(video, &left, &top, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetDestinationPosition(video, NULL, &top, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, NULL, &width, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetDestinationPosition(video, &left, &top, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetVideoSize(video, &width, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetVideoSize(video, NULL, &height); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, NULL, &l); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, &l, NULL); + todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + testfilter_init(&source); + IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, L"vmr9"); + IFilterGraph2_AddFilter(graph, filter, L"source"); + hr = IFilterGraph2_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &req_mt); + if (hr == E_FAIL) + { + skip("Got E_FAIL when connecting.\n"); + goto out; + } + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemInputPin_GetAllocator(input, &allocator); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + hr = IMemAllocator_SetProperties(allocator, &req_props, &ret_props); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!memcmp(&ret_props, &req_props, sizeof(req_props)), "Properties did not match.\n"); + hr = IMemAllocator_Commit(allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IMemAllocator_Release(allocator); + } + + reftime = 0.0; + hr = IBasicVideo_get_AvgTimePerFrame(video, &reftime); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(reftime == 0.02, "Got frame rate %.16e.\n", reftime); + + l = 0xdeadbeef; + hr = IBasicVideo_get_BitRate(video, &l); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!l, "Got bit rate %d.\n", l); + + l = 0xdeadbeef; + hr = IBasicVideo_get_BitErrorRate(video, &l); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!l, "Got bit rate %d.\n", l); + + hr = IBasicVideo_GetVideoPaletteEntries(video, 0, 1, &l, NULL); + todo_wine ok(hr == VFW_E_NO_PALETTE_AVAILABLE, "Got hr %#x.\n", hr); + + width = height = 0xdeadbeef; + hr = IBasicVideo_GetVideoSize(video, &width, &height); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(width == 600, "Got width %d.\n", width); + ok(height == 400, "Got height %d.\n", height); + + test_basic_video_source(video); + test_basic_video_destination(video); + +out: + ref = IFilterGraph2_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IBasicVideo_Release(video); + IMemInputPin_Release(input); + IPin_Release(pin); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IBaseFilter_Release(&source.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(vmr9) { IBaseFilter *filter; @@ -3312,6 +3761,7 @@ START_TEST(vmr9) test_mixing_mode(); test_clipping_window(); test_surface_allocator_notify_refcount(); + test_basic_video();
CoUninitialize(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=71406
Your paranoid android.
=== w8 (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w8adm (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w1064v1507 (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w1064v1809 (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w1064v1809_2scr (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w1064v1809_ar (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w1064v1809_he (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w1064v1809_ja (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.
=== w1064v1809_zh_CN (32 bit report) ===
quartz: vmr9.c:3696: Test failed: Got frame rate 1.9999999552965164e-002.