Change all SendAsyncCallback calls into the synchronous
[wine/wine-gecko.git] / dlls / quartz / videorenderer.c
blob71ae301b9c0a337ff8efbb42a5b7b8227a82fa97
1 /*
2 * Video Renderer (Fullscreen and Windowed using Direct Draw)
4 * Copyright 2004 Christian Costa
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.
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.
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
21 #include "config.h"
23 #define NONAMELESSSTRUCT
24 #define NONAMELESSUNION
25 #include "quartz_private.h"
26 #include "control_private.h"
27 #include "pin.h"
29 #include "uuids.h"
30 #include "mmreg.h"
31 #include "vfwmsgs.h"
32 #include "amvideo.h"
33 #include "fourcc.h"
34 #include "windef.h"
35 #include "winbase.h"
36 #include "dshow.h"
37 #include "evcode.h"
38 #include "strmif.h"
39 #include "ddraw.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
46 static BOOL wnd_class_registered = FALSE;
48 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
50 static const IBaseFilterVtbl VideoRenderer_Vtbl;
51 static const IBasicVideoVtbl IBasicVideo_VTable;
52 static const IVideoWindowVtbl IVideoWindow_VTable;
53 static const IPinVtbl VideoRenderer_InputPin_Vtbl;
55 typedef struct VideoRendererImpl
57 const IBaseFilterVtbl * lpVtbl;
58 const IBasicVideoVtbl * IBasicVideo_vtbl;
59 const IVideoWindowVtbl * IVideoWindow_vtbl;
61 LONG refCount;
62 CRITICAL_SECTION csFilter;
63 FILTER_STATE state;
64 REFERENCE_TIME rtStreamStart;
65 IReferenceClock * pClock;
66 FILTER_INFO filterInfo;
68 InputPin * pInputPin;
69 IPin ** ppPins;
71 BOOL init;
72 HANDLE hThread;
73 DWORD ThreadID;
74 HANDLE hEvent;
75 BOOL ThreadResult;
76 HWND hWnd;
77 HWND hWndMsgDrain;
78 BOOL AutoShow;
79 RECT SourceRect;
80 RECT DestRect;
81 RECT WindowPos;
82 long VideoWidth;
83 long VideoHeight;
84 } VideoRendererImpl;
86 static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
88 VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongA(hwnd, 0);
89 LPRECT lprect = (LPRECT)lParam;
91 if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
93 switch(uMsg)
95 case WM_KEYDOWN:
96 case WM_KEYUP:
97 case WM_LBUTTONDBLCLK:
98 case WM_LBUTTONDOWN:
99 case WM_LBUTTONUP:
100 case WM_MBUTTONDBLCLK:
101 case WM_MBUTTONDOWN:
102 case WM_MBUTTONUP:
103 case WM_MOUSEACTIVATE:
104 case WM_MOUSEMOVE:
105 case WM_NCLBUTTONDBLCLK:
106 case WM_NCLBUTTONDOWN:
107 case WM_NCLBUTTONUP:
108 case WM_NCMBUTTONDBLCLK:
109 case WM_NCMBUTTONDOWN:
110 case WM_NCMBUTTONUP:
111 case WM_NCMOUSEMOVE:
112 case WM_NCRBUTTONDBLCLK:
113 case WM_NCRBUTTONDOWN:
114 case WM_NCRBUTTONUP:
115 case WM_RBUTTONDBLCLK:
116 case WM_RBUTTONDOWN:
117 case WM_RBUTTONUP:
118 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
119 break;
120 default:
121 break;
125 switch(uMsg)
127 case WM_SIZING:
128 /* TRACE("WM_SIZING %ld %ld %ld %ld\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
129 SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
130 GetClientRect(hwnd, &pVideoRenderer->DestRect);
131 return TRUE;
132 default:
133 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
135 return 0;
138 static BOOL CreateRenderingWindow(VideoRendererImpl* This)
140 WNDCLASSA winclass;
142 TRACE("(%p)->()\n", This);
144 winclass.style = 0;
145 winclass.lpfnWndProc = VideoWndProcA;
146 winclass.cbClsExtra = 0;
147 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
148 winclass.hInstance = NULL;
149 winclass.hIcon = NULL;
150 winclass.hCursor = NULL;
151 winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
152 winclass.lpszMenuName = NULL;
153 winclass.lpszClassName = "Wine ActiveMovie Class";
155 if (!wnd_class_registered)
157 if (!RegisterClassA(&winclass))
159 ERR("Unable to register window %lx\n", GetLastError());
160 return FALSE;
162 wnd_class_registered = TRUE;
165 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
166 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
167 NULL, NULL, NULL);
169 if (!This->hWnd)
171 ERR("Unable to create window\n");
172 return FALSE;
175 SetWindowLongA(This->hWnd, 0, (LONG)This);
177 return TRUE;
180 static DWORD WINAPI MessageLoop(LPVOID lpParameter)
182 VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
183 MSG msg;
184 BOOL fGotMessage;
186 TRACE("Starting message loop\n");
188 if (!CreateRenderingWindow(This))
190 This->ThreadResult = FALSE;
191 SetEvent(This->hEvent);
192 return 0;
195 This->ThreadResult = TRUE;
196 SetEvent(This->hEvent);
198 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
200 TranslateMessage(&msg);
201 DispatchMessageA(&msg);
204 TRACE("End of message loop\n");
206 return msg.wParam;
209 static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
211 This->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
212 if (!This->hEvent)
213 return FALSE;
215 This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
216 if (!This->hThread)
218 CloseHandle(This->hEvent);
219 return FALSE;
222 WaitForSingleObject(This->hEvent, INFINITE);
223 CloseHandle(This->hEvent);
225 if (!This->ThreadResult)
227 CloseHandle(This->hThread);
228 return FALSE;
231 return TRUE;
234 static const IMemInputPinVtbl MemInputPin_Vtbl =
236 MemInputPin_QueryInterface,
237 MemInputPin_AddRef,
238 MemInputPin_Release,
239 MemInputPin_GetAllocator,
240 MemInputPin_NotifyAllocator,
241 MemInputPin_GetAllocatorRequirements,
242 MemInputPin_Receive,
243 MemInputPin_ReceiveMultiple,
244 MemInputPin_ReceiveCanBlock
247 static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
249 InputPin * pPinImpl;
251 *ppPin = NULL;
253 if (pPinInfo->dir != PINDIR_INPUT)
255 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
256 return E_INVALIDARG;
259 pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
261 if (!pPinImpl)
262 return E_OUTOFMEMORY;
264 if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
266 pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl;
267 pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
269 *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
270 return S_OK;
272 return E_FAIL;
275 static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
277 VIDEOINFOHEADER* format;
278 AM_MEDIA_TYPE amt;
279 HRESULT hr = S_OK;
280 DDSURFACEDESC sdesc;
281 int width;
282 int height;
283 LPBYTE palette = NULL;
284 HDC hDC;
286 TRACE("%p %p %ld\n", This, data, size);
288 sdesc.dwSize = sizeof(sdesc);
289 hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
290 if (FAILED(hr)) {
291 ERR("Unable to retrieve media type\n");
292 return hr;
294 format = (VIDEOINFOHEADER*)amt.pbFormat;
296 TRACE("biSize = %ld\n", format->bmiHeader.biSize);
297 TRACE("biWidth = %ld\n", format->bmiHeader.biWidth);
298 TRACE("biHeigth = %ld\n", format->bmiHeader.biHeight);
299 TRACE("biPlanes = %d\n", format->bmiHeader.biPlanes);
300 TRACE("biBitCount = %d\n", format->bmiHeader.biBitCount);
301 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(format->bmiHeader.biCompression), 4));
302 TRACE("biSizeImage = %ld\n", format->bmiHeader.biSizeImage);
304 width = format->bmiHeader.biWidth;
305 height = format->bmiHeader.biHeight;
306 palette = ((LPBYTE)&format->bmiHeader) + format->bmiHeader.biSize;
308 if (!This->init)
310 /* Compute the size of the whole window so the client area size matches video one */
311 RECT wrect, crect;
312 int h, v;
313 GetWindowRect(This->hWnd, &wrect);
314 GetClientRect(This->hWnd, &crect);
315 h = (wrect.right - wrect.left) - (crect.right - crect.left);
316 v = (wrect.bottom - wrect.top) - (crect.bottom - crect.top);
317 SetWindowPos(This->hWnd, NULL, 0, 0, width + h +20, height + v+20, SWP_NOZORDER|SWP_NOMOVE);
318 This->WindowPos.left = 0;
319 This->WindowPos.top = 0;
320 This->WindowPos.right = width;
321 This->WindowPos.bottom = height;
322 GetClientRect(This->hWnd, &This->DestRect);
323 This->init = TRUE;
326 hDC = GetDC(This->hWnd);
328 if (!hDC) {
329 ERR("Cannot get DC from window!\n");
330 return E_FAIL;
333 TRACE("Src Rect: %ld %ld %ld %ld\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
334 TRACE("Dst Rect: %ld %ld %ld %ld\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom);
336 StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
337 This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
338 This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
339 data, (BITMAPINFO*)&format->bmiHeader, DIB_RGB_COLORS, SRCCOPY);
341 ReleaseDC(This->hWnd, hDC);
343 if (This->AutoShow)
344 ShowWindow(This->hWnd, SW_SHOW);
346 return S_OK;
349 static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
351 VideoRendererImpl *This = (VideoRendererImpl *)iface;
352 LPBYTE pbSrcStream = NULL;
353 long cbSrcStream = 0;
354 REFERENCE_TIME tStart, tStop;
355 HRESULT hr;
357 TRACE("%p %p\n", iface, pSample);
359 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
360 if (FAILED(hr))
362 ERR("Cannot get pointer to sample data (%lx)\n", hr);
363 return hr;
366 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
367 if (FAILED(hr))
368 ERR("Cannot get sample time (%lx)\n", hr);
370 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
372 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
374 #if 0 /* For debugging purpose */
376 int i;
377 for(i = 0; i < cbSrcStream; i++)
379 if ((i!=0) && !(i%16))
380 TRACE("\n");
381 TRACE("%02x ", pbSrcStream[i]);
383 TRACE("\n");
385 #endif
387 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
389 return S_OK;
392 static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
394 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
395 return S_FALSE;
397 if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
398 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
399 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
400 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
402 VideoRendererImpl* This = (VideoRendererImpl*) iface;
403 VIDEOINFOHEADER* format = (VIDEOINFOHEADER*)pmt->pbFormat;
405 if (!IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
407 WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
408 return S_FALSE;
410 This->SourceRect.left = 0;
411 This->SourceRect.top = 0;
412 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
413 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
414 return S_OK;
416 return S_FALSE;
419 HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
421 HRESULT hr;
422 PIN_INFO piInput;
423 VideoRendererImpl * pVideoRenderer;
425 TRACE("(%p, %p)\n", pUnkOuter, ppv);
427 *ppv = NULL;
429 if (pUnkOuter)
430 return CLASS_E_NOAGGREGATION;
432 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
434 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
435 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
436 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
438 pVideoRenderer->refCount = 1;
439 InitializeCriticalSection(&pVideoRenderer->csFilter);
440 pVideoRenderer->state = State_Stopped;
441 pVideoRenderer->pClock = NULL;
442 pVideoRenderer->init = 0;
443 pVideoRenderer->AutoShow = 1;
444 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
446 pVideoRenderer->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
448 /* construct input pin */
449 piInput.dir = PINDIR_INPUT;
450 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
451 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
453 hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
455 if (SUCCEEDED(hr))
457 pVideoRenderer->ppPins[0] = (IPin *)pVideoRenderer->pInputPin;
458 *ppv = (LPVOID)pVideoRenderer;
460 else
462 CoTaskMemFree(pVideoRenderer->ppPins);
463 DeleteCriticalSection(&pVideoRenderer->csFilter);
464 CoTaskMemFree(pVideoRenderer);
467 if (!CreateRenderingSubsystem(pVideoRenderer))
468 return E_FAIL;
470 return hr;
473 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
475 VideoRendererImpl *This = (VideoRendererImpl *)iface;
476 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
478 *ppv = NULL;
480 if (IsEqualIID(riid, &IID_IUnknown))
481 *ppv = (LPVOID)This;
482 else if (IsEqualIID(riid, &IID_IPersist))
483 *ppv = (LPVOID)This;
484 else if (IsEqualIID(riid, &IID_IMediaFilter))
485 *ppv = (LPVOID)This;
486 else if (IsEqualIID(riid, &IID_IBaseFilter))
487 *ppv = (LPVOID)This;
488 else if (IsEqualIID(riid, &IID_IBasicVideo))
489 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
490 else if (IsEqualIID(riid, &IID_IVideoWindow))
491 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
493 if (*ppv)
495 IUnknown_AddRef((IUnknown *)(*ppv));
496 return S_OK;
499 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
501 return E_NOINTERFACE;
504 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
506 VideoRendererImpl *This = (VideoRendererImpl *)iface;
507 ULONG refCount = InterlockedIncrement(&This->refCount);
509 TRACE("(%p/%p)->() AddRef from %ld\n", This, iface, refCount - 1);
511 return refCount;
514 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
516 VideoRendererImpl *This = (VideoRendererImpl *)iface;
517 ULONG refCount = InterlockedDecrement(&This->refCount);
519 TRACE("(%p/%p)->() Release from %ld\n", This, iface, refCount + 1);
521 if (!refCount)
523 DeleteCriticalSection(&This->csFilter);
525 DestroyWindow(This->hWnd);
526 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
527 WaitForSingleObject(This->hThread, INFINITE);
528 CloseHandle(This->hThread);
530 if (This->pClock)
531 IReferenceClock_Release(This->pClock);
533 IPin_Release(This->ppPins[0]);
535 HeapFree(GetProcessHeap(), 0, This->ppPins);
536 This->lpVtbl = NULL;
538 TRACE("Destroying Video Renderer\n");
539 CoTaskMemFree(This);
541 return 0;
543 else
544 return refCount;
547 /** IPersist methods **/
549 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
551 VideoRendererImpl *This = (VideoRendererImpl *)iface;
553 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
555 *pClsid = CLSID_VideoRenderer;
557 return S_OK;
560 /** IMediaFilter methods **/
562 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
564 VideoRendererImpl *This = (VideoRendererImpl *)iface;
566 TRACE("(%p/%p)->()\n", This, iface);
568 EnterCriticalSection(&This->csFilter);
570 This->state = State_Stopped;
572 LeaveCriticalSection(&This->csFilter);
574 return S_OK;
577 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
579 VideoRendererImpl *This = (VideoRendererImpl *)iface;
581 TRACE("(%p/%p)->()\n", This, iface);
583 EnterCriticalSection(&This->csFilter);
585 This->state = State_Paused;
587 LeaveCriticalSection(&This->csFilter);
589 return S_OK;
592 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
594 VideoRendererImpl *This = (VideoRendererImpl *)iface;
596 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
598 EnterCriticalSection(&This->csFilter);
600 This->rtStreamStart = tStart;
601 This->state = State_Running;
603 LeaveCriticalSection(&This->csFilter);
605 return S_OK;
608 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
610 VideoRendererImpl *This = (VideoRendererImpl *)iface;
612 TRACE("(%p/%p)->(%ld, %p)\n", This, iface, dwMilliSecsTimeout, pState);
614 EnterCriticalSection(&This->csFilter);
616 *pState = This->state;
618 LeaveCriticalSection(&This->csFilter);
620 return S_OK;
623 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
625 VideoRendererImpl *This = (VideoRendererImpl *)iface;
627 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
629 EnterCriticalSection(&This->csFilter);
631 if (This->pClock)
632 IReferenceClock_Release(This->pClock);
633 This->pClock = pClock;
634 if (This->pClock)
635 IReferenceClock_AddRef(This->pClock);
637 LeaveCriticalSection(&This->csFilter);
639 return S_OK;
642 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
644 VideoRendererImpl *This = (VideoRendererImpl *)iface;
646 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
648 EnterCriticalSection(&This->csFilter);
650 *ppClock = This->pClock;
651 IReferenceClock_AddRef(This->pClock);
653 LeaveCriticalSection(&This->csFilter);
655 return S_OK;
658 /** IBaseFilter implementation **/
660 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
662 ENUMPINDETAILS epd;
663 VideoRendererImpl *This = (VideoRendererImpl *)iface;
665 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
667 epd.cPins = 1; /* input pin */
668 epd.ppPins = This->ppPins;
669 return IEnumPinsImpl_Construct(&epd, ppEnum);
672 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
674 VideoRendererImpl *This = (VideoRendererImpl *)iface;
676 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
678 FIXME("VideoRenderer::FindPin(...)\n");
680 /* FIXME: critical section */
682 return E_NOTIMPL;
685 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
687 VideoRendererImpl *This = (VideoRendererImpl *)iface;
689 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
691 strcpyW(pInfo->achName, This->filterInfo.achName);
692 pInfo->pGraph = This->filterInfo.pGraph;
694 if (pInfo->pGraph)
695 IFilterGraph_AddRef(pInfo->pGraph);
697 return S_OK;
700 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
702 VideoRendererImpl *This = (VideoRendererImpl *)iface;
704 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
706 EnterCriticalSection(&This->csFilter);
708 if (pName)
709 strcpyW(This->filterInfo.achName, pName);
710 else
711 *This->filterInfo.achName = '\0';
712 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
714 LeaveCriticalSection(&This->csFilter);
716 return S_OK;
719 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
721 VideoRendererImpl *This = (VideoRendererImpl *)iface;
722 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
723 return E_NOTIMPL;
726 static const IBaseFilterVtbl VideoRenderer_Vtbl =
728 VideoRenderer_QueryInterface,
729 VideoRenderer_AddRef,
730 VideoRenderer_Release,
731 VideoRenderer_GetClassID,
732 VideoRenderer_Stop,
733 VideoRenderer_Pause,
734 VideoRenderer_Run,
735 VideoRenderer_GetState,
736 VideoRenderer_SetSyncSource,
737 VideoRenderer_GetSyncSource,
738 VideoRenderer_EnumPins,
739 VideoRenderer_FindPin,
740 VideoRenderer_QueryFilterInfo,
741 VideoRenderer_JoinFilterGraph,
742 VideoRenderer_QueryVendorInfo
745 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
747 InputPin* This = (InputPin*)iface;
748 IMediaEventSink* pEventSink;
749 HRESULT hr;
751 TRACE("(%p/%p)->()\n", This, iface);
753 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
754 if (SUCCEEDED(hr))
756 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
757 IMediaEventSink_Release(pEventSink);
760 return hr;
763 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
765 InputPin_QueryInterface,
766 IPinImpl_AddRef,
767 InputPin_Release,
768 InputPin_Connect,
769 InputPin_ReceiveConnection,
770 IPinImpl_Disconnect,
771 IPinImpl_ConnectedTo,
772 IPinImpl_ConnectionMediaType,
773 IPinImpl_QueryPinInfo,
774 IPinImpl_QueryDirection,
775 IPinImpl_QueryId,
776 IPinImpl_QueryAccept,
777 IPinImpl_EnumMediaTypes,
778 IPinImpl_QueryInternalConnections,
779 VideoRenderer_InputPin_EndOfStream,
780 InputPin_BeginFlush,
781 InputPin_EndFlush,
782 InputPin_NewSegment
785 /*** IUnknown methods ***/
786 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
787 REFIID riid,
788 LPVOID*ppvObj) {
789 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
791 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
793 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
796 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
797 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
799 TRACE("(%p/%p)->()\n", This, iface);
801 return VideoRenderer_AddRef((IBaseFilter*)This);
804 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
805 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
807 TRACE("(%p/%p)->()\n", This, iface);
809 return VideoRenderer_Release((IBaseFilter*)This);
812 /*** IDispatch methods ***/
813 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
814 UINT*pctinfo) {
815 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
817 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
819 return S_OK;
822 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
823 UINT iTInfo,
824 LCID lcid,
825 ITypeInfo**ppTInfo) {
826 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
828 FIXME("(%p/%p)->(%d, %ld, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
830 return S_OK;
833 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
834 REFIID riid,
835 LPOLESTR*rgszNames,
836 UINT cNames,
837 LCID lcid,
838 DISPID*rgDispId) {
839 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
841 FIXME("(%p/%p)->(%s (%p), %p, %d, %ld, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
843 return S_OK;
846 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
847 DISPID dispIdMember,
848 REFIID riid,
849 LCID lcid,
850 WORD wFlags,
851 DISPPARAMS*pDispParams,
852 VARIANT*pVarResult,
853 EXCEPINFO*pExepInfo,
854 UINT*puArgErr) {
855 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
857 FIXME("(%p/%p)->(%ld, %s (%p), %ld, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
859 return S_OK;
862 /*** IBasicVideo methods ***/
863 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
864 REFTIME *pAvgTimePerFrame) {
865 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
867 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
869 return S_OK;
872 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
873 long *pBitRate) {
874 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
876 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
878 return S_OK;
881 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
882 long *pBitErrorRate) {
883 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
885 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
887 return S_OK;
890 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
891 long *pVideoWidth) {
892 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
894 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
896 *pVideoWidth = This->VideoWidth;
898 return S_OK;
901 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
902 long *pVideoHeight) {
903 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
905 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
907 *pVideoHeight = This->VideoHeight;
909 return S_OK;
912 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
913 long SourceLeft) {
914 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
916 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
918 This->SourceRect.left = SourceLeft;
920 return S_OK;
923 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
924 long *pSourceLeft) {
925 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
927 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
929 *pSourceLeft = This->SourceRect.left;
931 return S_OK;
934 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
935 long SourceWidth) {
936 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
938 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
940 This->SourceRect.right = This->SourceRect.left + SourceWidth;
942 return S_OK;
945 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
946 long *pSourceWidth) {
947 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
949 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
951 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
953 return S_OK;
956 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
957 long SourceTop) {
958 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
960 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
962 This->SourceRect.top = SourceTop;
964 return S_OK;
967 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
968 long *pSourceTop) {
969 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
971 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
973 *pSourceTop = This->SourceRect.top;
975 return S_OK;
978 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
979 long SourceHeight) {
980 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
982 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
984 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
986 return S_OK;
989 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
990 long *pSourceHeight) {
991 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
993 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
995 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
997 return S_OK;
1000 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1001 long DestinationLeft) {
1002 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1004 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1006 This->DestRect.left = DestinationLeft;
1008 return S_OK;
1011 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1012 long *pDestinationLeft) {
1013 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1015 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1017 *pDestinationLeft = This->DestRect.left;
1019 return S_OK;
1022 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1023 long DestinationWidth) {
1024 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1026 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1028 This->DestRect.right = This->DestRect.left + DestinationWidth;
1030 return S_OK;
1033 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1034 long *pDestinationWidth) {
1035 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1037 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1039 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1041 return S_OK;
1044 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1045 long DestinationTop) {
1046 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1048 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1050 This->DestRect.top = DestinationTop;
1052 return S_OK;
1055 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1056 long *pDestinationTop) {
1057 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1059 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1061 *pDestinationTop = This->DestRect.top;
1063 return S_OK;
1066 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1067 long DestinationHeight) {
1068 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1070 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1072 This->DestRect.right = This->DestRect.left + DestinationHeight;
1074 return S_OK;
1077 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1078 long *pDestinationHeight) {
1079 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1081 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1083 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1085 return S_OK;
1088 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1089 long Left,
1090 long Top,
1091 long Width,
1092 long Height) {
1093 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1095 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1097 This->SourceRect.left = Left;
1098 This->SourceRect.top = Top;
1099 This->SourceRect.right = Left + Width;
1100 This->SourceRect.bottom = Top + Height;
1102 return S_OK;
1105 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1106 long *pLeft,
1107 long *pTop,
1108 long *pWidth,
1109 long *pHeight) {
1110 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1112 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1114 *pLeft = This->SourceRect.left;
1115 *pTop = This->SourceRect.top;
1116 *pWidth = This->SourceRect.right - This->SourceRect.left;
1117 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1119 return S_OK;
1122 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1123 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1125 TRACE("(%p/%p)->()\n", This, iface);
1127 This->SourceRect.left = 0;
1128 This->SourceRect.top = 0;
1129 This->SourceRect.right = This->VideoWidth;
1130 This->SourceRect.bottom = This->VideoHeight;
1132 return S_OK;
1135 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1136 long Left,
1137 long Top,
1138 long Width,
1139 long Height) {
1140 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1142 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1144 This->DestRect.left = Left;
1145 This->DestRect.top = Top;
1146 This->DestRect.right = Left + Width;
1147 This->DestRect.bottom = Top + Height;
1149 return S_OK;
1152 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1153 long *pLeft,
1154 long *pTop,
1155 long *pWidth,
1156 long *pHeight) {
1157 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1159 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1161 *pLeft = This->DestRect.left;
1162 *pTop = This->DestRect.top;
1163 *pWidth = This->DestRect.right - This->DestRect.left;
1164 *pHeight = This->DestRect.bottom - This->DestRect.top;
1166 return S_OK;
1169 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1170 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1171 RECT rect;
1173 TRACE("(%p/%p)->()\n", This, iface);
1175 if (!GetClientRect(This->hWnd, &rect))
1176 return E_FAIL;
1178 This->SourceRect.left = 0;
1179 This->SourceRect.top = 0;
1180 This->SourceRect.right = rect.right;
1181 This->SourceRect.bottom = rect.bottom;
1183 return S_OK;
1186 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1187 long *pWidth,
1188 long *pHeight) {
1189 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1191 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1193 *pWidth = This->VideoWidth;
1194 *pHeight = This->VideoHeight;
1196 return S_OK;
1199 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1200 long StartIndex,
1201 long Entries,
1202 long *pRetrieved,
1203 long *pPalette) {
1204 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1206 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1208 return S_OK;
1211 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1212 long *pBufferSize,
1213 long *pDIBImage) {
1214 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1216 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
1218 return S_OK;
1221 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1222 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1224 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1226 return S_OK;
1229 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1230 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1232 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1234 return S_OK;
1238 static const IBasicVideoVtbl IBasicVideo_VTable =
1240 Basicvideo_QueryInterface,
1241 Basicvideo_AddRef,
1242 Basicvideo_Release,
1243 Basicvideo_GetTypeInfoCount,
1244 Basicvideo_GetTypeInfo,
1245 Basicvideo_GetIDsOfNames,
1246 Basicvideo_Invoke,
1247 Basicvideo_get_AvgTimePerFrame,
1248 Basicvideo_get_BitRate,
1249 Basicvideo_get_BitErrorRate,
1250 Basicvideo_get_VideoWidth,
1251 Basicvideo_get_VideoHeight,
1252 Basicvideo_put_SourceLeft,
1253 Basicvideo_get_SourceLeft,
1254 Basicvideo_put_SourceWidth,
1255 Basicvideo_get_SourceWidth,
1256 Basicvideo_put_SourceTop,
1257 Basicvideo_get_SourceTop,
1258 Basicvideo_put_SourceHeight,
1259 Basicvideo_get_SourceHeight,
1260 Basicvideo_put_DestinationLeft,
1261 Basicvideo_get_DestinationLeft,
1262 Basicvideo_put_DestinationWidth,
1263 Basicvideo_get_DestinationWidth,
1264 Basicvideo_put_DestinationTop,
1265 Basicvideo_get_DestinationTop,
1266 Basicvideo_put_DestinationHeight,
1267 Basicvideo_get_DestinationHeight,
1268 Basicvideo_SetSourcePosition,
1269 Basicvideo_GetSourcePosition,
1270 Basicvideo_SetDefaultSourcePosition,
1271 Basicvideo_SetDestinationPosition,
1272 Basicvideo_GetDestinationPosition,
1273 Basicvideo_SetDefaultDestinationPosition,
1274 Basicvideo_GetVideoSize,
1275 Basicvideo_GetVideoPaletteEntries,
1276 Basicvideo_GetCurrentImage,
1277 Basicvideo_IsUsingDefaultSource,
1278 Basicvideo_IsUsingDefaultDestination
1282 /*** IUnknown methods ***/
1283 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1284 REFIID riid,
1285 LPVOID*ppvObj) {
1286 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1288 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1290 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1293 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1294 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1296 TRACE("(%p/%p)->()\n", This, iface);
1298 return VideoRenderer_AddRef((IBaseFilter*)This);
1301 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1302 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1304 TRACE("(%p/%p)->()\n", This, iface);
1306 return VideoRenderer_Release((IBaseFilter*)This);
1309 /*** IDispatch methods ***/
1310 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1311 UINT*pctinfo) {
1312 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1314 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1316 return S_OK;
1319 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1320 UINT iTInfo,
1321 LCID lcid,
1322 ITypeInfo**ppTInfo) {
1323 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1325 FIXME("(%p/%p)->(%d, %ld, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1327 return S_OK;
1330 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1331 REFIID riid,
1332 LPOLESTR*rgszNames,
1333 UINT cNames,
1334 LCID lcid,
1335 DISPID*rgDispId) {
1336 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1338 FIXME("(%p/%p)->(%s (%p), %p, %d, %ld, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1340 return S_OK;
1343 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1344 DISPID dispIdMember,
1345 REFIID riid,
1346 LCID lcid,
1347 WORD wFlags,
1348 DISPPARAMS*pDispParams,
1349 VARIANT*pVarResult,
1350 EXCEPINFO*pExepInfo,
1351 UINT*puArgErr) {
1352 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1354 FIXME("(%p/%p)->(%ld, %s (%p), %ld, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
1356 return S_OK;
1359 /*** IVideoWindow methods ***/
1360 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1361 BSTR strCaption) {
1362 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1364 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1366 if (!SetWindowTextW(This->hWnd, strCaption))
1367 return E_FAIL;
1369 return S_OK;
1372 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1373 BSTR *strCaption) {
1374 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1376 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1378 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1380 return S_OK;
1383 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1384 long WindowStyle) {
1385 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1386 LONG old;
1388 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1390 TRACE("(%p/%p)->(%lx -> %lx)\n", This, iface, old, WindowStyle);
1392 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1393 return E_INVALIDARG;
1395 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1397 return S_OK;
1400 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1401 long *WindowStyle) {
1402 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1404 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1406 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1408 return S_OK;
1411 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1412 long WindowStyleEx) {
1413 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1415 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1417 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1418 return E_INVALIDARG;
1420 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1421 return E_FAIL;
1423 return S_OK;
1426 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1427 long *WindowStyleEx) {
1428 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1430 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1432 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1434 return S_OK;
1437 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1438 long AutoShow) {
1439 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1441 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1443 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1445 return S_OK;
1448 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1449 long *AutoShow) {
1450 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1452 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1454 *AutoShow = This->AutoShow;
1456 return S_OK;
1459 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1460 long WindowState) {
1461 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1463 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1465 return S_OK;
1468 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1469 long *WindowState) {
1470 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1472 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1474 return S_OK;
1477 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1478 long BackgroundPalette) {
1479 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1481 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1483 return S_OK;
1486 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1487 long *pBackgroundPalette) {
1488 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1490 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1492 return S_OK;
1495 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1496 long Visible) {
1497 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1499 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1501 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1503 return S_OK;
1506 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1507 long *pVisible) {
1508 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1510 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1512 *pVisible = IsWindowVisible(This->hWnd);
1514 return S_OK;
1517 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1518 long Left) {
1519 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1521 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1523 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1524 return E_FAIL;
1526 This->WindowPos.left = Left;
1528 return S_OK;
1531 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1532 long *pLeft) {
1533 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1535 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1537 *pLeft = This->WindowPos.left;
1539 return S_OK;
1542 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1543 long Width) {
1544 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1546 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1548 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1549 return E_FAIL;
1551 This->WindowPos.right = This->WindowPos.left + Width;
1553 return S_OK;
1556 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1557 long *pWidth) {
1558 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1560 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1562 *pWidth = This->WindowPos.right - This->WindowPos.left;
1564 return S_OK;
1567 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1568 long Top) {
1569 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1571 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1573 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1574 return E_FAIL;
1576 This->WindowPos.top = Top;
1578 return S_OK;
1581 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1582 long *pTop) {
1583 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1585 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1587 *pTop = This->WindowPos.top;
1589 return S_OK;
1592 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1593 long Height) {
1594 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1596 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1598 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1599 return E_FAIL;
1601 This->WindowPos.bottom = This->WindowPos.top + Height;
1603 return S_OK;
1606 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1607 long *pHeight) {
1608 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1610 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1612 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1614 return S_OK;
1617 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1618 OAHWND Owner) {
1619 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1621 TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) Owner);
1623 SetParent(This->hWnd, (HWND)Owner);
1625 return S_OK;
1628 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1629 OAHWND *Owner) {
1630 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1632 TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) Owner);
1634 *(HWND*)Owner = GetParent(This->hWnd);
1636 return S_OK;
1639 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1640 OAHWND Drain) {
1641 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1643 TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) Drain);
1645 This->hWndMsgDrain = (HWND)Drain;
1647 return S_OK;
1650 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1651 OAHWND *Drain) {
1652 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1654 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1656 *Drain = (OAHWND)This->hWndMsgDrain;
1658 return S_OK;
1661 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1662 long *Color) {
1663 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1665 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1667 return S_OK;
1670 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1671 long Color) {
1672 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1674 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1676 return S_OK;
1679 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1680 long *FullScreenMode) {
1681 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1683 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1685 return S_OK;
1688 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1689 long FullScreenMode) {
1690 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1692 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1694 return S_OK;
1697 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1698 long Focus) {
1699 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1700 BOOL ret;
1701 IPin* pPin;
1702 HRESULT hr;
1704 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1706 if ((Focus != FALSE) && (Focus != TRUE))
1707 return E_INVALIDARG;
1709 hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1710 if ((hr != S_OK) || !pPin)
1711 return VFW_E_NOT_CONNECTED;
1713 if (Focus)
1714 ret = SetForegroundWindow(This->hWnd);
1715 else
1716 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1718 if (!ret)
1719 return E_FAIL;
1721 return S_OK;
1724 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1725 OAHWND hwnd,
1726 long uMsg,
1727 LONG_PTR wParam,
1728 LONG_PTR lParam) {
1729 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1731 TRACE("(%p/%p)->(%08lx, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
1733 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1734 return E_FAIL;
1736 return S_OK;
1739 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1740 long Left,
1741 long Top,
1742 long Width,
1743 long Height) {
1744 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1746 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1748 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1749 return E_FAIL;
1751 This->WindowPos.left = Left;
1752 This->WindowPos.top = Top;
1753 This->WindowPos.right = Left + Width;
1754 This->WindowPos.bottom = Top + Height;
1756 return S_OK;
1759 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1760 long *pLeft,
1761 long *pTop,
1762 long *pWidth,
1763 long *pHeight) {
1764 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1766 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1768 *pLeft = This->WindowPos.left;
1769 *pTop = This->WindowPos.top;
1770 *pWidth = This->WindowPos.right - This->WindowPos.left;
1771 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1773 return S_OK;
1776 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1777 long *pWidth,
1778 long *pHeight) {
1779 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1781 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1783 *pWidth = This->VideoWidth;
1784 *pHeight = This->VideoHeight;
1786 return S_OK;
1789 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1790 long *pWidth,
1791 long *pHeight) {
1792 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1794 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1796 *pWidth = This->VideoWidth;
1797 *pHeight = This->VideoHeight;
1799 return S_OK;
1802 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1803 long *pLeft,
1804 long *pTop,
1805 long *pWidth,
1806 long *pHeight) {
1807 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1809 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
1811 return S_OK;
1814 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1815 long HideCursor) {
1816 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1818 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
1820 return S_OK;
1823 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1824 long *CursorHidden) {
1825 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1827 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
1829 return S_OK;
1832 static const IVideoWindowVtbl IVideoWindow_VTable =
1834 Videowindow_QueryInterface,
1835 Videowindow_AddRef,
1836 Videowindow_Release,
1837 Videowindow_GetTypeInfoCount,
1838 Videowindow_GetTypeInfo,
1839 Videowindow_GetIDsOfNames,
1840 Videowindow_Invoke,
1841 Videowindow_put_Caption,
1842 Videowindow_get_Caption,
1843 Videowindow_put_WindowStyle,
1844 Videowindow_get_WindowStyle,
1845 Videowindow_put_WindowStyleEx,
1846 Videowindow_get_WindowStyleEx,
1847 Videowindow_put_AutoShow,
1848 Videowindow_get_AutoShow,
1849 Videowindow_put_WindowState,
1850 Videowindow_get_WindowState,
1851 Videowindow_put_BackgroundPalette,
1852 Videowindow_get_BackgroundPalette,
1853 Videowindow_put_Visible,
1854 Videowindow_get_Visible,
1855 Videowindow_put_Left,
1856 Videowindow_get_Left,
1857 Videowindow_put_Width,
1858 Videowindow_get_Width,
1859 Videowindow_put_Top,
1860 Videowindow_get_Top,
1861 Videowindow_put_Height,
1862 Videowindow_get_Height,
1863 Videowindow_put_Owner,
1864 Videowindow_get_Owner,
1865 Videowindow_put_MessageDrain,
1866 Videowindow_get_MessageDrain,
1867 Videowindow_get_BorderColor,
1868 Videowindow_put_BorderColor,
1869 Videowindow_get_FullScreenMode,
1870 Videowindow_put_FullScreenMode,
1871 Videowindow_SetWindowForeground,
1872 Videowindow_NotifyOwnerMessage,
1873 Videowindow_SetWindowPosition,
1874 Videowindow_GetWindowPosition,
1875 Videowindow_GetMinIdealImageSize,
1876 Videowindow_GetMaxIdealImageSize,
1877 Videowindow_GetRestorePosition,
1878 Videowindow_HideCursor,
1879 Videowindow_IsCursorHidden