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"
28 #include "wine/unicode.h"
29 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
38 static const WCHAR wcsInputPinName
[] = {'i','n','p','u','t',' ','p','i','n',0};
39 static const IMediaSeekingVtbl Parser_Seeking_Vtbl
;
40 static const IPinVtbl Parser_OutputPin_Vtbl
;
41 static const IPinVtbl Parser_InputPin_Vtbl
;
43 static HRESULT WINAPI
Parser_ChangeStart(IMediaSeeking
*iface
);
44 static HRESULT WINAPI
Parser_ChangeStop(IMediaSeeking
*iface
);
45 static HRESULT WINAPI
Parser_ChangeRate(IMediaSeeking
*iface
);
46 static HRESULT WINAPI
Parser_OutputPin_DecideBufferSize(BaseOutputPin
*iface
, IMemAllocator
*pAlloc
, ALLOCATOR_PROPERTIES
*ppropInputRequest
);
47 static HRESULT WINAPI
Parser_OutputPin_GetMediaType(BasePin
*iface
, int iPosition
, AM_MEDIA_TYPE
*pmt
);
48 static HRESULT WINAPI
Parser_OutputPin_DecideAllocator(BaseOutputPin
*This
, IMemInputPin
*pPin
, IMemAllocator
**pAlloc
);
49 static HRESULT WINAPI
Parser_OutputPin_BreakConnect(BaseOutputPin
*This
);
51 static inline ParserImpl
*impl_from_IMediaSeeking( IMediaSeeking
*iface
)
53 return (ParserImpl
*)((char*)iface
- FIELD_OFFSET(ParserImpl
, sourceSeeking
.lpVtbl
));
57 static IPin
* WINAPI
Parser_GetPin(BaseFilter
*iface
, int pos
)
59 ParserImpl
*This
= (ParserImpl
*)iface
;
61 TRACE("Asking for pos %x\n", pos
);
63 /* Input pin also has a pin, hence the > and not >= */
64 if (pos
> This
->cStreams
|| pos
< 0)
67 IPin_AddRef(This
->ppPins
[pos
]);
68 return This
->ppPins
[pos
];
71 static LONG WINAPI
Parser_GetPinCount(BaseFilter
*iface
)
73 ParserImpl
*This
= (ParserImpl
*)iface
;
75 return This
->cStreams
;
78 static const BaseFilterFuncTable BaseFuncTable
= {
83 HRESULT
Parser_Create(ParserImpl
* pParser
, const IBaseFilterVtbl
*Parser_Vtbl
, const CLSID
* pClsid
, PFN_PROCESS_SAMPLE fnProcessSample
, PFN_QUERY_ACCEPT fnQueryAccept
, PFN_PRE_CONNECT fnPreConnect
, PFN_CLEANUP fnCleanup
, PFN_DISCONNECT fnDisconnect
, REQUESTPROC fnRequest
, STOPPROCESSPROC fnDone
, SourceSeeking_ChangeStop stop
, SourceSeeking_ChangeStart start
, SourceSeeking_ChangeRate rate
)
88 /* pTransformFilter is already allocated */
89 BaseFilter_Init(&pParser
->filter
, Parser_Vtbl
, pClsid
, (DWORD_PTR
)(__FILE__
": ParserImpl.csFilter"), &BaseFuncTable
);
91 pParser
->fnDisconnect
= fnDisconnect
;
93 pParser
->cStreams
= 0;
94 pParser
->ppPins
= CoTaskMemAlloc(1 * sizeof(IPin
*));
96 /* construct input pin */
97 piInput
.dir
= PINDIR_INPUT
;
98 piInput
.pFilter
= (IBaseFilter
*)pParser
;
99 lstrcpynW(piInput
.achName
, wcsInputPinName
, sizeof(piInput
.achName
) / sizeof(piInput
.achName
[0]));
102 start
= Parser_ChangeStart
;
105 stop
= Parser_ChangeStop
;
108 rate
= Parser_ChangeRate
;
110 SourceSeeking_Init(&pParser
->sourceSeeking
, &Parser_Seeking_Vtbl
, stop
, start
, rate
, &pParser
->filter
.csFilter
);
112 hr
= PullPin_Construct(&Parser_InputPin_Vtbl
, &piInput
, fnProcessSample
, (LPVOID
)pParser
, fnQueryAccept
, fnCleanup
, fnRequest
, fnDone
, &pParser
->filter
.csFilter
, (IPin
**)&pParser
->pInputPin
);
116 pParser
->ppPins
[0] = (IPin
*)pParser
->pInputPin
;
117 pParser
->pInputPin
->fnPreConnect
= fnPreConnect
;
121 CoTaskMemFree(pParser
->ppPins
);
122 BaseFilterImpl_Release((IBaseFilter
*)pParser
);
123 CoTaskMemFree(pParser
);
129 HRESULT WINAPI
Parser_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
131 ParserImpl
*This
= (ParserImpl
*)iface
;
132 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
136 if ( IsEqualIID(riid
, &IID_IUnknown
)
137 || IsEqualIID(riid
, &IID_IPersist
)
138 || IsEqualIID(riid
, &IID_IMediaFilter
)
139 || IsEqualIID(riid
, &IID_IBaseFilter
) )
144 IUnknown_AddRef((IUnknown
*)(*ppv
));
148 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IVideoWindow
))
149 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
151 return E_NOINTERFACE
;
154 ULONG WINAPI
Parser_AddRef(IBaseFilter
* iface
)
156 return BaseFilterImpl_AddRef(iface
);
159 void Parser_Destroy(ParserImpl
*This
)
161 IPin
*connected
= NULL
;
164 assert(!This
->filter
.refCount
);
165 PullPin_WaitForStateChange(This
->pInputPin
, INFINITE
);
167 /* Don't need to clean up output pins, freeing input pin will do that */
168 IPin_ConnectedTo((IPin
*)This
->pInputPin
, &connected
);
171 assert(IPin_Disconnect(connected
) == S_OK
);
172 IPin_Release(connected
);
173 assert(IPin_Disconnect((IPin
*)This
->pInputPin
) == S_OK
);
175 pinref
= IPin_Release((IPin
*)This
->pInputPin
);
178 /* Valgrind could find this, if I kill it here */
179 ERR("pinref should be null, is %u, destroying anyway\n", pinref
);
180 assert((LONG
)pinref
> 0);
183 pinref
= IPin_Release((IPin
*)This
->pInputPin
);
186 CoTaskMemFree(This
->ppPins
);
188 TRACE("Destroying parser\n");
192 ULONG WINAPI
Parser_Release(IBaseFilter
* iface
)
194 ParserImpl
*This
= (ParserImpl
*)iface
;
195 ULONG refCount
= BaseFilterImpl_Release(iface
);
197 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
200 Parser_Destroy(This
);
205 /** IPersist methods **/
207 HRESULT WINAPI
Parser_GetClassID(IBaseFilter
* iface
, CLSID
* pClsid
)
209 ParserImpl
*This
= (ParserImpl
*)iface
;
211 TRACE("(%p)\n", pClsid
);
213 *pClsid
= This
->filter
.clsid
;
218 /** IMediaFilter methods **/
220 HRESULT WINAPI
Parser_Stop(IBaseFilter
* iface
)
222 ParserImpl
*This
= (ParserImpl
*)iface
;
223 PullPin
*pin
= (PullPin
*)This
->ppPins
[0];
228 EnterCriticalSection(&pin
->thread_lock
);
230 IAsyncReader_BeginFlush(This
->pInputPin
->pReader
);
231 EnterCriticalSection(&This
->filter
.csFilter
);
233 if (This
->filter
.state
== State_Stopped
)
235 LeaveCriticalSection(&This
->filter
.csFilter
);
236 IAsyncReader_EndFlush(This
->pInputPin
->pReader
);
237 LeaveCriticalSection(&pin
->thread_lock
);
241 This
->filter
.state
= State_Stopped
;
243 for (i
= 1; i
< (This
->cStreams
+ 1); i
++)
245 BaseOutputPinImpl_Inactive((BaseOutputPin
*)This
->ppPins
[i
]);
248 LeaveCriticalSection(&This
->filter
.csFilter
);
250 PullPin_PauseProcessing(This
->pInputPin
);
251 PullPin_WaitForStateChange(This
->pInputPin
, INFINITE
);
252 IAsyncReader_EndFlush(This
->pInputPin
->pReader
);
254 LeaveCriticalSection(&pin
->thread_lock
);
258 HRESULT WINAPI
Parser_Pause(IBaseFilter
* iface
)
261 ParserImpl
*This
= (ParserImpl
*)iface
;
262 PullPin
*pin
= (PullPin
*)This
->ppPins
[0];
266 EnterCriticalSection(&pin
->thread_lock
);
267 EnterCriticalSection(&This
->filter
.csFilter
);
269 if (This
->filter
.state
== State_Paused
)
271 LeaveCriticalSection(&This
->filter
.csFilter
);
272 LeaveCriticalSection(&pin
->thread_lock
);
276 if (This
->filter
.state
== State_Stopped
)
278 LeaveCriticalSection(&This
->filter
.csFilter
);
279 hr
= IBaseFilter_Run(iface
, -1);
280 EnterCriticalSection(&This
->filter
.csFilter
);
284 This
->filter
.state
= State_Paused
;
286 LeaveCriticalSection(&This
->filter
.csFilter
);
287 LeaveCriticalSection(&pin
->thread_lock
);
292 HRESULT WINAPI
Parser_Run(IBaseFilter
* iface
, REFERENCE_TIME tStart
)
295 ParserImpl
*This
= (ParserImpl
*)iface
;
296 PullPin
*pin
= (PullPin
*)This
->ppPins
[0];
300 TRACE("(%s)\n", wine_dbgstr_longlong(tStart
));
302 EnterCriticalSection(&pin
->thread_lock
);
303 EnterCriticalSection(&This
->filter
.csFilter
);
305 HRESULT hr_any
= VFW_E_NOT_CONNECTED
;
307 This
->filter
.rtStreamStart
= tStart
;
308 if (This
->filter
.state
== State_Running
|| This
->filter
.state
== State_Paused
)
310 This
->filter
.state
= State_Running
;
311 LeaveCriticalSection(&This
->filter
.csFilter
);
312 LeaveCriticalSection(&pin
->thread_lock
);
316 for (i
= 1; i
< (This
->cStreams
+ 1); i
++)
318 hr
= BaseOutputPinImpl_Active((BaseOutputPin
*)This
->ppPins
[i
]);
326 LeaveCriticalSection(&This
->filter
.csFilter
);
327 hr
= PullPin_StartProcessing(This
->pInputPin
);
328 EnterCriticalSection(&This
->filter
.csFilter
);
332 This
->filter
.state
= State_Running
;
334 LeaveCriticalSection(&This
->filter
.csFilter
);
335 LeaveCriticalSection(&pin
->thread_lock
);
340 HRESULT WINAPI
Parser_GetState(IBaseFilter
* iface
, DWORD dwMilliSecsTimeout
, FILTER_STATE
*pState
)
342 ParserImpl
*This
= (ParserImpl
*)iface
;
343 PullPin
*pin
= (PullPin
*)This
->ppPins
[0];
346 TRACE("(%d, %p)\n", dwMilliSecsTimeout
, pState
);
348 EnterCriticalSection(&pin
->thread_lock
);
349 EnterCriticalSection(&This
->filter
.csFilter
);
351 *pState
= This
->filter
.state
;
353 LeaveCriticalSection(&This
->filter
.csFilter
);
355 if (This
->pInputPin
&& (PullPin_WaitForStateChange(This
->pInputPin
, dwMilliSecsTimeout
) == S_FALSE
))
356 hr
= VFW_S_STATE_INTERMEDIATE
;
357 LeaveCriticalSection(&pin
->thread_lock
);
362 HRESULT WINAPI
Parser_SetSyncSource(IBaseFilter
* iface
, IReferenceClock
*pClock
)
364 ParserImpl
*This
= (ParserImpl
*)iface
;
365 PullPin
*pin
= (PullPin
*)This
->ppPins
[0];
367 TRACE("(%p)\n", pClock
);
369 EnterCriticalSection(&pin
->thread_lock
);
370 BaseFilterImpl_SetSyncSource(iface
,pClock
);
371 LeaveCriticalSection(&pin
->thread_lock
);
376 HRESULT WINAPI
Parser_GetSyncSource(IBaseFilter
* iface
, IReferenceClock
**ppClock
)
378 return BaseFilterImpl_GetSyncSource(iface
, ppClock
);
381 /** IBaseFilter implementation **/
383 HRESULT WINAPI
Parser_EnumPins(IBaseFilter
* iface
, IEnumPins
**ppEnum
)
385 return BaseFilterImpl_EnumPins(iface
,ppEnum
);
388 HRESULT WINAPI
Parser_FindPin(IBaseFilter
* iface
, LPCWSTR Id
, IPin
**ppPin
)
390 FIXME("(%p)->(%s,%p)\n", iface
, debugstr_w(Id
), ppPin
);
392 /* FIXME: critical section */
397 HRESULT WINAPI
Parser_QueryFilterInfo(IBaseFilter
* iface
, FILTER_INFO
*pInfo
)
399 return BaseFilterImpl_QueryFilterInfo(iface
, pInfo
);
402 HRESULT WINAPI
Parser_JoinFilterGraph(IBaseFilter
* iface
, IFilterGraph
*pGraph
, LPCWSTR pName
)
404 return BaseFilterImpl_JoinFilterGraph(iface
, pGraph
, pName
);
407 HRESULT WINAPI
Parser_QueryVendorInfo(IBaseFilter
* iface
, LPWSTR
*pVendorInfo
)
409 return BaseFilterImpl_QueryVendorInfo(iface
, pVendorInfo
);
412 static const BasePinFuncTable output_BaseFuncTable
= {
414 BaseOutputPinImpl_AttemptConnection
,
415 BasePinImpl_GetMediaTypeVersion
,
416 Parser_OutputPin_GetMediaType
419 static const BaseOutputPinFuncTable output_BaseOutputFuncTable
= {
420 Parser_OutputPin_DecideBufferSize
,
421 Parser_OutputPin_DecideAllocator
,
422 Parser_OutputPin_BreakConnect
425 HRESULT
Parser_AddPin(ParserImpl
* This
, const PIN_INFO
* piOutput
, ALLOCATOR_PROPERTIES
* props
, const AM_MEDIA_TYPE
* amt
)
430 ppOldPins
= This
->ppPins
;
432 This
->ppPins
= CoTaskMemAlloc((This
->cStreams
+ 2) * sizeof(IPin
*));
433 memcpy(This
->ppPins
, ppOldPins
, (This
->cStreams
+ 1) * sizeof(IPin
*));
435 hr
= BaseOutputPin_Construct(&Parser_OutputPin_Vtbl
, sizeof(Parser_OutputPin
), piOutput
, &output_BaseFuncTable
, &output_BaseOutputFuncTable
, &This
->filter
.csFilter
, This
->ppPins
+ (This
->cStreams
+ 1));
439 IPin
*pPin
= This
->ppPins
[This
->cStreams
+ 1];
440 Parser_OutputPin
*pin
= (Parser_OutputPin
*)pPin
;
441 pin
->pmt
= CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
));
442 CopyMediaType(pin
->pmt
, amt
);
443 pin
->dwSamplesProcessed
= 0;
445 pin
->pin
.pin
.pinInfo
.pFilter
= (LPVOID
)This
;
446 pin
->allocProps
= *props
;
448 BaseFilterImpl_IncrementPinVersion((BaseFilter
*)This
);
449 CoTaskMemFree(ppOldPins
);
453 CoTaskMemFree(This
->ppPins
);
454 This
->ppPins
= ppOldPins
;
455 ERR("Failed with error %x\n", hr
);
461 static HRESULT
Parser_RemoveOutputPins(ParserImpl
* This
)
463 /* NOTE: should be in critical section when calling this function */
466 IPin
** ppOldPins
= This
->ppPins
;
468 TRACE("(%p)\n", This
);
470 /* reduce the pin array down to 1 (just our input pin) */
471 This
->ppPins
= CoTaskMemAlloc(sizeof(IPin
*) * 1);
472 memcpy(This
->ppPins
, ppOldPins
, sizeof(IPin
*) * 1);
474 for (i
= 0; i
< This
->cStreams
; i
++)
476 hr
= ((BaseOutputPin
*)ppOldPins
[i
+ 1])->pFuncsTable
->pfnBreakConnect((BaseOutputPin
*)ppOldPins
[i
+ 1]);
477 TRACE("Disconnect: %08x\n", hr
);
478 IPin_Release(ppOldPins
[i
+ 1]);
481 BaseFilterImpl_IncrementPinVersion((BaseFilter
*)This
);
483 CoTaskMemFree(ppOldPins
);
488 static HRESULT WINAPI
Parser_ChangeStart(IMediaSeeking
*iface
)
490 FIXME("(%p) filter hasn't implemented start position change!\n", iface
);
494 static HRESULT WINAPI
Parser_ChangeStop(IMediaSeeking
*iface
)
496 FIXME("(%p) filter hasn't implemented stop position change!\n", iface
);
500 static HRESULT WINAPI
Parser_ChangeRate(IMediaSeeking
*iface
)
502 FIXME("(%p) filter hasn't implemented rate change!\n", iface
);
507 static HRESULT WINAPI
Parser_Seeking_QueryInterface(IMediaSeeking
* iface
, REFIID riid
, LPVOID
* ppv
)
509 ParserImpl
*This
= impl_from_IMediaSeeking(iface
);
511 return IUnknown_QueryInterface((IUnknown
*)This
, riid
, ppv
);
514 static ULONG WINAPI
Parser_Seeking_AddRef(IMediaSeeking
* iface
)
516 ParserImpl
*This
= impl_from_IMediaSeeking(iface
);
518 return IUnknown_AddRef((IUnknown
*)This
);
521 static ULONG WINAPI
Parser_Seeking_Release(IMediaSeeking
* iface
)
523 ParserImpl
*This
= impl_from_IMediaSeeking(iface
);
525 return IUnknown_Release((IUnknown
*)This
);
528 static const IMediaSeekingVtbl Parser_Seeking_Vtbl
=
530 Parser_Seeking_QueryInterface
,
531 Parser_Seeking_AddRef
,
532 Parser_Seeking_Release
,
533 SourceSeekingImpl_GetCapabilities
,
534 SourceSeekingImpl_CheckCapabilities
,
535 SourceSeekingImpl_IsFormatSupported
,
536 SourceSeekingImpl_QueryPreferredFormat
,
537 SourceSeekingImpl_GetTimeFormat
,
538 SourceSeekingImpl_IsUsingTimeFormat
,
539 SourceSeekingImpl_SetTimeFormat
,
540 SourceSeekingImpl_GetDuration
,
541 SourceSeekingImpl_GetStopPosition
,
542 SourceSeekingImpl_GetCurrentPosition
,
543 SourceSeekingImpl_ConvertTimeFormat
,
544 SourceSeekingImpl_SetPositions
,
545 SourceSeekingImpl_GetPositions
,
546 SourceSeekingImpl_GetAvailable
,
547 SourceSeekingImpl_SetRate
,
548 SourceSeekingImpl_GetRate
,
549 SourceSeekingImpl_GetPreroll
552 static HRESULT WINAPI
Parser_OutputPin_DecideBufferSize(BaseOutputPin
*iface
, IMemAllocator
*pAlloc
, ALLOCATOR_PROPERTIES
*ppropInputRequest
)
554 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
555 ALLOCATOR_PROPERTIES actual
;
557 if (ppropInputRequest
->cbAlign
&& ppropInputRequest
->cbAlign
!= This
->allocProps
.cbAlign
)
558 FIXME("Requested Buffer cbAlign mismatch %i,%i\n",This
->allocProps
.cbAlign
, ppropInputRequest
->cbAlign
);
559 if (ppropInputRequest
->cbPrefix
)
560 FIXME("Requested Buffer cbPrefix mismatch %i,%i\n",This
->allocProps
.cbPrefix
, ppropInputRequest
->cbPrefix
);
561 if (ppropInputRequest
->cbBuffer
)
562 FIXME("Requested Buffer cbBuffer mismatch %i,%i\n",This
->allocProps
.cbBuffer
, ppropInputRequest
->cbBuffer
);
563 if (ppropInputRequest
->cBuffers
)
564 FIXME("Requested Buffer cBuffers mismatch %i,%i\n",This
->allocProps
.cBuffers
, ppropInputRequest
->cBuffers
);
566 return IMemAllocator_SetProperties(pAlloc
, &This
->allocProps
, &actual
);
569 static HRESULT WINAPI
Parser_OutputPin_GetMediaType(BasePin
*iface
, int iPosition
, AM_MEDIA_TYPE
*pmt
)
571 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
575 return VFW_S_NO_MORE_ITEMS
;
576 CopyMediaType(pmt
, This
->pmt
);
580 static HRESULT WINAPI
Parser_OutputPin_DecideAllocator(BaseOutputPin
*iface
, IMemInputPin
*pPin
, IMemAllocator
**pAlloc
)
582 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
588 hr
= IMemInputPin_NotifyAllocator(pPin
, This
->alloc
, This
->readonly
);
590 hr
= VFW_E_NO_ALLOCATOR
;
595 static HRESULT WINAPI
Parser_OutputPin_BreakConnect(BaseOutputPin
*This
)
599 TRACE("(%p)->()\n", This
);
601 EnterCriticalSection(This
->pin
.pCritSec
);
602 if (!This
->pin
.pConnectedTo
|| !This
->pMemInputPin
)
603 hr
= VFW_E_NOT_CONNECTED
;
606 hr
= IPin_Disconnect(This
->pin
.pConnectedTo
);
607 IPin_Disconnect((IPin
*)This
);
609 LeaveCriticalSection(This
->pin
.pCritSec
);
615 static HRESULT WINAPI
Parser_OutputPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
617 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
619 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
623 if (IsEqualIID(riid
, &IID_IUnknown
))
625 else if (IsEqualIID(riid
, &IID_IPin
))
627 /* The Parser filter does not support querying IMediaSeeking, return it directly */
628 else if (IsEqualIID(riid
, &IID_IMediaSeeking
))
629 *ppv
= &((ParserImpl
*)This
->pin
.pin
.pinInfo
.pFilter
)->sourceSeeking
;
633 IUnknown_AddRef((IUnknown
*)(*ppv
));
637 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
639 return E_NOINTERFACE
;
642 static ULONG WINAPI
Parser_OutputPin_Release(IPin
* iface
)
644 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
645 ULONG refCount
= InterlockedDecrement(&This
->pin
.pin
.refCount
);
647 TRACE("(%p)->() Release from %d\n", iface
, refCount
+ 1);
651 FreeMediaType(This
->pmt
);
652 CoTaskMemFree(This
->pmt
);
653 FreeMediaType(&This
->pin
.pin
.mtCurrent
);
660 static HRESULT WINAPI
Parser_OutputPin_Connect(IPin
* iface
, IPin
* pReceivePin
, const AM_MEDIA_TYPE
* pmt
)
662 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
663 ParserImpl
*parser
= (ParserImpl
*)This
->pin
.pin
.pinInfo
.pFilter
;
665 /* Set the allocator to our input pin's */
666 EnterCriticalSection(This
->pin
.pin
.pCritSec
);
667 This
->alloc
= parser
->pInputPin
->pAlloc
;
668 LeaveCriticalSection(This
->pin
.pin
.pCritSec
);
670 return BaseOutputPinImpl_Connect(iface
, pReceivePin
, pmt
);
673 static HRESULT WINAPI
Parser_OutputPin_QueryAccept(IPin
*iface
, const AM_MEDIA_TYPE
* pmt
)
675 Parser_OutputPin
*This
= (Parser_OutputPin
*)iface
;
678 dump_AM_MEDIA_TYPE(pmt
);
680 return (memcmp(This
->pmt
, pmt
, sizeof(AM_MEDIA_TYPE
)) == 0);
683 static const IPinVtbl Parser_OutputPin_Vtbl
=
685 Parser_OutputPin_QueryInterface
,
687 Parser_OutputPin_Release
,
688 Parser_OutputPin_Connect
,
689 BaseOutputPinImpl_ReceiveConnection
,
690 BaseOutputPinImpl_Disconnect
,
691 BasePinImpl_ConnectedTo
,
692 BasePinImpl_ConnectionMediaType
,
693 BasePinImpl_QueryPinInfo
,
694 BasePinImpl_QueryDirection
,
696 Parser_OutputPin_QueryAccept
,
697 BasePinImpl_EnumMediaTypes
,
698 BasePinImpl_QueryInternalConnections
,
699 BaseOutputPinImpl_EndOfStream
,
700 BaseOutputPinImpl_BeginFlush
,
701 BaseOutputPinImpl_EndFlush
,
702 BasePinImpl_NewSegment
705 static HRESULT WINAPI
Parser_PullPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
707 PullPin
*This
= (PullPin
*)iface
;
709 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, qzdebugstr_guid(riid
), ppv
);
714 * It is important to capture the request for the IMediaSeeking interface before it is passed
715 * on to PullPin_QueryInterface, this is necessary since the Parser filter does not support
716 * querying IMediaSeeking
718 if (IsEqualIID(riid
, &IID_IMediaSeeking
))
719 *ppv
= &((ParserImpl
*)This
->pin
.pinInfo
.pFilter
)->sourceSeeking
;
723 IUnknown_AddRef((IUnknown
*)(*ppv
));
727 return PullPin_QueryInterface(iface
, riid
, ppv
);
730 static HRESULT WINAPI
Parser_PullPin_Disconnect(IPin
* iface
)
733 PullPin
*This
= (PullPin
*)iface
;
737 EnterCriticalSection(&This
->thread_lock
);
738 EnterCriticalSection(This
->pin
.pCritSec
);
740 if (This
->pin
.pConnectedTo
)
743 ParserImpl
*Parser
= (ParserImpl
*)This
->pin
.pinInfo
.pFilter
;
745 LeaveCriticalSection(This
->pin
.pCritSec
);
746 hr
= IBaseFilter_GetState(This
->pin
.pinInfo
.pFilter
, INFINITE
, &state
);
747 EnterCriticalSection(This
->pin
.pCritSec
);
749 if (SUCCEEDED(hr
) && (state
== State_Stopped
) && SUCCEEDED(Parser
->fnDisconnect(Parser
)))
751 LeaveCriticalSection(This
->pin
.pCritSec
);
752 PullPin_Disconnect(iface
);
753 EnterCriticalSection(This
->pin
.pCritSec
);
754 hr
= Parser_RemoveOutputPins((ParserImpl
*)This
->pin
.pinInfo
.pFilter
);
757 hr
= VFW_E_NOT_STOPPED
;
762 LeaveCriticalSection(This
->pin
.pCritSec
);
763 LeaveCriticalSection(&This
->thread_lock
);
768 static HRESULT WINAPI
Parser_PullPin_ReceiveConnection(IPin
* iface
, IPin
* pReceivePin
, const AM_MEDIA_TYPE
* pmt
)
774 hr
= PullPin_ReceiveConnection(iface
, pReceivePin
, pmt
);
777 BasePin
*This
= (BasePin
*)iface
;
779 EnterCriticalSection(This
->pCritSec
);
780 Parser_RemoveOutputPins((ParserImpl
*)This
->pinInfo
.pFilter
);
781 LeaveCriticalSection(This
->pCritSec
);
787 static HRESULT WINAPI
Parser_PullPin_EnumMediaTypes(IPin
*iface
, IEnumMediaTypes
**ppEnum
)
789 BasePin
*This
= (BasePin
*)iface
;
791 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppEnum
);
793 return EnumMediaTypes_Construct(This
, BasePinImpl_GetMediaType
, BasePinImpl_GetMediaTypeVersion
, ppEnum
);
796 static const IPinVtbl Parser_InputPin_Vtbl
=
798 Parser_PullPin_QueryInterface
,
801 BaseInputPinImpl_Connect
,
802 Parser_PullPin_ReceiveConnection
,
803 Parser_PullPin_Disconnect
,
804 BasePinImpl_ConnectedTo
,
805 BasePinImpl_ConnectionMediaType
,
806 BasePinImpl_QueryPinInfo
,
807 BasePinImpl_QueryDirection
,
810 Parser_PullPin_EnumMediaTypes
,
811 BasePinImpl_QueryInternalConnections
,