winhttp: Add status notification tests. Make them pass.
[wine/wine64.git] / dlls / qcap / vfwcapture.c
blobfa4754fd603e67551524dc9376a70853a25378da
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 "pin.h"
39 #include "capture.h"
40 #include "uuids.h"
41 #include "vfwmsgs.h"
42 #include "amvideo.h"
43 #include "strmif.h"
44 #include "ddraw.h"
45 #include "ocidl.h"
46 #include "oleauto.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(qcap);
50 #define ICOM_THIS_MULTI(impl,field,iface) \
51 impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
53 static const IBaseFilterVtbl VfwCapture_Vtbl;
54 static const IAMStreamConfigVtbl IAMStreamConfig_VTable;
55 static const IAMVideoProcAmpVtbl IAMVideoProcAmp_VTable;
56 static const IPersistPropertyBagVtbl IPersistPropertyBag_VTable;
57 static const IPinVtbl VfwPin_Vtbl;
59 static HRESULT VfwPin_Construct( IBaseFilter *, LPCRITICAL_SECTION, IPin ** );
61 typedef struct VfwCapture
63 const IBaseFilterVtbl * lpVtbl;
64 const IAMStreamConfigVtbl * IAMStreamConfig_vtbl;
65 const IAMVideoProcAmpVtbl * IAMVideoProcAmp_vtbl;
66 const IPersistPropertyBagVtbl * IPersistPropertyBag_vtbl;
68 BOOL init;
69 Capture *driver_info;
70 LONG refCount;
71 FILTER_INFO filterInfo;
72 FILTER_STATE state;
73 CRITICAL_SECTION csFilter;
75 IPin * pOutputPin;
76 } VfwCapture;
78 /* VfwPin implementation */
79 typedef struct VfwPinImpl
81 OutputPin pin;
82 Capture *driver_info;
83 VfwCapture *parent;
84 const IKsPropertySetVtbl * KSP_VT;
85 } VfwPinImpl;
88 IUnknown * WINAPI QCAP_createVFWCaptureFilter(IUnknown *pUnkOuter, HRESULT *phr)
90 VfwCapture *pVfwCapture;
91 HRESULT hr;
93 TRACE("%p - %p\n", pUnkOuter, phr);
95 *phr = CLASS_E_NOAGGREGATION;
96 if (pUnkOuter)
97 return NULL;
98 *phr = E_OUTOFMEMORY;
100 pVfwCapture = CoTaskMemAlloc( sizeof(VfwCapture) );
102 if (!pVfwCapture)
103 return NULL;
105 pVfwCapture->lpVtbl = &VfwCapture_Vtbl;
106 pVfwCapture->IAMStreamConfig_vtbl = &IAMStreamConfig_VTable;
107 pVfwCapture->IAMVideoProcAmp_vtbl = &IAMVideoProcAmp_VTable;
108 pVfwCapture->IPersistPropertyBag_vtbl = &IPersistPropertyBag_VTable;
109 pVfwCapture->refCount = 1;
110 pVfwCapture->filterInfo.achName[0] = '\0';
111 pVfwCapture->filterInfo.pGraph = NULL;
112 pVfwCapture->state = State_Stopped;
113 pVfwCapture->init = FALSE;
114 InitializeCriticalSection(&pVfwCapture->csFilter);
115 pVfwCapture->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VfwCapture.csFilter");
116 hr = VfwPin_Construct((IBaseFilter *)&pVfwCapture->lpVtbl,
117 &pVfwCapture->csFilter, &pVfwCapture->pOutputPin);
118 if (!SUCCEEDED(hr))
120 CoTaskMemFree(pVfwCapture);
121 return NULL;
123 TRACE("-- created at %p\n", pVfwCapture);
125 ObjectRefCount(TRUE);
126 *phr = S_OK;
127 return (IUnknown *)pVfwCapture;
130 static HRESULT WINAPI VfwCapture_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
132 VfwCapture *This = (VfwCapture *)iface;
133 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
134 *ppv = NULL;
136 if (IsEqualIID(riid, &IID_IUnknown) ||
137 IsEqualIID(riid, &IID_IPersist) ||
138 IsEqualIID(riid, &IID_IMediaFilter) ||
139 IsEqualIID(riid, &IID_IBaseFilter))
141 *ppv = This;
143 else if (IsEqualIID(riid, &IID_IAMStreamConfig))
144 *ppv = &(This->IAMStreamConfig_vtbl);
145 else if (IsEqualIID(riid, &IID_IAMVideoProcAmp))
146 *ppv = &(This->IAMVideoProcAmp_vtbl);
147 else if (IsEqualIID(riid, &IID_IPersistPropertyBag))
148 *ppv = &(This->IPersistPropertyBag_vtbl);
150 if (!IsEqualIID(riid, &IID_IUnknown) &&
151 !IsEqualIID(riid, &IID_IPersist) &&
152 !IsEqualIID(riid, &IID_IPersistPropertyBag) &&
153 !This->init)
155 FIXME("Capture system not initialised when looking for %s, "
156 "trying it on primary device now\n", debugstr_guid(riid));
157 This->driver_info = qcap_driver_init( This->pOutputPin, 0 );
158 if (!This->driver_info)
160 ERR("VfwCapture initialisation failed\n");
161 return E_UNEXPECTED;
163 This->init = TRUE;
166 if (*ppv)
168 TRACE("Returning %s interface\n", debugstr_guid(riid));
169 IUnknown_AddRef((IUnknown *)(*ppv));
170 return S_OK;
173 FIXME("No interface for %s!\n", debugstr_guid(riid));
174 return E_NOINTERFACE;
177 static ULONG WINAPI VfwCapture_AddRef(IBaseFilter * iface)
179 VfwCapture *This = (VfwCapture *)iface;
180 ULONG refCount = InterlockedIncrement(&This->refCount);
182 TRACE("%p->() New refcount: %d\n", This, refCount);
184 return refCount;
187 static ULONG WINAPI VfwCapture_Release(IBaseFilter * iface)
189 VfwCapture *This = (VfwCapture *)iface;
190 ULONG refCount = InterlockedDecrement(&This->refCount);
192 TRACE("%p->() New refcount: %d\n", This, refCount);
194 if (!refCount)
196 IPinImpl *pin;
198 TRACE("destroying everything\n");
199 if (This->init)
201 if (This->state != State_Stopped)
202 qcap_driver_stop(This->driver_info, &This->state);
203 qcap_driver_destroy(This->driver_info);
205 pin = (IPinImpl*) This->pOutputPin;
206 if (pin->pConnectedTo != NULL)
208 IPin_Disconnect(pin->pConnectedTo);
209 IPin_Disconnect(This->pOutputPin);
211 IPin_Release(This->pOutputPin);
212 This->csFilter.DebugInfo->Spare[0] = 0;
213 DeleteCriticalSection(&This->csFilter);
214 This->lpVtbl = NULL;
215 CoTaskMemFree(This);
216 ObjectRefCount(FALSE);
218 return refCount;
221 /** IPersist methods **/
223 static HRESULT WINAPI VfwCapture_GetClassID(IBaseFilter * iface, CLSID * pClsid)
225 TRACE("(%p)\n", pClsid);
226 *pClsid = CLSID_VfwCapture;
227 return S_OK;
230 /** IMediaFilter methods **/
232 static HRESULT WINAPI VfwCapture_Stop(IBaseFilter * iface)
234 VfwCapture *This = (VfwCapture *)iface;
236 TRACE("()\n");
237 return qcap_driver_stop(This->driver_info, &This->state);
240 static HRESULT WINAPI VfwCapture_Pause(IBaseFilter * iface)
242 VfwCapture *This = (VfwCapture *)iface;
244 TRACE("()\n");
245 return qcap_driver_pause(This->driver_info, &This->state);
248 static HRESULT WINAPI VfwCapture_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
250 VfwCapture *This = (VfwCapture *)iface;
251 TRACE("(%x%08x)\n", (ULONG)(tStart >> 32), (ULONG)tStart);
252 return qcap_driver_run(This->driver_info, &This->state);
255 static HRESULT WINAPI
256 VfwCapture_GetState( IBaseFilter * iface, DWORD dwMilliSecsTimeout,
257 FILTER_STATE *pState )
259 VfwCapture *This = (VfwCapture *)iface;
261 TRACE("(%u, %p)\n", dwMilliSecsTimeout, pState);
263 *pState = This->state;
264 return S_OK;
267 static HRESULT WINAPI
268 VfwCapture_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
270 TRACE("(%p)\n", pClock);
272 return S_OK;
275 static HRESULT WINAPI
276 VfwCapture_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
278 TRACE("(%p)\n", ppClock);
280 return S_OK;
283 /** IBaseFilter methods **/
285 static HRESULT WINAPI
286 VfwCapture_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
288 ENUMPINDETAILS epd;
289 VfwCapture *This = (VfwCapture *)iface;
291 TRACE("(%p)\n", ppEnum);
293 epd.cPins = 1;
294 epd.ppPins = &This->pOutputPin;
295 return IEnumPinsImpl_Construct(&epd, ppEnum);
298 static HRESULT WINAPI VfwCapture_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
300 FIXME("(%s, %p) - stub\n", debugstr_w(Id), ppPin);
301 return E_NOTIMPL;
304 static HRESULT WINAPI VfwCapture_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
306 VfwCapture *This = (VfwCapture *)iface;
308 TRACE("(%p)\n", pInfo);
310 lstrcpyW(pInfo->achName, This->filterInfo.achName);
311 pInfo->pGraph = This->filterInfo.pGraph;
313 if (pInfo->pGraph)
314 IFilterGraph_AddRef(pInfo->pGraph);
315 return S_OK;
318 static HRESULT WINAPI
319 VfwCapture_JoinFilterGraph( IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName )
321 VfwCapture *This = (VfwCapture *)iface;
323 TRACE("(%p, %s)\n", pGraph, debugstr_w(pName));
325 if (pName)
326 lstrcpyW(This->filterInfo.achName, pName);
327 else
328 *This->filterInfo.achName = 0;
329 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
331 return S_OK;
334 static HRESULT WINAPI
335 VfwCapture_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
337 FIXME("(%p) - stub\n", pVendorInfo);
338 return E_NOTIMPL;
341 static const IBaseFilterVtbl VfwCapture_Vtbl =
343 VfwCapture_QueryInterface,
344 VfwCapture_AddRef,
345 VfwCapture_Release,
346 VfwCapture_GetClassID,
347 VfwCapture_Stop,
348 VfwCapture_Pause,
349 VfwCapture_Run,
350 VfwCapture_GetState,
351 VfwCapture_SetSyncSource,
352 VfwCapture_GetSyncSource,
353 VfwCapture_EnumPins,
354 VfwCapture_FindPin,
355 VfwCapture_QueryFilterInfo,
356 VfwCapture_JoinFilterGraph,
357 VfwCapture_QueryVendorInfo
360 /* AMStreamConfig interface, we only need to implement {G,S}etFormat */
361 static HRESULT WINAPI
362 AMStreamConfig_QueryInterface( IAMStreamConfig * iface, REFIID riid, LPVOID * ppv )
364 ICOM_THIS_MULTI(VfwCapture, IAMStreamConfig_vtbl, iface);
366 TRACE("%p --> %s\n", This, debugstr_guid(riid));
368 if (IsEqualIID(riid, &IID_IUnknown) ||
369 IsEqualIID(riid, &IID_IAMStreamConfig))
371 IAMStreamConfig_AddRef(iface);
372 *ppv = iface;
373 return S_OK;
376 FIXME("No interface for iid %s\n", debugstr_guid(riid));
377 return E_NOINTERFACE;
380 static ULONG WINAPI AMStreamConfig_AddRef( IAMStreamConfig * iface )
382 ICOM_THIS_MULTI(VfwCapture, IAMStreamConfig_vtbl, iface);
384 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
385 return IUnknown_AddRef((IUnknown *)This);
388 static ULONG WINAPI AMStreamConfig_Release( IAMStreamConfig * iface )
390 ICOM_THIS_MULTI(VfwCapture, IAMStreamConfig_vtbl, iface);
392 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
393 return IUnknown_Release((IUnknown *)This);
396 static HRESULT WINAPI
397 AMStreamConfig_SetFormat(IAMStreamConfig *iface, AM_MEDIA_TYPE *pmt)
399 HRESULT hr;
400 ICOM_THIS_MULTI(VfwCapture, IAMStreamConfig_vtbl, iface);
401 IPinImpl *pin;
403 TRACE("(%p): %p->%p\n", iface, pmt, pmt->pbFormat);
405 if (This->state != State_Stopped)
407 TRACE("Returning not stopped error\n");
408 return VFW_E_NOT_STOPPED;
411 dump_AM_MEDIA_TYPE(pmt);
413 pin = (IPinImpl *)This->pOutputPin;
414 if (pin->pConnectedTo != NULL)
416 hr = IPin_QueryAccept(pin->pConnectedTo, pmt);
417 TRACE("Would accept: %d\n", hr);
418 if (hr == S_FALSE)
419 return VFW_E_INVALIDMEDIATYPE;
422 hr = qcap_driver_set_format(This->driver_info, pmt);
423 if (SUCCEEDED(hr) && This->filterInfo.pGraph && pin->pConnectedTo )
425 hr = IFilterGraph_Reconnect(This->filterInfo.pGraph, This->pOutputPin);
426 if (SUCCEEDED(hr))
427 TRACE("Reconnection completed, with new media format..\n");
429 TRACE("Returning: %d\n", hr);
430 return hr;
433 static HRESULT WINAPI
434 AMStreamConfig_GetFormat( IAMStreamConfig *iface, AM_MEDIA_TYPE **pmt )
436 ICOM_THIS_MULTI(VfwCapture, IAMStreamConfig_vtbl, iface);
438 TRACE("%p -> (%p)\n", iface, pmt);
439 return qcap_driver_get_format(This->driver_info, pmt);
442 static HRESULT WINAPI
443 AMStreamConfig_GetNumberOfCapabilities( IAMStreamConfig *iface, int *piCount,
444 int *piSize )
446 FIXME("%p: %p %p - stub, intentional\n", iface, piCount, piSize);
447 return E_NOTIMPL; /* Not implemented for this interface */
450 static HRESULT WINAPI
451 AMStreamConfig_GetStreamCaps( IAMStreamConfig *iface, int iIndex,
452 AM_MEDIA_TYPE **pmt, BYTE *pSCC )
454 FIXME("%p: %d %p %p - stub, intentional\n", iface, iIndex, pmt, pSCC);
455 return E_NOTIMPL; /* Not implemented for this interface */
458 static const IAMStreamConfigVtbl IAMStreamConfig_VTable =
460 AMStreamConfig_QueryInterface,
461 AMStreamConfig_AddRef,
462 AMStreamConfig_Release,
463 AMStreamConfig_SetFormat,
464 AMStreamConfig_GetFormat,
465 AMStreamConfig_GetNumberOfCapabilities,
466 AMStreamConfig_GetStreamCaps
469 static HRESULT WINAPI
470 AMVideoProcAmp_QueryInterface( IAMVideoProcAmp * iface, REFIID riid,
471 LPVOID * ppv )
473 if (IsEqualIID(riid, &IID_IUnknown) ||
474 IsEqualIID(riid, &IID_IAMVideoProcAmp))
476 *ppv = iface;
477 IAMVideoProcAmp_AddRef( iface );
478 return S_OK;
481 FIXME("No interface for iid %s\n", debugstr_guid(riid));
482 return E_NOINTERFACE;
485 static ULONG WINAPI AMVideoProcAmp_AddRef(IAMVideoProcAmp * iface)
487 ICOM_THIS_MULTI(VfwCapture, IAMVideoProcAmp_vtbl, iface);
489 return IUnknown_AddRef((IUnknown *)This);
492 static ULONG WINAPI AMVideoProcAmp_Release(IAMVideoProcAmp * iface)
494 ICOM_THIS_MULTI(VfwCapture, IAMVideoProcAmp_vtbl, iface);
496 return IUnknown_Release((IUnknown *)This);
499 static HRESULT WINAPI
500 AMVideoProcAmp_GetRange( IAMVideoProcAmp * iface, long Property, long *pMin,
501 long *pMax, long *pSteppingDelta, long *pDefault, long *pCapsFlags )
503 ICOM_THIS_MULTI(VfwCapture, IAMVideoProcAmp_vtbl, iface);
505 return qcap_driver_get_prop_range( This->driver_info, Property, pMin, pMax,
506 pSteppingDelta, pDefault, pCapsFlags );
509 static HRESULT WINAPI
510 AMVideoProcAmp_Set( IAMVideoProcAmp * iface, long Property, long lValue,
511 long Flags )
513 ICOM_THIS_MULTI(VfwCapture, IAMVideoProcAmp_vtbl, iface);
515 return qcap_driver_set_prop(This->driver_info, Property, lValue, Flags);
518 static HRESULT WINAPI
519 AMVideoProcAmp_Get( IAMVideoProcAmp * iface, long Property, long *lValue,
520 long *Flags )
522 ICOM_THIS_MULTI(VfwCapture, IAMVideoProcAmp_vtbl, iface);
524 return qcap_driver_get_prop(This->driver_info, Property, lValue, Flags);
527 static const IAMVideoProcAmpVtbl IAMVideoProcAmp_VTable =
529 AMVideoProcAmp_QueryInterface,
530 AMVideoProcAmp_AddRef,
531 AMVideoProcAmp_Release,
532 AMVideoProcAmp_GetRange,
533 AMVideoProcAmp_Set,
534 AMVideoProcAmp_Get,
537 static HRESULT WINAPI
538 PPB_QueryInterface( IPersistPropertyBag * iface, REFIID riid, LPVOID * ppv )
540 if (IsEqualIID(riid, &IID_IUnknown) ||
541 IsEqualIID(riid, &IID_IPersist) ||
542 IsEqualIID(riid, &IID_IPersistPropertyBag))
544 IPersistPropertyBag_AddRef(iface);
545 *ppv = iface;
546 return S_OK;
548 if (IsEqualIID(riid, &IID_IBaseFilter))
550 /* FIXME: native devenum asks for IBaseFilter, should we return it? */
551 IPersistPropertyBag_AddRef(iface);
552 *ppv = iface;
553 return S_OK;
556 FIXME("No interface for iid %s\n", debugstr_guid(riid));
557 return E_NOINTERFACE;
560 static ULONG WINAPI PPB_AddRef(IPersistPropertyBag * iface)
562 ICOM_THIS_MULTI(VfwCapture, IPersistPropertyBag_vtbl, iface);
564 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
566 return IUnknown_AddRef((IUnknown *)This);
569 static ULONG WINAPI PPB_Release(IPersistPropertyBag * iface)
571 ICOM_THIS_MULTI(VfwCapture, IPersistPropertyBag_vtbl, iface);
573 TRACE("%p --> Forwarding to VfwCapture (%p)\n", iface, This);
575 return IUnknown_Release((IUnknown *)This);
578 static HRESULT WINAPI
579 PPB_GetClassID( IPersistPropertyBag * iface, CLSID * pClassID )
581 ICOM_THIS_MULTI(VfwCapture, IPersistPropertyBag_vtbl, iface);
583 FIXME("%p - stub\n", This);
585 return E_NOTIMPL;
588 static HRESULT WINAPI PPB_InitNew(IPersistPropertyBag * iface)
590 ICOM_THIS_MULTI(VfwCapture, IPersistPropertyBag_vtbl, iface);
592 FIXME("%p - stub\n", This);
594 return E_NOTIMPL;
597 static HRESULT WINAPI
598 PPB_Load( IPersistPropertyBag * iface, IPropertyBag *pPropBag,
599 IErrorLog *pErrorLog )
601 ICOM_THIS_MULTI(VfwCapture, IPersistPropertyBag_vtbl, iface);
602 HRESULT hr;
603 VARIANT var;
604 const OLECHAR VFWIndex[] = {'V','F','W','I','n','d','e','x',0};
606 TRACE("%p/%p-> (%p, %p)\n", iface, This, pPropBag, pErrorLog);
608 V_VT(&var) = VT_I4;
609 hr = IPropertyBag_Read(pPropBag, (LPCOLESTR)VFWIndex, &var, pErrorLog);
611 if (SUCCEEDED(hr))
613 VfwPinImpl *pin;
615 This->driver_info = qcap_driver_init( This->pOutputPin,
616 var.__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.ulVal );
617 if (This->driver_info)
619 pin = (VfwPinImpl *)This->pOutputPin;
620 pin->driver_info = This->driver_info;
621 pin->parent = This;
622 This->init = TRUE;
623 hr = S_OK;
625 else
626 hr = E_FAIL;
629 return hr;
632 static HRESULT WINAPI
633 PPB_Save( IPersistPropertyBag * iface, IPropertyBag *pPropBag,
634 BOOL fClearDirty, BOOL fSaveAllProperties )
636 ICOM_THIS_MULTI(VfwCapture, IPersistPropertyBag_vtbl, iface);
637 FIXME("%p - stub\n", This);
638 return E_NOTIMPL;
641 static const IPersistPropertyBagVtbl IPersistPropertyBag_VTable =
643 PPB_QueryInterface,
644 PPB_AddRef,
645 PPB_Release,
646 PPB_GetClassID,
647 PPB_InitNew,
648 PPB_Load,
649 PPB_Save
652 /* IKsPropertySet interface */
653 static HRESULT WINAPI
654 KSP_QueryInterface( IKsPropertySet * iface, REFIID riid, LPVOID * ppv )
656 if (IsEqualIID(riid, &IID_IUnknown) ||
657 IsEqualIID(riid, &IID_IKsPropertySet))
659 *ppv = (LPVOID)iface;
660 IKsPropertySet_AddRef( iface );
661 return S_OK;
664 FIXME("No interface for iid %s\n", debugstr_guid(riid));
665 return E_NOINTERFACE;
668 static ULONG WINAPI KSP_AddRef(IKsPropertySet * iface)
670 ICOM_THIS_MULTI(VfwPinImpl, KSP_VT, iface);
672 TRACE("%p --> Forwarding to VfwPin (%p)\n", iface, This);
674 return IUnknown_AddRef((IUnknown *)This);
677 static ULONG WINAPI KSP_Release(IKsPropertySet * iface)
679 ICOM_THIS_MULTI(VfwPinImpl, KSP_VT, iface);
681 TRACE("%p --> Forwarding to VfwPin (%p)\n", iface, This);
683 return IUnknown_Release((IUnknown *)This);
686 static HRESULT WINAPI
687 KSP_Set( IKsPropertySet * iface, REFGUID guidPropSet, DWORD dwPropID,
688 LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData,
689 DWORD cbPropData )
691 FIXME("%p: stub\n", iface);
692 return E_NOTIMPL;
695 static HRESULT WINAPI
696 KSP_Get( IKsPropertySet * iface, REFGUID guidPropSet, DWORD dwPropID,
697 LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData,
698 DWORD cbPropData, DWORD *pcbReturned )
700 LPGUID pGuid;
702 TRACE("()\n");
704 if (!IsEqualIID(guidPropSet, &AMPROPSETID_Pin))
705 return E_PROP_SET_UNSUPPORTED;
706 if (pPropData == NULL && pcbReturned == NULL)
707 return E_POINTER;
708 if (pcbReturned)
709 *pcbReturned = sizeof(GUID);
710 if (pPropData == NULL)
711 return S_OK;
712 if (cbPropData < sizeof(GUID))
713 return E_UNEXPECTED;
714 pGuid = pPropData;
715 *pGuid = PIN_CATEGORY_PREVIEW;
716 FIXME("() Not adding a pin with PIN_CATEGORY_CAPTURE\n");
717 return S_OK;
720 static HRESULT WINAPI
721 KSP_QuerySupported( IKsPropertySet * iface, REFGUID guidPropSet,
722 DWORD dwPropID, DWORD *pTypeSupport )
724 FIXME("%p: stub\n", iface);
725 return E_NOTIMPL;
728 static const IKsPropertySetVtbl KSP_VTable =
730 KSP_QueryInterface,
731 KSP_AddRef,
732 KSP_Release,
733 KSP_Set,
734 KSP_Get,
735 KSP_QuerySupported
738 static HRESULT
739 VfwPin_Construct( IBaseFilter * pBaseFilter, LPCRITICAL_SECTION pCritSec,
740 IPin ** ppPin )
742 static const WCHAR wszOutputPinName[] = { 'O','u','t','p','u','t',0 };
743 ALLOCATOR_PROPERTIES ap;
744 VfwPinImpl * pPinImpl;
745 PIN_INFO piOutput;
746 HRESULT hr;
748 pPinImpl = CoTaskMemAlloc( sizeof(*pPinImpl) );
749 if (!pPinImpl)
750 return E_OUTOFMEMORY;
752 /* What we put here doesn't matter, the
753 driver function should override it then commit */
754 ap.cBuffers = 3;
755 ap.cbBuffer = 230400;
756 ap.cbAlign = 1;
757 ap.cbPrefix = 0;
759 piOutput.dir = PINDIR_OUTPUT;
760 piOutput.pFilter = pBaseFilter;
761 lstrcpyW(piOutput.achName, wszOutputPinName);
762 ObjectRefCount(TRUE);
764 hr = OutputPin_Init(&piOutput, &ap, pBaseFilter, NULL, pCritSec, &pPinImpl->pin);
765 if (SUCCEEDED(hr))
767 pPinImpl->KSP_VT = &KSP_VTable;
768 pPinImpl->pin.pin.lpVtbl = &VfwPin_Vtbl;
769 *ppPin = (IPin *)(&pPinImpl->pin.pin.lpVtbl);
770 return S_OK;
773 CoTaskMemFree(pPinImpl);
774 return E_FAIL;
777 static HRESULT WINAPI VfwPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
779 VfwPinImpl *This = (VfwPinImpl *)iface;
781 TRACE("%s %p\n", debugstr_guid(riid), ppv);
783 *ppv = NULL;
784 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin))
785 *ppv = (LPVOID)This;
786 else if (IsEqualIID(riid, &IID_IKsPropertySet))
787 *ppv = (LPVOID)&(This->KSP_VT);
788 else if (IsEqualIID(riid, &IID_IAMStreamConfig))
789 return IUnknown_QueryInterface((IUnknown *)This->parent, riid, ppv);
791 if (*ppv)
793 IUnknown_AddRef((IUnknown *)(*ppv));
794 return S_OK;
797 FIXME("No interface for %s!\n", debugstr_guid(riid));
798 return E_NOINTERFACE;
801 static ULONG WINAPI VfwPin_AddRef(IPin * iface)
803 VfwPinImpl *This = (VfwPinImpl *)iface;
804 ULONG refCount = InterlockedIncrement(&This->pin.pin.refCount);
806 TRACE("() -> new refcount: %u\n", refCount);
808 return refCount;
811 static ULONG WINAPI
812 VfwPin_Release(IPin * iface)
814 VfwPinImpl *This = (VfwPinImpl *)iface;
815 ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
817 TRACE("() -> new refcount: %u\n", refCount);
819 if (!refCount)
821 CoTaskMemFree(This);
822 ObjectRefCount(FALSE);
824 return refCount;
827 static HRESULT WINAPI
828 VfwPin_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum)
830 ENUMMEDIADETAILS emd;
831 AM_MEDIA_TYPE *pmt;
832 HRESULT hr;
834 VfwPinImpl *This = (VfwPinImpl *)iface;
835 emd.cMediaTypes = 1;
836 hr = qcap_driver_get_format(This->driver_info, &pmt);
837 emd.pMediaTypes = pmt;
838 if (SUCCEEDED(hr))
839 hr = IEnumMediaTypesImpl_Construct(&emd, ppEnum);
840 TRACE("%p -- %x\n", This, hr);
841 DeleteMediaType(pmt);
842 return hr;
845 static HRESULT WINAPI
846 VfwPin_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin)
848 TRACE("(%p)->(%p, %p)\n", iface, apPin, cPin);
849 return E_NOTIMPL;
852 static HRESULT WINAPI VfwPin_EndOfStream(IPin * iface)
854 TRACE("()\n");
855 return E_UNEXPECTED;
858 static HRESULT WINAPI VfwPin_BeginFlush(IPin * iface)
860 TRACE("(%p)->()\n", iface);
861 return E_UNEXPECTED;
864 static HRESULT WINAPI VfwPin_EndFlush(IPin * iface)
866 TRACE("(%p)->()\n", iface);
867 return E_UNEXPECTED;
870 static HRESULT WINAPI
871 VfwPin_NewSegment(IPin * iface, REFERENCE_TIME tStart,
872 REFERENCE_TIME tStop, double dRate)
874 TRACE("(%p)->(%s, %s, %e)\n", iface, wine_dbgstr_longlong(tStart),
875 wine_dbgstr_longlong(tStop), dRate);
876 return E_UNEXPECTED;
879 static const IPinVtbl VfwPin_Vtbl =
881 VfwPin_QueryInterface,
882 VfwPin_AddRef,
883 VfwPin_Release,
884 OutputPin_Connect,
885 OutputPin_ReceiveConnection,
886 OutputPin_Disconnect,
887 IPinImpl_ConnectedTo,
888 IPinImpl_ConnectionMediaType,
889 IPinImpl_QueryPinInfo,
890 IPinImpl_QueryDirection,
891 IPinImpl_QueryId,
892 IPinImpl_QueryAccept,
893 VfwPin_EnumMediaTypes,
894 VfwPin_QueryInternalConnections,
895 VfwPin_EndOfStream,
896 VfwPin_BeginFlush,
897 VfwPin_EndFlush,
898 VfwPin_NewSegment