quartz: Merge the BaseControlVideo object into the video_window object.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-05-06 19:28:52 -05:00 committed by Alexandre Julliard
parent 833829cb31
commit 14b7035054
6 changed files with 615 additions and 698 deletions

View File

@ -18,7 +18,6 @@ C_SRCS = \
passthrough.c \
regsvr.c \
systemclock.c \
video.c \
videorenderer.c \
vmr9.c \
window.c

View File

@ -91,6 +91,9 @@ BOOL get_media_type(const WCHAR *filename, GUID *majortype, GUID *subtype, GUID
struct video_window
{
IVideoWindow IVideoWindow_iface;
IBasicVideo IBasicVideo_iface;
RECT src, dst;
HWND hwnd;
BOOL AutoShow;
@ -107,6 +110,10 @@ struct video_window_ops
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);
HRESULT (WINAPI *pfnSetDefaultSourceRect)(struct video_window *window);
HRESULT (WINAPI *pfnSetDefaultTargetRect)(struct video_window *window);
};
void video_window_cleanup(struct video_window *window) DECLSPEC_HIDDEN;
@ -162,30 +169,4 @@ HRESULT WINAPI BaseControlWindowImpl_GetRestorePosition(IVideoWindow *iface, LON
HRESULT WINAPI BaseControlWindowImpl_HideCursor(IVideoWindow *iface, LONG HideCursor) DECLSPEC_HIDDEN;
HRESULT WINAPI BaseControlWindowImpl_IsCursorHidden(IVideoWindow *iface, LONG *CursorHidden) DECLSPEC_HIDDEN;
typedef struct tagBaseControlVideo
{
IBasicVideo IBasicVideo_iface;
RECT src, dst;
struct strmbase_filter *pFilter;
struct strmbase_pin *pPin;
const struct BaseControlVideoFuncTable *pFuncsTable;
} BaseControlVideo;
typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage);
typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This);
typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultTargetRect)(BaseControlVideo* This);
typedef struct BaseControlVideoFuncTable
{
BaseControlVideo_GetStaticImage pfnGetStaticImage;
BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect;
BaseControlVideo_SetDefaultTargetRect pfnSetDefaultTargetRect;
} BaseControlVideoFuncTable;
void basic_video_init(BaseControlVideo *video, struct strmbase_filter *filter,
struct strmbase_pin *pin, const BaseControlVideoFuncTable *func_table) DECLSPEC_HIDDEN;
#endif /* __QUARTZ_PRIVATE_INCLUDED__ */

View File

