quartz: Add VMRSurfaceAllocatorNotify9 to VMR9.
[wine/multimedia.git] / dlls / quartz / vmr9.c
blob2f490e57a0c1c741b1db040be5b12a6f8058e87a
1 /*
2 * Video Mixing Renderer for dx9
4 * Copyright 2004 Christian Costa
5 * Copyright 2008 Maarten Lankhorst
6 * Copyright 2012 Aric Stewart
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
25 #define NONAMELESSSTRUCT
26 #define NONAMELESSUNION
27 #include "quartz_private.h"
29 #include "uuids.h"
30 #include "vfwmsgs.h"
31 #include "amvideo.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "dshow.h"
35 #include "evcode.h"
36 #include "strmif.h"
37 #include "ddraw.h"
38 #include "dvdmedia.h"
39 #include "d3d9.h"
40 #include "vmr9.h"
41 #include "pin.h"
43 #include "wine/unicode.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
48 typedef struct
50 BaseRenderer renderer;
51 BaseControlWindow baseControlWindow;
52 BaseControlVideo baseControlVideo;
54 IUnknown IUnknown_inner;
55 IAMFilterMiscFlags IAMFilterMiscFlags_iface;
56 IVMRFilterConfig9 IVMRFilterConfig9_iface;
57 IVMRWindowlessControl9 IVMRWindowlessControl9_iface;
58 IVMRSurfaceAllocatorNotify9 IVMRSurfaceAllocatorNotify9_iface;
60 IVMRSurfaceAllocatorEx9 *allocator;
61 IVMRImagePresenter9 *presenter;
62 BOOL allocator_is_ex;
64 VMR9Mode mode;
65 BITMAPINFOHEADER bmiheader;
66 IUnknown * outer_unk;
67 BOOL bUnkOuterValid;
68 BOOL bAggregatable;
70 DWORD_PTR cookie;
72 /* for Windowless Mode */
73 HWND hWndClippingWindow;
75 RECT source_rect;
76 RECT target_rect;
77 LONG VideoWidth;
78 LONG VideoHeight;
79 } VMR9Impl;
81 static inline VMR9Impl *impl_from_inner_IUnknown(IUnknown *iface)
83 return CONTAINING_RECORD(iface, VMR9Impl, IUnknown_inner);
86 static inline VMR9Impl *impl_from_BaseWindow( BaseWindow *wnd )
88 return CONTAINING_RECORD(wnd, VMR9Impl, baseControlWindow.baseWindow);
91 static inline VMR9Impl *impl_from_IVideoWindow( IVideoWindow *iface)
93 return CONTAINING_RECORD(iface, VMR9Impl, baseControlWindow.IVideoWindow_iface);
96 static inline VMR9Impl *impl_from_BaseControlVideo( BaseControlVideo *cvid )
98 return CONTAINING_RECORD(cvid, VMR9Impl, baseControlVideo);
101 static inline VMR9Impl *impl_from_IBasicVideo( IBasicVideo *iface)
103 return CONTAINING_RECORD(iface, VMR9Impl, baseControlVideo.IBasicVideo_iface);
106 static inline VMR9Impl *impl_from_IAMFilterMiscFlags( IAMFilterMiscFlags *iface)
108 return CONTAINING_RECORD(iface, VMR9Impl, IAMFilterMiscFlags_iface);
111 static inline VMR9Impl *impl_from_IVMRFilterConfig9( IVMRFilterConfig9 *iface)
113 return CONTAINING_RECORD(iface, VMR9Impl, IVMRFilterConfig9_iface);
116 static inline VMR9Impl *impl_from_IVMRWindowlessControl9( IVMRWindowlessControl9 *iface)
118 return CONTAINING_RECORD(iface, VMR9Impl, IVMRWindowlessControl9_iface);
121 static inline VMR9Impl *impl_from_IVMRSurfaceAllocatorNotify9( IVMRSurfaceAllocatorNotify9 *iface)
123 return CONTAINING_RECORD(iface, VMR9Impl, IVMRSurfaceAllocatorNotify9_iface);
126 static HRESULT WINAPI VMR9_DoRenderSample(BaseRenderer *iface, IMediaSample * pSample)
128 VMR9Impl *This = (VMR9Impl *)iface;
129 LPBYTE pbSrcStream = NULL;
130 REFERENCE_TIME tStart, tStop;
131 VMR9PresentationInfo info;
132 HRESULT hr;
134 TRACE("%p %p\n", iface, pSample);
136 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
137 if (FAILED(hr))
138 info.dwFlags = VMR9Sample_SrcDstRectsValid;
139 else
140 info.dwFlags = VMR9Sample_SrcDstRectsValid | VMR9Sample_TimeValid;
142 if (IMediaSample_IsDiscontinuity(pSample) == S_OK)
143 info.dwFlags |= VMR9Sample_Discontinuity;
145 if (IMediaSample_IsPreroll(pSample) == S_OK)
146 info.dwFlags |= VMR9Sample_Preroll;
148 if (IMediaSample_IsSyncPoint(pSample) == S_OK)
149 info.dwFlags |= VMR9Sample_SyncPoint;
151 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
152 if (FAILED(hr))
154 ERR("Cannot get pointer to sample data (%x)\n", hr);
155 return hr;
158 info.rtStart = tStart;
159 info.rtEnd = tStop;
160 info.szAspectRatio.cx = This->bmiheader.biWidth;
161 info.szAspectRatio.cy = This->bmiheader.biHeight;
163 return hr;
166 static HRESULT WINAPI VMR9_CheckMediaType(BaseRenderer *iface, const AM_MEDIA_TYPE * pmt)
168 VMR9Impl *This = (VMR9Impl*)iface;
170 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) || !pmt->pbFormat)
171 return S_FALSE;
173 /* Ignore subtype, test for bicompression instead */
174 if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
176 VIDEOINFOHEADER *format = (VIDEOINFOHEADER *)pmt->pbFormat;
178 This->bmiheader = format->bmiHeader;
179 TRACE("Resolution: %dx%d\n", format->bmiHeader.biWidth, format->bmiHeader.biHeight);
180 This->source_rect.right = This->VideoWidth = format->bmiHeader.biWidth;
181 This->source_rect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
182 This->source_rect.top = This->source_rect.left = 0;
184 else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
186 VIDEOINFOHEADER2 *format = (VIDEOINFOHEADER2 *)pmt->pbFormat;
188 This->bmiheader = format->bmiHeader;
190 TRACE("Resolution: %dx%d\n", format->bmiHeader.biWidth, format->bmiHeader.biHeight);
191 This->source_rect.right = This->VideoWidth = format->bmiHeader.biWidth;
192 This->source_rect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
193 This->source_rect.top = This->source_rect.left = 0;
195 else
197 ERR("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
198 return S_FALSE;
200 if (This->bmiheader.biCompression)
201 return S_FALSE;
202 return S_OK;
205 HRESULT WINAPI VMR9_ShouldDrawSampleNow(BaseRenderer *This, IMediaSample *pSample, REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime)
207 /* Preroll means the sample isn't shown, this is used for key frames and things like that */
208 if (IMediaSample_IsPreroll(pSample) == S_OK)
209 return E_FAIL;
210 return S_FALSE;
213 static const BaseRendererFuncTable BaseFuncTable = {
214 VMR9_CheckMediaType,
215 VMR9_DoRenderSample,
216 /**/
217 NULL,
218 NULL,
219 NULL,
220 NULL,
221 NULL,
222 NULL,
223 NULL,
224 NULL,
225 VMR9_ShouldDrawSampleNow,
226 NULL,
227 /**/
228 NULL,
229 NULL,
230 NULL,
231 NULL,
232 NULL,
235 static LPWSTR WINAPI VMR9_GetClassWindowStyles(BaseWindow *This, DWORD *pClassStyles, DWORD *pWindowStyles, DWORD *pWindowStylesEx)
237 static WCHAR classnameW[] = { 'I','V','M','R','9',' ','C','l','a','s','s', 0 };
239 *pClassStyles = 0;
240 *pWindowStyles = WS_SIZEBOX;
241 *pWindowStylesEx = 0;
243 return classnameW;
246 static RECT WINAPI VMR9_GetDefaultRect(BaseWindow *This)
248 VMR9Impl* pVMR9 = impl_from_BaseWindow(This);
249 static RECT defRect;
251 defRect.left = defRect.top = 0;
252 defRect.right = pVMR9->VideoWidth;
253 defRect.bottom = pVMR9->VideoHeight;
255 return defRect;
258 static BOOL WINAPI VMR9_OnSize(BaseWindow *This, LONG Width, LONG Height)
260 VMR9Impl* pVMR9 = impl_from_BaseWindow(This);
262 TRACE("WM_SIZE %d %d\n", Width, Height);
263 GetClientRect(This->hWnd, &pVMR9->target_rect);
264 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
265 pVMR9->target_rect.left,
266 pVMR9->target_rect.top,
267 pVMR9->target_rect.right - pVMR9->target_rect.left,
268 pVMR9->target_rect.bottom - pVMR9->target_rect.top);
269 return BaseWindowImpl_OnSize(This, Width, Height);
272 static const BaseWindowFuncTable renderer_BaseWindowFuncTable = {
273 VMR9_GetClassWindowStyles,
274 VMR9_GetDefaultRect,
275 NULL,
276 BaseControlWindowImpl_PossiblyEatMessage,
277 VMR9_OnSize,
280 HRESULT WINAPI VMR9_GetSourceRect(BaseControlVideo* This, RECT *pSourceRect)
282 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
283 CopyRect(pSourceRect,&pVMR9->source_rect);
284 return S_OK;
287 HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage)
289 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
290 BITMAPINFOHEADER *bmiHeader;
291 LONG needed_size;
292 AM_MEDIA_TYPE *amt = &pVMR9->renderer.pInputPin->pin.mtCurrent;
293 char *ptr;
295 FIXME("(%p/%p)->(%p, %p): partial stub\n", pVMR9, This, pBufferSize, pDIBImage);
297 EnterCriticalSection(&pVMR9->renderer.filter.csFilter);
299 if (!pVMR9->renderer.pMediaSample)
301 LeaveCriticalSection(&pVMR9->renderer.filter.csFilter);
302 return (pVMR9->renderer.filter.state == State_Paused ? E_UNEXPECTED : VFW_E_NOT_PAUSED);
305 if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo))
307 bmiHeader = &((VIDEOINFOHEADER *)amt->pbFormat)->bmiHeader;
309 else if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo2))
311 bmiHeader = &((VIDEOINFOHEADER2 *)amt->pbFormat)->bmiHeader;
313 else
315 FIXME("Unknown type %s\n", debugstr_guid(&amt->subtype));
316 LeaveCriticalSection(&pVMR9->renderer.filter.csFilter);
317 return VFW_E_RUNTIME_ERROR;
320 needed_size = bmiHeader->biSize;
321 needed_size += IMediaSample_GetActualDataLength(pVMR9->renderer.pMediaSample);
323 if (!pDIBImage)
325 *pBufferSize = needed_size;
326 LeaveCriticalSection(&pVMR9->renderer.filter.csFilter);
327 return S_OK;
330 if (needed_size < *pBufferSize)
332 ERR("Buffer too small %u/%u\n", needed_size, *pBufferSize);
333 LeaveCriticalSection(&pVMR9->renderer.filter.csFilter);
334 return E_FAIL;
336 *pBufferSize = needed_size;
338 memcpy(pDIBImage, bmiHeader, bmiHeader->biSize);
339 IMediaSample_GetPointer(pVMR9->renderer.pMediaSample, (BYTE **)&ptr);
340 memcpy((char *)pDIBImage + bmiHeader->biSize, ptr, IMediaSample_GetActualDataLength(pVMR9->renderer.pMediaSample));
342 LeaveCriticalSection(&pVMR9->renderer.filter.csFilter);
343 return S_OK;
346 HRESULT WINAPI VMR9_GetTargetRect(BaseControlVideo* This, RECT *pTargetRect)
348 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
349 CopyRect(pTargetRect,&pVMR9->target_rect);
350 return S_OK;
353 VIDEOINFOHEADER* WINAPI VMR9_GetVideoFormat(BaseControlVideo* This)
355 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
356 AM_MEDIA_TYPE *pmt;
358 TRACE("(%p/%p)\n", pVMR9, This);
360 pmt = &pVMR9->renderer.pInputPin->pin.mtCurrent;
361 if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) {
362 return (VIDEOINFOHEADER*)pmt->pbFormat;
363 } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) {
364 static VIDEOINFOHEADER vih;
365 VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
366 memcpy(&vih,vih2,sizeof(VIDEOINFOHEADER));
367 memcpy(&vih.bmiHeader, &vih2->bmiHeader, sizeof(BITMAPINFOHEADER));
368 return &vih;
369 } else {
370 ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt->formattype));
371 return NULL;
375 HRESULT WINAPI VMR9_IsDefaultSourceRect(BaseControlVideo* This)
377 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
378 FIXME("(%p/%p)->(): stub !!!\n", pVMR9, This);
380 return S_OK;
383 HRESULT WINAPI VMR9_IsDefaultTargetRect(BaseControlVideo* This)
385 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
386 FIXME("(%p/%p)->(): stub !!!\n", pVMR9, This);
388 return S_OK;
391 HRESULT WINAPI VMR9_SetDefaultSourceRect(BaseControlVideo* This)
393 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
395 pVMR9->source_rect.left = 0;
396 pVMR9->source_rect.top = 0;
397 pVMR9->source_rect.right = pVMR9->VideoWidth;
398 pVMR9->source_rect.bottom = pVMR9->VideoHeight;
400 return S_OK;
403 HRESULT WINAPI VMR9_SetDefaultTargetRect(BaseControlVideo* This)
405 RECT rect;
406 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
408 if (!GetClientRect(pVMR9->baseControlWindow.baseWindow.hWnd, &rect))
409 return E_FAIL;
411 pVMR9->target_rect.left = 0;
412 pVMR9->target_rect.top = 0;
413 pVMR9->target_rect.right = rect.right;
414 pVMR9->target_rect.bottom = rect.bottom;
416 return S_OK;
419 HRESULT WINAPI VMR9_SetSourceRect(BaseControlVideo* This, RECT *pSourceRect)
421 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
422 CopyRect(&pVMR9->source_rect,pSourceRect);
423 return S_OK;
426 HRESULT WINAPI VMR9_SetTargetRect(BaseControlVideo* This, RECT *pTargetRect)
428 VMR9Impl* pVMR9 = impl_from_BaseControlVideo(This);
429 CopyRect(&pVMR9->target_rect,pTargetRect);
430 return S_OK;
433 static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = {
434 VMR9_GetSourceRect,
435 VMR9_GetStaticImage,
436 VMR9_GetTargetRect,
437 VMR9_GetVideoFormat,
438 VMR9_IsDefaultSourceRect,
439 VMR9_IsDefaultTargetRect,
440 VMR9_SetDefaultSourceRect,
441 VMR9_SetDefaultTargetRect,
442 VMR9_SetSourceRect,
443 VMR9_SetTargetRect
446 static HRESULT WINAPI VMR9Inner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID * ppv)
448 VMR9Impl *This = impl_from_inner_IUnknown(iface);
449 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
451 if (This->bAggregatable)
452 This->bUnkOuterValid = TRUE;
454 *ppv = NULL;
456 if (IsEqualIID(riid, &IID_IUnknown))
457 *ppv = &This->IUnknown_inner;
458 else if (IsEqualIID(riid, &IID_IVideoWindow))
459 *ppv = &This->baseControlWindow.IVideoWindow_iface;
460 else if (IsEqualIID(riid, &IID_IBasicVideo))
461 *ppv = &This->baseControlVideo.IBasicVideo_iface;
462 else if (IsEqualIID(riid, &IID_IAMFilterMiscFlags))
463 *ppv = &This->IAMFilterMiscFlags_iface;
464 else if (IsEqualIID(riid, &IID_IVMRFilterConfig9))
465 *ppv = &This->IVMRFilterConfig9_iface;
466 else if (IsEqualIID(riid, &IID_IVMRWindowlessControl9) && This->mode == VMR9Mode_Windowless)
467 *ppv = &This->IVMRWindowlessControl9_iface;
468 else if (IsEqualIID(riid, &IID_IVMRSurfaceAllocatorNotify9) && This->mode == VMR9Mode_Renderless)
469 *ppv = &This->IVMRSurfaceAllocatorNotify9_iface;
470 else
472 HRESULT hr;
473 hr = BaseRendererImpl_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
474 if (SUCCEEDED(hr))
475 return hr;
478 if (*ppv)
480 IUnknown_AddRef((IUnknown *)(*ppv));
481 return S_OK;
484 else if (IsEqualIID(riid, &IID_IBasicVideo2))
485 FIXME("No interface for IID_IBasicVideo2\n");
486 else if (IsEqualIID(riid, &IID_IVMRWindowlessControl9))
488 else if (IsEqualIID(riid, &IID_IVMRSurfaceAllocatorNotify9))
490 else if (IsEqualIID(riid, &IID_IMediaPosition))
491 FIXME("No interface for IID_IMediaPosition\n");
492 else if (IsEqualIID(riid, &IID_IQualProp))
493 FIXME("No interface for IID_IQualProp\n");
494 else if (IsEqualIID(riid, &IID_IVMRAspectRatioControl9))
495 FIXME("No interface for IID_IVMRAspectRatioControl9\n");
496 else if (IsEqualIID(riid, &IID_IVMRDeinterlaceControl9))
497 FIXME("No interface for IID_IVMRDeinterlaceControl9\n");
498 else if (IsEqualIID(riid, &IID_IVMRMixerBitmap9))
499 FIXME("No interface for IID_IVMRMixerBitmap9\n");
500 else if (IsEqualIID(riid, &IID_IVMRMonitorConfig9))
501 FIXME("No interface for IID_IVMRMonitorConfig9\n");
502 else if (IsEqualIID(riid, &IID_IVMRMixerControl9))
503 FIXME("No interface for IID_IVMRMixerControl9\n");
504 else
505 FIXME("No interface for %s\n", debugstr_guid(riid));
507 return E_NOINTERFACE;
510 static ULONG WINAPI VMR9Inner_AddRef(IUnknown * iface)
512 VMR9Impl *This = impl_from_inner_IUnknown(iface);
513 ULONG refCount = BaseFilterImpl_AddRef(&This->renderer.filter.IBaseFilter_iface);
515 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
517 return refCount;
520 static ULONG WINAPI VMR9Inner_Release(IUnknown * iface)
522 VMR9Impl *This = impl_from_inner_IUnknown(iface);
523 ULONG refCount = BaseRendererImpl_Release(&This->renderer.filter.IBaseFilter_iface);
525 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
527 if (!refCount)
529 TRACE("Destroying\n");
531 if (This->allocator)
532 IVMRSurfaceAllocator9_Release(This->allocator);
533 if (This->presenter)
534 IVMRImagePresenter9_Release(This->presenter);
536 CoTaskMemFree(This);
538 return refCount;
541 static const IUnknownVtbl IInner_VTable =
543 VMR9Inner_QueryInterface,
544 VMR9Inner_AddRef,
545 VMR9Inner_Release
548 static HRESULT WINAPI VMR9_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
550 VMR9Impl *This = (VMR9Impl *)iface;
552 if (This->bAggregatable)
553 This->bUnkOuterValid = TRUE;
555 if (This->outer_unk)
557 if (This->bAggregatable)
558 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
560 if (IsEqualIID(riid, &IID_IUnknown))
562 HRESULT hr;
564 IUnknown_AddRef(&This->IUnknown_inner);
565 hr = IUnknown_QueryInterface(&This->IUnknown_inner, riid, ppv);
566 IUnknown_Release(&This->IUnknown_inner);
567 This->bAggregatable = TRUE;
568 return hr;
571 *ppv = NULL;
572 return E_NOINTERFACE;
575 return IUnknown_QueryInterface(&This->IUnknown_inner, riid, ppv);
578 static ULONG WINAPI VMR9_AddRef(IBaseFilter * iface)
580 VMR9Impl *This = (VMR9Impl *)iface;
581 LONG ret;
583 if (This->outer_unk && This->bUnkOuterValid)
584 ret = IUnknown_AddRef(This->outer_unk);
585 else
586 ret = IUnknown_AddRef(&This->IUnknown_inner);
588 TRACE("(%p)->AddRef from %d\n", iface, ret - 1);
590 return ret;
593 static ULONG WINAPI VMR9_Release(IBaseFilter * iface)
595 VMR9Impl *This = (VMR9Impl *)iface;
596 LONG ret;
598 if (This->outer_unk && This->bUnkOuterValid)
599 ret = IUnknown_Release(This->outer_unk);
600 else
601 ret = IUnknown_Release(&This->IUnknown_inner);
603 TRACE("(%p)->Release from %d\n", iface, ret + 1);
605 if (ret)
606 return ret;
607 return 0;
610 static const IBaseFilterVtbl VMR9_Vtbl =
612 VMR9_QueryInterface,
613 VMR9_AddRef,
614 VMR9_Release,
615 BaseFilterImpl_GetClassID,
616 BaseRendererImpl_Stop,
617 BaseRendererImpl_Pause,
618 BaseRendererImpl_Run,
619 BaseRendererImpl_GetState,
620 BaseRendererImpl_SetSyncSource,
621 BaseFilterImpl_GetSyncSource,
622 BaseFilterImpl_EnumPins,
623 BaseRendererImpl_FindPin,
624 BaseFilterImpl_QueryFilterInfo,
625 BaseFilterImpl_JoinFilterGraph,
626 BaseFilterImpl_QueryVendorInfo
629 /*** IUnknown methods ***/
630 static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface, REFIID riid, LPVOID*ppvObj)
632 VMR9Impl *This = impl_from_IVideoWindow(iface);
634 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
636 return VMR9_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppvObj);
639 static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface)
641 VMR9Impl *This = impl_from_IVideoWindow(iface);
643 TRACE("(%p/%p)->()\n", This, iface);
645 return VMR9_AddRef(&This->renderer.filter.IBaseFilter_iface);
648 static ULONG WINAPI Videowindow_Release(IVideoWindow *iface)
650 VMR9Impl *This = impl_from_IVideoWindow(iface);
652 TRACE("(%p/%p)->()\n", This, iface);
654 return VMR9_Release(&This->renderer.filter.IBaseFilter_iface);
657 static const IVideoWindowVtbl IVideoWindow_VTable =
659 Videowindow_QueryInterface,
660 Videowindow_AddRef,
661 Videowindow_Release,
662 BaseControlWindowImpl_GetTypeInfoCount,
663 BaseControlWindowImpl_GetTypeInfo,
664 BaseControlWindowImpl_GetIDsOfNames,
665 BaseControlWindowImpl_Invoke,
666 BaseControlWindowImpl_put_Caption,
667 BaseControlWindowImpl_get_Caption,
668 BaseControlWindowImpl_put_WindowStyle,
669 BaseControlWindowImpl_get_WindowStyle,
670 BaseControlWindowImpl_put_WindowStyleEx,
671 BaseControlWindowImpl_get_WindowStyleEx,
672 BaseControlWindowImpl_put_AutoShow,
673 BaseControlWindowImpl_get_AutoShow,
674 BaseControlWindowImpl_put_WindowState,
675 BaseControlWindowImpl_get_WindowState,
676 BaseControlWindowImpl_put_BackgroundPalette,
677 BaseControlWindowImpl_get_BackgroundPalette,
678 BaseControlWindowImpl_put_Visible,
679 BaseControlWindowImpl_get_Visible,
680 BaseControlWindowImpl_put_Left,
681 BaseControlWindowImpl_get_Left,
682 BaseControlWindowImpl_put_Width,
683 BaseControlWindowImpl_get_Width,
684 BaseControlWindowImpl_put_Top,
685 BaseControlWindowImpl_get_Top,
686 BaseControlWindowImpl_put_Height,
687 BaseControlWindowImpl_get_Height,
688 BaseControlWindowImpl_put_Owner,
689 BaseControlWindowImpl_get_Owner,
690 BaseControlWindowImpl_put_MessageDrain,
691 BaseControlWindowImpl_get_MessageDrain,
692 BaseControlWindowImpl_get_BorderColor,
693 BaseControlWindowImpl_put_BorderColor,
694 BaseControlWindowImpl_get_FullScreenMode,
695 BaseControlWindowImpl_put_FullScreenMode,
696 BaseControlWindowImpl_SetWindowForeground,
697 BaseControlWindowImpl_NotifyOwnerMessage,
698 BaseControlWindowImpl_SetWindowPosition,
699 BaseControlWindowImpl_GetWindowPosition,
700 BaseControlWindowImpl_GetMinIdealImageSize,
701 BaseControlWindowImpl_GetMaxIdealImageSize,
702 BaseControlWindowImpl_GetRestorePosition,
703 BaseControlWindowImpl_HideCursor,
704 BaseControlWindowImpl_IsCursorHidden
707 /*** IUnknown methods ***/
708 static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface, REFIID riid, LPVOID * ppvObj)
710 VMR9Impl *This = impl_from_IBasicVideo(iface);
712 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
714 return VMR9_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppvObj);
717 static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface)
719 VMR9Impl *This = impl_from_IBasicVideo(iface);
721 TRACE("(%p/%p)->()\n", This, iface);
723 return VMR9_AddRef(&This->renderer.filter.IBaseFilter_iface);
726 static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface)
728 VMR9Impl *This = impl_from_IBasicVideo(iface);
730 TRACE("(%p/%p)->()\n", This, iface);
732 return VMR9_Release(&This->renderer.filter.IBaseFilter_iface);
735 static const IBasicVideoVtbl IBasicVideo_VTable =
737 Basicvideo_QueryInterface,
738 Basicvideo_AddRef,
739 Basicvideo_Release,
740 BaseControlVideoImpl_GetTypeInfoCount,
741 BaseControlVideoImpl_GetTypeInfo,
742 BaseControlVideoImpl_GetIDsOfNames,
743 BaseControlVideoImpl_Invoke,
744 BaseControlVideoImpl_get_AvgTimePerFrame,
745 BaseControlVideoImpl_get_BitRate,
746 BaseControlVideoImpl_get_BitErrorRate,
747 BaseControlVideoImpl_get_VideoWidth,
748 BaseControlVideoImpl_get_VideoHeight,
749 BaseControlVideoImpl_put_SourceLeft,
750 BaseControlVideoImpl_get_SourceLeft,
751 BaseControlVideoImpl_put_SourceWidth,
752 BaseControlVideoImpl_get_SourceWidth,
753 BaseControlVideoImpl_put_SourceTop,
754 BaseControlVideoImpl_get_SourceTop,
755 BaseControlVideoImpl_put_SourceHeight,
756 BaseControlVideoImpl_get_SourceHeight,
757 BaseControlVideoImpl_put_DestinationLeft,
758 BaseControlVideoImpl_get_DestinationLeft,
759 BaseControlVideoImpl_put_DestinationWidth,
760 BaseControlVideoImpl_get_DestinationWidth,
761 BaseControlVideoImpl_put_DestinationTop,
762 BaseControlVideoImpl_get_DestinationTop,
763 BaseControlVideoImpl_put_DestinationHeight,
764 BaseControlVideoImpl_get_DestinationHeight,
765 BaseControlVideoImpl_SetSourcePosition,
766 BaseControlVideoImpl_GetSourcePosition,
767 BaseControlVideoImpl_SetDefaultSourcePosition,
768 BaseControlVideoImpl_SetDestinationPosition,
769 BaseControlVideoImpl_GetDestinationPosition,
770 BaseControlVideoImpl_SetDefaultDestinationPosition,
771 BaseControlVideoImpl_GetVideoSize,
772 BaseControlVideoImpl_GetVideoPaletteEntries,
773 BaseControlVideoImpl_GetCurrentImage,
774 BaseControlVideoImpl_IsUsingDefaultSource,
775 BaseControlVideoImpl_IsUsingDefaultDestination
778 static HRESULT WINAPI AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags *iface, REFIID riid, void **ppv) {
779 VMR9Impl *This = impl_from_IAMFilterMiscFlags(iface);
780 return VMR9_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
783 static ULONG WINAPI AMFilterMiscFlags_AddRef(IAMFilterMiscFlags *iface) {
784 VMR9Impl *This = impl_from_IAMFilterMiscFlags(iface);
785 return VMR9_AddRef(&This->renderer.filter.IBaseFilter_iface);
788 static ULONG WINAPI AMFilterMiscFlags_Release(IAMFilterMiscFlags *iface) {
789 VMR9Impl *This = impl_from_IAMFilterMiscFlags(iface);
790 return VMR9_Release(&This->renderer.filter.IBaseFilter_iface);
793 static ULONG WINAPI AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags *iface) {
794 return AM_FILTER_MISC_FLAGS_IS_RENDERER;
797 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl = {
798 AMFilterMiscFlags_QueryInterface,
799 AMFilterMiscFlags_AddRef,
800 AMFilterMiscFlags_Release,
801 AMFilterMiscFlags_GetMiscFlags
804 static HRESULT WINAPI VMR9FilterConfig_QueryInterface(IVMRFilterConfig9 *iface, REFIID riid, LPVOID * ppv)
806 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
807 return VMR9_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
810 static ULONG WINAPI VMR9FilterConfig_AddRef(IVMRFilterConfig9 *iface)
812 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
813 return VMR9_AddRef(&This->renderer.filter.IBaseFilter_iface);
816 static ULONG WINAPI VMR9FilterConfig_Release(IVMRFilterConfig9 *iface)
818 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
819 return VMR9_Release(&This->renderer.filter.IBaseFilter_iface);
822 static HRESULT WINAPI VMR9FilterConfig_SetImageCompositor(IVMRFilterConfig9 *iface, IVMRImageCompositor9 *compositor)
824 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
826 FIXME("(%p/%p)->(%p) stub\n", iface, This, compositor);
827 return E_NOTIMPL;
830 static HRESULT WINAPI VMR9FilterConfig_SetNumberOfStreams(IVMRFilterConfig9 *iface, DWORD max)
832 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
834 FIXME("(%p/%p)->(%u) stub\n", iface, This, max);
835 return E_NOTIMPL;
838 static HRESULT WINAPI VMR9FilterConfig_GetNumberOfStreams(IVMRFilterConfig9 *iface, DWORD *max)
840 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
842 FIXME("(%p/%p)->(%p) stub\n", iface, This, max);
843 return E_NOTIMPL;
846 static HRESULT WINAPI VMR9FilterConfig_SetRenderingPrefs(IVMRFilterConfig9 *iface, DWORD renderflags)
848 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
850 FIXME("(%p/%p)->(%u) stub\n", iface, This, renderflags);
851 return E_NOTIMPL;
854 static HRESULT WINAPI VMR9FilterConfig_GetRenderingPrefs(IVMRFilterConfig9 *iface, DWORD *renderflags)
856 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
858 FIXME("(%p/%p)->(%p) stub\n", iface, This, renderflags);
859 return E_NOTIMPL;
862 static HRESULT WINAPI VMR9FilterConfig_SetRenderingMode(IVMRFilterConfig9 *iface, DWORD mode)
864 HRESULT hr = S_OK;
865 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
867 TRACE("(%p/%p)->(%u)\n", iface, This, mode);
869 EnterCriticalSection(&This->renderer.filter.csFilter);
870 if (This->mode)
872 LeaveCriticalSection(&This->renderer.filter.csFilter);
873 return VFW_E_WRONG_STATE;
876 if (This->allocator)
877 IVMRSurfaceAllocator9_Release(This->allocator);
878 if (This->presenter)
879 IVMRImagePresenter9_Release(This->presenter);
881 This->allocator = NULL;
882 This->presenter = NULL;
884 switch (mode)
886 case VMR9Mode_Windowed:
887 case VMR9Mode_Windowless:
888 This->allocator = NULL;
889 This->presenter = NULL;
890 This->allocator_is_ex = 0;
891 This->cookie = ~0;
892 break;
893 case VMR9Mode_Renderless:
894 break;
895 default:
896 LeaveCriticalSection(&This->renderer.filter.csFilter);
897 return E_INVALIDARG;
900 This->mode = mode;
901 LeaveCriticalSection(&This->renderer.filter.csFilter);
902 return hr;
905 static HRESULT WINAPI VMR9FilterConfig_GetRenderingMode(IVMRFilterConfig9 *iface, DWORD *mode)
907 VMR9Impl *This = impl_from_IVMRFilterConfig9(iface);
909 TRACE("(%p/%p)->(%p) stub\n", iface, This, mode);
910 if (!mode)
911 return E_POINTER;
913 if (This->mode)
914 *mode = This->mode;
915 else
916 *mode = VMR9Mode_Windowed;
918 return S_OK;
921 static const IVMRFilterConfig9Vtbl VMR9_FilterConfig_Vtbl =
923 VMR9FilterConfig_QueryInterface,
924 VMR9FilterConfig_AddRef,
925 VMR9FilterConfig_Release,
926 VMR9FilterConfig_SetImageCompositor,
927 VMR9FilterConfig_SetNumberOfStreams,
928 VMR9FilterConfig_GetNumberOfStreams,
929 VMR9FilterConfig_SetRenderingPrefs,
930 VMR9FilterConfig_GetRenderingPrefs,
931 VMR9FilterConfig_SetRenderingMode,
932 VMR9FilterConfig_GetRenderingMode
935 static HRESULT WINAPI VMR9WindowlessControl_QueryInterface(IVMRWindowlessControl9 *iface, REFIID riid, LPVOID * ppv)
937 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
938 return VMR9_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
941 static ULONG WINAPI VMR9WindowlessControl_AddRef(IVMRWindowlessControl9 *iface)
943 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
944 return VMR9_AddRef(&This->renderer.filter.IBaseFilter_iface);
947 static ULONG WINAPI VMR9WindowlessControl_Release(IVMRWindowlessControl9 *iface)
949 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
950 return VMR9_Release(&This->renderer.filter.IBaseFilter_iface);
953 static HRESULT WINAPI VMR9WindowlessControl_GetNativeVideoSize(IVMRWindowlessControl9 *iface, LONG *width, LONG *height, LONG *arwidth, LONG *arheight)
955 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
956 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", iface, This, width, height, arwidth, arheight);
958 if (!width || !height || !arwidth || !arheight)
960 ERR("Got no pointer\n");
961 return E_POINTER;
964 *width = This->bmiheader.biWidth;
965 *height = This->bmiheader.biHeight;
966 *arwidth = This->bmiheader.biWidth;
967 *arheight = This->bmiheader.biHeight;
969 return S_OK;
972 static HRESULT WINAPI VMR9WindowlessControl_GetMinIdealVideoSize(IVMRWindowlessControl9 *iface, LONG *width, LONG *height)
974 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
976 FIXME("(%p/%p)->(...) stub\n", iface, This);
977 return E_NOTIMPL;
980 static HRESULT WINAPI VMR9WindowlessControl_GetMaxIdealVideoSize(IVMRWindowlessControl9 *iface, LONG *width, LONG *height)
982 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
984 FIXME("(%p/%p)->(...) stub\n", iface, This);
985 return E_NOTIMPL;
988 static HRESULT WINAPI VMR9WindowlessControl_SetVideoPosition(IVMRWindowlessControl9 *iface, const RECT *source, const RECT *dest)
990 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
992 TRACE("(%p/%p)->(%p, %p)\n", iface, This, source, dest);
994 EnterCriticalSection(&This->renderer.filter.csFilter);
996 if (source)
997 This->source_rect = *source;
998 if (dest)
1000 This->target_rect = *dest;
1001 if (This->baseControlWindow.baseWindow.hWnd)
1003 FIXME("Output rectangle: starting at %dx%d, up to point %dx%d\n", dest->left, dest->top, dest->right, dest->bottom);
1004 SetWindowPos(This->baseControlWindow.baseWindow.hWnd, NULL, dest->left, dest->top, dest->right - dest->left,
1005 dest->bottom-dest->top, SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOOWNERZORDER|SWP_NOREDRAW);
1009 LeaveCriticalSection(&This->renderer.filter.csFilter);
1011 return S_OK;
1014 static HRESULT WINAPI VMR9WindowlessControl_GetVideoPosition(IVMRWindowlessControl9 *iface, RECT *source, RECT *dest)
1016 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1018 if (source)
1019 *source = This->source_rect;
1021 if (dest)
1022 *dest = This->target_rect;
1024 FIXME("(%p/%p)->(%p/%p) stub\n", iface, This, source, dest);
1025 return S_OK;
1028 static HRESULT WINAPI VMR9WindowlessControl_GetAspectRatioMode(IVMRWindowlessControl9 *iface, DWORD *mode)
1030 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1032 FIXME("(%p/%p)->(...) stub\n", iface, This);
1033 return E_NOTIMPL;
1036 static HRESULT WINAPI VMR9WindowlessControl_SetAspectRatioMode(IVMRWindowlessControl9 *iface, DWORD mode)
1038 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1040 FIXME("(%p/%p)->(...) stub\n", iface, This);
1041 return E_NOTIMPL;
1044 static HRESULT WINAPI VMR9WindowlessControl_SetVideoClippingWindow(IVMRWindowlessControl9 *iface, HWND hwnd)
1046 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1048 TRACE("(%p/%p)->(%p)\n", iface, This, hwnd);
1050 EnterCriticalSection(&This->renderer.filter.csFilter);
1051 This->hWndClippingWindow = hwnd;
1052 if (!hwnd)
1053 IVMRSurfaceAllocatorEx9_TerminateDevice(This->allocator, This->cookie);
1054 LeaveCriticalSection(&This->renderer.filter.csFilter);
1055 return S_OK;
1058 static HRESULT WINAPI VMR9WindowlessControl_RepaintVideo(IVMRWindowlessControl9 *iface, HWND hwnd, HDC hdc)
1060 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1062 FIXME("(%p/%p)->(...) stub\n", iface, This);
1063 return E_NOTIMPL;
1066 static HRESULT WINAPI VMR9WindowlessControl_DisplayModeChanged(IVMRWindowlessControl9 *iface)
1068 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1070 FIXME("(%p/%p)->(...) stub\n", iface, This);
1071 return E_NOTIMPL;
1074 static HRESULT WINAPI VMR9WindowlessControl_GetCurrentImage(IVMRWindowlessControl9 *iface, BYTE **dib)
1076 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1078 FIXME("(%p/%p)->(...) stub\n", iface, This);
1079 return E_NOTIMPL;
1082 static HRESULT WINAPI VMR9WindowlessControl_SetBorderColor(IVMRWindowlessControl9 *iface, COLORREF color)
1084 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1086 FIXME("(%p/%p)->(...) stub\n", iface, This);
1087 return E_NOTIMPL;
1090 static HRESULT WINAPI VMR9WindowlessControl_GetBorderColor(IVMRWindowlessControl9 *iface, COLORREF *color)
1092 VMR9Impl *This = impl_from_IVMRWindowlessControl9(iface);
1094 FIXME("(%p/%p)->(...) stub\n", iface, This);
1095 return E_NOTIMPL;
1098 static const IVMRWindowlessControl9Vtbl VMR9_WindowlessControl_Vtbl =
1100 VMR9WindowlessControl_QueryInterface,
1101 VMR9WindowlessControl_AddRef,
1102 VMR9WindowlessControl_Release,
1103 VMR9WindowlessControl_GetNativeVideoSize,
1104 VMR9WindowlessControl_GetMinIdealVideoSize,
1105 VMR9WindowlessControl_GetMaxIdealVideoSize,
1106 VMR9WindowlessControl_SetVideoPosition,
1107 VMR9WindowlessControl_GetVideoPosition,
1108 VMR9WindowlessControl_GetAspectRatioMode,
1109 VMR9WindowlessControl_SetAspectRatioMode,
1110 VMR9WindowlessControl_SetVideoClippingWindow,
1111 VMR9WindowlessControl_RepaintVideo,
1112 VMR9WindowlessControl_DisplayModeChanged,
1113 VMR9WindowlessControl_GetCurrentImage,
1114 VMR9WindowlessControl_SetBorderColor,
1115 VMR9WindowlessControl_GetBorderColor
1118 static HRESULT WINAPI VMR9SurfaceAllocatorNotify_QueryInterface(IVMRSurfaceAllocatorNotify9 *iface, REFIID riid, LPVOID * ppv)
1120 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1121 return VMR9_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
1124 static ULONG WINAPI VMR9SurfaceAllocatorNotify_AddRef(IVMRSurfaceAllocatorNotify9 *iface)
1126 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1127 return VMR9_AddRef(&This->renderer.filter.IBaseFilter_iface);
1130 static ULONG WINAPI VMR9SurfaceAllocatorNotify_Release(IVMRSurfaceAllocatorNotify9 *iface)
1132 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1133 return VMR9_Release(&This->renderer.filter.IBaseFilter_iface);
1136 static HRESULT WINAPI VMR9SurfaceAllocatorNotify_AdviseSurfaceAllocator(IVMRSurfaceAllocatorNotify9 *iface, DWORD_PTR id, IVMRSurfaceAllocator9 *alloc)
1138 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1140 /* FIXME: This code is not tested!!! */
1141 FIXME("(%p/%p)->(...) stub\n", iface, This);
1142 This->cookie = id;
1144 if (This->presenter)
1145 return VFW_E_WRONG_STATE;
1147 if (FAILED(IUnknown_QueryInterface(alloc, &IID_IVMRImagePresenter9, (void **)&This->presenter)))
1148 return E_NOINTERFACE;
1150 if (SUCCEEDED(IUnknown_QueryInterface(alloc, &IID_IVMRSurfaceAllocatorEx9, (void **)&This->allocator)))
1151 This->allocator_is_ex = 1;
1152 else
1154 This->allocator = (IVMRSurfaceAllocatorEx9 *)alloc;
1155 IUnknown_AddRef(alloc);
1156 This->allocator_is_ex = 0;
1159 return S_OK;
1162 static HRESULT WINAPI VMR9SurfaceAllocatorNotify_SetD3DDevice(IVMRSurfaceAllocatorNotify9 *iface, IDirect3DDevice9 *device, HMONITOR monitor)
1164 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1166 FIXME("(%p/%p)->(...) stub\n", iface, This);
1167 return E_NOTIMPL;
1170 static HRESULT WINAPI VMR9SurfaceAllocatorNotify_ChangeD3DDevice(IVMRSurfaceAllocatorNotify9 *iface, IDirect3DDevice9 *device, HMONITOR monitor)
1172 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1174 FIXME("(%p/%p)->(...) stub\n", iface, This);
1175 return E_NOTIMPL;
1178 static HRESULT WINAPI VMR9SurfaceAllocatorNotify_AllocateSurfaceHelper(IVMRSurfaceAllocatorNotify9 *iface, VMR9AllocationInfo *allocinfo, DWORD *numbuffers, IDirect3DSurface9 **surface)
1180 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1182 FIXME("(%p/%p)->(%p, %p => %u, %p) semi-stub\n", iface, This, allocinfo, numbuffers, (numbuffers ? *numbuffers : 0), surface);
1184 if (!allocinfo || !numbuffers || !surface)
1185 return E_POINTER;
1187 if (!*numbuffers || *numbuffers < allocinfo->MinBuffers)
1189 ERR("Invalid number of buffers?\n");
1190 return E_INVALIDARG;
1193 return E_NOTIMPL;
1196 static HRESULT WINAPI VMR9SurfaceAllocatorNotify_NotifyEvent(IVMRSurfaceAllocatorNotify9 *iface, LONG code, LONG_PTR param1, LONG_PTR param2)
1198 VMR9Impl *This = impl_from_IVMRSurfaceAllocatorNotify9(iface);
1200 FIXME("(%p/%p)->(...) stub\n", iface, This);
1201 return E_NOTIMPL;
1204 static const IVMRSurfaceAllocatorNotify9Vtbl IVMRSurfaceAllocatorNotify9_Vtbl =
1206 VMR9SurfaceAllocatorNotify_QueryInterface,
1207 VMR9SurfaceAllocatorNotify_AddRef,
1208 VMR9SurfaceAllocatorNotify_Release,
1209 VMR9SurfaceAllocatorNotify_AdviseSurfaceAllocator,
1210 VMR9SurfaceAllocatorNotify_SetD3DDevice,
1211 VMR9SurfaceAllocatorNotify_ChangeD3DDevice,
1212 VMR9SurfaceAllocatorNotify_AllocateSurfaceHelper,
1213 VMR9SurfaceAllocatorNotify_NotifyEvent
1216 HRESULT VMR9Impl_create(IUnknown * outer_unk, LPVOID * ppv)
1218 HRESULT hr;
1219 VMR9Impl * pVMR9;
1221 TRACE("(%p, %p)\n", outer_unk, ppv);
1223 *ppv = NULL;
1225 pVMR9 = CoTaskMemAlloc(sizeof(VMR9Impl));
1227 pVMR9->outer_unk = outer_unk;
1228 pVMR9->bUnkOuterValid = FALSE;
1229 pVMR9->bAggregatable = FALSE;
1230 pVMR9->IUnknown_inner.lpVtbl = &IInner_VTable;
1231 pVMR9->IAMFilterMiscFlags_iface.lpVtbl = &IAMFilterMiscFlags_Vtbl;
1233 pVMR9->mode = 0;
1234 pVMR9->allocator = NULL;
1235 pVMR9->presenter = NULL;
1236 pVMR9->hWndClippingWindow = NULL;
1237 pVMR9->IVMRFilterConfig9_iface.lpVtbl = &VMR9_FilterConfig_Vtbl;
1238 pVMR9->IVMRWindowlessControl9_iface.lpVtbl = &VMR9_WindowlessControl_Vtbl;
1239 pVMR9->IVMRSurfaceAllocatorNotify9_iface.lpVtbl = &IVMRSurfaceAllocatorNotify9_Vtbl;
1241 hr = BaseRenderer_Init(&pVMR9->renderer, &VMR9_Vtbl, outer_unk, &CLSID_VideoMixingRenderer9, (DWORD_PTR)(__FILE__ ": VMR9Impl.csFilter"), &BaseFuncTable);
1242 if (FAILED(hr))
1243 goto fail;
1245 hr = BaseControlWindow_Init(&pVMR9->baseControlWindow, &IVideoWindow_VTable, &pVMR9->renderer.filter, &pVMR9->renderer.filter.csFilter, &pVMR9->renderer.pInputPin->pin, &renderer_BaseWindowFuncTable);
1246 if (FAILED(hr))
1247 goto fail;
1249 hr = BaseControlVideo_Init(&pVMR9->baseControlVideo, &IBasicVideo_VTable, &pVMR9->renderer.filter, &pVMR9->renderer.filter.csFilter, &pVMR9->renderer.pInputPin->pin, &renderer_BaseControlVideoFuncTable);
1250 if (FAILED(hr))
1251 goto fail;
1253 *ppv = (LPVOID)pVMR9;
1254 ZeroMemory(&pVMR9->source_rect, sizeof(RECT));
1255 ZeroMemory(&pVMR9->target_rect, sizeof(RECT));
1256 TRACE("Created at %p\n", pVMR9);
1257 return hr;
1259 fail:
1260 BaseRendererImpl_Release(&pVMR9->renderer.filter.IBaseFilter_iface);
1261 CoTaskMemFree(pVMR9);
1262 return hr;