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