Release 0.9.39.
[wine/gsoc-2012-control.git] / dlls / quartz / videorenderer.c
blobb42338c62d08539e965a34cebe4c82c1687904d5
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 "vfwmsgs.h"
31 #include "amvideo.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "dshow.h"
35 #include "evcode.h"
36 #include "strmif.h"
37 #include "ddraw.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
44 static BOOL wnd_class_registered = FALSE;
46 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
48 static const IBaseFilterVtbl VideoRenderer_Vtbl;
49 static const IBasicVideoVtbl IBasicVideo_VTable;
50 static const IVideoWindowVtbl IVideoWindow_VTable;
51 static const IPinVtbl VideoRenderer_InputPin_Vtbl;
53 typedef struct VideoRendererImpl
55 const IBaseFilterVtbl * lpVtbl;
56 const IBasicVideoVtbl * IBasicVideo_vtbl;
57 const IVideoWindowVtbl * IVideoWindow_vtbl;
59 LONG refCount;
60 CRITICAL_SECTION csFilter;
61 FILTER_STATE state;
62 REFERENCE_TIME rtStreamStart;
63 IReferenceClock * pClock;
64 FILTER_INFO filterInfo;
66 InputPin * pInputPin;
67 IPin ** ppPins;
69 BOOL init;
70 HANDLE hThread;
71 DWORD ThreadID;
72 HANDLE hEvent;
73 BOOL ThreadResult;
74 HWND hWnd;
75 HWND hWndMsgDrain;
76 BOOL AutoShow;
77 RECT SourceRect;
78 RECT DestRect;
79 RECT WindowPos;
80 long VideoWidth;
81 long VideoHeight;
82 } VideoRendererImpl;
84 static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
86 VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongA(hwnd, 0);
87 LPRECT lprect = (LPRECT)lParam;
89 if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
91 switch(uMsg)
93 case WM_KEYDOWN:
94 case WM_KEYUP:
95 case WM_LBUTTONDBLCLK:
96 case WM_LBUTTONDOWN:
97 case WM_LBUTTONUP:
98 case WM_MBUTTONDBLCLK:
99 case WM_MBUTTONDOWN:
100 case WM_MBUTTONUP:
101 case WM_MOUSEACTIVATE:
102 case WM_MOUSEMOVE:
103 case WM_NCLBUTTONDBLCLK:
104 case WM_NCLBUTTONDOWN:
105 case WM_NCLBUTTONUP:
106 case WM_NCMBUTTONDBLCLK:
107 case WM_NCMBUTTONDOWN:
108 case WM_NCMBUTTONUP:
109 case WM_NCMOUSEMOVE:
110 case WM_NCRBUTTONDBLCLK:
111 case WM_NCRBUTTONDOWN:
112 case WM_NCRBUTTONUP:
113 case WM_RBUTTONDBLCLK:
114 case WM_RBUTTONDOWN:
115 case WM_RBUTTONUP:
116 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
117 break;
118 default:
119 break;
123 switch(uMsg)
125 case WM_SIZING:
126 /* TRACE("WM_SIZING %d %d %d %d\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
127 SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
128 GetClientRect(hwnd, &pVideoRenderer->DestRect);
129 return TRUE;
130 default:
131 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
133 return 0;
136 static BOOL CreateRenderingWindow(VideoRendererImpl* This)
138 WNDCLASSA winclass;
140 TRACE("(%p)->()\n", This);
142 winclass.style = 0;
143 winclass.lpfnWndProc = VideoWndProcA;
144 winclass.cbClsExtra = 0;
145 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
146 winclass.hInstance = NULL;
147 winclass.hIcon = NULL;
148 winclass.hCursor = NULL;
149 winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
150 winclass.lpszMenuName = NULL;
151 winclass.lpszClassName = "Wine ActiveMovie Class";
153 if (!wnd_class_registered)
155 if (!RegisterClassA(&winclass))
157 ERR("Unable to register window %u\n", GetLastError());
158 return FALSE;
160 wnd_class_registered = TRUE;
163 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
164 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
165 NULL, NULL, NULL);
167 if (!This->hWnd)
169 ERR("Unable to create window\n");
170 return FALSE;
173 SetWindowLongA(This->hWnd, 0, (LONG)This);
175 return TRUE;
178 static DWORD WINAPI MessageLoop(LPVOID lpParameter)
180 VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
181 MSG msg;
182 BOOL fGotMessage;
184 TRACE("Starting message loop\n");
186 if (!CreateRenderingWindow(This))
188 This->ThreadResult = FALSE;
189 SetEvent(This->hEvent);
190 return 0;
193 This->ThreadResult = TRUE;
194 SetEvent(This->hEvent);
196 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
198 TranslateMessage(&msg);
199 DispatchMessageA(&msg);
202 TRACE("End of message loop\n");
204 return msg.wParam;
207 static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
209 This->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
210 if (!This->hEvent)
211 return FALSE;
213 This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
214 if (!This->hThread)
216 CloseHandle(This->hEvent);
217 return FALSE;
220 WaitForSingleObject(This->hEvent, INFINITE);
221 CloseHandle(This->hEvent);
223 if (!This->ThreadResult)
225 CloseHandle(This->hThread);
226 return FALSE;
229 return TRUE;
232 static const IMemInputPinVtbl MemInputPin_Vtbl =
234 MemInputPin_QueryInterface,
235 MemInputPin_AddRef,
236 MemInputPin_Release,
237 MemInputPin_GetAllocator,
238 MemInputPin_NotifyAllocator,
239 MemInputPin_GetAllocatorRequirements,
240 MemInputPin_Receive,
241 MemInputPin_ReceiveMultiple,
242 MemInputPin_ReceiveCanBlock
245 static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
247 InputPin * pPinImpl;
249 *ppPin = NULL;
251 if (pPinInfo->dir != PINDIR_INPUT)
253 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
254 return E_INVALIDARG;
257 pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
259 if (!pPinImpl)
260 return E_OUTOFMEMORY;
262 if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
264 pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl;
265 pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
267 *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
268 return S_OK;
270 return E_FAIL;
273 static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
275 VIDEOINFOHEADER* format;
276 AM_MEDIA_TYPE amt;
277 HRESULT hr = S_OK;
278 DDSURFACEDESC sdesc;
279 int width;
280 int height;
281 LPBYTE palette = NULL;
282 HDC hDC;
284 TRACE("%p %p %d\n", This, data, size);
286 sdesc.dwSize = sizeof(sdesc);
287 hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
288 if (FAILED(hr)) {
289 ERR("Unable to retrieve media type\n");
290 return hr;
292 format = (VIDEOINFOHEADER*)amt.pbFormat;
294 TRACE("biSize = %d\n", format->bmiHeader.biSize);
295 TRACE("biWidth = %d\n", format->bmiHeader.biWidth);
296 TRACE("biHeight = %d\n", format->bmiHeader.biHeight);
297 TRACE("biPlanes = %d\n", format->bmiHeader.biPlanes);
298 TRACE("biBitCount = %d\n", format->bmiHeader.biBitCount);
299 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(format->bmiHeader.biCompression), 4));
300 TRACE("biSizeImage = %d\n", format->bmiHeader.biSizeImage);
302 width = format->bmiHeader.biWidth;
303 height = format->bmiHeader.biHeight;
304 palette = ((LPBYTE)&format->bmiHeader) + format->bmiHeader.biSize;
306 if (!This->init)
308 /* Compute the size of the whole window so the client area size matches video one */
309 RECT wrect, crect;
310 int h, v;
311 GetWindowRect(This->hWnd, &wrect);
312 GetClientRect(This->hWnd, &crect);
313 h = (wrect.right - wrect.left) - (crect.right - crect.left);
314 v = (wrect.bottom - wrect.top) - (crect.bottom - crect.top);
315 SetWindowPos(This->hWnd, NULL, 0, 0, width + h +20, height + v+20, SWP_NOZORDER|SWP_NOMOVE);
316 This->WindowPos.left = 0;
317 This->WindowPos.top = 0;
318 This->WindowPos.right = width;
319 This->WindowPos.bottom = abs(height);
320 GetClientRect(This->hWnd, &This->DestRect);
321 This->init = TRUE;
324 hDC = GetDC(This->hWnd);
326 if (!hDC) {
327 ERR("Cannot get DC from window!\n");
328 return E_FAIL;
331 TRACE("Src Rect: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
332 TRACE("Dst Rect: %d %d %d %d\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom);
334 StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
335 This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
336 This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
337 data, (BITMAPINFO*)&format->bmiHeader, DIB_RGB_COLORS, SRCCOPY);
339 ReleaseDC(This->hWnd, hDC);
341 if (This->AutoShow)
342 ShowWindow(This->hWnd, SW_SHOW);
344 return S_OK;
347 static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
349 VideoRendererImpl *This = (VideoRendererImpl *)iface;
350 LPBYTE pbSrcStream = NULL;
351 long cbSrcStream = 0;
352 REFERENCE_TIME tStart, tStop;
353 HRESULT hr;
355 TRACE("%p %p\n", iface, pSample);
357 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
358 if (FAILED(hr))
360 ERR("Cannot get pointer to sample data (%x)\n", hr);
361 return hr;
364 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
365 if (FAILED(hr))
366 ERR("Cannot get sample time (%x)\n", hr);
368 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
370 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
372 #if 0 /* For debugging purpose */
374 int i;
375 for(i = 0; i < cbSrcStream; i++)
377 if ((i!=0) && !(i%16))
378 TRACE("\n");
379 TRACE("%02x ", pbSrcStream[i]);
381 TRACE("\n");
383 #endif
385 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
387 return S_OK;
390 static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
392 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
393 return S_FALSE;
395 if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
396 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
397 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
398 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
400 VideoRendererImpl* This = (VideoRendererImpl*) iface;
401 VIDEOINFOHEADER* format = (VIDEOINFOHEADER*)pmt->pbFormat;
403 if (!IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
405 WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
406 return S_FALSE;
408 This->SourceRect.left = 0;
409 This->SourceRect.top = 0;
410 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
411 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
412 return S_OK;
414 return S_FALSE;
417 HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
419 HRESULT hr;
420 PIN_INFO piInput;
421 VideoRendererImpl * pVideoRenderer;
423 TRACE("(%p, %p)\n", pUnkOuter, ppv);
425 *ppv = NULL;
427 if (pUnkOuter)
428 return CLASS_E_NOAGGREGATION;
430 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
432 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
433 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
434 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
436 pVideoRenderer->refCount = 1;
437 InitializeCriticalSection(&pVideoRenderer->csFilter);
438 pVideoRenderer->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
439 pVideoRenderer->state = State_Stopped;
440 pVideoRenderer->pClock = NULL;
441 pVideoRenderer->init = 0;
442 pVideoRenderer->AutoShow = 1;
443 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
445 pVideoRenderer->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
447 /* construct input pin */
448 piInput.dir = PINDIR_INPUT;
449 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
450 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
452 hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
454 if (SUCCEEDED(hr))
456 pVideoRenderer->ppPins[0] = (IPin *)pVideoRenderer->pInputPin;
457 *ppv = (LPVOID)pVideoRenderer;
459 else
461 CoTaskMemFree(pVideoRenderer->ppPins);
462 pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
463 DeleteCriticalSection(&pVideoRenderer->csFilter);
464 CoTaskMemFree(pVideoRenderer);
467 if (!CreateRenderingSubsystem(pVideoRenderer))
468 return E_FAIL;
470 return hr;
473 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
475 VideoRendererImpl *This = (VideoRendererImpl *)iface;
476 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
478 *ppv = NULL;
480 if (IsEqualIID(riid, &IID_IUnknown))
481 *ppv = (LPVOID)This;
482 else if (IsEqualIID(riid, &IID_IPersist))
483 *ppv = (LPVOID)This;
484 else if (IsEqualIID(riid, &IID_IMediaFilter))
485 *ppv = (LPVOID)This;
486 else if (IsEqualIID(riid, &IID_IBaseFilter))
487 *ppv = (LPVOID)This;
488 else if (IsEqualIID(riid, &IID_IBasicVideo))
489 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
490 else if (IsEqualIID(riid, &IID_IVideoWindow))
491 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
493 if (*ppv)
495 IUnknown_AddRef((IUnknown *)(*ppv));
496 return S_OK;
499 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
501 return E_NOINTERFACE;
504 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
506 VideoRendererImpl *This = (VideoRendererImpl *)iface;
507 ULONG refCount = InterlockedIncrement(&This->refCount);
509 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
511 return refCount;
514 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
516 VideoRendererImpl *This = (VideoRendererImpl *)iface;
517 ULONG refCount = InterlockedDecrement(&This->refCount);
519 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
521 if (!refCount)
523 IPin *pConnectedTo;
525 DestroyWindow(This->hWnd);
526 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
527 WaitForSingleObject(This->hThread, INFINITE);
528 CloseHandle(This->hThread);
530 if (This->pClock)
531 IReferenceClock_Release(This->pClock);
533 if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[0], &pConnectedTo)))
535 IPin_Disconnect(pConnectedTo);
536 IPin_Release(pConnectedTo);
538 IPin_Disconnect(This->ppPins[0]);
540 IPin_Release(This->ppPins[0]);
542 CoTaskMemFree(This->ppPins);
543 This->lpVtbl = NULL;
545 This->csFilter.DebugInfo->Spare[0] = 0;
546 DeleteCriticalSection(&This->csFilter);
548 TRACE("Destroying Video Renderer\n");
549 CoTaskMemFree(This);
551 return 0;
553 else
554 return refCount;
557 /** IPersist methods **/
559 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
561 VideoRendererImpl *This = (VideoRendererImpl *)iface;
563 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
565 *pClsid = CLSID_VideoRenderer;
567 return S_OK;
570 /** IMediaFilter methods **/
572 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
574 VideoRendererImpl *This = (VideoRendererImpl *)iface;
576 TRACE("(%p/%p)->()\n", This, iface);
578 EnterCriticalSection(&This->csFilter);
580 This->state = State_Stopped;
582 LeaveCriticalSection(&This->csFilter);
584 return S_OK;
587 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
589 VideoRendererImpl *This = (VideoRendererImpl *)iface;
591 TRACE("(%p/%p)->()\n", This, iface);
593 EnterCriticalSection(&This->csFilter);
595 This->state = State_Paused;
597 LeaveCriticalSection(&This->csFilter);
599 return S_OK;
602 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
604 VideoRendererImpl *This = (VideoRendererImpl *)iface;
606 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
608 EnterCriticalSection(&This->csFilter);
610 This->rtStreamStart = tStart;
611 This->state = State_Running;
613 LeaveCriticalSection(&This->csFilter);
615 return S_OK;
618 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
620 VideoRendererImpl *This = (VideoRendererImpl *)iface;
622 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
624 EnterCriticalSection(&This->csFilter);
626 *pState = This->state;
628 LeaveCriticalSection(&This->csFilter);
630 return S_OK;
633 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
635 VideoRendererImpl *This = (VideoRendererImpl *)iface;
637 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
639 EnterCriticalSection(&This->csFilter);
641 if (This->pClock)
642 IReferenceClock_Release(This->pClock);
643 This->pClock = pClock;
644 if (This->pClock)
645 IReferenceClock_AddRef(This->pClock);
647 LeaveCriticalSection(&This->csFilter);
649 return S_OK;
652 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
654 VideoRendererImpl *This = (VideoRendererImpl *)iface;
656 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
658 EnterCriticalSection(&This->csFilter);
660 *ppClock = This->pClock;
661 IReferenceClock_AddRef(This->pClock);
663 LeaveCriticalSection(&This->csFilter);
665 return S_OK;
668 /** IBaseFilter implementation **/
670 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
672 ENUMPINDETAILS epd;
673 VideoRendererImpl *This = (VideoRendererImpl *)iface;
675 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
677 epd.cPins = 1; /* input pin */
678 epd.ppPins = This->ppPins;
679 return IEnumPinsImpl_Construct(&epd, ppEnum);
682 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
684 VideoRendererImpl *This = (VideoRendererImpl *)iface;
686 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
688 FIXME("VideoRenderer::FindPin(...)\n");
690 /* FIXME: critical section */
692 return E_NOTIMPL;
695 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
697 VideoRendererImpl *This = (VideoRendererImpl *)iface;
699 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
701 strcpyW(pInfo->achName, This->filterInfo.achName);
702 pInfo->pGraph = This->filterInfo.pGraph;
704 if (pInfo->pGraph)
705 IFilterGraph_AddRef(pInfo->pGraph);
707 return S_OK;
710 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
712 VideoRendererImpl *This = (VideoRendererImpl *)iface;
714 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
716 EnterCriticalSection(&This->csFilter);
718 if (pName)
719 strcpyW(This->filterInfo.achName, pName);
720 else
721 *This->filterInfo.achName = '\0';
722 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
724 LeaveCriticalSection(&This->csFilter);
726 return S_OK;
729 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
731 VideoRendererImpl *This = (VideoRendererImpl *)iface;
732 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
733 return E_NOTIMPL;
736 static const IBaseFilterVtbl VideoRenderer_Vtbl =
738 VideoRenderer_QueryInterface,
739 VideoRenderer_AddRef,
740 VideoRenderer_Release,
741 VideoRenderer_GetClassID,
742 VideoRenderer_Stop,
743 VideoRenderer_Pause,
744 VideoRenderer_Run,
745 VideoRenderer_GetState,
746 VideoRenderer_SetSyncSource,
747 VideoRenderer_GetSyncSource,
748 VideoRenderer_EnumPins,
749 VideoRenderer_FindPin,
750 VideoRenderer_QueryFilterInfo,
751 VideoRenderer_JoinFilterGraph,
752 VideoRenderer_QueryVendorInfo
755 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
757 InputPin* This = (InputPin*)iface;
758 IMediaEventSink* pEventSink;
759 HRESULT hr;
761 TRACE("(%p/%p)->()\n", This, iface);
763 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
764 if (SUCCEEDED(hr))
766 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
767 IMediaEventSink_Release(pEventSink);
770 return hr;
773 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
775 InputPin_QueryInterface,
776 IPinImpl_AddRef,
777 InputPin_Release,
778 InputPin_Connect,
779 InputPin_ReceiveConnection,
780 IPinImpl_Disconnect,
781 IPinImpl_ConnectedTo,
782 IPinImpl_ConnectionMediaType,
783 IPinImpl_QueryPinInfo,
784 IPinImpl_QueryDirection,
785 IPinImpl_QueryId,
786 IPinImpl_QueryAccept,
787 IPinImpl_EnumMediaTypes,
788 IPinImpl_QueryInternalConnections,
789 VideoRenderer_InputPin_EndOfStream,
790 InputPin_BeginFlush,
791 InputPin_EndFlush,
792 InputPin_NewSegment
795 /*** IUnknown methods ***/
796 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
797 REFIID riid,
798 LPVOID*ppvObj) {
799 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
801 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
803 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
806 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
807 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
809 TRACE("(%p/%p)->()\n", This, iface);
811 return VideoRenderer_AddRef((IBaseFilter*)This);
814 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
815 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
817 TRACE("(%p/%p)->()\n", This, iface);
819 return VideoRenderer_Release((IBaseFilter*)This);
822 /*** IDispatch methods ***/
823 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
824 UINT*pctinfo) {
825 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
827 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
829 return S_OK;
832 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
833 UINT iTInfo,
834 LCID lcid,
835 ITypeInfo**ppTInfo) {
836 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
838 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
840 return S_OK;
843 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
844 REFIID riid,
845 LPOLESTR*rgszNames,
846 UINT cNames,
847 LCID lcid,
848 DISPID*rgDispId) {
849 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
851 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
853 return S_OK;
856 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
857 DISPID dispIdMember,
858 REFIID riid,
859 LCID lcid,
860 WORD wFlags,
861 DISPPARAMS*pDispParams,
862 VARIANT*pVarResult,
863 EXCEPINFO*pExepInfo,
864 UINT*puArgErr) {
865 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
867 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);
869 return S_OK;
872 /*** IBasicVideo methods ***/
873 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
874 REFTIME *pAvgTimePerFrame) {
875 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
877 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
879 return S_OK;
882 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
883 long *pBitRate) {
884 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
886 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
888 return S_OK;
891 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
892 long *pBitErrorRate) {
893 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
895 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
897 return S_OK;
900 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
901 long *pVideoWidth) {
902 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
904 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
906 *pVideoWidth = This->VideoWidth;
908 return S_OK;
911 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
912 long *pVideoHeight) {
913 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
915 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
917 *pVideoHeight = This->VideoHeight;
919 return S_OK;
922 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
923 long SourceLeft) {
924 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
926 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
928 This->SourceRect.left = SourceLeft;
930 return S_OK;
933 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
934 long *pSourceLeft) {
935 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
937 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
939 *pSourceLeft = This->SourceRect.left;
941 return S_OK;
944 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
945 long SourceWidth) {
946 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
948 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
950 This->SourceRect.right = This->SourceRect.left + SourceWidth;
952 return S_OK;
955 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
956 long *pSourceWidth) {
957 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
959 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
961 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
963 return S_OK;
966 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
967 long SourceTop) {
968 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
970 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
972 This->SourceRect.top = SourceTop;
974 return S_OK;
977 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
978 long *pSourceTop) {
979 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
981 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
983 *pSourceTop = This->SourceRect.top;
985 return S_OK;
988 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
989 long SourceHeight) {
990 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
992 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
994 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
996 return S_OK;
999 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
1000 long *pSourceHeight) {
1001 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1003 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1005 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
1007 return S_OK;
1010 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1011 long DestinationLeft) {
1012 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1014 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1016 This->DestRect.left = DestinationLeft;
1018 return S_OK;
1021 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1022 long *pDestinationLeft) {
1023 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1025 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1027 *pDestinationLeft = This->DestRect.left;
1029 return S_OK;
1032 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1033 long DestinationWidth) {
1034 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1036 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1038 This->DestRect.right = This->DestRect.left + DestinationWidth;
1040 return S_OK;
1043 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1044 long *pDestinationWidth) {
1045 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1047 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1049 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1051 return S_OK;
1054 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1055 long DestinationTop) {
1056 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1058 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1060 This->DestRect.top = DestinationTop;
1062 return S_OK;
1065 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1066 long *pDestinationTop) {
1067 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1069 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1071 *pDestinationTop = This->DestRect.top;
1073 return S_OK;
1076 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1077 long DestinationHeight) {
1078 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1080 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1082 This->DestRect.right = This->DestRect.left + DestinationHeight;
1084 return S_OK;
1087 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1088 long *pDestinationHeight) {
1089 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1091 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1093 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1095 return S_OK;
1098 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1099 long Left,
1100 long Top,
1101 long Width,
1102 long Height) {
1103 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1105 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1107 This->SourceRect.left = Left;
1108 This->SourceRect.top = Top;
1109 This->SourceRect.right = Left + Width;
1110 This->SourceRect.bottom = Top + Height;
1112 return S_OK;
1115 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1116 long *pLeft,
1117 long *pTop,
1118 long *pWidth,
1119 long *pHeight) {
1120 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1122 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1124 *pLeft = This->SourceRect.left;
1125 *pTop = This->SourceRect.top;
1126 *pWidth = This->SourceRect.right - This->SourceRect.left;
1127 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1129 return S_OK;
1132 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1133 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1135 TRACE("(%p/%p)->()\n", This, iface);
1137 This->SourceRect.left = 0;
1138 This->SourceRect.top = 0;
1139 This->SourceRect.right = This->VideoWidth;
1140 This->SourceRect.bottom = This->VideoHeight;
1142 return S_OK;
1145 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1146 long Left,
1147 long Top,
1148 long Width,
1149 long Height) {
1150 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1152 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1154 This->DestRect.left = Left;
1155 This->DestRect.top = Top;
1156 This->DestRect.right = Left + Width;
1157 This->DestRect.bottom = Top + Height;
1159 return S_OK;
1162 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1163 long *pLeft,
1164 long *pTop,
1165 long *pWidth,
1166 long *pHeight) {
1167 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1169 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1171 *pLeft = This->DestRect.left;
1172 *pTop = This->DestRect.top;
1173 *pWidth = This->DestRect.right - This->DestRect.left;
1174 *pHeight = This->DestRect.bottom - This->DestRect.top;
1176 return S_OK;
1179 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1180 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1181 RECT rect;
1183 TRACE("(%p/%p)->()\n", This, iface);
1185 if (!GetClientRect(This->hWnd, &rect))
1186 return E_FAIL;
1188 This->SourceRect.left = 0;
1189 This->SourceRect.top = 0;
1190 This->SourceRect.right = rect.right;
1191 This->SourceRect.bottom = rect.bottom;
1193 return S_OK;
1196 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1197 long *pWidth,
1198 long *pHeight) {
1199 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1201 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1203 *pWidth = This->VideoWidth;
1204 *pHeight = This->VideoHeight;
1206 return S_OK;
1209 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1210 long StartIndex,
1211 long Entries,
1212 long *pRetrieved,
1213 long *pPalette) {
1214 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1216 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1218 return S_OK;
1221 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1222 long *pBufferSize,
1223 long *pDIBImage) {
1224 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1226 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
1228 return S_OK;
1231 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1232 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1234 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1236 return S_OK;
1239 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1240 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1242 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1244 return S_OK;
1248 static const IBasicVideoVtbl IBasicVideo_VTable =
1250 Basicvideo_QueryInterface,
1251 Basicvideo_AddRef,
1252 Basicvideo_Release,
1253 Basicvideo_GetTypeInfoCount,
1254 Basicvideo_GetTypeInfo,
1255 Basicvideo_GetIDsOfNames,
1256 Basicvideo_Invoke,
1257 Basicvideo_get_AvgTimePerFrame,
1258 Basicvideo_get_BitRate,
1259 Basicvideo_get_BitErrorRate,
1260 Basicvideo_get_VideoWidth,
1261 Basicvideo_get_VideoHeight,
1262 Basicvideo_put_SourceLeft,
1263 Basicvideo_get_SourceLeft,
1264 Basicvideo_put_SourceWidth,
1265 Basicvideo_get_SourceWidth,
1266 Basicvideo_put_SourceTop,
1267 Basicvideo_get_SourceTop,
1268 Basicvideo_put_SourceHeight,
1269 Basicvideo_get_SourceHeight,
1270 Basicvideo_put_DestinationLeft,
1271 Basicvideo_get_DestinationLeft,
1272 Basicvideo_put_DestinationWidth,
1273 Basicvideo_get_DestinationWidth,
1274 Basicvideo_put_DestinationTop,
1275 Basicvideo_get_DestinationTop,
1276 Basicvideo_put_DestinationHeight,
1277 Basicvideo_get_DestinationHeight,
1278 Basicvideo_SetSourcePosition,
1279 Basicvideo_GetSourcePosition,
1280 Basicvideo_SetDefaultSourcePosition,
1281 Basicvideo_SetDestinationPosition,
1282 Basicvideo_GetDestinationPosition,
1283 Basicvideo_SetDefaultDestinationPosition,
1284 Basicvideo_GetVideoSize,
1285 Basicvideo_GetVideoPaletteEntries,
1286 Basicvideo_GetCurrentImage,
1287 Basicvideo_IsUsingDefaultSource,
1288 Basicvideo_IsUsingDefaultDestination
1292 /*** IUnknown methods ***/
1293 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1294 REFIID riid,
1295 LPVOID*ppvObj) {
1296 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1298 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1300 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1303 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1304 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1306 TRACE("(%p/%p)->()\n", This, iface);
1308 return VideoRenderer_AddRef((IBaseFilter*)This);
1311 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1312 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1314 TRACE("(%p/%p)->()\n", This, iface);
1316 return VideoRenderer_Release((IBaseFilter*)This);
1319 /*** IDispatch methods ***/
1320 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1321 UINT*pctinfo) {
1322 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1324 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1326 return S_OK;
1329 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1330 UINT iTInfo,
1331 LCID lcid,
1332 ITypeInfo**ppTInfo) {
1333 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1335 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1337 return S_OK;
1340 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1341 REFIID riid,
1342 LPOLESTR*rgszNames,
1343 UINT cNames,
1344 LCID lcid,
1345 DISPID*rgDispId) {
1346 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1348 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1350 return S_OK;
1353 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1354 DISPID dispIdMember,
1355 REFIID riid,
1356 LCID lcid,
1357 WORD wFlags,
1358 DISPPARAMS*pDispParams,
1359 VARIANT*pVarResult,
1360 EXCEPINFO*pExepInfo,
1361 UINT*puArgErr) {
1362 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1364 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);
1366 return S_OK;
1369 /*** IVideoWindow methods ***/
1370 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1371 BSTR strCaption) {
1372 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1374 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1376 if (!SetWindowTextW(This->hWnd, strCaption))
1377 return E_FAIL;
1379 return S_OK;
1382 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1383 BSTR *strCaption) {
1384 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1386 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1388 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1390 return S_OK;
1393 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1394 long WindowStyle) {
1395 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1396 LONG old;
1398 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1400 TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
1402 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1403 return E_INVALIDARG;
1405 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1407 return S_OK;
1410 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1411 long *WindowStyle) {
1412 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1414 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1416 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1418 return S_OK;
1421 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1422 long WindowStyleEx) {
1423 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1425 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1427 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1428 return E_INVALIDARG;
1430 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1431 return E_FAIL;
1433 return S_OK;
1436 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1437 long *WindowStyleEx) {
1438 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1440 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1442 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1444 return S_OK;
1447 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1448 long AutoShow) {
1449 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1451 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1453 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1455 return S_OK;
1458 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1459 long *AutoShow) {
1460 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1462 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1464 *AutoShow = This->AutoShow;
1466 return S_OK;
1469 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1470 long WindowState) {
1471 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1473 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1475 return S_OK;
1478 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1479 long *WindowState) {
1480 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1482 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1484 return S_OK;
1487 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1488 long BackgroundPalette) {
1489 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1491 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1493 return S_OK;
1496 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1497 long *pBackgroundPalette) {
1498 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1500 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1502 return S_OK;
1505 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1506 long Visible) {
1507 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1509 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1511 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1513 return S_OK;
1516 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1517 long *pVisible) {
1518 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1520 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1522 *pVisible = IsWindowVisible(This->hWnd);
1524 return S_OK;
1527 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1528 long Left) {
1529 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1531 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1533 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1534 return E_FAIL;
1536 This->WindowPos.left = Left;
1538 return S_OK;
1541 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1542 long *pLeft) {
1543 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1545 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1547 *pLeft = This->WindowPos.left;
1549 return S_OK;
1552 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1553 long Width) {
1554 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1556 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1558 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1559 return E_FAIL;
1561 This->WindowPos.right = This->WindowPos.left + Width;
1563 return S_OK;
1566 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1567 long *pWidth) {
1568 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1570 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1572 *pWidth = This->WindowPos.right - This->WindowPos.left;
1574 return S_OK;
1577 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1578 long Top) {
1579 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1581 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1583 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1584 return E_FAIL;
1586 This->WindowPos.top = Top;
1588 return S_OK;
1591 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1592 long *pTop) {
1593 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1595 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1597 *pTop = This->WindowPos.top;
1599 return S_OK;
1602 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1603 long Height) {
1604 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1606 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1608 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1609 return E_FAIL;
1611 This->WindowPos.bottom = This->WindowPos.top + Height;
1613 return S_OK;
1616 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1617 long *pHeight) {
1618 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1620 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1622 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1624 return S_OK;
1627 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1628 OAHWND Owner) {
1629 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1631 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1633 SetParent(This->hWnd, (HWND)Owner);
1635 return S_OK;
1638 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1639 OAHWND *Owner) {
1640 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1642 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1644 *(HWND*)Owner = GetParent(This->hWnd);
1646 return S_OK;
1649 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1650 OAHWND Drain) {
1651 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1653 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
1655 This->hWndMsgDrain = (HWND)Drain;
1657 return S_OK;
1660 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1661 OAHWND *Drain) {
1662 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1664 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1666 *Drain = (OAHWND)This->hWndMsgDrain;
1668 return S_OK;
1671 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1672 long *Color) {
1673 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1675 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1677 return S_OK;
1680 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1681 long Color) {
1682 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1684 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1686 return S_OK;
1689 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1690 long *FullScreenMode) {
1691 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1693 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1695 return S_OK;
1698 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1699 long FullScreenMode) {
1700 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1702 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1704 return S_OK;
1707 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1708 long Focus) {
1709 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1710 BOOL ret;
1711 IPin* pPin;
1712 HRESULT hr;
1714 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1716 if ((Focus != FALSE) && (Focus != TRUE))
1717 return E_INVALIDARG;
1719 hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1720 if ((hr != S_OK) || !pPin)
1721 return VFW_E_NOT_CONNECTED;
1723 if (Focus)
1724 ret = SetForegroundWindow(This->hWnd);
1725 else
1726 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1728 if (!ret)
1729 return E_FAIL;
1731 return S_OK;
1734 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1735 OAHWND hwnd,
1736 long uMsg,
1737 LONG_PTR wParam,
1738 LONG_PTR lParam) {
1739 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1741 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
1743 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1744 return E_FAIL;
1746 return S_OK;
1749 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1750 long Left,
1751 long Top,
1752 long Width,
1753 long Height) {
1754 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1756 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1758 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1759 return E_FAIL;
1761 This->WindowPos.left = Left;
1762 This->WindowPos.top = Top;
1763 This->WindowPos.right = Left + Width;
1764 This->WindowPos.bottom = Top + Height;
1766 return S_OK;
1769 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1770 long *pLeft,
1771 long *pTop,
1772 long *pWidth,
1773 long *pHeight) {
1774 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1776 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1778 *pLeft = This->WindowPos.left;
1779 *pTop = This->WindowPos.top;
1780 *pWidth = This->WindowPos.right - This->WindowPos.left;
1781 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1783 return S_OK;
1786 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1787 long *pWidth,
1788 long *pHeight) {
1789 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1791 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1793 *pWidth = This->VideoWidth;
1794 *pHeight = This->VideoHeight;
1796 return S_OK;
1799 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1800 long *pWidth,
1801 long *pHeight) {
1802 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1804 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1806 *pWidth = This->VideoWidth;
1807 *pHeight = This->VideoHeight;
1809 return S_OK;
1812 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1813 long *pLeft,
1814 long *pTop,
1815 long *pWidth,
1816 long *pHeight) {
1817 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1819 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
1821 return S_OK;
1824 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1825 long HideCursor) {
1826 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1828 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
1830 return S_OK;
1833 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1834 long *CursorHidden) {
1835 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1837 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
1839 return S_OK;
1842 static const IVideoWindowVtbl IVideoWindow_VTable =
1844 Videowindow_QueryInterface,
1845 Videowindow_AddRef,
1846 Videowindow_Release,
1847 Videowindow_GetTypeInfoCount,
1848 Videowindow_GetTypeInfo,
1849 Videowindow_GetIDsOfNames,
1850 Videowindow_Invoke,
1851 Videowindow_put_Caption,
1852 Videowindow_get_Caption,
1853 Videowindow_put_WindowStyle,
1854 Videowindow_get_WindowStyle,
1855 Videowindow_put_WindowStyleEx,
1856 Videowindow_get_WindowStyleEx,
1857 Videowindow_put_AutoShow,
1858 Videowindow_get_AutoShow,
1859 Videowindow_put_WindowState,
1860 Videowindow_get_WindowState,
1861 Videowindow_put_BackgroundPalette,
1862 Videowindow_get_BackgroundPalette,
1863 Videowindow_put_Visible,
1864 Videowindow_get_Visible,
1865 Videowindow_put_Left,
1866 Videowindow_get_Left,
1867 Videowindow_put_Width,
1868 Videowindow_get_Width,
1869 Videowindow_put_Top,
1870 Videowindow_get_Top,
1871 Videowindow_put_Height,
1872 Videowindow_get_Height,
1873 Videowindow_put_Owner,
1874 Videowindow_get_Owner,
1875 Videowindow_put_MessageDrain,
1876 Videowindow_get_MessageDrain,
1877 Videowindow_get_BorderColor,
1878 Videowindow_put_BorderColor,
1879 Videowindow_get_FullScreenMode,
1880 Videowindow_put_FullScreenMode,
1881 Videowindow_SetWindowForeground,
1882 Videowindow_NotifyOwnerMessage,
1883 Videowindow_SetWindowPosition,
1884 Videowindow_GetWindowPosition,
1885 Videowindow_GetMinIdealImageSize,
1886 Videowindow_GetMaxIdealImageSize,
1887 Videowindow_GetRestorePosition,
1888 Videowindow_HideCursor,
1889 Videowindow_IsCursorHidden