2 * Parser (Base for parsers and splitters)
4 * Copyright 2003 Robert Shearman
5 * Copyright 2004-2005 Christian Costa
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "quartz_private.h"
23 #include "control_private.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
44 static const WCHAR wcsInputPinName
[] = {'i','n','p','u','t',' ','p','i','n',0};
45 static const IBaseFilterVtbl Parser_Vtbl
;
46 static const IMediaSeekingVtbl Parser_Seeking_Vtbl
;
47 static const IPinVtbl Parser_OutputPin_Vtbl
;
48 static const IPinVtbl Parser_InputPin_Vtbl
;
50 static HRESULT
Parser_OutputPin_QueryAccept(LPVOID iface
, const AM_MEDIA_TYPE
* pmt
);
51 static HRESULT
Parser_ChangeStart(LPVOID iface
);
52 static HRESULT
Parser_ChangeStop(LPVOID iface
);
53 static HRESULT
Parser_ChangeRate(LPVOID iface
);
55 static HRESULT
Parser_InputPin_Construct(const PIN_INFO
* pPinInfo
, SAMPLEPROC pSampleProc
, LPVOID pUserData
, QUERYACCEPTPROC pQueryAccept
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
);
57 static inline Parser_OutputPin
*impl_from_IMediaSeeking( IMediaSeeking
*iface
)
59 return (Parser_OutputPin
*)((char*)iface
- FIELD_OFFSET(Parser_OutputPin
, mediaSeeking
.lpVtbl
));
63 HRESULT
Parser_Create(ParserImpl
* pParser
, const CLSID
* pClsid
, PFN_PROCESS_SAMPLE fnProcessSample
, PFN_QUERY_ACCEPT fnQueryAccept
, PFN_PRE_CONNECT fnPreConnect
, PFN_CLEANUP fnCleanup
)
68 /* pTransformFilter is already allocated */
69 pParser
->clsid
= *pClsid
;
71 pParser
->lpVtbl
= &Parser_Vtbl
;
72 pParser
->refCount
= 1;
73 InitializeCriticalSection(&pParser
->csFilter
);
74 pParser
->csFilter
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ParserImpl.csFilter");
75 pParser
->state
= State_Stopped
;
76 pParser
->pClock
= NULL
;
77 pParser
->fnCleanup
= fnCleanup
;
78 ZeroMemory(&pParser
->filterInfo
, sizeof(FILTER_INFO
));
80 pParser
->cStreams
= 0;
81 pParser
->ppPins
= CoTaskMemAlloc(1 * sizeof(IPin
*));
83 /* construct input pin */
84 piInput
.dir
= PINDIR_INPUT
;
85 piInput
.pFilter
= (IBaseFilter
*)pParser
;
86 lstrcpynW(piInput
.achName
, wcsInputPinName
, sizeof(piInput
.achName
) / sizeof(piInput
.achName
[0]));
88 hr
= Parser_InputPin_Construct(&piInput
, fnProcessSample
, (LPVOID
)pParser
, fnQueryAccept
, &pParser
->csFilter
, (IPin
**)&pParser
->pInputPin
);
92 pParser
->ppPins
[0] = (IPin
*)pParser
->pInputPin
;
93 pParser
->pInputPin
->fnPreConnect
= fnPreConnect
;
97 CoTaskMemFree(pParser
->ppPins
);
98 pParser
->csFilter
.DebugInfo
->Spare
[0] = 0;
99 DeleteCriticalSection(&pParser
->csFilter
);
100 CoTaskMemFree(pParser
);
106 static HRESULT
Parser_OutputPin_Init(const PIN_INFO
* pPinInfo
, ALLOCATOR_PROPERTIES
* props
, LPVOID pUserData
, QUERYACCEPTPROC pQueryAccept
, const AM_MEDIA_TYPE
* pmt
, float fSamplesPerSec
, LPCRITICAL_SECTION pCritSec
, Parser_OutputPin
* pPinImpl
)
108 pPinImpl
->pmt
= CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
));
109 CopyMediaType(pPinImpl
->pmt
, pmt
);
110 pPinImpl
->dwSamplesProcessed
= 0;
111 pPinImpl
->dwSampleSize
= 0;
112 pPinImpl
->fSamplesPerSec
= fSamplesPerSec
;
114 MediaSeekingImpl_Init((LPVOID
)pPinInfo
->pFilter
, Parser_ChangeStop
, Parser_ChangeStart
, Parser_ChangeRate
, &pPinImpl
->mediaSeeking
);
115 pPinImpl
->mediaSeeking
.lpVtbl
= &Parser_Seeking_Vtbl
;
117 return OutputPin_Init(pPinInfo
, props
, pUserData
, pQueryAccept
, pCritSec
, &pPinImpl
->pin
);
120 static HRESULT
Parser_OutputPin_Construct(const PIN_INFO
* pPinInfo
, ALLOCATOR_PROPERTIES
* props
, LPVOID pUserData
, QUERYACCEPTPROC pQueryAccept
, const AM_MEDIA_TYPE
* pmt
, float fSamplesPerSec
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
)
122 Parser_OutputPin
* pPinImpl
;
126 assert(pPinInfo
->dir
== PINDIR_OUTPUT
);
128 pPinImpl
= CoTaskMemAlloc(sizeof(Parser_OutputPin
));
131 return E_OUTOFMEMORY
;
133 if (SUCCEEDED(Parser_OutputPin_Init(pPinInfo
, props
, pUserData
, pQueryAccept
, pmt
, fSamplesPerSec
, pCritSec
, pPinImpl
)))
135 pPinImpl
->pin
.pin
.lpVtbl
= &Parser_OutputPin_Vtbl
;
137 *ppPin
= (IPin
*)pPinImpl
;
143 static HRESULT WINAPI
Parser_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
145 ParserImpl
*This
= (ParserImpl
*)iface
;
146 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
150 if (IsEqualIID(riid
, &IID_IUnknown
))
152 else if (IsEqualIID(riid
, &IID_IPersist
))
154 else if (IsEqualIID(riid
, &IID_IMediaFilter
))
156 else if (IsEqualIID(riid
, &IID_IBaseFilter
))
161 IUnknown_AddRef((IUnknown
*)(*ppv
));
165 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
167 return E_NOINTERFACE
;
170 static ULONG WINAPI
Parser_AddRef(IBaseFilter
* iface
)
172 ParserImpl
*This
= (ParserImpl
*)iface
;
173 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
175 TRACE("(%p/%p)->() AddRef from %d\n", This
, iface
, refCount
- 1);
180 static ULONG WINAPI
Parser_Release(IBaseFilter
* iface
)
182 ParserImpl
*This
= (ParserImpl
*)iface
;
183 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
185 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
192 This
->fnCleanup(This
);
195 IReferenceClock_Release(This
->pClock
);
197 for (i
= 0; i
< This
->cStreams
+ 1; i
++)
201 if (SUCCEEDED(IPin_ConnectedTo(This
->ppPins
[i
], &pConnectedTo
)))
203 IPin_Disconnect(pConnectedTo
);
204 IPin_Release(pConnectedTo
);
206 IPin_Disconnect(This
->ppPins
[i
]);
208 IPin_Release(This
->ppPins
[i
]);
211 CoTaskMemFree(This
->ppPins
);
214 This
->csFilter
.DebugInfo
->Spare
[0] = 0;
215 DeleteCriticalSection(&This
->csFilter
);
217 TRACE("Destroying parser\n");
226 /** IPersist methods **/
228 static HRESULT WINAPI
Parser_GetClassID(IBaseFilter
* iface
, CLSID
* pClsid
)
230 ParserImpl
*This
= (ParserImpl
*)iface
;
232 TRACE("(%p)\n", pClsid
);
234 *pClsid
= This
->clsid
;
239 /** IMediaFilter methods **/
241 static HRESULT WINAPI
Parser_Stop(IBaseFilter
* iface
)
244 ParserImpl
*This
= (ParserImpl
*)iface
;
248 EnterCriticalSection(&This
->csFilter
);
250 if (This
->state
== State_Stopped
)
252 LeaveCriticalSection(&This
->csFilter
);
255 hr
= PullPin_StopProcessing(This
->pInputPin
);
256 This
->state
= State_Stopped
;
258 LeaveCriticalSection(&This
->csFilter
);
263 static HRESULT WINAPI
Parser_Pause(IBaseFilter
* iface
)
267 ParserImpl
*This
= (ParserImpl
*)iface
;
271 EnterCriticalSection(&This
->csFilter
);
273 if (This
->state
== State_Paused
)
275 LeaveCriticalSection(&This
->csFilter
);
278 bInit
= (This
->state
== State_Stopped
);
279 This
->state
= State_Paused
;
281 LeaveCriticalSection(&This
->csFilter
);
287 hr
= PullPin_Seek(This
->pInputPin
, 0, ((LONGLONG
)0x7fffffff << 32) | 0xffffffff);
290 hr
= PullPin_InitProcessing(This
->pInputPin
);
294 for (i
= 1; i
< This
->cStreams
+ 1; i
++)
296 Parser_OutputPin
* StreamPin
= (Parser_OutputPin
*)This
->ppPins
[i
];
297 OutputPin_DeliverNewSegment((OutputPin
*)This
->ppPins
[i
], 0, (LONGLONG
)ceil(10000000.0 * (float)StreamPin
->dwLength
/ StreamPin
->fSamplesPerSec
), 1.0);
298 StreamPin
->mediaSeeking
.llDuration
= (LONGLONG
)ceil(10000000.0 * (float)StreamPin
->dwLength
/ StreamPin
->fSamplesPerSec
);
299 StreamPin
->mediaSeeking
.llStop
= (LONGLONG
)ceil(10000000.0 * (float)StreamPin
->dwLength
/ StreamPin
->fSamplesPerSec
);
300 OutputPin_CommitAllocator((OutputPin
*)This
->ppPins
[i
]);
303 /* FIXME: this is a little hacky: we have to deliver (at least?) one sample
304 * to each renderer before they will complete their transitions. We should probably
305 * seek through the stream for the first of each, rather than do it this way which is
306 * probably a bit prone to deadlocking */
307 hr
= PullPin_StartProcessing(This
->pInputPin
);
310 /* FIXME: else pause thread */
313 hr
= PullPin_PauseProcessing(This
->pInputPin
);
318 static HRESULT WINAPI
Parser_Run(IBaseFilter
* iface
, REFERENCE_TIME tStart
)
321 ParserImpl
*This
= (ParserImpl
*)iface
;
324 TRACE("(%s)\n", wine_dbgstr_longlong(tStart
));
326 EnterCriticalSection(&This
->csFilter
);
328 if (This
->state
== State_Running
)
330 LeaveCriticalSection(&This
->csFilter
);
334 This
->rtStreamStart
= tStart
;
336 hr
= PullPin_Seek(This
->pInputPin
, tStart
, ((LONGLONG
)0x7fffffff << 32) | 0xffffffff);
338 if (SUCCEEDED(hr
) && (This
->state
== State_Stopped
))
340 hr
= PullPin_InitProcessing(This
->pInputPin
);
344 for (i
= 1; i
< (This
->cStreams
+ 1); i
++)
346 OutputPin_CommitAllocator((OutputPin
*)This
->ppPins
[i
]);
352 hr
= PullPin_StartProcessing(This
->pInputPin
);
355 This
->state
= State_Running
;
357 LeaveCriticalSection(&This
->csFilter
);
362 static HRESULT WINAPI
Parser_GetState(IBaseFilter
* iface
, DWORD dwMilliSecsTimeout
, FILTER_STATE
*pState
)
364 ParserImpl
*This
= (ParserImpl
*)iface
;
366 TRACE("(%d, %p)\n", dwMilliSecsTimeout
, pState
);
368 EnterCriticalSection(&This
->csFilter
);
370 *pState
= This
->state
;
372 LeaveCriticalSection(&This
->csFilter
);
374 /* FIXME: this is a little bit unsafe, but I don't see that we can do this
375 * while in the critical section. Maybe we could copy the pointer and addref in the
376 * critical section and then release after this.
378 if (This
->pInputPin
&& (PullPin_WaitForStateChange(This
->pInputPin
, dwMilliSecsTimeout
) == S_FALSE
))
379 return VFW_S_STATE_INTERMEDIATE
;
384 static HRESULT WINAPI
Parser_SetSyncSource(IBaseFilter
* iface
, IReferenceClock
*pClock
)
386 ParserImpl
*This
= (ParserImpl
*)iface
;
388 TRACE("(%p)\n", pClock
);
390 EnterCriticalSection(&This
->csFilter
);
393 IReferenceClock_Release(This
->pClock
);
394 This
->pClock
= pClock
;
396 IReferenceClock_AddRef(This
->pClock
);
398 LeaveCriticalSection(&This
->csFilter
);
403 static HRESULT WINAPI
Parser_GetSyncSource(IBaseFilter
* iface
, IReferenceClock
**ppClock
)
405 ParserImpl
*This
= (ParserImpl
*)iface
;
407 TRACE("(%p)\n", ppClock
);
409 EnterCriticalSection(&This
->csFilter
);
411 *ppClock
= This
->pClock
;
413 IReferenceClock_AddRef(This
->pClock
);
415 LeaveCriticalSection(&This
->csFilter
);
420 /** IBaseFilter implementation **/
422 static HRESULT WINAPI
Parser_EnumPins(IBaseFilter
* iface
, IEnumPins
**ppEnum
)
425 ParserImpl
*This
= (ParserImpl
*)iface
;
427 TRACE("(%p)\n", ppEnum
);
429 epd
.cPins
= This
->cStreams
+ 1; /* +1 for input pin */
430 epd
.ppPins
= This
->ppPins
;
431 return IEnumPinsImpl_Construct(&epd
, ppEnum
);
434 static HRESULT WINAPI
Parser_FindPin(IBaseFilter
* iface
, LPCWSTR Id
, IPin
**ppPin
)
436 FIXME("(%p)->(%s,%p)\n", iface
, debugstr_w(Id
), ppPin
);
438 /* FIXME: critical section */
443 static HRESULT WINAPI
Parser_QueryFilterInfo(IBaseFilter
* iface
, FILTER_INFO
*pInfo
)
445 ParserImpl
*This
= (ParserImpl
*)iface
;
447 TRACE("(%p)\n", pInfo
);
449 strcpyW(pInfo
->achName
, This
->filterInfo
.achName
);
450 pInfo
->pGraph
= This
->filterInfo
.pGraph
;
453 IFilterGraph_AddRef(pInfo
->pGraph
);
458 static HRESULT WINAPI
Parser_JoinFilterGraph(IBaseFilter
* iface
, IFilterGraph
*pGraph
, LPCWSTR pName
)
461 ParserImpl
*This
= (ParserImpl
*)iface
;
463 TRACE("(%p, %s)\n", pGraph
, debugstr_w(pName
));
465 EnterCriticalSection(&This
->csFilter
);
468 strcpyW(This
->filterInfo
.achName
, pName
);
470 *This
->filterInfo
.achName
= '\0';
471 This
->filterInfo
.pGraph
= pGraph
; /* NOTE: do NOT increase ref. count */
473 LeaveCriticalSection(&This
->csFilter
);
478 static HRESULT WINAPI
Parser_QueryVendorInfo(IBaseFilter
* iface
, LPWSTR
*pVendorInfo
)
480 TRACE("(%p)\n", pVendorInfo
);
484 static const IBaseFilterVtbl Parser_Vtbl
=
486 Parser_QueryInterface
,
494 Parser_SetSyncSource
,
495 Parser_GetSyncSource
,
498 Parser_QueryFilterInfo
,
499 Parser_JoinFilterGraph
,
500 Parser_QueryVendorInfo
503 HRESULT
Parser_AddPin(ParserImpl
* This
, PIN_INFO
* piOutput
, ALLOCATOR_PROPERTIES
* props
, AM_MEDIA_TYPE
* amt
, float fSamplesPerSec
, DWORD dwSampleSize
, DWORD dwLength
)
508 ppOldPins
= This
->ppPins
;
510 This
->ppPins
= CoTaskMemAlloc((This
->cStreams
+ 2) * sizeof(IPin
*));
511 memcpy(This
->ppPins
, ppOldPins
, (This
->cStreams
+ 1) * sizeof(IPin
*));
513 hr
= Parser_OutputPin_Construct(piOutput
, props
, NULL
, Parser_OutputPin_QueryAccept
, amt
, fSamplesPerSec
, &This
->csFilter
, This
->ppPins
+ This
->cStreams
+ 1);
517 ((Parser_OutputPin
*)(This
->ppPins
[This
->cStreams
+ 1]))->dwSampleSize
= dwSampleSize
;
518 ((Parser_OutputPin
*)(This
->ppPins
[This
->cStreams
+ 1]))->dwLength
= dwLength
;
519 ((Parser_OutputPin
*)(This
->ppPins
[This
->cStreams
+ 1]))->pin
.pin
.pUserData
= (LPVOID
)This
->ppPins
[This
->cStreams
+ 1];
521 CoTaskMemFree(ppOldPins
);
525 CoTaskMemFree(This
->ppPins
);
526 This
->ppPins
= ppOldPins
;
527 ERR("Failed with error %x\n", hr
);
533 static HRESULT
Parser_RemoveOutputPins(ParserImpl
* This
)
535 /* NOTE: should be in critical section when calling this function */
538 IPin
** ppOldPins
= This
->ppPins
;
540 /* reduce the pin array down to 1 (just our input pin) */
541 This
->ppPins
= CoTaskMemAlloc(sizeof(IPin
*) * 1);
542 memcpy(This
->ppPins
, ppOldPins
, sizeof(IPin
*) * 1);
544 for (i
= 0; i
< This
->cStreams
; i
++)
546 OutputPin_DeliverDisconnect((OutputPin
*)ppOldPins
[i
+ 1]);
547 IPin_Release(ppOldPins
[i
+ 1]);
551 CoTaskMemFree(ppOldPins
);
556 static HRESULT
Parser_ChangeStart(LPVOID iface
)
558 FIXME("(%p)\n", iface
);
562 static HRESULT
Parser_ChangeStop(LPVOID iface
)
564 FIXME("(%p)\n", iface
);
568 static HRESULT
Parser_ChangeRate(LPVOID iface
)
570 FIXME("(%p)\n", iface
);
575 static HRESULT WINAPI
Parser_Seeking_QueryInterface(IMediaSeeking
* iface
, REFIID riid
, LPVOID
* ppv
)
577 Parser_OutputPin
*This
= impl_from_IMediaSeeking(iface
);
579 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
582 static ULONG WINAPI
Parser_Seeking_AddRef(IMediaSeeking
* iface
)
584 Parser_OutputPin
*This
= impl_from_IMediaSeeking(iface
);
586 return IUnknown_AddRef((IUnknown
*)This
);
589 static ULONG WINAPI
Parser_Seeking_Release(IMediaSeeking
* iface
)
591 Parser_OutputPin
*This
= impl_from_IMediaSeeking(iface
);
593 return IUnknown_Release((IUnknown
*)This
);
596 static const IMediaSeekingVtbl Parser_Seeking_Vtbl
=
598 Parser_Seeking_QueryInterface
,
599 Parser_Seeking_AddRef
,
600 Parser_Seeking_Release
,
601 MediaSeekingImpl_GetCapabilities
,
602 MediaSeekingImpl_CheckCapabilities
,
603 MediaSeekingImpl_IsFormatSupported
,
604 MediaSeekingImpl_QueryPreferredFormat
,
605 MediaSeekingImpl_GetTimeFormat
,
606 MediaSeekingImpl_IsUsingTimeFormat
,
607 MediaSeekingImpl_SetTimeFormat
,
608 MediaSeekingImpl_GetDuration
,
609 MediaSeekingImpl_GetStopPosition
,
610 MediaSeekingImpl_GetCurrentPosition
,
611 MediaSeekingImpl_ConvertTimeFormat
,
612 MediaSeekingImpl_SetPositions
,
613 MediaSeekingImpl_GetPositions
,
614 MediaSeekingImpl_GetAvailable
,
615 MediaSeekingImpl_SetRate
,
616 MediaSeekingImpl_GetRate
,
617 MediaSeekingImpl_GetPreroll
620 static HRESULT WINAPI
Parser_OutputPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
622 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
624 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
628 if (IsEqualIID(riid
, &IID_IUnknown
))
629 *ppv
= (LPVOID
)iface
;
630 else if (IsEqualIID(riid
, &IID_IPin
))
631 *ppv
= (LPVOID
)iface
;
632 else if (IsEqualIID(riid
, &IID_IMediaSeeking
))
633 *ppv
= (LPVOID
)&This
->mediaSeeking
;
637 IUnknown_AddRef((IUnknown
*)(*ppv
));
641 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
643 return E_NOINTERFACE
;
646 static ULONG WINAPI
Parser_OutputPin_Release(IPin
* iface
)
648 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
649 ULONG refCount
= InterlockedDecrement(&This
->pin
.pin
.refCount
);
651 TRACE("(%p)->() Release from %d\n", iface
, refCount
+ 1);
655 FreeMediaType(This
->pmt
);
656 CoTaskMemFree(This
->pmt
);
657 FreeMediaType(&This
->pin
.pin
.mtCurrent
);
664 static HRESULT WINAPI
Parser_OutputPin_EnumMediaTypes(IPin
* iface
, IEnumMediaTypes
** ppEnum
)
666 ENUMMEDIADETAILS emd
;
667 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
669 TRACE("(%p)\n", ppEnum
);
671 /* override this method to allow enumeration of your types */
673 emd
.pMediaTypes
= This
->pmt
;
675 return IEnumMediaTypesImpl_Construct(&emd
, ppEnum
);
678 static HRESULT
Parser_OutputPin_QueryAccept(LPVOID iface
, const AM_MEDIA_TYPE
* pmt
)
680 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
683 dump_AM_MEDIA_TYPE(pmt
);
685 return (memcmp(This
->pmt
, pmt
, sizeof(AM_MEDIA_TYPE
)) == 0);
688 static const IPinVtbl Parser_OutputPin_Vtbl
=
690 Parser_OutputPin_QueryInterface
,
692 Parser_OutputPin_Release
,
694 OutputPin_ReceiveConnection
,
695 OutputPin_Disconnect
,
696 IPinImpl_ConnectedTo
,
697 IPinImpl_ConnectionMediaType
,
698 IPinImpl_QueryPinInfo
,
699 IPinImpl_QueryDirection
,
701 IPinImpl_QueryAccept
,
702 Parser_OutputPin_EnumMediaTypes
,
703 IPinImpl_QueryInternalConnections
,
704 OutputPin_EndOfStream
,
705 OutputPin_BeginFlush
,
710 static HRESULT
Parser_InputPin_Construct(const PIN_INFO
* pPinInfo
, SAMPLEPROC pSampleProc
, LPVOID pUserData
, QUERYACCEPTPROC pQueryAccept
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
)
716 if (pPinInfo
->dir
!= PINDIR_INPUT
)
718 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo
->dir
);
722 pPinImpl
= CoTaskMemAlloc(sizeof(*pPinImpl
));
725 return E_OUTOFMEMORY
;
727 if (SUCCEEDED(PullPin_Init(pPinInfo
, pSampleProc
, pUserData
, pQueryAccept
, pCritSec
, pPinImpl
)))
729 pPinImpl
->pin
.lpVtbl
= &Parser_InputPin_Vtbl
;
731 *ppPin
= (IPin
*)(&pPinImpl
->pin
.lpVtbl
);
737 static HRESULT WINAPI
Parser_InputPin_Disconnect(IPin
* iface
)
740 IPinImpl
*This
= (IPinImpl
*)iface
;
744 EnterCriticalSection(This
->pCritSec
);
746 if (This
->pConnectedTo
)
750 hr
= IBaseFilter_GetState(This
->pinInfo
.pFilter
, 0, &state
);
752 if (SUCCEEDED(hr
) && (state
== State_Stopped
))
754 IPin_Release(This
->pConnectedTo
);
755 This
->pConnectedTo
= NULL
;
756 hr
= Parser_RemoveOutputPins((ParserImpl
*)This
->pinInfo
.pFilter
);
759 hr
= VFW_E_NOT_STOPPED
;
764 LeaveCriticalSection(This
->pCritSec
);
769 HRESULT WINAPI
Parser_PullPin_ReceiveConnection(IPin
* iface
, IPin
* pReceivePin
, const AM_MEDIA_TYPE
* pmt
)
775 hr
= PullPin_ReceiveConnection(iface
, pReceivePin
, pmt
);
778 IPinImpl
*This
= (IPinImpl
*)iface
;
780 EnterCriticalSection(This
->pCritSec
);
781 Parser_RemoveOutputPins((ParserImpl
*)This
->pinInfo
.pFilter
);
782 LeaveCriticalSection(This
->pCritSec
);
788 static const IPinVtbl Parser_InputPin_Vtbl
=
790 PullPin_QueryInterface
,
794 Parser_PullPin_ReceiveConnection
,
795 Parser_InputPin_Disconnect
,
796 IPinImpl_ConnectedTo
,
797 IPinImpl_ConnectionMediaType
,
798 IPinImpl_QueryPinInfo
,
799 IPinImpl_QueryDirection
,
801 IPinImpl_QueryAccept
,
802 IPinImpl_EnumMediaTypes
,
803 IPinImpl_QueryInternalConnections
,