ntdll: Initialize pointers to NULL (Coverity).
[wine] / dlls / quartz / videorenderer.c
1 /*
2  * Video Renderer (Fullscreen and Windowed using Direct Draw)
3  *
4  * Copyright 2004 Christian Costa
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #define NONAMELESSSTRUCT
24 #define NONAMELESSUNION
25 #include "quartz_private.h"
26 #include "control_private.h"
27 #include "pin.h"
28
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
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
43
44 static BOOL wnd_class_registered = FALSE;
45
46 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
47
48 static const IBaseFilterVtbl VideoRenderer_Vtbl;
49 static const IBasicVideoVtbl IBasicVideo_VTable;
50 static const IVideoWindowVtbl IVideoWindow_VTable;
51 static const IPinVtbl VideoRenderer_InputPin_Vtbl;
52
53 typedef struct VideoRendererImpl
54 {
55     const IBaseFilterVtbl * lpVtbl;
56     const IBasicVideoVtbl * IBasicVideo_vtbl;
57     const IVideoWindowVtbl * IVideoWindow_vtbl;
58
59     LONG refCount;
60     CRITICAL_SECTION csFilter;
61     FILTER_STATE state;
62     REFERENCE_TIME rtStreamStart;
63     IReferenceClock * pClock;
64     FILTER_INFO filterInfo;
65
66     InputPin * pInputPin;
67     IPin ** ppPins;
68
69     BOOL init;
70     HANDLE hThread;
71     DWORD ThreadID;
72     HANDLE hEvent;
73     BOOL ThreadResult;
74     HWND hWnd;
75     HWND hWndMsgDrain;
76     BOOL AutoShow;
77     RECT SourceRect;
78     RECT DestRect;
79     RECT WindowPos;
80     long VideoWidth;
81     long VideoHeight;
82 } VideoRendererImpl;
83
84 static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
85 {
86     VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongA(hwnd, 0);
87     LPRECT lprect = (LPRECT)lParam;
88
89     if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
90     {
91         switch(uMsg)
92         {
93             case WM_KEYDOWN:
94             case WM_KEYUP:
95             case WM_LBUTTONDBLCLK:
96             case WM_LBUTTONDOWN:
97             case WM_LBUTTONUP:
98             case WM_MBUTTONDBLCLK:
99             case WM_MBUTTONDOWN:
100             case WM_MBUTTONUP:
101             case WM_MOUSEACTIVATE:
102             case WM_MOUSEMOVE:
103             case WM_NCLBUTTONDBLCLK:
104             case WM_NCLBUTTONDOWN:
105             case WM_NCLBUTTONUP:
106             case WM_NCMBUTTONDBLCLK:
107             case WM_NCMBUTTONDOWN:
108             case WM_NCMBUTTONUP:
109             case WM_NCMOUSEMOVE:
110             case WM_NCRBUTTONDBLCLK:
111             case WM_NCRBUTTONDOWN:
112             case WM_NCRBUTTONUP:
113             case WM_RBUTTONDBLCLK:
114             case WM_RBUTTONDOWN:
115             case WM_RBUTTONUP:
116                 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
117                 break;
118             default:
119                 break;
120         }
121     }
122
123     switch(uMsg)
124     {
125         case WM_SIZING:
126             /* TRACE("WM_SIZING %d %d %d %d\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
127             SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
128             GetClientRect(hwnd, &pVideoRenderer->DestRect);
129             return TRUE;
130         default:
131             return DefWindowProcA(hwnd, uMsg, wParam, lParam);
132     }
133     return 0;
134 }
135
136 static BOOL CreateRenderingWindow(VideoRendererImpl* This)
137 {
138     WNDCLASSA winclass;
139
140     TRACE("(%p)->()\n", This);
141     
142     winclass.style = 0;
143     winclass.lpfnWndProc = VideoWndProcA;
144     winclass.cbClsExtra = 0;
145     winclass.cbWndExtra = sizeof(VideoRendererImpl*);
146     winclass.hInstance = NULL;
147     winclass.hIcon = NULL;
148     winclass.hCursor = NULL;
149     winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
150     winclass.lpszMenuName = NULL;
151     winclass.lpszClassName = "Wine ActiveMovie Class";
152
153     if (!wnd_class_registered)
154     {
155         if (!RegisterClassA(&winclass))
156         {
157             ERR("Unable to register window %u\n", GetLastError());
158             return FALSE;
159         }
160         wnd_class_registered = TRUE;
161     }
162
163     This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
164                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
165                                  NULL, NULL, NULL);
166
167     if (!This->hWnd)
168     {
169         ERR("Unable to create window\n");
170         return FALSE;
171     }
172
173     SetWindowLongA(This->hWnd, 0, (LONG)This);
174
175     return TRUE;
176 }
177
178 static DWORD WINAPI MessageLoop(LPVOID lpParameter)
179 {
180     VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
181     MSG msg; 
182     BOOL fGotMessage;
183
184     TRACE("Starting message loop\n");
185
186     if (!CreateRenderingWindow(This))
187     {
188         This->ThreadResult = FALSE;
189         SetEvent(This->hEvent);
190         return 0;
191     }
192
193     This->ThreadResult = TRUE;
194     SetEvent(This->hEvent);
195
196     while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1) 
197     {
198         TranslateMessage(&msg); 
199         DispatchMessageA(&msg); 
200     }
201
202     TRACE("End of message loop\n");
203
204     return msg.wParam;
205 }
206
207 static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
208 {
209     This->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
210     if (!This->hEvent)
211         return FALSE;
212
213     This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
214     if (!This->hThread)
215     {
216         CloseHandle(This->hEvent);
217         return FALSE;
218     }
219
220     WaitForSingleObject(This->hEvent, INFINITE);
221     CloseHandle(This->hEvent);
222
223     if (!This->ThreadResult)
224     {
225         CloseHandle(This->hThread);
226         return FALSE;
227     }
228
229     return TRUE;
230 }
231
232 static const IMemInputPinVtbl MemInputPin_Vtbl = 
233 {
234     MemInputPin_QueryInterface,
235     MemInputPin_AddRef,
236     MemInputPin_Release,
237     MemInputPin_GetAllocator,
238     MemInputPin_NotifyAllocator,
239     MemInputPin_GetAllocatorRequirements,
240     MemInputPin_Receive,
241     MemInputPin_ReceiveMultiple,
242     MemInputPin_ReceiveCanBlock
243 };
244
245 static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
246 {
247     InputPin * pPinImpl;
248
249     *ppPin = NULL;
250
251     if (pPinInfo->dir != PINDIR_INPUT)
252     {
253         ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
254         return E_INVALIDARG;
255     }
256
257     pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
258
259     if (!pPinImpl)
260         return E_OUTOFMEMORY;
261
262     if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
263     {
264         pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl;
265         pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
266       
267         *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
268         return S_OK;
269     }
270     return E_FAIL;
271 }
272
273 static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
274 {
275     VIDEOINFOHEADER* format;
276     AM_MEDIA_TYPE amt;
277     HRESULT hr = S_OK;
278     DDSURFACEDESC sdesc;
279     int width;
280     int height;
281     LPBYTE palette = NULL;
282     HDC hDC;
283
284     TRACE("%p %p %d\n", This, data, size);
285
286     sdesc.dwSize = sizeof(sdesc);
287     hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
288     if (FAILED(hr)) {
289         ERR("Unable to retrieve media type\n");
290         return hr;
291     }
292     format = (VIDEOINFOHEADER*)amt.pbFormat;
293
294     TRACE("biSize = %d\n", format->bmiHeader.biSize);
295     TRACE("biWidth = %d\n", format->bmiHeader.biWidth);
296     TRACE("biHeight = %d\n", format->bmiHeader.biHeight);
297     TRACE("biPlanes = %d\n", format->bmiHeader.biPlanes);
298     TRACE("biBitCount = %d\n", format->bmiHeader.biBitCount);
299     TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(format->bmiHeader.biCompression), 4));
300     TRACE("biSizeImage = %d\n", format->bmiHeader.biSizeImage);
301
302     width = format->bmiHeader.biWidth;
303     height = format->bmiHeader.biHeight;
304     palette = ((LPBYTE)&format->bmiHeader) + format->bmiHeader.biSize;
305  
306     if (!This->init)
307     {
308         /* Compute the size of the whole window so the client area size matches video one */
309         RECT wrect, crect;
310         int h, v;
311         GetWindowRect(This->hWnd, &wrect);
312         GetClientRect(This->hWnd, &crect);
313         h = (wrect.right - wrect.left) - (crect.right - crect.left);
314         v = (wrect.bottom - wrect.top) - (crect.bottom - crect.top);
315         SetWindowPos(This->hWnd, NULL, 0, 0, width + h +20, height + v+20, SWP_NOZORDER|SWP_NOMOVE);
316         This->WindowPos.left = 0;
317         This->WindowPos.top = 0;
318         This->WindowPos.right = width;
319         This->WindowPos.bottom = abs(height);
320         GetClientRect(This->hWnd, &This->DestRect);
321         This->init  = TRUE;
322     }
323
324     hDC = GetDC(This->hWnd);
325
326     if (!hDC) {
327         ERR("Cannot get DC from window!\n");
328         return E_FAIL;
329     }
330
331     TRACE("Src Rect: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
332     TRACE("Dst Rect: %d %d %d %d\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom);
333
334     StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
335                   This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
336                   This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
337                   data, (BITMAPINFO*)&format->bmiHeader, DIB_RGB_COLORS, SRCCOPY);
338
339     ReleaseDC(This->hWnd, hDC);
340     
341     if (This->AutoShow)
342         ShowWindow(This->hWnd, SW_SHOW);
343
344     return S_OK;
345 }
346
347 static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
348 {
349     VideoRendererImpl *This = (VideoRendererImpl *)iface;
350     LPBYTE pbSrcStream = NULL;
351     long cbSrcStream = 0;
352     REFERENCE_TIME tStart, tStop;
353     HRESULT hr;
354
355     TRACE("%p %p\n", iface, pSample);
356     
357     hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
358     if (FAILED(hr))
359     {
360         ERR("Cannot get pointer to sample data (%x)\n", hr);
361         return hr;
362     }
363
364     hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
365     if (FAILED(hr))
366         ERR("Cannot get sample time (%x)\n", hr);
367
368     cbSrcStream = IMediaSample_GetActualDataLength(pSample);
369
370     TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
371
372 #if 0 /* For debugging purpose */
373     {
374         int i;
375         for(i = 0; i < cbSrcStream; i++)
376         {
377             if ((i!=0) && !(i%16))
378                 TRACE("\n");
379                 TRACE("%02x ", pbSrcStream[i]);
380         }
381         TRACE("\n");
382     }
383 #endif
384     
385     VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
386
387     return S_OK;
388 }
389
390 static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
391 {
392     if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
393         return S_FALSE;
394
395     if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
396         IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
397         IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
398         IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
399     {
400         VideoRendererImpl* This = (VideoRendererImpl*) iface;
401         VIDEOINFOHEADER* format = (VIDEOINFOHEADER*)pmt->pbFormat;
402
403         if (!IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
404         {
405             WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
406             return S_FALSE;
407         }
408         This->SourceRect.left = 0;
409         This->SourceRect.top = 0;
410         This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
411         This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
412         return S_OK;
413     }
414     return S_FALSE;
415 }
416
417 HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
418 {
419     HRESULT hr;
420     PIN_INFO piInput;
421     VideoRendererImpl * pVideoRenderer;
422
423     TRACE("(%p, %p)\n", pUnkOuter, ppv);
424
425     *ppv = NULL;
426
427     if (pUnkOuter)
428         return CLASS_E_NOAGGREGATION;
429     
430     pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
431
432     pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
433     pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
434     pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
435     
436     pVideoRenderer->refCount = 1;
437     InitializeCriticalSection(&pVideoRenderer->csFilter);
438     pVideoRenderer->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
439     pVideoRenderer->state = State_Stopped;
440     pVideoRenderer->pClock = NULL;
441     pVideoRenderer->init = 0;
442     pVideoRenderer->AutoShow = 1;
443     ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
444
445     pVideoRenderer->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
446
447     /* construct input pin */
448     piInput.dir = PINDIR_INPUT;
449     piInput.pFilter = (IBaseFilter *)pVideoRenderer;
450     lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
451
452     hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
453
454     if (SUCCEEDED(hr))
455     {
456         pVideoRenderer->ppPins[0] = (IPin *)pVideoRenderer->pInputPin;
457         *ppv = (LPVOID)pVideoRenderer;
458     }
459     else
460     {
461         CoTaskMemFree(pVideoRenderer->ppPins);
462         pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
463         DeleteCriticalSection(&pVideoRenderer->csFilter);
464         CoTaskMemFree(pVideoRenderer);
465     }
466
467     if (!CreateRenderingSubsystem(pVideoRenderer))
468         return E_FAIL;
469     
470     return hr;
471 }
472
473 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
474 {
475     VideoRendererImpl *This = (VideoRendererImpl *)iface;
476     TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
477
478     *ppv = NULL;
479
480     if (IsEqualIID(riid, &IID_IUnknown))
481         *ppv = (LPVOID)This;
482     else if (IsEqualIID(riid, &IID_IPersist))
483         *ppv = (LPVOID)This;
484     else if (IsEqualIID(riid, &IID_IMediaFilter))
485         *ppv = (LPVOID)This;
486     else if (IsEqualIID(riid, &IID_IBaseFilter))
487         *ppv = (LPVOID)This;
488     else if (IsEqualIID(riid, &IID_IBasicVideo))
489         *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
490     else if (IsEqualIID(riid, &IID_IVideoWindow))
491         *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
492
493     if (*ppv)
494     {
495         IUnknown_AddRef((IUnknown *)(*ppv));
496         return S_OK;
497     }
498
499     FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
500
501     return E_NOINTERFACE;
502 }
503
504 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
505 {
506     VideoRendererImpl *This = (VideoRendererImpl *)iface;
507     ULONG refCount = InterlockedIncrement(&This->refCount);
508
509     TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
510
511     return refCount;
512 }
513
514 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
515 {
516     VideoRendererImpl *This = (VideoRendererImpl *)iface;
517     ULONG refCount = InterlockedDecrement(&This->refCount);
518
519     TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
520
521     if (!refCount)
522     {
523         IPin *pConnectedTo;
524
525         DestroyWindow(This->hWnd);
526         PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
527         WaitForSingleObject(This->hThread, INFINITE);
528         CloseHandle(This->hThread);
529
530         if (This->pClock)
531             IReferenceClock_Release(This->pClock);
532         
533         if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[0], &pConnectedTo)))
534         {
535             IPin_Disconnect(pConnectedTo);
536             IPin_Release(pConnectedTo);
537         }
538         IPin_Disconnect(This->ppPins[0]);
539
540         IPin_Release(This->ppPins[0]);
541         
542         CoTaskMemFree(This->ppPins);
543         This->lpVtbl = NULL;
544         
545         This->csFilter.DebugInfo->Spare[0] = 0;
546         DeleteCriticalSection(&This->csFilter);
547
548         TRACE("Destroying Video Renderer\n");
549         CoTaskMemFree(This);
550         
551         return 0;
552     }
553     else
554         return refCount;
555 }
556
557 /** IPersist methods **/
558
559 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
560 {
561     VideoRendererImpl *This = (VideoRendererImpl *)iface;
562
563     TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
564
565     *pClsid = CLSID_VideoRenderer;
566
567     return S_OK;
568 }
569
570 /** IMediaFilter methods **/
571
572 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
573 {
574     VideoRendererImpl *This = (VideoRendererImpl *)iface;
575
576     TRACE("(%p/%p)->()\n", This, iface);
577
578     EnterCriticalSection(&This->csFilter);
579     {
580         This->state = State_Stopped;
581     }
582     LeaveCriticalSection(&This->csFilter);
583     
584     return S_OK;
585 }
586
587 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
588 {
589     VideoRendererImpl *This = (VideoRendererImpl *)iface;
590     
591     TRACE("(%p/%p)->()\n", This, iface);
592
593     EnterCriticalSection(&This->csFilter);
594     {
595         This->state = State_Paused;
596     }
597     LeaveCriticalSection(&This->csFilter);
598
599     return S_OK;
600 }
601
602 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
603 {
604     VideoRendererImpl *This = (VideoRendererImpl *)iface;
605
606     TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
607
608     EnterCriticalSection(&This->csFilter);
609     {
610         This->rtStreamStart = tStart;
611         This->state = State_Running;
612     }
613     LeaveCriticalSection(&This->csFilter);
614
615     return S_OK;
616 }
617
618 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
619 {
620     VideoRendererImpl *This = (VideoRendererImpl *)iface;
621
622     TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
623
624     EnterCriticalSection(&This->csFilter);
625     {
626         *pState = This->state;
627     }
628     LeaveCriticalSection(&This->csFilter);
629
630     return S_OK;
631 }
632
633 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
634 {
635     VideoRendererImpl *This = (VideoRendererImpl *)iface;
636
637     TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
638
639     EnterCriticalSection(&This->csFilter);
640     {
641         if (This->pClock)
642             IReferenceClock_Release(This->pClock);
643         This->pClock = pClock;
644         if (This->pClock)
645             IReferenceClock_AddRef(This->pClock);
646     }
647     LeaveCriticalSection(&This->csFilter);
648
649     return S_OK;
650 }
651
652 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
653 {
654     VideoRendererImpl *This = (VideoRendererImpl *)iface;
655
656     TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
657
658     EnterCriticalSection(&This->csFilter);
659     {
660         *ppClock = This->pClock;
661         IReferenceClock_AddRef(This->pClock);
662     }
663     LeaveCriticalSection(&This->csFilter);
664     
665     return S_OK;
666 }
667
668 /** IBaseFilter implementation **/
669
670 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
671 {
672     ENUMPINDETAILS epd;
673     VideoRendererImpl *This = (VideoRendererImpl *)iface;
674
675     TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
676
677     epd.cPins = 1; /* input pin */
678     epd.ppPins = This->ppPins;
679     return IEnumPinsImpl_Construct(&epd, ppEnum);
680 }
681
682 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
683 {
684     VideoRendererImpl *This = (VideoRendererImpl *)iface;
685
686     TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
687
688     FIXME("VideoRenderer::FindPin(...)\n");
689
690     /* FIXME: critical section */
691
692     return E_NOTIMPL;
693 }
694
695 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
696 {
697     VideoRendererImpl *This = (VideoRendererImpl *)iface;
698
699     TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
700
701     strcpyW(pInfo->achName, This->filterInfo.achName);
702     pInfo->pGraph = This->filterInfo.pGraph;
703
704     if (pInfo->pGraph)
705         IFilterGraph_AddRef(pInfo->pGraph);
706     
707     return S_OK;
708 }
709
710 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
711 {
712     VideoRendererImpl *This = (VideoRendererImpl *)iface;
713
714     TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
715
716     EnterCriticalSection(&This->csFilter);
717     {
718         if (pName)
719             strcpyW(This->filterInfo.achName, pName);
720         else
721             *This->filterInfo.achName = '\0';
722         This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
723     }
724     LeaveCriticalSection(&This->csFilter);
725
726     return S_OK;
727 }
728
729 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
730 {
731     VideoRendererImpl *This = (VideoRendererImpl *)iface;
732     TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
733     return E_NOTIMPL;
734 }
735
736 static const IBaseFilterVtbl VideoRenderer_Vtbl =
737 {
738     VideoRenderer_QueryInterface,
739     VideoRenderer_AddRef,
740     VideoRenderer_Release,
741     VideoRenderer_GetClassID,
742     VideoRenderer_Stop,
743     VideoRenderer_Pause,
744     VideoRenderer_Run,
745     VideoRenderer_GetState,
746     VideoRenderer_SetSyncSource,
747     VideoRenderer_GetSyncSource,
748     VideoRenderer_EnumPins,
749     VideoRenderer_FindPin,
750     VideoRenderer_QueryFilterInfo,
751     VideoRenderer_JoinFilterGraph,
752     VideoRenderer_QueryVendorInfo
753 };
754
755 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
756 {
757     InputPin* This = (InputPin*)iface;
758     IMediaEventSink* pEventSink;
759     HRESULT hr;
760
761     TRACE("(%p/%p)->()\n", This, iface);
762
763     hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
764     if (SUCCEEDED(hr))
765     {
766         hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
767         IMediaEventSink_Release(pEventSink);
768     }
769
770     return hr;
771 }
772
773 static const IPinVtbl VideoRenderer_InputPin_Vtbl = 
774 {
775     InputPin_QueryInterface,
776     IPinImpl_AddRef,
777     InputPin_Release,
778     InputPin_Connect,
779     InputPin_ReceiveConnection,
780     IPinImpl_Disconnect,
781     IPinImpl_ConnectedTo,
782     IPinImpl_ConnectionMediaType,
783     IPinImpl_QueryPinInfo,
784     IPinImpl_QueryDirection,
785     IPinImpl_QueryId,
786     IPinImpl_QueryAccept,
787     IPinImpl_EnumMediaTypes,
788     IPinImpl_QueryInternalConnections,
789     VideoRenderer_InputPin_EndOfStream,
790     InputPin_BeginFlush,
791     InputPin_EndFlush,
792     InputPin_NewSegment
793 };
794
795 /*** IUnknown methods ***/
796 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
797                                                 REFIID riid,
798                                                 LPVOID*ppvObj) {
799     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
800
801     TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
802
803     return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
804 }
805
806 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
807     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
808
809     TRACE("(%p/%p)->()\n", This, iface);
810
811     return VideoRenderer_AddRef((IBaseFilter*)This);
812 }
813
814 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
815     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
816
817     TRACE("(%p/%p)->()\n", This, iface);
818
819     return VideoRenderer_Release((IBaseFilter*)This);
820 }
821
822 /*** IDispatch methods ***/
823 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
824                                                   UINT*pctinfo) {
825     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
826
827     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
828
829     return S_OK;
830 }
831
832 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
833                                              UINT iTInfo,
834                                              LCID lcid,
835                                              ITypeInfo**ppTInfo) {
836     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
837
838     FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
839
840     return S_OK;
841 }
842
843 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
844                                                REFIID riid,
845                                                LPOLESTR*rgszNames,
846                                                UINT cNames,
847                                                LCID lcid,
848                                                DISPID*rgDispId) {
849     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
850
851     FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
852
853     return S_OK;
854 }
855
856 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
857                                         DISPID dispIdMember,
858                                         REFIID riid,
859                                         LCID lcid,
860                                         WORD wFlags,
861                                         DISPPARAMS*pDispParams,
862                                         VARIANT*pVarResult,
863                                         EXCEPINFO*pExepInfo,
864                                         UINT*puArgErr) {
865     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
866
867     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);
868
869     return S_OK;
870 }
871
872 /*** IBasicVideo methods ***/
873 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
874                                                      REFTIME *pAvgTimePerFrame) {
875     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
876
877     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
878
879     return S_OK;
880 }
881
882 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
883                                              long *pBitRate) {
884     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
885
886     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
887
888     return S_OK;
889 }
890
891 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
892                                                   long *pBitErrorRate) {
893     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
894
895     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
896
897     return S_OK;
898 }
899
900 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
901                                                 long *pVideoWidth) {
902     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
903
904     TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
905
906     *pVideoWidth = This->VideoWidth;
907
908     return S_OK;
909 }
910
911 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
912                                                  long *pVideoHeight) {
913     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
914
915     TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
916
917     *pVideoHeight = This->VideoHeight;
918
919     return S_OK;
920 }
921
922 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
923                                                 long SourceLeft) {
924     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
925
926     TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
927
928     This->SourceRect.left = SourceLeft;
929
930     return S_OK;
931 }
932
933 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
934                                                 long *pSourceLeft) {
935     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
936
937     TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
938
939     *pSourceLeft = This->SourceRect.left;
940
941     return S_OK;
942 }
943
944 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
945                                                  long SourceWidth) {
946     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
947
948     TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
949
950     This->SourceRect.right = This->SourceRect.left + SourceWidth;
951
952     return S_OK;
953 }
954
955 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
956                                                  long *pSourceWidth) {
957     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
958
959     TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
960
961     *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
962     
963     return S_OK;
964 }
965
966 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
967                                                long SourceTop) {
968     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
969
970     TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
971
972     This->SourceRect.top = SourceTop;
973
974     return S_OK;
975 }
976
977 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
978                                                long *pSourceTop) {
979     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
980
981     TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
982
983     *pSourceTop = This->SourceRect.top;
984
985     return S_OK;
986 }
987
988 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
989                                                   long SourceHeight) {
990     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
991
992     TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
993
994     This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
995
996     return S_OK;
997 }
998
999 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
1000                                                   long *pSourceHeight) {
1001     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1002
1003     TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1004
1005     *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
1006
1007     return S_OK;
1008 }
1009
1010 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1011                                                      long DestinationLeft) {
1012     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1013
1014     TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1015
1016     This->DestRect.left = DestinationLeft;
1017
1018     return S_OK;
1019 }
1020
1021 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1022                                                      long *pDestinationLeft) {
1023     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1024
1025     TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1026
1027     *pDestinationLeft = This->DestRect.left;
1028
1029     return S_OK;
1030 }
1031
1032 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1033                                                       long DestinationWidth) {
1034     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1035
1036     TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1037
1038     This->DestRect.right = This->DestRect.left + DestinationWidth;
1039
1040     return S_OK;
1041 }
1042
1043 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1044                                                       long *pDestinationWidth) {
1045     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1046
1047     TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1048
1049     *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1050
1051     return S_OK;
1052 }
1053
1054 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1055                                                     long DestinationTop) {
1056     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1057
1058     TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1059
1060     This->DestRect.top = DestinationTop;
1061     
1062     return S_OK;
1063 }
1064
1065 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1066                                                     long *pDestinationTop) {
1067     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1068
1069     TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1070
1071     *pDestinationTop = This->DestRect.top;
1072
1073     return S_OK;
1074 }
1075
1076 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1077                                                        long DestinationHeight) {
1078     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1079
1080     TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1081
1082     This->DestRect.right = This->DestRect.left + DestinationHeight;
1083
1084     return S_OK;
1085 }
1086
1087 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1088                                                        long *pDestinationHeight) {
1089     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1090
1091     TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1092
1093     *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1094
1095     return S_OK;
1096 }
1097
1098 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1099                                                    long Left,
1100                                                    long Top,
1101                                                    long Width,
1102                                                    long Height) {
1103     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1104
1105     TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1106
1107     This->SourceRect.left = Left;
1108     This->SourceRect.top = Top;
1109     This->SourceRect.right = Left + Width;
1110     This->SourceRect.bottom = Top + Height;
1111     
1112     return S_OK;
1113 }
1114
1115 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1116                                                    long *pLeft,
1117                                                    long *pTop,
1118                                                    long *pWidth,
1119                                                    long *pHeight) {
1120     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1121
1122     TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1123
1124     *pLeft = This->SourceRect.left;
1125     *pTop = This->SourceRect.top;
1126     *pWidth = This->SourceRect.right - This->SourceRect.left;
1127     *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1128     
1129     return S_OK;
1130 }
1131
1132 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1133     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1134
1135     TRACE("(%p/%p)->()\n", This, iface);
1136
1137     This->SourceRect.left = 0;
1138     This->SourceRect.top = 0;
1139     This->SourceRect.right = This->VideoWidth;
1140     This->SourceRect.bottom = This->VideoHeight;
1141
1142     return S_OK;
1143 }
1144
1145 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1146                                                         long Left,
1147                                                         long Top,
1148                                                         long Width,
1149                                                         long Height) {
1150     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1151
1152     TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1153
1154     This->DestRect.left = Left;
1155     This->DestRect.top = Top;
1156     This->DestRect.right = Left + Width;
1157     This->DestRect.bottom = Top + Height;
1158
1159     return S_OK;
1160 }
1161
1162 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1163                                                         long *pLeft,
1164                                                         long *pTop,
1165                                                         long *pWidth,
1166                                                         long *pHeight) {
1167     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1168
1169     TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1170
1171     *pLeft = This->DestRect.left;
1172     *pTop = This->DestRect.top;
1173     *pWidth = This->DestRect.right - This->DestRect.left;
1174     *pHeight = This->DestRect.bottom - This->DestRect.top;
1175
1176     return S_OK;
1177 }
1178
1179 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1180     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1181     RECT rect;
1182
1183     TRACE("(%p/%p)->()\n", This, iface);
1184
1185     if (!GetClientRect(This->hWnd, &rect))
1186         return E_FAIL;
1187     
1188     This->SourceRect.left = 0;
1189     This->SourceRect.top = 0;
1190     This->SourceRect.right = rect.right;
1191     This->SourceRect.bottom = rect.bottom;
1192     
1193     return S_OK;
1194 }
1195
1196 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1197                                               long *pWidth,
1198                                               long *pHeight) {
1199     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1200
1201     TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1202
1203     *pWidth = This->VideoWidth;
1204     *pHeight = This->VideoHeight;
1205     
1206     return S_OK;
1207 }
1208
1209 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1210                                                         long StartIndex,
1211                                                         long Entries,
1212                                                         long *pRetrieved,
1213                                                         long *pPalette) {
1214     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1215
1216     FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1217
1218     return S_OK;
1219 }
1220
1221 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1222                                                  long *pBufferSize,
1223                                                  long *pDIBImage) {
1224     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1225
1226     FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
1227
1228     return S_OK;
1229 }
1230
1231 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1232     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1233
1234     FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1235
1236     return S_OK;
1237 }
1238
1239 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1240     ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1241
1242     FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1243
1244     return S_OK;
1245 }
1246
1247
1248 static const IBasicVideoVtbl IBasicVideo_VTable =
1249 {
1250     Basicvideo_QueryInterface,
1251     Basicvideo_AddRef,
1252     Basicvideo_Release,
1253     Basicvideo_GetTypeInfoCount,
1254     Basicvideo_GetTypeInfo,
1255     Basicvideo_GetIDsOfNames,
1256     Basicvideo_Invoke,
1257     Basicvideo_get_AvgTimePerFrame,
1258     Basicvideo_get_BitRate,
1259     Basicvideo_get_BitErrorRate,
1260     Basicvideo_get_VideoWidth,
1261     Basicvideo_get_VideoHeight,
1262     Basicvideo_put_SourceLeft,
1263     Basicvideo_get_SourceLeft,
1264     Basicvideo_put_SourceWidth,
1265     Basicvideo_get_SourceWidth,
1266     Basicvideo_put_SourceTop,
1267     Basicvideo_get_SourceTop,
1268     Basicvideo_put_SourceHeight,
1269     Basicvideo_get_SourceHeight,
1270     Basicvideo_put_DestinationLeft,
1271     Basicvideo_get_DestinationLeft,
1272     Basicvideo_put_DestinationWidth,
1273     Basicvideo_get_DestinationWidth,
1274     Basicvideo_put_DestinationTop,
1275     Basicvideo_get_DestinationTop,
1276     Basicvideo_put_DestinationHeight,
1277     Basicvideo_get_DestinationHeight,
1278     Basicvideo_SetSourcePosition,
1279     Basicvideo_GetSourcePosition,
1280     Basicvideo_SetDefaultSourcePosition,
1281     Basicvideo_SetDestinationPosition,
1282     Basicvideo_GetDestinationPosition,
1283     Basicvideo_SetDefaultDestinationPosition,
1284     Basicvideo_GetVideoSize,
1285     Basicvideo_GetVideoPaletteEntries,
1286     Basicvideo_GetCurrentImage,
1287     Basicvideo_IsUsingDefaultSource,
1288     Basicvideo_IsUsingDefaultDestination
1289 };
1290
1291
1292 /*** IUnknown methods ***/
1293 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1294                                                  REFIID riid,
1295                                                  LPVOID*ppvObj) {
1296     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1297
1298     TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1299
1300     return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1301 }
1302
1303 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1304     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1305
1306     TRACE("(%p/%p)->()\n", This, iface);
1307
1308     return VideoRenderer_AddRef((IBaseFilter*)This);
1309 }
1310
1311 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1312     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1313
1314     TRACE("(%p/%p)->()\n", This, iface);
1315
1316     return VideoRenderer_Release((IBaseFilter*)This);
1317 }
1318
1319 /*** IDispatch methods ***/
1320 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1321                                                    UINT*pctinfo) {
1322     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1323
1324     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1325
1326     return S_OK;
1327 }
1328
1329 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1330                                               UINT iTInfo,
1331                                               LCID lcid,
1332                                               ITypeInfo**ppTInfo) {
1333     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1334
1335     FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1336
1337     return S_OK;
1338 }
1339
1340 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1341                                                 REFIID riid,
1342                                                 LPOLESTR*rgszNames,
1343                                                 UINT cNames,
1344                                                 LCID lcid,
1345                                                 DISPID*rgDispId) {
1346     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1347
1348     FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1349
1350     return S_OK;
1351 }
1352
1353 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1354                                          DISPID dispIdMember,
1355                                          REFIID riid,
1356                                          LCID lcid,
1357                                          WORD wFlags,
1358                                          DISPPARAMS*pDispParams,
1359                                          VARIANT*pVarResult,
1360                                          EXCEPINFO*pExepInfo,
1361                                          UINT*puArgErr) {
1362     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1363
1364     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);
1365
1366     return S_OK;
1367 }
1368
1369 /*** IVideoWindow methods ***/
1370 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1371                                               BSTR strCaption) {
1372     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1373
1374     TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1375
1376     if (!SetWindowTextW(This->hWnd, strCaption))
1377         return E_FAIL;
1378
1379     return S_OK;
1380 }
1381
1382 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1383                                               BSTR *strCaption) {
1384     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1385
1386     TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1387
1388     GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1389
1390     return S_OK;
1391 }
1392
1393 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1394                                                   long WindowStyle) {
1395     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1396     LONG old;
1397
1398     old = GetWindowLongA(This->hWnd, GWL_STYLE);
1399     
1400     TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
1401
1402     if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1403         return E_INVALIDARG;
1404     
1405     SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1406
1407     return S_OK;
1408 }
1409
1410 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1411                                                   long *WindowStyle) {
1412     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1413
1414     TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1415
1416     *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1417
1418     return S_OK;
1419 }
1420
1421 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1422                                                     long WindowStyleEx) {
1423     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1424
1425     TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1426
1427     if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1428         return E_INVALIDARG;
1429
1430     if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1431         return E_FAIL;
1432
1433     return S_OK;
1434 }
1435
1436 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1437                                                     long *WindowStyleEx) {
1438     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1439
1440     TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1441
1442     *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1443
1444     return S_OK;
1445 }
1446
1447 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1448                                                long AutoShow) {
1449     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1450
1451     TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1452
1453     This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1454
1455     return S_OK;
1456 }
1457
1458 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1459                                                long *AutoShow) {
1460     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1461
1462     TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1463
1464     *AutoShow = This->AutoShow;
1465
1466     return S_OK;
1467 }
1468
1469 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1470                                                   long WindowState) {
1471     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1472
1473     FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1474
1475     return S_OK;
1476 }
1477
1478 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1479                                                   long *WindowState) {
1480     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1481
1482     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1483
1484     return S_OK;
1485 }
1486
1487 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1488                                                         long BackgroundPalette) {
1489     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1490
1491     FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1492
1493     return S_OK;
1494 }
1495
1496 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1497                                                         long *pBackgroundPalette) {
1498     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1499
1500     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1501
1502     return S_OK;
1503 }
1504
1505 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1506                                               long Visible) {
1507     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1508
1509     TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1510
1511     ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1512
1513     return S_OK;
1514 }
1515
1516 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1517                                               long *pVisible) {
1518     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1519
1520     TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1521
1522     *pVisible = IsWindowVisible(This->hWnd);
1523
1524     return S_OK;
1525 }
1526
1527 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1528                                            long Left) {
1529     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1530
1531     TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1532
1533     if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1534         return E_FAIL;
1535
1536     This->WindowPos.left = Left;
1537
1538     return S_OK;
1539 }
1540
1541 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1542                                            long *pLeft) {
1543     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1544
1545     TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1546
1547     *pLeft = This->WindowPos.left;
1548
1549     return S_OK;
1550 }
1551
1552 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1553                                             long Width) {
1554     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1555
1556     TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1557
1558     if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1559         return E_FAIL;
1560
1561     This->WindowPos.right = This->WindowPos.left + Width;
1562
1563     return S_OK;
1564 }
1565
1566 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1567                                             long *pWidth) {
1568     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1569
1570     TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1571
1572     *pWidth = This->WindowPos.right - This->WindowPos.left;
1573
1574     return S_OK;
1575 }
1576
1577 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1578                                           long Top) {
1579     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1580
1581     TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1582
1583     if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1584         return E_FAIL;
1585
1586     This->WindowPos.top = Top;
1587
1588     return S_OK;
1589 }
1590
1591 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1592                                           long *pTop) {
1593     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1594
1595     TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1596
1597     *pTop = This->WindowPos.top;
1598
1599     return S_OK;
1600 }
1601
1602 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1603                                              long Height) {
1604     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1605
1606     TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1607
1608     if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1609         return E_FAIL;
1610
1611     This->WindowPos.bottom = This->WindowPos.top + Height;
1612
1613     return S_OK;
1614 }
1615
1616 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1617                                              long *pHeight) {
1618     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1619
1620     TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1621
1622     *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1623
1624     return S_OK;
1625 }
1626
1627 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1628                                             OAHWND Owner) {
1629     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1630
1631     TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1632
1633     SetParent(This->hWnd, (HWND)Owner);
1634
1635     return S_OK;
1636 }
1637
1638 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1639                                             OAHWND *Owner) {
1640     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1641
1642     TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1643
1644     *(HWND*)Owner = GetParent(This->hWnd);
1645
1646     return S_OK;
1647 }
1648
1649 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1650                                                    OAHWND Drain) {
1651     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1652
1653     TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
1654
1655     This->hWndMsgDrain = (HWND)Drain;
1656
1657     return S_OK;
1658 }
1659
1660 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1661                                                    OAHWND *Drain) {
1662     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1663
1664     TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1665
1666     *Drain = (OAHWND)This->hWndMsgDrain;
1667
1668     return S_OK;
1669 }
1670
1671 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1672                                                   long *Color) {
1673     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1674
1675     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1676
1677     return S_OK;
1678 }
1679
1680 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1681                                                   long Color) {
1682     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1683
1684     FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1685
1686     return S_OK;
1687 }
1688
1689 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1690                                                      long *FullScreenMode) {
1691     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1692
1693     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1694
1695     return S_OK;
1696 }
1697
1698 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1699                                                      long FullScreenMode) {
1700     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1701
1702     FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1703
1704     return S_OK;
1705 }
1706
1707 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1708                                                       long Focus) {
1709     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1710     BOOL ret;
1711     IPin* pPin;
1712     HRESULT hr;
1713
1714     TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1715
1716     if ((Focus != FALSE) && (Focus != TRUE))
1717         return E_INVALIDARG;
1718
1719     hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1720     if ((hr != S_OK) || !pPin)
1721         return VFW_E_NOT_CONNECTED;
1722
1723     if (Focus)
1724         ret = SetForegroundWindow(This->hWnd);
1725     else
1726         ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1727
1728     if (!ret)
1729         return E_FAIL;
1730
1731     return S_OK;
1732 }
1733
1734 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1735                                                      OAHWND hwnd,
1736                                                      long uMsg,
1737                                                      LONG_PTR wParam,
1738                                                      LONG_PTR lParam) {
1739     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1740
1741     TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
1742
1743     if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1744         return E_FAIL;
1745     
1746     return S_OK;
1747 }
1748
1749 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1750                                                     long Left,
1751                                                     long Top,
1752                                                     long Width,
1753                                                     long Height) {
1754     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1755     
1756     TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1757
1758     if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1759         return E_FAIL;
1760
1761     This->WindowPos.left = Left;
1762     This->WindowPos.top = Top;
1763     This->WindowPos.right = Left + Width;
1764     This->WindowPos.bottom = Top + Height;
1765     
1766     return S_OK;
1767 }
1768
1769 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1770                                                     long *pLeft,
1771                                                     long *pTop,
1772                                                     long *pWidth,
1773                                                     long *pHeight) {
1774     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1775
1776     TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1777
1778     *pLeft = This->WindowPos.left;
1779     *pTop = This->WindowPos.top;
1780     *pWidth = This->WindowPos.right - This->WindowPos.left;
1781     *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1782
1783     return S_OK;
1784 }
1785
1786 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1787                                                        long *pWidth,
1788                                                        long *pHeight) {
1789     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1790
1791     FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1792
1793     *pWidth = This->VideoWidth;
1794     *pHeight = This->VideoHeight;
1795
1796     return S_OK;
1797 }
1798
1799 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1800                                                        long *pWidth,
1801                                                        long *pHeight) {
1802     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1803
1804     FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1805
1806     *pWidth = This->VideoWidth;
1807     *pHeight = This->VideoHeight;
1808
1809     return S_OK;
1810 }
1811
1812 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1813                                                      long *pLeft,
1814                                                      long *pTop,
1815                                                      long *pWidth,
1816                                                      long *pHeight) {
1817     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1818
1819     FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
1820
1821     return S_OK;
1822 }
1823
1824 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1825                                              long HideCursor) {
1826     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1827
1828     FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
1829
1830     return S_OK;
1831 }
1832
1833 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1834                                                  long *CursorHidden) {
1835     ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1836
1837     FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
1838
1839     return S_OK;
1840 }
1841
1842 static const IVideoWindowVtbl IVideoWindow_VTable =
1843 {
1844     Videowindow_QueryInterface,
1845     Videowindow_AddRef,
1846     Videowindow_Release,
1847     Videowindow_GetTypeInfoCount,
1848     Videowindow_GetTypeInfo,
1849     Videowindow_GetIDsOfNames,
1850     Videowindow_Invoke,
1851     Videowindow_put_Caption,
1852     Videowindow_get_Caption,
1853     Videowindow_put_WindowStyle,
1854     Videowindow_get_WindowStyle,
1855     Videowindow_put_WindowStyleEx,
1856     Videowindow_get_WindowStyleEx,
1857     Videowindow_put_AutoShow,
1858     Videowindow_get_AutoShow,
1859     Videowindow_put_WindowState,
1860     Videowindow_get_WindowState,
1861     Videowindow_put_BackgroundPalette,
1862     Videowindow_get_BackgroundPalette,
1863     Videowindow_put_Visible,
1864     Videowindow_get_Visible,
1865     Videowindow_put_Left,
1866     Videowindow_get_Left,
1867     Videowindow_put_Width,
1868     Videowindow_get_Width,
1869     Videowindow_put_Top,
1870     Videowindow_get_Top,
1871     Videowindow_put_Height,
1872     Videowindow_get_Height,
1873     Videowindow_put_Owner,
1874     Videowindow_get_Owner,
1875     Videowindow_put_MessageDrain,
1876     Videowindow_get_MessageDrain,
1877     Videowindow_get_BorderColor,
1878     Videowindow_put_BorderColor,
1879     Videowindow_get_FullScreenMode,
1880     Videowindow_put_FullScreenMode,
1881     Videowindow_SetWindowForeground,
1882     Videowindow_NotifyOwnerMessage,
1883     Videowindow_SetWindowPosition,
1884     Videowindow_GetWindowPosition,
1885     Videowindow_GetMinIdealImageSize,
1886     Videowindow_GetMaxIdealImageSize,
1887     Videowindow_GetRestorePosition,
1888     Videowindow_HideCursor,
1889     Videowindow_IsCursorHidden
1890 };