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