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
23 #define NONAMELESSSTRUCT
24 #define NONAMELESSUNION
25 #include "quartz_private.h"
26 #include "control_private.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 IUnknownVtbl IInner_VTable;
52 static const IBasicVideoVtbl IBasicVideo_VTable;
53 static const IVideoWindowVtbl IVideoWindow_VTable;
54 static const IPinVtbl VideoRenderer_InputPin_Vtbl;
56 typedef struct VideoRendererImpl
58 const IBaseFilterVtbl * lpVtbl;
59 const IBasicVideoVtbl * IBasicVideo_vtbl;
60 const IVideoWindowVtbl * IVideoWindow_vtbl;
61 const IUnknownVtbl * IInner_vtbl;
64 CRITICAL_SECTION csFilter;
66 REFERENCE_TIME rtStreamStart;
67 IReferenceClock * pClock;
68 FILTER_INFO filterInfo;
88 REFERENCE_TIME rtLastStop;
89 MediaSeekingImpl mediaSeeking;
91 /* During pause we can hold a single sample, for use in GetCurrentImage */
92 IMediaSample *sample_held;
95 static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
97 VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongA(hwnd, 0);
98 LPRECT lprect = (LPRECT)lParam;
100 if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
106 case WM_LBUTTONDBLCLK:
109 case WM_MBUTTONDBLCLK:
112 case WM_MOUSEACTIVATE:
114 case WM_NCLBUTTONDBLCLK:
115 case WM_NCLBUTTONDOWN:
117 case WM_NCMBUTTONDBLCLK:
118 case WM_NCMBUTTONDOWN:
121 case WM_NCRBUTTONDBLCLK:
122 case WM_NCRBUTTONDOWN:
124 case WM_RBUTTONDBLCLK:
127 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
137 /* TRACE("WM_SIZING %d %d %d %d\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
138 SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
139 GetClientRect(hwnd, &pVideoRenderer->DestRect);
140 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
141 pVideoRenderer->DestRect.left,
142 pVideoRenderer->DestRect.top,
143 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
144 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
147 TRACE("WM_SIZE %d %d\n", LOWORD(lParam), HIWORD(lParam));
148 GetClientRect(hwnd, &pVideoRenderer->DestRect);
149 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
150 pVideoRenderer->DestRect.left,
151 pVideoRenderer->DestRect.top,
152 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
153 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
156 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
161 static BOOL CreateRenderingWindow(VideoRendererImpl* This)
165 TRACE("(%p)->()\n", This);
168 winclass.lpfnWndProc = VideoWndProcA;
169 winclass.cbClsExtra = 0;
170 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
171 winclass.hInstance = NULL;
172 winclass.hIcon = NULL;
173 winclass.hCursor = NULL;
174 winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
175 winclass.lpszMenuName = NULL;
176 winclass.lpszClassName = "Wine ActiveMovie Class";
178 if (!wnd_class_registered)
180 if (!RegisterClassA(&winclass))
182 ERR("Unable to register window %u\n", GetLastError());
185 wnd_class_registered = TRUE;
188 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
189 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
194 ERR("Unable to create window\n");
198 SetWindowLongA(This->hWnd, 0, (LONG)This);
203 static DWORD WINAPI MessageLoop(LPVOID lpParameter)
205 VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
209 TRACE("Starting message loop\n");
211 if (!CreateRenderingWindow(This))
213 This->ThreadResult = FALSE;
214 SetEvent(This->hEvent);
218 This->ThreadResult = TRUE;
219 SetEvent(This->hEvent);
221 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
223 TranslateMessage(&msg);
224 DispatchMessageA(&msg);
227 TRACE("End of message loop\n");
232 static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
234 This->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
238 This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
241 CloseHandle(This->hEvent);
245 WaitForSingleObject(This->hEvent, INFINITE);
246 CloseHandle(This->hEvent);
248 if (!This->ThreadResult)
250 CloseHandle(This->hThread);
257 static const IMemInputPinVtbl MemInputPin_Vtbl =
259 MemInputPin_QueryInterface,
262 MemInputPin_GetAllocator,
263 MemInputPin_NotifyAllocator,
264 MemInputPin_GetAllocatorRequirements,
266 MemInputPin_ReceiveMultiple,
267 MemInputPin_ReceiveCanBlock
270 static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
277 LPBYTE palette = NULL;
279 BITMAPINFOHEADER *bmiHeader;
281 TRACE("%p %p %d\n", This, data, size);
283 sdesc.dwSize = sizeof(sdesc);
284 hr = IPin_ConnectionMediaType((IPin *)This->pInputPin, &amt);
286 ERR("Unable to retrieve media type\n");
290 if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo))
292 bmiHeader = &((VIDEOINFOHEADER *)amt.pbFormat)->bmiHeader;
294 else if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo2))
296 bmiHeader = &((VIDEOINFOHEADER2 *)amt.pbFormat)->bmiHeader;
300 FIXME("Unknown type %s\n", debugstr_guid(&amt.subtype));
301 return VFW_E_RUNTIME_ERROR;
305 TRACE("biSize = %d\n", bmiHeader->biSize);
306 TRACE("biWidth = %d\n", bmiHeader->biWidth);
307 TRACE("biHeight = %d\n", bmiHeader->biHeight);
308 TRACE("biPlanes = %d\n", bmiHeader->biPlanes);
309 TRACE("biBitCount = %d\n", bmiHeader->biBitCount);
310 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(bmiHeader->biCompression), 4));
311 TRACE("biSizeImage = %d\n", bmiHeader->biSizeImage);
313 width = bmiHeader->biWidth;
314 height = bmiHeader->biHeight;
315 palette = ((LPBYTE)bmiHeader) + bmiHeader->biSize;
319 if (!This->WindowPos.right || !This->WindowPos.bottom)
320 This->WindowPos = This->SourceRect;
322 TRACE("WindowPos: %d %d %d %d\n", This->WindowPos.left, This->WindowPos.top, This->WindowPos.right, This->WindowPos.bottom);
323 SetWindowPos(This->hWnd, NULL,
324 This->WindowPos.left,
326 This->WindowPos.right - This->WindowPos.left,
327 This->WindowPos.bottom - This->WindowPos.top,
328 SWP_NOZORDER|SWP_NOMOVE);
330 GetClientRect(This->hWnd, &This->DestRect);
334 hDC = GetDC(This->hWnd);
337 ERR("Cannot get DC from window!\n");
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 *)bmiHeader, DIB_RGB_COLORS, SRCCOPY);
349 ReleaseDC(This->hWnd, hDC);
351 ShowWindow(This->hWnd, SW_SHOW);
356 static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
358 VideoRendererImpl *This = (VideoRendererImpl *)iface;
359 LPBYTE pbSrcStream = NULL;
360 long cbSrcStream = 0;
361 REFERENCE_TIME tStart, tStop;
364 if (This->state == State_Stopped)
367 TRACE("%p %p\n", iface, pSample);
369 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
371 ERR("Cannot get sample time (%x)\n", hr);
373 if (This->rtLastStop != tStart)
375 if (IMediaSample_IsDiscontinuity(pSample) == S_FALSE)
376 ERR("Unexpected discontinuity: Last: %u.%03u, tStart: %u.%03u\n",
377 (DWORD)(This->rtLastStop / 10000000),
378 (DWORD)((This->rtLastStop / 10000)%1000),
379 (DWORD)(tStart / 10000000), (DWORD)((tStart / 10000)%1000));
380 This->rtLastStop = tStart;
383 /* Preroll means the sample isn't shown, this is used for key frames and things like that */
384 if (IMediaSample_IsPreroll(pSample) == S_OK)
386 This->rtLastStop = tStop;
390 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
393 ERR("Cannot get pointer to sample data (%x)\n", hr);
397 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
399 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
401 #if 0 /* For debugging purpose */
404 for(i = 0; i < cbSrcStream; i++)
406 if ((i!=0) && !(i%16))
408 TRACE("%02x ", pbSrcStream[i]);
414 if (This->state == State_Paused)
416 if (This->sample_held)
417 IMediaSample_Release(This->sample_held);
419 This->sample_held = pSample;
420 IMediaSample_AddRef(pSample);
423 if (This->pClock && This->state == State_Running)
425 REFERENCE_TIME time, trefstart, trefstop;
428 /* Perhaps I <SHOULD> use the reference clock AdviseTime function here
429 * I'm not going to! When I tried, it seemed to generate lag and
430 * it caused instability.
432 IReferenceClock_GetTime(This->pClock, &time);
434 trefstart = This->rtStreamStart;
435 trefstop = (REFERENCE_TIME)((double)(tStop - tStart) / This->pInputPin->dRate) + This->rtStreamStart;
436 delta = (LONG)((trefstart-time)/10000);
437 This->rtStreamStart = trefstop;
438 This->rtLastStop = tStop;
442 TRACE("Sleeping for %u ms\n", delta);
445 else if (time > trefstop)
447 TRACE("Dropping sample: Time: %lld ms trefstop: %lld ms!\n", time/10000, trefstop/10000);
448 This->rtLastStop = tStop;
452 This->rtLastStop = tStop;
454 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
459 static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
461 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
464 if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
465 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
466 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
467 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
469 VideoRendererImpl* This = (VideoRendererImpl*) iface;
471 if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
473 VIDEOINFOHEADER *format = (VIDEOINFOHEADER *)pmt->pbFormat;
474 This->SourceRect.left = 0;
475 This->SourceRect.top = 0;
476 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
477 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
479 else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
481 VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)pmt->pbFormat;
483 This->SourceRect.left = 0;
484 This->SourceRect.top = 0;
485 This->SourceRect.right = This->VideoWidth = format2->bmiHeader.biWidth;
486 This->SourceRect.bottom = This->VideoHeight = format2->bmiHeader.biHeight;
490 WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
498 static inline VideoRendererImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
500 return (VideoRendererImpl *)((char*)iface - FIELD_OFFSET(VideoRendererImpl, mediaSeeking.lpVtbl));
503 static HRESULT WINAPI VideoRendererImpl_Seeking_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
505 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
507 return IUnknown_QueryInterface((IUnknown *)This, riid, ppv);
510 static ULONG WINAPI VideoRendererImpl_Seeking_AddRef(IMediaSeeking * iface)
512 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
514 return IUnknown_AddRef((IUnknown *)This);
517 static ULONG WINAPI VideoRendererImpl_Seeking_Release(IMediaSeeking * iface)
519 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
521 return IUnknown_Release((IUnknown *)This);
524 static const IMediaSeekingVtbl VideoRendererImpl_Seeking_Vtbl =
526 VideoRendererImpl_Seeking_QueryInterface,
527 VideoRendererImpl_Seeking_AddRef,
528 VideoRendererImpl_Seeking_Release,
529 MediaSeekingImpl_GetCapabilities,
530 MediaSeekingImpl_CheckCapabilities,
531 MediaSeekingImpl_IsFormatSupported,
532 MediaSeekingImpl_QueryPreferredFormat,
533 MediaSeekingImpl_GetTimeFormat,
534 MediaSeekingImpl_IsUsingTimeFormat,
535 MediaSeekingImpl_SetTimeFormat,
536 MediaSeekingImpl_GetDuration,
537 MediaSeekingImpl_GetStopPosition,
538 MediaSeekingImpl_GetCurrentPosition,
539 MediaSeekingImpl_ConvertTimeFormat,
540 MediaSeekingImpl_SetPositions,
541 MediaSeekingImpl_GetPositions,
542 MediaSeekingImpl_GetAvailable,
543 MediaSeekingImpl_SetRate,
544 MediaSeekingImpl_GetRate,
545 MediaSeekingImpl_GetPreroll
548 static HRESULT VideoRendererImpl_Change(IBaseFilter *iface)
550 TRACE("(%p)\n", iface);
554 HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
558 VideoRendererImpl * pVideoRenderer;
560 TRACE("(%p, %p)\n", pUnkOuter, ppv);
564 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
565 pVideoRenderer->pUnkOuter = pUnkOuter;
566 pVideoRenderer->bUnkOuterValid = FALSE;
567 pVideoRenderer->bAggregatable = FALSE;
568 pVideoRenderer->IInner_vtbl = &IInner_VTable;
570 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
571 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
572 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
574 pVideoRenderer->refCount = 1;
575 InitializeCriticalSection(&pVideoRenderer->csFilter);
576 pVideoRenderer->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
577 pVideoRenderer->state = State_Stopped;
578 pVideoRenderer->pClock = NULL;
579 pVideoRenderer->init = 0;
580 pVideoRenderer->AutoShow = 1;
581 pVideoRenderer->rtLastStop = -1;
582 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
583 ZeroMemory(&pVideoRenderer->SourceRect, sizeof(RECT));
584 ZeroMemory(&pVideoRenderer->DestRect, sizeof(RECT));
585 ZeroMemory(&pVideoRenderer->WindowPos, sizeof(RECT));
586 pVideoRenderer->hWndMsgDrain = NULL;
588 /* construct input pin */
589 piInput.dir = PINDIR_INPUT;
590 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
591 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
593 hr = InputPin_Construct(&VideoRenderer_InputPin_Vtbl, &piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, NULL, &pVideoRenderer->csFilter, NULL, (IPin **)&pVideoRenderer->pInputPin);
597 MediaSeekingImpl_Init((IBaseFilter*)pVideoRenderer, VideoRendererImpl_Change, VideoRendererImpl_Change, VideoRendererImpl_Change, &pVideoRenderer->mediaSeeking, &pVideoRenderer->csFilter);
598 pVideoRenderer->mediaSeeking.lpVtbl = &VideoRendererImpl_Seeking_Vtbl;
600 pVideoRenderer->sample_held = NULL;
601 *ppv = (LPVOID)pVideoRenderer;
605 pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
606 DeleteCriticalSection(&pVideoRenderer->csFilter);
607 CoTaskMemFree(pVideoRenderer);
610 if (!CreateRenderingSubsystem(pVideoRenderer))
616 HRESULT VideoRendererDefault_create(IUnknown * pUnkOuter, LPVOID * ppv)
618 /* TODO: Attempt to use the VMR-7 renderer instead when possible */
619 return VideoRenderer_create(pUnkOuter, ppv);
622 static HRESULT WINAPI VideoRendererInner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID * ppv)
624 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
625 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
627 if (This->bAggregatable)
628 This->bUnkOuterValid = TRUE;
632 if (IsEqualIID(riid, &IID_IUnknown))
633 *ppv = (LPVOID)&(This->IInner_vtbl);
634 else if (IsEqualIID(riid, &IID_IPersist))
636 else if (IsEqualIID(riid, &IID_IMediaFilter))
638 else if (IsEqualIID(riid, &IID_IBaseFilter))
640 else if (IsEqualIID(riid, &IID_IBasicVideo))
641 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
642 else if (IsEqualIID(riid, &IID_IVideoWindow))
643 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
644 else if (IsEqualIID(riid, &IID_IMediaSeeking))
645 *ppv = &This->mediaSeeking;
649 IUnknown_AddRef((IUnknown *)(*ppv));
653 if (!IsEqualIID(riid, &IID_IPin))
654 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
656 return E_NOINTERFACE;
659 static ULONG WINAPI VideoRendererInner_AddRef(IUnknown * iface)
661 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
662 ULONG refCount = InterlockedIncrement(&This->refCount);
664 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
669 static ULONG WINAPI VideoRendererInner_Release(IUnknown * iface)
671 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
672 ULONG refCount = InterlockedDecrement(&This->refCount);
674 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
680 DestroyWindow(This->hWnd);
681 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
682 WaitForSingleObject(This->hThread, INFINITE);
683 CloseHandle(This->hThread);
686 IReferenceClock_Release(This->pClock);
688 if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo)))
690 IPin_Disconnect(pConnectedTo);
691 IPin_Release(pConnectedTo);
693 IPin_Disconnect((IPin *)This->pInputPin);
695 IPin_Release((IPin *)This->pInputPin);
699 This->csFilter.DebugInfo->Spare[0] = 0;
700 DeleteCriticalSection(&This->csFilter);
702 TRACE("Destroying Video Renderer\n");
711 static const IUnknownVtbl IInner_VTable =
713 VideoRendererInner_QueryInterface,
714 VideoRendererInner_AddRef,
715 VideoRendererInner_Release
718 static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
720 VideoRendererImpl *This = (VideoRendererImpl *)iface;
722 if (This->bAggregatable)
723 This->bUnkOuterValid = TRUE;
727 if (This->bAggregatable)
728 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
730 if (IsEqualIID(riid, &IID_IUnknown))
734 IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
735 hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
736 IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
737 This->bAggregatable = TRUE;
742 return E_NOINTERFACE;
745 return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
748 static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
750 VideoRendererImpl *This = (VideoRendererImpl *)iface;
752 if (This->pUnkOuter && This->bUnkOuterValid)
753 return IUnknown_AddRef(This->pUnkOuter);
754 return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
757 static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
759 VideoRendererImpl *This = (VideoRendererImpl *)iface;
761 if (This->pUnkOuter && This->bUnkOuterValid)
762 return IUnknown_Release(This->pUnkOuter);
763 return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
766 /** IPersist methods **/
768 static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
770 VideoRendererImpl *This = (VideoRendererImpl *)iface;
772 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
774 *pClsid = CLSID_VideoRenderer;
779 /** IMediaFilter methods **/
781 static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
783 VideoRendererImpl *This = (VideoRendererImpl *)iface;
785 TRACE("(%p/%p)->()\n", This, iface);
787 EnterCriticalSection(&This->csFilter);
789 This->state = State_Stopped;
791 if (This->sample_held)
793 IMediaSample_Release(This->sample_held);
794 This->sample_held = NULL;
797 LeaveCriticalSection(&This->csFilter);
802 static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
804 VideoRendererImpl *This = (VideoRendererImpl *)iface;
806 TRACE("(%p/%p)->()\n", This, iface);
808 EnterCriticalSection(&This->csFilter);
810 if (This->state == State_Stopped)
811 This->pInputPin->end_of_stream = 0;
813 This->state = State_Paused;
815 LeaveCriticalSection(&This->csFilter);
820 static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
822 VideoRendererImpl *This = (VideoRendererImpl *)iface;
824 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
826 EnterCriticalSection(&This->csFilter);
827 if (This->state != State_Running)
829 if (This->state == State_Stopped)
830 This->pInputPin->end_of_stream = 0;
832 This->rtStreamStart = tStart;
833 This->state = State_Running;
835 if (This->sample_held)
837 IMediaSample_Release(This->sample_held);
838 This->sample_held = NULL;
841 LeaveCriticalSection(&This->csFilter);
846 static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
848 VideoRendererImpl *This = (VideoRendererImpl *)iface;
850 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
852 EnterCriticalSection(&This->csFilter);
854 *pState = This->state;
856 LeaveCriticalSection(&This->csFilter);
861 static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
863 VideoRendererImpl *This = (VideoRendererImpl *)iface;
865 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
867 EnterCriticalSection(&This->csFilter);
870 IReferenceClock_Release(This->pClock);
871 This->pClock = pClock;
873 IReferenceClock_AddRef(This->pClock);
875 LeaveCriticalSection(&This->csFilter);
880 static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
882 VideoRendererImpl *This = (VideoRendererImpl *)iface;
884 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
886 EnterCriticalSection(&This->csFilter);
888 *ppClock = This->pClock;
890 IReferenceClock_AddRef(This->pClock);
892 LeaveCriticalSection(&This->csFilter);
897 /** IBaseFilter implementation **/
899 static HRESULT VideoRenderer_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin, DWORD *lastsynctick)
901 VideoRendererImpl *This = (VideoRendererImpl *)iface;
903 /* Our pins are static, not changing so setting static tick count is ok */
909 *pin = (IPin *)This->pInputPin;
914 static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
916 VideoRendererImpl *This = (VideoRendererImpl *)iface;
918 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
920 return IEnumPinsImpl_Construct(ppEnum, VideoRenderer_GetPin, iface);
923 static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
925 VideoRendererImpl *This = (VideoRendererImpl *)iface;
927 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
929 FIXME("VideoRenderer::FindPin(...)\n");
931 /* FIXME: critical section */
936 static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
938 VideoRendererImpl *This = (VideoRendererImpl *)iface;
940 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
942 strcpyW(pInfo->achName, This->filterInfo.achName);
943 pInfo->pGraph = This->filterInfo.pGraph;
946 IFilterGraph_AddRef(pInfo->pGraph);
951 static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
953 VideoRendererImpl *This = (VideoRendererImpl *)iface;
955 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
957 EnterCriticalSection(&This->csFilter);
960 strcpyW(This->filterInfo.achName, pName);
962 *This->filterInfo.achName = '\0';
963 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
965 LeaveCriticalSection(&This->csFilter);
970 static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
972 VideoRendererImpl *This = (VideoRendererImpl *)iface;
973 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
977 static const IBaseFilterVtbl VideoRenderer_Vtbl =
979 VideoRenderer_QueryInterface,
980 VideoRenderer_AddRef,
981 VideoRenderer_Release,
982 VideoRenderer_GetClassID,
986 VideoRenderer_GetState,
987 VideoRenderer_SetSyncSource,
988 VideoRenderer_GetSyncSource,
989 VideoRenderer_EnumPins,
990 VideoRenderer_FindPin,
991 VideoRenderer_QueryFilterInfo,
992 VideoRenderer_JoinFilterGraph,
993 VideoRenderer_QueryVendorInfo
996 static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
998 InputPin* This = (InputPin*)iface;
999 IMediaEventSink* pEventSink;
1002 TRACE("(%p/%p)->()\n", This, iface);
1004 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
1007 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
1008 IMediaEventSink_Release(pEventSink);
1014 static const IPinVtbl VideoRenderer_InputPin_Vtbl =
1016 InputPin_QueryInterface,
1020 InputPin_ReceiveConnection,
1021 IPinImpl_Disconnect,
1022 IPinImpl_ConnectedTo,
1023 IPinImpl_ConnectionMediaType,
1024 IPinImpl_QueryPinInfo,
1025 IPinImpl_QueryDirection,
1027 IPinImpl_QueryAccept,
1028 IPinImpl_EnumMediaTypes,
1029 IPinImpl_QueryInternalConnections,
1030 VideoRenderer_InputPin_EndOfStream,
1031 InputPin_BeginFlush,
1036 /*** IUnknown methods ***/
1037 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
1040 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1042 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1044 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1047 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
1048 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1050 TRACE("(%p/%p)->()\n", This, iface);
1052 return VideoRenderer_AddRef((IBaseFilter*)This);
1055 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
1056 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1058 TRACE("(%p/%p)->()\n", This, iface);
1060 return VideoRenderer_Release((IBaseFilter*)This);
1063 /*** IDispatch methods ***/
1064 static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
1066 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1068 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1073 static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
1076 ITypeInfo**ppTInfo) {
1077 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1079 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1084 static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
1090 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1092 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1097 static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
1098 DISPID dispIdMember,
1102 DISPPARAMS*pDispParams,
1104 EXCEPINFO*pExepInfo,
1106 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1108 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);
1113 /*** IBasicVideo methods ***/
1114 static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
1115 REFTIME *pAvgTimePerFrame) {
1116 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1118 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
1123 static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
1125 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1127 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
1132 static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
1133 long *pBitErrorRate) {
1134 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1136 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
1141 static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
1142 long *pVideoWidth) {
1143 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1145 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
1147 *pVideoWidth = This->VideoWidth;
1152 static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
1153 long *pVideoHeight) {
1154 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1156 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
1158 *pVideoHeight = This->VideoHeight;
1163 static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
1165 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1167 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
1169 This->SourceRect.left = SourceLeft;
1174 static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
1175 long *pSourceLeft) {
1176 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1178 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
1180 *pSourceLeft = This->SourceRect.left;
1185 static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
1187 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1189 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
1191 This->SourceRect.right = This->SourceRect.left + SourceWidth;
1196 static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
1197 long *pSourceWidth) {
1198 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1200 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
1202 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
1207 static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
1209 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1211 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
1213 This->SourceRect.top = SourceTop;
1218 static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
1220 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1222 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
1224 *pSourceTop = This->SourceRect.top;
1229 static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
1230 long SourceHeight) {
1231 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1233 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
1235 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
1240 static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
1241 long *pSourceHeight) {
1242 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1244 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1246 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
1251 static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1252 long DestinationLeft) {
1253 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1255 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1257 This->DestRect.left = DestinationLeft;
1262 static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1263 long *pDestinationLeft) {
1264 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1266 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1268 *pDestinationLeft = This->DestRect.left;
1273 static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1274 long DestinationWidth) {
1275 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1277 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1279 This->DestRect.right = This->DestRect.left + DestinationWidth;
1284 static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1285 long *pDestinationWidth) {
1286 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1288 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1290 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
1295 static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1296 long DestinationTop) {
1297 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1299 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
1301 This->DestRect.top = DestinationTop;
1306 static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1307 long *pDestinationTop) {
1308 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1310 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1312 *pDestinationTop = This->DestRect.top;
1317 static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1318 long DestinationHeight) {
1319 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1321 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1323 This->DestRect.right = This->DestRect.left + DestinationHeight;
1328 static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1329 long *pDestinationHeight) {
1330 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1332 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1334 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
1339 static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1344 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1346 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1348 This->SourceRect.left = Left;
1349 This->SourceRect.top = Top;
1350 This->SourceRect.right = Left + Width;
1351 This->SourceRect.bottom = Top + Height;
1356 static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1361 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1363 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1365 *pLeft = This->SourceRect.left;
1366 *pTop = This->SourceRect.top;
1367 *pWidth = This->SourceRect.right - This->SourceRect.left;
1368 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1373 static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1374 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1376 TRACE("(%p/%p)->()\n", This, iface);
1378 This->SourceRect.left = 0;
1379 This->SourceRect.top = 0;
1380 This->SourceRect.right = This->VideoWidth;
1381 This->SourceRect.bottom = This->VideoHeight;
1386 static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1391 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1393 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1395 This->DestRect.left = Left;
1396 This->DestRect.top = Top;
1397 This->DestRect.right = Left + Width;
1398 This->DestRect.bottom = Top + Height;
1403 static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1408 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1410 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1412 *pLeft = This->DestRect.left;
1413 *pTop = This->DestRect.top;
1414 *pWidth = This->DestRect.right - This->DestRect.left;
1415 *pHeight = This->DestRect.bottom - This->DestRect.top;
1420 static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1421 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1424 TRACE("(%p/%p)->()\n", This, iface);
1426 if (!GetClientRect(This->hWnd, &rect))
1429 This->SourceRect.left = 0;
1430 This->SourceRect.top = 0;
1431 This->SourceRect.right = rect.right;
1432 This->SourceRect.bottom = rect.bottom;
1437 static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1440 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1442 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
1444 *pWidth = This->VideoWidth;
1445 *pHeight = This->VideoHeight;
1450 static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1455 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1457 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
1462 static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1465 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1466 BITMAPINFOHEADER *bmiHeader;
1468 AM_MEDIA_TYPE *amt = &This->pInputPin->pin.mtCurrent;
1471 EnterCriticalSection(&This->csFilter);
1473 if (!This->sample_held)
1475 LeaveCriticalSection(&This->csFilter);
1476 return (This->state == State_Paused ? E_UNEXPECTED : VFW_E_NOT_PAUSED);
1479 FIXME("(%p/%p)->(%p, %p): partial stub\n", This, iface, pBufferSize, pDIBImage);
1481 if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo))
1483 bmiHeader = &((VIDEOINFOHEADER *)amt->pbFormat)->bmiHeader;
1485 else if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo2))
1487 bmiHeader = &((VIDEOINFOHEADER2 *)amt->pbFormat)->bmiHeader;
1491 FIXME("Unknown type %s\n", debugstr_guid(&amt->subtype));
1492 LeaveCriticalSection(&This->csFilter);
1493 return VFW_E_RUNTIME_ERROR;
1496 needed_size = bmiHeader->biSize;
1497 needed_size += IMediaSample_GetActualDataLength(This->sample_held);
1501 *pBufferSize = needed_size;
1502 LeaveCriticalSection(&This->csFilter);
1506 if (needed_size < *pBufferSize)
1508 ERR("Buffer too small %u/%lu\n", needed_size, *pBufferSize);
1509 LeaveCriticalSection(&This->csFilter);
1512 *pBufferSize = needed_size;
1514 memcpy(pDIBImage, bmiHeader, bmiHeader->biSize);
1515 IMediaSample_GetPointer(This->sample_held, (BYTE **)&ptr);
1516 memcpy((char *)pDIBImage + bmiHeader->biSize, ptr, IMediaSample_GetActualDataLength(This->sample_held));
1518 LeaveCriticalSection(&This->csFilter);
1523 static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1524 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1526 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1531 static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1532 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1534 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
1540 static const IBasicVideoVtbl IBasicVideo_VTable =
1542 Basicvideo_QueryInterface,
1545 Basicvideo_GetTypeInfoCount,
1546 Basicvideo_GetTypeInfo,
1547 Basicvideo_GetIDsOfNames,
1549 Basicvideo_get_AvgTimePerFrame,
1550 Basicvideo_get_BitRate,
1551 Basicvideo_get_BitErrorRate,
1552 Basicvideo_get_VideoWidth,
1553 Basicvideo_get_VideoHeight,
1554 Basicvideo_put_SourceLeft,
1555 Basicvideo_get_SourceLeft,
1556 Basicvideo_put_SourceWidth,
1557 Basicvideo_get_SourceWidth,
1558 Basicvideo_put_SourceTop,
1559 Basicvideo_get_SourceTop,
1560 Basicvideo_put_SourceHeight,
1561 Basicvideo_get_SourceHeight,
1562 Basicvideo_put_DestinationLeft,
1563 Basicvideo_get_DestinationLeft,
1564 Basicvideo_put_DestinationWidth,
1565 Basicvideo_get_DestinationWidth,
1566 Basicvideo_put_DestinationTop,
1567 Basicvideo_get_DestinationTop,
1568 Basicvideo_put_DestinationHeight,
1569 Basicvideo_get_DestinationHeight,
1570 Basicvideo_SetSourcePosition,
1571 Basicvideo_GetSourcePosition,
1572 Basicvideo_SetDefaultSourcePosition,
1573 Basicvideo_SetDestinationPosition,
1574 Basicvideo_GetDestinationPosition,
1575 Basicvideo_SetDefaultDestinationPosition,
1576 Basicvideo_GetVideoSize,
1577 Basicvideo_GetVideoPaletteEntries,
1578 Basicvideo_GetCurrentImage,
1579 Basicvideo_IsUsingDefaultSource,
1580 Basicvideo_IsUsingDefaultDestination
1584 /*** IUnknown methods ***/
1585 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1588 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1590 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1592 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1595 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1596 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1598 TRACE("(%p/%p)->()\n", This, iface);
1600 return VideoRenderer_AddRef((IBaseFilter*)This);
1603 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1604 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1606 TRACE("(%p/%p)->()\n", This, iface);
1608 return VideoRenderer_Release((IBaseFilter*)This);
1611 /*** IDispatch methods ***/
1612 static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1614 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1616 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
1621 static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1624 ITypeInfo**ppTInfo) {
1625 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1627 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
1632 static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1638 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1640 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
1645 static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1646 DISPID dispIdMember,
1650 DISPPARAMS*pDispParams,
1652 EXCEPINFO*pExepInfo,
1654 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1656 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);
1661 /*** IVideoWindow methods ***/
1662 static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1664 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1666 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1668 if (!SetWindowTextW(This->hWnd, strCaption))
1674 static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1676 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1678 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1680 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
1685 static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1687 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1690 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1692 TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
1694 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1695 return E_INVALIDARG;
1697 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
1702 static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1703 long *WindowStyle) {
1704 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1706 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1708 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
1713 static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1714 long WindowStyleEx) {
1715 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1717 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1719 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1720 return E_INVALIDARG;
1722 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1728 static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1729 long *WindowStyleEx) {
1730 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1732 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1734 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
1739 static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1741 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1743 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1745 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
1750 static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1752 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1754 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1756 *AutoShow = This->AutoShow;
1761 static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1763 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1765 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
1770 static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1771 long *WindowState) {
1772 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1774 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
1779 static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1780 long BackgroundPalette) {
1781 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1783 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
1788 static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1789 long *pBackgroundPalette) {
1790 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1792 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
1797 static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1799 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1801 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1803 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
1808 static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1810 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1812 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1814 *pVisible = IsWindowVisible(This->hWnd);
1819 static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1821 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1823 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1825 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1828 This->WindowPos.left = Left;
1833 static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1835 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1837 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1839 *pLeft = This->WindowPos.left;
1844 static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1846 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1848 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1850 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1853 This->WindowPos.right = This->WindowPos.left + Width;
1858 static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1860 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1862 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1864 *pWidth = This->WindowPos.right - This->WindowPos.left;
1869 static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1871 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1873 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1875 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1878 This->WindowPos.top = Top;
1883 static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1885 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1887 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1889 *pTop = This->WindowPos.top;
1894 static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1896 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1898 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1900 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1903 This->WindowPos.bottom = This->WindowPos.top + Height;
1908 static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1910 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1912 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1914 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
1919 static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1921 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1923 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1925 SetParent(This->hWnd, (HWND)Owner);
1930 static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1932 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1934 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
1936 *(HWND*)Owner = GetParent(This->hWnd);
1941 static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1943 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1945 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
1947 This->hWndMsgDrain = (HWND)Drain;
1952 static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1954 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1956 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1958 *Drain = (OAHWND)This->hWndMsgDrain;
1963 static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1965 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1967 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
1972 static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1974 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1976 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
1981 static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1982 long *FullScreenMode) {
1983 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1985 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
1990 static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1991 long FullScreenMode) {
1992 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1994 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
1999 static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
2001 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2006 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
2008 if ((Focus != FALSE) && (Focus != TRUE))
2009 return E_INVALIDARG;
2011 hr = IPin_ConnectedTo((IPin *)This->pInputPin, &pPin);
2012 if ((hr != S_OK) || !pPin)
2013 return VFW_E_NOT_CONNECTED;
2016 ret = SetForegroundWindow(This->hWnd);
2018 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2026 static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
2031 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2033 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
2035 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
2041 static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
2046 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2048 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
2050 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
2053 This->WindowPos.left = Left;
2054 This->WindowPos.top = Top;
2055 This->WindowPos.right = Left + Width;
2056 This->WindowPos.bottom = Top + Height;
2061 static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
2066 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2068 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2070 *pLeft = This->WindowPos.left;
2071 *pTop = This->WindowPos.top;
2072 *pWidth = This->WindowPos.right - This->WindowPos.left;
2073 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
2078 static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
2081 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2083 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
2085 *pWidth = This->VideoWidth;
2086 *pHeight = This->VideoHeight;
2091 static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
2094 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2096 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
2098 *pWidth = This->VideoWidth;
2099 *pHeight = This->VideoHeight;
2104 static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
2109 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2111 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
2116 static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
2118 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2120 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
2125 static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
2126 long *CursorHidden) {
2127 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2129 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
2134 static const IVideoWindowVtbl IVideoWindow_VTable =
2136 Videowindow_QueryInterface,
2138 Videowindow_Release,
2139 Videowindow_GetTypeInfoCount,
2140 Videowindow_GetTypeInfo,
2141 Videowindow_GetIDsOfNames,
2143 Videowindow_put_Caption,
2144 Videowindow_get_Caption,
2145 Videowindow_put_WindowStyle,
2146 Videowindow_get_WindowStyle,
2147 Videowindow_put_WindowStyleEx,
2148 Videowindow_get_WindowStyleEx,
2149 Videowindow_put_AutoShow,
2150 Videowindow_get_AutoShow,
2151 Videowindow_put_WindowState,
2152 Videowindow_get_WindowState,
2153 Videowindow_put_BackgroundPalette,
2154 Videowindow_get_BackgroundPalette,
2155 Videowindow_put_Visible,
2156 Videowindow_get_Visible,
2157 Videowindow_put_Left,
2158 Videowindow_get_Left,
2159 Videowindow_put_Width,
2160 Videowindow_get_Width,
2161 Videowindow_put_Top,
2162 Videowindow_get_Top,
2163 Videowindow_put_Height,
2164 Videowindow_get_Height,
2165 Videowindow_put_Owner,
2166 Videowindow_get_Owner,
2167 Videowindow_put_MessageDrain,
2168 Videowindow_get_MessageDrain,
2169 Videowindow_get_BorderColor,
2170 Videowindow_put_BorderColor,
2171 Videowindow_get_FullScreenMode,
2172 Videowindow_put_FullScreenMode,
2173 Videowindow_SetWindowForeground,
2174 Videowindow_NotifyOwnerMessage,
2175 Videowindow_SetWindowPosition,
2176 Videowindow_GetWindowPosition,
2177 Videowindow_GetMinIdealImageSize,
2178 Videowindow_GetMaxIdealImageSize,
2179 Videowindow_GetRestorePosition,
2180 Videowindow_HideCursor,
2181 Videowindow_IsCursorHidden