quartz: Add DebugInfo to critical sections.
[wine/hacks.git] / dlls / quartz / videorenderer.c
blob695258d18a293bf8610fa414b10fdf032df50735
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 %d %d %d %d\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 %u\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 %d\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 = %d\n", format->bmiHeader.biSize);
297 TRACE("biWidth = %d\n", format->bmiHeader.biWidth);
298 TRACE("biHeight = %d\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 = %d\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 = abs(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: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
334 TRACE("Dst Rect: %d %d %d %d\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 (%x)\n", hr);
363 return hr;
366 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
367 if (FAILED(hr))
368 ERR("Cannot get sample time (%x)\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->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
441 pVideoRenderer->state = State_Stopped;
442 pVideoRenderer->pClock = NULL;
443 pVideoRenderer->init = 0;
444 pVideoRenderer->AutoShow = 1;
445 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
447 pVideoRenderer->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
449 /* construct input pin */
450 piInput.dir = PINDIR_INPUT;
451 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
452 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
454 hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
456 if (SUCCEEDED(hr))
458 pVideoRenderer->ppPins[0] = (IPin *)pVideoRenderer->pInputPin;
459 *ppv = (LPVOID)pVideoRenderer;
461 else
463 CoTaskMemFree(pVideoRenderer->ppPins);
464 pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
465 DeleteCriticalSection(&pVideoRenderer->csFilter);
466 CoTaskMemFree(pVideoRenderer);
469 if (!CreateRenderingSubsystem(pVideoRenderer))
470 return E_FAIL;
472 return hr;
475 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
477 VideoRendererImpl *This = (VideoRendererImpl *)iface;
478 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
480 *ppv = NULL;
482 if (IsEqualIID(riid, &IID_IUnknown))
483 *ppv = (LPVOID)This;
484 else if (IsEqualIID(riid, &IID_IPersist))
485 *ppv = (LPVOID)This;
486 else if (IsEqualIID(riid, &IID_IMediaFilter))
487 *ppv = (LPVOID)This;
488 else if (IsEqualIID(riid, &IID_IBaseFilter))
489 *ppv = (LPVOID)This;
490 else if (IsEqualIID(riid, &IID_IBasicVideo))
491 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
492 else if (IsEqualIID(riid, &IID_IVideoWindow))
493 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
495 if (*ppv)
497 IUnknown_AddRef((IUnknown *)(*ppv));
498 return S_OK;
501 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
503 return E_NOINTERFACE;
506 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
508 VideoRendererImpl *This = (VideoRendererImpl *)iface;
509 ULONG refCount = InterlockedIncrement(&This->refCount);
511 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
513 return refCount;
516 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
518 VideoRendererImpl *This = (VideoRendererImpl *)iface;
519 ULONG refCount = InterlockedDecrement(&This->refCount);
521 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
523 if (!refCount)
525 This->csFilter.DebugInfo->Spare[0] = 0;
526 DeleteCriticalSection(&This->csFilter);
528 DestroyWindow(This->hWnd);
529 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
530 WaitForSingleObject(This->hThread, INFINITE);
531 CloseHandle(This->hThread);
533 if (This->pClock)
534 IReferenceClock_Release(This->pClock);
536 IPin_Release(This->ppPins[0]);
538 CoTaskMemFree(This->ppPins);
539 This->lpVtbl = NULL;
541 TRACE("Destroying Video Renderer\n");
542 CoTaskMemFree(This);
544 return 0;
546 else
547 return refCount;
550 /** IPersist methods **/
552 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
554 VideoRendererImpl *This = (VideoRendererImpl *)iface;
556 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
558 *pClsid = CLSID_VideoRenderer;
560 return S_OK;
563 /** IMediaFilter methods **/
565 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
567 VideoRendererImpl *This = (VideoRendererImpl *)iface;
569 TRACE("(%p/%p)->()\n", This, iface);
571 EnterCriticalSection(&This->csFilter);
573 This->state = State_Stopped;
575 LeaveCriticalSection(&This->csFilter);
577 return S_OK;
580 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
582 VideoRendererImpl *This = (VideoRendererImpl *)iface;
584 TRACE("(%p/%p)->()\n", This, iface);
586 EnterCriticalSection(&This->csFilter);
588 This->state = State_Paused;
590 LeaveCriticalSection(&This->csFilter);
592 return S_OK;
595 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
597 VideoRendererImpl *This = (VideoRendererImpl *)iface;
599 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
601 EnterCriticalSection(&This->csFilter);
603 This->rtStreamStart = tStart;
604 This->state = State_Running;
606 LeaveCriticalSection(&This->csFilter);
608 return S_OK;
611 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
613 VideoRendererImpl *This = (VideoRendererImpl *)iface;
615 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
617 EnterCriticalSection(&This->csFilter);
619 *pState = This->state;
621 LeaveCriticalSection(&This->csFilter);
623 return S_OK;
626 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
628 VideoRendererImpl *This = (VideoRendererImpl *)iface;
630 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
632 EnterCriticalSection(&This->csFilter);
634 if (This->pClock)
635 IReferenceClock_Release(This->pClock);
636 This->pClock = pClock;
637 if (This->pClock)
638 IReferenceClock_AddRef(This->pClock);
640 LeaveCriticalSection(&This->csFilter);
642 return S_OK;
645 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
647 VideoRendererImpl *This = (VideoRendererImpl *)iface;
649 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
651 EnterCriticalSection(&This->csFilter);
653 *ppClock = This->pClock;
654 IReferenceClock_AddRef(This->pClock);
656 LeaveCriticalSection(&This->csFilter);
658 return S_OK;
661 /** IBaseFilter implementation **/
663 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
665 ENUMPINDETAILS epd;
666 VideoRendererImpl *This = (VideoRendererImpl *)iface;
668 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
670 epd.cPins = 1; /* input pin */
671 epd.ppPins = This->ppPins;
672 return IEnumPinsImpl_Construct(&epd, ppEnum);
675 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
677 VideoRendererImpl *This = (VideoRendererImpl *)iface;
679 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
681 FIXME("VideoRenderer::FindPin(...)\n");
683 /* FIXME: critical section */
685 return E_NOTIMPL;
688 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
690 VideoRendererImpl *This = (VideoRendererImpl *)iface;
692 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
694 strcpyW(pInfo->achName, This->filterInfo.achName);
695 pInfo->pGraph = This->filterInfo.pGraph;
697 if (pInfo->pGraph)
698 IFilterGraph_AddRef(pInfo->pGraph);
700 return S_OK;
703 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
705 VideoRendererImpl *This = (VideoRendererImpl *)iface;
707 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
709 EnterCriticalSection(&This->csFilter);
711 if (pName)
712 strcpyW(This->filterInfo.achName, pName);
713 else
714 *This->filterInfo.achName = '\0';
715 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
717 LeaveCriticalSection(&This->csFilter);
719 return S_OK;
722 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
724 VideoRendererImpl *This = (VideoRendererImpl *)iface;
725 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
726 return E_NOTIMPL;
729 static const IBaseFilterVtbl VideoRenderer_Vtbl =
731 VideoRenderer_QueryInterface,
732 VideoRenderer_AddRef,
733 VideoRenderer_Release,
734 VideoRenderer_GetClassID,
735 VideoRenderer_Stop,
736 VideoRenderer_Pause,
737 VideoRenderer_Run,
738 VideoRenderer_GetState,
739 VideoRenderer_SetSyncSource,
740 VideoRenderer_GetSyncSource,
741 VideoRenderer_EnumPins,
742 VideoRenderer_FindPin,
743 VideoRenderer_QueryFilterInfo,
744 VideoRenderer_JoinFilterGraph,
745 VideoRenderer_QueryVendorInfo
748 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
750 InputPin* This = (InputPin*)iface;
751 IMediaEventSink* pEventSink;
752 HRESULT hr;
754 TRACE("(%p/%p)->()\n", This, iface);
756 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
757 if (SUCCEEDED(hr))
759 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
760 IMediaEventSink_Release(pEventSink);
763 return hr;
766 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
768 InputPin_QueryInterface,
769 IPinImpl_AddRef,
770 InputPin_Release,
771 InputPin_Connect,
772 InputPin_ReceiveConnection,
773 IPinImpl_Disconnect,
774 IPinImpl_ConnectedTo,
775 IPinImpl_ConnectionMediaType,
776 IPinImpl_QueryPinInfo,
777 IPinImpl_QueryDirection,
778 IPinImpl_QueryId,
779 IPinImpl_QueryAccept,
780 IPinImpl_EnumMediaTypes,
781 IPinImpl_QueryInternalConnections,
782 VideoRenderer_InputPin_EndOfStream,
783 InputPin_BeginFlush,
784 InputPin_EndFlush,
785 InputPin_NewSegment
788 /*** IUnknown methods ***/
789 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
790 REFIID riid,
791 LPVOID*ppvObj) {
792 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
794 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
796 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
799 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
800 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
802 TRACE("(%p/%p)->()\n", This, iface);
804 return VideoRenderer_AddRef((IBaseFilter*)This);
807 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
808 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
810 TRACE("(%p/%p)->()\n", This, iface);
812 return VideoRenderer_Release((IBaseFilter*)This);
815 /*** IDispatch methods ***/
816 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
817 UINT*pctinfo) {
818 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
820 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
822 return S_OK;
825 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
826 UINT iTInfo,
827 LCID lcid,
828 ITypeInfo**ppTInfo) {
829 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
831 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
833 return S_OK;
836 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
837 REFIID riid,
838 LPOLESTR*rgszNames,
839 UINT cNames,
840 LCID lcid,
841 DISPID*rgDispId) {
842 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
844 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
846 return S_OK;
849 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
850 DISPID dispIdMember,
851 REFIID riid,
852 LCID lcid,
853 WORD wFlags,
854 DISPPARAMS*pDispParams,
855 VARIANT*pVarResult,
856 EXCEPINFO*pExepInfo,
857 UINT*puArgErr) {
858 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
860 FIXME("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
862 return S_OK;
865 /*** IBasicVideo methods ***/
866 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
867 REFTIME *pAvgTimePerFrame) {
868 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
870 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
872 return S_OK;
875 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
876 long *pBitRate) {
877 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
879 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
881 return S_OK;
884 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
885 long *pBitErrorRate) {
886 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
888 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
890 return S_OK;
893 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
894 long *pVideoWidth) {
895 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
897 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
899 *pVideoWidth = This->VideoWidth;
901 return S_OK;
904 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
905 long *pVideoHeight) {
906 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
908 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
910 *pVideoHeight = This->VideoHeight;
912 return S_OK;
915 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
916 long SourceLeft) {
917 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
919 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
921 This->SourceRect.left = SourceLeft;
923 return S_OK;
926 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
927 long *pSourceLeft) {
928 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
930 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
932 *pSourceLeft = This->SourceRect.left;
934 return S_OK;
937 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
938 long SourceWidth) {
939 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
941 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
943 This->SourceRect.right = This->SourceRect.left + SourceWidth;
945 return S_OK;
948 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
949 long *pSourceWidth) {
950 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
952 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
954 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
956 return S_OK;
959 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
960 long SourceTop) {
961 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
963 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
965 This->SourceRect.top = SourceTop;
967 return S_OK;
970 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
971 long *pSourceTop) {
972 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
974 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
976 *pSourceTop = This->SourceRect.top;
978 return S_OK;
981 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
982 long SourceHeight) {
983 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
985 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
987 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
989 return S_OK;
992 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
993 long *pSourceHeight) {
994 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
996 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
998 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
1000 return S_OK;
1003 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1004 long DestinationLeft) {
1005 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1007 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1009 This->DestRect.left = DestinationLeft;
1011 return S_OK;
1014 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1015 long *pDestinationLeft) {
1016 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1018 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1020 *pDestinationLeft = This->DestRect.left;
1022 return S_OK;
1025 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1026 long DestinationWidth) {
1027 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1029 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1031 This->DestRect.right = This->DestRect.left + DestinationWidth;
1033 return S_OK;
1036 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1037 long *pDestinationWidth) {
1038 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1040 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1042 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1044 return S_OK;
1047 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1048 long DestinationTop) {
1049 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1051 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1053 This->DestRect.top = DestinationTop;
1055 return S_OK;
1058 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1059 long *pDestinationTop) {
1060 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1062 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1064 *pDestinationTop = This->DestRect.top;
1066 return S_OK;
1069 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1070 long DestinationHeight) {
1071 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1073 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1075 This->DestRect.right = This->DestRect.left + DestinationHeight;
1077 return S_OK;
1080 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1081 long *pDestinationHeight) {
1082 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1084 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1086 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1088 return S_OK;
1091 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1092 long Left,
1093 long Top,
1094 long Width,
1095 long Height) {
1096 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1098 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1100 This->SourceRect.left = Left;
1101 This->SourceRect.top = Top;
1102 This->SourceRect.right = Left + Width;
1103 This->SourceRect.bottom = Top + Height;
1105 return S_OK;
1108 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1109 long *pLeft,
1110 long *pTop,
1111 long *pWidth,
1112 long *pHeight) {
1113 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1115 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1117 *pLeft = This->SourceRect.left;
1118 *pTop = This->SourceRect.top;
1119 *pWidth = This->SourceRect.right - This->SourceRect.left;
1120 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1122 return S_OK;
1125 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1126 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1128 TRACE("(%p/%p)->()\n", This, iface);
1130 This->SourceRect.left = 0;
1131 This->SourceRect.top = 0;
1132 This->SourceRect.right = This->VideoWidth;
1133 This->SourceRect.bottom = This->VideoHeight;
1135 return S_OK;
1138 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1139 long Left,
1140 long Top,
1141 long Width,
1142 long Height) {
1143 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1145 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1147 This->DestRect.left = Left;
1148 This->DestRect.top = Top;
1149 This->DestRect.right = Left + Width;
1150 This->DestRect.bottom = Top + Height;
1152 return S_OK;
1155 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1156 long *pLeft,
1157 long *pTop,
1158 long *pWidth,
1159 long *pHeight) {
1160 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1162 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1164 *pLeft = This->DestRect.left;
1165 *pTop = This->DestRect.top;
1166 *pWidth = This->DestRect.right - This->DestRect.left;
1167 *pHeight = This->DestRect.bottom - This->DestRect.top;
1169 return S_OK;
1172 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1173 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1174 RECT rect;
1176 TRACE("(%p/%p)->()\n", This, iface);
1178 if (!GetClientRect(This->hWnd, &rect))
1179 return E_FAIL;
1181 This->SourceRect.left = 0;
1182 This->SourceRect.top = 0;
1183 This->SourceRect.right = rect.right;
1184 This->SourceRect.bottom = rect.bottom;
1186 return S_OK;
1189 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1190 long *pWidth,
1191 long *pHeight) {
1192 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1194 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1196 *pWidth = This->VideoWidth;
1197 *pHeight = This->VideoHeight;
1199 return S_OK;
1202 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1203 long StartIndex,
1204 long Entries,
1205 long *pRetrieved,
1206 long *pPalette) {
1207 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1209 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1211 return S_OK;
1214 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1215 long *pBufferSize,
1216 long *pDIBImage) {
1217 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1219 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
1221 return S_OK;
1224 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1225 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1227 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1229 return S_OK;
1232 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1233 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1235 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1237 return S_OK;
1241 static const IBasicVideoVtbl IBasicVideo_VTable =
1243 Basicvideo_QueryInterface,
1244 Basicvideo_AddRef,
1245 Basicvideo_Release,
1246 Basicvideo_GetTypeInfoCount,
1247 Basicvideo_GetTypeInfo,
1248 Basicvideo_GetIDsOfNames,
1249 Basicvideo_Invoke,
1250 Basicvideo_get_AvgTimePerFrame,
1251 Basicvideo_get_BitRate,
1252 Basicvideo_get_BitErrorRate,
1253 Basicvideo_get_VideoWidth,
1254 Basicvideo_get_VideoHeight,
1255 Basicvideo_put_SourceLeft,
1256 Basicvideo_get_SourceLeft,
1257 Basicvideo_put_SourceWidth,
1258 Basicvideo_get_SourceWidth,
1259 Basicvideo_put_SourceTop,
1260 Basicvideo_get_SourceTop,
1261 Basicvideo_put_SourceHeight,
1262 Basicvideo_get_SourceHeight,
1263 Basicvideo_put_DestinationLeft,
1264 Basicvideo_get_DestinationLeft,
1265 Basicvideo_put_DestinationWidth,
1266 Basicvideo_get_DestinationWidth,
1267 Basicvideo_put_DestinationTop,
1268 Basicvideo_get_DestinationTop,
1269 Basicvideo_put_DestinationHeight,
1270 Basicvideo_get_DestinationHeight,
1271 Basicvideo_SetSourcePosition,
1272 Basicvideo_GetSourcePosition,
1273 Basicvideo_SetDefaultSourcePosition,
1274 Basicvideo_SetDestinationPosition,
1275 Basicvideo_GetDestinationPosition,
1276 Basicvideo_SetDefaultDestinationPosition,
1277 Basicvideo_GetVideoSize,
1278 Basicvideo_GetVideoPaletteEntries,
1279 Basicvideo_GetCurrentImage,
1280 Basicvideo_IsUsingDefaultSource,
1281 Basicvideo_IsUsingDefaultDestination
1285 /*** IUnknown methods ***/
1286 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1287 REFIID riid,
1288 LPVOID*ppvObj) {
1289 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1291 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1293 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1296 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1297 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1299 TRACE("(%p/%p)->()\n", This, iface);
1301 return VideoRenderer_AddRef((IBaseFilter*)This);
1304 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1305 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1307 TRACE("(%p/%p)->()\n", This, iface);
1309 return VideoRenderer_Release((IBaseFilter*)This);
1312 /*** IDispatch methods ***/
1313 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1314 UINT*pctinfo) {
1315 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1317 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1319 return S_OK;
1322 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1323 UINT iTInfo,
1324 LCID lcid,
1325 ITypeInfo**ppTInfo) {
1326 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1328 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1330 return S_OK;
1333 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1334 REFIID riid,
1335 LPOLESTR*rgszNames,
1336 UINT cNames,
1337 LCID lcid,
1338 DISPID*rgDispId) {
1339 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1341 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1343 return S_OK;
1346 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1347 DISPID dispIdMember,
1348 REFIID riid,
1349 LCID lcid,
1350 WORD wFlags,
1351 DISPPARAMS*pDispParams,
1352 VARIANT*pVarResult,
1353 EXCEPINFO*pExepInfo,
1354 UINT*puArgErr) {
1355 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1357 FIXME("(%p/%p)->(%d, %s (%p), %d, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
1359 return S_OK;
1362 /*** IVideoWindow methods ***/
1363 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1364 BSTR strCaption) {
1365 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1367 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1369 if (!SetWindowTextW(This->hWnd, strCaption))
1370 return E_FAIL;
1372 return S_OK;
1375 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1376 BSTR *strCaption) {
1377 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1379 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1381 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1383 return S_OK;
1386 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1387 long WindowStyle) {
1388 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1389 LONG old;
1391 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1393 TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
1395 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1396 return E_INVALIDARG;
1398 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1400 return S_OK;
1403 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1404 long *WindowStyle) {
1405 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1407 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1409 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1411 return S_OK;
1414 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1415 long WindowStyleEx) {
1416 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1418 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1420 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1421 return E_INVALIDARG;
1423 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1424 return E_FAIL;
1426 return S_OK;
1429 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1430 long *WindowStyleEx) {
1431 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1433 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1435 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1437 return S_OK;
1440 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1441 long AutoShow) {
1442 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1444 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1446 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1448 return S_OK;
1451 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1452 long *AutoShow) {
1453 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1455 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1457 *AutoShow = This->AutoShow;
1459 return S_OK;
1462 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1463 long WindowState) {
1464 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1466 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1468 return S_OK;
1471 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1472 long *WindowState) {
1473 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1475 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1477 return S_OK;
1480 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1481 long BackgroundPalette) {
1482 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1484 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1486 return S_OK;
1489 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1490 long *pBackgroundPalette) {
1491 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1493 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1495 return S_OK;
1498 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1499 long Visible) {
1500 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1502 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1504 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1506 return S_OK;
1509 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1510 long *pVisible) {
1511 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1513 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1515 *pVisible = IsWindowVisible(This->hWnd);
1517 return S_OK;
1520 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1521 long Left) {
1522 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1524 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1526 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1527 return E_FAIL;
1529 This->WindowPos.left = Left;
1531 return S_OK;
1534 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1535 long *pLeft) {
1536 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1538 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1540 *pLeft = This->WindowPos.left;
1542 return S_OK;
1545 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1546 long Width) {
1547 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1549 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1551 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1552 return E_FAIL;
1554 This->WindowPos.right = This->WindowPos.left + Width;
1556 return S_OK;
1559 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1560 long *pWidth) {
1561 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1563 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1565 *pWidth = This->WindowPos.right - This->WindowPos.left;
1567 return S_OK;
1570 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1571 long Top) {
1572 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1574 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1576 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1577 return E_FAIL;
1579 This->WindowPos.top = Top;
1581 return S_OK;
1584 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1585 long *pTop) {
1586 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1588 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1590 *pTop = This->WindowPos.top;
1592 return S_OK;
1595 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1596 long Height) {
1597 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1599 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1601 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1602 return E_FAIL;
1604 This->WindowPos.bottom = This->WindowPos.top + Height;
1606 return S_OK;
1609 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1610 long *pHeight) {
1611 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1613 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1615 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1617 return S_OK;
1620 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1621 OAHWND Owner) {
1622 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1624 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1626 SetParent(This->hWnd, (HWND)Owner);
1628 return S_OK;
1631 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1632 OAHWND *Owner) {
1633 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1635 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1637 *(HWND*)Owner = GetParent(This->hWnd);
1639 return S_OK;
1642 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1643 OAHWND Drain) {
1644 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1646 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
1648 This->hWndMsgDrain = (HWND)Drain;
1650 return S_OK;
1653 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1654 OAHWND *Drain) {
1655 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1657 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1659 *Drain = (OAHWND)This->hWndMsgDrain;
1661 return S_OK;
1664 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1665 long *Color) {
1666 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1668 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1670 return S_OK;
1673 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1674 long Color) {
1675 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1677 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1679 return S_OK;
1682 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1683 long *FullScreenMode) {
1684 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1686 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1688 return S_OK;
1691 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1692 long FullScreenMode) {
1693 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1695 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1697 return S_OK;
1700 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1701 long Focus) {
1702 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1703 BOOL ret;
1704 IPin* pPin;
1705 HRESULT hr;
1707 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1709 if ((Focus != FALSE) && (Focus != TRUE))
1710 return E_INVALIDARG;
1712 hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1713 if ((hr != S_OK) || !pPin)
1714 return VFW_E_NOT_CONNECTED;
1716 if (Focus)
1717 ret = SetForegroundWindow(This->hWnd);
1718 else
1719 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1721 if (!ret)
1722 return E_FAIL;
1724 return S_OK;
1727 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1728 OAHWND hwnd,
1729 long uMsg,
1730 LONG_PTR wParam,
1731 LONG_PTR lParam) {
1732 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1734 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
1736 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1737 return E_FAIL;
1739 return S_OK;
1742 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1743 long Left,
1744 long Top,
1745 long Width,
1746 long Height) {
1747 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1749 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1751 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1752 return E_FAIL;
1754 This->WindowPos.left = Left;
1755 This->WindowPos.top = Top;
1756 This->WindowPos.right = Left + Width;
1757 This->WindowPos.bottom = Top + Height;
1759 return S_OK;
1762 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1763 long *pLeft,
1764 long *pTop,
1765 long *pWidth,
1766 long *pHeight) {
1767 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1769 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1771 *pLeft = This->WindowPos.left;
1772 *pTop = This->WindowPos.top;
1773 *pWidth = This->WindowPos.right - This->WindowPos.left;
1774 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1776 return S_OK;
1779 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1780 long *pWidth,
1781 long *pHeight) {
1782 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1784 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1786 *pWidth = This->VideoWidth;
1787 *pHeight = This->VideoHeight;
1789 return S_OK;
1792 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1793 long *pWidth,
1794 long *pHeight) {
1795 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1797 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1799 *pWidth = This->VideoWidth;
1800 *pHeight = This->VideoHeight;
1802 return S_OK;
1805 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1806 long *pLeft,
1807 long *pTop,
1808 long *pWidth,
1809 long *pHeight) {
1810 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1812 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
1814 return S_OK;
1817 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1818 long HideCursor) {
1819 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1821 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
1823 return S_OK;
1826 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1827 long *CursorHidden) {
1828 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1830 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
1832 return S_OK;
1835 static const IVideoWindowVtbl IVideoWindow_VTable =
1837 Videowindow_QueryInterface,
1838 Videowindow_AddRef,
1839 Videowindow_Release,
1840 Videowindow_GetTypeInfoCount,
1841 Videowindow_GetTypeInfo,
1842 Videowindow_GetIDsOfNames,
1843 Videowindow_Invoke,
1844 Videowindow_put_Caption,
1845 Videowindow_get_Caption,
1846 Videowindow_put_WindowStyle,
1847 Videowindow_get_WindowStyle,
1848 Videowindow_put_WindowStyleEx,
1849 Videowindow_get_WindowStyleEx,
1850 Videowindow_put_AutoShow,
1851 Videowindow_get_AutoShow,
1852 Videowindow_put_WindowState,
1853 Videowindow_get_WindowState,
1854 Videowindow_put_BackgroundPalette,
1855 Videowindow_get_BackgroundPalette,
1856 Videowindow_put_Visible,
1857 Videowindow_get_Visible,
1858 Videowindow_put_Left,
1859 Videowindow_get_Left,
1860 Videowindow_put_Width,
1861 Videowindow_get_Width,
1862 Videowindow_put_Top,
1863 Videowindow_get_Top,
1864 Videowindow_put_Height,
1865 Videowindow_get_Height,
1866 Videowindow_put_Owner,
1867 Videowindow_get_Owner,
1868 Videowindow_put_MessageDrain,
1869 Videowindow_get_MessageDrain,
1870 Videowindow_get_BorderColor,
1871 Videowindow_put_BorderColor,
1872 Videowindow_get_FullScreenMode,
1873 Videowindow_put_FullScreenMode,
1874 Videowindow_SetWindowForeground,
1875 Videowindow_NotifyOwnerMessage,
1876 Videowindow_SetWindowPosition,
1877 Videowindow_GetWindowPosition,
1878 Videowindow_GetMinIdealImageSize,
1879 Videowindow_GetMaxIdealImageSize,
1880 Videowindow_GetRestorePosition,
1881 Videowindow_HideCursor,
1882 Videowindow_IsCursorHidden