URLMonikerImpl_BindToStorage: Escape special characters.
[wine/multimedia.git] / dlls / quartz / videorenderer.c
blob308790641e91034ffdc2df009c6970ba20c801b5
1 /*
2 * Video Renderer (Fullscreen and Windowed using Direct Draw)
4 * Copyright 2004 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #define NONAMELESSSTRUCT
24 #define NONAMELESSUNION
25 #include "quartz_private.h"
26 #include "control_private.h"
27 #include "pin.h"
29 #include "uuids.h"
30 #include "mmreg.h"
31 #include "vfwmsgs.h"
32 #include "amvideo.h"
33 #include "fourcc.h"
34 #include "windef.h"
35 #include "winbase.h"
36 #include "dshow.h"
37 #include "evcode.h"
38 #include "strmif.h"
39 #include "ddraw.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
46 static BOOL wnd_class_registered = FALSE;
48 static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
50 static const IBaseFilterVtbl VideoRenderer_Vtbl;
51 static const IBasicVideoVtbl IBasicVideo_VTable;
52 static const IVideoWindowVtbl IVideoWindow_VTable;
53 static const IPinVtbl VideoRenderer_InputPin_Vtbl;
55 typedef struct VideoRendererImpl
57 const IBaseFilterVtbl * lpVtbl;
58 const IBasicVideoVtbl * IBasicVideo_vtbl;
59 const IVideoWindowVtbl * IVideoWindow_vtbl;
61 ULONG refCount;
62 CRITICAL_SECTION csFilter;
63 FILTER_STATE state;
64 REFERENCE_TIME rtStreamStart;
65 IReferenceClock * pClock;
66 FILTER_INFO filterInfo;
68 InputPin * pInputPin;
69 IPin ** ppPins;
71 BOOL init;
72 HANDLE hThread;
73 DWORD ThreadID;
74 HANDLE hEvent;
75 BOOL ThreadResult;
76 HWND hWnd;
77 HWND hWndMsgDrain;
78 BOOL AutoShow;
79 RECT SourceRect;
80 RECT DestRect;
81 RECT WindowPos;
82 long VideoWidth;
83 long VideoHeight;
84 } VideoRendererImpl;
86 static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
88 VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongA(hwnd, 0);
89 LPRECT lprect = (LPRECT)lParam;
91 if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
93 switch(uMsg)
95 case WM_KEYDOWN:
96 case WM_KEYUP:
97 case WM_LBUTTONDBLCLK:
98 case WM_LBUTTONDOWN:
99 case WM_LBUTTONUP:
100 case WM_MBUTTONDBLCLK:
101 case WM_MBUTTONDOWN:
102 case WM_MBUTTONUP:
103 case WM_MOUSEACTIVATE:
104 case WM_MOUSEMOVE:
105 case WM_NCLBUTTONDBLCLK:
106 case WM_NCLBUTTONDOWN:
107 case WM_NCLBUTTONUP:
108 case WM_NCMBUTTONDBLCLK:
109 case WM_NCMBUTTONDOWN:
110 case WM_NCMBUTTONUP:
111 case WM_NCMOUSEMOVE:
112 case WM_NCRBUTTONDBLCLK:
113 case WM_NCRBUTTONDOWN:
114 case WM_NCRBUTTONUP:
115 case WM_RBUTTONDBLCLK:
116 case WM_RBUTTONDOWN:
117 case WM_RBUTTONUP:
118 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
119 break;
120 default:
121 break;
125 switch(uMsg)
127 case WM_SIZING:
128 /* TRACE("WM_SIZING %ld %ld %ld %ld\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
129 SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
130 GetClientRect(hwnd, &pVideoRenderer->DestRect);
131 return TRUE;
132 default:
133 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
135 return 0;
138 static BOOL CreateRenderingWindow(VideoRendererImpl* This)
140 WNDCLASSA winclass;
142 TRACE("(%p)->()\n", This);
144 winclass.style = 0;
145 winclass.lpfnWndProc = VideoWndProcA;
146 winclass.cbClsExtra = 0;
147 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
148 winclass.hInstance = NULL;
149 winclass.hIcon = NULL;
150 winclass.hCursor = NULL;
151 winclass.hbrBackground = NULL;
152 winclass.lpszMenuName = NULL;
153 winclass.lpszClassName = "Wine ActiveMovie Class";
155 if (!wnd_class_registered)
157 if (!RegisterClassA(&winclass))
159 ERR("Unable to register window %lx\n", GetLastError());
160 return FALSE;
162 wnd_class_registered = TRUE;
165 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
166 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
167 NULL, NULL, NULL);
169 if (!This->hWnd)
171 ERR("Unable to create window\n");
172 return FALSE;
175 SetWindowLongA(This->hWnd, 0, (LONG)This);
177 return TRUE;
180 static DWORD WINAPI MessageLoop(LPVOID lpParameter)
182 VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
183 MSG msg;
184 BOOL fGotMessage;
186 TRACE("Starting message loop\n");
188 if (!CreateRenderingWindow(This))
190 This->ThreadResult = FALSE;
191 SetEvent(This->hEvent);
192 return 0;
195 This->ThreadResult = TRUE;
196 SetEvent(This->hEvent);
198 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
200 TranslateMessage(&msg);
201 DispatchMessageA(&msg);
204 TRACE("End of message loop\n");
206 return msg.wParam;
209 static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
211 This->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
212 if (!This->hEvent)
213 return FALSE;
215 This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
216 if (!This->hThread)
218 CloseHandle(This->hEvent);
219 return FALSE;
222 WaitForSingleObject(This->hEvent, INFINITE);
223 CloseHandle(This->hEvent);
225 if (!This->ThreadResult)
227 CloseHandle(This->hThread);
228 return FALSE;
231 return TRUE;
234 static const IMemInputPinVtbl MemInputPin_Vtbl =
236 MemInputPin_QueryInterface,
237 MemInputPin_AddRef,
238 MemInputPin_Release,
239 MemInputPin_GetAllocator,
240 MemInputPin_NotifyAllocator,
241 MemInputPin_GetAllocatorRequirements,
242 MemInputPin_Receive,
243 MemInputPin_ReceiveMultiple,
244 MemInputPin_ReceiveCanBlock
247 static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
249 InputPin * pPinImpl;
251 *ppPin = NULL;
253 if (pPinInfo->dir != PINDIR_INPUT)
255 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
256 return E_INVALIDARG;
259 pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
261 if (!pPinImpl)
262 return E_OUTOFMEMORY;
264 if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
266 pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl;
267 pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
269 *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
270 return S_OK;
272 return E_FAIL;
275 static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
277 VIDEOINFOHEADER* format;
278 AM_MEDIA_TYPE amt;
279 HRESULT hr = S_OK;
280 DDSURFACEDESC sdesc;
281 int width;
282 int height;
283 LPBYTE palette = NULL;
284 HDC hDC;
286 TRACE("%p %p %ld\n", This, data, size);
288 sdesc.dwSize = sizeof(sdesc);
289 hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
290 if (FAILED(hr)) {
291 ERR("Unable to retrieve media type\n");
292 return hr;
294 format = (VIDEOINFOHEADER*)amt.pbFormat;
296 TRACE("biSize = %ld\n", format->bmiHeader.biSize);
297 TRACE("biWidth = %ld\n", format->bmiHeader.biWidth);
298 TRACE("biHeigth = %ld\n", format->bmiHeader.biHeight);
299 TRACE("biPlanes = %d\n", format->bmiHeader.biPlanes);
300 TRACE("biBitCount = %d\n", format->bmiHeader.biBitCount);
301 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(format->bmiHeader.biCompression), 4));
302 TRACE("biSizeImage = %ld\n", format->bmiHeader.biSizeImage);
304 width = format->bmiHeader.biWidth;
305 height = format->bmiHeader.biHeight;
306 palette = ((LPBYTE)&format->bmiHeader) + format->bmiHeader.biSize;
308 if (!This->init)
310 /* Compute the size of the whole window so the client area size matches video one */
311 RECT wrect, crect;
312 int h, v;
313 GetWindowRect(This->hWnd, &wrect);
314 GetClientRect(This->hWnd, &crect);
315 h = (wrect.right - wrect.left) - (crect.right - crect.left);
316 v = (wrect.bottom - wrect.top) - (crect.bottom - crect.top);
317 SetWindowPos(This->hWnd, NULL, 0, 0, width + h +20, height + v+20, SWP_NOZORDER|SWP_NOMOVE);
318 This->WindowPos.left = 0;
319 This->WindowPos.top = 0;
320 This->WindowPos.right = width;
321 This->WindowPos.bottom = height;
322 GetClientRect(This->hWnd, &This->DestRect);
323 This->init = TRUE;
326 hDC = GetDC(This->hWnd);
328 if (!hDC) {
329 ERR("Cannot get DC from window!\n");
330 return E_FAIL;
333 TRACE("Src Rect: %ld %ld %ld %ld\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
334 TRACE("Dst Rect: %ld %ld %ld %ld\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom);
336 StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
337 This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
338 This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
339 data, (BITMAPINFO*)&format->bmiHeader, DIB_PAL_COLORS, SRCCOPY);
341 ReleaseDC(This->hWnd, hDC);
343 if (This->AutoShow)
344 ShowWindow(This->hWnd, SW_SHOW);
346 return S_OK;
349 static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
351 VideoRendererImpl *This = (VideoRendererImpl *)iface;
352 LPBYTE pbSrcStream = NULL;
353 long cbSrcStream = 0;
354 REFERENCE_TIME tStart, tStop;
355 HRESULT hr;
357 TRACE("%p %p\n", iface, pSample);
359 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
360 if (FAILED(hr))
362 ERR("Cannot get pointer to sample data (%lx)\n", hr);
363 return hr;
366 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
367 if (FAILED(hr))
368 ERR("Cannot get sample time (%lx)\n", hr);
370 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
372 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
374 #if 0 /* For debugging purpose */
376 int i;
377 for(i = 0; i < cbSrcStream; i++)
379 if ((i!=0) && !(i%16))
380 DPRINTF("\n");
381 DPRINTF("%02x ", pbSrcStream[i]);
383 DPRINTF("\n");
385 #endif
387 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
389 return S_OK;
392 static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
394 if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32)) ||
395 (IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24)) ||
396 (IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565)) ||
397 (IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) && IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8)))
399 VideoRendererImpl* This = (VideoRendererImpl*) iface;
400 VIDEOINFOHEADER* format = (VIDEOINFOHEADER*)pmt->pbFormat;
401 This->SourceRect.left = 0;
402 This->SourceRect.top = 0;
403 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
404 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
405 return S_OK;
407 return S_FALSE;
410 HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
412 HRESULT hr;
413 PIN_INFO piInput;
414 VideoRendererImpl * pVideoRenderer;
416 TRACE("(%p, %p)\n", pUnkOuter, ppv);
418 *ppv = NULL;
420 if (pUnkOuter)
421 return CLASS_E_NOAGGREGATION;
423 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
425 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
426 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
427 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
429 pVideoRenderer->refCount = 1;
430 InitializeCriticalSection(&pVideoRenderer->csFilter);
431 pVideoRenderer->state = State_Stopped;
432 pVideoRenderer->pClock = NULL;
433 pVideoRenderer->init = 0;
434 pVideoRenderer->AutoShow = 1;
435 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
437 pVideoRenderer->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
439 /* construct input pin */
440 piInput.dir = PINDIR_INPUT;
441 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
442 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
444 hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
446 if (SUCCEEDED(hr))
448 pVideoRenderer->ppPins[0] = (IPin *)pVideoRenderer->pInputPin;
449 *ppv = (LPVOID)pVideoRenderer;
451 else
453 CoTaskMemFree(pVideoRenderer->ppPins);
454 DeleteCriticalSection(&pVideoRenderer->csFilter);
455 CoTaskMemFree(pVideoRenderer);
458 if (!CreateRenderingSubsystem(pVideoRenderer))
459 return E_FAIL;
461 return hr;
464 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
466 VideoRendererImpl *This = (VideoRendererImpl *)iface;
467 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
469 *ppv = NULL;
471 if (IsEqualIID(riid, &IID_IUnknown))
472 *ppv = (LPVOID)This;
473 else if (IsEqualIID(riid, &IID_IPersist))
474 *ppv = (LPVOID)This;
475 else if (IsEqualIID(riid, &IID_IMediaFilter))
476 *ppv = (LPVOID)This;
477 else if (IsEqualIID(riid, &IID_IBaseFilter))
478 *ppv = (LPVOID)This;
479 else if (IsEqualIID(riid, &IID_IBasicVideo))
480 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
481 else if (IsEqualIID(riid, &IID_IVideoWindow))
482 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
484 if (*ppv)
486 IUnknown_AddRef((IUnknown *)(*ppv));
487 return S_OK;
490 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
492 return E_NOINTERFACE;
495 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
497 VideoRendererImpl *This = (VideoRendererImpl *)iface;
498 ULONG refCount = InterlockedIncrement(&This->refCount);
500 TRACE("(%p/%p)->() AddRef from %ld\n", This, iface, refCount - 1);
502 return refCount;
505 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
507 VideoRendererImpl *This = (VideoRendererImpl *)iface;
508 ULONG refCount = InterlockedDecrement(&This->refCount);
510 TRACE("(%p/%p)->() Release from %ld\n", This, iface, refCount + 1);
512 if (!refCount)
514 DeleteCriticalSection(&This->csFilter);
516 DestroyWindow(This->hWnd);
517 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
518 WaitForSingleObject(This->hThread, INFINITE);
519 CloseHandle(This->hThread);
521 if (This->pClock)
522 IReferenceClock_Release(This->pClock);
524 IPin_Release(This->ppPins[0]);
526 HeapFree(GetProcessHeap(), 0, This->ppPins);
527 This->lpVtbl = NULL;
529 TRACE("Destroying Video Renderer\n");
530 CoTaskMemFree(This);
532 return 0;
534 else
535 return refCount;
538 /** IPersist methods **/
540 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
542 VideoRendererImpl *This = (VideoRendererImpl *)iface;
544 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
546 *pClsid = CLSID_VideoRenderer;
548 return S_OK;
551 /** IMediaFilter methods **/
553 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
555 VideoRendererImpl *This = (VideoRendererImpl *)iface;
557 TRACE("(%p/%p)->()\n", This, iface);
559 EnterCriticalSection(&This->csFilter);
561 This->state = State_Stopped;
563 LeaveCriticalSection(&This->csFilter);
565 return S_OK;
568 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
570 VideoRendererImpl *This = (VideoRendererImpl *)iface;
572 TRACE("(%p/%p)->()\n", This, iface);
574 EnterCriticalSection(&This->csFilter);
576 This->state = State_Paused;
578 LeaveCriticalSection(&This->csFilter);
580 return S_OK;
583 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
585 VideoRendererImpl *This = (VideoRendererImpl *)iface;
587 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
589 EnterCriticalSection(&This->csFilter);
591 This->rtStreamStart = tStart;
592 This->state = State_Running;
594 LeaveCriticalSection(&This->csFilter);
596 return S_OK;
599 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
601 VideoRendererImpl *This = (VideoRendererImpl *)iface;
603 TRACE("(%p/%p)->(%ld, %p)\n", This, iface, dwMilliSecsTimeout, pState);
605 EnterCriticalSection(&This->csFilter);
607 *pState = This->state;
609 LeaveCriticalSection(&This->csFilter);
611 return S_OK;
614 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
616 VideoRendererImpl *This = (VideoRendererImpl *)iface;
618 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
620 EnterCriticalSection(&This->csFilter);
622 if (This->pClock)
623 IReferenceClock_Release(This->pClock);
624 This->pClock = pClock;
625 if (This->pClock)
626 IReferenceClock_AddRef(This->pClock);
628 LeaveCriticalSection(&This->csFilter);
630 return S_OK;
633 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
635 VideoRendererImpl *This = (VideoRendererImpl *)iface;
637 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
639 EnterCriticalSection(&This->csFilter);
641 *ppClock = This->pClock;
642 IReferenceClock_AddRef(This->pClock);
644 LeaveCriticalSection(&This->csFilter);
646 return S_OK;
649 /** IBaseFilter implementation **/
651 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
653 ENUMPINDETAILS epd;
654 VideoRendererImpl *This = (VideoRendererImpl *)iface;
656 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
658 epd.cPins = 1; /* input pin */
659 epd.ppPins = This->ppPins;
660 return IEnumPinsImpl_Construct(&epd, ppEnum);
663 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
665 VideoRendererImpl *This = (VideoRendererImpl *)iface;
667 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
669 FIXME("VideoRenderer::FindPin(...)\n");
671 /* FIXME: critical section */
673 return E_NOTIMPL;
676 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
678 VideoRendererImpl *This = (VideoRendererImpl *)iface;
680 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
682 strcpyW(pInfo->achName, This->filterInfo.achName);
683 pInfo->pGraph = This->filterInfo.pGraph;
685 if (pInfo->pGraph)
686 IFilterGraph_AddRef(pInfo->pGraph);
688 return S_OK;
691 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
693 VideoRendererImpl *This = (VideoRendererImpl *)iface;
695 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
697 EnterCriticalSection(&This->csFilter);
699 if (pName)
700 strcpyW(This->filterInfo.achName, pName);
701 else
702 *This->filterInfo.achName = '\0';
703 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
705 LeaveCriticalSection(&This->csFilter);
707 return S_OK;
710 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
712 VideoRendererImpl *This = (VideoRendererImpl *)iface;
713 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
714 return E_NOTIMPL;
717 static const IBaseFilterVtbl VideoRenderer_Vtbl =
719 VideoRenderer_QueryInterface,
720 VideoRenderer_AddRef,
721 VideoRenderer_Release,
722 VideoRenderer_GetClassID,
723 VideoRenderer_Stop,
724 VideoRenderer_Pause,
725 VideoRenderer_Run,
726 VideoRenderer_GetState,
727 VideoRenderer_SetSyncSource,
728 VideoRenderer_GetSyncSource,
729 VideoRenderer_EnumPins,
730 VideoRenderer_FindPin,
731 VideoRenderer_QueryFilterInfo,
732 VideoRenderer_JoinFilterGraph,
733 VideoRenderer_QueryVendorInfo
736 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
738 InputPin* This = (InputPin*)iface;
739 IMediaEventSink* pEventSink;
740 HRESULT hr;
742 TRACE("(%p/%p)->()\n", This, iface);
744 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
745 if (SUCCEEDED(hr))
747 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
748 IMediaEventSink_Release(pEventSink);
751 return hr;
754 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
756 InputPin_QueryInterface,
757 IPinImpl_AddRef,
758 InputPin_Release,
759 InputPin_Connect,
760 InputPin_ReceiveConnection,
761 IPinImpl_Disconnect,
762 IPinImpl_ConnectedTo,
763 IPinImpl_ConnectionMediaType,
764 IPinImpl_QueryPinInfo,
765 IPinImpl_QueryDirection,
766 IPinImpl_QueryId,
767 IPinImpl_QueryAccept,
768 IPinImpl_EnumMediaTypes,
769 IPinImpl_QueryInternalConnections,
770 VideoRenderer_InputPin_EndOfStream,
771 InputPin_BeginFlush,
772 InputPin_EndFlush,
773 InputPin_NewSegment
776 /*** IUnknown methods ***/
777 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
778 REFIID riid,
779 LPVOID*ppvObj) {
780 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
782 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
784 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
787 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
788 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
790 TRACE("(%p/%p)->()\n", This, iface);
792 return VideoRenderer_AddRef((IBaseFilter*)This);
795 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
796 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
798 TRACE("(%p/%p)->()\n", This, iface);
800 return VideoRenderer_Release((IBaseFilter*)This);
803 /*** IDispatch methods ***/
804 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
805 UINT*pctinfo) {
806 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
808 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
810 return S_OK;
813 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
814 UINT iTInfo,
815 LCID lcid,
816 ITypeInfo**ppTInfo) {
817 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
819 FIXME("(%p/%p)->(%d, %ld, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
821 return S_OK;
824 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
825 REFIID riid,
826 LPOLESTR*rgszNames,
827 UINT cNames,
828 LCID lcid,
829 DISPID*rgDispId) {
830 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
832 FIXME("(%p/%p)->(%s (%p), %p, %d, %ld, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
834 return S_OK;
837 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
838 DISPID dispIdMember,
839 REFIID riid,
840 LCID lcid,
841 WORD wFlags,
842 DISPPARAMS*pDispParams,
843 VARIANT*pVarResult,
844 EXCEPINFO*pExepInfo,
845 UINT*puArgErr) {
846 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
848 FIXME("(%p/%p)->(%ld, %s (%p), %ld, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
850 return S_OK;
853 /*** IBasicVideo methods ***/
854 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
855 REFTIME *pAvgTimePerFrame) {
856 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
858 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
860 return S_OK;
863 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
864 long *pBitRate) {
865 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
867 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
869 return S_OK;
872 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
873 long *pBitErrorRate) {
874 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
876 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
878 return S_OK;
881 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
882 long *pVideoWidth) {
883 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
885 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
887 *pVideoWidth = This->VideoWidth;
889 return S_OK;
892 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
893 long *pVideoHeight) {
894 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
896 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
898 *pVideoHeight = This->VideoHeight;
900 return S_OK;
903 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
904 long SourceLeft) {
905 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
907 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
909 This->SourceRect.left = SourceLeft;
911 return S_OK;
914 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
915 long *pSourceLeft) {
916 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
918 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
920 *pSourceLeft = This->SourceRect.left;
922 return S_OK;
925 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
926 long SourceWidth) {
927 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
929 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
931 This->SourceRect.right = This->SourceRect.left + SourceWidth;
933 return S_OK;
936 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
937 long *pSourceWidth) {
938 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
940 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
942 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
944 return S_OK;
947 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
948 long SourceTop) {
949 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
951 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
953 This->SourceRect.top = SourceTop;
955 return S_OK;
958 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
959 long *pSourceTop) {
960 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
962 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
964 *pSourceTop = This->SourceRect.top;
966 return S_OK;
969 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
970 long SourceHeight) {
971 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
973 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
975 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
977 return S_OK;
980 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
981 long *pSourceHeight) {
982 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
984 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
986 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
988 return S_OK;
991 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
992 long DestinationLeft) {
993 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
995 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
997 This->DestRect.left = DestinationLeft;
999 return S_OK;
1002 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1003 long *pDestinationLeft) {
1004 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1006 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1008 *pDestinationLeft = This->DestRect.left;
1010 return S_OK;
1013 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1014 long DestinationWidth) {
1015 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1017 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1019 This->DestRect.right = This->DestRect.left + DestinationWidth;
1021 return S_OK;
1024 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1025 long *pDestinationWidth) {
1026 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1028 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1030 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1032 return S_OK;
1035 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1036 long DestinationTop) {
1037 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1039 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1041 This->DestRect.top = DestinationTop;
1043 return S_OK;
1046 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1047 long *pDestinationTop) {
1048 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1050 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1052 *pDestinationTop = This->DestRect.top;
1054 return S_OK;
1057 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1058 long DestinationHeight) {
1059 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1061 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1063 This->DestRect.right = This->DestRect.left + DestinationHeight;
1065 return S_OK;
1068 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1069 long *pDestinationHeight) {
1070 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1072 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1074 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1076 return S_OK;
1079 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1080 long Left,
1081 long Top,
1082 long Width,
1083 long Height) {
1084 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1086 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1088 This->SourceRect.left = Left;
1089 This->SourceRect.top = Top;
1090 This->SourceRect.right = Left + Width;
1091 This->SourceRect.bottom = Top + Height;
1093 return S_OK;
1096 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1097 long *pLeft,
1098 long *pTop,
1099 long *pWidth,
1100 long *pHeight) {
1101 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1103 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1105 *pLeft = This->SourceRect.left;
1106 *pTop = This->SourceRect.top;
1107 *pWidth = This->SourceRect.right - This->SourceRect.left;
1108 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1110 return S_OK;
1113 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1114 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1116 TRACE("(%p/%p)->()\n", This, iface);
1118 This->SourceRect.left = 0;
1119 This->SourceRect.top = 0;
1120 This->SourceRect.right = This->VideoWidth;
1121 This->SourceRect.bottom = This->VideoHeight;
1123 return S_OK;
1126 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1127 long Left,
1128 long Top,
1129 long Width,
1130 long Height) {
1131 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1133 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1135 This->DestRect.left = Left;
1136 This->DestRect.top = Top;
1137 This->DestRect.right = Left + Width;
1138 This->DestRect.bottom = Top + Height;
1140 return S_OK;
1143 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1144 long *pLeft,
1145 long *pTop,
1146 long *pWidth,
1147 long *pHeight) {
1148 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1150 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1152 *pLeft = This->DestRect.left;
1153 *pTop = This->DestRect.top;
1154 *pWidth = This->DestRect.right - This->DestRect.left;
1155 *pHeight = This->DestRect.bottom - This->DestRect.top;
1157 return S_OK;
1160 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1161 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1162 RECT rect;
1164 TRACE("(%p/%p)->()\n", This, iface);
1166 if (!GetClientRect(This->hWnd, &rect))
1167 return E_FAIL;
1169 This->SourceRect.left = 0;
1170 This->SourceRect.top = 0;
1171 This->SourceRect.right = rect.right;
1172 This->SourceRect.bottom = rect.bottom;
1174 return S_OK;
1177 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1178 long *pWidth,
1179 long *pHeight) {
1180 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1182 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1184 *pWidth = This->VideoWidth;
1185 *pHeight = This->VideoHeight;
1187 return S_OK;
1190 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1191 long StartIndex,
1192 long Entries,
1193 long *pRetrieved,
1194 long *pPalette) {
1195 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1197 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1199 return S_OK;
1202 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1203 long *pBufferSize,
1204 long *pDIBImage) {
1205 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1207 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
1209 return S_OK;
1212 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1213 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1215 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1217 return S_OK;
1220 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1221 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1223 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1225 return S_OK;
1229 static const IBasicVideoVtbl IBasicVideo_VTable =
1231 Basicvideo_QueryInterface,
1232 Basicvideo_AddRef,
1233 Basicvideo_Release,
1234 Basicvideo_GetTypeInfoCount,
1235 Basicvideo_GetTypeInfo,
1236 Basicvideo_GetIDsOfNames,
1237 Basicvideo_Invoke,
1238 Basicvideo_get_AvgTimePerFrame,
1239 Basicvideo_get_BitRate,
1240 Basicvideo_get_BitErrorRate,
1241 Basicvideo_get_VideoWidth,
1242 Basicvideo_get_VideoHeight,
1243 Basicvideo_put_SourceLeft,
1244 Basicvideo_get_SourceLeft,
1245 Basicvideo_put_SourceWidth,
1246 Basicvideo_get_SourceWidth,
1247 Basicvideo_put_SourceTop,
1248 Basicvideo_get_SourceTop,
1249 Basicvideo_put_SourceHeight,
1250 Basicvideo_get_SourceHeight,
1251 Basicvideo_put_DestinationLeft,
1252 Basicvideo_get_DestinationLeft,
1253 Basicvideo_put_DestinationWidth,
1254 Basicvideo_get_DestinationWidth,
1255 Basicvideo_put_DestinationTop,
1256 Basicvideo_get_DestinationTop,
1257 Basicvideo_put_DestinationHeight,
1258 Basicvideo_get_DestinationHeight,
1259 Basicvideo_SetSourcePosition,
1260 Basicvideo_GetSourcePosition,
1261 Basicvideo_SetDefaultSourcePosition,
1262 Basicvideo_SetDestinationPosition,
1263 Basicvideo_GetDestinationPosition,
1264 Basicvideo_SetDefaultDestinationPosition,
1265 Basicvideo_GetVideoSize,
1266 Basicvideo_GetVideoPaletteEntries,
1267 Basicvideo_GetCurrentImage,
1268 Basicvideo_IsUsingDefaultSource,
1269 Basicvideo_IsUsingDefaultDestination
1273 /*** IUnknown methods ***/
1274 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1275 REFIID riid,
1276 LPVOID*ppvObj) {
1277 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1279 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1281 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1284 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1285 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1287 TRACE("(%p/%p)->()\n", This, iface);
1289 return VideoRenderer_AddRef((IBaseFilter*)This);
1292 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1293 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1295 TRACE("(%p/%p)->()\n", This, iface);
1297 return VideoRenderer_Release((IBaseFilter*)This);
1300 /*** IDispatch methods ***/
1301 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1302 UINT*pctinfo) {
1303 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1305 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1307 return S_OK;
1310 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1311 UINT iTInfo,
1312 LCID lcid,
1313 ITypeInfo**ppTInfo) {
1314 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1316 FIXME("(%p/%p)->(%d, %ld, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1318 return S_OK;
1321 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1322 REFIID riid,
1323 LPOLESTR*rgszNames,
1324 UINT cNames,
1325 LCID lcid,
1326 DISPID*rgDispId) {
1327 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1329 FIXME("(%p/%p)->(%s (%p), %p, %d, %ld, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1331 return S_OK;
1334 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1335 DISPID dispIdMember,
1336 REFIID riid,
1337 LCID lcid,
1338 WORD wFlags,
1339 DISPPARAMS*pDispParams,
1340 VARIANT*pVarResult,
1341 EXCEPINFO*pExepInfo,
1342 UINT*puArgErr) {
1343 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1345 FIXME("(%p/%p)->(%ld, %s (%p), %ld, %04x, %p, %p, %p, %p): stub !!!\n", This, iface, dispIdMember, debugstr_guid(riid), riid, lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
1347 return S_OK;
1350 /*** IVideoWindow methods ***/
1351 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1352 BSTR strCaption) {
1353 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1355 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1357 if (!SetWindowTextW(This->hWnd, strCaption))
1358 return E_FAIL;
1360 return S_OK;
1363 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1364 BSTR *strCaption) {
1365 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1367 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1369 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1371 return S_OK;
1374 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1375 long WindowStyle) {
1376 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1377 LONG old;
1379 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1381 TRACE("(%p/%p)->(%lx -> %lx)\n", This, iface, old, WindowStyle);
1383 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1384 return E_INVALIDARG;
1386 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1388 return S_OK;
1391 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1392 long *WindowStyle) {
1393 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1395 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1397 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1399 return S_OK;
1402 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1403 long WindowStyleEx) {
1404 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1406 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1408 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1409 return E_INVALIDARG;
1411 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1412 return E_FAIL;
1414 return S_OK;
1417 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1418 long *WindowStyleEx) {
1419 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1421 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1423 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1425 return S_OK;
1428 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1429 long AutoShow) {
1430 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1432 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1434 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1436 return S_OK;
1439 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1440 long *AutoShow) {
1441 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1443 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1445 *AutoShow = This->AutoShow;
1447 return S_OK;
1450 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1451 long WindowState) {
1452 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1454 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1456 return S_OK;
1459 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1460 long *WindowState) {
1461 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1463 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1465 return S_OK;
1468 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1469 long BackgroundPalette) {
1470 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1472 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1474 return S_OK;
1477 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1478 long *pBackgroundPalette) {
1479 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1481 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1483 return S_OK;
1486 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1487 long Visible) {
1488 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1490 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1492 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1494 return S_OK;
1497 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1498 long *pVisible) {
1499 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1501 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1503 *pVisible = IsWindowVisible(This->hWnd);
1505 return S_OK;
1508 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1509 long Left) {
1510 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1512 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1514 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1515 return E_FAIL;
1517 This->WindowPos.left = Left;
1519 return S_OK;
1522 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1523 long *pLeft) {
1524 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1526 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1528 *pLeft = This->WindowPos.left;
1530 return S_OK;
1533 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1534 long Width) {
1535 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1537 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1539 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1540 return E_FAIL;
1542 This->WindowPos.right = This->WindowPos.left + Width;
1544 return S_OK;
1547 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1548 long *pWidth) {
1549 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1551 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1553 *pWidth = This->WindowPos.right - This->WindowPos.left;
1555 return S_OK;
1558 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1559 long Top) {
1560 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1562 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1564 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1565 return E_FAIL;
1567 This->WindowPos.top = Top;
1569 return S_OK;
1572 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1573 long *pTop) {
1574 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1576 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1578 *pTop = This->WindowPos.top;
1580 return S_OK;
1583 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1584 long Height) {
1585 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1587 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1589 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1590 return E_FAIL;
1592 This->WindowPos.bottom = This->WindowPos.top + Height;
1594 return S_OK;
1597 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1598 long *pHeight) {
1599 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1601 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1603 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1605 return S_OK;
1608 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1609 OAHWND Owner) {
1610 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1612 TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) Owner);
1614 SetParent(This->hWnd, (HWND)Owner);
1616 return S_OK;
1619 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1620 OAHWND *Owner) {
1621 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1623 TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) Owner);
1625 *(HWND*)Owner = GetParent(This->hWnd);
1627 return S_OK;
1630 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1631 OAHWND Drain) {
1632 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1634 TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) Drain);
1636 This->hWndMsgDrain = (HWND)Drain;
1638 return S_OK;
1641 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1642 OAHWND *Drain) {
1643 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1645 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1647 *Drain = (OAHWND)This->hWndMsgDrain;
1649 return S_OK;
1652 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1653 long *Color) {
1654 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1656 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1658 return S_OK;
1661 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1662 long Color) {
1663 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1665 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1667 return S_OK;
1670 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1671 long *FullScreenMode) {
1672 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1674 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1676 return S_OK;
1679 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1680 long FullScreenMode) {
1681 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1683 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1685 return S_OK;
1688 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1689 long Focus) {
1690 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1691 BOOL ret;
1692 IPin* pPin;
1693 HRESULT hr;
1695 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1697 if ((Focus != FALSE) && (Focus != TRUE))
1698 return E_INVALIDARG;
1700 hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1701 if ((hr != S_OK) || !pPin)
1702 return VFW_E_NOT_CONNECTED;
1704 if (Focus)
1705 ret = SetForegroundWindow(This->hWnd);
1706 else
1707 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1709 if (!ret)
1710 return E_FAIL;
1712 return S_OK;
1715 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1716 OAHWND hwnd,
1717 long uMsg,
1718 LONG_PTR wParam,
1719 LONG_PTR lParam) {
1720 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1722 TRACE("(%p/%p)->(%08lx, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
1724 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1725 return E_FAIL;
1727 return S_OK;
1730 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1731 long Left,
1732 long Top,
1733 long Width,
1734 long Height) {
1735 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1737 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1739 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1740 return E_FAIL;
1742 This->WindowPos.left = Left;
1743 This->WindowPos.top = Top;
1744 This->WindowPos.right = Left + Width;
1745 This->WindowPos.bottom = Top + Height;
1747 return S_OK;
1750 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1751 long *pLeft,
1752 long *pTop,
1753 long *pWidth,
1754 long *pHeight) {
1755 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1757 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1759 *pLeft = This->WindowPos.left;
1760 *pTop = This->WindowPos.top;
1761 *pWidth = This->WindowPos.right - This->WindowPos.left;
1762 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1764 return S_OK;
1767 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1768 long *pWidth,
1769 long *pHeight) {
1770 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1772 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1774 *pWidth = This->VideoWidth;
1775 *pHeight = This->VideoHeight;
1777 return S_OK;
1780 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1781 long *pWidth,
1782 long *pHeight) {
1783 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1785 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1787 *pWidth = This->VideoWidth;
1788 *pHeight = This->VideoHeight;
1790 return S_OK;
1793 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1794 long *pLeft,
1795 long *pTop,
1796 long *pWidth,
1797 long *pHeight) {
1798 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1800 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
1802 return S_OK;
1805 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1806 long HideCursor) {
1807 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1809 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
1811 return S_OK;
1814 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1815 long *CursorHidden) {
1816 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1818 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
1820 return S_OK;
1823 static const IVideoWindowVtbl IVideoWindow_VTable =
1825 Videowindow_QueryInterface,
1826 Videowindow_AddRef,
1827 Videowindow_Release,
1828 Videowindow_GetTypeInfoCount,
1829 Videowindow_GetTypeInfo,
1830 Videowindow_GetIDsOfNames,
1831 Videowindow_Invoke,
1832 Videowindow_put_Caption,
1833 Videowindow_get_Caption,
1834 Videowindow_put_WindowStyle,
1835 Videowindow_get_WindowStyle,
1836 Videowindow_put_WindowStyleEx,
1837 Videowindow_get_WindowStyleEx,
1838 Videowindow_put_AutoShow,
1839 Videowindow_get_AutoShow,
1840 Videowindow_put_WindowState,
1841 Videowindow_get_WindowState,
1842 Videowindow_put_BackgroundPalette,
1843 Videowindow_get_BackgroundPalette,
1844 Videowindow_put_Visible,
1845 Videowindow_get_Visible,
1846 Videowindow_put_Left,
1847 Videowindow_get_Left,
1848 Videowindow_put_Width,
1849 Videowindow_get_Width,
1850 Videowindow_put_Top,
1851 Videowindow_get_Top,
1852 Videowindow_put_Height,
1853 Videowindow_get_Height,
1854 Videowindow_put_Owner,
1855 Videowindow_get_Owner,
1856 Videowindow_put_MessageDrain,
1857 Videowindow_get_MessageDrain,
1858 Videowindow_get_BorderColor,
1859 Videowindow_put_BorderColor,
1860 Videowindow_get_FullScreenMode,
1861 Videowindow_put_FullScreenMode,
1862 Videowindow_SetWindowForeground,
1863 Videowindow_NotifyOwnerMessage,
1864 Videowindow_SetWindowPosition,
1865 Videowindow_GetWindowPosition,
1866 Videowindow_GetMinIdealImageSize,
1867 Videowindow_GetMaxIdealImageSize,
1868 Videowindow_GetRestorePosition,
1869 Videowindow_HideCursor,
1870 Videowindow_IsCursorHidden