When including 'wine/port.h', include it first.
[wine] / dlls / quartz / vidren.c
1 /*
2  * Implements CLSID_VideoRenderer.
3  *
4  * hidenori@a2.ctktv.ne.jp
5  *
6  * FIXME - use clock
7  */
8
9 #include "config.h"
10
11 #include <stdlib.h>
12 #include "windef.h"
13 #include "winbase.h"
14 #include "wingdi.h"
15 #include "winuser.h"
16 #include "winerror.h"
17 #include "mmsystem.h"
18 #include "strmif.h"
19 #include "control.h"
20 #include "vfwmsgs.h"
21 #include "uuids.h"
22 #include "amvideo.h"
23 #include "evcode.h"
24
25 #include "debugtools.h"
26 DEFAULT_DEBUG_CHANNEL(quartz);
27
28 #include "quartz_private.h"
29 #include "vidren.h"
30
31
32 static const WCHAR QUARTZ_VideoRenderer_Name[] =
33 { 'V','i','d','e','o',' ','R','e','n','d','e','r','e','r',0 };
34 static const WCHAR QUARTZ_VideoRendererPin_Name[] =
35 { 'I','n',0 };
36
37 #define VIDRENMSG_UPDATE        (WM_APP+0)
38 #define VIDRENMSG_ENDTHREAD     (WM_APP+1)
39
40 static const CHAR VIDREN_szWndClass[] = "Wine_VideoRenderer";
41 static const CHAR VIDREN_szWndName[] = "Wine Video Renderer";
42
43
44
45
46 static void VIDREN_OnPaint( CVideoRendererImpl* This, HWND hwnd )
47 {
48         PAINTSTRUCT ps;
49         const VIDEOINFOHEADER* pinfo;
50         const AM_MEDIA_TYPE* pmt;
51
52         TRACE("(%p,%08x)\n",This,hwnd);
53
54         if ( !BeginPaint( hwnd, &ps ) )
55                 return;
56
57         pmt = This->pPin->pin.pmtConn;
58         if ( (!This->m_bSampleIsValid) || pmt == NULL )
59                 goto err;
60
61         pinfo = (const VIDEOINFOHEADER*)pmt->pbFormat;
62
63         StretchDIBits(
64                 ps.hdc,
65                 0, 0,
66                 abs(pinfo->bmiHeader.biWidth), abs(pinfo->bmiHeader.biHeight),
67                 0, 0,
68                 abs(pinfo->bmiHeader.biWidth), abs(pinfo->bmiHeader.biHeight),
69                 This->m_pSampleData, (BITMAPINFO*)(&pinfo->bmiHeader),
70                 DIB_RGB_COLORS, SRCCOPY );
71
72 err:
73         EndPaint( hwnd, &ps );
74 }
75
76 static void VIDREN_OnQueryNewPalette( CVideoRendererImpl* This, HWND hwnd )
77 {
78         FIXME("(%p,%08x)\n",This,hwnd);
79 }
80
81 static void VIDREN_OnUpdate( CVideoRendererImpl* This, HWND hwnd )
82 {
83         MSG     msg;
84
85         TRACE("(%p,%08x)\n",This,hwnd);
86
87         InvalidateRect(hwnd,NULL,FALSE);
88         UpdateWindow(hwnd);
89
90         /* FIXME */
91         while ( PeekMessageA(&msg,hwnd,
92                 VIDRENMSG_UPDATE,VIDRENMSG_UPDATE,
93                 PM_REMOVE) != FALSE )
94         {
95                 /* discard this message. */
96         }
97 }
98
99
100 static LRESULT CALLBACK
101 VIDREN_WndProc(
102         HWND hwnd, UINT message,
103         WPARAM wParam, LPARAM lParam )
104 {
105         CVideoRendererImpl*     This = (CVideoRendererImpl*)
106                 GetWindowLongA( hwnd, 0L );
107
108         TRACE("(%p) - %u/%u/%ld\n",This,message,wParam,lParam);
109
110         if ( message == WM_NCCREATE )
111         {
112                 This = (CVideoRendererImpl*)(((CREATESTRUCTA*)lParam)->lpCreateParams);
113                 SetWindowLongA( hwnd, 0L, (LONG)This );
114                 This->m_hwnd = hwnd;
115         }
116
117         if ( message == WM_NCDESTROY )
118         {
119                 PostQuitMessage(0);
120                 This->m_hwnd = (HWND)NULL;
121                 SetWindowLongA( hwnd, 0L, (LONG)NULL );
122                 This = NULL;
123         }
124
125         if ( This != NULL )
126         {
127                 switch ( message )
128                 {
129                 case WM_PAINT:
130                         TRACE("WM_PAINT begin\n");
131                         EnterCriticalSection( &This->m_csSample );
132                         VIDREN_OnPaint( This, hwnd );
133                         LeaveCriticalSection( &This->m_csSample );
134                         TRACE("WM_PAINT end\n");
135                         return 0;
136                 case WM_CLOSE:
137                         ShowWindow( hwnd, SW_HIDE );
138                         return 0;
139                 case WM_PALETTECHANGED:
140                         if ( hwnd == (HWND)wParam )
141                                 break;
142                         /* fall through */
143                 case WM_QUERYNEWPALETTE:
144                         VIDREN_OnQueryNewPalette( This, hwnd );
145                         break;
146                 case VIDRENMSG_UPDATE:
147                         VIDREN_OnUpdate( This, hwnd );
148                         return 0;
149                 case VIDRENMSG_ENDTHREAD:
150                         DestroyWindow(hwnd);
151                         return 0;
152                 default:
153                         break;
154                 }
155         }
156
157         return DefWindowProcA( hwnd, message, wParam, lParam );
158 }
159
160 static BOOL VIDREN_Register( HINSTANCE hInst )
161 {
162         WNDCLASSA       wc;
163         ATOM    atom;
164
165         wc.style = 0;
166         wc.lpfnWndProc = VIDREN_WndProc;
167         wc.cbClsExtra = 0;
168         wc.cbWndExtra = sizeof(LONG);
169         wc.hInstance = hInst;
170         wc.hIcon = LoadIconA((HINSTANCE)NULL,IDI_WINLOGOA);
171         wc.hCursor = LoadCursorA((HINSTANCE)NULL,IDC_ARROWA);
172         wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
173         wc.lpszMenuName = NULL;
174         wc.lpszClassName = VIDREN_szWndClass;
175
176         atom = RegisterClassA( &wc );
177         if ( atom != (ATOM)0 )
178                 return TRUE;
179
180         /* FIXME */
181         return FALSE;
182 }
183
184 static HWND VIDREN_Create( HWND hwndOwner, CVideoRendererImpl* This )
185 {
186         HINSTANCE hInst = (HINSTANCE)GetModuleHandleA(NULL);
187         const VIDEOINFOHEADER* pinfo;
188         DWORD   dwExStyle = 0;
189         DWORD   dwStyle = WS_OVERLAPPED|WS_CAPTION|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
190         RECT    rcWnd;
191
192         if ( !VIDREN_Register( hInst ) )
193                 return (HWND)NULL;
194
195         pinfo = (const VIDEOINFOHEADER*)This->pPin->pin.pmtConn->pbFormat;
196
197         TRACE("width %ld, height %ld\n", pinfo->bmiHeader.biWidth, pinfo->bmiHeader.biHeight);
198
199         rcWnd.left = 0;
200         rcWnd.top = 0;
201         rcWnd.right = pinfo->bmiHeader.biWidth;
202         rcWnd.bottom = abs(pinfo->bmiHeader.biHeight);
203         AdjustWindowRectEx( &rcWnd, dwStyle, FALSE, dwExStyle );
204
205         TRACE("window width %d,height %d\n",
206                 rcWnd.right-rcWnd.left,rcWnd.bottom-rcWnd.top);
207
208         return CreateWindowExA(
209                 dwExStyle,
210                 VIDREN_szWndClass, VIDREN_szWndName,
211                 dwStyle | WS_VISIBLE,
212                 100,100, /* FIXME */
213                 rcWnd.right-rcWnd.left, rcWnd.bottom-rcWnd.top,
214                 hwndOwner, (HMENU)NULL,
215                 hInst, (LPVOID)This );
216 }
217
218 static DWORD WINAPI VIDREN_ThreadEntry( LPVOID pv )
219 {
220         CVideoRendererImpl*     This = (CVideoRendererImpl*)pv;
221         MSG     msg;
222
223         TRACE("(%p)\n",This);
224         if ( !VIDREN_Create( (HWND)NULL, This ) )
225                 return 0;
226         TRACE("VIDREN_Create succeeded\n");
227
228         SetEvent( This->m_hEventInit );
229         TRACE("Enter message loop\n");
230
231         while ( GetMessageA(&msg,(HWND)NULL,0,0) )
232         {
233                 TranslateMessage(&msg);
234                 DispatchMessageA(&msg);
235         }
236
237         return 0;
238 }
239
240 static HRESULT VIDREN_StartThread( CVideoRendererImpl* This )
241 {
242         DWORD dwRes;
243         DWORD dwThreadId;
244         HANDLE  hEvents[2];
245
246         if ( This->m_hEventInit != (HANDLE)NULL ||
247                  This->m_hwnd != (HWND)NULL ||
248                  This->m_hThread != (HANDLE)NULL ||
249                  This->pPin->pin.pmtConn == NULL )
250                 return E_UNEXPECTED;
251
252         This->m_hEventInit = CreateEventA(NULL,TRUE,FALSE,NULL);
253         if ( This->m_hEventInit == (HANDLE)NULL )
254                 return E_OUTOFMEMORY;
255
256         This->m_hThread = CreateThread(
257                 NULL, 0,
258                 VIDREN_ThreadEntry,
259                 (LPVOID)This,
260                 0, &dwThreadId );
261         if ( This->m_hThread == (HANDLE)NULL )
262                 return E_FAIL;
263
264         hEvents[0] = This->m_hEventInit;
265         hEvents[1] = This->m_hThread;
266
267         dwRes = WaitForMultipleObjects(2,hEvents,FALSE,INFINITE);
268         if ( dwRes != WAIT_OBJECT_0 )
269                 return E_FAIL;
270
271         return S_OK;
272 }
273
274 static void VIDREN_EndThread( CVideoRendererImpl* This )
275 {
276         if ( This->m_hwnd != (HWND)NULL )
277                 PostMessageA( This->m_hwnd, VIDRENMSG_ENDTHREAD, 0, 0 );
278
279         if ( This->m_hThread != (HANDLE)NULL )
280         {
281                 WaitForSingleObject( This->m_hThread, INFINITE );
282                 CloseHandle( This->m_hThread );
283                 This->m_hThread = (HANDLE)NULL;
284         }
285         if ( This->m_hEventInit != (HANDLE)NULL )
286         {
287                 CloseHandle( This->m_hEventInit );
288                 This->m_hEventInit = (HANDLE)NULL;
289         }
290 }
291
292
293
294 /***************************************************************************
295  *
296  *      CVideoRendererImpl methods
297  *
298  */
299
300 static HRESULT CVideoRendererImpl_OnActive( CBaseFilterImpl* pImpl )
301 {
302         CVideoRendererImpl_THIS(pImpl,basefilter);
303
304         FIXME( "(%p)\n", This );
305
306         This->m_bSampleIsValid = FALSE;
307
308         return NOERROR;
309 }
310
311 static HRESULT CVideoRendererImpl_OnInactive( CBaseFilterImpl* pImpl )
312 {
313         CVideoRendererImpl_THIS(pImpl,basefilter);
314
315         FIXME( "(%p)\n", This );
316
317         EnterCriticalSection( &This->m_csSample );
318         This->m_bSampleIsValid = FALSE;
319         LeaveCriticalSection( &This->m_csSample );
320
321         return NOERROR;
322 }
323
324 static const CBaseFilterHandlers filterhandlers =
325 {
326         CVideoRendererImpl_OnActive, /* pOnActive */
327         CVideoRendererImpl_OnInactive, /* pOnInactive */
328         NULL, /* pOnStop */
329 };
330
331 /***************************************************************************
332  *
333  *      CVideoRendererPinImpl methods
334  *
335  */
336
337 static HRESULT CVideoRendererPinImpl_OnPreConnect( CPinBaseImpl* pImpl, IPin* pPin )
338 {
339         CVideoRendererPinImpl_THIS(pImpl,pin);
340
341         TRACE("(%p,%p)\n",This,pPin);
342
343         return NOERROR;
344 }
345
346 static HRESULT CVideoRendererPinImpl_OnPostConnect( CPinBaseImpl* pImpl, IPin* pPin )
347 {
348         CVideoRendererPinImpl_THIS(pImpl,pin);
349         const VIDEOINFOHEADER* pinfo;
350         HRESULT hr;
351
352         TRACE("(%p,%p)\n",This,pPin);
353
354         if ( This->pRender->m_pSampleData != NULL )
355         {
356                 QUARTZ_FreeMem(This->pRender->m_pSampleData);
357                 This->pRender->m_pSampleData = NULL;
358         }
359         This->pRender->m_cbSampleData = 0;
360         This->pRender->m_bSampleIsValid = FALSE;
361
362         pinfo = (const VIDEOINFOHEADER*)This->pin.pmtConn->pbFormat;
363         if ( pinfo == NULL )
364                 return E_FAIL;
365
366         This->pRender->m_bSampleIsValid = FALSE;
367         This->pRender->m_cbSampleData = DIBSIZE(pinfo->bmiHeader);
368         This->pRender->m_pSampleData = (BYTE*)QUARTZ_AllocMem(This->pRender->m_cbSampleData);
369         if ( This->pRender->m_pSampleData == NULL )
370                 return E_OUTOFMEMORY;
371
372         hr = VIDREN_StartThread(This->pRender);
373         if ( FAILED(hr) )
374                 return hr;
375
376         return NOERROR;
377 }
378
379 static HRESULT CVideoRendererPinImpl_OnDisconnect( CPinBaseImpl* pImpl )
380 {
381         CVideoRendererPinImpl_THIS(pImpl,pin);
382
383         TRACE("(%p)\n",This);
384
385         VIDREN_EndThread(This->pRender);
386
387         if ( This->pRender->m_pSampleData != NULL )
388         {
389                 QUARTZ_FreeMem(This->pRender->m_pSampleData);
390                 This->pRender->m_pSampleData = NULL;
391         }
392         This->pRender->m_cbSampleData = 0;
393         This->pRender->m_bSampleIsValid = FALSE;
394
395         return NOERROR;
396 }
397
398 static HRESULT CVideoRendererPinImpl_CheckMediaType( CPinBaseImpl* pImpl, const AM_MEDIA_TYPE* pmt )
399 {
400         CVideoRendererPinImpl_THIS(pImpl,pin);
401         const VIDEOINFOHEADER* pinfo;
402
403         TRACE("(%p,%p)\n",This,pmt);
404
405         if ( !IsEqualGUID( &pmt->majortype, &MEDIATYPE_Video ) )
406                 return E_FAIL;
407         if ( !IsEqualGUID( &pmt->formattype, &FORMAT_VideoInfo ) )
408                 return E_FAIL;
409         /*
410          * check subtype.
411          */
412         if ( !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB555 ) &&
413              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB565 ) &&
414              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB24 ) &&
415              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB32 ) )
416                 return E_FAIL;
417
418         /****
419          *
420          *
421         if ( !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB8 ) &&
422              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB555 ) &&
423              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB565 ) &&
424              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB24 ) &&
425              !IsEqualGUID( &pmt->subtype, &MEDIASUBTYPE_RGB32 ) )
426                 return E_FAIL;
427          *
428          ****/
429
430         pinfo = (const VIDEOINFOHEADER*)pmt->pbFormat;
431         if ( pinfo == NULL ||
432                  pinfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER) ||
433                  pinfo->bmiHeader.biWidth <= 0 ||
434                  pinfo->bmiHeader.biHeight == 0 ||
435                  pinfo->bmiHeader.biPlanes != 1 ||
436                  pinfo->bmiHeader.biCompression != 0 )
437                 return E_FAIL;
438
439         return NOERROR;
440 }
441
442 static HRESULT CVideoRendererPinImpl_Receive( CPinBaseImpl* pImpl, IMediaSample* pSample )
443 {
444         CVideoRendererPinImpl_THIS(pImpl,pin);
445         HWND hwnd;
446         BYTE*   pData = NULL;
447         LONG    lLength;
448         HRESULT hr;
449
450         TRACE( "(%p,%p)\n",This,pSample );
451
452         hwnd = This->pRender->m_hwnd;
453         if ( hwnd == (HWND)NULL ||
454                  This->pRender->m_hThread == (HWND)NULL )
455                 return E_UNEXPECTED;
456         if ( This->pRender->m_fInFlush )
457                 return S_FALSE;
458         if ( pSample == NULL )
459                 return E_POINTER;
460
461         /* FIXME - wait/skip/qualitycontrol */
462         
463
464         /* duplicate this sample. */
465         hr = IMediaSample_GetPointer(pSample,&pData);
466         if ( FAILED(hr) )
467                 return hr;
468         lLength = (LONG)IMediaSample_GetActualDataLength(pSample);
469         if ( lLength <= 0 || (lLength < (LONG)This->pRender->m_cbSampleData) )
470         {
471                 ERR( "invalid length: %ld\n", lLength );
472                 return NOERROR;
473         }
474
475         EnterCriticalSection( &This->pRender->m_csSample );
476         memcpy(This->pRender->m_pSampleData,pData,lLength);
477         This->pRender->m_bSampleIsValid = TRUE;
478         PostMessageA( hwnd, VIDRENMSG_UPDATE, 0, 0 );
479         LeaveCriticalSection( &This->pRender->m_csSample );
480
481         return NOERROR;
482 }
483
484 static HRESULT CVideoRendererPinImpl_ReceiveCanBlock( CPinBaseImpl* pImpl )
485 {
486         CVideoRendererPinImpl_THIS(pImpl,pin);
487
488         TRACE( "(%p)\n", This );
489
490         /* might block. */
491         return S_OK;
492 }
493
494 static HRESULT CVideoRendererPinImpl_EndOfStream( CPinBaseImpl* pImpl )
495 {
496         CVideoRendererPinImpl_THIS(pImpl,pin);
497
498         FIXME( "(%p)\n", This );
499
500         This->pRender->m_fInFlush = FALSE;
501
502         /* FIXME - don't notify twice until stopped or seeked. */
503         return CBaseFilterImpl_MediaEventNotify(
504                 &This->pRender->basefilter, EC_COMPLETE,
505                 (LONG_PTR)S_OK, (LONG_PTR)(IBaseFilter*)(This->pRender) );
506 }
507
508 static HRESULT CVideoRendererPinImpl_BeginFlush( CPinBaseImpl* pImpl )
509 {
510         CVideoRendererPinImpl_THIS(pImpl,pin);
511
512         FIXME( "(%p)\n", This );
513
514         This->pRender->m_fInFlush = TRUE;
515         EnterCriticalSection( &This->pRender->m_csSample );
516         This->pRender->m_bSampleIsValid = FALSE;
517         LeaveCriticalSection( &This->pRender->m_csSample );
518
519         return NOERROR;
520 }
521
522 static HRESULT CVideoRendererPinImpl_EndFlush( CPinBaseImpl* pImpl )
523 {
524         CVideoRendererPinImpl_THIS(pImpl,pin);
525
526         FIXME( "(%p)\n", This );
527
528         This->pRender->m_fInFlush = FALSE;
529
530         return NOERROR;
531 }
532
533 static HRESULT CVideoRendererPinImpl_NewSegment( CPinBaseImpl* pImpl, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double rate )
534 {
535         CVideoRendererPinImpl_THIS(pImpl,pin);
536
537         FIXME( "(%p)\n", This );
538
539         This->pRender->m_fInFlush = FALSE;
540
541         return NOERROR;
542 }
543
544
545
546
547 static const CBasePinHandlers pinhandlers =
548 {
549         CVideoRendererPinImpl_OnPreConnect, /* pOnPreConnect */
550         CVideoRendererPinImpl_OnPostConnect, /* pOnPostConnect */
551         CVideoRendererPinImpl_OnDisconnect, /* pOnDisconnect */
552         CVideoRendererPinImpl_CheckMediaType, /* pCheckMediaType */
553         NULL, /* pQualityNotify */
554         CVideoRendererPinImpl_Receive, /* pReceive */
555         CVideoRendererPinImpl_ReceiveCanBlock, /* pReceiveCanBlock */
556         CVideoRendererPinImpl_EndOfStream, /* pEndOfStream */
557         CVideoRendererPinImpl_BeginFlush, /* pBeginFlush */
558         CVideoRendererPinImpl_EndFlush, /* pEndFlush */
559         CVideoRendererPinImpl_NewSegment, /* pNewSegment */
560 };
561
562
563 /***************************************************************************
564  *
565  *      new/delete CVideoRendererImpl
566  *
567  */
568
569 /* can I use offsetof safely? - FIXME? */
570 static QUARTZ_IFEntry FilterIFEntries[] =
571 {
572   { &IID_IPersist, offsetof(CVideoRendererImpl,basefilter)-offsetof(CVideoRendererImpl,unk) },
573   { &IID_IMediaFilter, offsetof(CVideoRendererImpl,basefilter)-offsetof(CVideoRendererImpl,unk) },
574   { &IID_IBaseFilter, offsetof(CVideoRendererImpl,basefilter)-offsetof(CVideoRendererImpl,unk) },
575   { &IID_IBasicVideo, offsetof(CVideoRendererImpl,basvid)-offsetof(CVideoRendererImpl,unk) },
576   { &IID_IBasicVideo2, offsetof(CVideoRendererImpl,basvid)-offsetof(CVideoRendererImpl,unk) },
577   { &IID_IVideoWindow, offsetof(CVideoRendererImpl,vidwin)-offsetof(CVideoRendererImpl,unk) },
578 };
579
580 static void QUARTZ_DestroyVideoRenderer(IUnknown* punk)
581 {
582         CVideoRendererImpl_THIS(punk,unk);
583
584         TRACE( "(%p)\n", This );
585         CVideoRendererImpl_OnInactive(&This->basefilter);
586         VIDREN_EndThread(This);
587
588         if ( This->pPin != NULL )
589         {
590                 IUnknown_Release(This->pPin->unk.punkControl);
591                 This->pPin = NULL;
592         }
593
594         CVideoRendererImpl_UninitIBasicVideo2(This);
595         CVideoRendererImpl_UninitIVideoWindow(This);
596         CBaseFilterImpl_UninitIBaseFilter(&This->basefilter);
597
598         DeleteCriticalSection( &This->m_csSample );
599 }
600
601 HRESULT QUARTZ_CreateVideoRenderer(IUnknown* punkOuter,void** ppobj)
602 {
603         CVideoRendererImpl*     This = NULL;
604         HRESULT hr;
605
606         TRACE("(%p,%p)\n",punkOuter,ppobj);
607
608         This = (CVideoRendererImpl*)
609                 QUARTZ_AllocObj( sizeof(CVideoRendererImpl) );
610         if ( This == NULL )
611                 return E_OUTOFMEMORY;
612         This->pPin = NULL;
613         This->m_fInFlush = FALSE;
614
615         This->m_hEventInit = (HANDLE)NULL;
616         This->m_hThread = (HANDLE)NULL;
617         This->m_hwnd = (HWND)NULL;
618         This->m_bSampleIsValid = FALSE;
619         This->m_pSampleData = NULL;
620         This->m_cbSampleData = 0;
621
622         QUARTZ_IUnkInit( &This->unk, punkOuter );
623
624         hr = CBaseFilterImpl_InitIBaseFilter(
625                 &This->basefilter,
626                 This->unk.punkControl,
627                 &CLSID_VideoRenderer,
628                 QUARTZ_VideoRenderer_Name,
629                 &filterhandlers );
630         if ( SUCCEEDED(hr) )
631         {
632                 hr = CVideoRendererImpl_InitIBasicVideo2(This);
633                 if ( SUCCEEDED(hr) )
634                 {
635                         hr = CVideoRendererImpl_InitIVideoWindow(This);
636                         if ( FAILED(hr) )
637                         {
638                                 CVideoRendererImpl_UninitIBasicVideo2(This);
639                         }
640                 }
641                 if ( FAILED(hr) )
642                 {
643                         CBaseFilterImpl_UninitIBaseFilter(&This->basefilter);
644                 }
645         }
646
647         if ( FAILED(hr) )
648         {
649                 QUARTZ_FreeObj(This);
650                 return hr;
651         }
652
653         This->unk.pEntries = FilterIFEntries;
654         This->unk.dwEntries = sizeof(FilterIFEntries)/sizeof(FilterIFEntries[0]);
655         This->unk.pOnFinalRelease = QUARTZ_DestroyVideoRenderer;
656
657         hr = QUARTZ_CreateVideoRendererPin(
658                 This,
659                 &This->basefilter.csFilter,
660                 &This->pPin );
661         if ( SUCCEEDED(hr) )
662                 hr = QUARTZ_CompList_AddComp(
663                         This->basefilter.pInPins,
664                         (IUnknown*)&This->pPin->pin,
665                         NULL, 0 );
666         if ( FAILED(hr) )
667         {
668                 IUnknown_Release( This->unk.punkControl );
669                 return hr;
670         }
671
672         InitializeCriticalSection( &This->m_csSample );
673
674         *ppobj = (void*)&(This->unk);
675
676         return S_OK;
677 }
678
679 /***************************************************************************
680  *
681  *      new/delete CVideoRendererPinImpl
682  *
683  */
684
685 /* can I use offsetof safely? - FIXME? */
686 static QUARTZ_IFEntry PinIFEntries[] =
687 {
688   { &IID_IPin, offsetof(CVideoRendererPinImpl,pin)-offsetof(CVideoRendererPinImpl,unk) },
689   { &IID_IMemInputPin, offsetof(CVideoRendererPinImpl,meminput)-offsetof(CVideoRendererPinImpl,unk) },
690 };
691
692 static void QUARTZ_DestroyVideoRendererPin(IUnknown* punk)
693 {
694         CVideoRendererPinImpl_THIS(punk,unk);
695
696         TRACE( "(%p)\n", This );
697
698         CPinBaseImpl_UninitIPin( &This->pin );
699         CMemInputPinBaseImpl_UninitIMemInputPin( &This->meminput );
700 }
701
702 HRESULT QUARTZ_CreateVideoRendererPin(
703         CVideoRendererImpl* pFilter,
704         CRITICAL_SECTION* pcsPin,
705         CVideoRendererPinImpl** ppPin)
706 {
707         CVideoRendererPinImpl*  This = NULL;
708         HRESULT hr;
709
710         TRACE("(%p,%p,%p)\n",pFilter,pcsPin,ppPin);
711
712         This = (CVideoRendererPinImpl*)
713                 QUARTZ_AllocObj( sizeof(CVideoRendererPinImpl) );
714         if ( This == NULL )
715                 return E_OUTOFMEMORY;
716
717         QUARTZ_IUnkInit( &This->unk, NULL );
718         This->pRender = pFilter;
719
720         hr = CPinBaseImpl_InitIPin(
721                 &This->pin,
722                 This->unk.punkControl,
723                 pcsPin,
724                 &pFilter->basefilter,
725                 QUARTZ_VideoRendererPin_Name,
726                 FALSE,
727                 &pinhandlers );
728
729         if ( SUCCEEDED(hr) )
730         {
731                 hr = CMemInputPinBaseImpl_InitIMemInputPin(
732                         &This->meminput,
733                         This->unk.punkControl,
734                         &This->pin );
735                 if ( FAILED(hr) )
736                 {
737                         CPinBaseImpl_UninitIPin( &This->pin );
738                 }
739         }
740
741         if ( FAILED(hr) )
742         {
743                 QUARTZ_FreeObj(This);
744                 return hr;
745         }
746
747         This->unk.pEntries = PinIFEntries;
748         This->unk.dwEntries = sizeof(PinIFEntries)/sizeof(PinIFEntries[0]);
749         This->unk.pOnFinalRelease = QUARTZ_DestroyVideoRendererPin;
750
751         *ppPin = This;
752
753         TRACE("returned successfully.\n");
754
755         return S_OK;
756 }
757
758 /***************************************************************************
759  *
760  *      CVideoRendererImpl::IBasicVideo2
761  *
762  */
763
764
765 static HRESULT WINAPI
766 IBasicVideo2_fnQueryInterface(IBasicVideo2* iface,REFIID riid,void** ppobj)
767 {
768         CVideoRendererImpl_THIS(iface,basvid);
769
770         TRACE("(%p)->()\n",This);
771
772         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
773 }
774
775 static ULONG WINAPI
776 IBasicVideo2_fnAddRef(IBasicVideo2* iface)
777 {
778         CVideoRendererImpl_THIS(iface,basvid);
779
780         TRACE("(%p)->()\n",This);
781
782         return IUnknown_AddRef(This->unk.punkControl);
783 }
784
785 static ULONG WINAPI
786 IBasicVideo2_fnRelease(IBasicVideo2* iface)
787 {
788         CVideoRendererImpl_THIS(iface,basvid);
789
790         TRACE("(%p)->()\n",This);
791
792         return IUnknown_Release(This->unk.punkControl);
793 }
794
795 static HRESULT WINAPI
796 IBasicVideo2_fnGetTypeInfoCount(IBasicVideo2* iface,UINT* pcTypeInfo)
797 {
798         CVideoRendererImpl_THIS(iface,basvid);
799
800         FIXME("(%p)->()\n",This);
801
802         return E_NOTIMPL;
803 }
804
805 static HRESULT WINAPI
806 IBasicVideo2_fnGetTypeInfo(IBasicVideo2* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
807 {
808         CVideoRendererImpl_THIS(iface,basvid);
809
810         FIXME("(%p)->()\n",This);
811
812         return E_NOTIMPL;
813 }
814
815 static HRESULT WINAPI
816 IBasicVideo2_fnGetIDsOfNames(IBasicVideo2* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
817 {
818         CVideoRendererImpl_THIS(iface,basvid);
819
820         FIXME("(%p)->()\n",This);
821
822         return E_NOTIMPL;
823 }
824
825 static HRESULT WINAPI
826 IBasicVideo2_fnInvoke(IBasicVideo2* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
827 {
828         CVideoRendererImpl_THIS(iface,basvid);
829
830         FIXME("(%p)->()\n",This);
831
832         return E_NOTIMPL;
833 }
834
835
836 static HRESULT WINAPI
837 IBasicVideo2_fnget_AvgTimePerFrame(IBasicVideo2* iface,REFTIME* prefTime)
838 {
839         CVideoRendererImpl_THIS(iface,basvid);
840
841         FIXME("(%p)->()\n",This);
842
843         return E_NOTIMPL;
844 }
845
846 static HRESULT WINAPI
847 IBasicVideo2_fnget_BitRate(IBasicVideo2* iface,long* plRate)
848 {
849         CVideoRendererImpl_THIS(iface,basvid);
850
851         FIXME("(%p)->()\n",This);
852
853         return E_NOTIMPL;
854 }
855
856 static HRESULT WINAPI
857 IBasicVideo2_fnget_BitErrorRate(IBasicVideo2* iface,long* plRate)
858 {
859         CVideoRendererImpl_THIS(iface,basvid);
860
861         FIXME("(%p)->()\n",This);
862
863         return E_NOTIMPL;
864 }
865
866 static HRESULT WINAPI
867 IBasicVideo2_fnget_VideoWidth(IBasicVideo2* iface,long* plWidth)
868 {
869         CVideoRendererImpl_THIS(iface,basvid);
870
871         FIXME("(%p)->()\n",This);
872
873         return E_NOTIMPL;
874 }
875
876 static HRESULT WINAPI
877 IBasicVideo2_fnget_VideoHeight(IBasicVideo2* iface,long* plHeight)
878 {
879         CVideoRendererImpl_THIS(iface,basvid);
880
881         FIXME("(%p)->()\n",This);
882
883         return E_NOTIMPL;
884 }
885
886 static HRESULT WINAPI
887 IBasicVideo2_fnput_SourceLeft(IBasicVideo2* iface,long lLeft)
888 {
889         CVideoRendererImpl_THIS(iface,basvid);
890
891         FIXME("(%p)->()\n",This);
892
893         return E_NOTIMPL;
894 }
895
896 static HRESULT WINAPI
897 IBasicVideo2_fnget_SourceLeft(IBasicVideo2* iface,long* plLeft)
898 {
899         CVideoRendererImpl_THIS(iface,basvid);
900
901         FIXME("(%p)->()\n",This);
902
903         return E_NOTIMPL;
904 }
905
906 static HRESULT WINAPI
907 IBasicVideo2_fnput_SourceWidth(IBasicVideo2* iface,long lWidth)
908 {
909         CVideoRendererImpl_THIS(iface,basvid);
910
911         FIXME("(%p)->()\n",This);
912
913         return E_NOTIMPL;
914 }
915
916 static HRESULT WINAPI
917 IBasicVideo2_fnget_SourceWidth(IBasicVideo2* iface,long* plWidth)
918 {
919         CVideoRendererImpl_THIS(iface,basvid);
920
921         FIXME("(%p)->()\n",This);
922
923         return E_NOTIMPL;
924 }
925
926 static HRESULT WINAPI
927 IBasicVideo2_fnput_SourceTop(IBasicVideo2* iface,long lTop)
928 {
929         CVideoRendererImpl_THIS(iface,basvid);
930
931         FIXME("(%p)->()\n",This);
932
933         return E_NOTIMPL;
934 }
935
936 static HRESULT WINAPI
937 IBasicVideo2_fnget_SourceTop(IBasicVideo2* iface,long* plTop)
938 {
939         CVideoRendererImpl_THIS(iface,basvid);
940
941         FIXME("(%p)->()\n",This);
942
943         return E_NOTIMPL;
944 }
945
946 static HRESULT WINAPI
947 IBasicVideo2_fnput_SourceHeight(IBasicVideo2* iface,long lHeight)
948 {
949         CVideoRendererImpl_THIS(iface,basvid);
950
951         FIXME("(%p)->()\n",This);
952
953         return E_NOTIMPL;
954 }
955
956 static HRESULT WINAPI
957 IBasicVideo2_fnget_SourceHeight(IBasicVideo2* iface,long* plHeight)
958 {
959         CVideoRendererImpl_THIS(iface,basvid);
960
961         FIXME("(%p)->()\n",This);
962
963         return E_NOTIMPL;
964 }
965
966 static HRESULT WINAPI
967 IBasicVideo2_fnput_DestinationLeft(IBasicVideo2* iface,long lLeft)
968 {
969         CVideoRendererImpl_THIS(iface,basvid);
970
971         FIXME("(%p)->()\n",This);
972
973         return E_NOTIMPL;
974 }
975
976 static HRESULT WINAPI
977 IBasicVideo2_fnget_DestinationLeft(IBasicVideo2* iface,long* plLeft)
978 {
979         CVideoRendererImpl_THIS(iface,basvid);
980
981         FIXME("(%p)->()\n",This);
982
983         return E_NOTIMPL;
984 }
985
986 static HRESULT WINAPI
987 IBasicVideo2_fnput_DestinationWidth(IBasicVideo2* iface,long lWidth)
988 {
989         CVideoRendererImpl_THIS(iface,basvid);
990
991         FIXME("(%p)->()\n",This);
992
993         return E_NOTIMPL;
994 }
995
996 static HRESULT WINAPI
997 IBasicVideo2_fnget_DestinationWidth(IBasicVideo2* iface,long* plWidth)
998 {
999         CVideoRendererImpl_THIS(iface,basvid);
1000
1001         FIXME("(%p)->()\n",This);
1002
1003         return E_NOTIMPL;
1004 }
1005
1006 static HRESULT WINAPI
1007 IBasicVideo2_fnput_DestinationTop(IBasicVideo2* iface,long lTop)
1008 {
1009         CVideoRendererImpl_THIS(iface,basvid);
1010
1011         FIXME("(%p)->()\n",This);
1012
1013         return E_NOTIMPL;
1014 }
1015
1016 static HRESULT WINAPI
1017 IBasicVideo2_fnget_DestinationTop(IBasicVideo2* iface,long* plTop)
1018 {
1019         CVideoRendererImpl_THIS(iface,basvid);
1020
1021         FIXME("(%p)->()\n",This);
1022
1023         return E_NOTIMPL;
1024 }
1025
1026 static HRESULT WINAPI
1027 IBasicVideo2_fnput_DestinationHeight(IBasicVideo2* iface,long lHeight)
1028 {
1029         CVideoRendererImpl_THIS(iface,basvid);
1030
1031         FIXME("(%p)->()\n",This);
1032
1033         return E_NOTIMPL;
1034 }
1035
1036 static HRESULT WINAPI
1037 IBasicVideo2_fnget_DestinationHeight(IBasicVideo2* iface,long* plHeight)
1038 {
1039         CVideoRendererImpl_THIS(iface,basvid);
1040
1041         FIXME("(%p)->()\n",This);
1042
1043         return E_NOTIMPL;
1044 }
1045
1046 static HRESULT WINAPI
1047 IBasicVideo2_fnSetSourcePosition(IBasicVideo2* iface,long lLeft,long lTop,long lWidth,long lHeight)
1048 {
1049         CVideoRendererImpl_THIS(iface,basvid);
1050
1051         FIXME("(%p)->()\n",This);
1052
1053         return E_NOTIMPL;
1054 }
1055
1056 static HRESULT WINAPI
1057 IBasicVideo2_fnGetSourcePosition(IBasicVideo2* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
1058 {
1059         CVideoRendererImpl_THIS(iface,basvid);
1060
1061         FIXME("(%p)->()\n",This);
1062
1063         return E_NOTIMPL;
1064 }
1065
1066 static HRESULT WINAPI
1067 IBasicVideo2_fnSetDefaultSourcePosition(IBasicVideo2* iface)
1068 {
1069         CVideoRendererImpl_THIS(iface,basvid);
1070
1071         FIXME("(%p)->()\n",This);
1072
1073         return E_NOTIMPL;
1074 }
1075
1076 static HRESULT WINAPI
1077 IBasicVideo2_fnSetDestinationPosition(IBasicVideo2* iface,long lLeft,long lTop,long lWidth,long lHeight)
1078 {
1079         CVideoRendererImpl_THIS(iface,basvid);
1080
1081         FIXME("(%p)->()\n",This);
1082
1083         return E_NOTIMPL;
1084 }
1085
1086 static HRESULT WINAPI
1087 IBasicVideo2_fnGetDestinationPosition(IBasicVideo2* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
1088 {
1089         CVideoRendererImpl_THIS(iface,basvid);
1090
1091         FIXME("(%p)->()\n",This);
1092
1093         return E_NOTIMPL;
1094 }
1095
1096 static HRESULT WINAPI
1097 IBasicVideo2_fnSetDefaultDestinationPosition(IBasicVideo2* iface)
1098 {
1099         CVideoRendererImpl_THIS(iface,basvid);
1100
1101         FIXME("(%p)->()\n",This);
1102
1103         return E_NOTIMPL;
1104 }
1105
1106 static HRESULT WINAPI
1107 IBasicVideo2_fnGetVideoSize(IBasicVideo2* iface,long* plWidth,long* plHeight)
1108 {
1109         CVideoRendererImpl_THIS(iface,basvid);
1110
1111         FIXME("(%p)->()\n",This);
1112
1113         return E_NOTIMPL;
1114 }
1115
1116 static HRESULT WINAPI
1117 IBasicVideo2_fnGetVideoPaletteEntries(IBasicVideo2* iface,long lStart,long lCount,long* plRet,long* plPaletteEntry)
1118 {
1119         CVideoRendererImpl_THIS(iface,basvid);
1120
1121         FIXME("(%p)->()\n",This);
1122
1123         return E_NOTIMPL;
1124 }
1125
1126 static HRESULT WINAPI
1127 IBasicVideo2_fnGetCurrentImage(IBasicVideo2* iface,long* plBufferSize,long* plDIBBuffer)
1128 {
1129         CVideoRendererImpl_THIS(iface,basvid);
1130
1131         FIXME("(%p)->()\n",This);
1132
1133         return E_NOTIMPL;
1134 }
1135
1136 static HRESULT WINAPI
1137 IBasicVideo2_fnIsUsingDefaultSource(IBasicVideo2* iface)
1138 {
1139         CVideoRendererImpl_THIS(iface,basvid);
1140
1141         FIXME("(%p)->()\n",This);
1142
1143         return E_NOTIMPL;
1144 }
1145
1146 static HRESULT WINAPI
1147 IBasicVideo2_fnIsUsingDefaultDestination(IBasicVideo2* iface)
1148 {
1149         CVideoRendererImpl_THIS(iface,basvid);
1150
1151         FIXME("(%p)->()\n",This);
1152
1153         return E_NOTIMPL;
1154 }
1155
1156 static HRESULT WINAPI
1157 IBasicVideo2_fnGetPreferredAspectRatio(IBasicVideo2* iface,long* plRateX,long* plRateY)
1158 {
1159         CVideoRendererImpl_THIS(iface,basvid);
1160
1161         FIXME("(%p)->()\n",This);
1162
1163         return E_NOTIMPL;
1164 }
1165
1166
1167
1168
1169 static ICOM_VTABLE(IBasicVideo2) ibasicvideo =
1170 {
1171         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1172         /* IUnknown fields */
1173         IBasicVideo2_fnQueryInterface,
1174         IBasicVideo2_fnAddRef,
1175         IBasicVideo2_fnRelease,
1176         /* IDispatch fields */
1177         IBasicVideo2_fnGetTypeInfoCount,
1178         IBasicVideo2_fnGetTypeInfo,
1179         IBasicVideo2_fnGetIDsOfNames,
1180         IBasicVideo2_fnInvoke,
1181         /* IBasicVideo fields */
1182         IBasicVideo2_fnget_AvgTimePerFrame,
1183         IBasicVideo2_fnget_BitRate,
1184         IBasicVideo2_fnget_BitErrorRate,
1185         IBasicVideo2_fnget_VideoWidth,
1186         IBasicVideo2_fnget_VideoHeight,
1187         IBasicVideo2_fnput_SourceLeft,
1188         IBasicVideo2_fnget_SourceLeft,
1189         IBasicVideo2_fnput_SourceWidth,
1190         IBasicVideo2_fnget_SourceWidth,
1191         IBasicVideo2_fnput_SourceTop,
1192         IBasicVideo2_fnget_SourceTop,
1193         IBasicVideo2_fnput_SourceHeight,
1194         IBasicVideo2_fnget_SourceHeight,
1195         IBasicVideo2_fnput_DestinationLeft,
1196         IBasicVideo2_fnget_DestinationLeft,
1197         IBasicVideo2_fnput_DestinationWidth,
1198         IBasicVideo2_fnget_DestinationWidth,
1199         IBasicVideo2_fnput_DestinationTop,
1200         IBasicVideo2_fnget_DestinationTop,
1201         IBasicVideo2_fnput_DestinationHeight,
1202         IBasicVideo2_fnget_DestinationHeight,
1203         IBasicVideo2_fnSetSourcePosition,
1204         IBasicVideo2_fnGetSourcePosition,
1205         IBasicVideo2_fnSetDefaultSourcePosition,
1206         IBasicVideo2_fnSetDestinationPosition,
1207         IBasicVideo2_fnGetDestinationPosition,
1208         IBasicVideo2_fnSetDefaultDestinationPosition,
1209         IBasicVideo2_fnGetVideoSize,
1210         IBasicVideo2_fnGetVideoPaletteEntries,
1211         IBasicVideo2_fnGetCurrentImage,
1212         IBasicVideo2_fnIsUsingDefaultSource,
1213         IBasicVideo2_fnIsUsingDefaultDestination,
1214         /* IBasicVideo2 fields */
1215         IBasicVideo2_fnGetPreferredAspectRatio,
1216 };
1217
1218
1219 HRESULT CVideoRendererImpl_InitIBasicVideo2( CVideoRendererImpl* This )
1220 {
1221         TRACE("(%p)\n",This);
1222         ICOM_VTBL(&This->basvid) = &ibasicvideo;
1223
1224         return NOERROR;
1225 }
1226
1227 void CVideoRendererImpl_UninitIBasicVideo2( CVideoRendererImpl* This )
1228 {
1229         TRACE("(%p)\n",This);
1230 }
1231
1232 /***************************************************************************
1233  *
1234  *      CVideoRendererImpl::IVideoWindow
1235  *
1236  */
1237
1238
1239 static HRESULT WINAPI
1240 IVideoWindow_fnQueryInterface(IVideoWindow* iface,REFIID riid,void** ppobj)
1241 {
1242         CVideoRendererImpl_THIS(iface,vidwin);
1243
1244         TRACE("(%p)->()\n",This);
1245
1246         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
1247 }
1248
1249 static ULONG WINAPI
1250 IVideoWindow_fnAddRef(IVideoWindow* iface)
1251 {
1252         CVideoRendererImpl_THIS(iface,vidwin);
1253
1254         TRACE("(%p)->()\n",This);
1255
1256         return IUnknown_AddRef(This->unk.punkControl);
1257 }
1258
1259 static ULONG WINAPI
1260 IVideoWindow_fnRelease(IVideoWindow* iface)
1261 {
1262         CVideoRendererImpl_THIS(iface,vidwin);
1263
1264         TRACE("(%p)->()\n",This);
1265
1266         return IUnknown_Release(This->unk.punkControl);
1267 }
1268
1269 static HRESULT WINAPI
1270 IVideoWindow_fnGetTypeInfoCount(IVideoWindow* iface,UINT* pcTypeInfo)
1271 {
1272         CVideoRendererImpl_THIS(iface,vidwin);
1273
1274         FIXME("(%p)->()\n",This);
1275
1276         return E_NOTIMPL;
1277 }
1278
1279 static HRESULT WINAPI
1280 IVideoWindow_fnGetTypeInfo(IVideoWindow* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
1281 {
1282         CVideoRendererImpl_THIS(iface,vidwin);
1283
1284         FIXME("(%p)->()\n",This);
1285
1286         return E_NOTIMPL;
1287 }
1288
1289 static HRESULT WINAPI
1290 IVideoWindow_fnGetIDsOfNames(IVideoWindow* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
1291 {
1292         CVideoRendererImpl_THIS(iface,vidwin);
1293
1294         FIXME("(%p)->()\n",This);
1295
1296         return E_NOTIMPL;
1297 }
1298
1299 static HRESULT WINAPI
1300 IVideoWindow_fnInvoke(IVideoWindow* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1301 {
1302         CVideoRendererImpl_THIS(iface,vidwin);
1303
1304         FIXME("(%p)->()\n",This);
1305
1306         return E_NOTIMPL;
1307 }
1308
1309
1310
1311 static HRESULT WINAPI
1312 IVideoWindow_fnput_Caption(IVideoWindow* iface,BSTR strCaption)
1313 {
1314         CVideoRendererImpl_THIS(iface,vidwin);
1315
1316         FIXME("(%p)->()\n",This);
1317
1318         return E_NOTIMPL;
1319 }
1320
1321 static HRESULT WINAPI
1322 IVideoWindow_fnget_Caption(IVideoWindow* iface,BSTR* pstrCaption)
1323 {
1324         CVideoRendererImpl_THIS(iface,vidwin);
1325
1326         FIXME("(%p)->()\n",This);
1327
1328         return E_NOTIMPL;
1329 }
1330
1331 static HRESULT WINAPI
1332 IVideoWindow_fnput_WindowStyle(IVideoWindow* iface,long lStyle)
1333 {
1334         CVideoRendererImpl_THIS(iface,vidwin);
1335
1336         FIXME("(%p)->()\n",This);
1337
1338         return E_NOTIMPL;
1339 }
1340
1341 static HRESULT WINAPI
1342 IVideoWindow_fnget_WindowStyle(IVideoWindow* iface,long* plStyle)
1343 {
1344         CVideoRendererImpl_THIS(iface,vidwin);
1345
1346         FIXME("(%p)->()\n",This);
1347
1348         return E_NOTIMPL;
1349 }
1350
1351 static HRESULT WINAPI
1352 IVideoWindow_fnput_WindowStyleEx(IVideoWindow* iface,long lExStyle)
1353 {
1354         CVideoRendererImpl_THIS(iface,vidwin);
1355
1356         FIXME("(%p)->()\n",This);
1357
1358         return E_NOTIMPL;
1359 }
1360
1361 static HRESULT WINAPI
1362 IVideoWindow_fnget_WindowStyleEx(IVideoWindow* iface,long* plExStyle)
1363 {
1364         CVideoRendererImpl_THIS(iface,vidwin);
1365
1366         FIXME("(%p)->()\n",This);
1367
1368         return E_NOTIMPL;
1369 }
1370
1371 static HRESULT WINAPI
1372 IVideoWindow_fnput_AutoShow(IVideoWindow* iface,long lAutoShow)
1373 {
1374         CVideoRendererImpl_THIS(iface,vidwin);
1375
1376         FIXME("(%p)->()\n",This);
1377
1378         return E_NOTIMPL;
1379 }
1380
1381 static HRESULT WINAPI
1382 IVideoWindow_fnget_AutoShow(IVideoWindow* iface,long* plAutoShow)
1383 {
1384         CVideoRendererImpl_THIS(iface,vidwin);
1385
1386         FIXME("(%p)->()\n",This);
1387
1388         return E_NOTIMPL;
1389 }
1390
1391 static HRESULT WINAPI
1392 IVideoWindow_fnput_WindowState(IVideoWindow* iface,long lState)
1393 {
1394         CVideoRendererImpl_THIS(iface,vidwin);
1395
1396         FIXME("(%p)->()\n",This);
1397
1398         return E_NOTIMPL;
1399 }
1400
1401 static HRESULT WINAPI
1402 IVideoWindow_fnget_WindowState(IVideoWindow* iface,long* plState)
1403 {
1404         CVideoRendererImpl_THIS(iface,vidwin);
1405
1406         FIXME("(%p)->()\n",This);
1407
1408         return E_NOTIMPL;
1409 }
1410
1411 static HRESULT WINAPI
1412 IVideoWindow_fnput_BackgroundPalette(IVideoWindow* iface,long lBackPal)
1413 {
1414         CVideoRendererImpl_THIS(iface,vidwin);
1415
1416         FIXME("(%p)->()\n",This);
1417
1418         return E_NOTIMPL;
1419 }
1420
1421 static HRESULT WINAPI
1422 IVideoWindow_fnget_BackgroundPalette(IVideoWindow* iface,long* plBackPal)
1423 {
1424         CVideoRendererImpl_THIS(iface,vidwin);
1425
1426         FIXME("(%p)->()\n",This);
1427
1428         return E_NOTIMPL;
1429 }
1430
1431 static HRESULT WINAPI
1432 IVideoWindow_fnput_Visible(IVideoWindow* iface,long lVisible)
1433 {
1434         CVideoRendererImpl_THIS(iface,vidwin);
1435
1436         FIXME("(%p)->()\n",This);
1437
1438         return E_NOTIMPL;
1439 }
1440
1441 static HRESULT WINAPI
1442 IVideoWindow_fnget_Visible(IVideoWindow* iface,long* plVisible)
1443 {
1444         CVideoRendererImpl_THIS(iface,vidwin);
1445
1446         FIXME("(%p)->()\n",This);
1447
1448         return E_NOTIMPL;
1449 }
1450
1451 static HRESULT WINAPI
1452 IVideoWindow_fnput_Left(IVideoWindow* iface,long lLeft)
1453 {
1454         CVideoRendererImpl_THIS(iface,vidwin);
1455
1456         FIXME("(%p)->()\n",This);
1457
1458         return E_NOTIMPL;
1459 }
1460
1461 static HRESULT WINAPI
1462 IVideoWindow_fnget_Left(IVideoWindow* iface,long* plLeft)
1463 {
1464         CVideoRendererImpl_THIS(iface,vidwin);
1465
1466         FIXME("(%p)->()\n",This);
1467
1468         return E_NOTIMPL;
1469 }
1470
1471 static HRESULT WINAPI
1472 IVideoWindow_fnput_Width(IVideoWindow* iface,long lWidth)
1473 {
1474         CVideoRendererImpl_THIS(iface,vidwin);
1475
1476         FIXME("(%p)->()\n",This);
1477
1478         return E_NOTIMPL;
1479 }
1480
1481 static HRESULT WINAPI
1482 IVideoWindow_fnget_Width(IVideoWindow* iface,long* plWidth)
1483 {
1484         CVideoRendererImpl_THIS(iface,vidwin);
1485
1486         FIXME("(%p)->()\n",This);
1487
1488         return E_NOTIMPL;
1489 }
1490
1491 static HRESULT WINAPI
1492 IVideoWindow_fnput_Top(IVideoWindow* iface,long lTop)
1493 {
1494         CVideoRendererImpl_THIS(iface,vidwin);
1495
1496         FIXME("(%p)->()\n",This);
1497
1498         return E_NOTIMPL;
1499 }
1500
1501 static HRESULT WINAPI
1502 IVideoWindow_fnget_Top(IVideoWindow* iface,long* plTop)
1503 {
1504         CVideoRendererImpl_THIS(iface,vidwin);
1505
1506         FIXME("(%p)->()\n",This);
1507
1508         return E_NOTIMPL;
1509 }
1510
1511 static HRESULT WINAPI
1512 IVideoWindow_fnput_Height(IVideoWindow* iface,long lHeight)
1513 {
1514         CVideoRendererImpl_THIS(iface,vidwin);
1515
1516         FIXME("(%p)->()\n",This);
1517
1518         return E_NOTIMPL;
1519 }
1520
1521 static HRESULT WINAPI
1522 IVideoWindow_fnget_Height(IVideoWindow* iface,long* plHeight)
1523 {
1524         CVideoRendererImpl_THIS(iface,vidwin);
1525
1526         FIXME("(%p)->()\n",This);
1527
1528         return E_NOTIMPL;
1529 }
1530
1531 static HRESULT WINAPI
1532 IVideoWindow_fnput_Owner(IVideoWindow* iface,OAHWND hwnd)
1533 {
1534         CVideoRendererImpl_THIS(iface,vidwin);
1535
1536         FIXME("(%p)->()\n",This);
1537
1538         return E_NOTIMPL;
1539 }
1540
1541 static HRESULT WINAPI
1542 IVideoWindow_fnget_Owner(IVideoWindow* iface,OAHWND* phwnd)
1543 {
1544         CVideoRendererImpl_THIS(iface,vidwin);
1545
1546         FIXME("(%p)->()\n",This);
1547
1548         return E_NOTIMPL;
1549 }
1550
1551 static HRESULT WINAPI
1552 IVideoWindow_fnput_MessageDrain(IVideoWindow* iface,OAHWND hwnd)
1553 {
1554         CVideoRendererImpl_THIS(iface,vidwin);
1555
1556         FIXME("(%p)->()\n",This);
1557
1558         return E_NOTIMPL;
1559 }
1560
1561 static HRESULT WINAPI
1562 IVideoWindow_fnget_MessageDrain(IVideoWindow* iface,OAHWND* phwnd)
1563 {
1564         CVideoRendererImpl_THIS(iface,vidwin);
1565
1566         FIXME("(%p)->()\n",This);
1567
1568         return E_NOTIMPL;
1569 }
1570
1571 static HRESULT WINAPI
1572 IVideoWindow_fnget_BorderColor(IVideoWindow* iface,long* plColor)
1573 {
1574         CVideoRendererImpl_THIS(iface,vidwin);
1575
1576         FIXME("(%p)->()\n",This);
1577
1578         return E_NOTIMPL;
1579 }
1580
1581 static HRESULT WINAPI
1582 IVideoWindow_fnput_BorderColor(IVideoWindow* iface,long lColor)
1583 {
1584         CVideoRendererImpl_THIS(iface,vidwin);
1585
1586         FIXME("(%p)->()\n",This);
1587
1588         return E_NOTIMPL;
1589 }
1590
1591 static HRESULT WINAPI
1592 IVideoWindow_fnget_FullScreenMode(IVideoWindow* iface,long* plMode)
1593 {
1594         CVideoRendererImpl_THIS(iface,vidwin);
1595
1596         FIXME("(%p)->()\n",This);
1597
1598         return E_NOTIMPL;
1599 }
1600
1601 static HRESULT WINAPI
1602 IVideoWindow_fnput_FullScreenMode(IVideoWindow* iface,long lMode)
1603 {
1604         CVideoRendererImpl_THIS(iface,vidwin);
1605
1606         FIXME("(%p)->()\n",This);
1607
1608         return E_NOTIMPL;
1609 }
1610
1611 static HRESULT WINAPI
1612 IVideoWindow_fnSetWindowForeground(IVideoWindow* iface,long lFocus)
1613 {
1614         CVideoRendererImpl_THIS(iface,vidwin);
1615
1616         FIXME("(%p)->()\n",This);
1617
1618         return E_NOTIMPL;
1619 }
1620
1621 static HRESULT WINAPI
1622 IVideoWindow_fnNotifyOwnerMessage(IVideoWindow* iface,OAHWND hwnd,long message,LONG_PTR wParam,LONG_PTR lParam)
1623 {
1624         CVideoRendererImpl_THIS(iface,vidwin);
1625
1626         FIXME("(%p)->()\n",This);
1627
1628         return E_NOTIMPL;
1629 }
1630
1631 static HRESULT WINAPI
1632 IVideoWindow_fnSetWindowPosition(IVideoWindow* iface,long lLeft,long lTop,long lWidth,long lHeight)
1633 {
1634         CVideoRendererImpl_THIS(iface,vidwin);
1635
1636         FIXME("(%p)->()\n",This);
1637
1638         return E_NOTIMPL;
1639 }
1640
1641 static HRESULT WINAPI
1642 IVideoWindow_fnGetWindowPosition(IVideoWindow* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
1643 {
1644         CVideoRendererImpl_THIS(iface,vidwin);
1645
1646         FIXME("(%p)->()\n",This);
1647
1648         return E_NOTIMPL;
1649 }
1650
1651 static HRESULT WINAPI
1652 IVideoWindow_fnGetMinIdealImageSize(IVideoWindow* iface,long* plWidth,long* plHeight)
1653 {
1654         CVideoRendererImpl_THIS(iface,vidwin);
1655
1656         FIXME("(%p)->()\n",This);
1657
1658         return E_NOTIMPL;
1659 }
1660
1661 static HRESULT WINAPI
1662 IVideoWindow_fnGetMaxIdealImageSize(IVideoWindow* iface,long* plWidth,long* plHeight)
1663 {
1664         CVideoRendererImpl_THIS(iface,vidwin);
1665
1666         FIXME("(%p)->()\n",This);
1667
1668         return E_NOTIMPL;
1669 }
1670
1671 static HRESULT WINAPI
1672 IVideoWindow_fnGetRestorePosition(IVideoWindow* iface,long* plLeft,long* plTop,long* plWidth,long* plHeight)
1673 {
1674         CVideoRendererImpl_THIS(iface,vidwin);
1675
1676         FIXME("(%p)->()\n",This);
1677
1678         return E_NOTIMPL;
1679 }
1680
1681 static HRESULT WINAPI
1682 IVideoWindow_fnHideCursor(IVideoWindow* iface,long lHide)
1683 {
1684         CVideoRendererImpl_THIS(iface,vidwin);
1685
1686         FIXME("(%p)->()\n",This);
1687
1688         return E_NOTIMPL;
1689 }
1690
1691 static HRESULT WINAPI
1692 IVideoWindow_fnIsCursorHidden(IVideoWindow* iface,long* plHide)
1693 {
1694         CVideoRendererImpl_THIS(iface,vidwin);
1695
1696         FIXME("(%p)->()\n",This);
1697
1698         return E_NOTIMPL;
1699 }
1700
1701
1702
1703
1704 static ICOM_VTABLE(IVideoWindow) ivideowindow =
1705 {
1706         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1707         /* IUnknown fields */
1708         IVideoWindow_fnQueryInterface,
1709         IVideoWindow_fnAddRef,
1710         IVideoWindow_fnRelease,
1711         /* IDispatch fields */
1712         IVideoWindow_fnGetTypeInfoCount,
1713         IVideoWindow_fnGetTypeInfo,
1714         IVideoWindow_fnGetIDsOfNames,
1715         IVideoWindow_fnInvoke,
1716         /* IVideoWindow fields */
1717         IVideoWindow_fnput_Caption,
1718         IVideoWindow_fnget_Caption,
1719         IVideoWindow_fnput_WindowStyle,
1720         IVideoWindow_fnget_WindowStyle,
1721         IVideoWindow_fnput_WindowStyleEx,
1722         IVideoWindow_fnget_WindowStyleEx,
1723         IVideoWindow_fnput_AutoShow,
1724         IVideoWindow_fnget_AutoShow,
1725         IVideoWindow_fnput_WindowState,
1726         IVideoWindow_fnget_WindowState,
1727         IVideoWindow_fnput_BackgroundPalette,
1728         IVideoWindow_fnget_BackgroundPalette,
1729         IVideoWindow_fnput_Visible,
1730         IVideoWindow_fnget_Visible,
1731         IVideoWindow_fnput_Left,
1732         IVideoWindow_fnget_Left,
1733         IVideoWindow_fnput_Width,
1734         IVideoWindow_fnget_Width,
1735         IVideoWindow_fnput_Top,
1736         IVideoWindow_fnget_Top,
1737         IVideoWindow_fnput_Height,
1738         IVideoWindow_fnget_Height,
1739         IVideoWindow_fnput_Owner,
1740         IVideoWindow_fnget_Owner,
1741         IVideoWindow_fnput_MessageDrain,
1742         IVideoWindow_fnget_MessageDrain,
1743         IVideoWindow_fnget_BorderColor,
1744         IVideoWindow_fnput_BorderColor,
1745         IVideoWindow_fnget_FullScreenMode,
1746         IVideoWindow_fnput_FullScreenMode,
1747         IVideoWindow_fnSetWindowForeground,
1748         IVideoWindow_fnNotifyOwnerMessage,
1749         IVideoWindow_fnSetWindowPosition,
1750         IVideoWindow_fnGetWindowPosition,
1751         IVideoWindow_fnGetMinIdealImageSize,
1752         IVideoWindow_fnGetMaxIdealImageSize,
1753         IVideoWindow_fnGetRestorePosition,
1754         IVideoWindow_fnHideCursor,
1755         IVideoWindow_fnIsCursorHidden,
1756
1757 };
1758
1759
1760 HRESULT CVideoRendererImpl_InitIVideoWindow( CVideoRendererImpl* This )
1761 {
1762         TRACE("(%p)\n",This);
1763         ICOM_VTBL(&This->vidwin) = &ivideowindow;
1764
1765         return NOERROR;
1766 }
1767
1768 void CVideoRendererImpl_UninitIVideoWindow( CVideoRendererImpl* This )
1769 {
1770         TRACE("(%p)\n",This);
1771 }
1772