msi: Fix the size allocated for the deferred custom action string.
[wine/gsoc_dplay.git] / dlls / quartz / videorenderer.c
blob9e76fd136dabf2d652fdc2f8221ef96e440d1d2b
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 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
130 pVideoRenderer->DestRect.left,
131 pVideoRenderer->DestRect.top,
132 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
133 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
134 return TRUE;
135 case WM_SIZE:
136 TRACE("WM_SIZE %d %d\n", LOWORD(lParam), HIWORD(lParam));
137 GetClientRect(hwnd, &pVideoRenderer->DestRect);
138 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
139 pVideoRenderer->DestRect.left,
140 pVideoRenderer->DestRect.top,
141 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
142 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
143 return TRUE;
144 default:
145 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
147 return 0;
150 static BOOL CreateRenderingWindow(VideoRendererImpl* This)
152 WNDCLASSA winclass;
154 TRACE("(%p)->()\n", This);
156 winclass.style = 0;
157 winclass.lpfnWndProc = VideoWndProcA;
158 winclass.cbClsExtra = 0;
159 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
160 winclass.hInstance = NULL;
161 winclass.hIcon = NULL;
162 winclass.hCursor = NULL;
163 winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
164 winclass.lpszMenuName = NULL;
165 winclass.lpszClassName = "Wine ActiveMovie Class";
167 if (!wnd_class_registered)
169 if (!RegisterClassA(&winclass))
171 ERR("Unable to register window %u\n", GetLastError());
172 return FALSE;
174 wnd_class_registered = TRUE;
177 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
178 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
179 NULL, NULL, NULL);
181 if (!This->hWnd)
183 ERR("Unable to create window\n");
184 return FALSE;
187 SetWindowLongA(This->hWnd, 0, (LONG)This);
189 return TRUE;
192 static DWORD WINAPI MessageLoop(LPVOID lpParameter)
194 VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
195 MSG msg;
196 BOOL fGotMessage;
198 TRACE("Starting message loop\n");
200 if (!CreateRenderingWindow(This))
202 This->ThreadResult = FALSE;
203 SetEvent(This->hEvent);
204 return 0;
207 This->ThreadResult = TRUE;
208 SetEvent(This->hEvent);
210 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
212 TranslateMessage(&msg);
213 DispatchMessageA(&msg);
216 TRACE("End of message loop\n");
218 return msg.wParam;
221 static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
223 This->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
224 if (!This->hEvent)
225 return FALSE;
227 This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
228 if (!This->hThread)
230 CloseHandle(This->hEvent);
231 return FALSE;
234 WaitForSingleObject(This->hEvent, INFINITE);
235 CloseHandle(This->hEvent);
237 if (!This->ThreadResult)
239 CloseHandle(This->hThread);
240 return FALSE;
243 return TRUE;
246 static const IMemInputPinVtbl MemInputPin_Vtbl =
248 MemInputPin_QueryInterface,
249 MemInputPin_AddRef,
250 MemInputPin_Release,
251 MemInputPin_GetAllocator,
252 MemInputPin_NotifyAllocator,
253 MemInputPin_GetAllocatorRequirements,
254 MemInputPin_Receive,
255 MemInputPin_ReceiveMultiple,
256 MemInputPin_ReceiveCanBlock
259 static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
261 InputPin * pPinImpl;
263 *ppPin = NULL;
265 if (pPinInfo->dir != PINDIR_INPUT)
267 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
268 return E_INVALIDARG;
271 pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
273 if (!pPinImpl)
274 return E_OUTOFMEMORY;
276 if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
278 pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl;
279 pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
281 *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
282 return S_OK;
284 return E_FAIL;
287 static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
289 VIDEOINFOHEADER* format;
290 AM_MEDIA_TYPE amt;
291 HRESULT hr = S_OK;
292 DDSURFACEDESC sdesc;
293 int width;
294 int height;
295 LPBYTE palette = NULL;
296 HDC hDC;
298 TRACE("%p %p %d\n", This, data, size);
300 sdesc.dwSize = sizeof(sdesc);
301 hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
302 if (FAILED(hr)) {
303 ERR("Unable to retrieve media type\n");
304 return hr;
306 format = (VIDEOINFOHEADER*)amt.pbFormat;
308 TRACE("biSize = %d\n", format->bmiHeader.biSize);
309 TRACE("biWidth = %d\n", format->bmiHeader.biWidth);
310 TRACE("biHeight = %d\n", format->bmiHeader.biHeight);
311 TRACE("biPlanes = %d\n", format->bmiHeader.biPlanes);
312 TRACE("biBitCount = %d\n", format->bmiHeader.biBitCount);
313 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(format->bmiHeader.biCompression), 4));
314 TRACE("biSizeImage = %d\n", format->bmiHeader.biSizeImage);
316 width = format->bmiHeader.biWidth;
317 height = format->bmiHeader.biHeight;
318 palette = ((LPBYTE)&format->bmiHeader) + format->bmiHeader.biSize;
320 if (!This->init)
322 /* Honor previously set WindowPos */
323 TRACE("WindowPos: %d %d %d %d\n", This->WindowPos.left, This->WindowPos.top, This->WindowPos.right, This->WindowPos.bottom);
324 SetWindowPos(This->hWnd, NULL,
325 This->WindowPos.left,
326 This->WindowPos.top,
327 This->WindowPos.right - This->WindowPos.left,
328 This->WindowPos.bottom - This->WindowPos.top,
329 SWP_NOZORDER|SWP_NOMOVE);
330 GetClientRect(This->hWnd, &This->DestRect);
331 This->init = TRUE;
334 hDC = GetDC(This->hWnd);
336 if (!hDC) {
337 ERR("Cannot get DC from window!\n");
338 return E_FAIL;
341 TRACE("Src Rect: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
342 TRACE("Dst Rect: %d %d %d %d\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom);
344 StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
345 This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
346 This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
347 data, (BITMAPINFO*)&format->bmiHeader, DIB_RGB_COLORS, SRCCOPY);
349 ReleaseDC(This->hWnd, hDC);
351 if (This->AutoShow)
352 ShowWindow(This->hWnd, SW_SHOW);
354 return S_OK;
357 static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
359 VideoRendererImpl *This = (VideoRendererImpl *)iface;
360 LPBYTE pbSrcStream = NULL;
361 long cbSrcStream = 0;
362 REFERENCE_TIME tStart, tStop;
363 HRESULT hr;
365 TRACE("%p %p\n", iface, pSample);
367 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
368 if (FAILED(hr))
370 ERR("Cannot get pointer to sample data (%x)\n", hr);
371 return hr;
374 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
375 if (FAILED(hr))
376 ERR("Cannot get sample time (%x)\n", hr);
378 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
380 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
382 #if 0 /* For debugging purpose */
384 int i;
385 for(i = 0; i < cbSrcStream; i++)
387 if ((i!=0) && !(i%16))
388 TRACE("\n");
389 TRACE("%02x ", pbSrcStream[i]);
391 TRACE("\n");
393 #endif
395 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
397 return S_OK;
400 static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
402 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
403 return S_FALSE;
405 if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
406 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
407 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
408 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
410 VideoRendererImpl* This = (VideoRendererImpl*) iface;
411 VIDEOINFOHEADER* format = (VIDEOINFOHEADER*)pmt->pbFormat;
413 if (!IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
415 WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
416 return S_FALSE;
418 This->SourceRect.left = 0;
419 This->SourceRect.top = 0;
420 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
421 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
422 return S_OK;
424 return S_FALSE;
427 HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
429 HRESULT hr;
430 PIN_INFO piInput;
431 VideoRendererImpl * pVideoRenderer;
433 TRACE("(%p, %p)\n", pUnkOuter, ppv);
435 *ppv = NULL;
437 if (pUnkOuter)
438 return CLASS_E_NOAGGREGATION;
440 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
442 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
443 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
444 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
446 pVideoRenderer->refCount = 1;
447 InitializeCriticalSection(&pVideoRenderer->csFilter);
448 pVideoRenderer->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
449 pVideoRenderer->state = State_Stopped;
450 pVideoRenderer->pClock = NULL;
451 pVideoRenderer->init = 0;
452 pVideoRenderer->AutoShow = 1;
453 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
455 pVideoRenderer->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
457 /* construct input pin */
458 piInput.dir = PINDIR_INPUT;
459 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
460 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
462 hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
464 if (SUCCEEDED(hr))
466 pVideoRenderer->ppPins[0] = (IPin *)pVideoRenderer->pInputPin;
467 *ppv = (LPVOID)pVideoRenderer;
469 else
471 CoTaskMemFree(pVideoRenderer->ppPins);
472 pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
473 DeleteCriticalSection(&pVideoRenderer->csFilter);
474 CoTaskMemFree(pVideoRenderer);
477 if (!CreateRenderingSubsystem(pVideoRenderer))
478 return E_FAIL;
480 return hr;
483 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
485 VideoRendererImpl *This = (VideoRendererImpl *)iface;
486 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
488 *ppv = NULL;
490 if (IsEqualIID(riid, &IID_IUnknown))
491 *ppv = (LPVOID)This;
492 else if (IsEqualIID(riid, &IID_IPersist))
493 *ppv = (LPVOID)This;
494 else if (IsEqualIID(riid, &IID_IMediaFilter))
495 *ppv = (LPVOID)This;
496 else if (IsEqualIID(riid, &IID_IBaseFilter))
497 *ppv = (LPVOID)This;
498 else if (IsEqualIID(riid, &IID_IBasicVideo))
499 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
500 else if (IsEqualIID(riid, &IID_IVideoWindow))
501 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
503 if (*ppv)
505 IUnknown_AddRef((IUnknown *)(*ppv));
506 return S_OK;
509 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
511 return E_NOINTERFACE;
514 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
516 VideoRendererImpl *This = (VideoRendererImpl *)iface;
517 ULONG refCount = InterlockedIncrement(&This->refCount);
519 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
521 return refCount;
524 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
526 VideoRendererImpl *This = (VideoRendererImpl *)iface;
527 ULONG refCount = InterlockedDecrement(&This->refCount);
529 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
531 if (!refCount)
533 IPin *pConnectedTo;
535 DestroyWindow(This->hWnd);
536 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
537 WaitForSingleObject(This->hThread, INFINITE);
538 CloseHandle(This->hThread);
540 if (This->pClock)
541 IReferenceClock_Release(This->pClock);
543 if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[0], &pConnectedTo)))
545 IPin_Disconnect(pConnectedTo);
546 IPin_Release(pConnectedTo);
548 IPin_Disconnect(This->ppPins[0]);
550 IPin_Release(This->ppPins[0]);
552 CoTaskMemFree(This->ppPins);
553 This->lpVtbl = NULL;
555 This->csFilter.DebugInfo->Spare[0] = 0;
556 DeleteCriticalSection(&This->csFilter);
558 TRACE("Destroying Video Renderer\n");
559 CoTaskMemFree(This);
561 return 0;
563 else
564 return refCount;
567 /** IPersist methods **/
569 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
571 VideoRendererImpl *This = (VideoRendererImpl *)iface;
573 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
575 *pClsid = CLSID_VideoRenderer;
577 return S_OK;
580 /** IMediaFilter methods **/
582 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
584 VideoRendererImpl *This = (VideoRendererImpl *)iface;
586 TRACE("(%p/%p)->()\n", This, iface);
588 EnterCriticalSection(&This->csFilter);
590 This->state = State_Stopped;
592 LeaveCriticalSection(&This->csFilter);
594 return S_OK;
597 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
599 VideoRendererImpl *This = (VideoRendererImpl *)iface;
601 TRACE("(%p/%p)->()\n", This, iface);
603 EnterCriticalSection(&This->csFilter);
605 This->state = State_Paused;
607 LeaveCriticalSection(&This->csFilter);
609 return S_OK;
612 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
614 VideoRendererImpl *This = (VideoRendererImpl *)iface;
616 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
618 EnterCriticalSection(&This->csFilter);
620 This->rtStreamStart = tStart;
621 This->state = State_Running;
623 LeaveCriticalSection(&This->csFilter);
625 return S_OK;
628 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
630 VideoRendererImpl *This = (VideoRendererImpl *)iface;
632 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
634 EnterCriticalSection(&This->csFilter);
636 *pState = This->state;
638 LeaveCriticalSection(&This->csFilter);
640 return S_OK;
643 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
645 VideoRendererImpl *This = (VideoRendererImpl *)iface;
647 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
649 EnterCriticalSection(&This->csFilter);
651 if (This->pClock)
652 IReferenceClock_Release(This->pClock);
653 This->pClock = pClock;
654 if (This->pClock)
655 IReferenceClock_AddRef(This->pClock);
657 LeaveCriticalSection(&This->csFilter);
659 return S_OK;
662 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
664 VideoRendererImpl *This = (VideoRendererImpl *)iface;
666 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
668 EnterCriticalSection(&This->csFilter);
670 *ppClock = This->pClock;
671 IReferenceClock_AddRef(This->pClock);
673 LeaveCriticalSection(&This->csFilter);
675 return S_OK;
678 /** IBaseFilter implementation **/
680 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
682 ENUMPINDETAILS epd;
683 VideoRendererImpl *This = (VideoRendererImpl *)iface;
685 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
687 epd.cPins = 1; /* input pin */
688 epd.ppPins = This->ppPins;
689 return IEnumPinsImpl_Construct(&epd, ppEnum);
692 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
694 VideoRendererImpl *This = (VideoRendererImpl *)iface;
696 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
698 FIXME("VideoRenderer::FindPin(...)\n");
700 /* FIXME: critical section */
702 return E_NOTIMPL;
705 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
707 VideoRendererImpl *This = (VideoRendererImpl *)iface;
709 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
711 strcpyW(pInfo->achName, This->filterInfo.achName);
712 pInfo->pGraph = This->filterInfo.pGraph;
714 if (pInfo->pGraph)
715 IFilterGraph_AddRef(pInfo->pGraph);
717 return S_OK;
720 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
722 VideoRendererImpl *This = (VideoRendererImpl *)iface;
724 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
726 EnterCriticalSection(&This->csFilter);
728 if (pName)
729 strcpyW(This->filterInfo.achName, pName);
730 else
731 *This->filterInfo.achName = '\0';
732 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
734 LeaveCriticalSection(&This->csFilter);
736 return S_OK;
739 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
741 VideoRendererImpl *This = (VideoRendererImpl *)iface;
742 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
743 return E_NOTIMPL;
746 static const IBaseFilterVtbl VideoRenderer_Vtbl =
748 VideoRenderer_QueryInterface,
749 VideoRenderer_AddRef,
750 VideoRenderer_Release,
751 VideoRenderer_GetClassID,
752 VideoRenderer_Stop,
753 VideoRenderer_Pause,
754 VideoRenderer_Run,
755 VideoRenderer_GetState,
756 VideoRenderer_SetSyncSource,
757 VideoRenderer_GetSyncSource,
758 VideoRenderer_EnumPins,
759 VideoRenderer_FindPin,
760 VideoRenderer_QueryFilterInfo,
761 VideoRenderer_JoinFilterGraph,
762 VideoRenderer_QueryVendorInfo
765 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
767 InputPin* This = (InputPin*)iface;
768 IMediaEventSink* pEventSink;
769 HRESULT hr;
771 TRACE("(%p/%p)->()\n", This, iface);
773 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
774 if (SUCCEEDED(hr))
776 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
777 IMediaEventSink_Release(pEventSink);
780 return hr;
783 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
785 InputPin_QueryInterface,
786 IPinImpl_AddRef,
787 InputPin_Release,
788 InputPin_Connect,
789 InputPin_ReceiveConnection,
790 IPinImpl_Disconnect,
791 IPinImpl_ConnectedTo,
792 IPinImpl_ConnectionMediaType,
793 IPinImpl_QueryPinInfo,
794 IPinImpl_QueryDirection,
795 IPinImpl_QueryId,
796 IPinImpl_QueryAccept,
797 IPinImpl_EnumMediaTypes,
798 IPinImpl_QueryInternalConnections,
799 VideoRenderer_InputPin_EndOfStream,
800 InputPin_BeginFlush,
801 InputPin_EndFlush,
802 InputPin_NewSegment
805 /*** IUnknown methods ***/
806 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
807 REFIID riid,
808 LPVOID*ppvObj) {
809 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
811 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
813 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
816 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
817 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
819 TRACE("(%p/%p)->()\n", This, iface);
821 return VideoRenderer_AddRef((IBaseFilter*)This);
824 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
825 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
827 TRACE("(%p/%p)->()\n", This, iface);
829 return VideoRenderer_Release((IBaseFilter*)This);
832 /*** IDispatch methods ***/
833 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
834 UINT*pctinfo) {
835 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
837 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
839 return S_OK;
842 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
843 UINT iTInfo,
844 LCID lcid,
845 ITypeInfo**ppTInfo) {
846 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
848 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
850 return S_OK;
853 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
854 REFIID riid,
855 LPOLESTR*rgszNames,
856 UINT cNames,
857 LCID lcid,
858 DISPID*rgDispId) {
859 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
861 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
863 return S_OK;
866 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
867 DISPID dispIdMember,
868 REFIID riid,
869 LCID lcid,
870 WORD wFlags,
871 DISPPARAMS*pDispParams,
872 VARIANT*pVarResult,
873 EXCEPINFO*pExepInfo,
874 UINT*puArgErr) {
875 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
877 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);
879 return S_OK;
882 /*** IBasicVideo methods ***/
883 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
884 REFTIME *pAvgTimePerFrame) {
885 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
887 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
889 return S_OK;
892 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
893 long *pBitRate) {
894 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
896 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
898 return S_OK;
901 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
902 long *pBitErrorRate) {
903 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
905 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
907 return S_OK;
910 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
911 long *pVideoWidth) {
912 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
914 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
916 *pVideoWidth = This->VideoWidth;
918 return S_OK;
921 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
922 long *pVideoHeight) {
923 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
925 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
927 *pVideoHeight = This->VideoHeight;
929 return S_OK;
932 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
933 long SourceLeft) {
934 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
936 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
938 This->SourceRect.left = SourceLeft;
940 return S_OK;
943 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
944 long *pSourceLeft) {
945 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
947 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
949 *pSourceLeft = This->SourceRect.left;
951 return S_OK;
954 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
955 long SourceWidth) {
956 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
958 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
960 This->SourceRect.right = This->SourceRect.left + SourceWidth;
962 return S_OK;
965 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
966 long *pSourceWidth) {
967 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
969 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
971 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
973 return S_OK;
976 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
977 long SourceTop) {
978 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
980 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
982 This->SourceRect.top = SourceTop;
984 return S_OK;
987 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
988 long *pSourceTop) {
989 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
991 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
993 *pSourceTop = This->SourceRect.top;
995 return S_OK;
998 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
999 long SourceHeight) {
1000 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1002 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
1004 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
1006 return S_OK;
1009 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
1010 long *pSourceHeight) {
1011 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1013 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1015 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
1017 return S_OK;
1020 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1021 long DestinationLeft) {
1022 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1024 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1026 This->DestRect.left = DestinationLeft;
1028 return S_OK;
1031 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1032 long *pDestinationLeft) {
1033 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1035 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1037 *pDestinationLeft = This->DestRect.left;
1039 return S_OK;
1042 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1043 long DestinationWidth) {
1044 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1046 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1048 This->DestRect.right = This->DestRect.left + DestinationWidth;
1050 return S_OK;
1053 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1054 long *pDestinationWidth) {
1055 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1057 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1059 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1061 return S_OK;
1064 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1065 long DestinationTop) {
1066 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1068 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1070 This->DestRect.top = DestinationTop;
1072 return S_OK;
1075 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1076 long *pDestinationTop) {
1077 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1079 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1081 *pDestinationTop = This->DestRect.top;
1083 return S_OK;
1086 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1087 long DestinationHeight) {
1088 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1090 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1092 This->DestRect.right = This->DestRect.left + DestinationHeight;
1094 return S_OK;
1097 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1098 long *pDestinationHeight) {
1099 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1101 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1103 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1105 return S_OK;
1108 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1109 long Left,
1110 long Top,
1111 long Width,
1112 long Height) {
1113 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1115 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1117 This->SourceRect.left = Left;
1118 This->SourceRect.top = Top;
1119 This->SourceRect.right = Left + Width;
1120 This->SourceRect.bottom = Top + Height;
1122 return S_OK;
1125 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1126 long *pLeft,
1127 long *pTop,
1128 long *pWidth,
1129 long *pHeight) {
1130 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1132 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1134 *pLeft = This->SourceRect.left;
1135 *pTop = This->SourceRect.top;
1136 *pWidth = This->SourceRect.right - This->SourceRect.left;
1137 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1139 return S_OK;
1142 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1143 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1145 TRACE("(%p/%p)->()\n", This, iface);
1147 This->SourceRect.left = 0;
1148 This->SourceRect.top = 0;
1149 This->SourceRect.right = This->VideoWidth;
1150 This->SourceRect.bottom = This->VideoHeight;
1152 return S_OK;
1155 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1156 long Left,
1157 long Top,
1158 long Width,
1159 long Height) {
1160 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1162 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1164 This->DestRect.left = Left;
1165 This->DestRect.top = Top;
1166 This->DestRect.right = Left + Width;
1167 This->DestRect.bottom = Top + Height;
1169 return S_OK;
1172 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1173 long *pLeft,
1174 long *pTop,
1175 long *pWidth,
1176 long *pHeight) {
1177 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1179 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1181 *pLeft = This->DestRect.left;
1182 *pTop = This->DestRect.top;
1183 *pWidth = This->DestRect.right - This->DestRect.left;
1184 *pHeight = This->DestRect.bottom - This->DestRect.top;
1186 return S_OK;
1189 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1190 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1191 RECT rect;
1193 TRACE("(%p/%p)->()\n", This, iface);
1195 if (!GetClientRect(This->hWnd, &rect))
1196 return E_FAIL;
1198 This->SourceRect.left = 0;
1199 This->SourceRect.top = 0;
1200 This->SourceRect.right = rect.right;
1201 This->SourceRect.bottom = rect.bottom;
1203 return S_OK;
1206 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1207 long *pWidth,
1208 long *pHeight) {
1209 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1211 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1213 *pWidth = This->VideoWidth;
1214 *pHeight = This->VideoHeight;
1216 return S_OK;
1219 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1220 long StartIndex,
1221 long Entries,
1222 long *pRetrieved,
1223 long *pPalette) {
1224 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1226 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1228 return S_OK;
1231 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1232 long *pBufferSize,
1233 long *pDIBImage) {
1234 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1236 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
1238 return S_OK;
1241 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1242 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1244 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1246 return S_OK;
1249 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1250 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1252 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1254 return S_OK;
1258 static const IBasicVideoVtbl IBasicVideo_VTable =
1260 Basicvideo_QueryInterface,
1261 Basicvideo_AddRef,
1262 Basicvideo_Release,
1263 Basicvideo_GetTypeInfoCount,
1264 Basicvideo_GetTypeInfo,
1265 Basicvideo_GetIDsOfNames,
1266 Basicvideo_Invoke,
1267 Basicvideo_get_AvgTimePerFrame,
1268 Basicvideo_get_BitRate,
1269 Basicvideo_get_BitErrorRate,
1270 Basicvideo_get_VideoWidth,
1271 Basicvideo_get_VideoHeight,
1272 Basicvideo_put_SourceLeft,
1273 Basicvideo_get_SourceLeft,
1274 Basicvideo_put_SourceWidth,
1275 Basicvideo_get_SourceWidth,
1276 Basicvideo_put_SourceTop,
1277 Basicvideo_get_SourceTop,
1278 Basicvideo_put_SourceHeight,
1279 Basicvideo_get_SourceHeight,
1280 Basicvideo_put_DestinationLeft,
1281 Basicvideo_get_DestinationLeft,
1282 Basicvideo_put_DestinationWidth,
1283 Basicvideo_get_DestinationWidth,
1284 Basicvideo_put_DestinationTop,
1285 Basicvideo_get_DestinationTop,
1286 Basicvideo_put_DestinationHeight,
1287 Basicvideo_get_DestinationHeight,
1288 Basicvideo_SetSourcePosition,
1289 Basicvideo_GetSourcePosition,
1290 Basicvideo_SetDefaultSourcePosition,
1291 Basicvideo_SetDestinationPosition,
1292 Basicvideo_GetDestinationPosition,
1293 Basicvideo_SetDefaultDestinationPosition,
1294 Basicvideo_GetVideoSize,
1295 Basicvideo_GetVideoPaletteEntries,
1296 Basicvideo_GetCurrentImage,
1297 Basicvideo_IsUsingDefaultSource,
1298 Basicvideo_IsUsingDefaultDestination
1302 /*** IUnknown methods ***/
1303 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1304 REFIID riid,
1305 LPVOID*ppvObj) {
1306 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1308 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1310 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1313 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1314 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1316 TRACE("(%p/%p)->()\n", This, iface);
1318 return VideoRenderer_AddRef((IBaseFilter*)This);
1321 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1322 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1324 TRACE("(%p/%p)->()\n", This, iface);
1326 return VideoRenderer_Release((IBaseFilter*)This);
1329 /*** IDispatch methods ***/
1330 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1331 UINT*pctinfo) {
1332 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1334 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1336 return S_OK;
1339 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1340 UINT iTInfo,
1341 LCID lcid,
1342 ITypeInfo**ppTInfo) {
1343 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1345 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1347 return S_OK;
1350 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1351 REFIID riid,
1352 LPOLESTR*rgszNames,
1353 UINT cNames,
1354 LCID lcid,
1355 DISPID*rgDispId) {
1356 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1358 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1360 return S_OK;
1363 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1364 DISPID dispIdMember,
1365 REFIID riid,
1366 LCID lcid,
1367 WORD wFlags,
1368 DISPPARAMS*pDispParams,
1369 VARIANT*pVarResult,
1370 EXCEPINFO*pExepInfo,
1371 UINT*puArgErr) {
1372 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1374 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);
1376 return S_OK;
1379 /*** IVideoWindow methods ***/
1380 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1381 BSTR strCaption) {
1382 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1384 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1386 if (!SetWindowTextW(This->hWnd, strCaption))
1387 return E_FAIL;
1389 return S_OK;
1392 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1393 BSTR *strCaption) {
1394 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1396 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1398 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1400 return S_OK;
1403 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1404 long WindowStyle) {
1405 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1406 LONG old;
1408 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1410 TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
1412 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1413 return E_INVALIDARG;
1415 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1417 return S_OK;
1420 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1421 long *WindowStyle) {
1422 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1424 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1426 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1428 return S_OK;
1431 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1432 long WindowStyleEx) {
1433 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1435 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1437 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1438 return E_INVALIDARG;
1440 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1441 return E_FAIL;
1443 return S_OK;
1446 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1447 long *WindowStyleEx) {
1448 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1450 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1452 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1454 return S_OK;
1457 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1458 long AutoShow) {
1459 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1461 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1463 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1465 return S_OK;
1468 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1469 long *AutoShow) {
1470 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1472 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1474 *AutoShow = This->AutoShow;
1476 return S_OK;
1479 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1480 long WindowState) {
1481 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1483 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1485 return S_OK;
1488 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1489 long *WindowState) {
1490 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1492 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1494 return S_OK;
1497 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1498 long BackgroundPalette) {
1499 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1501 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1503 return S_OK;
1506 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1507 long *pBackgroundPalette) {
1508 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1510 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1512 return S_OK;
1515 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1516 long Visible) {
1517 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1519 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1521 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1523 return S_OK;
1526 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1527 long *pVisible) {
1528 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1530 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1532 *pVisible = IsWindowVisible(This->hWnd);
1534 return S_OK;
1537 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1538 long Left) {
1539 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1541 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1543 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1544 return E_FAIL;
1546 This->WindowPos.left = Left;
1548 return S_OK;
1551 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1552 long *pLeft) {
1553 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1555 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1557 *pLeft = This->WindowPos.left;
1559 return S_OK;
1562 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1563 long Width) {
1564 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1566 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1568 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1569 return E_FAIL;
1571 This->WindowPos.right = This->WindowPos.left + Width;
1573 return S_OK;
1576 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1577 long *pWidth) {
1578 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1580 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1582 *pWidth = This->WindowPos.right - This->WindowPos.left;
1584 return S_OK;
1587 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1588 long Top) {
1589 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1591 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1593 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1594 return E_FAIL;
1596 This->WindowPos.top = Top;
1598 return S_OK;
1601 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1602 long *pTop) {
1603 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1605 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1607 *pTop = This->WindowPos.top;
1609 return S_OK;
1612 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1613 long Height) {
1614 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1616 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1618 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1619 return E_FAIL;
1621 This->WindowPos.bottom = This->WindowPos.top + Height;
1623 return S_OK;
1626 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1627 long *pHeight) {
1628 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1630 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1632 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1634 return S_OK;
1637 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1638 OAHWND Owner) {
1639 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1641 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1643 SetParent(This->hWnd, (HWND)Owner);
1645 return S_OK;
1648 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1649 OAHWND *Owner) {
1650 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1652 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1654 *(HWND*)Owner = GetParent(This->hWnd);
1656 return S_OK;
1659 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1660 OAHWND Drain) {
1661 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1663 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
1665 This->hWndMsgDrain = (HWND)Drain;
1667 return S_OK;
1670 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1671 OAHWND *Drain) {
1672 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1674 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1676 *Drain = (OAHWND)This->hWndMsgDrain;
1678 return S_OK;
1681 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1682 long *Color) {
1683 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1685 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1687 return S_OK;
1690 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1691 long Color) {
1692 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1694 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1696 return S_OK;
1699 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1700 long *FullScreenMode) {
1701 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1703 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1705 return S_OK;
1708 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1709 long FullScreenMode) {
1710 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1712 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1714 return S_OK;
1717 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1718 long Focus) {
1719 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1720 BOOL ret;
1721 IPin* pPin;
1722 HRESULT hr;
1724 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1726 if ((Focus != FALSE) && (Focus != TRUE))
1727 return E_INVALIDARG;
1729 hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1730 if ((hr != S_OK) || !pPin)
1731 return VFW_E_NOT_CONNECTED;
1733 if (Focus)
1734 ret = SetForegroundWindow(This->hWnd);
1735 else
1736 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1738 if (!ret)
1739 return E_FAIL;
1741 return S_OK;
1744 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1745 OAHWND hwnd,
1746 long uMsg,
1747 LONG_PTR wParam,
1748 LONG_PTR lParam) {
1749 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1751 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
1753 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1754 return E_FAIL;
1756 return S_OK;
1759 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1760 long Left,
1761 long Top,
1762 long Width,
1763 long Height) {
1764 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1766 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1768 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1769 return E_FAIL;
1771 This->WindowPos.left = Left;
1772 This->WindowPos.top = Top;
1773 This->WindowPos.right = Left + Width;
1774 This->WindowPos.bottom = Top + Height;
1776 return S_OK;
1779 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1780 long *pLeft,
1781 long *pTop,
1782 long *pWidth,
1783 long *pHeight) {
1784 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1786 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1788 *pLeft = This->WindowPos.left;
1789 *pTop = This->WindowPos.top;
1790 *pWidth = This->WindowPos.right - This->WindowPos.left;
1791 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1793 return S_OK;
1796 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1797 long *pWidth,
1798 long *pHeight) {
1799 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1801 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1803 *pWidth = This->VideoWidth;
1804 *pHeight = This->VideoHeight;
1806 return S_OK;
1809 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1810 long *pWidth,
1811 long *pHeight) {
1812 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1814 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1816 *pWidth = This->VideoWidth;
1817 *pHeight = This->VideoHeight;
1819 return S_OK;
1822 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1823 long *pLeft,
1824 long *pTop,
1825 long *pWidth,
1826 long *pHeight) {
1827 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1829 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
1831 return S_OK;
1834 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1835 long HideCursor) {
1836 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1838 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
1840 return S_OK;
1843 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1844 long *CursorHidden) {
1845 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1847 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
1849 return S_OK;
1852 static const IVideoWindowVtbl IVideoWindow_VTable =
1854 Videowindow_QueryInterface,
1855 Videowindow_AddRef,
1856 Videowindow_Release,
1857 Videowindow_GetTypeInfoCount,
1858 Videowindow_GetTypeInfo,
1859 Videowindow_GetIDsOfNames,
1860 Videowindow_Invoke,
1861 Videowindow_put_Caption,
1862 Videowindow_get_Caption,
1863 Videowindow_put_WindowStyle,
1864 Videowindow_get_WindowStyle,
1865 Videowindow_put_WindowStyleEx,
1866 Videowindow_get_WindowStyleEx,
1867 Videowindow_put_AutoShow,
1868 Videowindow_get_AutoShow,
1869 Videowindow_put_WindowState,
1870 Videowindow_get_WindowState,
1871 Videowindow_put_BackgroundPalette,
1872 Videowindow_get_BackgroundPalette,
1873 Videowindow_put_Visible,
1874 Videowindow_get_Visible,
1875 Videowindow_put_Left,
1876 Videowindow_get_Left,
1877 Videowindow_put_Width,
1878 Videowindow_get_Width,
1879 Videowindow_put_Top,
1880 Videowindow_get_Top,
1881 Videowindow_put_Height,
1882 Videowindow_get_Height,
1883 Videowindow_put_Owner,
1884 Videowindow_get_Owner,
1885 Videowindow_put_MessageDrain,
1886 Videowindow_get_MessageDrain,
1887 Videowindow_get_BorderColor,
1888 Videowindow_put_BorderColor,
1889 Videowindow_get_FullScreenMode,
1890 Videowindow_put_FullScreenMode,
1891 Videowindow_SetWindowForeground,
1892 Videowindow_NotifyOwnerMessage,
1893 Videowindow_SetWindowPosition,
1894 Videowindow_GetWindowPosition,
1895 Videowindow_GetMinIdealImageSize,
1896 Videowindow_GetMaxIdealImageSize,
1897 Videowindow_GetRestorePosition,
1898 Videowindow_HideCursor,
1899 Videowindow_IsCursorHidden