localui: Add German resources.
[wine/wine64.git] / dlls / quartz / videorenderer.c
bloba7df440cff73165573246200267efd65dd4f5867
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 IPin *pConnectedTo;
527 DestroyWindow(This->hWnd);
528 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
529 WaitForSingleObject(This->hThread, INFINITE);
530 CloseHandle(This->hThread);
532 if (This->pClock)
533 IReferenceClock_Release(This->pClock);
535 if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[0], &pConnectedTo)))
537 IPin_Disconnect(pConnectedTo);
538 IPin_Release(pConnectedTo);
540 IPin_Disconnect(This->ppPins[0]);
542 IPin_Release(This->ppPins[0]);
544 CoTaskMemFree(This->ppPins);
545 This->lpVtbl = NULL;
547 This->csFilter.DebugInfo->Spare[0] = 0;
548 DeleteCriticalSection(&This->csFilter);
550 TRACE("Destroying Video Renderer\n");
551 CoTaskMemFree(This);
553 return 0;
555 else
556 return refCount;
559 /** IPersist methods **/
561 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
563 VideoRendererImpl *This = (VideoRendererImpl *)iface;
565 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
567 *pClsid = CLSID_VideoRenderer;
569 return S_OK;
572 /** IMediaFilter methods **/
574 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
576 VideoRendererImpl *This = (VideoRendererImpl *)iface;
578 TRACE("(%p/%p)->()\n", This, iface);
580 EnterCriticalSection(&This->csFilter);
582 This->state = State_Stopped;
584 LeaveCriticalSection(&This->csFilter);
586 return S_OK;
589 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
591 VideoRendererImpl *This = (VideoRendererImpl *)iface;
593 TRACE("(%p/%p)->()\n", This, iface);
595 EnterCriticalSection(&This->csFilter);
597 This->state = State_Paused;
599 LeaveCriticalSection(&This->csFilter);
601 return S_OK;
604 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
606 VideoRendererImpl *This = (VideoRendererImpl *)iface;
608 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
610 EnterCriticalSection(&This->csFilter);
612 This->rtStreamStart = tStart;
613 This->state = State_Running;
615 LeaveCriticalSection(&This->csFilter);
617 return S_OK;
620 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
622 VideoRendererImpl *This = (VideoRendererImpl *)iface;
624 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
626 EnterCriticalSection(&This->csFilter);
628 *pState = This->state;
630 LeaveCriticalSection(&This->csFilter);
632 return S_OK;
635 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
637 VideoRendererImpl *This = (VideoRendererImpl *)iface;
639 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
641 EnterCriticalSection(&This->csFilter);
643 if (This->pClock)
644 IReferenceClock_Release(This->pClock);
645 This->pClock = pClock;
646 if (This->pClock)
647 IReferenceClock_AddRef(This->pClock);
649 LeaveCriticalSection(&This->csFilter);
651 return S_OK;
654 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
656 VideoRendererImpl *This = (VideoRendererImpl *)iface;
658 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
660 EnterCriticalSection(&This->csFilter);
662 *ppClock = This->pClock;
663 IReferenceClock_AddRef(This->pClock);
665 LeaveCriticalSection(&This->csFilter);
667 return S_OK;
670 /** IBaseFilter implementation **/
672 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
674 ENUMPINDETAILS epd;
675 VideoRendererImpl *This = (VideoRendererImpl *)iface;
677 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
679 epd.cPins = 1; /* input pin */
680 epd.ppPins = This->ppPins;
681 return IEnumPinsImpl_Construct(&epd, ppEnum);
684 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
686 VideoRendererImpl *This = (VideoRendererImpl *)iface;
688 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
690 FIXME("VideoRenderer::FindPin(...)\n");
692 /* FIXME: critical section */
694 return E_NOTIMPL;
697 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
699 VideoRendererImpl *This = (VideoRendererImpl *)iface;
701 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
703 strcpyW(pInfo->achName, This->filterInfo.achName);
704 pInfo->pGraph = This->filterInfo.pGraph;
706 if (pInfo->pGraph)
707 IFilterGraph_AddRef(pInfo->pGraph);
709 return S_OK;
712 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
714 VideoRendererImpl *This = (VideoRendererImpl *)iface;
716 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
718 EnterCriticalSection(&This->csFilter);
720 if (pName)
721 strcpyW(This->filterInfo.achName, pName);
722 else
723 *This->filterInfo.achName = '\0';
724 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
726 LeaveCriticalSection(&This->csFilter);
728 return S_OK;
731 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
733 VideoRendererImpl *This = (VideoRendererImpl *)iface;
734 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
735 return E_NOTIMPL;
738 static const IBaseFilterVtbl VideoRenderer_Vtbl =
740 VideoRenderer_QueryInterface,
741 VideoRenderer_AddRef,
742 VideoRenderer_Release,
743 VideoRenderer_GetClassID,
744 VideoRenderer_Stop,
745 VideoRenderer_Pause,
746 VideoRenderer_Run,
747 VideoRenderer_GetState,
748 VideoRenderer_SetSyncSource,
749 VideoRenderer_GetSyncSource,
750 VideoRenderer_EnumPins,
751 VideoRenderer_FindPin,
752 VideoRenderer_QueryFilterInfo,
753 VideoRenderer_JoinFilterGraph,
754 VideoRenderer_QueryVendorInfo
757 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
759 InputPin* This = (InputPin*)iface;
760 IMediaEventSink* pEventSink;
761 HRESULT hr;
763 TRACE("(%p/%p)->()\n", This, iface);
765 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
766 if (SUCCEEDED(hr))
768 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
769 IMediaEventSink_Release(pEventSink);
772 return hr;
775 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
777 InputPin_QueryInterface,
778 IPinImpl_AddRef,
779 InputPin_Release,
780 InputPin_Connect,
781 InputPin_ReceiveConnection,
782 IPinImpl_Disconnect,
783 IPinImpl_ConnectedTo,
784 IPinImpl_ConnectionMediaType,
785 IPinImpl_QueryPinInfo,
786 IPinImpl_QueryDirection,
787 IPinImpl_QueryId,
788 IPinImpl_QueryAccept,
789 IPinImpl_EnumMediaTypes,
790 IPinImpl_QueryInternalConnections,
791 VideoRenderer_InputPin_EndOfStream,
792 InputPin_BeginFlush,
793 InputPin_EndFlush,
794 InputPin_NewSegment
797 /*** IUnknown methods ***/
798 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
799 REFIID riid,
800 LPVOID*ppvObj) {
801 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
803 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
805 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
808 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
809 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
811 TRACE("(%p/%p)->()\n", This, iface);
813 return VideoRenderer_AddRef((IBaseFilter*)This);
816 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
817 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
819 TRACE("(%p/%p)->()\n", This, iface);
821 return VideoRenderer_Release((IBaseFilter*)This);
824 /*** IDispatch methods ***/
825 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
826 UINT*pctinfo) {
827 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
829 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
831 return S_OK;
834 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
835 UINT iTInfo,
836 LCID lcid,
837 ITypeInfo**ppTInfo) {
838 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
840 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
842 return S_OK;
845 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
846 REFIID riid,
847 LPOLESTR*rgszNames,
848 UINT cNames,
849 LCID lcid,
850 DISPID*rgDispId) {
851 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
853 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
855 return S_OK;
858 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
859 DISPID dispIdMember,
860 REFIID riid,
861 LCID lcid,
862 WORD wFlags,
863 DISPPARAMS*pDispParams,
864 VARIANT*pVarResult,
865 EXCEPINFO*pExepInfo,
866 UINT*puArgErr) {
867 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
869 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);
871 return S_OK;
874 /*** IBasicVideo methods ***/
875 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
876 REFTIME *pAvgTimePerFrame) {
877 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
879 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
881 return S_OK;
884 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
885 long *pBitRate) {
886 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
888 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
890 return S_OK;
893 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
894 long *pBitErrorRate) {
895 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
897 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
899 return S_OK;
902 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
903 long *pVideoWidth) {
904 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
906 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
908 *pVideoWidth = This->VideoWidth;
910 return S_OK;
913 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
914 long *pVideoHeight) {
915 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
917 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
919 *pVideoHeight = This->VideoHeight;
921 return S_OK;
924 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
925 long SourceLeft) {
926 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
928 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
930 This->SourceRect.left = SourceLeft;
932 return S_OK;
935 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
936 long *pSourceLeft) {
937 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
939 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
941 *pSourceLeft = This->SourceRect.left;
943 return S_OK;
946 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
947 long SourceWidth) {
948 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
950 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
952 This->SourceRect.right = This->SourceRect.left + SourceWidth;
954 return S_OK;
957 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
958 long *pSourceWidth) {
959 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
961 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
963 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
965 return S_OK;
968 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
969 long SourceTop) {
970 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
972 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
974 This->SourceRect.top = SourceTop;
976 return S_OK;
979 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
980 long *pSourceTop) {
981 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
983 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
985 *pSourceTop = This->SourceRect.top;
987 return S_OK;
990 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
991 long SourceHeight) {
992 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
994 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
996 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
998 return S_OK;
1001 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
1002 long *pSourceHeight) {
1003 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1005 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1007 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
1009 return S_OK;
1012 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1013 long DestinationLeft) {
1014 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1016 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1018 This->DestRect.left = DestinationLeft;
1020 return S_OK;
1023 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1024 long *pDestinationLeft) {
1025 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1027 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1029 *pDestinationLeft = This->DestRect.left;
1031 return S_OK;
1034 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1035 long DestinationWidth) {
1036 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1038 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1040 This->DestRect.right = This->DestRect.left + DestinationWidth;
1042 return S_OK;
1045 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1046 long *pDestinationWidth) {
1047 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1049 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1051 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1053 return S_OK;
1056 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1057 long DestinationTop) {
1058 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1060 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1062 This->DestRect.top = DestinationTop;
1064 return S_OK;
1067 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1068 long *pDestinationTop) {
1069 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1071 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1073 *pDestinationTop = This->DestRect.top;
1075 return S_OK;
1078 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1079 long DestinationHeight) {
1080 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1082 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1084 This->DestRect.right = This->DestRect.left + DestinationHeight;
1086 return S_OK;
1089 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1090 long *pDestinationHeight) {
1091 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1093 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1095 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1097 return S_OK;
1100 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1101 long Left,
1102 long Top,
1103 long Width,
1104 long Height) {
1105 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1107 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1109 This->SourceRect.left = Left;
1110 This->SourceRect.top = Top;
1111 This->SourceRect.right = Left + Width;
1112 This->SourceRect.bottom = Top + Height;
1114 return S_OK;
1117 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1118 long *pLeft,
1119 long *pTop,
1120 long *pWidth,
1121 long *pHeight) {
1122 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1124 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1126 *pLeft = This->SourceRect.left;
1127 *pTop = This->SourceRect.top;
1128 *pWidth = This->SourceRect.right - This->SourceRect.left;
1129 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1131 return S_OK;
1134 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1135 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1137 TRACE("(%p/%p)->()\n", This, iface);
1139 This->SourceRect.left = 0;
1140 This->SourceRect.top = 0;
1141 This->SourceRect.right = This->VideoWidth;
1142 This->SourceRect.bottom = This->VideoHeight;
1144 return S_OK;
1147 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1148 long Left,
1149 long Top,
1150 long Width,
1151 long Height) {
1152 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1154 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1156 This->DestRect.left = Left;
1157 This->DestRect.top = Top;
1158 This->DestRect.right = Left + Width;
1159 This->DestRect.bottom = Top + Height;
1161 return S_OK;
1164 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1165 long *pLeft,
1166 long *pTop,
1167 long *pWidth,
1168 long *pHeight) {
1169 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1171 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1173 *pLeft = This->DestRect.left;
1174 *pTop = This->DestRect.top;
1175 *pWidth = This->DestRect.right - This->DestRect.left;
1176 *pHeight = This->DestRect.bottom - This->DestRect.top;
1178 return S_OK;
1181 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1182 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1183 RECT rect;
1185 TRACE("(%p/%p)->()\n", This, iface);
1187 if (!GetClientRect(This->hWnd, &rect))
1188 return E_FAIL;
1190 This->SourceRect.left = 0;
1191 This->SourceRect.top = 0;
1192 This->SourceRect.right = rect.right;
1193 This->SourceRect.bottom = rect.bottom;
1195 return S_OK;
1198 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1199 long *pWidth,
1200 long *pHeight) {
1201 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1203 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1205 *pWidth = This->VideoWidth;
1206 *pHeight = This->VideoHeight;
1208 return S_OK;
1211 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1212 long StartIndex,
1213 long Entries,
1214 long *pRetrieved,
1215 long *pPalette) {
1216 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1218 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1220 return S_OK;
1223 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1224 long *pBufferSize,
1225 long *pDIBImage) {
1226 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1228 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
1230 return S_OK;
1233 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1234 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1236 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1238 return S_OK;
1241 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1242 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1244 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1246 return S_OK;
1250 static const IBasicVideoVtbl IBasicVideo_VTable =
1252 Basicvideo_QueryInterface,
1253 Basicvideo_AddRef,
1254 Basicvideo_Release,
1255 Basicvideo_GetTypeInfoCount,
1256 Basicvideo_GetTypeInfo,
1257 Basicvideo_GetIDsOfNames,
1258 Basicvideo_Invoke,
1259 Basicvideo_get_AvgTimePerFrame,
1260 Basicvideo_get_BitRate,
1261 Basicvideo_get_BitErrorRate,
1262 Basicvideo_get_VideoWidth,
1263 Basicvideo_get_VideoHeight,
1264 Basicvideo_put_SourceLeft,
1265 Basicvideo_get_SourceLeft,
1266 Basicvideo_put_SourceWidth,
1267 Basicvideo_get_SourceWidth,
1268 Basicvideo_put_SourceTop,
1269 Basicvideo_get_SourceTop,
1270 Basicvideo_put_SourceHeight,
1271 Basicvideo_get_SourceHeight,
1272 Basicvideo_put_DestinationLeft,
1273 Basicvideo_get_DestinationLeft,
1274 Basicvideo_put_DestinationWidth,
1275 Basicvideo_get_DestinationWidth,
1276 Basicvideo_put_DestinationTop,
1277 Basicvideo_get_DestinationTop,
1278 Basicvideo_put_DestinationHeight,
1279 Basicvideo_get_DestinationHeight,
1280 Basicvideo_SetSourcePosition,
1281 Basicvideo_GetSourcePosition,
1282 Basicvideo_SetDefaultSourcePosition,
1283 Basicvideo_SetDestinationPosition,
1284 Basicvideo_GetDestinationPosition,
1285 Basicvideo_SetDefaultDestinationPosition,
1286 Basicvideo_GetVideoSize,
1287 Basicvideo_GetVideoPaletteEntries,
1288 Basicvideo_GetCurrentImage,
1289 Basicvideo_IsUsingDefaultSource,
1290 Basicvideo_IsUsingDefaultDestination
1294 /*** IUnknown methods ***/
1295 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1296 REFIID riid,
1297 LPVOID*ppvObj) {
1298 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1300 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1302 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1305 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1306 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1308 TRACE("(%p/%p)->()\n", This, iface);
1310 return VideoRenderer_AddRef((IBaseFilter*)This);
1313 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1314 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1316 TRACE("(%p/%p)->()\n", This, iface);
1318 return VideoRenderer_Release((IBaseFilter*)This);
1321 /*** IDispatch methods ***/
1322 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1323 UINT*pctinfo) {
1324 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1326 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1328 return S_OK;
1331 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1332 UINT iTInfo,
1333 LCID lcid,
1334 ITypeInfo**ppTInfo) {
1335 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1337 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1339 return S_OK;
1342 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1343 REFIID riid,
1344 LPOLESTR*rgszNames,
1345 UINT cNames,
1346 LCID lcid,
1347 DISPID*rgDispId) {
1348 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1350 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1352 return S_OK;
1355 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1356 DISPID dispIdMember,
1357 REFIID riid,
1358 LCID lcid,
1359 WORD wFlags,
1360 DISPPARAMS*pDispParams,
1361 VARIANT*pVarResult,
1362 EXCEPINFO*pExepInfo,
1363 UINT*puArgErr) {
1364 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1366 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);
1368 return S_OK;
1371 /*** IVideoWindow methods ***/
1372 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1373 BSTR strCaption) {
1374 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1376 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1378 if (!SetWindowTextW(This->hWnd, strCaption))
1379 return E_FAIL;
1381 return S_OK;
1384 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1385 BSTR *strCaption) {
1386 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1388 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1390 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1392 return S_OK;
1395 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1396 long WindowStyle) {
1397 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1398 LONG old;
1400 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1402 TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
1404 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1405 return E_INVALIDARG;
1407 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1409 return S_OK;
1412 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1413 long *WindowStyle) {
1414 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1416 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1418 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1420 return S_OK;
1423 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1424 long WindowStyleEx) {
1425 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1427 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1429 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1430 return E_INVALIDARG;
1432 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1433 return E_FAIL;
1435 return S_OK;
1438 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1439 long *WindowStyleEx) {
1440 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1442 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1444 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1446 return S_OK;
1449 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1450 long AutoShow) {
1451 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1453 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1455 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1457 return S_OK;
1460 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1461 long *AutoShow) {
1462 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1464 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1466 *AutoShow = This->AutoShow;
1468 return S_OK;
1471 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1472 long WindowState) {
1473 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1475 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1477 return S_OK;
1480 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1481 long *WindowState) {
1482 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1484 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1486 return S_OK;
1489 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1490 long BackgroundPalette) {
1491 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1493 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1495 return S_OK;
1498 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1499 long *pBackgroundPalette) {
1500 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1502 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1504 return S_OK;
1507 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1508 long Visible) {
1509 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1511 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1513 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1515 return S_OK;
1518 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1519 long *pVisible) {
1520 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1522 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1524 *pVisible = IsWindowVisible(This->hWnd);
1526 return S_OK;
1529 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1530 long Left) {
1531 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1533 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1535 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1536 return E_FAIL;
1538 This->WindowPos.left = Left;
1540 return S_OK;
1543 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1544 long *pLeft) {
1545 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1547 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1549 *pLeft = This->WindowPos.left;
1551 return S_OK;
1554 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1555 long Width) {
1556 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1558 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1560 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1561 return E_FAIL;
1563 This->WindowPos.right = This->WindowPos.left + Width;
1565 return S_OK;
1568 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1569 long *pWidth) {
1570 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1572 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1574 *pWidth = This->WindowPos.right - This->WindowPos.left;
1576 return S_OK;
1579 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1580 long Top) {
1581 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1583 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1585 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1586 return E_FAIL;
1588 This->WindowPos.top = Top;
1590 return S_OK;
1593 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1594 long *pTop) {
1595 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1597 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1599 *pTop = This->WindowPos.top;
1601 return S_OK;
1604 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1605 long Height) {
1606 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1608 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1610 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1611 return E_FAIL;
1613 This->WindowPos.bottom = This->WindowPos.top + Height;
1615 return S_OK;
1618 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1619 long *pHeight) {
1620 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1622 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1624 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1626 return S_OK;
1629 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1630 OAHWND Owner) {
1631 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1633 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1635 SetParent(This->hWnd, (HWND)Owner);
1637 return S_OK;
1640 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1641 OAHWND *Owner) {
1642 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1644 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1646 *(HWND*)Owner = GetParent(This->hWnd);
1648 return S_OK;
1651 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1652 OAHWND Drain) {
1653 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1655 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
1657 This->hWndMsgDrain = (HWND)Drain;
1659 return S_OK;
1662 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1663 OAHWND *Drain) {
1664 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1666 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1668 *Drain = (OAHWND)This->hWndMsgDrain;
1670 return S_OK;
1673 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1674 long *Color) {
1675 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1677 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1679 return S_OK;
1682 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1683 long Color) {
1684 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1686 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1688 return S_OK;
1691 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1692 long *FullScreenMode) {
1693 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1695 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1697 return S_OK;
1700 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1701 long FullScreenMode) {
1702 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1704 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1706 return S_OK;
1709 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1710 long Focus) {
1711 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1712 BOOL ret;
1713 IPin* pPin;
1714 HRESULT hr;
1716 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1718 if ((Focus != FALSE) && (Focus != TRUE))
1719 return E_INVALIDARG;
1721 hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1722 if ((hr != S_OK) || !pPin)
1723 return VFW_E_NOT_CONNECTED;
1725 if (Focus)
1726 ret = SetForegroundWindow(This->hWnd);
1727 else
1728 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1730 if (!ret)
1731 return E_FAIL;
1733 return S_OK;
1736 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1737 OAHWND hwnd,
1738 long uMsg,
1739 LONG_PTR wParam,
1740 LONG_PTR lParam) {
1741 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1743 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
1745 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1746 return E_FAIL;
1748 return S_OK;
1751 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1752 long Left,
1753 long Top,
1754 long Width,
1755 long Height) {
1756 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1758 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1760 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1761 return E_FAIL;
1763 This->WindowPos.left = Left;
1764 This->WindowPos.top = Top;
1765 This->WindowPos.right = Left + Width;
1766 This->WindowPos.bottom = Top + Height;
1768 return S_OK;
1771 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1772 long *pLeft,
1773 long *pTop,
1774 long *pWidth,
1775 long *pHeight) {
1776 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1778 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1780 *pLeft = This->WindowPos.left;
1781 *pTop = This->WindowPos.top;
1782 *pWidth = This->WindowPos.right - This->WindowPos.left;
1783 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1785 return S_OK;
1788 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1789 long *pWidth,
1790 long *pHeight) {
1791 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1793 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1795 *pWidth = This->VideoWidth;
1796 *pHeight = This->VideoHeight;
1798 return S_OK;
1801 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1802 long *pWidth,
1803 long *pHeight) {
1804 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1806 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1808 *pWidth = This->VideoWidth;
1809 *pHeight = This->VideoHeight;
1811 return S_OK;
1814 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1815 long *pLeft,
1816 long *pTop,
1817 long *pWidth,
1818 long *pHeight) {
1819 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1821 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
1823 return S_OK;
1826 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1827 long HideCursor) {
1828 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1830 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
1832 return S_OK;
1835 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1836 long *CursorHidden) {
1837 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1839 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
1841 return S_OK;
1844 static const IVideoWindowVtbl IVideoWindow_VTable =
1846 Videowindow_QueryInterface,
1847 Videowindow_AddRef,
1848 Videowindow_Release,
1849 Videowindow_GetTypeInfoCount,
1850 Videowindow_GetTypeInfo,
1851 Videowindow_GetIDsOfNames,
1852 Videowindow_Invoke,
1853 Videowindow_put_Caption,
1854 Videowindow_get_Caption,
1855 Videowindow_put_WindowStyle,
1856 Videowindow_get_WindowStyle,
1857 Videowindow_put_WindowStyleEx,
1858 Videowindow_get_WindowStyleEx,
1859 Videowindow_put_AutoShow,
1860 Videowindow_get_AutoShow,
1861 Videowindow_put_WindowState,
1862 Videowindow_get_WindowState,
1863 Videowindow_put_BackgroundPalette,
1864 Videowindow_get_BackgroundPalette,
1865 Videowindow_put_Visible,
1866 Videowindow_get_Visible,
1867 Videowindow_put_Left,
1868 Videowindow_get_Left,
1869 Videowindow_put_Width,
1870 Videowindow_get_Width,
1871 Videowindow_put_Top,
1872 Videowindow_get_Top,
1873 Videowindow_put_Height,
1874 Videowindow_get_Height,
1875 Videowindow_put_Owner,
1876 Videowindow_get_Owner,
1877 Videowindow_put_MessageDrain,
1878 Videowindow_get_MessageDrain,
1879 Videowindow_get_BorderColor,
1880 Videowindow_put_BorderColor,
1881 Videowindow_get_FullScreenMode,
1882 Videowindow_put_FullScreenMode,
1883 Videowindow_SetWindowForeground,
1884 Videowindow_NotifyOwnerMessage,
1885 Videowindow_SetWindowPosition,
1886 Videowindow_GetWindowPosition,
1887 Videowindow_GetMinIdealImageSize,
1888 Videowindow_GetMaxIdealImageSize,
1889 Videowindow_GetRestorePosition,
1890 Videowindow_HideCursor,
1891 Videowindow_IsCursorHidden