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"
29 #include "wine/unicode.h"
30 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
39 static const WCHAR wcsInputPinName
[] = {'i','n','p','u','t',' ','p','i','n',0};
40 static const IBaseFilterVtbl Parser_Vtbl
;
41 static const IMediaSeekingVtbl Parser_Seeking_Vtbl
;
42 static const IPinVtbl Parser_OutputPin_Vtbl
;
43 static const IPinVtbl Parser_InputPin_Vtbl
;
45 static HRESULT
Parser_OutputPin_QueryAccept(LPVOID iface
, const AM_MEDIA_TYPE
* pmt
);
46 static HRESULT
Parser_ChangeStart(LPVOID iface
);
47 static HRESULT
Parser_ChangeStop(LPVOID iface
);
48 static HRESULT
Parser_ChangeRate(LPVOID iface
);
50 static HRESULT
Parser_InputPin_Construct(const PIN_INFO
* pPinInfo
, SAMPLEPROC pSampleProc
, LPVOID pUserData
, QUERYACCEPTPROC pQueryAccept
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
);
52 static inline Parser_OutputPin
*impl_from_IMediaSeeking( IMediaSeeking
*iface
)
54 return (Parser_OutputPin
*)((char*)iface
- FIELD_OFFSET(Parser_OutputPin
, mediaSeeking
.lpVtbl
));
58 HRESULT
Parser_Create(ParserImpl
* pParser
, const CLSID
* pClsid
, PFN_PROCESS_SAMPLE fnProcessSample
, PFN_QUERY_ACCEPT fnQueryAccept
, PFN_PRE_CONNECT fnPreConnect
, PFN_CLEANUP fnCleanup
)
63 /* pTransformFilter is already allocated */
64 pParser
->clsid
= *pClsid
;
66 pParser
->lpVtbl
= &Parser_Vtbl
;
67 pParser
->refCount
= 1;
68 InitializeCriticalSection(&pParser
->csFilter
);
69 pParser
->csFilter
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ParserImpl.csFilter");
70 pParser
->state
= State_Stopped
;
71 pParser
->pClock
= NULL
;
72 pParser
->fnCleanup
= fnCleanup
;
73 ZeroMemory(&pParser
->filterInfo
, sizeof(FILTER_INFO
));
75 pParser
->cStreams
= 0;
76 pParser
->ppPins
= CoTaskMemAlloc(1 * sizeof(IPin
*));
78 /* construct input pin */
79 piInput
.dir
= PINDIR_INPUT
;
80 piInput
.pFilter
= (IBaseFilter
*)pParser
;
81 lstrcpynW(piInput
.achName
, wcsInputPinName
, sizeof(piInput
.achName
) / sizeof(piInput
.achName
[0]));
83 hr
= Parser_InputPin_Construct(&piInput
, fnProcessSample
, (LPVOID
)pParser
, fnQueryAccept
, &pParser
->csFilter
, (IPin
**)&pParser
->pInputPin
);
87 pParser
->ppPins
[0] = (IPin
*)pParser
->pInputPin
;
88 pParser
->pInputPin
->fnPreConnect
= fnPreConnect
;
92 CoTaskMemFree(pParser
->ppPins
);
93 pParser
->csFilter
.DebugInfo
->Spare
[0] = 0;
94 DeleteCriticalSection(&pParser
->csFilter
);
95 CoTaskMemFree(pParser
);
101 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
)
103 pPinImpl
->pmt
= CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
));
104 CopyMediaType(pPinImpl
->pmt
, pmt
);
105 pPinImpl
->dwSamplesProcessed
= 0;
106 pPinImpl
->dwSampleSize
= 0;
107 pPinImpl
->fSamplesPerSec
= fSamplesPerSec
;
109 MediaSeekingImpl_Init((LPVOID
)pPinInfo
->pFilter
, Parser_ChangeStop
, Parser_ChangeStart
, Parser_ChangeRate
, &pPinImpl
->mediaSeeking
);
110 pPinImpl
->mediaSeeking
.lpVtbl
= &Parser_Seeking_Vtbl
;
112 return OutputPin_Init(pPinInfo
, props
, pUserData
, pQueryAccept
, pCritSec
, &pPinImpl
->pin
);
115 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
)
117 Parser_OutputPin
* pPinImpl
;
121 assert(pPinInfo
->dir
== PINDIR_OUTPUT
);
123 pPinImpl
= CoTaskMemAlloc(sizeof(Parser_OutputPin
));
126 return E_OUTOFMEMORY
;
128 if (SUCCEEDED(Parser_OutputPin_Init(pPinInfo
, props
, pUserData
, pQueryAccept
, pmt
, fSamplesPerSec
, pCritSec
, pPinImpl
)))
130 pPinImpl
->pin
.pin
.lpVtbl
= &Parser_OutputPin_Vtbl
;
132 *ppPin
= (IPin
*)pPinImpl
;
136 CoTaskMemFree(pPinImpl
);
140 static HRESULT WINAPI
Parser_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
142 ParserImpl
*This
= (ParserImpl
*)iface
;
143 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
147 if (IsEqualIID(riid
, &IID_IUnknown
))
149 else if (IsEqualIID(riid
, &IID_IPersist
))
151 else if (IsEqualIID(riid
, &IID_IMediaFilter
))
153 else if (IsEqualIID(riid
, &IID_IBaseFilter
))
158 IUnknown_AddRef((IUnknown
*)(*ppv
));
162 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
164 return E_NOINTERFACE
;
167 static ULONG WINAPI
Parser_AddRef(IBaseFilter
* iface
)
169 ParserImpl
*This
= (ParserImpl
*)iface
;
170 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
172 TRACE("(%p/%p)->() AddRef from %d\n", This
, iface
, refCount
- 1);
177 static ULONG WINAPI
Parser_Release(IBaseFilter
* iface
)
179 ParserImpl
*This
= (ParserImpl
*)iface
;
180 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
182 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
189 This
->fnCleanup(This
);
192 IReferenceClock_Release(This
->pClock
);
194 for (i
= 0; i
< This
->cStreams
+ 1; i
++)
198 if (SUCCEEDED(IPin_ConnectedTo(This
->ppPins
[i
], &pConnectedTo
)))
200 IPin_Disconnect(pConnectedTo
);
201 IPin_Release(pConnectedTo
);
203 IPin_Disconnect(This
->ppPins
[i
]);
205 IPin_Release(This
->ppPins
[i
]);
208 CoTaskMemFree(This
->ppPins
);
211 This
->csFilter
.DebugInfo
->Spare
[0] = 0;
212 DeleteCriticalSection(&This
->csFilter
);
214 TRACE("Destroying parser\n");
223 /** IPersist methods **/
225 static HRESULT WINAPI
Parser_GetClassID(IBaseFilter
* iface
, CLSID
* pClsid
)
227 ParserImpl
*This
= (ParserImpl
*)iface
;
229 TRACE("(%p)\n", pClsid
);
231 *pClsid
= This
->clsid
;
236 /** IMediaFilter methods **/
238 static HRESULT WINAPI
Parser_Stop(IBaseFilter
* iface
)
241 ParserImpl
*This
= (ParserImpl
*)iface
;
245 EnterCriticalSection(&This
->csFilter
);
247 if (This
->state
== State_Stopped
)
249 LeaveCriticalSection(&This
->csFilter
);
252 hr
= PullPin_StopProcessing(This
->pInputPin
);
253 This
->state
= State_Stopped
;
255 LeaveCriticalSection(&This
->csFilter
);
260 static HRESULT WINAPI
Parser_Pause(IBaseFilter
* iface
)
264 ParserImpl
*This
= (ParserImpl
*)iface
;
268 EnterCriticalSection(&This
->csFilter
);
270 if (This
->state
== State_Paused
)
272 LeaveCriticalSection(&This
->csFilter
);
275 bInit
= (This
->state
== State_Stopped
);
276 This
->state
= State_Paused
;
278 LeaveCriticalSection(&This
->csFilter
);
284 hr
= PullPin_Seek(This
->pInputPin
, 0, ((LONGLONG
)0x7fffffff << 32) | 0xffffffff);
287 hr
= PullPin_InitProcessing(This
->pInputPin
);
291 for (i
= 1; i
< This
->cStreams
+ 1; i
++)
293 Parser_OutputPin
* StreamPin
= (Parser_OutputPin
*)This
->ppPins
[i
];
294 OutputPin_DeliverNewSegment((OutputPin
*)This
->ppPins
[i
], 0, (LONGLONG
)ceil(10000000.0 * (float)StreamPin
->dwLength
/ StreamPin
->fSamplesPerSec
), 1.0);
295 StreamPin
->mediaSeeking
.llDuration
= (LONGLONG
)ceil(10000000.0 * (float)StreamPin
->dwLength
/ StreamPin
->fSamplesPerSec
);
296 StreamPin
->mediaSeeking
.llStop
= (LONGLONG
)ceil(10000000.0 * (float)StreamPin
->dwLength
/ StreamPin
->fSamplesPerSec
);
297 OutputPin_CommitAllocator((OutputPin
*)This
->ppPins
[i
]);
300 /* FIXME: this is a little hacky: we have to deliver (at least?) one sample
301 * to each renderer before they will complete their transitions. We should probably
302 * seek through the stream for the first of each, rather than do it this way which is
303 * probably a bit prone to deadlocking */
304 hr
= PullPin_StartProcessing(This
->pInputPin
);
307 /* FIXME: else pause thread */
310 hr
= PullPin_PauseProcessing(This
->pInputPin
);
315 static HRESULT WINAPI
Parser_Run(IBaseFilter
* iface
, REFERENCE_TIME tStart
)
318 ParserImpl
*This
= (ParserImpl
*)iface
;
321 TRACE("(%s)\n", wine_dbgstr_longlong(tStart
));
323 EnterCriticalSection(&This
->csFilter
);
325 if (This
->state
== State_Running
)
327 LeaveCriticalSection(&This
->csFilter
);
331 This
->rtStreamStart
= tStart
;
333 hr
= PullPin_Seek(This
->pInputPin
, tStart
, ((LONGLONG
)0x7fffffff << 32) | 0xffffffff);
335 if (SUCCEEDED(hr
) && (This
->state
== State_Stopped
))
337 hr
= PullPin_InitProcessing(This
->pInputPin
);
341 for (i
= 1; i
< (This
->cStreams
+ 1); i
++)
343 OutputPin_CommitAllocator((OutputPin
*)This
->ppPins
[i
]);
349 hr
= PullPin_StartProcessing(This
->pInputPin
);
352 This
->state
= State_Running
;
354 LeaveCriticalSection(&This
->csFilter
);
359 static HRESULT WINAPI
Parser_GetState(IBaseFilter
* iface
, DWORD dwMilliSecsTimeout
, FILTER_STATE
*pState
)
361 ParserImpl
*This
= (ParserImpl
*)iface
;
363 TRACE("(%d, %p)\n", dwMilliSecsTimeout
, pState
);
365 EnterCriticalSection(&This
->csFilter
);
367 *pState
= This
->state
;
369 LeaveCriticalSection(&This
->csFilter
);
371 /* FIXME: this is a little bit unsafe, but I don't see that we can do this
372 * while in the critical section. Maybe we could copy the pointer and addref in the
373 * critical section and then release after this.
375 if (This
->pInputPin
&& (PullPin_WaitForStateChange(This
->pInputPin
, dwMilliSecsTimeout
) == S_FALSE
))
376 return VFW_S_STATE_INTERMEDIATE
;
381 static HRESULT WINAPI
Parser_SetSyncSource(IBaseFilter
* iface
, IReferenceClock
*pClock
)
383 ParserImpl
*This
= (ParserImpl
*)iface
;
385 TRACE("(%p)\n", pClock
);
387 EnterCriticalSection(&This
->csFilter
);
390 IReferenceClock_Release(This
->pClock
);
391 This
->pClock
= pClock
;
393 IReferenceClock_AddRef(This
->pClock
);
395 LeaveCriticalSection(&This
->csFilter
);
400 static HRESULT WINAPI
Parser_GetSyncSource(IBaseFilter
* iface
, IReferenceClock
**ppClock
)
402 ParserImpl
*This
= (ParserImpl
*)iface
;
404 TRACE("(%p)\n", ppClock
);
406 EnterCriticalSection(&This
->csFilter
);
408 *ppClock
= This
->pClock
;
410 IReferenceClock_AddRef(This
->pClock
);
412 LeaveCriticalSection(&This
->csFilter
);
417 /** IBaseFilter implementation **/
419 static HRESULT WINAPI
Parser_EnumPins(IBaseFilter
* iface
, IEnumPins
**ppEnum
)
422 ParserImpl
*This
= (ParserImpl
*)iface
;
424 TRACE("(%p)\n", ppEnum
);
426 epd
.cPins
= This
->cStreams
+ 1; /* +1 for input pin */
427 epd
.ppPins
= This
->ppPins
;
428 return IEnumPinsImpl_Construct(&epd
, ppEnum
);
431 static HRESULT WINAPI
Parser_FindPin(IBaseFilter
* iface
, LPCWSTR Id
, IPin
**ppPin
)
433 FIXME("(%p)->(%s,%p)\n", iface
, debugstr_w(Id
), ppPin
);
435 /* FIXME: critical section */
440 static HRESULT WINAPI
Parser_QueryFilterInfo(IBaseFilter
* iface
, FILTER_INFO
*pInfo
)
442 ParserImpl
*This
= (ParserImpl
*)iface
;
444 TRACE("(%p)\n", pInfo
);
446 strcpyW(pInfo
->achName
, This
->filterInfo
.achName
);
447 pInfo
->pGraph
= This
->filterInfo
.pGraph
;
450 IFilterGraph_AddRef(pInfo
->pGraph
);
455 static HRESULT WINAPI
Parser_JoinFilterGraph(IBaseFilter
* iface
, IFilterGraph
*pGraph
, LPCWSTR pName
)
458 ParserImpl
*This
= (ParserImpl
*)iface
;
460 TRACE("(%p, %s)\n", pGraph
, debugstr_w(pName
));
462 EnterCriticalSection(&This
->csFilter
);
465 strcpyW(This
->filterInfo
.achName
, pName
);
467 *This
->filterInfo
.achName
= '\0';
468 This
->filterInfo
.pGraph
= pGraph
; /* NOTE: do NOT increase ref. count */
470 LeaveCriticalSection(&This
->csFilter
);
475 static HRESULT WINAPI
Parser_QueryVendorInfo(IBaseFilter
* iface
, LPWSTR
*pVendorInfo
)
477 TRACE("(%p)\n", pVendorInfo
);
481 static const IBaseFilterVtbl Parser_Vtbl
=
483 Parser_QueryInterface
,
491 Parser_SetSyncSource
,
492 Parser_GetSyncSource
,
495 Parser_QueryFilterInfo
,
496 Parser_JoinFilterGraph
,
497 Parser_QueryVendorInfo
500 HRESULT
Parser_AddPin(ParserImpl
* This
, const PIN_INFO
* piOutput
, ALLOCATOR_PROPERTIES
* props
,
501 const AM_MEDIA_TYPE
* amt
, float fSamplesPerSec
, DWORD dwSampleSize
, DWORD dwLength
)
506 ppOldPins
= This
->ppPins
;
508 This
->ppPins
= CoTaskMemAlloc((This
->cStreams
+ 2) * sizeof(IPin
*));
509 memcpy(This
->ppPins
, ppOldPins
, (This
->cStreams
+ 1) * sizeof(IPin
*));
511 hr
= Parser_OutputPin_Construct(piOutput
, props
, NULL
, Parser_OutputPin_QueryAccept
, amt
, fSamplesPerSec
, &This
->csFilter
, This
->ppPins
+ This
->cStreams
+ 1);
515 ((Parser_OutputPin
*)(This
->ppPins
[This
->cStreams
+ 1]))->dwSampleSize
= dwSampleSize
;
516 ((Parser_OutputPin
*)(This
->ppPins
[This
->cStreams
+ 1]))->dwLength
= dwLength
;
517 ((Parser_OutputPin
*)(This
->ppPins
[This
->cStreams
+ 1]))->pin
.pin
.pUserData
= (LPVOID
)This
->ppPins
[This
->cStreams
+ 1];
519 CoTaskMemFree(ppOldPins
);
523 CoTaskMemFree(This
->ppPins
);
524 This
->ppPins
= ppOldPins
;
525 ERR("Failed with error %x\n", hr
);
531 static HRESULT
Parser_RemoveOutputPins(ParserImpl
* This
)
533 /* NOTE: should be in critical section when calling this function */
536 IPin
** ppOldPins
= This
->ppPins
;
538 /* reduce the pin array down to 1 (just our input pin) */
539 This
->ppPins
= CoTaskMemAlloc(sizeof(IPin
*) * 1);
540 memcpy(This
->ppPins
, ppOldPins
, sizeof(IPin
*) * 1);
542 for (i
= 0; i
< This
->cStreams
; i
++)
544 OutputPin_DeliverDisconnect((OutputPin
*)ppOldPins
[i
+ 1]);
545 IPin_Release(ppOldPins
[i
+ 1]);
549 CoTaskMemFree(ppOldPins
);
554 static HRESULT
Parser_ChangeStart(LPVOID iface
)
556 FIXME("(%p)\n", iface
);
560 static HRESULT
Parser_ChangeStop(LPVOID iface
)
562 FIXME("(%p)\n", iface
);
566 static HRESULT
Parser_ChangeRate(LPVOID iface
)
568 FIXME("(%p)\n", iface
);
573 static HRESULT WINAPI
Parser_Seeking_QueryInterface(IMediaSeeking
* iface
, REFIID riid
, LPVOID
* ppv
)
575 Parser_OutputPin
*This
= impl_from_IMediaSeeking(iface
);
577 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
580 static ULONG WINAPI
Parser_Seeking_AddRef(IMediaSeeking
* iface
)
582 Parser_OutputPin
*This
= impl_from_IMediaSeeking(iface
);
584 return IUnknown_AddRef((IUnknown
*)This
);
587 static ULONG WINAPI
Parser_Seeking_Release(IMediaSeeking
* iface
)
589 Parser_OutputPin
*This
= impl_from_IMediaSeeking(iface
);
591 return IUnknown_Release((IUnknown
*)This
);
594 static const IMediaSeekingVtbl Parser_Seeking_Vtbl
=
596 Parser_Seeking_QueryInterface
,
597 Parser_Seeking_AddRef
,
598 Parser_Seeking_Release
,
599 MediaSeekingImpl_GetCapabilities
,
600 MediaSeekingImpl_CheckCapabilities
,
601 MediaSeekingImpl_IsFormatSupported
,
602 MediaSeekingImpl_QueryPreferredFormat
,
603 MediaSeekingImpl_GetTimeFormat
,
604 MediaSeekingImpl_IsUsingTimeFormat
,
605 MediaSeekingImpl_SetTimeFormat
,
606 MediaSeekingImpl_GetDuration
,
607 MediaSeekingImpl_GetStopPosition
,
608 MediaSeekingImpl_GetCurrentPosition
,
609 MediaSeekingImpl_ConvertTimeFormat
,
610 MediaSeekingImpl_SetPositions
,
611 MediaSeekingImpl_GetPositions
,
612 MediaSeekingImpl_GetAvailable
,
613 MediaSeekingImpl_SetRate
,
614 MediaSeekingImpl_GetRate
,
615 MediaSeekingImpl_GetPreroll
618 static HRESULT WINAPI
Parser_OutputPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
620 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
622 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
626 if (IsEqualIID(riid
, &IID_IUnknown
))
627 *ppv
= (LPVOID
)iface
;
628 else if (IsEqualIID(riid
, &IID_IPin
))
629 *ppv
= (LPVOID
)iface
;
630 else if (IsEqualIID(riid
, &IID_IMediaSeeking
))
631 *ppv
= (LPVOID
)&This
->mediaSeeking
;
635 IUnknown_AddRef((IUnknown
*)(*ppv
));
639 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
641 return E_NOINTERFACE
;
644 static ULONG WINAPI
Parser_OutputPin_Release(IPin
* iface
)
646 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
647 ULONG refCount
= InterlockedDecrement(&This
->pin
.pin
.refCount
);
649 TRACE("(%p)->() Release from %d\n", iface
, refCount
+ 1);
653 FreeMediaType(This
->pmt
);
654 CoTaskMemFree(This
->pmt
);
655 FreeMediaType(&This
->pin
.pin
.mtCurrent
);
662 static HRESULT WINAPI
Parser_OutputPin_EnumMediaTypes(IPin
* iface
, IEnumMediaTypes
** ppEnum
)
664 ENUMMEDIADETAILS emd
;
665 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
667 TRACE("(%p)\n", ppEnum
);
669 /* override this method to allow enumeration of your types */
671 emd
.pMediaTypes
= This
->pmt
;
673 return IEnumMediaTypesImpl_Construct(&emd
, ppEnum
);
676 static HRESULT
Parser_OutputPin_QueryAccept(LPVOID iface
, const AM_MEDIA_TYPE
* pmt
)
678 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
681 dump_AM_MEDIA_TYPE(pmt
);
683 return (memcmp(This
->pmt
, pmt
, sizeof(AM_MEDIA_TYPE
)) == 0);
686 static const IPinVtbl Parser_OutputPin_Vtbl
=
688 Parser_OutputPin_QueryInterface
,
690 Parser_OutputPin_Release
,
692 OutputPin_ReceiveConnection
,
693 OutputPin_Disconnect
,
694 IPinImpl_ConnectedTo
,
695 IPinImpl_ConnectionMediaType
,
696 IPinImpl_QueryPinInfo
,
697 IPinImpl_QueryDirection
,
699 IPinImpl_QueryAccept
,
700 Parser_OutputPin_EnumMediaTypes
,
701 IPinImpl_QueryInternalConnections
,
702 OutputPin_EndOfStream
,
703 OutputPin_BeginFlush
,
708 static HRESULT
Parser_InputPin_Construct(const PIN_INFO
* pPinInfo
, SAMPLEPROC pSampleProc
, LPVOID pUserData
, QUERYACCEPTPROC pQueryAccept
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
)
714 if (pPinInfo
->dir
!= PINDIR_INPUT
)
716 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo
->dir
);
720 pPinImpl
= CoTaskMemAlloc(sizeof(*pPinImpl
));
723 return E_OUTOFMEMORY
;
725 if (SUCCEEDED(PullPin_Init(pPinInfo
, pSampleProc
, pUserData
, pQueryAccept
, pCritSec
, pPinImpl
)))
727 pPinImpl
->pin
.lpVtbl
= &Parser_InputPin_Vtbl
;
729 *ppPin
= (IPin
*)(&pPinImpl
->pin
.lpVtbl
);
733 CoTaskMemFree(pPinImpl
);
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
,