quartz: Only allocate 1 buffer in transform filter.
[wine/wine64.git] / dlls / quartz / videorenderer.c
blob629ad1debf996f857cfcbe35b116c9a47e22703e
1 /*
2 * Video Renderer (Fullscreen and Windowed using Direct Draw)
4 * Copyright 2004 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #define NONAMELESSSTRUCT
24 #define NONAMELESSUNION
25 #include "quartz_private.h"
26 #include "control_private.h"
27 #include "pin.h"
29 #include "uuids.h"
30 #include "vfwmsgs.h"
31 #include "amvideo.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "dshow.h"
35 #include "evcode.h"
36 #include "strmif.h"
37 #include "ddraw.h"
38 #include "dvdmedia.h"
40 #include "assert.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
46 static BOOL wnd_class_registered = FALSE;
48 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
50 static const IBaseFilterVtbl VideoRenderer_Vtbl;
51 static const IUnknownVtbl IInner_VTable;
52 static const IBasicVideoVtbl IBasicVideo_VTable;
53 static const IVideoWindowVtbl IVideoWindow_VTable;
54 static const IPinVtbl VideoRenderer_InputPin_Vtbl;
56 typedef struct VideoRendererImpl
58 const IBaseFilterVtbl * lpVtbl;
59 const IBasicVideoVtbl * IBasicVideo_vtbl;
60 const IVideoWindowVtbl * IVideoWindow_vtbl;
61 const IUnknownVtbl * IInner_vtbl;
63 LONG refCount;
64 CRITICAL_SECTION csFilter;
65 FILTER_STATE state;
66 REFERENCE_TIME rtStreamStart;
67 IReferenceClock * pClock;
68 FILTER_INFO filterInfo;
70 InputPin *pInputPin;
72 BOOL init;
73 HANDLE hThread;
74 HANDLE blocked;
76 DWORD ThreadID;
77 HANDLE hEvent;
78 BOOL ThreadResult;
79 HWND hWnd;
80 HWND hWndMsgDrain;
81 BOOL AutoShow;
82 RECT SourceRect;
83 RECT DestRect;
84 RECT WindowPos;
85 long VideoWidth;
86 long VideoHeight;
87 IUnknown * pUnkOuter;
88 BOOL bUnkOuterValid;
89 BOOL bAggregatable;
90 REFERENCE_TIME rtLastStop;
91 MediaSeekingImpl mediaSeeking;
93 /* During pause we can hold a single sample, for use in GetCurrentImage */
94 IMediaSample *sample_held;
95 } VideoRendererImpl;
97 static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
99 VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongA(hwnd, 0);
100 LPRECT lprect = (LPRECT)lParam;
102 if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
104 switch(uMsg)
106 case WM_KEYDOWN:
107 case WM_KEYUP:
108 case WM_LBUTTONDBLCLK:
109 case WM_LBUTTONDOWN:
110 case WM_LBUTTONUP:
111 case WM_MBUTTONDBLCLK:
112 case WM_MBUTTONDOWN:
113 case WM_MBUTTONUP:
114 case WM_MOUSEACTIVATE:
115 case WM_MOUSEMOVE:
116 case WM_NCLBUTTONDBLCLK:
117 case WM_NCLBUTTONDOWN:
118 case WM_NCLBUTTONUP:
119 case WM_NCMBUTTONDBLCLK:
120 case WM_NCMBUTTONDOWN:
121 case WM_NCMBUTTONUP:
122 case WM_NCMOUSEMOVE:
123 case WM_NCRBUTTONDBLCLK:
124 case WM_NCRBUTTONDOWN:
125 case WM_NCRBUTTONUP:
126 case WM_RBUTTONDBLCLK:
127 case WM_RBUTTONDOWN:
128 case WM_RBUTTONUP:
129 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
130 break;
131 default:
132 break;
136 switch(uMsg)
138 case WM_SIZING:
139 /* TRACE("WM_SIZING %d %d %d %d\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
140 SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
141 GetClientRect(hwnd, &pVideoRenderer->DestRect);
142 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
143 pVideoRenderer->DestRect.left,
144 pVideoRenderer->DestRect.top,
145 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
146 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
147 return TRUE;
148 case WM_SIZE:
149 TRACE("WM_SIZE %d %d\n", LOWORD(lParam), HIWORD(lParam));
150 GetClientRect(hwnd, &pVideoRenderer->DestRect);
151 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
152 pVideoRenderer->DestRect.left,
153 pVideoRenderer->DestRect.top,
154 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
155 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
156 return TRUE;
157 default:
158 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
160 return 0;
163 static BOOL CreateRenderingWindow(VideoRendererImpl* This)
165 WNDCLASSA winclass;
167 TRACE("(%p)->()\n", This);
169 winclass.style = 0;
170 winclass.lpfnWndProc = VideoWndProcA;
171 winclass.cbClsExtra = 0;
172 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
173 winclass.hInstance = NULL;
174 winclass.hIcon = NULL;
175 winclass.hCursor = NULL;
176 winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
177 winclass.lpszMenuName = NULL;
178 winclass.lpszClassName = "Wine ActiveMovie Class";
180 if (!wnd_class_registered)
182 if (!RegisterClassA(&winclass))
184 ERR("Unable to register window %u\n", GetLastError());
185 return FALSE;
187 wnd_class_registered = TRUE;
190 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
191 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
192 NULL, NULL, NULL);
194 if (!This->hWnd)
196 ERR("Unable to create window\n");
197 return FALSE;
200 SetWindowLongA(This->hWnd, 0, (LONG)This);
202 return TRUE;
205 static DWORD WINAPI MessageLoop(LPVOID lpParameter)
207 VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
208 MSG msg;
209 BOOL fGotMessage;
211 TRACE("Starting message loop\n");
213 if (!CreateRenderingWindow(This))
215 This->ThreadResult = FALSE;
216 SetEvent(This->hEvent);
217 return 0;
220 This->ThreadResult = TRUE;
221 SetEvent(This->hEvent);
223 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
225 TranslateMessage(&msg);
226 DispatchMessageA(&msg);
229 TRACE("End of message loop\n");
231 return msg.wParam;
234 static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
236 This->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
237 if (!This->hEvent)
238 return FALSE;
240 This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
241 if (!This->hThread)
243 CloseHandle(This->hEvent);
244 return FALSE;
247 WaitForSingleObject(This->hEvent, INFINITE);
249 if (!This->ThreadResult)
251 CloseHandle(This->hEvent);
252 CloseHandle(This->hThread);
253 return FALSE;
256 return TRUE;
259 static const IMemInputPinVtbl MemInputPin_Vtbl =
261 MemInputPin_QueryInterface,
262 MemInputPin_AddRef,
263 MemInputPin_Release,
264 MemInputPin_GetAllocator,
265 MemInputPin_NotifyAllocator,
266 MemInputPin_GetAllocatorRequirements,
267 MemInputPin_Receive,
268 MemInputPin_ReceiveMultiple,
269 MemInputPin_ReceiveCanBlock
272 static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
274 AM_MEDIA_TYPE amt;
275 HRESULT hr = S_OK;
276 DDSURFACEDESC sdesc;
277 int width;
278 int height;
279 LPBYTE palette = NULL;
280 HDC hDC;
281 BITMAPINFOHEADER *bmiHeader;
283 TRACE("%p %p %d\n", This, data, size);
285 sdesc.dwSize = sizeof(sdesc);
286 hr = IPin_ConnectionMediaType((IPin *)This->pInputPin, &amt);
287 if (FAILED(hr)) {
288 ERR("Unable to retrieve media type\n");
289 return hr;
292 if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo))
294 bmiHeader = &((VIDEOINFOHEADER *)amt.pbFormat)->bmiHeader;
296 else if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo2))
298 bmiHeader = &((VIDEOINFOHEADER2 *)amt.pbFormat)->bmiHeader;
300 else
302 FIXME("Unknown type %s\n", debugstr_guid(&amt.subtype));
303 return VFW_E_RUNTIME_ERROR;
307 TRACE("biSize = %d\n", bmiHeader->biSize);
308 TRACE("biWidth = %d\n", bmiHeader->biWidth);
309 TRACE("biHeight = %d\n", bmiHeader->biHeight);
310 TRACE("biPlanes = %d\n", bmiHeader->biPlanes);
311 TRACE("biBitCount = %d\n", bmiHeader->biBitCount);
312 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(bmiHeader->biCompression), 4));
313 TRACE("biSizeImage = %d\n", bmiHeader->biSizeImage);
315 width = bmiHeader->biWidth;
316 height = bmiHeader->biHeight;
317 palette = ((LPBYTE)bmiHeader) + bmiHeader->biSize;
319 if (!This->init)
321 if (!This->WindowPos.right || !This->WindowPos.bottom)
322 This->WindowPos = This->SourceRect;
324 TRACE("WindowPos: %d %d %d %d\n", This->WindowPos.left, This->WindowPos.top, This->WindowPos.right, This->WindowPos.bottom);
325 SetWindowPos(This->hWnd, NULL,
326 This->WindowPos.left,
327 This->WindowPos.top,
328 This->WindowPos.right - This->WindowPos.left,
329 This->WindowPos.bottom - This->WindowPos.top,
330 SWP_NOZORDER|SWP_NOMOVE);
332 GetClientRect(This->hWnd, &This->DestRect);
333 This->init = TRUE;
336 hDC = GetDC(This->hWnd);
338 if (!hDC) {
339 ERR("Cannot get DC from window!\n");
340 return E_FAIL;
343 TRACE("Src Rect: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
344 TRACE("Dst Rect: %d %d %d %d\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom);
346 StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
347 This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
348 This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
349 data, (BITMAPINFO *)bmiHeader, DIB_RGB_COLORS, SRCCOPY);
351 ReleaseDC(This->hWnd, hDC);
352 if (This->AutoShow)
353 ShowWindow(This->hWnd, SW_SHOW);
355 return S_OK;
358 static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
360 VideoRendererImpl *This = (VideoRendererImpl *)iface;
361 LPBYTE pbSrcStream = NULL;
362 long cbSrcStream = 0;
363 REFERENCE_TIME tStart, tStop;
364 HRESULT hr;
365 EnterCriticalSection(&This->csFilter);
366 if (This->pInputPin->flushing || This->pInputPin->end_of_stream)
367 hr = S_FALSE;
369 if (This->state == State_Stopped)
371 LeaveCriticalSection(&This->csFilter);
372 return VFW_E_WRONG_STATE;
375 TRACE("%p %p\n", iface, pSample);
377 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
378 if (FAILED(hr))
379 ERR("Cannot get sample time (%x)\n", hr);
381 if (This->rtLastStop != tStart)
383 if (IMediaSample_IsDiscontinuity(pSample) == S_FALSE)
384 ERR("Unexpected discontinuity: Last: %u.%03u, tStart: %u.%03u\n",
385 (DWORD)(This->rtLastStop / 10000000),
386 (DWORD)((This->rtLastStop / 10000)%1000),
387 (DWORD)(tStart / 10000000), (DWORD)((tStart / 10000)%1000));
388 This->rtLastStop = tStart;
391 /* Preroll means the sample isn't shown, this is used for key frames and things like that */
392 if (IMediaSample_IsPreroll(pSample) == S_OK)
394 This->rtLastStop = tStop;
395 LeaveCriticalSection(&This->csFilter);
396 return S_OK;
399 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
400 if (FAILED(hr))
402 ERR("Cannot get pointer to sample data (%x)\n", hr);
403 LeaveCriticalSection(&This->csFilter);
404 return hr;
407 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
409 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
411 #if 0 /* For debugging purpose */
413 int i;
414 for(i = 0; i < cbSrcStream; i++)
416 if ((i!=0) && !(i%16))
417 TRACE("\n");
418 TRACE("%02x ", pbSrcStream[i]);
420 TRACE("\n");
422 #endif
424 SetEvent(This->hEvent);
425 if (This->state == State_Paused)
427 This->sample_held = pSample;
428 LeaveCriticalSection(&This->csFilter);
429 WaitForSingleObject(This->blocked, INFINITE);
430 EnterCriticalSection(&This->csFilter);
431 This->sample_held = NULL;
432 if (This->state == State_Paused)
434 /* Flushing */
435 LeaveCriticalSection(&This->csFilter);
436 return S_OK;
438 if (This->state == State_Stopped)
440 LeaveCriticalSection(&This->csFilter);
441 return VFW_E_WRONG_STATE;
445 if (This->pClock && This->state == State_Running)
447 REFERENCE_TIME time, trefstart, trefstop;
448 LONG delta;
450 /* Perhaps I <SHOULD> use the reference clock AdviseTime function here
451 * I'm not going to! When I tried, it seemed to generate lag and
452 * it caused instability.
454 IReferenceClock_GetTime(This->pClock, &time);
456 trefstart = This->rtStreamStart;
457 trefstop = (REFERENCE_TIME)((double)(tStop - tStart) / This->pInputPin->dRate) + This->rtStreamStart;
458 delta = (LONG)((trefstart-time)/10000);
459 This->rtStreamStart = trefstop;
460 This->rtLastStop = tStop;
462 if (delta > 0)
464 TRACE("Sleeping for %u ms\n", delta);
465 Sleep(delta);
467 else if (time > trefstop)
469 TRACE("Dropping sample: Time: %u.%03u ms trefstop: %u.%03u ms!\n",
470 (DWORD)(time / 10000000), (DWORD)((time / 10000)%1000),
471 (DWORD)(trefstop / 10000000), (DWORD)((trefstop / 10000)%1000) );
472 This->rtLastStop = tStop;
473 LeaveCriticalSection(&This->csFilter);
474 return S_OK;
477 This->rtLastStop = tStop;
479 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
481 LeaveCriticalSection(&This->csFilter);
482 return S_OK;
485 static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
487 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
488 return S_FALSE;
490 if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
491 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
492 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
493 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
495 VideoRendererImpl* This = (VideoRendererImpl*) iface;
497 if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
499 VIDEOINFOHEADER *format = (VIDEOINFOHEADER *)pmt->pbFormat;
500 This->SourceRect.left = 0;
501 This->SourceRect.top = 0;
502 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
503 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
505 else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
507 VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)pmt->pbFormat;
509 This->SourceRect.left = 0;
510 This->SourceRect.top = 0;
511 This->SourceRect.right = This->VideoWidth = format2->bmiHeader.biWidth;
512 This->SourceRect.bottom = This->VideoHeight = format2->bmiHeader.biHeight;
514 else
516 WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
517 return S_FALSE;
519 return S_OK;
521 return S_FALSE;
524 static inline VideoRendererImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
526 return (VideoRendererImpl *)((char*)iface - FIELD_OFFSET(VideoRendererImpl, mediaSeeking.lpVtbl));
529 static HRESULT WINAPI VideoRendererImpl_Seeking_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
531 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
533 return IUnknown_QueryInterface((IUnknown *)This, riid, ppv);
536 static ULONG WINAPI VideoRendererImpl_Seeking_AddRef(IMediaSeeking * iface)
538 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
540 return IUnknown_AddRef((IUnknown *)This);
543 static ULONG WINAPI VideoRendererImpl_Seeking_Release(IMediaSeeking * iface)
545 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
547 return IUnknown_Release((IUnknown *)This);
550 static const IMediaSeekingVtbl VideoRendererImpl_Seeking_Vtbl =
552 VideoRendererImpl_Seeking_QueryInterface,
553 VideoRendererImpl_Seeking_AddRef,
554 VideoRendererImpl_Seeking_Release,
555 MediaSeekingImpl_GetCapabilities,
556 MediaSeekingImpl_CheckCapabilities,
557 MediaSeekingImpl_IsFormatSupported,
558 MediaSeekingImpl_QueryPreferredFormat,
559 MediaSeekingImpl_GetTimeFormat,
560 MediaSeekingImpl_IsUsingTimeFormat,
561 MediaSeekingImpl_SetTimeFormat,
562 MediaSeekingImpl_GetDuration,
563 MediaSeekingImpl_GetStopPosition,
564 MediaSeekingImpl_GetCurrentPosition,
565 MediaSeekingImpl_ConvertTimeFormat,
566 MediaSeekingImpl_SetPositions,
567 MediaSeekingImpl_GetPositions,
568 MediaSeekingImpl_GetAvailable,
569 MediaSeekingImpl_SetRate,
570 MediaSeekingImpl_GetRate,
571 MediaSeekingImpl_GetPreroll
574 static HRESULT VideoRendererImpl_Change(IBaseFilter *iface)
576 TRACE("(%p)\n", iface);
577 return S_OK;
580 HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
582 HRESULT hr;
583 PIN_INFO piInput;
584 VideoRendererImpl * pVideoRenderer;
586 TRACE("(%p, %p)\n", pUnkOuter, ppv);
588 *ppv = NULL;
590 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
591 pVideoRenderer->pUnkOuter = pUnkOuter;
592 pVideoRenderer->bUnkOuterValid = FALSE;
593 pVideoRenderer->bAggregatable = FALSE;
594 pVideoRenderer->IInner_vtbl = &IInner_VTable;
596 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
597 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
598 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
600 pVideoRenderer->refCount = 1;
601 InitializeCriticalSection(&pVideoRenderer->csFilter);
602 pVideoRenderer->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
603 pVideoRenderer->state = State_Stopped;
604 pVideoRenderer->pClock = NULL;
605 pVideoRenderer->init = 0;
606 pVideoRenderer->AutoShow = 1;
607 pVideoRenderer->rtLastStop = -1;
608 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
609 ZeroMemory(&pVideoRenderer->SourceRect, sizeof(RECT));
610 ZeroMemory(&pVideoRenderer->DestRect, sizeof(RECT));
611 ZeroMemory(&pVideoRenderer->WindowPos, sizeof(RECT));
612 pVideoRenderer->hWndMsgDrain = NULL;
614 /* construct input pin */
615 piInput.dir = PINDIR_INPUT;
616 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
617 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
619 hr = InputPin_Construct(&VideoRenderer_InputPin_Vtbl, &piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, NULL, &pVideoRenderer->csFilter, NULL, (IPin **)&pVideoRenderer->pInputPin);
621 if (SUCCEEDED(hr))
623 MediaSeekingImpl_Init((IBaseFilter*)pVideoRenderer, VideoRendererImpl_Change, VideoRendererImpl_Change, VideoRendererImpl_Change, &pVideoRenderer->mediaSeeking, &pVideoRenderer->csFilter);
624 pVideoRenderer->mediaSeeking.lpVtbl = &VideoRendererImpl_Seeking_Vtbl;
626 pVideoRenderer->sample_held = NULL;
627 *ppv = (LPVOID)pVideoRenderer;
629 else
631 pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
632 DeleteCriticalSection(&pVideoRenderer->csFilter);
633 CoTaskMemFree(pVideoRenderer);
636 if (!CreateRenderingSubsystem(pVideoRenderer))
637 return E_FAIL;
639 pVideoRenderer->blocked = CreateEventW(NULL, FALSE, FALSE, NULL);
640 if (!pVideoRenderer->blocked)
642 hr = HRESULT_FROM_WIN32(GetLastError());
643 IUnknown_Release((IUnknown *)pVideoRenderer);
646 return hr;
649 HRESULT VideoRendererDefault_create(IUnknown * pUnkOuter, LPVOID * ppv)
651 /* TODO: Attempt to use the VMR-7 renderer instead when possible */
652 return VideoRenderer_create(pUnkOuter, ppv);
655 static HRESULT WINAPI VideoRendererInner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID * ppv)
657 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
658 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
660 if (This->bAggregatable)
661 This->bUnkOuterValid = TRUE;
663 *ppv = NULL;
665 if (IsEqualIID(riid, &IID_IUnknown))
666 *ppv = (LPVOID)&(This->IInner_vtbl);
667 else if (IsEqualIID(riid, &IID_IPersist))
668 *ppv = (LPVOID)This;
669 else if (IsEqualIID(riid, &IID_IMediaFilter))
670 *ppv = (LPVOID)This;
671 else if (IsEqualIID(riid, &IID_IBaseFilter))
672 *ppv = (LPVOID)This;
673 else if (IsEqualIID(riid, &IID_IBasicVideo))
674 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
675 else if (IsEqualIID(riid, &IID_IVideoWindow))
676 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
677 else if (IsEqualIID(riid, &IID_IMediaSeeking))
678 *ppv = &This->mediaSeeking;
680 if (*ppv)
682 IUnknown_AddRef((IUnknown *)(*ppv));
683 return S_OK;
686 if (!IsEqualIID(riid, &IID_IPin))
687 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
689 return E_NOINTERFACE;
692 static ULONG WINAPI VideoRendererInner_AddRef(IUnknown * iface)
694 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
695 ULONG refCount = InterlockedIncrement(&This->refCount);
697 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
699 return refCount;
702 static ULONG WINAPI VideoRendererInner_Release(IUnknown * iface)
704 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
705 ULONG refCount = InterlockedDecrement(&This->refCount);
707 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
709 if (!refCount)
711 IPin *pConnectedTo;
713 DestroyWindow(This->hWnd);
714 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
715 WaitForSingleObject(This->hThread, INFINITE);
716 CloseHandle(This->hThread);
717 CloseHandle(This->hEvent);
719 if (This->pClock)
720 IReferenceClock_Release(This->pClock);
722 if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo)))
724 IPin_Disconnect(pConnectedTo);
725 IPin_Release(pConnectedTo);
727 IPin_Disconnect((IPin *)This->pInputPin);
729 IPin_Release((IPin *)This->pInputPin);
731 This->lpVtbl = NULL;
733 This->csFilter.DebugInfo->Spare[0] = 0;
734 DeleteCriticalSection(&This->csFilter);
736 TRACE("Destroying Video Renderer\n");
737 CoTaskMemFree(This);
739 return 0;
741 else
742 return refCount;
745 static const IUnknownVtbl IInner_VTable =
747 VideoRendererInner_QueryInterface,
748 VideoRendererInner_AddRef,
749 VideoRendererInner_Release
752 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
754 VideoRendererImpl *This = (VideoRendererImpl *)iface;
756 if (This->bAggregatable)
757 This->bUnkOuterValid = TRUE;
759 if (This->pUnkOuter)
761 if (This->bAggregatable)
762 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
764 if (IsEqualIID(riid, &IID_IUnknown))
766 HRESULT hr;
768 IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
769 hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
770 IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
771 This->bAggregatable = TRUE;
772 return hr;
775 *ppv = NULL;
776 return E_NOINTERFACE;
779 return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
782 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
784 VideoRendererImpl *This = (VideoRendererImpl *)iface;
786 if (This->pUnkOuter && This->bUnkOuterValid)
787 return IUnknown_AddRef(This->pUnkOuter);
788 return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
791 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
793 VideoRendererImpl *This = (VideoRendererImpl *)iface;
795 if (This->pUnkOuter && This->bUnkOuterValid)
796 return IUnknown_Release(This->pUnkOuter);
797 return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
800 /** IPersist methods **/
802 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
804 VideoRendererImpl *This = (VideoRendererImpl *)iface;
806 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
808 *pClsid = CLSID_VideoRenderer;
810 return S_OK;
813 /** IMediaFilter methods **/
815 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
817 VideoRendererImpl *This = (VideoRendererImpl *)iface;
819 TRACE("(%p/%p)->()\n", This, iface);
821 EnterCriticalSection(&This->csFilter);
823 This->state = State_Stopped;
824 SetEvent(This->hEvent);
825 SetEvent(This->blocked);
827 LeaveCriticalSection(&This->csFilter);
829 return S_OK;
832 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
834 VideoRendererImpl *This = (VideoRendererImpl *)iface;
836 TRACE("(%p/%p)->()\n", This, iface);
838 EnterCriticalSection(&This->csFilter);
839 if (This->state != State_Paused)
841 if (This->state == State_Stopped)
843 This->pInputPin->end_of_stream = 0;
844 ResetEvent(This->hEvent);
847 This->state = State_Paused;
848 ResetEvent(This->blocked);
850 LeaveCriticalSection(&This->csFilter);
852 return S_OK;
855 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
857 VideoRendererImpl *This = (VideoRendererImpl *)iface;
859 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
861 EnterCriticalSection(&This->csFilter);
862 if (This->state != State_Running)
864 if (This->state == State_Stopped)
866 This->pInputPin->end_of_stream = 0;
867 ResetEvent(This->hEvent);
869 SetEvent(This->blocked);
871 This->rtStreamStart = tStart;
872 This->state = State_Running;
874 LeaveCriticalSection(&This->csFilter);
876 return S_OK;
879 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
881 VideoRendererImpl *This = (VideoRendererImpl *)iface;
882 HRESULT hr;
884 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
886 if (WaitForSingleObject(This->hEvent, dwMilliSecsTimeout) == WAIT_TIMEOUT)
887 hr = VFW_S_STATE_INTERMEDIATE;
888 else
889 hr = S_OK;
891 EnterCriticalSection(&This->csFilter);
893 *pState = This->state;
895 LeaveCriticalSection(&This->csFilter);
897 return hr;
900 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
902 VideoRendererImpl *This = (VideoRendererImpl *)iface;
904 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
906 EnterCriticalSection(&This->csFilter);
908 if (This->pClock)
909 IReferenceClock_Release(This->pClock);
910 This->pClock = pClock;
911 if (This->pClock)
912 IReferenceClock_AddRef(This->pClock);
914 LeaveCriticalSection(&This->csFilter);
916 return S_OK;
919 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
921 VideoRendererImpl *This = (VideoRendererImpl *)iface;
923 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
925 EnterCriticalSection(&This->csFilter);
927 *ppClock = This->pClock;
928 if (This->pClock)
929 IReferenceClock_AddRef(This->pClock);
931 LeaveCriticalSection(&This->csFilter);
933 return S_OK;
936 /** IBaseFilter implementation **/
938 static HRESULT VideoRenderer_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin, DWORD *lastsynctick)
940 VideoRendererImpl *This = (VideoRendererImpl *)iface;
942 /* Our pins are static, not changing so setting static tick count is ok */
943 *lastsynctick = 0;
945 if (pos >= 1)
946 return S_FALSE;
948 *pin = (IPin *)This->pInputPin;
949 IPin_AddRef(*pin);
950 return S_OK;
953 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
955 VideoRendererImpl *This = (VideoRendererImpl *)iface;
957 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
959 return IEnumPinsImpl_Construct(ppEnum, VideoRenderer_GetPin, iface);
962 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
964 VideoRendererImpl *This = (VideoRendererImpl *)iface;
966 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
968 FIXME("VideoRenderer::FindPin(...)\n");
970 /* FIXME: critical section */
972 return E_NOTIMPL;
975 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
977 VideoRendererImpl *This = (VideoRendererImpl *)iface;
979 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
981 strcpyW(pInfo->achName, This->filterInfo.achName);
982 pInfo->pGraph = This->filterInfo.pGraph;
984 if (pInfo->pGraph)
985 IFilterGraph_AddRef(pInfo->pGraph);
987 return S_OK;
990 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
992 VideoRendererImpl *This = (VideoRendererImpl *)iface;
994 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
996 EnterCriticalSection(&This->csFilter);
998 if (pName)
999 strcpyW(This->filterInfo.achName, pName);
1000 else
1001 *This->filterInfo.achName = '\0';
1002 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
1004 LeaveCriticalSection(&This->csFilter);
1006 return S_OK;
1009 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
1011 VideoRendererImpl *This = (VideoRendererImpl *)iface;
1012 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
1013 return E_NOTIMPL;
1016 static const IBaseFilterVtbl VideoRenderer_Vtbl =
1018 VideoRenderer_QueryInterface,
1019 VideoRenderer_AddRef,
1020 VideoRenderer_Release,
1021 VideoRenderer_GetClassID,
1022 VideoRenderer_Stop,
1023 VideoRenderer_Pause,
1024 VideoRenderer_Run,
1025 VideoRenderer_GetState,
1026 VideoRenderer_SetSyncSource,
1027 VideoRenderer_GetSyncSource,
1028 VideoRenderer_EnumPins,
1029 VideoRenderer_FindPin,
1030 VideoRenderer_QueryFilterInfo,
1031 VideoRenderer_JoinFilterGraph,
1032 VideoRenderer_QueryVendorInfo
1035 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
1037 InputPin* This = (InputPin*)iface;
1038 IMediaEventSink* pEventSink;
1039 HRESULT hr;
1041 TRACE("(%p/%p)->()\n", This, iface);
1043 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
1044 if (SUCCEEDED(hr))
1046 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
1047 IMediaEventSink_Release(pEventSink);
1050 return hr;
1053 static HRESULT WINAPI VideoRenderer_InputPin_BeginFlush(IPin * iface)
1055 InputPin* This = (InputPin*)iface;
1056 VideoRendererImpl *pVideoRenderer = (VideoRendererImpl *)This->pin.pinInfo.pFilter;
1057 HRESULT hr;
1059 TRACE("(%p/%p)->()\n", This, iface);
1061 EnterCriticalSection(This->pin.pCritSec);
1062 if (pVideoRenderer->state == State_Paused)
1063 SetEvent(pVideoRenderer->blocked);
1065 hr = InputPin_BeginFlush(iface);
1066 LeaveCriticalSection(This->pin.pCritSec);
1068 return hr;
1071 static HRESULT WINAPI VideoRenderer_InputPin_EndFlush(IPin * iface)
1073 InputPin* This = (InputPin*)iface;
1074 VideoRendererImpl *pVideoRenderer = (VideoRendererImpl *)This->pin.pinInfo.pFilter;
1075 HRESULT hr;
1077 TRACE("(%p/%p)->()\n", This, iface);
1079 EnterCriticalSection(This->pin.pCritSec);
1080 if (pVideoRenderer->state == State_Paused)
1081 ResetEvent(pVideoRenderer->blocked);
1083 hr = InputPin_EndFlush(iface);
1084 LeaveCriticalSection(This->pin.pCritSec);
1086 return hr;
1089 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
1091 InputPin_QueryInterface,
1092 IPinImpl_AddRef,
1093 InputPin_Release,
1094 InputPin_Connect,
1095 InputPin_ReceiveConnection,
1096 IPinImpl_Disconnect,
1097 IPinImpl_ConnectedTo,
1098 IPinImpl_ConnectionMediaType,
1099 IPinImpl_QueryPinInfo,
1100 IPinImpl_QueryDirection,
1101 IPinImpl_QueryId,
1102 IPinImpl_QueryAccept,
1103 IPinImpl_EnumMediaTypes,
1104 IPinImpl_QueryInternalConnections,
1105 VideoRenderer_InputPin_EndOfStream,
1106 VideoRenderer_InputPin_BeginFlush,
1107 VideoRenderer_InputPin_EndFlush,
1108 InputPin_NewSegment
1111 /*** IUnknown methods ***/
1112 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
1113 REFIID riid,
1114 LPVOID*ppvObj) {
1115 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1117 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1119 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1122 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
1123 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1125 TRACE("(%p/%p)->()\n", This, iface);
1127 return VideoRenderer_AddRef((IBaseFilter*)This);
1130 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
1131 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1133 TRACE("(%p/%p)->()\n", This, iface);
1135 return VideoRenderer_Release((IBaseFilter*)This);
1138 /*** IDispatch methods ***/
1139 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
1140 UINT*pctinfo) {
1141 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1143 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1145 return S_OK;
1148 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
1149 UINT iTInfo,
1150 LCID lcid,
1151 ITypeInfo**ppTInfo) {
1152 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1154 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1156 return S_OK;
1159 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
1160 REFIID riid,
1161 LPOLESTR*rgszNames,
1162 UINT cNames,
1163 LCID lcid,
1164 DISPID*rgDispId) {
1165 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1167 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1169 return S_OK;
1172 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
1173 DISPID dispIdMember,
1174 REFIID riid,
1175 LCID lcid,
1176 WORD wFlags,
1177 DISPPARAMS*pDispParams,
1178 VARIANT*pVarResult,
1179 EXCEPINFO*pExepInfo,
1180 UINT*puArgErr) {
1181 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1183 FIXME("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
1185 return S_OK;
1188 /*** IBasicVideo methods ***/
1189 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
1190 REFTIME *pAvgTimePerFrame) {
1191 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1193 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
1195 return S_OK;
1198 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
1199 long *pBitRate) {
1200 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1202 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
1204 return S_OK;
1207 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
1208 long *pBitErrorRate) {
1209 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1211 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
1213 return S_OK;
1216 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
1217 long *pVideoWidth) {
1218 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1220 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
1222 *pVideoWidth = This->VideoWidth;
1224 return S_OK;
1227 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
1228 long *pVideoHeight) {
1229 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1231 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
1233 *pVideoHeight = This->VideoHeight;
1235 return S_OK;
1238 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
1239 long SourceLeft) {
1240 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1242 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
1244 This->SourceRect.left = SourceLeft;
1246 return S_OK;
1249 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
1250 long *pSourceLeft) {
1251 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1253 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
1255 *pSourceLeft = This->SourceRect.left;
1257 return S_OK;
1260 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
1261 long SourceWidth) {
1262 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1264 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
1266 This->SourceRect.right = This->SourceRect.left + SourceWidth;
1268 return S_OK;
1271 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
1272 long *pSourceWidth) {
1273 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1275 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
1277 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
1279 return S_OK;
1282 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
1283 long SourceTop) {
1284 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1286 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
1288 This->SourceRect.top = SourceTop;
1290 return S_OK;
1293 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
1294 long *pSourceTop) {
1295 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1297 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
1299 *pSourceTop = This->SourceRect.top;
1301 return S_OK;
1304 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
1305 long SourceHeight) {
1306 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1308 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
1310 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
1312 return S_OK;
1315 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
1316 long *pSourceHeight) {
1317 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1319 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1321 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
1323 return S_OK;
1326 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1327 long DestinationLeft) {
1328 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1330 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1332 This->DestRect.left = DestinationLeft;
1334 return S_OK;
1337 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1338 long *pDestinationLeft) {
1339 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1341 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1343 *pDestinationLeft = This->DestRect.left;
1345 return S_OK;
1348 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1349 long DestinationWidth) {
1350 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1352 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1354 This->DestRect.right = This->DestRect.left + DestinationWidth;
1356 return S_OK;
1359 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1360 long *pDestinationWidth) {
1361 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1363 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1365 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1367 return S_OK;
1370 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1371 long DestinationTop) {
1372 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1374 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1376 This->DestRect.top = DestinationTop;
1378 return S_OK;
1381 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1382 long *pDestinationTop) {
1383 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1385 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1387 *pDestinationTop = This->DestRect.top;
1389 return S_OK;
1392 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1393 long DestinationHeight) {
1394 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1396 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1398 This->DestRect.right = This->DestRect.left + DestinationHeight;
1400 return S_OK;
1403 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1404 long *pDestinationHeight) {
1405 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1407 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1409 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1411 return S_OK;
1414 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1415 long Left,
1416 long Top,
1417 long Width,
1418 long Height) {
1419 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1421 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1423 This->SourceRect.left = Left;
1424 This->SourceRect.top = Top;
1425 This->SourceRect.right = Left + Width;
1426 This->SourceRect.bottom = Top + Height;
1428 return S_OK;
1431 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1432 long *pLeft,
1433 long *pTop,
1434 long *pWidth,
1435 long *pHeight) {
1436 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1438 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1440 *pLeft = This->SourceRect.left;
1441 *pTop = This->SourceRect.top;
1442 *pWidth = This->SourceRect.right - This->SourceRect.left;
1443 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1445 return S_OK;
1448 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1449 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1451 TRACE("(%p/%p)->()\n", This, iface);
1453 This->SourceRect.left = 0;
1454 This->SourceRect.top = 0;
1455 This->SourceRect.right = This->VideoWidth;
1456 This->SourceRect.bottom = This->VideoHeight;
1458 return S_OK;
1461 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1462 long Left,
1463 long Top,
1464 long Width,
1465 long Height) {
1466 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1468 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1470 This->DestRect.left = Left;
1471 This->DestRect.top = Top;
1472 This->DestRect.right = Left + Width;
1473 This->DestRect.bottom = Top + Height;
1475 return S_OK;
1478 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1479 long *pLeft,
1480 long *pTop,
1481 long *pWidth,
1482 long *pHeight) {
1483 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1485 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1487 *pLeft = This->DestRect.left;
1488 *pTop = This->DestRect.top;
1489 *pWidth = This->DestRect.right - This->DestRect.left;
1490 *pHeight = This->DestRect.bottom - This->DestRect.top;
1492 return S_OK;
1495 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1496 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1497 RECT rect;
1499 TRACE("(%p/%p)->()\n", This, iface);
1501 if (!GetClientRect(This->hWnd, &rect))
1502 return E_FAIL;
1504 This->SourceRect.left = 0;
1505 This->SourceRect.top = 0;
1506 This->SourceRect.right = rect.right;
1507 This->SourceRect.bottom = rect.bottom;
1509 return S_OK;
1512 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1513 long *pWidth,
1514 long *pHeight) {
1515 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1517 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1519 *pWidth = This->VideoWidth;
1520 *pHeight = This->VideoHeight;
1522 return S_OK;
1525 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1526 long StartIndex,
1527 long Entries,
1528 long *pRetrieved,
1529 long *pPalette) {
1530 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1532 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1534 return S_OK;
1537 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1538 long *pBufferSize,
1539 long *pDIBImage) {
1540 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1541 BITMAPINFOHEADER *bmiHeader;
1542 LONG needed_size;
1543 AM_MEDIA_TYPE *amt = &This->pInputPin->pin.mtCurrent;
1544 char *ptr;
1546 EnterCriticalSection(&This->csFilter);
1548 if (!This->sample_held)
1550 LeaveCriticalSection(&This->csFilter);
1551 return (This->state == State_Paused ? E_UNEXPECTED : VFW_E_NOT_PAUSED);
1554 FIXME("(%p/%p)->(%p, %p): partial stub\n", This, iface, pBufferSize, pDIBImage);
1556 if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo))
1558 bmiHeader = &((VIDEOINFOHEADER *)amt->pbFormat)->bmiHeader;
1560 else if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo2))
1562 bmiHeader = &((VIDEOINFOHEADER2 *)amt->pbFormat)->bmiHeader;
1564 else
1566 FIXME("Unknown type %s\n", debugstr_guid(&amt->subtype));
1567 LeaveCriticalSection(&This->csFilter);
1568 return VFW_E_RUNTIME_ERROR;
1571 needed_size = bmiHeader->biSize;
1572 needed_size += IMediaSample_GetActualDataLength(This->sample_held);
1574 if (!pDIBImage)
1576 *pBufferSize = needed_size;
1577 LeaveCriticalSection(&This->csFilter);
1578 return S_OK;
1581 if (needed_size < *pBufferSize)
1583 ERR("Buffer too small %u/%lu\n", needed_size, *pBufferSize);
1584 LeaveCriticalSection(&This->csFilter);
1585 return E_FAIL;
1587 *pBufferSize = needed_size;
1589 memcpy(pDIBImage, bmiHeader, bmiHeader->biSize);
1590 IMediaSample_GetPointer(This->sample_held, (BYTE **)&ptr);
1591 memcpy((char *)pDIBImage + bmiHeader->biSize, ptr, IMediaSample_GetActualDataLength(This->sample_held));
1593 LeaveCriticalSection(&This->csFilter);
1595 return S_OK;
1598 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1599 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1601 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1603 return S_OK;
1606 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1607 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1609 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1611 return S_OK;
1615 static const IBasicVideoVtbl IBasicVideo_VTable =
1617 Basicvideo_QueryInterface,
1618 Basicvideo_AddRef,
1619 Basicvideo_Release,
1620 Basicvideo_GetTypeInfoCount,
1621 Basicvideo_GetTypeInfo,
1622 Basicvideo_GetIDsOfNames,
1623 Basicvideo_Invoke,
1624 Basicvideo_get_AvgTimePerFrame,
1625 Basicvideo_get_BitRate,
1626 Basicvideo_get_BitErrorRate,
1627 Basicvideo_get_VideoWidth,
1628 Basicvideo_get_VideoHeight,
1629 Basicvideo_put_SourceLeft,
1630 Basicvideo_get_SourceLeft,
1631 Basicvideo_put_SourceWidth,
1632 Basicvideo_get_SourceWidth,
1633 Basicvideo_put_SourceTop,
1634 Basicvideo_get_SourceTop,
1635 Basicvideo_put_SourceHeight,
1636 Basicvideo_get_SourceHeight,
1637 Basicvideo_put_DestinationLeft,
1638 Basicvideo_get_DestinationLeft,
1639 Basicvideo_put_DestinationWidth,
1640 Basicvideo_get_DestinationWidth,
1641 Basicvideo_put_DestinationTop,
1642 Basicvideo_get_DestinationTop,
1643 Basicvideo_put_DestinationHeight,
1644 Basicvideo_get_DestinationHeight,
1645 Basicvideo_SetSourcePosition,
1646 Basicvideo_GetSourcePosition,
1647 Basicvideo_SetDefaultSourcePosition,
1648 Basicvideo_SetDestinationPosition,
1649 Basicvideo_GetDestinationPosition,
1650 Basicvideo_SetDefaultDestinationPosition,
1651 Basicvideo_GetVideoSize,
1652 Basicvideo_GetVideoPaletteEntries,
1653 Basicvideo_GetCurrentImage,
1654 Basicvideo_IsUsingDefaultSource,
1655 Basicvideo_IsUsingDefaultDestination
1659 /*** IUnknown methods ***/
1660 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1661 REFIID riid,
1662 LPVOID*ppvObj) {
1663 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1665 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1667 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1670 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1671 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1673 TRACE("(%p/%p)->()\n", This, iface);
1675 return VideoRenderer_AddRef((IBaseFilter*)This);
1678 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1679 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1681 TRACE("(%p/%p)->()\n", This, iface);
1683 return VideoRenderer_Release((IBaseFilter*)This);
1686 /*** IDispatch methods ***/
1687 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1688 UINT*pctinfo) {
1689 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1691 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1693 return S_OK;
1696 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1697 UINT iTInfo,
1698 LCID lcid,
1699 ITypeInfo**ppTInfo) {
1700 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1702 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1704 return S_OK;
1707 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1708 REFIID riid,
1709 LPOLESTR*rgszNames,
1710 UINT cNames,
1711 LCID lcid,
1712 DISPID*rgDispId) {
1713 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1715 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1717 return S_OK;
1720 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1721 DISPID dispIdMember,
1722 REFIID riid,
1723 LCID lcid,
1724 WORD wFlags,
1725 DISPPARAMS*pDispParams,
1726 VARIANT*pVarResult,
1727 EXCEPINFO*pExepInfo,
1728 UINT*puArgErr) {
1729 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1731 FIXME("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
1733 return S_OK;
1736 /*** IVideoWindow methods ***/
1737 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1738 BSTR strCaption) {
1739 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1741 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1743 if (!SetWindowTextW(This->hWnd, strCaption))
1744 return E_FAIL;
1746 return S_OK;
1749 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1750 BSTR *strCaption) {
1751 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1753 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1755 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1757 return S_OK;
1760 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1761 long WindowStyle) {
1762 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1763 LONG old;
1765 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1767 TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
1769 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1770 return E_INVALIDARG;
1772 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1774 return S_OK;
1777 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1778 long *WindowStyle) {
1779 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1781 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1783 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1785 return S_OK;
1788 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1789 long WindowStyleEx) {
1790 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1792 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1794 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1795 return E_INVALIDARG;
1797 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1798 return E_FAIL;
1800 return S_OK;
1803 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1804 long *WindowStyleEx) {
1805 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1807 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1809 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1811 return S_OK;
1814 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1815 long AutoShow) {
1816 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1818 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1820 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1822 return S_OK;
1825 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1826 long *AutoShow) {
1827 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1829 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1831 *AutoShow = This->AutoShow;
1833 return S_OK;
1836 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1837 long WindowState) {
1838 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1840 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1842 return S_OK;
1845 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1846 long *WindowState) {
1847 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1849 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1851 return S_OK;
1854 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1855 long BackgroundPalette) {
1856 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1858 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1860 return S_OK;
1863 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1864 long *pBackgroundPalette) {
1865 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1867 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1869 return S_OK;
1872 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1873 long Visible) {
1874 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1876 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1878 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1880 return S_OK;
1883 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1884 long *pVisible) {
1885 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1887 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1889 *pVisible = IsWindowVisible(This->hWnd);
1891 return S_OK;
1894 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1895 long Left) {
1896 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1898 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1900 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1901 return E_FAIL;
1903 This->WindowPos.left = Left;
1905 return S_OK;
1908 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1909 long *pLeft) {
1910 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1912 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1914 *pLeft = This->WindowPos.left;
1916 return S_OK;
1919 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1920 long Width) {
1921 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1923 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1925 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1926 return E_FAIL;
1928 This->WindowPos.right = This->WindowPos.left + Width;
1930 return S_OK;
1933 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1934 long *pWidth) {
1935 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1937 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1939 *pWidth = This->WindowPos.right - This->WindowPos.left;
1941 return S_OK;
1944 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1945 long Top) {
1946 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1948 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1950 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1951 return E_FAIL;
1953 This->WindowPos.top = Top;
1955 return S_OK;
1958 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1959 long *pTop) {
1960 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1962 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1964 *pTop = This->WindowPos.top;
1966 return S_OK;
1969 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1970 long Height) {
1971 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1973 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1975 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1976 return E_FAIL;
1978 This->WindowPos.bottom = This->WindowPos.top + Height;
1980 return S_OK;
1983 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1984 long *pHeight) {
1985 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1987 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1989 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1991 return S_OK;
1994 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1995 OAHWND Owner) {
1996 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1998 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
2000 SetParent(This->hWnd, (HWND)Owner);
2002 return S_OK;
2005 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
2006 OAHWND *Owner) {
2007 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2009 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
2011 *(HWND*)Owner = GetParent(This->hWnd);
2013 return S_OK;
2016 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
2017 OAHWND Drain) {
2018 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2020 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
2022 This->hWndMsgDrain = (HWND)Drain;
2024 return S_OK;
2027 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
2028 OAHWND *Drain) {
2029 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2031 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
2033 *Drain = (OAHWND)This->hWndMsgDrain;
2035 return S_OK;
2038 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
2039 long *Color) {
2040 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2042 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
2044 return S_OK;
2047 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
2048 long Color) {
2049 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2051 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
2053 return S_OK;
2056 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
2057 long *FullScreenMode) {
2058 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2060 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
2062 return S_OK;
2065 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
2066 long FullScreenMode) {
2067 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2069 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
2071 return S_OK;
2074 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
2075 long Focus) {
2076 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2077 BOOL ret;
2078 IPin* pPin;
2079 HRESULT hr;
2081 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
2083 if ((Focus != FALSE) && (Focus != TRUE))
2084 return E_INVALIDARG;
2086 hr = IPin_ConnectedTo((IPin *)This->pInputPin, &pPin);
2087 if ((hr != S_OK) || !pPin)
2088 return VFW_E_NOT_CONNECTED;
2090 if (Focus)
2091 ret = SetForegroundWindow(This->hWnd);
2092 else
2093 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2095 if (!ret)
2096 return E_FAIL;
2098 return S_OK;
2101 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
2102 OAHWND hwnd,
2103 long uMsg,
2104 LONG_PTR wParam,
2105 LONG_PTR lParam) {
2106 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2108 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
2110 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
2111 return E_FAIL;
2113 return S_OK;
2116 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
2117 long Left,
2118 long Top,
2119 long Width,
2120 long Height) {
2121 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2123 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2125 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
2126 return E_FAIL;
2128 This->WindowPos.left = Left;
2129 This->WindowPos.top = Top;
2130 This->WindowPos.right = Left + Width;
2131 This->WindowPos.bottom = Top + Height;
2133 return S_OK;
2136 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
2137 long *pLeft,
2138 long *pTop,
2139 long *pWidth,
2140 long *pHeight) {
2141 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2143 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2145 *pLeft = This->WindowPos.left;
2146 *pTop = This->WindowPos.top;
2147 *pWidth = This->WindowPos.right - This->WindowPos.left;
2148 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
2150 return S_OK;
2153 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
2154 long *pWidth,
2155 long *pHeight) {
2156 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2158 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
2160 *pWidth = This->VideoWidth;
2161 *pHeight = This->VideoHeight;
2163 return S_OK;
2166 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
2167 long *pWidth,
2168 long *pHeight) {
2169 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2171 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
2173 *pWidth = This->VideoWidth;
2174 *pHeight = This->VideoHeight;
2176 return S_OK;
2179 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
2180 long *pLeft,
2181 long *pTop,
2182 long *pWidth,
2183 long *pHeight) {
2184 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2186 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
2188 return S_OK;
2191 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
2192 long HideCursor) {
2193 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2195 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
2197 return S_OK;
2200 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
2201 long *CursorHidden) {
2202 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2204 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
2206 return S_OK;
2209 static const IVideoWindowVtbl IVideoWindow_VTable =
2211 Videowindow_QueryInterface,
2212 Videowindow_AddRef,
2213 Videowindow_Release,
2214 Videowindow_GetTypeInfoCount,
2215 Videowindow_GetTypeInfo,
2216 Videowindow_GetIDsOfNames,
2217 Videowindow_Invoke,
2218 Videowindow_put_Caption,
2219 Videowindow_get_Caption,
2220 Videowindow_put_WindowStyle,
2221 Videowindow_get_WindowStyle,
2222 Videowindow_put_WindowStyleEx,
2223 Videowindow_get_WindowStyleEx,
2224 Videowindow_put_AutoShow,
2225 Videowindow_get_AutoShow,
2226 Videowindow_put_WindowState,
2227 Videowindow_get_WindowState,
2228 Videowindow_put_BackgroundPalette,
2229 Videowindow_get_BackgroundPalette,
2230 Videowindow_put_Visible,
2231 Videowindow_get_Visible,
2232 Videowindow_put_Left,
2233 Videowindow_get_Left,
2234 Videowindow_put_Width,
2235 Videowindow_get_Width,
2236 Videowindow_put_Top,
2237 Videowindow_get_Top,
2238 Videowindow_put_Height,
2239 Videowindow_get_Height,
2240 Videowindow_put_Owner,
2241 Videowindow_get_Owner,
2242 Videowindow_put_MessageDrain,
2243 Videowindow_get_MessageDrain,
2244 Videowindow_get_BorderColor,
2245 Videowindow_put_BorderColor,
2246 Videowindow_get_FullScreenMode,
2247 Videowindow_put_FullScreenMode,
2248 Videowindow_SetWindowForeground,
2249 Videowindow_NotifyOwnerMessage,
2250 Videowindow_SetWindowPosition,
2251 Videowindow_GetWindowPosition,
2252 Videowindow_GetMinIdealImageSize,
2253 Videowindow_GetMaxIdealImageSize,
2254 Videowindow_GetRestorePosition,
2255 Videowindow_HideCursor,
2256 Videowindow_IsCursorHidden