Implement ResetDC and PHYSICALOFFSET[X|Y] devcaps.
[wine] / dlls / quartz / vidren.c
1 /*
2  * Implements CLSID_VideoRenderer.
3  *
4  * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  * FIXME - use clock
21  */
22
23 #include "config.h"
24
25 #include <stdlib.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winerror.h"
31 #include "mmsystem.h"
32 #include "strmif.h"
33 #include "control.h"
34 #include "vfwmsgs.h"
35 #include "uuids.h"
36 #include "amvideo.h"
37 #include "evcode.h"
38
39 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
41
42 #include "quartz_private.h"
43 #include "vidren.h"
44 #include "seekpass.h"
45
46
47 static const WCHAR QUARTZ_VideoRenderer_Name[] =
48 { 'V','i','d','e','o',' ','R','e','n','d','e','r','e','r',0 };
49 static const WCHAR QUARTZ_VideoRendererPin_Name[] =
50 { 'I','n',0 };
51
52 #define VIDRENMSG_UPDATE        (WM_APP+0)
53 #define VIDRENMSG_ENDTHREAD     (WM_APP+1)
54
55 static const CHAR VIDREN_szWndClass[] = "Wine_VideoRenderer";
56 static const CHAR VIDREN_szWndName[] = "Wine Video Renderer";
57
58
59
60
61 static void VIDREN_OnPaint( CVideoRendererImpl* This, HWND hwnd )
62 {
63         PAINTSTRUCT ps;
64         const VIDEOINFOHEADER* pinfo;
65         const AM_MEDIA_TYPE* pmt;
66
67         TRACE("(%p,%08x)\n",This,hwnd);
68
69         if ( !BeginPaint( hwnd, &ps ) )
70                 return;
71
72         pmt = This->pPin->pin.pmtConn;
73         if ( (!This->m_bSampleIsValid) || pmt == NULL )
74                 goto err;
75
76         pinfo = (const VIDEOINFOHEADER*)pmt->pbFormat;
77
78         StretchDIBits(
79                 ps.hdc,
80                 0, 0,
81                 abs(pinfo->bmiHeader.biWidth), abs(pinfo->bmiHeader.biHeight),
82                 0, 0,
83                 abs(pinfo->bmiHeader.biWidth), abs(pinfo->bmiHeader.biHeight),
84                 This->m_pSampleData, (BITMAPINFO*)(&pinfo->bmiHeader),
85                 DIB_RGB_COLORS, SRCCOPY );
86
87 err:
88         EndPaint( hwnd, &ps );
89 }
90
91 static void VIDREN_OnQueryNewPalette( CVideoRendererImpl* This, HWND hwnd )
92 {
93         FIXME("(%p,%08x)\n",This,hwnd);
94 }
95
96 static void VIDREN_OnUpdate( CVideoRendererImpl* This, HWND hwnd )
97 {
98         MSG     msg;
99
100         TRACE("(%p,%08x)\n",This,hwnd);
101
102         InvalidateRect(hwnd,NULL,FALSE);
103         UpdateWindow(hwnd);
104
105         /* FIXME */
106         while ( PeekMessageA(&msg,hwnd,
107                 VIDRENMSG_UPDATE,VIDRENMSG_UPDATE,
108                 PM_REMOVE) != FALSE )
109         {
110                 /* discard this message. */
111         }
112 }
113
114
115 static LRESULT CALLBACK
116 VIDREN_WndProc(
117         HWND hwnd, UINT message,
118         WPARAM wParam, LPARAM lParam )
119 {
120         CVideoRendererImpl*     This = (CVideoRendererImpl*)
121                 GetWindowLongA( hwnd, 0L );
122
123         TRACE("(%p) - %u/%u/%ld\n",This,message,wParam,lParam);
124
125         if ( message == WM_NCCREATE )
126         {
127                 This = (CVideoRendererImpl*)(((CREATESTRUCTA*)lParam)->lpCreateParams);
128                 SetWindowLongA( hwnd, 0L, (LONG)This );
129                 This->m_hwnd = hwnd;
130         }
131
132         if ( message == WM_NCDESTROY )
133         {
134                 PostQuitMessage(0);
135                 This->m_hwnd = (HWND)NULL;
136                 SetWindowLongA( hwnd, 0L, (LONG)NULL );
137                 This = NULL;
138         }
139
140         if ( This != NULL )
141         {
142                 switch ( message )
143                 {
144                 case WM_PAINT:
145                         TRACE("WM_PAINT begin\n");
146                         EnterCriticalSection( &This->m_csReceive );
147                         VIDREN_OnPaint( This, hwnd );
148                         LeaveCriticalSection( &This->m_csReceive );
149                         TRACE("WM_PAINT end\n");
150                         return 0;
151                 case WM_CLOSE:
152                         ShowWindow( hwnd, SW_HIDE );
153                         return 0;
154                 case WM_PALETTECHANGED:
155                         if ( hwnd == (HWND)wParam )
156                                 break;
157                         /* fall through */
158                 case WM_QUERYNEWPALETTE:
159                         VIDREN_OnQueryNewPalette( This, hwnd );
160                         break;
161                 case VIDRENMSG_UPDATE:
162                         VIDREN_OnUpdate( This, hwnd );
163                         return 0;
164                 case VIDRENMSG_ENDTHREAD:
165                         DestroyWindow(hwnd);
166                         return 0;
167                 default:
168                         break;
169                 }
170         }
171
172         return DefWindowProcA( hwnd, message, wParam, lParam );
173 }
174
175 static BOOL VIDREN_Register( HINSTANCE hInst )
176 {
177         WNDCLASSA       wc;
178         ATOM    atom;
179
180         wc.style = 0;
181         wc.lpfnWndProc = VIDREN_WndProc;
182         wc.cbClsExtra = 0;
183         wc.cbWndExtra = sizeof(LONG);
184         wc.hInstance = hInst;
185         wc.hIcon = LoadIconA((HINSTANCE)NULL,IDI_WINLOGOA);
186         wc.hCursor = LoadCursorA((HINSTANCE)NULL,IDC_ARROWA);
187         wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
188         wc.lpszMenuName = NULL;
189         wc.lpszClassName = VIDREN_szWndClass;
190
191         atom = RegisterClassA( &wc );
192         if ( atom != (ATOM)0 )
193                 return TRUE;
194
195         /* FIXME */
196         return FALSE;
197 }
198
199 static HWND VIDREN_Create( HWND hwndOwner, CVideoRendererImpl* This )
200 {
201         HINSTANCE hInst = (HINSTANCE)GetModuleHandleA(NULL);
202         const VIDEOINFOHEADER* pinfo;
203         DWORD   dwExStyle = 0;
204         DWORD   dwStyle = WS_POPUP|WS_CAPTION|WS_CLIPCHILDREN;
205         RECT    rcWnd;
206         HWND    hwnd;
207
208         if ( !VIDREN_Register( hInst ) )
209                 return (HWND)NULL;
210
211         pinfo = (const VIDEOINFOHEADER*)This->pPin->pin.pmtConn->pbFormat;
212
213         TRACE("width %ld, height %ld\n", pinfo->bmiHeader.biWidth, pinfo->bmiHeader.biHeight);
214
215         rcWnd.left = 0;
216         rcWnd.top = 0;
217         rcWnd.right = pinfo->bmiHeader.biWidth;
218         rcWnd.bottom = abs(pinfo->bmiHeader.biHeight);
219         AdjustWindowRectEx( &rcWnd, dwStyle, FALSE, dwExStyle );
220
221         TRACE("window width %d,height %d\n",
222                 rcWnd.right-rcWnd.left,rcWnd.bottom-rcWnd.top);
223
224         hwnd = CreateWindowExA(
225                 dwExStyle,
226                 VIDREN_szWndClass, VIDREN_szWndName,
227                 dwStyle,
228                 100,100, /* FIXME */
229                 rcWnd.right-rcWnd.left, rcWnd.bottom-rcWnd.top,
230                 hwndOwner, (HMENU)NULL,
231                 hInst, (LPVOID)This );
232         if ( hwnd != (HWND)NULL )
233                 ShowWindow(hwnd,SW_SHOW);
234
235         return hwnd;
236 }
237
238 static DWORD WINAPI VIDREN_ThreadEntry( LPVOID pv )
239 {
240         CVideoRendererImpl*     This = (CVideoRendererImpl*)pv;
241         MSG     msg;
242
243         TRACE("(%p)\n",This);
244         if ( !VIDREN_Create( (HWND)NULL, This ) )
245                 return 0;
246         TRACE("VIDREN_Create succeeded\n");
247
248         SetEvent( This->m_hEventInit );
249         TRACE("Enter message loop\n");
250
251         while ( GetMessageA(&msg,(HWND)NULL,0,0) )
252         {
253                 TranslateMessage(&msg);
254                 DispatchMessageA(&msg);
255         }
256
257         return 0;
258 }
259
260 static HRESULT VIDREN_StartThread( CVideoRendererImpl* This )
261 {
262         DWORD dwRes;
263         DWORD dwThreadId;
264         HANDLE  hEvents[2];
265
266         if ( This->m_hEventInit != (HANDLE)NULL ||
267                  This->m_hwnd != (HWND)NULL ||
268                  This->m_hThread != (HANDLE)NULL ||
269                  This->pPin->pin.pmtConn == NULL )
270                 return E_UNEXPECTED;
271
272         This->m_hEventInit = CreateEventA(NULL,TRUE,FALSE,NULL);
273         if ( This->m_hEventInit == (HANDLE)NULL )
274                 return E_OUTOFMEMORY;
275
276         This->m_hThread = CreateThread(
277                 NULL, 0,
278                 VIDREN_ThreadEntry,
279                 (LPVOID)This,
280                 0, &dwThreadId );
281         if ( This->m_hThread == (HANDLE)NULL )
282                 return E_FAIL;
283
284         hEvents[0] = This->m_hEventInit;
285         hEvents[1] = This->m_hThread;
286
287         dwRes = WaitForMultipleObjects(2,hEvents,FALSE,INFINITE);
288         if ( dwRes != WAIT_OBJECT_0 )
289                 return E_FAIL;
290
291         return S_OK;
292 }
293
294 static void VIDREN_EndThread( CVideoRendererImpl* This )
295 {
296         if ( This->m_hwnd != (HWND)NULL )
297                 PostMessageA( This->m_hwnd, VIDRENMSG_ENDTHREAD, 0, 0 );
298
299         if ( This->m_hThread != (HANDLE)NULL )
300         {
301                 WaitForSingleObject( This->m_hThread, INFINITE );
302                 CloseHandle( This->m_hThread );
303                 This->m_hThread = (HANDLE)NULL;
304         }
305         if ( This->m_hEventInit != (HANDLE)NULL )
306         {
307                 CloseHandle( This->m_hEventInit );
308                 This->m_hEventInit = (HANDLE)NULL;
309         }
310 }
311
312
313
314 /***************************************************************************
315  *
316  *      CVideoRendererImpl methods
317  *
318  */
319
320 static HRESULT CVideoRendererImpl_OnActive( CBaseFilterImpl* pImpl )
321 {
322         CVideoRendererImpl_THIS(pImpl,basefilter);
323
324         FIXME( "(%p)\n", This );
325
326         This->m_bSampleIsValid = FALSE;
327
328         return NOERROR;
329 }
330
331 static HRESULT CVideoRendererImpl_OnInactive( CBaseFilterImpl* pImpl )
332 {
333         CVideoRendererImpl_THIS(pImpl,basefilter);
334
335         FIXME( "(%p)\n", This );
336
337         EnterCriticalSection( &This->m_csReceive );
338         This->m_bSampleIsValid = FALSE;
339         LeaveCriticalSection( &This->m_csReceive );
340
341         return NOERROR;
342 }
343
344 static const CBaseFilterHandlers filterhandlers =
345 {
346         CVideoRendererImpl_OnActive, /* pOnActive */
347         CVideoRendererImpl_OnInactive, /* pOnInactive */
348         NULL, /* pOnStop */
349 };
350
351 /***************************************************************************
352  *
353  *      CVideoRendererPinImpl methods
354  *
355  */
356
357 static HRESULT CVideoRendererPinImpl_OnPreConnect( CPinBaseImpl* pImpl, IPin* pPin )
358 {
359         CVideoRendererPinImpl_THIS(pImpl,pin);
360
361         TRACE("(%p,%p)\n",This,pPin);
362
363         return NOERROR;
364 }
365
366 static HRESULT CVideoRendererPinImpl_OnPostConnect( CPinBaseImpl* pImpl, IPin* pPin )
367 {
368         CVideoRendererPinImpl_THIS(pImpl,pin);
369         const VIDEOINFOHEADER* pinfo;
370         HRESULT hr;
371
372         TRACE("(%p,%p)\n",This,pPin);
373
374         if ( This->pRender->m_pSampleData != NULL )
375         {
376                 QUARTZ_FreeMem(This->pRender->m_pSampleData);
377                 This->pRender->m_pSampleData = NULL;
378         }
379         This->pRender->m_cbSampleData = 0;
380         This->pRender->m_bSampleIsValid = FALSE;
381
382         pinfo = (const VIDEOINFOHEADER*)This->pin.pmtConn->pbFormat;
383         if ( pinfo == NULL )
384                 return E_FAIL;
385
386         This->pRender->m_bSampleIsValid = FALSE;
387         This->pRender->m_cbSampleData = DIBSIZE(pinfo->bmiHeader);
388         This->pRender->m_pSampleData = (BYTE*)QUARTZ_AllocMem(This->pRender->m_cbSampleData);
389         if ( This->pRender->m_pSampleData == NULL )
390                 return E_OUTOFMEMORY;
391
392         hr = VIDREN_StartThread(This->pRender);
393         if ( FAILED(hr) )
394                 return hr;
395
396         return NOERROR;
397 }
398
399 static HRESULT CVideoRendererPinImpl_OnDisconnect( CPinBaseImpl* pImpl )
400 {
401         CVideoRendererPinImpl_THIS(pImpl,pin);
402
403         TRACE("(%p)\n",This);
404
405         VIDREN_EndThread(This->pRender);
406
407         if ( This->pRender->m_pSampleData != NULL )
408         {
409                 QUARTZ_FreeMem(This->pRender->m_pSampleData);
410                 This->pRender->m_pSampleData = NULL;
411         }
412         This->pRender->m_cbSampleData = 0;
413         This->pRender->m_bSampleIsValid = FALSE;
414
415         if ( This->meminput.pAllocator != NULL )
416         {
417                 IMemAllocator_Decommit(This->meminput.pAllocator);
418                 IMemAllocator_Release(This->meminput.pAllocator);
419                 This->meminput.pAllocator = NULL;
420         }
421
422         return NOERROR;
423 }
424
425 static HRESULT CVideoRendererPinImpl_CheckMediaType( CPinBaseImpl* pImpl, const AM_MEDIA_TYPE* pmt )
426 {
427         CVideoRendererPinImpl_THIS(pImpl,pin);
428         const VIDEOINFOHEADER* pinfo;
429
430         TRACE("(%p,%p)\n",This,pmt);
431
432         if ( !IsEqualGUID( &pmt->majortype, &MEDIATYPE_Video ) )
433                 return E_FAIL;
434         if ( !IsEqualGUID( &pmt->formattype, &FORMAT_VideoInfo ) )
435                 return E_FAIL;
436         /*
437          * check subtype.
438          */
439         if ( !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB555 ) &&
440              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB565 ) &&
441              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB24 ) &&
442              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB32 ) )
443                 return E_FAIL;
444
445         /****
446          *
447          *
448         if ( !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB8 ) &&
449              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB555 ) &&
450              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB565 ) &&
451              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB24 ) &&
452              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB32 ) )
453                 return E_FAIL;
454          *
455          ****/
456
457         pinfo = (const VIDEOINFOHEADER*)pmt->pbFormat;
458         if ( pinfo == NULL ||
459                  pinfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER) ||
460                  pinfo->bmiHeader.biWidth <= 0 ||
461                  pinfo->bmiHeader.biHeight == 0 ||
462                  pinfo->bmiHeader.biPlanes != 1 ||
463                  pinfo->bmiHeader.biCompression != 0 )
464                 return E_FAIL;
465
466         return NOERROR;
467 }
468
469 static HRESULT CVideoRendererPinImpl_Receive( CPinBaseImpl* pImpl, IMediaSample* pSample )
470 {
471         CVideoRendererPinImpl_THIS(pImpl,pin);
472         HWND hwnd;
473         BYTE*   pData = NULL;
474         LONG    lLength;
475         HRESULT hr;
476
477         TRACE( "(%p,%p)\n",This,pSample );
478
479         hwnd = This->pRender->m_hwnd;
480         if ( hwnd == (HWND)NULL ||
481                  This->pRender->m_hThread == (HWND)NULL )
482                 return E_UNEXPECTED;
483         if ( This->pRender->m_fInFlush )
484                 return S_FALSE;
485         if ( pSample == NULL )
486                 return E_POINTER;
487
488         /* FIXME - wait/skip/qualitycontrol */
489         
490
491         /* duplicate this sample. */
492         hr = IMediaSample_GetPointer(pSample,&pData);
493         if ( FAILED(hr) )
494                 return hr;
495         lLength = (LONG)IMediaSample_GetActualDataLength(pSample);
496         if ( lLength <= 0 || (lLength < (LONG)This->pRender->m_cbSampleData) )
497         {
498                 ERR( "invalid length: %ld\n", lLength );
499                 return NOERROR;
500         }
501
502         memcpy(This->pRender->m_pSampleData,pData,lLength);
503         This->pRender->m_bSampleIsValid = TRUE;
504         PostMessageA( hwnd, VIDRENMSG_UPDATE, 0, 0 );
505
506         return NOERROR;
507 }
508
509 static HRESULT CVideoRendererPinImpl_ReceiveCanBlock( CPinBaseImpl* pImpl )
510 {
511         CVideoRendererPinImpl_THIS(pImpl,pin);
512
513         TRACE( "(%p)\n", This );
514
515         /* might block. */
516         return S_OK;
517 }
518
519 static HRESULT CVideoRendererPinImpl_EndOfStream( CPinBaseImpl* pImpl )
520 {
521         CVideoRendererPinImpl_THIS(pImpl,pin);
522
523         FIXME( "(%p)\n", This );
524
525         This->pRender->m_fInFlush = FALSE;
526
527         /* FIXME - don't notify twice until stopped or seeked. */
528         return CBaseFilterImpl_MediaEventNotify(
529                 &This->pRender->basefilter, EC_COMPLETE,
530                 (LONG_PTR)S_OK, (LONG_PTR)(IBaseFilter*)(This->pRender) );
531 }
532
533 static HRESULT CVideoRendererPinImpl_BeginFlush( CPinBaseImpl* pImpl )
534 {
535         CVideoRendererPinImpl_THIS(pImpl,pin);
536
537         FIXME( "(%p)\n", This );
538
539         This->pRender->m_fInFlush = TRUE;
540         EnterCriticalSection( &This->pRender->m_csReceive );
541         This->pRender->m_bSampleIsValid = FALSE;
542         LeaveCriticalSection( &This->pRender->m_csReceive );
543
544         return NOERROR;
545 }
546
547 static HRESULT CVideoRendererPinImpl_EndFlush( CPinBaseImpl* pImpl )
548 {
549         CVideoRendererPinImpl_THIS(pImpl,pin);
550
551         FIXME( "(%p)\n", This );
552
553         This->pRender->m_fInFlush = FALSE;
554
555         return NOERROR;
556 }
557
558 static HRESULT CVideoRendererPinImpl_NewSegment( CPinBaseImpl* pImpl, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double rate )
559 {
560         CVideoRendererPinImpl_THIS(pImpl,pin);
561
562         FIXME( "(%p)\n", This );
563
564         This->pRender->m_fInFlush = FALSE;
565
566         return NOERROR;
567 }
568
569
570
571
572 static const CBasePinHandlers pinhandlers =
573 {
574         CVideoRendererPinImpl_OnPreConnect, /* pOnPreConnect */
575         CVideoRendererPinImpl_OnPostConnect, /* pOnPostConnect */
576         CVideoRendererPinImpl_OnDisconnect, /* pOnDisconnect */
577         CVideoRendererPinImpl_CheckMediaType, /* pCheckMediaType */
578         NULL, /* pQualityNotify */
579         CVideoRendererPinImpl_Receive, /* pReceive */
580         CVideoRendererPinImpl_ReceiveCanBlock, /* pReceiveCanBlock */
581         CVideoRendererPinImpl_EndOfStream, /* pEndOfStream */
582         CVideoRendererPinImpl_BeginFlush, /* pBeginFlush */
583         CVideoRendererPinImpl_EndFlush, /* pEndFlush */
584         CVideoRendererPinImpl_NewSegment, /* pNewSegment */
585 };
586
587
588 /***************************************************************************
589  *
590  *      new/delete CVideoRendererImpl
591  *
592  */
593
594 /* can I use offsetof safely? - FIXME? */
595 static QUARTZ_IFEntry FilterIFEntries[] =
596 {
597   { &IID_IPersist, offsetof(CVideoRendererImpl,basefilter)-offsetof(CVideoRendererImpl,unk) },
598   { &IID_IMediaFilter, offsetof(CVideoRendererImpl,basefilter)-offsetof(CVideoRendererImpl,unk) },
599   { &IID_IBaseFilter, offsetof(CVideoRendererImpl,basefilter)-offsetof(CVideoRendererImpl,unk) },
600   { &IID_IBasicVideo, offsetof(CVideoRendererImpl,basvid)-offsetof(CVideoRendererImpl,unk) },
601   { &IID_IVideoWindow, offsetof(CVideoRendererImpl,vidwin)-offsetof(CVideoRendererImpl,unk) },
602 };
603
604 static HRESULT CVideoRendererImpl_OnQueryInterface(
605         IUnknown* punk, const IID* piid, void** ppobj )
606 {
607         CVideoRendererImpl_THIS(punk,unk);
608
609         if ( This->pSeekPass == NULL )
610                 return E_NOINTERFACE;
611
612         if ( IsEqualGUID( &IID_IMediaPosition, piid ) ||
613                  IsEqualGUID( &IID_IMediaSeeking, piid ) )
614         {
615                 TRACE( "IMediaSeeking(or IMediaPosition) is queried\n" );
616                 return IUnknown_QueryInterface( (IUnknown*)(&This->pSeekPass->unk), piid, ppobj );
617         }
618
619         return E_NOINTERFACE;
620 }
621
622 static void QUARTZ_DestroyVideoRenderer(IUnknown* punk)
623 {
624         CVideoRendererImpl_THIS(punk,unk);
625
626         TRACE( "(%p)\n", This );
627         CVideoRendererImpl_OnInactive(&This->basefilter);
628         VIDREN_EndThread(This);
629
630         if ( This->pPin != NULL )
631         {
632                 IUnknown_Release(This->pPin->unk.punkControl);
633                 This->pPin = NULL;
634         }
635         if ( This->pSeekPass != NULL )
636         {
637                 IUnknown_Release((IUnknown*)&This->pSeekPass->unk);
638                 This->pSeekPass = NULL;
639         }
640
641         CVideoRendererImpl_UninitIBasicVideo(This);
642         CVideoRendererImpl_UninitIVideoWindow(This);
643         CBaseFilterImpl_UninitIBaseFilter(&This->basefilter);
644
645         DeleteCriticalSection( &This->m_csReceive );
646 }
647
648 HRESULT QUARTZ_CreateVideoRenderer(IUnknown* punkOuter,void** ppobj)
649 {
650         CVideoRendererImpl*     This = NULL;
651         HRESULT hr;
652
653         TRACE("(%p,%p)\n",punkOuter,ppobj);
654
655         This = (CVideoRendererImpl*)
656                 QUARTZ_AllocObj( sizeof(CVideoRendererImpl) );
657         if ( This == NULL )
658                 return E_OUTOFMEMORY;
659         This->pSeekPass = NULL;
660         This->pPin = NULL;
661         This->m_fInFlush = FALSE;
662
663         This->m_hEventInit = (HANDLE)NULL;
664         This->m_hThread = (HANDLE)NULL;
665         This->m_hwnd = (HWND)NULL;
666         This->m_bSampleIsValid = FALSE;
667         This->m_pSampleData = NULL;
668         This->m_cbSampleData = 0;
669
670         QUARTZ_IUnkInit( &This->unk, punkOuter );
671         This->qiext.pNext = NULL;
672         This->qiext.pOnQueryInterface = &CVideoRendererImpl_OnQueryInterface;
673         QUARTZ_IUnkAddDelegation( &This->unk, &This->qiext );
674
675         hr = CBaseFilterImpl_InitIBaseFilter(
676                 &This->basefilter,
677                 This->unk.punkControl,
678                 &CLSID_VideoRenderer,
679                 QUARTZ_VideoRenderer_Name,
680                 &filterhandlers );
681         if ( SUCCEEDED(hr) )
682         {
683                 hr = CVideoRendererImpl_InitIBasicVideo(This);
684                 if ( SUCCEEDED(hr) )
685                 {
686                         hr = CVideoRendererImpl_InitIVideoWindow(This);
687                         if ( FAILED(hr) )
688                         {
689                                 CVideoRendererImpl_UninitIBasicVideo(This);
690                         }
691                 }
692                 if ( FAILED(hr) )
693                 {
694                         CBaseFilterImpl_UninitIBaseFilter(&This->basefilter);
695                 }
696         }
697
698         if ( FAILED(hr) )
699         {
700                 QUARTZ_FreeObj(This);
701                 return hr;
702         }
703
704         This->unk.pEntries = FilterIFEntries;
705         This->unk.dwEntries = sizeof(FilterIFEntries)/sizeof(FilterIFEntries[0]);
706         This->unk.pOnFinalRelease = QUARTZ_DestroyVideoRenderer;
707
708         InitializeCriticalSection( &This->m_csReceive );
709
710         hr = QUARTZ_CreateVideoRendererPin(
711                 This,
712                 &This->basefilter.csFilter,
713                 &This->m_csReceive,
714                 &This->pPin );
715         if ( SUCCEEDED(hr) )
716                 hr = QUARTZ_CompList_AddComp(
717                         This->basefilter.pInPins,
718                         (IUnknown*)&This->pPin->pin,
719                         NULL, 0 );
720         if ( SUCCEEDED(hr) )
721                 hr = QUARTZ_CreateSeekingPassThruInternal(
722                         (IUnknown*)&(This->unk), &This->pSeekPass,
723                         TRUE, (IPin*)&(This->pPin->pin) );
724
725         if ( FAILED(hr) )
726         {
727                 IUnknown_Release( This->unk.punkControl );
728                 return hr;
729         }
730
731         *ppobj = (void*)&(This->unk);
732
733         return S_OK;
734 }
735
736 /***************************************************************************
737  *
738  *      new/delete CVideoRendererPinImpl
739  *
740  */
741
742 /* can I use offsetof safely? - FIXME? */
743 static QUARTZ_IFEntry PinIFEntries[] =
744 {
745   { &IID_IPin, offsetof(CVideoRendererPinImpl,pin)-offsetof(CVideoRendererPinImpl,unk) },
746   { &IID_IMemInputPin, offsetof(CVideoRendererPinImpl,meminput)-offsetof(CVideoRendererPinImpl,unk) },
747 };
748
749 static void QUARTZ_DestroyVideoRendererPin(IUnknown* punk)
750 {
751         CVideoRendererPinImpl_THIS(punk,unk);
752
753         TRACE( "(%p)\n", This );
754
755         CPinBaseImpl_UninitIPin( &This->pin );
756         CMemInputPinBaseImpl_UninitIMemInputPin( &This->meminput );
757 }
758
759 HRESULT QUARTZ_CreateVideoRendererPin(
760         CVideoRendererImpl* pFilter,
761         CRITICAL_SECTION* pcsPin,
762         CRITICAL_SECTION* pcsPinReceive,
763         CVideoRendererPinImpl** ppPin)
764 {
765         CVideoRendererPinImpl*  This = NULL;
766         HRESULT hr;
767
768         TRACE("(%p,%p,%p,%p)\n",pFilter,pcsPin,pcsPinReceive,ppPin);
769
770         This = (CVideoRendererPinImpl*)
771                 QUARTZ_AllocObj( sizeof(CVideoRendererPinImpl) );
772         if ( This == NULL )
773                 return E_OUTOFMEMORY;
774
775         QUARTZ_IUnkInit( &This->unk, NULL );
776         This->pRender = pFilter;
777
778         hr = CPinBaseImpl_InitIPin(
779                 &This->pin,
780                 This->unk.punkControl,
781                 pcsPin, pcsPinReceive,
782                 &pFilter->basefilter,
783                 QUARTZ_VideoRendererPin_Name,
784                 FALSE,
785                 &pinhandlers );
786
787         if ( SUCCEEDED(hr) )
788         {
789                 hr = CMemInputPinBaseImpl_InitIMemInputPin(
790                         &This->meminput,
791                         This->unk.punkControl,
792                         &This->pin );
793                 if ( FAILED(hr) )
794                 {
795                         CPinBaseImpl_UninitIPin( &This->pin );
796                 }
797         }
798
799         if ( FAILED(hr) )
800         {
801                 QUARTZ_FreeObj(This);
802                 return hr;
803         }
804
805         This->unk.pEntries = PinIFEntries;
806         This->unk.dwEntries = sizeof(PinIFEntries)/sizeof(PinIFEntries[0]);
807         This->unk.pOnFinalRelease = QUARTZ_DestroyVideoRendererPin;
808
809         *ppPin = This;
810
811         TRACE("returned successfully.\n");
812
813         return S_OK;
814 }
815
816 /***************************************************************************
817  *
818  *      CVideoRendererImpl::IBasicVideo
819  *
820  */
821
822
823 static HRESULT WINAPI
824 IBasicVideo_fnQueryInterface(IBasicVideo* iface,REFIID riid,void** ppobj)
825 {
826         CVideoRendererImpl_THIS(iface,basvid);
827
828         TRACE("(%p)->()\n",This);
829
830         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
831 }
832
833 static ULONG WINAPI
834 IBasicVideo_fnAddRef(IBasicVideo* iface)
835 {
836         CVideoRendererImpl_THIS(iface,basvid);
837
838         TRACE("(%p)->()\n",This);
839
840         return IUnknown_AddRef(This->unk.punkControl);
841 }
842
843 static ULONG WINAPI
844 IBasicVideo_fnRelease(IBasicVideo* iface)
845 {
846         CVideoRendererImpl_THIS(iface,basvid);
847
848         TRACE("(%p)->()\n",This);
849
850         return IUnknown_Release(This->unk.punkControl);
851 }
852
853 static HRESULT WINAPI
854 IBasicVideo_fnGetTypeInfoCount(IBasicVideo* iface,UINT* pcTypeInfo)
855 {
856         CVideoRendererImpl_THIS(iface,basvid);
857
858         FIXME("(%p)->()\n",This);
859
860         return E_NOTIMPL;
861 }
862
863 static HRESULT WINAPI
864 IBasicVideo_fnGetTypeInfo(IBasicVideo* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
865 {
866         CVideoRendererImpl_THIS(iface,basvid);
867
868         FIXME("(%p)->()\n",This);
869
870         return E_NOTIMPL;
871 }
872
873 static HRESULT WINAPI
874 IBasicVideo_fnGetIDsOfNames(IBasicVideo* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
875 {
876         CVideoRendererImpl_THIS(iface,basvid);
877
878         FIXME("(%p)->()\n",This);
879
880         return E_NOTIMPL;
881 }
882
883 static HRESULT WINAPI
884 IBasicVideo_fnInvoke(IBasicVideo* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
885 {
886         CVideoRendererImpl_THIS(iface,basvid);
887
888         FIXME("(%p)->()\n",This);
889
890         return E_NOTIMPL;
891 }
892
893
894 static HRESULT WINAPI
895 IBasicVideo_fnget_AvgTimePerFrame(IBasicVideo* iface,REFTIME* prefTime)
896 {
897         CVideoRendererImpl_THIS(iface,basvid);
898
899         FIXME("(%p)->()\n",This);
900
901         return E_NOTIMPL;
902 }
903
904 static HRESULT WINAPI
905 IBasicVideo_fnget_BitRate(IBasicVideo* iface,long* plRate)
906 {
907         CVideoRendererImpl_THIS(iface,basvid);
908
909         FIXME("(%p)->()\n",This);
910
911         return E_NOTIMPL;
912 }
913
914 static HRESULT WINAPI
915 IBasicVideo_fnget_BitErrorRate(IBasicVideo* iface,long* plRate)
916 {
917         CVideoRendererImpl_THIS(iface,basvid);
918
919         FIXME("(%p)->()\n",This);
920
921         return E_NOTIMPL;
922 }
923
924 static HRESULT WINAPI
925 IBasicVideo_fnget_VideoWidth(IBasicVideo* iface,long* plWidth)
926 {
927         CVideoRendererImpl_THIS(iface,basvid);
928
929         FIXME("(%p)->()\n",This);
930
931         return E_NOTIMPL;
932 }
933
934 static HRESULT WINAPI
935 IBasicVideo_fnget_VideoHeight(IBasicVideo* iface,long* plHeight)
936 {
937         CVideoRendererImpl_THIS(iface,basvid);
938
939         FIXME("(%p)->()\n",This);
940
941         return E_NOTIMPL;
942 }
943
944 static HRESULT WINAPI
945 IBasicVideo_fnput_SourceLeft(IBasicVideo* iface,long lLeft)
946 {
947         CVideoRendererImpl_THIS(iface,basvid);
948
949         FIXME("(%p)->()\n",This);
950
951         return E_NOTIMPL;
952 }
953
954 static HRESULT WINAPI
955 IBasicVideo_fnget_SourceLeft(IBasicVideo* iface,long* plLeft)
956 {
957         CVideoRendererImpl_THIS(iface,basvid);
958
959         FIXME("(%p)->()\n",This);
960
961         return E_NOTIMPL;
962 }
963
964 static HRESULT WINAPI
965 IBasicVideo_fnput_SourceWidth(IBasicVideo* iface,long lWidth)
966 {
967         CVideoRendererImpl_THIS(iface,basvid);
968
969         FIXME("(%p)->()\n",This);
970
971         return E_NOTIMPL;
972 }
973
974 static HRESULT WINAPI
975 IBasicVideo_fnget_SourceWidth(IBasicVideo* iface,long* plWidth)
976 {
977         CVideoRendererImpl_THIS(iface,basvid);
978
979         FIXME("(%p)->()\n",This);
980
981         return E_NOTIMPL;
982 }
983
984 static HRESULT WINAPI
985 IBasicVideo_fnput_SourceTop(IBasicVideo* iface,long lTop)
986 {
987         CVideoRendererImpl_THIS(iface,basvid);
988
989         FIXME("(%p)->()\n",This);
990
991         return E_NOTIMPL;
992 }
993
994 static HRESULT WINAPI
995 IBasicVideo_fnget_SourceTop(IBasicVideo* iface,long* plTop)
996 {
997         CVideoRendererImpl_THIS(iface,basvid);
998
999         FIXME("(%p)->()\n",This);
1000
1001         return E_NOTIMPL;
1002 }
1003
1004 static HRESULT WINAPI
1005 IBasicVideo_fnput_SourceHeight(IBasicVideo* iface,long lHeight)
1006 {
1007         CVideoRendererImpl_THIS(iface,basvid);
1008
1009         FIXME("(%p)->()\n",This);
1010
1011         return E_NOTIMPL;
1012 }
1013
1014 static HRESULT WINAPI
1015 IBasicVideo_fnget_SourceHeight(IBasicVideo* iface,long* plHeight)
1016 {
1017         CVideoRendererImpl_THIS(iface,basvid);
1018
1019         FIXME("(%p)->()\n",This);
1020
1021         return E_NOTIMPL;
1022 }
1023
1024 static HRESULT WINAPI
1025 IBasicVideo_fnput_DestinationLeft(IBasicVideo* iface,long lLeft)
1026 {
1027         CVideoRendererImpl_THIS(iface,basvid);
1028
1029         FIXME("(%p)->()\n",This);
1030
1031         return E_NOTIMPL;
1032 }
1033
1034 static HRESULT WINAPI
1035 IBasicVideo_fnget_DestinationLeft(IBasicVideo* iface,long* plLeft)
1036 {
1037         CVideoRendererImpl_THIS(iface,basvid);
1038
1039         FIXME("(%p)->()\n",This);
1040
1041         return E_NOTIMPL;
1042 }
1043
1044 static HRESULT WINAPI
1045 IBasicVideo_fnput_DestinationWidth(IBasicVideo* iface,long lWidth)
1046 {
1047         CVideoRendererImpl_THIS(iface,basvid);
1048
1049         FIXME("(%p)->()\n",This);
1050
1051         return E_NOTIMPL;
1052 }
1053
1054 static HRESULT WINAPI
1055 IBasicVideo_fnget_DestinationWidth(IBasicVideo* iface,long* plWidth)
1056 {
1057         CVideoRendererImpl_THIS(iface,basvid);
1058
1059         FIXME("(%p)->()\n",This);
1060
1061         return E_NOTIMPL;
1062 }
1063
1064 static HRESULT WINAPI
1065 IBasicVideo_fnput_DestinationTop(IBasicVideo* iface,long lTop)
1066 {
1067         CVideoRendererImpl_THIS(iface,basvid);
1068
1069         FIXME("(%p)->()\n",This);
1070
1071         return E_NOTIMPL;
1072 }
1073
1074 static HRESULT WINAPI
1075 IBasicVideo_fnget_DestinationTop(IBasicVideo* iface,long* plTop)
1076 {
1077         CVideoRendererImpl_THIS(iface,basvid);
1078
1079         FIXME("(%p)->()\n",This);
1080
1081         return E_NOTIMPL;
1082 }
1083
1084 static HRESULT WINAPI
1085 IBasicVideo_fnput_DestinationHeight(IBasicVideo* iface,long lHeight)
1086 {
1087         CVideoRendererImpl_THIS(iface,basvid);
1088
1089         FIXME("(%p)->()\n",This);
1090
1091         return E_NOTIMPL;
1092 }
1093
1094 static HRESULT WINAPI
1095 IBasicVideo_fnget_DestinationHeight(IBasicVideo* iface,long* plHeight)
1096 {
1097         CVideoRendererImpl_THIS(iface,basvid);
1098
1099         FIXME("(%p)->()\n",This);
1100
1101         return E_NOTIMPL;
1102 }
1103
1104 static HRESULT WINAPI
1105 IBasicVideo_fnSetSourcePosition(IBasicVideo* iface,long lLeft,long lTop,long lWidth,long lHeight)
1106 {
1107         CVideoRendererImpl_THIS(iface,basvid);
1108
1109         FIXME("(%p)->()\n",This);
1110
1111         return E_NOTIMPL;
1112 }
1113
1114 static HRESULT WINAPI
1115 IBasicVideo_fnGetSourcePosition(IBasicVideo* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
1116 {
1117         CVideoRendererImpl_THIS(iface,basvid);
1118
1119         FIXME("(%p)->()\n",This);
1120
1121         return E_NOTIMPL;
1122 }
1123
1124 static HRESULT WINAPI
1125 IBasicVideo_fnSetDefaultSourcePosition(IBasicVideo* iface)
1126 {
1127         CVideoRendererImpl_THIS(iface,basvid);
1128
1129         FIXME("(%p)->()\n",This);
1130
1131         return E_NOTIMPL;
1132 }
1133
1134 static HRESULT WINAPI
1135 IBasicVideo_fnSetDestinationPosition(IBasicVideo* iface,long lLeft,long lTop,long lWidth,long lHeight)
1136 {
1137         CVideoRendererImpl_THIS(iface,basvid);
1138
1139         FIXME("(%p)->()\n",This);
1140
1141         return E_NOTIMPL;
1142 }
1143
1144 static HRESULT WINAPI
1145 IBasicVideo_fnGetDestinationPosition(IBasicVideo* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
1146 {
1147         CVideoRendererImpl_THIS(iface,basvid);
1148
1149         FIXME("(%p)->()\n",This);
1150
1151         return E_NOTIMPL;
1152 }
1153
1154 static HRESULT WINAPI
1155 IBasicVideo_fnSetDefaultDestinationPosition(IBasicVideo* iface)
1156 {
1157         CVideoRendererImpl_THIS(iface,basvid);
1158
1159         FIXME("(%p)->()\n",This);
1160
1161         return E_NOTIMPL;
1162 }
1163
1164 static HRESULT WINAPI
1165 IBasicVideo_fnGetVideoSize(IBasicVideo* iface,long* plWidth,long* plHeight)
1166 {
1167         CVideoRendererImpl_THIS(iface,basvid);
1168
1169         FIXME("(%p)->()\n",This);
1170
1171         return E_NOTIMPL;
1172 }
1173
1174 static HRESULT WINAPI
1175 IBasicVideo_fnGetVideoPaletteEntries(IBasicVideo* iface,long lStart,long lCount,long* plRet,long* plPaletteEntry)
1176 {
1177         CVideoRendererImpl_THIS(iface,basvid);
1178
1179         FIXME("(%p)->()\n",This);
1180
1181         return E_NOTIMPL;
1182 }
1183
1184 static HRESULT WINAPI
1185 IBasicVideo_fnGetCurrentImage(IBasicVideo* iface,long* plBufferSize,long* plDIBBuffer)
1186 {
1187         CVideoRendererImpl_THIS(iface,basvid);
1188
1189         FIXME("(%p)->()\n",This);
1190
1191         return E_NOTIMPL;
1192 }
1193
1194 static HRESULT WINAPI
1195 IBasicVideo_fnIsUsingDefaultSource(IBasicVideo* iface)
1196 {
1197         CVideoRendererImpl_THIS(iface,basvid);
1198
1199         FIXME("(%p)->()\n",This);
1200
1201         return E_NOTIMPL;
1202 }
1203
1204 static HRESULT WINAPI
1205 IBasicVideo_fnIsUsingDefaultDestination(IBasicVideo* iface)
1206 {
1207         CVideoRendererImpl_THIS(iface,basvid);
1208
1209         FIXME("(%p)->()\n",This);
1210
1211         return E_NOTIMPL;
1212 }
1213
1214
1215
1216
1217 static ICOM_VTABLE(IBasicVideo) ibasicvideo =
1218 {
1219         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1220         /* IUnknown fields */
1221         IBasicVideo_fnQueryInterface,
1222         IBasicVideo_fnAddRef,
1223         IBasicVideo_fnRelease,
1224         /* IDispatch fields */
1225         IBasicVideo_fnGetTypeInfoCount,
1226         IBasicVideo_fnGetTypeInfo,
1227         IBasicVideo_fnGetIDsOfNames,
1228         IBasicVideo_fnInvoke,
1229         /* IBasicVideo fields */
1230         IBasicVideo_fnget_AvgTimePerFrame,
1231         IBasicVideo_fnget_BitRate,
1232         IBasicVideo_fnget_BitErrorRate,
1233         IBasicVideo_fnget_VideoWidth,
1234         IBasicVideo_fnget_VideoHeight,
1235         IBasicVideo_fnput_SourceLeft,
1236         IBasicVideo_fnget_SourceLeft,
1237         IBasicVideo_fnput_SourceWidth,
1238         IBasicVideo_fnget_SourceWidth,
1239         IBasicVideo_fnput_SourceTop,
1240         IBasicVideo_fnget_SourceTop,
1241         IBasicVideo_fnput_SourceHeight,
1242         IBasicVideo_fnget_SourceHeight,
1243         IBasicVideo_fnput_DestinationLeft,
1244         IBasicVideo_fnget_DestinationLeft,
1245         IBasicVideo_fnput_DestinationWidth,
1246         IBasicVideo_fnget_DestinationWidth,
1247         IBasicVideo_fnput_DestinationTop,
1248         IBasicVideo_fnget_DestinationTop,
1249         IBasicVideo_fnput_DestinationHeight,
1250         IBasicVideo_fnget_DestinationHeight,
1251         IBasicVideo_fnSetSourcePosition,
1252         IBasicVideo_fnGetSourcePosition,
1253         IBasicVideo_fnSetDefaultSourcePosition,
1254         IBasicVideo_fnSetDestinationPosition,
1255         IBasicVideo_fnGetDestinationPosition,
1256         IBasicVideo_fnSetDefaultDestinationPosition,
1257         IBasicVideo_fnGetVideoSize,
1258         IBasicVideo_fnGetVideoPaletteEntries,
1259         IBasicVideo_fnGetCurrentImage,
1260         IBasicVideo_fnIsUsingDefaultSource,
1261         IBasicVideo_fnIsUsingDefaultDestination,
1262 };
1263
1264
1265 HRESULT CVideoRendererImpl_InitIBasicVideo( CVideoRendererImpl* This )
1266 {
1267         TRACE("(%p)\n",This);
1268         ICOM_VTBL(&This->basvid) = &ibasicvideo;
1269
1270         return NOERROR;
1271 }
1272
1273 void CVideoRendererImpl_UninitIBasicVideo( CVideoRendererImpl* This )
1274 {
1275         TRACE("(%p)\n",This);
1276 }
1277
1278 /***************************************************************************
1279  *
1280  *      CVideoRendererImpl::IVideoWindow
1281  *
1282  */
1283
1284
1285 static HRESULT WINAPI
1286 IVideoWindow_fnQueryInterface(IVideoWindow* iface,REFIID riid,void** ppobj)
1287 {
1288         CVideoRendererImpl_THIS(iface,vidwin);
1289
1290         TRACE("(%p)->()\n",This);
1291
1292         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
1293 }
1294
1295 static ULONG WINAPI
1296 IVideoWindow_fnAddRef(IVideoWindow* iface)
1297 {
1298         CVideoRendererImpl_THIS(iface,vidwin);
1299
1300         TRACE("(%p)->()\n",This);
1301
1302         return IUnknown_AddRef(This->unk.punkControl);
1303 }
1304
1305 static ULONG WINAPI
1306 IVideoWindow_fnRelease(IVideoWindow* iface)
1307 {
1308         CVideoRendererImpl_THIS(iface,vidwin);
1309
1310         TRACE("(%p)->()\n",This);
1311
1312         return IUnknown_Release(This->unk.punkControl);
1313 }
1314
1315 static HRESULT WINAPI
1316 IVideoWindow_fnGetTypeInfoCount(IVideoWindow* iface,UINT* pcTypeInfo)
1317 {
1318         CVideoRendererImpl_THIS(iface,vidwin);
1319
1320         FIXME("(%p)->()\n",This);
1321
1322         return E_NOTIMPL;
1323 }
1324
1325 static HRESULT WINAPI
1326 IVideoWindow_fnGetTypeInfo(IVideoWindow* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
1327 {
1328         CVideoRendererImpl_THIS(iface,vidwin);
1329
1330         FIXME("(%p)->()\n",This);
1331
1332         return E_NOTIMPL;
1333 }
1334
1335 static HRESULT WINAPI
1336 IVideoWindow_fnGetIDsOfNames(IVideoWindow* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
1337 {
1338         CVideoRendererImpl_THIS(iface,vidwin);
1339
1340         FIXME("(%p)->()\n",This);
1341
1342         return E_NOTIMPL;
1343 }
1344
1345 static HRESULT WINAPI
1346 IVideoWindow_fnInvoke(IVideoWindow* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1347 {
1348         CVideoRendererImpl_THIS(iface,vidwin);
1349
1350         FIXME("(%p)->()\n",This);
1351
1352         return E_NOTIMPL;
1353 }
1354
1355
1356
1357 static HRESULT WINAPI
1358 IVideoWindow_fnput_Caption(IVideoWindow* iface,BSTR strCaption)
1359 {
1360         CVideoRendererImpl_THIS(iface,vidwin);
1361         HRESULT hr = E_NOTIMPL;
1362
1363         FIXME("(%p)->()\n",This);
1364
1365         EnterCriticalSection ( &This->basefilter.csFilter );
1366         if ( This->m_hwnd == (HWND)NULL )
1367         {
1368                 hr = VFW_E_NOT_CONNECTED;
1369                 goto end;
1370         }
1371
1372         /* FIXME */
1373 end:
1374         LeaveCriticalSection ( &This->basefilter.csFilter );
1375
1376         return hr;
1377 }
1378
1379 static HRESULT WINAPI
1380 IVideoWindow_fnget_Caption(IVideoWindow* iface,BSTR* pstrCaption)
1381 {
1382         CVideoRendererImpl_THIS(iface,vidwin);
1383         HRESULT hr = E_NOTIMPL;
1384
1385         FIXME("(%p)->()\n",This);
1386
1387         EnterCriticalSection ( &This->basefilter.csFilter );
1388         if ( This->m_hwnd == (HWND)NULL )
1389         {
1390                 hr = VFW_E_NOT_CONNECTED;
1391                 goto end;
1392         }
1393
1394         /* FIXME */
1395 end:
1396         LeaveCriticalSection ( &This->basefilter.csFilter );
1397
1398         return hr;
1399 }
1400
1401 static HRESULT WINAPI
1402 IVideoWindow_fnput_WindowStyle(IVideoWindow* iface,long lStyle)
1403 {
1404         CVideoRendererImpl_THIS(iface,vidwin);
1405         HRESULT hr = E_NOTIMPL;
1406
1407         FIXME("(%p)->()\n",This);
1408
1409         EnterCriticalSection ( &This->basefilter.csFilter );
1410         if ( This->m_hwnd == (HWND)NULL )
1411         {
1412                 hr = VFW_E_NOT_CONNECTED;
1413                 goto end;
1414         }
1415
1416         SetLastError(0);
1417         if ( SetWindowLongA( This->m_hwnd, GWL_STYLE, (DWORD)lStyle ) == 0 &&
1418                  GetLastError() != 0 )
1419         {
1420                 hr = E_FAIL;
1421                 goto end;
1422         }
1423
1424         hr = S_OK;
1425 end:
1426         LeaveCriticalSection ( &This->basefilter.csFilter );
1427
1428         return hr;
1429 }
1430
1431 static HRESULT WINAPI
1432 IVideoWindow_fnget_WindowStyle(IVideoWindow* iface,long* plStyle)
1433 {
1434         CVideoRendererImpl_THIS(iface,vidwin);
1435         HRESULT hr = E_NOTIMPL;
1436
1437         FIXME("(%p)->()\n",This);
1438
1439         EnterCriticalSection ( &This->basefilter.csFilter );
1440         if ( This->m_hwnd == (HWND)NULL )
1441         {
1442                 hr = VFW_E_NOT_CONNECTED;
1443                 goto end;
1444         }
1445
1446         *plStyle = (LONG)GetWindowLongA( This->m_hwnd, GWL_STYLE );
1447         hr = S_OK;
1448 end:
1449         LeaveCriticalSection ( &This->basefilter.csFilter );
1450
1451         return hr;
1452 }
1453
1454 static HRESULT WINAPI
1455 IVideoWindow_fnput_WindowStyleEx(IVideoWindow* iface,long lExStyle)
1456 {
1457         CVideoRendererImpl_THIS(iface,vidwin);
1458         HRESULT hr = E_NOTIMPL;
1459
1460         FIXME("(%p)->()\n",This);
1461
1462         EnterCriticalSection ( &This->basefilter.csFilter );
1463         if ( This->m_hwnd == (HWND)NULL )
1464         {
1465                 hr = VFW_E_NOT_CONNECTED;
1466                 goto end;
1467         }
1468
1469         SetLastError(0);
1470         if ( SetWindowLongA( This->m_hwnd, GWL_EXSTYLE, (DWORD)lExStyle ) == 0 &&
1471                  GetLastError() != 0 )
1472         {
1473                 hr = E_FAIL;
1474                 goto end;
1475         }
1476
1477         hr = S_OK;
1478 end:
1479         LeaveCriticalSection ( &This->basefilter.csFilter );
1480
1481         return hr;
1482 }
1483
1484 static HRESULT WINAPI
1485 IVideoWindow_fnget_WindowStyleEx(IVideoWindow* iface,long* plExStyle)
1486 {
1487         CVideoRendererImpl_THIS(iface,vidwin);
1488         HRESULT hr = E_NOTIMPL;
1489
1490         FIXME("(%p)->()\n",This);
1491
1492         if ( plExStyle == NULL )
1493                 return E_POINTER;
1494
1495         EnterCriticalSection ( &This->basefilter.csFilter );
1496         if ( This->m_hwnd == (HWND)NULL )
1497         {
1498                 hr = VFW_E_NOT_CONNECTED;
1499                 goto end;
1500         }
1501
1502         *plExStyle = (LONG)GetWindowLongA( This->m_hwnd, GWL_EXSTYLE );
1503         hr = S_OK;
1504 end:
1505         LeaveCriticalSection ( &This->basefilter.csFilter );
1506
1507         return hr;
1508 }
1509
1510 static HRESULT WINAPI
1511 IVideoWindow_fnput_AutoShow(IVideoWindow* iface,long lAutoShow)
1512 {
1513         CVideoRendererImpl_THIS(iface,vidwin);
1514         HRESULT hr = E_NOTIMPL;
1515
1516         FIXME("(%p)->()\n",This);
1517
1518         EnterCriticalSection ( &This->basefilter.csFilter );
1519         if ( This->m_hwnd == (HWND)NULL )
1520         {
1521                 hr = VFW_E_NOT_CONNECTED;
1522                 goto end;
1523         }
1524
1525         /* FIXME */
1526 end:
1527         LeaveCriticalSection ( &This->basefilter.csFilter );
1528
1529         return hr;
1530 }
1531
1532 static HRESULT WINAPI
1533 IVideoWindow_fnget_AutoShow(IVideoWindow* iface,long* plAutoShow)
1534 {
1535         CVideoRendererImpl_THIS(iface,vidwin);
1536         HRESULT hr = E_NOTIMPL;
1537
1538         FIXME("(%p)->()\n",This);
1539
1540         EnterCriticalSection ( &This->basefilter.csFilter );
1541         if ( This->m_hwnd == (HWND)NULL )
1542         {
1543                 hr = VFW_E_NOT_CONNECTED;
1544                 goto end;
1545         }
1546
1547         /* FIXME */
1548 end:
1549         LeaveCriticalSection ( &This->basefilter.csFilter );
1550
1551         return hr;
1552 }
1553
1554 static HRESULT WINAPI
1555 IVideoWindow_fnput_WindowState(IVideoWindow* iface,long lState)
1556 {
1557         CVideoRendererImpl_THIS(iface,vidwin);
1558         HRESULT hr = E_NOTIMPL;
1559
1560         FIXME("(%p)->()\n",This);
1561
1562         EnterCriticalSection ( &This->basefilter.csFilter );
1563         if ( This->m_hwnd == (HWND)NULL )
1564         {
1565                 hr = VFW_E_NOT_CONNECTED;
1566                 goto end;
1567         }
1568
1569         /* FIXME */
1570 end:
1571         LeaveCriticalSection ( &This->basefilter.csFilter );
1572
1573         return hr;
1574 }
1575
1576 static HRESULT WINAPI
1577 IVideoWindow_fnget_WindowState(IVideoWindow* iface,long* plState)
1578 {
1579         CVideoRendererImpl_THIS(iface,vidwin);
1580         HRESULT hr = E_NOTIMPL;
1581
1582         FIXME("(%p)->()\n",This);
1583
1584         EnterCriticalSection ( &This->basefilter.csFilter );
1585         if ( This->m_hwnd == (HWND)NULL )
1586         {
1587                 hr = VFW_E_NOT_CONNECTED;
1588                 goto end;
1589         }
1590
1591         /* FIXME */
1592 end:
1593         LeaveCriticalSection ( &This->basefilter.csFilter );
1594
1595         return hr;
1596 }
1597
1598 static HRESULT WINAPI
1599 IVideoWindow_fnput_BackgroundPalette(IVideoWindow* iface,long lBackPal)
1600 {
1601         CVideoRendererImpl_THIS(iface,vidwin);
1602         HRESULT hr = E_NOTIMPL;
1603
1604         FIXME("(%p)->()\n",This);
1605
1606         EnterCriticalSection ( &This->basefilter.csFilter );
1607         if ( This->m_hwnd == (HWND)NULL )
1608         {
1609                 hr = VFW_E_NOT_CONNECTED;
1610                 goto end;
1611         }
1612
1613         /* FIXME */
1614 end:
1615         LeaveCriticalSection ( &This->basefilter.csFilter );
1616
1617         return hr;
1618 }
1619
1620 static HRESULT WINAPI
1621 IVideoWindow_fnget_BackgroundPalette(IVideoWindow* iface,long* plBackPal)
1622 {
1623         CVideoRendererImpl_THIS(iface,vidwin);
1624         HRESULT hr = E_NOTIMPL;
1625
1626         FIXME("(%p)->()\n",This);
1627
1628         EnterCriticalSection ( &This->basefilter.csFilter );
1629         if ( This->m_hwnd == (HWND)NULL )
1630         {
1631                 hr = VFW_E_NOT_CONNECTED;
1632                 goto end;
1633         }
1634
1635         /* FIXME */
1636 end:
1637         LeaveCriticalSection ( &This->basefilter.csFilter );
1638
1639         return hr;
1640 }
1641
1642 static HRESULT WINAPI
1643 IVideoWindow_fnput_Visible(IVideoWindow* iface,long lVisible)
1644 {
1645         CVideoRendererImpl_THIS(iface,vidwin);
1646         HRESULT hr = E_NOTIMPL;
1647
1648         FIXME("(%p)->()\n",This);
1649
1650         EnterCriticalSection ( &This->basefilter.csFilter );
1651         if ( This->m_hwnd == (HWND)NULL )
1652         {
1653                 hr = VFW_E_NOT_CONNECTED;
1654                 goto end;
1655         }
1656
1657         /* FIXME */
1658 end:
1659         LeaveCriticalSection ( &This->basefilter.csFilter );
1660
1661         return hr;
1662 }
1663
1664 static HRESULT WINAPI
1665 IVideoWindow_fnget_Visible(IVideoWindow* iface,long* plVisible)
1666 {
1667         CVideoRendererImpl_THIS(iface,vidwin);
1668         HRESULT hr = E_NOTIMPL;
1669
1670         FIXME("(%p)->()\n",This);
1671
1672         EnterCriticalSection ( &This->basefilter.csFilter );
1673         if ( This->m_hwnd == (HWND)NULL )
1674         {
1675                 hr = VFW_E_NOT_CONNECTED;
1676                 goto end;
1677         }
1678
1679         /* FIXME */
1680 end:
1681         LeaveCriticalSection ( &This->basefilter.csFilter );
1682
1683         return hr;
1684 }
1685
1686 static HRESULT WINAPI
1687 IVideoWindow_fnput_Left(IVideoWindow* iface,long lLeft)
1688 {
1689         CVideoRendererImpl_THIS(iface,vidwin);
1690         HRESULT hr = E_NOTIMPL;
1691         RECT    rc;
1692
1693         FIXME("(%p)->()\n",This);
1694
1695         EnterCriticalSection ( &This->basefilter.csFilter );
1696         if ( This->m_hwnd == (HWND)NULL )
1697         {
1698                 hr = VFW_E_NOT_CONNECTED;
1699                 goto end;
1700         }
1701
1702         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1703         {
1704                 hr = E_FAIL;
1705                 goto end;
1706         }
1707         if ( ! MoveWindow( This->m_hwnd, lLeft, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE ) )
1708         {
1709                 hr = E_FAIL;
1710                 goto end;
1711         }
1712         hr = S_OK;
1713 end:
1714         LeaveCriticalSection ( &This->basefilter.csFilter );
1715
1716         return hr;
1717 }
1718
1719 static HRESULT WINAPI
1720 IVideoWindow_fnget_Left(IVideoWindow* iface,long* plLeft)
1721 {
1722         CVideoRendererImpl_THIS(iface,vidwin);
1723         HRESULT hr = E_NOTIMPL;
1724         RECT    rc;
1725
1726         FIXME("(%p)->()\n",This);
1727
1728         if ( plLeft == NULL )
1729                 return E_POINTER;
1730
1731         EnterCriticalSection ( &This->basefilter.csFilter );
1732         if ( This->m_hwnd == (HWND)NULL )
1733         {
1734                 hr = VFW_E_NOT_CONNECTED;
1735                 goto end;
1736         }
1737
1738         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1739         {
1740                 hr = E_FAIL;
1741                 goto end;
1742         }
1743         *plLeft = rc.left;
1744         hr = S_OK;
1745 end:
1746         LeaveCriticalSection ( &This->basefilter.csFilter );
1747
1748         return hr;
1749 }
1750
1751 static HRESULT WINAPI
1752 IVideoWindow_fnput_Width(IVideoWindow* iface,long lWidth)
1753 {
1754         CVideoRendererImpl_THIS(iface,vidwin);
1755         HRESULT hr = E_NOTIMPL;
1756         RECT    rc;
1757
1758         FIXME("(%p)->()\n",This);
1759
1760         if ( lWidth < 0 )
1761                 return E_INVALIDARG;
1762
1763         EnterCriticalSection ( &This->basefilter.csFilter );
1764         if ( This->m_hwnd == (HWND)NULL )
1765         {
1766                 hr = VFW_E_NOT_CONNECTED;
1767                 goto end;
1768         }
1769
1770         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1771         {
1772                 hr = E_FAIL;
1773                 goto end;
1774         }
1775         if ( ! MoveWindow( This->m_hwnd, rc.left, rc.top, lWidth, rc.bottom-rc.top, TRUE ) )
1776         {
1777                 hr = E_FAIL;
1778                 goto end;
1779         }
1780         hr = S_OK;
1781 end:
1782         LeaveCriticalSection ( &This->basefilter.csFilter );
1783
1784         return hr;
1785 }
1786
1787 static HRESULT WINAPI
1788 IVideoWindow_fnget_Width(IVideoWindow* iface,long* plWidth)
1789 {
1790         CVideoRendererImpl_THIS(iface,vidwin);
1791         HRESULT hr = E_NOTIMPL;
1792         RECT    rc;
1793
1794         FIXME("(%p)->()\n",This);
1795
1796         if ( plWidth == NULL )
1797                 return E_POINTER;
1798
1799         EnterCriticalSection ( &This->basefilter.csFilter );
1800         if ( This->m_hwnd == (HWND)NULL )
1801         {
1802                 hr = VFW_E_NOT_CONNECTED;
1803                 goto end;
1804         }
1805
1806         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1807         {
1808                 hr = E_FAIL;
1809                 goto end;
1810         }
1811         *plWidth = rc.right-rc.left;
1812         hr = S_OK;
1813 end:
1814         LeaveCriticalSection ( &This->basefilter.csFilter );
1815
1816         return hr;
1817 }
1818
1819 static HRESULT WINAPI
1820 IVideoWindow_fnput_Top(IVideoWindow* iface,long lTop)
1821 {
1822         CVideoRendererImpl_THIS(iface,vidwin);
1823         HRESULT hr = E_NOTIMPL;
1824         RECT    rc;
1825
1826         FIXME("(%p)->()\n",This);
1827
1828         EnterCriticalSection ( &This->basefilter.csFilter );
1829         if ( This->m_hwnd == (HWND)NULL )
1830         {
1831                 hr = VFW_E_NOT_CONNECTED;
1832                 goto end;
1833         }
1834
1835         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1836         {
1837                 hr = E_FAIL;
1838                 goto end;
1839         }
1840         if ( ! MoveWindow( This->m_hwnd, rc.left, lTop, rc.right-rc.left, rc.bottom-rc.top, TRUE ) )
1841         {
1842                 hr = E_FAIL;
1843                 goto end;
1844         }
1845         hr = S_OK;
1846 end:
1847         LeaveCriticalSection ( &This->basefilter.csFilter );
1848
1849         return hr;
1850 }
1851
1852 static HRESULT WINAPI
1853 IVideoWindow_fnget_Top(IVideoWindow* iface,long* plTop)
1854 {
1855         CVideoRendererImpl_THIS(iface,vidwin);
1856         HRESULT hr = E_NOTIMPL;
1857         RECT    rc;
1858
1859         FIXME("(%p)->()\n",This);
1860
1861         if ( plTop == NULL )
1862                 return E_POINTER;
1863
1864         EnterCriticalSection ( &This->basefilter.csFilter );
1865         if ( This->m_hwnd == (HWND)NULL )
1866         {
1867                 hr = VFW_E_NOT_CONNECTED;
1868                 goto end;
1869         }
1870
1871         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1872         {
1873                 hr = E_FAIL;
1874                 goto end;
1875         }
1876         *plTop = rc.top;
1877         hr = S_OK;
1878 end:
1879         LeaveCriticalSection ( &This->basefilter.csFilter );
1880
1881         return hr;
1882 }
1883
1884 static HRESULT WINAPI
1885 IVideoWindow_fnput_Height(IVideoWindow* iface,long lHeight)
1886 {
1887         CVideoRendererImpl_THIS(iface,vidwin);
1888         HRESULT hr = E_NOTIMPL;
1889         RECT    rc;
1890
1891         FIXME("(%p)->()\n",This);
1892
1893         if ( lHeight < 0 )
1894                 return E_INVALIDARG;
1895
1896         EnterCriticalSection ( &This->basefilter.csFilter );
1897         if ( This->m_hwnd == (HWND)NULL )
1898         {
1899                 hr = VFW_E_NOT_CONNECTED;
1900                 goto end;
1901         }
1902
1903         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1904         {
1905                 hr = E_FAIL;
1906                 goto end;
1907         }
1908         if ( ! MoveWindow( This->m_hwnd, rc.left, rc.top, rc.right-rc.left, lHeight, TRUE ) )
1909         {
1910                 hr = E_FAIL;
1911                 goto end;
1912         }
1913         hr = S_OK;
1914 end:
1915         LeaveCriticalSection ( &This->basefilter.csFilter );
1916
1917         return hr;
1918 }
1919
1920 static HRESULT WINAPI
1921 IVideoWindow_fnget_Height(IVideoWindow* iface,long* plHeight)
1922 {
1923         CVideoRendererImpl_THIS(iface,vidwin);
1924         HRESULT hr = E_NOTIMPL;
1925         RECT    rc;
1926
1927         FIXME("(%p)->()\n",This);
1928
1929         if ( plHeight == NULL )
1930                 return E_POINTER;
1931
1932         EnterCriticalSection ( &This->basefilter.csFilter );
1933         if ( This->m_hwnd == (HWND)NULL )
1934         {
1935                 hr = VFW_E_NOT_CONNECTED;
1936                 goto end;
1937         }
1938
1939         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1940         {
1941                 hr = E_FAIL;
1942                 goto end;
1943         }
1944         *plHeight = rc.bottom-rc.top;
1945         hr = S_OK;
1946 end:
1947         LeaveCriticalSection ( &This->basefilter.csFilter );
1948
1949         return hr;
1950 }
1951
1952 static HRESULT WINAPI
1953 IVideoWindow_fnput_Owner(IVideoWindow* iface,OAHWND hwnd)
1954 {
1955         CVideoRendererImpl_THIS(iface,vidwin);
1956         HRESULT hr = E_NOTIMPL;
1957         DWORD   dwStyle;
1958         RECT    rc;
1959
1960         FIXME("(%p)->()\n",This);
1961
1962         EnterCriticalSection ( &This->basefilter.csFilter );
1963         if ( This->m_hwnd == (HWND)NULL )
1964         {
1965                 hr = VFW_E_NOT_CONNECTED;
1966                 goto end;
1967         }
1968         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
1969         {
1970                 hr = E_FAIL;
1971                 goto end;
1972         }
1973
1974         dwStyle = (DWORD)GetWindowLongA( This->m_hwnd, GWL_STYLE );
1975         if ( hwnd == (HWND)NULL )
1976                 SetWindowLongA( This->m_hwnd, GWL_STYLE, dwStyle & (~WS_CHILD) );
1977         SetParent( This->m_hwnd, (HWND)hwnd );
1978         if ( (HWND)hwnd != (HWND)NULL )
1979         {
1980                 SetWindowLongA( This->m_hwnd, GWL_STYLE, dwStyle | WS_CHILD );
1981                 MoveWindow( This->m_hwnd, 0, 0, rc.right-rc.left, rc.bottom-rc.top, TRUE );
1982         }
1983
1984         hr = S_OK;
1985 end:
1986         LeaveCriticalSection ( &This->basefilter.csFilter );
1987
1988         return hr;
1989 }
1990
1991 static HRESULT WINAPI
1992 IVideoWindow_fnget_Owner(IVideoWindow* iface,OAHWND* phwnd)
1993 {
1994         CVideoRendererImpl_THIS(iface,vidwin);
1995         HRESULT hr = E_NOTIMPL;
1996
1997         FIXME("(%p)->()\n",This);
1998
1999         if ( phwnd == NULL )
2000                 return E_POINTER;
2001
2002         EnterCriticalSection ( &This->basefilter.csFilter );
2003         if ( This->m_hwnd == (HWND)NULL )
2004         {
2005                 hr = VFW_E_NOT_CONNECTED;
2006                 goto end;
2007         }
2008
2009         *phwnd = (OAHWND)GetParent( This->m_hwnd );
2010         hr = S_OK;
2011 end:
2012         LeaveCriticalSection ( &This->basefilter.csFilter );
2013
2014         return hr;
2015 }
2016
2017 static HRESULT WINAPI
2018 IVideoWindow_fnput_MessageDrain(IVideoWindow* iface,OAHWND hwnd)
2019 {
2020         CVideoRendererImpl_THIS(iface,vidwin);
2021         HRESULT hr = E_NOTIMPL;
2022
2023         FIXME("(%p)->()\n",This);
2024
2025         EnterCriticalSection ( &This->basefilter.csFilter );
2026         if ( This->m_hwnd == (HWND)NULL )
2027         {
2028                 hr = VFW_E_NOT_CONNECTED;
2029                 goto end;
2030         }
2031
2032         /* FIXME */
2033 end:
2034         LeaveCriticalSection ( &This->basefilter.csFilter );
2035
2036         return hr;
2037 }
2038
2039 static HRESULT WINAPI
2040 IVideoWindow_fnget_MessageDrain(IVideoWindow* iface,OAHWND* phwnd)
2041 {
2042         CVideoRendererImpl_THIS(iface,vidwin);
2043         HRESULT hr = E_NOTIMPL;
2044
2045         FIXME("(%p)->()\n",This);
2046
2047         EnterCriticalSection ( &This->basefilter.csFilter );
2048         if ( This->m_hwnd == (HWND)NULL )
2049         {
2050                 hr = VFW_E_NOT_CONNECTED;
2051                 goto end;
2052         }
2053
2054         /* FIXME */
2055 end:
2056         LeaveCriticalSection ( &This->basefilter.csFilter );
2057
2058         return hr;
2059 }
2060
2061 static HRESULT WINAPI
2062 IVideoWindow_fnget_BorderColor(IVideoWindow* iface,long* plColor)
2063 {
2064         CVideoRendererImpl_THIS(iface,vidwin);
2065         HRESULT hr = E_NOTIMPL;
2066
2067         FIXME("(%p)->()\n",This);
2068
2069         EnterCriticalSection ( &This->basefilter.csFilter );
2070         if ( This->m_hwnd == (HWND)NULL )
2071         {
2072                 hr = VFW_E_NOT_CONNECTED;
2073                 goto end;
2074         }
2075
2076         /* FIXME */
2077 end:
2078         LeaveCriticalSection ( &This->basefilter.csFilter );
2079
2080         return hr;
2081 }
2082
2083 static HRESULT WINAPI
2084 IVideoWindow_fnput_BorderColor(IVideoWindow* iface,long lColor)
2085 {
2086         CVideoRendererImpl_THIS(iface,vidwin);
2087         HRESULT hr = E_NOTIMPL;
2088
2089         FIXME("(%p)->()\n",This);
2090
2091         EnterCriticalSection ( &This->basefilter.csFilter );
2092         if ( This->m_hwnd == (HWND)NULL )
2093         {
2094                 hr = VFW_E_NOT_CONNECTED;
2095                 goto end;
2096         }
2097
2098         /* FIXME */
2099 end:
2100         LeaveCriticalSection ( &This->basefilter.csFilter );
2101
2102         return hr;
2103 }
2104
2105 static HRESULT WINAPI
2106 IVideoWindow_fnget_FullScreenMode(IVideoWindow* iface,long* plMode)
2107 {
2108         CVideoRendererImpl_THIS(iface,vidwin);
2109         HRESULT hr = E_NOTIMPL;
2110
2111         FIXME("(%p)->()\n",This);
2112
2113         EnterCriticalSection ( &This->basefilter.csFilter );
2114         if ( This->m_hwnd == (HWND)NULL )
2115         {
2116                 hr = VFW_E_NOT_CONNECTED;
2117                 goto end;
2118         }
2119
2120         /* FIXME */
2121 end:
2122         LeaveCriticalSection ( &This->basefilter.csFilter );
2123
2124         return hr;
2125 }
2126
2127 static HRESULT WINAPI
2128 IVideoWindow_fnput_FullScreenMode(IVideoWindow* iface,long lMode)
2129 {
2130         CVideoRendererImpl_THIS(iface,vidwin);
2131         HRESULT hr = E_NOTIMPL;
2132
2133         FIXME("(%p)->()\n",This);
2134
2135         EnterCriticalSection ( &This->basefilter.csFilter );
2136         if ( This->m_hwnd == (HWND)NULL )
2137         {
2138                 hr = VFW_E_NOT_CONNECTED;
2139                 goto end;
2140         }
2141
2142         /* FIXME */
2143 end:
2144         LeaveCriticalSection ( &This->basefilter.csFilter );
2145
2146         return hr;
2147 }
2148
2149 static HRESULT WINAPI
2150 IVideoWindow_fnSetWindowForeground(IVideoWindow* iface,long lFocus)
2151 {
2152         CVideoRendererImpl_THIS(iface,vidwin);
2153         HRESULT hr = E_NOTIMPL;
2154
2155         FIXME("(%p)->()\n",This);
2156
2157         EnterCriticalSection ( &This->basefilter.csFilter );
2158         if ( This->m_hwnd == (HWND)NULL )
2159         {
2160                 hr = VFW_E_NOT_CONNECTED;
2161                 goto end;
2162         }
2163
2164         /* FIXME */
2165 end:
2166         LeaveCriticalSection ( &This->basefilter.csFilter );
2167
2168         return hr;
2169 }
2170
2171 static HRESULT WINAPI
2172 IVideoWindow_fnNotifyOwnerMessage(IVideoWindow* iface,OAHWND hwnd,long message,LONG_PTR wParam,LONG_PTR lParam)
2173 {
2174         CVideoRendererImpl_THIS(iface,vidwin);
2175         HRESULT hr = E_NOTIMPL;
2176
2177         FIXME("(%p)->()\n",This);
2178
2179         EnterCriticalSection ( &This->basefilter.csFilter );
2180         if ( This->m_hwnd == (HWND)NULL )
2181         {
2182                 hr = VFW_E_NOT_CONNECTED;
2183                 goto end;
2184         }
2185
2186         /* FIXME */
2187 end:
2188         LeaveCriticalSection ( &This->basefilter.csFilter );
2189
2190         return hr;
2191 }
2192
2193 static HRESULT WINAPI
2194 IVideoWindow_fnSetWindowPosition(IVideoWindow* iface,long lLeft,long lTop,long lWidth,long lHeight)
2195 {
2196         CVideoRendererImpl_THIS(iface,vidwin);
2197         HRESULT hr = E_NOTIMPL;
2198
2199         FIXME("(%p)->()\n",This);
2200
2201         EnterCriticalSection ( &This->basefilter.csFilter );
2202         if ( This->m_hwnd == (HWND)NULL )
2203         {
2204                 hr = VFW_E_NOT_CONNECTED;
2205                 goto end;
2206         }
2207
2208         if ( ! MoveWindow( This->m_hwnd, lLeft, lTop, lWidth, lHeight, TRUE ) )
2209         {
2210                 hr = E_FAIL;
2211                 goto end;
2212         }
2213         hr = S_OK;
2214 end:
2215         LeaveCriticalSection ( &This->basefilter.csFilter );
2216
2217         return hr;
2218 }
2219
2220 static HRESULT WINAPI
2221 IVideoWindow_fnGetWindowPosition(IVideoWindow* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
2222 {
2223         CVideoRendererImpl_THIS(iface,vidwin);
2224         HRESULT hr = E_NOTIMPL;
2225         RECT    rc;
2226
2227         FIXME("(%p)->()\n",This);
2228
2229         if ( plLeft == NULL || plTop == NULL ||
2230                  plWidth == NULL || plHeight == NULL )
2231                 return E_POINTER;
2232
2233         EnterCriticalSection ( &This->basefilter.csFilter );
2234         if ( This->m_hwnd == (HWND)NULL )
2235         {
2236                 hr = VFW_E_NOT_CONNECTED;
2237                 goto end;
2238         }
2239
2240         /* FIXME */
2241         if ( ! GetWindowRect( This->m_hwnd, &rc ) )
2242         {
2243                 hr = E_FAIL;
2244                 goto end;
2245         }
2246
2247         *plLeft = rc.left;
2248         *plTop = rc.top;
2249         *plWidth = rc.right-rc.left;
2250         *plHeight = rc.bottom-rc.top;
2251         hr = S_OK;
2252
2253 end:
2254         LeaveCriticalSection ( &This->basefilter.csFilter );
2255
2256         return hr;
2257 }
2258
2259 static HRESULT WINAPI
2260 IVideoWindow_fnGetMinIdealImageSize(IVideoWindow* iface,long* plWidth,long* plHeight)
2261 {
2262         CVideoRendererImpl_THIS(iface,vidwin);
2263         HRESULT hr = E_NOTIMPL;
2264
2265         FIXME("(%p)->()\n",This);
2266
2267         EnterCriticalSection ( &This->basefilter.csFilter );
2268         if ( This->m_hwnd == (HWND)NULL )
2269         {
2270                 hr = VFW_E_NOT_CONNECTED;
2271                 goto end;
2272         }
2273
2274         /* FIXME */
2275 end:
2276         LeaveCriticalSection ( &This->basefilter.csFilter );
2277
2278         return hr;
2279 }
2280
2281 static HRESULT WINAPI
2282 IVideoWindow_fnGetMaxIdealImageSize(IVideoWindow* iface,long* plWidth,long* plHeight)
2283 {
2284         CVideoRendererImpl_THIS(iface,vidwin);
2285         HRESULT hr = E_NOTIMPL;
2286
2287         FIXME("(%p)->()\n",This);
2288
2289         EnterCriticalSection ( &This->basefilter.csFilter );
2290         if ( This->m_hwnd == (HWND)NULL )
2291         {
2292                 hr = VFW_E_NOT_CONNECTED;
2293                 goto end;
2294         }
2295
2296         /* FIXME */
2297 end:
2298         LeaveCriticalSection ( &This->basefilter.csFilter );
2299
2300         return hr;
2301 }
2302
2303 static HRESULT WINAPI
2304 IVideoWindow_fnGetRestorePosition(IVideoWindow* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
2305 {
2306         CVideoRendererImpl_THIS(iface,vidwin);
2307         HRESULT hr = E_NOTIMPL;
2308
2309         FIXME("(%p)->()\n",This);
2310
2311         EnterCriticalSection ( &This->basefilter.csFilter );
2312         if ( This->m_hwnd == (HWND)NULL )
2313         {
2314                 hr = VFW_E_NOT_CONNECTED;
2315                 goto end;
2316         }
2317
2318         /* FIXME */
2319 end:
2320         LeaveCriticalSection ( &This->basefilter.csFilter );
2321
2322         return hr;
2323 }
2324
2325 static HRESULT WINAPI
2326 IVideoWindow_fnHideCursor(IVideoWindow* iface,long lHide)
2327 {
2328         CVideoRendererImpl_THIS(iface,vidwin);
2329         HRESULT hr = E_NOTIMPL;
2330
2331         FIXME("(%p)->()\n",This);
2332
2333         EnterCriticalSection ( &This->basefilter.csFilter );
2334         if ( This->m_hwnd == (HWND)NULL )
2335         {
2336                 hr = VFW_E_NOT_CONNECTED;
2337                 goto end;
2338         }
2339
2340         /* FIXME */
2341 end:
2342         LeaveCriticalSection ( &This->basefilter.csFilter );
2343
2344         return hr;
2345 }
2346
2347 static HRESULT WINAPI
2348 IVideoWindow_fnIsCursorHidden(IVideoWindow* iface,long* plHide)
2349 {
2350         CVideoRendererImpl_THIS(iface,vidwin);
2351         HRESULT hr = E_NOTIMPL;
2352
2353         FIXME("(%p)->()\n",This);
2354
2355         EnterCriticalSection ( &This->basefilter.csFilter );
2356         if ( This->m_hwnd == (HWND)NULL )
2357         {
2358                 hr = VFW_E_NOT_CONNECTED;
2359                 goto end;
2360         }
2361
2362         /* FIXME */
2363 end:
2364         LeaveCriticalSection ( &This->basefilter.csFilter );
2365
2366         return hr;
2367 }
2368
2369
2370
2371
2372 static ICOM_VTABLE(IVideoWindow) ivideowindow =
2373 {
2374         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2375         /* IUnknown fields */
2376         IVideoWindow_fnQueryInterface,
2377         IVideoWindow_fnAddRef,
2378         IVideoWindow_fnRelease,
2379         /* IDispatch fields */
2380         IVideoWindow_fnGetTypeInfoCount,
2381         IVideoWindow_fnGetTypeInfo,
2382         IVideoWindow_fnGetIDsOfNames,
2383         IVideoWindow_fnInvoke,
2384         /* IVideoWindow fields */
2385         IVideoWindow_fnput_Caption,
2386         IVideoWindow_fnget_Caption,
2387         IVideoWindow_fnput_WindowStyle,
2388         IVideoWindow_fnget_WindowStyle,
2389         IVideoWindow_fnput_WindowStyleEx,
2390         IVideoWindow_fnget_WindowStyleEx,
2391         IVideoWindow_fnput_AutoShow,
2392         IVideoWindow_fnget_AutoShow,
2393         IVideoWindow_fnput_WindowState,
2394         IVideoWindow_fnget_WindowState,
2395         IVideoWindow_fnput_BackgroundPalette,
2396         IVideoWindow_fnget_BackgroundPalette,
2397         IVideoWindow_fnput_Visible,
2398         IVideoWindow_fnget_Visible,
2399         IVideoWindow_fnput_Left,
2400         IVideoWindow_fnget_Left,
2401         IVideoWindow_fnput_Width,
2402         IVideoWindow_fnget_Width,
2403         IVideoWindow_fnput_Top,
2404         IVideoWindow_fnget_Top,
2405         IVideoWindow_fnput_Height,
2406         IVideoWindow_fnget_Height,
2407         IVideoWindow_fnput_Owner,
2408         IVideoWindow_fnget_Owner,
2409         IVideoWindow_fnput_MessageDrain,
2410         IVideoWindow_fnget_MessageDrain,
2411         IVideoWindow_fnget_BorderColor,
2412         IVideoWindow_fnput_BorderColor,
2413         IVideoWindow_fnget_FullScreenMode,
2414         IVideoWindow_fnput_FullScreenMode,
2415         IVideoWindow_fnSetWindowForeground,
2416         IVideoWindow_fnNotifyOwnerMessage,
2417         IVideoWindow_fnSetWindowPosition,
2418         IVideoWindow_fnGetWindowPosition,
2419         IVideoWindow_fnGetMinIdealImageSize,
2420         IVideoWindow_fnGetMaxIdealImageSize,
2421         IVideoWindow_fnGetRestorePosition,
2422         IVideoWindow_fnHideCursor,
2423         IVideoWindow_fnIsCursorHidden,
2424
2425 };
2426
2427
2428 HRESULT CVideoRendererImpl_InitIVideoWindow( CVideoRendererImpl* This )
2429 {
2430         TRACE("(%p)\n",This);
2431         ICOM_VTBL(&This->vidwin) = &ivideowindow;
2432
2433         return NOERROR;
2434 }
2435
2436 void CVideoRendererImpl_UninitIVideoWindow( CVideoRendererImpl* This )
2437 {
2438         TRACE("(%p)\n",This);
2439 }
2440