gdiplus: Retrieve LOGFONT from a GpFont using GdipGetLogFontW instead of accessing...
[wine.git] / dlls / qcap / vfwcapture.c
blob68341ae8eb5d5dadc49d7ac0c3e7b4b27bc2262e
1 /* Video For Windows Steering structure
3 * Copyright 2005 Maarten Lankhorst
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define NONAMELESSSTRUCT
22 #define NONAMELESSUNION
23 #define COBJMACROS
25 #include "config.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wtypes.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "dshow.h"
35 #include "qcap_main.h"
36 #include "wine/debug.h"
38 #include "capture.h"
39 #include "uuids.h"
40 #include "vfwmsgs.h"
41 #include "amvideo.h"
42 #include "strmif.h"
43 #include "ddraw.h"
44 #include "ocidl.h"
45 #include "oleauto.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(qcap);
49 #define ICOM_THIS_MULTI(impl,field,iface) \
50 impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
52 static const IBaseFilterVtbl VfwCapture_Vtbl;
53 static const IAMStreamConfigVtbl IAMStreamConfig_VTable;
54 static const IAMVideoProcAmpVtbl IAMVideoProcAmp_VTable;
55 static const IPersistPropertyBagVtbl IPersistPropertyBag_VTable;
56 static const IPinVtbl VfwPin_Vtbl;
58 static HRESULT VfwPin_Construct( IBaseFilter *, LPCRITICAL_SECTION, IPin ** );
60 typedef struct VfwCapture
62 BaseFilter filter;
63 IAMStreamConfig IAMStreamConfig_iface;
64 IAMVideoProcAmp IAMVideoProcAmp_iface;
65 IPersistPropertyBag IPersistPropertyBag_iface;
67 BOOL init;
68 Capture *driver_info;
70 IPin * pOutputPin;
71 } VfwCapture;
73 static inline VfwCapture *impl_from_IAMStreamConfig(IAMStreamConfig *iface)
75 return CONTAINING_RECORD(iface, VfwCapture, IAMStreamConfig_iface);
78 static inline VfwCapture *impl_from_IAMVideoProcAmp(IAMVideoProcAmp *iface)
80 return CONTAINING_RECORD(iface, VfwCapture, IAMVideoProcAmp_iface);
83 static inline VfwCapture *impl_from_IPersistPropertyBag(IPersistPropertyBag *iface)
85 return CONTAINING_RECORD(iface, VfwCapture, IPersistPropertyBag_iface);
88 /* VfwPin implementation */
89 typedef struct VfwPinImpl
91 BaseOutputPin pin;
92 Capture *driver_info;
93 VfwCapture *parent;
94 const IKsPropertySetVtbl * KSP_VT;
95 } VfwPinImpl;
97 static IPin* WINAPI VfwCapture_GetPin(BaseFilter *iface, int pos)
99 VfwCapture *This = (VfwCapture *)iface;
101 if (pos >= 1 || pos < 0)
102 return NULL;
104 IPin_AddRef(This->pOutputPin);
105 return This->pOutputPin;
108 static LONG WINAPI VfwCapture_GetPinCount(BaseFilter *iface)
110 return 1;
113 static const BaseFilterFuncTable BaseFuncTable = {
114 VfwCapture_GetPin,
115 VfwCapture_GetPinCount
118 IUnknown * WINAPI QCAP_createVFWCaptureFilter(IUnknown *pUnkOuter, HRESULT *phr)
120 VfwCapture *pVfwCapture;
121 HRESULT hr;
123 TRACE("%p - %p\n", pUnkOuter, phr);
125 *phr = CLASS_E_NOAGGREGATION;
126 if (pUnkOuter)
127 return NULL;
128 *phr = E_OUTOFMEMORY;
130 pVfwCapture = CoTaskMemAlloc( sizeof(VfwCapture) );
132 if (!pVfwCapture)
133 return NULL;
135 BaseFilter_Init(&pVfwCapture->filter, &VfwCapture_Vtbl, &CLSID_VfwCapture, (DWORD_PTR)(__FILE__ ": VfwCapture.csFilter"), &BaseFuncTable);
137 pVfwCapture->IAMStreamConfig_iface.lpVtbl = &IAMStreamConfig_VTable;
138 pVfwCapture->IAMVideoProcAmp_iface.lpVtbl = &IAMVideoProcAmp_VTable;
139 pVfwCapture->IPersistPropertyBag_iface.lpVtbl = &IPersistPropertyBag_VTable;
140 pVfwCapture->init = FALSE;
142 hr = VfwPin_Construct(&pVfwCapture->filter.IBaseFilter_iface,
143 &pVfwCapture->filter.csFilter, &pVfwCapture->pOutputPin);
144 if (FAILED(hr))
146 CoTaskMemFree(pVfwCapture);
147 return NULL;
149 TRACE("-- created at %p\n", pVfwCapture);
151 ObjectRefCount(TRUE);
152 *phr = S_OK;
153 return (IUnknown *)pVfwCapture;
156 static HRESULT WINAPI VfwCapture_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
158 VfwCapture *This = (VfwCapture *)iface;
159 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
160 *ppv = NULL;
162 if (IsEqualIID(riid, &IID_IUnknown) ||
163 IsEqualIID(riid, &IID_IPersist) ||
164 IsEqualIID(riid, &IID_IMediaFilter) ||
165 IsEqualIID(riid, &IID_IBaseFilter))
167 *ppv = This;
169 else if (IsEqualIID(riid, &IID_IAMStreamConfig))
170 *ppv = &This->IAMStreamConfig_iface;
171 else if (IsEqualIID(riid, &IID_IAMVideoProcAmp))
172 *ppv = &This->IAMVideoProcAmp_iface;
173 else if (IsEqualIID(riid, &IID_IPersistPropertyBag))
174 *ppv = &This->IPersistPropertyBag_iface;
176 if (!IsEqualIID(riid, &IID_IUnknown) &&
177 !IsEqualIID(riid, &IID_IPersist) &&
178 !IsEqualIID(riid, &IID_IPersistPropertyBag) &&
179 !This->init)
181 FIXME("Capture system not initialised when looking for %s, "
182 "trying it on primary device now\n", debugstr_guid(riid));
183 This->driver_info = qcap_driver_init( This->pOutputPin, 0 );
184 if (!This->driver_info)
186 ERR("VfwCapture initialisation failed\n");
187 return E_UNEXPECTED;
189 This->init = TRUE;
192 if (*ppv)
194 TRACE("Returning %s interface\n", debugstr_guid(riid));
195 IUnknown_AddRef((IUnknown *)(*ppv));
196 return S_OK;
199 FIXME("No interface for %s!\n", debugstr_guid(riid));
200 return E_NOINTERFACE;
203 static ULONG WINAPI VfwCapture_Release(IBaseFilter * iface)
205 VfwCapture *This = (VfwCapture *)iface;
206 ULONG refCount = BaseFilterImpl_Release(iface);
208 TRACE("%p->() New refcount: %d\n", This, refCount);
210 if (!refCount)
212 BasePin *pin;
214 TRACE("destroying everything\n");
215 if (This->init)
217 if (This->filter.state != State_Stopped)
218 qcap_driver_stop(This->driver_info, &This->filter.state);
219 qcap_driver_destroy(This->driver_info);
221 pin = (BasePin*) This->pOutputPin;
222 if (pin->pConnectedTo != NULL)
224 IPin_Disconnect(pin->pConnectedTo);
225 IPin_Disconnect(This->pOutputPin);
227 IPin_Release(This->pOutputPin);
228 CoTaskMemFree(This);
229 ObjectRefCount(FALSE);
231 return refCount;
234 /** IMediaFilter methods **/
236 static HRESULT WINAPI VfwCapture_Stop(IBaseFilter * iface)
238 VfwCapture *This = (VfwCapture *)iface;
240 TRACE("()\n");
241 return qcap_driver_stop(This->driver_info, &This->filter.state);
244 static HRESULT WINAPI VfwCapture_Pause(IBaseFilter * iface)
246 VfwCapture *This = (VfwCapture *)iface;
248 TRACE("()\n");
249 return qcap_driver_pause(This->driver_info, &This->filter.state);
252 static HRESULT WINAPI VfwCapture_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
254 VfwCapture *This = (VfwCapture *)iface;
255 TRACE("(%x%08x)\n", (ULONG)(tStart >> 32), (ULONG)tStart);
256 return qcap_driver_run(This->driver_info, &This->filter.state);
259 /** IBaseFilter methods **/
260 static HRESULT WINAPI VfwCapture_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
262 FIXME("(%s, %p) - stub\n", debugstr_w(Id), ppPin);
263 return E_NOTIMPL;
266 static const IBaseFilterVtbl VfwCapture_Vtbl =
268 VfwCapture_QueryInterface,
269 BaseFilterImpl_AddRef,
270 VfwCapture_Release,
271 BaseFilterImpl_GetClassID,
272 VfwCapture_Stop,
273 VfwCapture_Pause,
274 VfwCapture_Run,
275 BaseFilterImpl_GetState,
276 BaseFilterImpl_SetSyncSource,
277 BaseFilterImpl_GetSyncSource,
278 BaseFilterImpl_EnumPins,
279 VfwCapture_FindPin,
280 BaseFilterImpl_QueryFilterInfo,
281 BaseFilterImpl_JoinFilterGraph,
282 BaseFilterImpl_QueryVendorInfo
285 /* AMStreamConfig interface, we only need to implement {G,S}etFormat */
286 static HRESULT WINAPI
287 AMStreamConfig_QueryInterface( IAMStreamConfig * iface, REFIID riid, LPVOID * ppv )
289 VfwCapture *This = impl_from_IAMStreamConfig(iface);
291 TRACE("%p --> %s\n", This, debugstr_guid(riid));
293 if (IsEqualIID(riid, &IID_IUnknown) ||
294 IsEqualIID(riid, &IID_IAMStreamConfig))
296 IAMStreamConfig_AddRef(iface);
297 *ppv = iface;
298 return S_OK;
301 FIXME("No interface for iid %s\n", debugstr_guid(riid));
302 return E_NOINTERFACE;
305 static ULONG WINAPI AMStreamConfig_AddRef( IAMStreamConfig * iface )
307 VfwCapture *This = impl_from_IAMStreamConfig(iface);
309 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
310 return IUnknown_AddRef((IUnknown *)This);
313 static ULONG WINAPI AMStreamConfig_Release( IAMStreamConfig * iface )
315 VfwCapture *This = impl_from_IAMStreamConfig(iface);
317 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
318 return IUnknown_Release((IUnknown *)This);
321 static HRESULT WINAPI
322 AMStreamConfig_SetFormat(IAMStreamConfig *iface, AM_MEDIA_TYPE *pmt)
324 HRESULT hr;
325 VfwCapture *This = impl_from_IAMStreamConfig(iface);
326 BasePin *pin;
328 TRACE("(%p): %p->%p\n", iface, pmt, pmt ? pmt->pbFormat : NULL);
330 if (This->filter.state != State_Stopped)
332 TRACE("Returning not stopped error\n");
333 return VFW_E_NOT_STOPPED;
336 if (!pmt)
338 TRACE("pmt is NULL\n");
339 return E_POINTER;
342 dump_AM_MEDIA_TYPE(pmt);
344 pin = (BasePin *)This->pOutputPin;
345 if (pin->pConnectedTo != NULL)
347 hr = IPin_QueryAccept(pin->pConnectedTo, pmt);
348 TRACE("Would accept: %d\n", hr);
349 if (hr == S_FALSE)
350 return VFW_E_INVALIDMEDIATYPE;
353 hr = qcap_driver_set_format(This->driver_info, pmt);
354 if (SUCCEEDED(hr) && This->filter.filterInfo.pGraph && pin->pConnectedTo )
356 hr = IFilterGraph_Reconnect(This->filter.filterInfo.pGraph, This->pOutputPin);
357 if (SUCCEEDED(hr))
358 TRACE("Reconnection completed, with new media format..\n");
360 TRACE("Returning: %d\n", hr);
361 return hr;
364 static HRESULT WINAPI
365 AMStreamConfig_GetFormat( IAMStreamConfig *iface, AM_MEDIA_TYPE **pmt )
367 VfwCapture *This = impl_from_IAMStreamConfig(iface);
369 TRACE("%p -> (%p)\n", iface, pmt);
370 return qcap_driver_get_format(This->driver_info, pmt);
373 static HRESULT WINAPI
374 AMStreamConfig_GetNumberOfCapabilities( IAMStreamConfig *iface, int *piCount,
375 int *piSize )
377 FIXME("%p: %p %p - stub, intentional\n", iface, piCount, piSize);
378 return E_NOTIMPL; /* Not implemented for this interface */
381 static HRESULT WINAPI
382 AMStreamConfig_GetStreamCaps( IAMStreamConfig *iface, int iIndex,
383 AM_MEDIA_TYPE **pmt, BYTE *pSCC )
385 FIXME("%p: %d %p %p - stub, intentional\n", iface, iIndex, pmt, pSCC);
386 return E_NOTIMPL; /* Not implemented for this interface */
389 static const IAMStreamConfigVtbl IAMStreamConfig_VTable =
391 AMStreamConfig_QueryInterface,
392 AMStreamConfig_AddRef,
393 AMStreamConfig_Release,
394 AMStreamConfig_SetFormat,
395 AMStreamConfig_GetFormat,
396 AMStreamConfig_GetNumberOfCapabilities,
397 AMStreamConfig_GetStreamCaps
400 static HRESULT WINAPI
401 AMVideoProcAmp_QueryInterface( IAMVideoProcAmp * iface, REFIID riid,
402 LPVOID * ppv )
404 if (IsEqualIID(riid, &IID_IUnknown) ||
405 IsEqualIID(riid, &IID_IAMVideoProcAmp))
407 *ppv = iface;
408 IAMVideoProcAmp_AddRef( iface );
409 return S_OK;
412 FIXME("No interface for iid %s\n", debugstr_guid(riid));
413 return E_NOINTERFACE;
416 static ULONG WINAPI AMVideoProcAmp_AddRef(IAMVideoProcAmp * iface)
418 VfwCapture *This = impl_from_IAMVideoProcAmp(iface);
420 return IUnknown_AddRef((IUnknown *)This);
423 static ULONG WINAPI AMVideoProcAmp_Release(IAMVideoProcAmp * iface)
425 VfwCapture *This = impl_from_IAMVideoProcAmp(iface);
427 return IUnknown_Release((IUnknown *)This);
430 static HRESULT WINAPI
431 AMVideoProcAmp_GetRange( IAMVideoProcAmp * iface, LONG Property, LONG *pMin,
432 LONG *pMax, LONG *pSteppingDelta, LONG *pDefault, LONG *pCapsFlags )
434 VfwCapture *This = impl_from_IAMVideoProcAmp(iface);
436 return qcap_driver_get_prop_range( This->driver_info, Property, pMin, pMax,
437 pSteppingDelta, pDefault, pCapsFlags );
440 static HRESULT WINAPI
441 AMVideoProcAmp_Set( IAMVideoProcAmp * iface, LONG Property, LONG lValue,
442 LONG Flags )
444 VfwCapture *This = impl_from_IAMVideoProcAmp(iface);
446 return qcap_driver_set_prop(This->driver_info, Property, lValue, Flags);
449 static HRESULT WINAPI
450 AMVideoProcAmp_Get( IAMVideoProcAmp * iface, LONG Property, LONG *lValue,
451 LONG *Flags )
453 VfwCapture *This = impl_from_IAMVideoProcAmp(iface);
455 return qcap_driver_get_prop(This->driver_info, Property, lValue, Flags);
458 static const IAMVideoProcAmpVtbl IAMVideoProcAmp_VTable =
460 AMVideoProcAmp_QueryInterface,
461 AMVideoProcAmp_AddRef,
462 AMVideoProcAmp_Release,
463 AMVideoProcAmp_GetRange,
464 AMVideoProcAmp_Set,
465 AMVideoProcAmp_Get,
468 static HRESULT WINAPI
469 PPB_QueryInterface( IPersistPropertyBag * iface, REFIID riid, LPVOID * ppv )
471 if (IsEqualIID(riid, &IID_IUnknown) ||
472 IsEqualIID(riid, &IID_IPersist) ||
473 IsEqualIID(riid, &IID_IPersistPropertyBag))
475 IPersistPropertyBag_AddRef(iface);
476 *ppv = iface;
477 return S_OK;
479 if (IsEqualIID(riid, &IID_IBaseFilter))
481 /* FIXME: native devenum asks for IBaseFilter, should we return it? */
482 IPersistPropertyBag_AddRef(iface);
483 *ppv = iface;
484 return S_OK;
487 FIXME("No interface for iid %s\n", debugstr_guid(riid));
488 return E_NOINTERFACE;
491 static ULONG WINAPI PPB_AddRef(IPersistPropertyBag * iface)
493 VfwCapture *This = impl_from_IPersistPropertyBag(iface);
495 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
497 return IUnknown_AddRef((IUnknown *)This);
500 static ULONG WINAPI PPB_Release(IPersistPropertyBag * iface)
502 VfwCapture *This = impl_from_IPersistPropertyBag(iface);
504 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
506 return IUnknown_Release((IUnknown *)This);
509 static HRESULT WINAPI
510 PPB_GetClassID( IPersistPropertyBag * iface, CLSID * pClassID )
512 VfwCapture *This = impl_from_IPersistPropertyBag(iface);
514 FIXME("%p - stub\n", This);
516 return E_NOTIMPL;
519 static HRESULT WINAPI PPB_InitNew(IPersistPropertyBag * iface)
521 VfwCapture *This = impl_from_IPersistPropertyBag(iface);
523 FIXME("%p - stub\n", This);
525 return E_NOTIMPL;
528 static HRESULT WINAPI
529 PPB_Load( IPersistPropertyBag * iface, IPropertyBag *pPropBag,
530 IErrorLog *pErrorLog )
532 VfwCapture *This = impl_from_IPersistPropertyBag(iface);
533 HRESULT hr;
534 VARIANT var;
535 const OLECHAR VFWIndex[] = {'V','F','W','I','n','d','e','x',0};
537 TRACE("%p/%p-> (%p, %p)\n", iface, This, pPropBag, pErrorLog);
539 V_VT(&var) = VT_I4;
540 hr = IPropertyBag_Read(pPropBag, VFWIndex, &var, pErrorLog);
542 if (SUCCEEDED(hr))
544 VfwPinImpl *pin;
546 This->driver_info = qcap_driver_init( This->pOutputPin,
547 var.__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.ulVal );
548 if (This->driver_info)
550 pin = (VfwPinImpl *)This->pOutputPin;
551 pin->driver_info = This->driver_info;
552 pin->parent = This;
553 This->init = TRUE;
554 hr = S_OK;
556 else
557 hr = E_FAIL;
560 return hr;
563 static HRESULT WINAPI
564 PPB_Save( IPersistPropertyBag * iface, IPropertyBag *pPropBag,
565 BOOL fClearDirty, BOOL fSaveAllProperties )
567 VfwCapture *This = impl_from_IPersistPropertyBag(iface);
568 FIXME("%p - stub\n", This);
569 return E_NOTIMPL;
572 static const IPersistPropertyBagVtbl IPersistPropertyBag_VTable =
574 PPB_QueryInterface,
575 PPB_AddRef,
576 PPB_Release,
577 PPB_GetClassID,
578 PPB_InitNew,
579 PPB_Load,
580 PPB_Save
583 /* IKsPropertySet interface */
584 static HRESULT WINAPI
585 KSP_QueryInterface( IKsPropertySet * iface, REFIID riid, LPVOID * ppv )
587 if (IsEqualIID(riid, &IID_IUnknown) ||
588 IsEqualIID(riid, &IID_IKsPropertySet))
590 *ppv = iface;
591 IKsPropertySet_AddRef( iface );
592 return S_OK;
595 FIXME("No interface for iid %s\n", debugstr_guid(riid));
596 return E_NOINTERFACE;
599 static ULONG WINAPI KSP_AddRef(IKsPropertySet * iface)
601 ICOM_THIS_MULTI(VfwPinImpl, KSP_VT, iface);
603 TRACE("%p --> Forwarding to VfwPin (%p)\n", iface, This);
605 return IUnknown_AddRef((IUnknown *)This);
608 static ULONG WINAPI KSP_Release(IKsPropertySet * iface)
610 ICOM_THIS_MULTI(VfwPinImpl, KSP_VT, iface);
612 TRACE("%p --> Forwarding to VfwPin (%p)\n", iface, This);
614 return IUnknown_Release((IUnknown *)This);
617 static HRESULT WINAPI
618 KSP_Set( IKsPropertySet * iface, REFGUID guidPropSet, DWORD dwPropID,
619 LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData,
620 DWORD cbPropData )
622 FIXME("%p: stub\n", iface);
623 return E_NOTIMPL;
626 static HRESULT WINAPI
627 KSP_Get( IKsPropertySet * iface, REFGUID guidPropSet, DWORD dwPropID,
628 LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData,
629 DWORD cbPropData, DWORD *pcbReturned )
631 LPGUID pGuid;
633 TRACE("()\n");
635 if (!IsEqualIID(guidPropSet, &AMPROPSETID_Pin))
636 return E_PROP_SET_UNSUPPORTED;
637 if (pPropData == NULL && pcbReturned == NULL)
638 return E_POINTER;
639 if (pcbReturned)
640 *pcbReturned = sizeof(GUID);
641 if (pPropData == NULL)
642 return S_OK;
643 if (cbPropData < sizeof(GUID))
644 return E_UNEXPECTED;
645 pGuid = pPropData;
646 *pGuid = PIN_CATEGORY_PREVIEW;
647 FIXME("() Not adding a pin with PIN_CATEGORY_CAPTURE\n");
648 return S_OK;
651 static HRESULT WINAPI
652 KSP_QuerySupported( IKsPropertySet * iface, REFGUID guidPropSet,
653 DWORD dwPropID, DWORD *pTypeSupport )
655 FIXME("%p: stub\n", iface);
656 return E_NOTIMPL;
659 static const IKsPropertySetVtbl KSP_VTable =
661 KSP_QueryInterface,
662 KSP_AddRef,
663 KSP_Release,
664 KSP_Set,
665 KSP_Get,
666 KSP_QuerySupported
669 static HRESULT WINAPI VfwPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
671 VfwPinImpl *This = (VfwPinImpl *)iface;
672 AM_MEDIA_TYPE *vfw_pmt;
673 HRESULT hr;
675 if (iPosition < 0)
676 return E_INVALIDARG;
677 if (iPosition > 0)
678 return VFW_S_NO_MORE_ITEMS;
680 hr = qcap_driver_get_format(This->driver_info, &vfw_pmt);
681 CopyMediaType(pmt, vfw_pmt);
682 DeleteMediaType(vfw_pmt);
684 return hr;
687 static LONG WINAPI VfwPin_GetMediaTypeVersion(BasePin *iface)
689 return 1;
692 static HRESULT WINAPI VfwPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
694 ALLOCATOR_PROPERTIES actual;
696 /* What we put here doesn't matter, the
697 driver function should override it then commit */
698 if (!ppropInputRequest->cBuffers)
699 ppropInputRequest->cBuffers = 3;
700 if (!ppropInputRequest->cbBuffer)
701 ppropInputRequest->cbBuffer = 230400;
702 if (!ppropInputRequest->cbAlign)
703 ppropInputRequest->cbAlign = 1;
705 return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
708 static const BasePinFuncTable output_BaseFuncTable = {
709 NULL,
710 BaseOutputPinImpl_AttemptConnection,
711 VfwPin_GetMediaTypeVersion,
712 VfwPin_GetMediaType
715 static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
716 VfwPin_DecideBufferSize,
717 BaseOutputPinImpl_DecideAllocator,
718 BaseOutputPinImpl_BreakConnect
721 static HRESULT
722 VfwPin_Construct( IBaseFilter * pBaseFilter, LPCRITICAL_SECTION pCritSec,
723 IPin ** ppPin )
725 static const WCHAR wszOutputPinName[] = { 'O','u','t','p','u','t',0 };
726 PIN_INFO piOutput;
727 HRESULT hr;
729 *ppPin = NULL;
731 piOutput.dir = PINDIR_OUTPUT;
732 piOutput.pFilter = pBaseFilter;
733 lstrcpyW(piOutput.achName, wszOutputPinName);
734 ObjectRefCount(TRUE);
736 hr = BaseOutputPin_Construct(&VfwPin_Vtbl, sizeof(VfwPinImpl), &piOutput, &output_BaseFuncTable, &output_BaseOutputFuncTable, pCritSec, ppPin);
738 if (SUCCEEDED(hr))
740 VfwPinImpl *pPinImpl = (VfwPinImpl*)*ppPin;
741 pPinImpl->KSP_VT = &KSP_VTable;
744 return hr;
747 static HRESULT WINAPI VfwPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
749 VfwPinImpl *This = (VfwPinImpl *)iface;
751 TRACE("%s %p\n", debugstr_guid(riid), ppv);
753 *ppv = NULL;
754 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin))
755 *ppv = This;
756 else if (IsEqualIID(riid, &IID_IKsPropertySet))
757 *ppv = &(This->KSP_VT);
758 else if (IsEqualIID(riid, &IID_IAMStreamConfig))
759 return IUnknown_QueryInterface((IUnknown *)This->parent, riid, ppv);
761 if (*ppv)
763 IUnknown_AddRef((IUnknown *)(*ppv));
764 return S_OK;
767 FIXME("No interface for %s!\n", debugstr_guid(riid));
768 return E_NOINTERFACE;
771 static ULONG WINAPI
772 VfwPin_Release(IPin * iface)
774 VfwPinImpl *This = (VfwPinImpl *)iface;
775 ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
777 TRACE("() -> new refcount: %u\n", refCount);
779 if (!refCount)
781 CoTaskMemFree(This);
782 ObjectRefCount(FALSE);
784 return refCount;
787 static HRESULT WINAPI
788 VfwPin_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum)
790 AM_MEDIA_TYPE *pmt;
791 HRESULT hr;
793 VfwPinImpl *This = (VfwPinImpl *)iface;
794 hr = qcap_driver_get_format(This->driver_info, &pmt);
795 if (SUCCEEDED(hr))
796 hr = BasePinImpl_EnumMediaTypes(iface, ppEnum);
797 TRACE("%p -- %x\n", This, hr);
798 DeleteMediaType(pmt);
800 return hr;
803 static HRESULT WINAPI
804 VfwPin_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin)
806 TRACE("(%p)->(%p, %p)\n", iface, apPin, cPin);
807 return E_NOTIMPL;
810 static const IPinVtbl VfwPin_Vtbl =
812 VfwPin_QueryInterface,
813 BasePinImpl_AddRef,
814 VfwPin_Release,
815 BaseOutputPinImpl_Connect,
816 BaseOutputPinImpl_ReceiveConnection,
817 BaseOutputPinImpl_Disconnect,
818 BasePinImpl_ConnectedTo,
819 BasePinImpl_ConnectionMediaType,
820 BasePinImpl_QueryPinInfo,
821 BasePinImpl_QueryDirection,
822 BasePinImpl_QueryId,
823 BasePinImpl_QueryAccept,
824 VfwPin_EnumMediaTypes,
825 VfwPin_QueryInternalConnections,
826 BaseOutputPinImpl_EndOfStream,
827 BaseOutputPinImpl_BeginFlush,
828 BaseOutputPinImpl_EndFlush,
829 BasePinImpl_NewSegment