@ -1,581 +0,0 @@
/*
* Common implementation of IBasicVideo
*
* Copyright 2012 Aric Stewart, CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "quartz_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
static inline BaseControlVideo *impl_from_IBasicVideo(IBasicVideo *iface)
{
return CONTAINING_RECORD(iface, BaseControlVideo, IBasicVideo_iface);
}
static HRESULT BaseControlVideoImpl_CheckSourceRect(BaseControlVideo *This, RECT *pSourceRect)
{
LONG VideoWidth, VideoHeight;
HRESULT hr;
if (IsRectEmpty(pSourceRect))
return E_INVALIDARG;
hr = IBasicVideo_GetVideoSize(&This->IBasicVideo_iface, &VideoWidth, &VideoHeight);
if (FAILED(hr))
return hr;
if (pSourceRect->top < 0 || pSourceRect->left < 0 ||
pSourceRect->bottom > VideoHeight || pSourceRect->right > VideoWidth)
return E_INVALIDARG;
return S_OK;
}
static HRESULT BaseControlVideoImpl_CheckTargetRect(BaseControlVideo *This, RECT *pTargetRect)
{
if (IsRectEmpty(pTargetRect))
return E_INVALIDARG;
return S_OK;
}
static HRESULT WINAPI basic_video_QueryInterface(IBasicVideo *iface, REFIID iid, void **out)
{
BaseControlVideo *video = impl_from_IBasicVideo(iface);
return IUnknown_QueryInterface(video->pFilter->outer_unk, iid, out);
}
static ULONG WINAPI basic_video_AddRef(IBasicVideo *iface)
{
BaseControlVideo *video = impl_from_IBasicVideo(iface);
return IUnknown_AddRef(video->pFilter->outer_unk);
}
static ULONG WINAPI basic_video_Release(IBasicVideo *iface)
{
BaseControlVideo *video = impl_from_IBasicVideo(iface);
return IUnknown_Release(video->pFilter->outer_unk);
}
static HRESULT WINAPI basic_video_GetTypeInfoCount(IBasicVideo *iface, UINT *count)
{
TRACE("iface %p, count %p.\n", iface, count);
*count = 1;
return S_OK;
}
static HRESULT WINAPI basic_video_GetTypeInfo(IBasicVideo *iface, UINT index,
LCID lcid, ITypeInfo **typeinfo)
{
TRACE("iface %p, index %u, lcid %#x, typeinfo %p.\n", iface, index, lcid, typeinfo);
return strmbase_get_typeinfo(IBasicVideo_tid, typeinfo);
}
static HRESULT WINAPI basic_video_GetIDsOfNames(IBasicVideo *iface, REFIID iid,
LPOLESTR *names, UINT count, LCID lcid, DISPID *ids)
{
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("iface %p, iid %s, names %p, count %u, lcid %#x, ids %p.\n",
iface, debugstr_guid(iid), names, count, lcid, ids);
if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo)))
{
hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, ids);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID iid, LCID lcid,
WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *error_arg)
{
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("iface %p, id %d, iid %s, lcid %#x, flags %#x, params %p, result %p, excepinfo %p, error_arg %p.\n",
iface, id, debugstr_guid(iid), lcid, flags, params, result, excepinfo, error_arg);
if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo)))
{
hr = ITypeInfo_Invoke(typeinfo, iface, id, flags, params, result, excepinfo, error_arg);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static const VIDEOINFOHEADER *get_video_format(BaseControlVideo *video)
{
/* Members of VIDEOINFOHEADER up to bmiHeader are identical to those of
* VIDEOINFOHEADER2. */
return (const VIDEOINFOHEADER *)video->pPin->mt.pbFormat;
}
static const BITMAPINFOHEADER *get_bitmap_header(BaseControlVideo *video)
{
const AM_MEDIA_TYPE *mt = &video->pPin->mt;
if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader;
else
return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader;
}
static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *pAvgTimePerFrame)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
if (!pAvgTimePerFrame)
return E_POINTER;
if (!This->pPin->peer)
return VFW_E_NOT_CONNECTED;
TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
*pAvgTimePerFrame = get_video_format(This)->AvgTimePerFrame;
return S_OK;
}
static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate);
if (!pBitRate)
return E_POINTER;
if (!This->pPin->peer)
return VFW_E_NOT_CONNECTED;
*pBitRate = get_video_format(This)->dwBitRate;
return S_OK;
}
static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate);
if (!pBitErrorRate)
return E_POINTER;
if (!This->pPin->peer)
return VFW_E_NOT_CONNECTED;
*pBitErrorRate = get_video_format(This)->dwBitErrorRate;
return S_OK;
}
static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
if (!pVideoWidth)
return E_POINTER;
*pVideoWidth = get_bitmap_header(This)->biWidth;
return S_OK;
}
static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
if (!pVideoHeight)
return E_POINTER;
*pVideoHeight = abs(get_bitmap_header(This)->biHeight);
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceLeft(IBasicVideo *iface, LONG left)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, left %d.\n", iface, left);
if (left < 0 || This->src.right + left - This->src.left > get_bitmap_header(This)->biWidth)
return E_INVALIDARG;
OffsetRect(&This->src, left - This->src.left, 0);
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceLeft(IBasicVideo *iface, LONG *pSourceLeft)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
if (!pSourceLeft)
return E_POINTER;
*pSourceLeft = This->src.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceWidth(IBasicVideo *iface, LONG width)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, width %d.\n", iface, width);
if (width <= 0 || This->src.left + width > get_bitmap_header(This)->biWidth)
return E_INVALIDARG;
This->src.right = This->src.left + width;
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceWidth(IBasicVideo *iface, LONG *pSourceWidth)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
if (!pSourceWidth)
return E_POINTER;
*pSourceWidth = This->src.right - This->src.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceTop(IBasicVideo *iface, LONG top)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, top %d.\n", iface, top);
if (top < 0 || This->src.bottom + top - This->src.top > get_bitmap_header(This)->biHeight)
return E_INVALIDARG;
OffsetRect(&This->src, 0, top - This->src.top);
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceTop(IBasicVideo *iface, LONG *pSourceTop)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
if (!pSourceTop)
return E_POINTER;
*pSourceTop = This->src.top;
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceHeight(IBasicVideo *iface, LONG height)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, height %d.\n", iface, height);
if (height <= 0 || This->src.top + height > get_bitmap_header(This)->biHeight)
return E_INVALIDARG;
This->src.bottom = This->src.top + height;
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceHeight(IBasicVideo *iface, LONG *pSourceHeight)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
if (!pSourceHeight)
return E_POINTER;
*pSourceHeight = This->src.bottom - This->src.top;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG left)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, left %d.\n", iface, left);
OffsetRect(&This->dst, left - This->dst.left, 0);
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationLeft(IBasicVideo *iface, LONG *pDestinationLeft)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
if (!pDestinationLeft)
return E_POINTER;
*pDestinationLeft = This->dst.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG width)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, width %d.\n", iface, width);
if (width <= 0)
return E_INVALIDARG;
This->dst.right = This->dst.left + width;
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationWidth(IBasicVideo *iface, LONG *pDestinationWidth)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
if (!pDestinationWidth)
return E_POINTER;
*pDestinationWidth = This->dst.right - This->dst.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG top)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, top %d.\n", iface, top);
OffsetRect(&This->dst, 0, top - This->dst.top);
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationTop(IBasicVideo *iface, LONG *pDestinationTop)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
if (!pDestinationTop)
return E_POINTER;
*pDestinationTop = This->dst.top;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG height)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("iface %p, height %d.\n", iface, height);
if (height <= 0)
return E_INVALIDARG;
This->dst.bottom = This->dst.top + height;
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationHeight(IBasicVideo *iface, LONG *pDestinationHeight)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
if (!pDestinationHeight)
return E_POINTER;
*pDestinationHeight = This->dst.bottom - This->dst.top;
return S_OK;
}
static HRESULT WINAPI basic_video_SetSourcePosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height)
{
RECT SourceRect;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
SetRect(&SourceRect, Left, Top, Left + Width, Top + Height);
if (FAILED(BaseControlVideoImpl_CheckSourceRect(This, &SourceRect)))
return E_INVALIDARG;
This->src = SourceRect;
return S_OK;
}
static HRESULT WINAPI basic_video_GetSourcePosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
if (!pLeft || !pTop || !pWidth || !pHeight)
return E_POINTER;
*pLeft = This->src.left;
*pTop = This->src.top;
*pWidth = This->src.right - This->src.left;
*pHeight = This->src.bottom - This->src.top;
return S_OK;
}
static HRESULT WINAPI basic_video_SetDefaultSourcePosition(IBasicVideo *iface)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->()\n", This, iface);
return This->pFuncsTable->pfnSetDefaultSourceRect(This);
}
static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height)
{
RECT DestRect;
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
SetRect(&DestRect, Left, Top, Left + Width, Top + Height);
if (FAILED(BaseControlVideoImpl_CheckTargetRect(This, &DestRect)))
return E_INVALIDARG;
This->dst = DestRect;
return S_OK;
}
static HRESULT WINAPI basic_video_GetDestinationPosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
if (!pLeft || !pTop || !pWidth || !pHeight)
return E_POINTER;
*pLeft = This->dst.left;
*pTop = This->dst.top;
*pWidth = This->dst.right - This->dst.left;
*pHeight = This->dst.bottom - This->dst.top;
return S_OK;
}
static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *iface)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->()\n", This, iface);
return This->pFuncsTable->pfnSetDefaultTargetRect(This);
}
static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *pWidth, LONG *pHeight)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(This);
TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
if (!pWidth || !pHeight)
return E_POINTER;
*pHeight = bitmap_header->biHeight;
*pWidth = bitmap_header->biWidth;
return S_OK;
}
static HRESULT WINAPI basic_video_GetVideoPaletteEntries(IBasicVideo *iface, LONG StartIndex, LONG Entries, LONG *pRetrieved, LONG *pPalette)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
if (!pRetrieved || !pPalette)
return E_POINTER;
*pRetrieved = 0;
return VFW_E_NO_PALETTE_AVAILABLE;
}
static HRESULT WINAPI basic_video_GetCurrentImage(IBasicVideo *iface, LONG *pBufferSize, LONG *pDIBImage)
{
BaseControlVideo *This = impl_from_IBasicVideo(iface);
if (!pBufferSize || !pDIBImage)
return E_POINTER;
return This->pFuncsTable->pfnGetStaticImage(This, pBufferSize, pDIBImage);
}
static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface)
{
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface)
{
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
static const IBasicVideoVtbl basic_video_vtbl =
{
basic_video_QueryInterface,
basic_video_AddRef,
basic_video_Release,
basic_video_GetTypeInfoCount,
basic_video_GetTypeInfo,
basic_video_GetIDsOfNames,
basic_video_Invoke,
basic_video_get_AvgTimePerFrame,
basic_video_get_BitRate,
basic_video_get_BitErrorRate,
basic_video_get_VideoWidth,
basic_video_get_VideoHeight,
basic_video_put_SourceLeft,
basic_video_get_SourceLeft,
basic_video_put_SourceWidth,
basic_video_get_SourceWidth,
basic_video_put_SourceTop,
basic_video_get_SourceTop,
basic_video_put_SourceHeight,
basic_video_get_SourceHeight,
basic_video_put_DestinationLeft,
basic_video_get_DestinationLeft,
basic_video_put_DestinationWidth,
basic_video_get_DestinationWidth,
basic_video_put_DestinationTop,
basic_video_get_DestinationTop,
basic_video_put_DestinationHeight,
basic_video_get_DestinationHeight,
basic_video_SetSourcePosition,
basic_video_GetSourcePosition,
basic_video_SetDefaultSourcePosition,
basic_video_SetDestinationPosition,
basic_video_GetDestinationPosition,
basic_video_SetDefaultDestinationPosition,
basic_video_GetVideoSize,
basic_video_GetVideoPaletteEntries,
basic_video_GetCurrentImage,
basic_video_IsUsingDefaultSource,
basic_video_IsUsingDefaultDestination
};
void basic_video_init(BaseControlVideo *video, struct strmbase_filter *filter,
struct strmbase_pin *pin, const BaseControlVideoFuncTable *func_table)
{
video->IBasicVideo_iface.lpVtbl = &basic_video_vtbl;
video->pFilter = filter;
video->pPin = pin;
video->pFuncsTable = func_table;
}

View File

@ -40,7 +40,6 @@ struct video_renderer
{
struct strmbase_renderer renderer;
struct video_window window;
BaseControlVideo baseControlVideo;
IOverlay IOverlay_iface;
@ -69,11 +68,6 @@ static inline struct video_renderer *impl_from_IVideoWindow(IVideoWindow *iface)
return CONTAINING_RECORD(iface, struct video_renderer, window.IVideoWindow_iface);
}
static inline struct video_renderer *impl_from_BaseControlVideo(BaseControlVideo *iface)
{
return CONTAINING_RECORD(iface, struct video_renderer, baseControlVideo);
}
static const BITMAPINFOHEADER *get_bitmap_header(const AM_MEDIA_TYPE *mt)
{
if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
@ -100,7 +94,7 @@ static HRESULT WINAPI VideoRenderer_ShouldDrawSampleNow(struct strmbase_renderer
static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *iface, IMediaSample *pSample)
{
struct video_renderer *filter = impl_from_strmbase_renderer(iface);
RECT src = filter->baseControlVideo.src, dst = filter->baseControlVideo.dst;
RECT src = filter->window.src, dst = filter->window.dst;
LPBYTE pbSrcStream = NULL;
HRESULT hr;
HDC dc;
@ -171,7 +165,7 @@ static HRESULT video_renderer_query_interface(struct strmbase_renderer *iface, R
struct video_renderer *filter = impl_from_strmbase_renderer(iface);
if (IsEqualGUID(iid, &IID_IBasicVideo))
*out = &filter->baseControlVideo.IBasicVideo_iface;
*out = &filter->window.IBasicVideo_iface;
else if (IsEqualGUID(iid, &IID_IVideoWindow))
*out = &filter->window.IVideoWindow_iface;
else
@ -231,7 +225,7 @@ static HRESULT video_renderer_connect(struct strmbase_renderer *iface, const AM_
filter->VideoWidth = bitmap_header->biWidth;
filter->VideoHeight = abs(bitmap_header->biHeight);
SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight);
filter->baseControlVideo.src = filter->baseControlVideo.dst = rect;
filter->window.src = filter->window.dst = rect;
AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE,
GetWindowLongW(window, GWL_EXSTYLE));
@ -256,7 +250,7 @@ static BOOL video_renderer_resize(struct video_window *iface, LONG Width, LONG H
struct video_renderer *filter = impl_from_video_window(iface);
TRACE("WM_SIZE %d %d\n", Width, Height);
GetClientRect(iface->hwnd, &filter->baseControlVideo.dst);
GetClientRect(iface->hwnd, &filter->window.dst);
return TRUE;
}
@ -275,21 +269,13 @@ static const struct strmbase_renderer_ops renderer_ops =
.renderer_connect = video_renderer_connect,
};
static const struct video_window_ops window_ops =
static HRESULT video_renderer_get_current_image(struct video_window *iface, LONG *size, LONG *image)
{
.get_default_rect = video_renderer_get_default_rect,
.resize = video_renderer_resize,
};
static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image)
{
struct video_renderer *filter = impl_from_BaseControlVideo(iface);
struct video_renderer *filter = impl_from_video_window(iface);
const BITMAPINFOHEADER *bih;
size_t image_size;
BYTE *sample_data;
TRACE("filter %p, size %p, image %p.\n", filter, size, image);
EnterCriticalSection(&filter->renderer.csRenderLock);
bih = get_bitmap_header(&filter->renderer.sink.pin.mt);
@ -328,32 +314,35 @@ static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG
return S_OK;
}
static HRESULT WINAPI VideoRenderer_SetDefaultSourceRect(BaseControlVideo* iface)
static HRESULT WINAPI VideoRenderer_SetDefaultSourceRect(struct video_window *iface)
{
struct video_renderer *This = impl_from_BaseControlVideo(iface);
struct video_renderer *This = impl_from_video_window(iface);
SetRect(&This->baseControlVideo.src, 0, 0, This->VideoWidth, This->VideoHeight);
SetRect(&This->window.src, 0, 0, This->VideoWidth, This->VideoHeight);
return S_OK;
}
static HRESULT WINAPI VideoRenderer_SetDefaultTargetRect(BaseControlVideo* iface)
static HRESULT WINAPI VideoRenderer_SetDefaultTargetRect(struct video_window *iface)
{
struct video_renderer *This = impl_from_BaseControlVideo(iface);
struct video_renderer *This = impl_from_video_window(iface);
RECT rect;
if (!GetClientRect(This->window.hwnd, &rect))
return E_FAIL;
SetRect(&This->baseControlVideo.dst, 0, 0, rect.right, rect.bottom);
SetRect(&This->window.dst, 0, 0, rect.right, rect.bottom);
return S_OK;
}
static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = {
VideoRenderer_GetStaticImage,
VideoRenderer_SetDefaultSourceRect,
VideoRenderer_SetDefaultTargetRect,
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,
@ -386,16 +375,16 @@ static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface, LONG f
SetWindowLongW(window, GWL_STYLE, WS_POPUP);
SetWindowPos(window, HWND_TOP, 0, 0,
GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
GetWindowRect(window, &filter->baseControlVideo.dst);
GetWindowRect(window, &filter->window.dst);
}
else
{
ShowWindow(window, SW_HIDE);
SetParent(window, filter->window.hwndOwner);
SetWindowLongW(window, GWL_STYLE, filter->saved_style);
GetClientRect(window, &filter->baseControlVideo.dst);
SetWindowPos(window, 0, filter->baseControlVideo.dst.left, filter->baseControlVideo.dst.top,
filter->baseControlVideo.dst.right, filter->baseControlVideo.dst.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
GetClientRect(window, &filter->window.dst);
SetWindowPos(window, 0, filter->window.dst.left, filter->window.dst.top,
filter->window.dst.right, filter->window.dst.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
}
filter->FullScreenMode = fullscreen;
@ -569,8 +558,6 @@ HRESULT video_renderer_create(IUnknown *outer, IUnknown **out)
video_window_init(&object->window, &IVideoWindow_VTable,
&object->renderer.filter, &object->renderer.sink.pin, &window_ops);
basic_video_init(&object->baseControlVideo, &object->renderer.filter,
&object->renderer.sink.pin, &renderer_BaseControlVideoFuncTable);
if (FAILED(hr = video_window_create_window(&object->window)))
{

View File

@ -57,7 +57,6 @@ struct quartz_vmr
{
struct strmbase_renderer renderer;
struct video_window window;
BaseControlVideo baseControlVideo;
IAMCertifiedOutputProtection IAMCertifiedOutputProtection_iface;
IAMFilterMiscFlags IAMFilterMiscFlags_iface;
@ -120,11 +119,6 @@ static inline struct quartz_vmr *impl_from_video_window(struct video_window *ifa
return CONTAINING_RECORD(iface, struct quartz_vmr, window);
}
static inline struct quartz_vmr *impl_from_BaseControlVideo(BaseControlVideo *cvid)
{
return CONTAINING_RECORD(cvid, struct quartz_vmr, baseControlVideo);
}
static inline struct quartz_vmr *impl_from_IAMCertifiedOutputProtection(IAMCertifiedOutputProtection *iface)
{
return CONTAINING_RECORD(iface, struct quartz_vmr, IAMCertifiedOutputProtection_iface);
@ -415,8 +409,8 @@ static HRESULT allocate_surfaces(struct quartz_vmr *filter, const AM_MEDIA_TYPE
if (filter->mode == VMR9Mode_Windowless && !filter->hWndClippingWindow)
return S_OK;
info.dwWidth = filter->baseControlVideo.src.right;
info.dwHeight = filter->baseControlVideo.src.bottom;
info.dwWidth = filter->window.src.right;
info.dwHeight = filter->window.src.bottom;
info.Pool = D3DPOOL_DEFAULT;
info.MinBuffers = 1;
info.szAspectRatio.cx = info.dwWidth;
@ -512,7 +506,7 @@ static HRESULT vmr_connect(struct strmbase_renderer *iface, const AM_MEDIA_TYPE
filter->VideoWidth = bitmap_header->biWidth;
filter->VideoHeight = bitmap_header->biHeight;
SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight);
filter->baseControlVideo.src = filter->baseControlVideo.dst = rect;
filter->window.src = filter->window.dst = rect;
AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE,
GetWindowLongW(window, GWL_EXSTYLE));
@ -598,7 +592,7 @@ static HRESULT vmr_query_interface(struct strmbase_renderer *iface, REFIID iid,
if (IsEqualGUID(iid, &IID_IVideoWindow))
*out = &filter->window.IVideoWindow_iface;
else if (IsEqualGUID(iid, &IID_IBasicVideo))
*out = &filter->baseControlVideo.IBasicVideo_iface;
*out = &filter->window.IBasicVideo_iface;
else if (IsEqualGUID(iid, &IID_IAMCertifiedOutputProtection))
*out = &filter->IAMCertifiedOutputProtection_iface;
else if (IsEqualGUID(iid, &IID_IAMFilterMiscFlags))
@ -674,20 +668,14 @@ 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->baseControlVideo.dst);
GetClientRect(This->hwnd, &pVMR9->window.dst);
return TRUE;
}
static const struct video_window_ops window_ops =
static HRESULT vmr_get_current_image(struct video_window *iface, LONG *size, LONG *image)
{
.get_default_rect = vmr_get_default_rect,
.resize = vmr_resize,
};
static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image)
{
struct quartz_vmr *filter = impl_from_BaseControlVideo(iface);
struct quartz_vmr *filter = impl_from_video_window(iface);
IDirect3DSurface9 *rt = NULL, *surface = NULL;
D3DLOCKED_RECT locked_rect;
IDirect3DDevice9 *device;
@ -697,8 +685,6 @@ static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, L
char *dst;
HRESULT hr;
TRACE("filter %p, size %d, image %p.\n", filter, *size, image);
EnterCriticalSection(&filter->renderer.csRenderLock);
device = filter->allocator_d3d9_dev;
@ -748,32 +734,35 @@ out:
return hr;
}
static HRESULT WINAPI VMR9_SetDefaultSourceRect(BaseControlVideo* This)
static HRESULT WINAPI VMR9_SetDefaultSourceRect(struct video_window *iface)
{
struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This);
struct quartz_vmr *filter = impl_from_video_window(iface);
SetRect(&pVMR9->baseControlVideo.src, 0, 0, pVMR9->VideoWidth, pVMR9->VideoHeight);
SetRect(&filter->window.src, 0, 0, filter->VideoWidth, filter->VideoHeight);
return S_OK;
}
static HRESULT WINAPI VMR9_SetDefaultTargetRect(BaseControlVideo* This)
static HRESULT WINAPI VMR9_SetDefaultTargetRect(struct video_window *iface)
{
RECT rect;
struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This);
struct quartz_vmr *filter = impl_from_video_window(iface);
if (!GetClientRect(pVMR9->window.hwnd, &rect))
if (!GetClientRect(filter->window.hwnd, &rect))
return E_FAIL;
SetRect(&pVMR9->baseControlVideo.dst, 0, 0, rect.right, rect.bottom);
SetRect(&filter->window.dst, 0, 0, rect.right, rect.bottom);
return S_OK;
}
static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = {
VMR9_GetStaticImage,
VMR9_SetDefaultSourceRect,
VMR9_SetDefaultTargetRect,
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 =
@ -1510,10 +1499,10 @@ static HRESULT WINAPI VMR7WindowlessControl_SetVideoPosition(IVMRWindowlessContr
EnterCriticalSection(&This->renderer.filter.csFilter);
if (source)
This->baseControlVideo.src = *source;
This->window.src = *source;
if (dest)
{
This->baseControlVideo.dst = *dest;
This->window.dst = *dest;
FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest));
SetWindowPos(This->window.hwnd, NULL,
dest->left, dest->top, dest->right - dest->left, dest->bottom-dest->top,
@ -1531,10 +1520,10 @@ static HRESULT WINAPI VMR7WindowlessControl_GetVideoPosition(IVMRWindowlessContr
struct quartz_vmr *This = impl_from_IVMRWindowlessControl(iface);
if (source)
*source = This->baseControlVideo.src;
*source = This->window.src;
if (dest)
*dest = This->baseControlVideo.dst;
*dest = This->window.dst;
FIXME("(%p/%p)->(%p/%p) stub\n", iface, This, source, dest);
return S_OK;
@ -1711,10 +1700,10 @@ static HRESULT WINAPI VMR9WindowlessControl_SetVideoPosition(IVMRWindowlessContr
EnterCriticalSection(&This->renderer.filter.csFilter);
if (source)
This->baseControlVideo.src = *source;
This->window.src = *source;
if (dest)
{
This->baseControlVideo.dst = *dest;
This->window.dst = *dest;
FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest));
SetWindowPos(This->window.hwnd, NULL,
dest->left, dest->top, dest->right - dest->left, dest->bottom - dest->top,
@ -1731,10 +1720,10 @@ static HRESULT WINAPI VMR9WindowlessControl_GetVideoPosition(IVMRWindowlessContr
struct quartz_vmr *This = impl_from_IVMRWindowlessControl9(iface);
if (source)
*source = This->baseControlVideo.src;
*source = This->window.src;
if (dest)
*dest = This->baseControlVideo.dst;
*dest = This->window.dst;
FIXME("(%p/%p)->(%p/%p) stub\n", iface, This, source, dest);
return S_OK;
@ -2352,9 +2341,6 @@ static HRESULT vmr_create(IUnknown *outer, IUnknown **out, const CLSID *clsid)
return hr;
}
basic_video_init(&object->baseControlVideo, &object->renderer.filter,
&object->renderer.sink.pin, &renderer_BaseControlVideoFuncTable);
object->run_event = CreateEventW(NULL, TRUE, FALSE, NULL);
TRACE("Created VMR %p.\n", object);
@ -2519,11 +2505,11 @@ static HRESULT VMR9_ImagePresenter_PresentOffscreenSurface(struct default_presen
}
/* Move rect to origin and flip it */
SetRect(&target_rect, 0, This->pVMR9->baseControlVideo.dst.bottom - This->pVMR9->baseControlVideo.dst.top,
This->pVMR9->baseControlVideo.dst.right - This->pVMR9->baseControlVideo.dst.left, 0);
SetRect(&target_rect, 0, This->pVMR9->window.dst.bottom - This->pVMR9->window.dst.top,
This->pVMR9->window.dst.right - This->pVMR9->window.dst.left, 0);
hr = IDirect3DDevice9_StretchRect(This->d3d9_dev, surface,
&This->pVMR9->baseControlVideo.src, target, &target_rect, D3DTEXF_LINEAR);
&This->pVMR9->window.src, target, &target_rect, D3DTEXF_LINEAR);
if (FAILED(hr))
ERR("IDirect3DDevice9_StretchRect -- %08x\n", hr);
IDirect3DSurface9_Release(target);
@ -2695,8 +2681,8 @@ static BOOL CreateRenderingWindow(struct default_presenter *This, VMR9Allocation
d3dpp.Windowed = TRUE;
d3dpp.hDeviceWindow = This->pVMR9->window.hwnd;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferHeight = This->pVMR9->baseControlVideo.dst.bottom - This->pVMR9->baseControlVideo.dst.top;
d3dpp.BackBufferWidth = This->pVMR9->baseControlVideo.dst.right - This->pVMR9->baseControlVideo.dst.left;
d3dpp.BackBufferHeight = This->pVMR9->window.dst.bottom - This->pVMR9->window.dst.top;
d3dpp.BackBufferWidth = This->pVMR9->window.dst.right - This->pVMR9->window.dst.left;
hr = IDirect3D9_CreateDevice(This->d3d9_ptr, d3d9_adapter, D3DDEVTYPE_HAL, NULL, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &This->d3d9_dev);
if (FAILED(hr))
@ -2831,24 +2817,24 @@ static HRESULT VMR9_SurfaceAllocator_UpdateDeviceReset(struct default_presenter
{
if (i % 2)
{
t_vert[i].x = (float)This->pVMR9->baseControlVideo.dst.right - (float)This->pVMR9->baseControlVideo.dst.left - 0.5f;
t_vert[i].u = (float)This->pVMR9->baseControlVideo.src.right / (float)width;
t_vert[i].x = (float)This->pVMR9->window.dst.right - (float)This->pVMR9->window.dst.left - 0.5f;
t_vert[i].u = (float)This->pVMR9->window.src.right / (float)width;
}
else
{
t_vert[i].x = -0.5f;
t_vert[i].u = (float)This->pVMR9->baseControlVideo.src.left / (float)width;
t_vert[i].u = (float)This->pVMR9->window.src.left / (float)width;
}
if (i % 4 < 2)
{
t_vert[i].y = -0.5f;
t_vert[i].v = (float)This->pVMR9->baseControlVideo.src.bottom / (float)height;
t_vert[i].v = (float)This->pVMR9->window.src.bottom / (float)height;
}
else
{
t_vert[i].y = (float)This->pVMR9->baseControlVideo.dst.bottom - (float)This->pVMR9->baseControlVideo.dst.top - 0.5f;
t_vert[i].v = (float)This->pVMR9->baseControlVideo.src.top / (float)height;
t_vert[i].y = (float)This->pVMR9->window.dst.bottom - (float)This->pVMR9->window.dst.top - 0.5f;
t_vert[i].v = (float)This->pVMR9->window.src.top / (float)height;
}
t_vert[i].z = 0.0f;
t_vert[i].rhw = 1.0f;

View File

@ -656,6 +656,550 @@ HRESULT WINAPI BaseControlWindowImpl_IsCursorHidden(IVideoWindow *iface, LONG *C
return S_OK;
}
static inline struct video_window *impl_from_IBasicVideo(IBasicVideo *iface)
{
return CONTAINING_RECORD(iface, struct video_window, IBasicVideo_iface);
}
static HRESULT WINAPI basic_video_QueryInterface(IBasicVideo *iface, REFIID iid, void **out)
{
struct video_window *window = impl_from_IBasicVideo(iface);
return IUnknown_QueryInterface(window->pFilter->outer_unk, iid, out);
}
static ULONG WINAPI basic_video_AddRef(IBasicVideo *iface)
{
struct video_window *window = impl_from_IBasicVideo(iface);
return IUnknown_AddRef(window->pFilter->outer_unk);
}
static ULONG WINAPI basic_video_Release(IBasicVideo *iface)
{
struct video_window *window = impl_from_IBasicVideo(iface);
return IUnknown_Release(window->pFilter->outer_unk);
}
static HRESULT WINAPI basic_video_GetTypeInfoCount(IBasicVideo *iface, UINT *count)
{
TRACE("iface %p, count %p.\n", iface, count);
*count = 1;
return S_OK;
}
static HRESULT WINAPI basic_video_GetTypeInfo(IBasicVideo *iface, UINT index,
LCID lcid, ITypeInfo **typeinfo)
{
TRACE("iface %p, index %u, lcid %#x, typeinfo %p.\n", iface, index, lcid, typeinfo);
return strmbase_get_typeinfo(IBasicVideo_tid, typeinfo);
}
static HRESULT WINAPI basic_video_GetIDsOfNames(IBasicVideo *iface, REFIID iid,
LPOLESTR *names, UINT count, LCID lcid, DISPID *ids)
{
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("iface %p, iid %s, names %p, count %u, lcid %#x, ids %p.\n",
iface, debugstr_guid(iid), names, count, lcid, ids);
if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo)))
{
hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, ids);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID iid, LCID lcid,
WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *error_arg)
{
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("iface %p, id %d, iid %s, lcid %#x, flags %#x, params %p, result %p, excepinfo %p, error_arg %p.\n",
iface, id, debugstr_guid(iid), lcid, flags, params, result, excepinfo, error_arg);
if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo)))
{
hr = ITypeInfo_Invoke(typeinfo, iface, id, flags, params, result, excepinfo, error_arg);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static const VIDEOINFOHEADER *get_video_format(struct video_window *window)
{
/* Members of VIDEOINFOHEADER up to bmiHeader are identical to those of
* VIDEOINFOHEADER2. */
return (const VIDEOINFOHEADER *)window->pPin->mt.pbFormat;
}
static const BITMAPINFOHEADER *get_bitmap_header(struct video_window *window)
{
const AM_MEDIA_TYPE *mt = &window->pPin->mt;
if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader;
else
return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader;
}
static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *reftime)
{
struct video_window *window = impl_from_IBasicVideo(iface);
if (!reftime)
return E_POINTER;
if (!window->pPin->peer)
return VFW_E_NOT_CONNECTED;
TRACE("window %p, reftime %p.\n", window, reftime);
*reftime = get_video_format(window)->AvgTimePerFrame;
return S_OK;
}
static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *rate)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, rate %p.\n", window, rate);
if (!rate)
return E_POINTER;
if (!window->pPin->peer)
return VFW_E_NOT_CONNECTED;
*rate = get_video_format(window)->dwBitRate;
return S_OK;
}
static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *rate)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, rate %p.\n", window, rate);
if (!rate)
return E_POINTER;
if (!window->pPin->peer)
return VFW_E_NOT_CONNECTED;
*rate = get_video_format(window)->dwBitErrorRate;
return S_OK;
}
static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *width)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, width %p.\n", window, width);
if (!width)
return E_POINTER;
*width = get_bitmap_header(window)->biWidth;
return S_OK;
}
static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, height %p.\n", window, height);
if (!height)
return E_POINTER;
*height = abs(get_bitmap_header(window)->biHeight);
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceLeft(IBasicVideo *iface, LONG left)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, left %d.\n", window, left);
if (left < 0 || window->src.right + left - window->src.left > get_bitmap_header(window)->biWidth)
return E_INVALIDARG;
OffsetRect(&window->src, left - window->src.left, 0);
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceLeft(IBasicVideo *iface, LONG *left)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, left %p.\n", window, left);
if (!left)
return E_POINTER;
*left = window->src.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceWidth(IBasicVideo *iface, LONG width)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, width %d.\n", window, width);
if (width <= 0 || window->src.left + width > get_bitmap_header(window)->biWidth)
return E_INVALIDARG;
window->src.right = window->src.left + width;
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceWidth(IBasicVideo *iface, LONG *width)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, width %p.\n", window, width);
if (!width)
return E_POINTER;
*width = window->src.right - window->src.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceTop(IBasicVideo *iface, LONG top)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, top %d.\n", window, top);
if (top < 0 || window->src.bottom + top - window->src.top > get_bitmap_header(window)->biHeight)
return E_INVALIDARG;
OffsetRect(&window->src, 0, top - window->src.top);
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceTop(IBasicVideo *iface, LONG *top)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, top %p.\n", window, top);
if (!top)
return E_POINTER;
*top = window->src.top;
return S_OK;
}
static HRESULT WINAPI basic_video_put_SourceHeight(IBasicVideo *iface, LONG height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, height %d.\n", window, height);
if (height <= 0 || window->src.top + height > get_bitmap_header(window)->biHeight)
return E_INVALIDARG;
window->src.bottom = window->src.top + height;
return S_OK;
}
static HRESULT WINAPI basic_video_get_SourceHeight(IBasicVideo *iface, LONG *height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, height %p\n", window, height);
if (!height)
return E_POINTER;
*height = window->src.bottom - window->src.top;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG left)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, left %d.\n", window, left);
OffsetRect(&window->dst, left - window->dst.left, 0);
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationLeft(IBasicVideo *iface, LONG *left)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, left %p.\n", window, left);
if (!left)
return E_POINTER;
*left = window->dst.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG width)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, width %d.\n", window, width);
if (width <= 0)
return E_INVALIDARG;
window->dst.right = window->dst.left + width;
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationWidth(IBasicVideo *iface, LONG *width)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, width %p.\n", window, width);
if (!width)
return E_POINTER;
*width = window->dst.right - window->dst.left;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG top)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, top %d.\n", window, top);
OffsetRect(&window->dst, 0, top - window->dst.top);
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationTop(IBasicVideo *iface, LONG *top)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, top %p.\n", window, top);
if (!top)
return E_POINTER;
*top = window->dst.top;
return S_OK;
}
static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, height %d.\n", window, height);
if (height <= 0)
return E_INVALIDARG;
window->dst.bottom = window->dst.top + height;
return S_OK;
}
static HRESULT WINAPI basic_video_get_DestinationHeight(IBasicVideo *iface, LONG *height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, height %p.\n", window, height);
if (!height)
return E_POINTER;
*height = window->dst.bottom - window->dst.top;
return S_OK;
}
static HRESULT WINAPI basic_video_SetSourcePosition(IBasicVideo *iface,
LONG left, LONG top, LONG width, LONG height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(window);
TRACE("window %p, left %d, top %d, width %d, height %d.\n", window, left, top, width, height);
if (left < 0 || left + width > bitmap_header->biWidth || width <= 0)
return E_INVALIDARG;
if (top < 0 || top + height > bitmap_header->biHeight || height <= 0)
return E_INVALIDARG;
SetRect(&window->src, left, top, left + width, top + height);
return S_OK;
}
static HRESULT WINAPI basic_video_GetSourcePosition(IBasicVideo *iface,
LONG *left, LONG *top, LONG *width, LONG *height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, left %p, top %p, width %p, height %p.\n", window, left, top, width, height);
if (!left || !top || !width || !height)
return E_POINTER;
*left = window->src.left;
*top = window->src.top;
*width = window->src.right - window->src.left;
*height = window->src.bottom - window->src.top;
return S_OK;
}
static HRESULT WINAPI basic_video_SetDefaultSourcePosition(IBasicVideo *iface)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p.\n", window);
return window->ops->pfnSetDefaultSourceRect(window);
}
static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface,
LONG left, LONG top, LONG width, LONG height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, left %d, top %d, width %d, height %d.\n", window, left, top, width, height);
if (width <= 0 || height <= 0)
return E_INVALIDARG;
SetRect(&window->dst, left, top, left + width, top + height);
return S_OK;
}
static HRESULT WINAPI basic_video_GetDestinationPosition(IBasicVideo *iface,
LONG *left, LONG *top, LONG *width, LONG *height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, left %p, top %p, width %p, height %p.\n", window, left, top, width, height);
if (!left || !top || !width || !height)
return E_POINTER;
*left = window->dst.left;
*top = window->dst.top;
*width = window->dst.right - window->dst.left;
*height = window->dst.bottom - window->dst.top;
return S_OK;
}
static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *iface)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p.\n", window);
return window->ops->pfnSetDefaultTargetRect(window);
}
static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *width, LONG *height)
{
struct video_window *window = impl_from_IBasicVideo(iface);
const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(window);
TRACE("window %p, width %p, height %p.\n", window, width, height);
if (!width || !height)
return E_POINTER;
*width = bitmap_header->biWidth;
*height = bitmap_header->biHeight;
return S_OK;
}
static HRESULT WINAPI basic_video_GetVideoPaletteEntries(IBasicVideo *iface,
LONG start, LONG count, LONG *ret_count, LONG *palette)
{
struct video_window *window = impl_from_IBasicVideo(iface);
FIXME("window %p, start %d, count %d, ret_count %p, palette %p, stub!\n",
window, start, count, ret_count, palette);
if (!ret_count || !palette)
return E_POINTER;
*ret_count = 0;
return VFW_E_NO_PALETTE_AVAILABLE;
}
static HRESULT WINAPI basic_video_GetCurrentImage(IBasicVideo *iface, LONG *size, LONG *image)
{
struct video_window *window = impl_from_IBasicVideo(iface);
TRACE("window %p, size %p, image %p.\n", window, size, image);
if (!size || !image)
return E_POINTER;
return window->ops->get_current_image(window, size, image);
}
static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface)
{
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface)
{
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
static const IBasicVideoVtbl basic_video_vtbl =
{
basic_video_QueryInterface,
basic_video_AddRef,
basic_video_Release,
basic_video_GetTypeInfoCount,
basic_video_GetTypeInfo,
basic_video_GetIDsOfNames,
basic_video_Invoke,
basic_video_get_AvgTimePerFrame,
basic_video_get_BitRate,
basic_video_get_BitErrorRate,
basic_video_get_VideoWidth,
basic_video_get_VideoHeight,
basic_video_put_SourceLeft,
basic_video_get_SourceLeft,
basic_video_put_SourceWidth,
basic_video_get_SourceWidth,
basic_video_put_SourceTop,
basic_video_get_SourceTop,
basic_video_put_SourceHeight,
basic_video_get_SourceHeight,
basic_video_put_DestinationLeft,
basic_video_get_DestinationLeft,
basic_video_put_DestinationWidth,
basic_video_get_DestinationWidth,
basic_video_put_DestinationTop,
basic_video_get_DestinationTop,
basic_video_put_DestinationHeight,
basic_video_get_DestinationHeight,
basic_video_SetSourcePosition,
basic_video_GetSourcePosition,
basic_video_SetDefaultSourcePosition,
basic_video_SetDestinationPosition,
basic_video_GetDestinationPosition,
basic_video_SetDefaultDestinationPosition,
basic_video_GetVideoSize,
basic_video_GetVideoPaletteEntries,
basic_video_GetCurrentImage,
basic_video_IsUsingDefaultSource,
basic_video_IsUsingDefaultDestination
};
void video_window_unregister_class(void)
{
if (!UnregisterClassW(class_name, NULL) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST)
@ -668,6 +1212,7 @@ void video_window_init(struct video_window *window, const IVideoWindowVtbl *vtbl
memset(window, 0, sizeof(*window));
window->ops = ops;
window->IVideoWindow_iface.lpVtbl = vtbl;
window->IBasicVideo_iface.lpVtbl = &basic_video_vtbl;
window->AutoShow = OATRUE;
window->pFilter = owner;
window->pPin = pin;