CMpegInputPin.cpp
上传用户:hhs829
上传日期:2022-06-17
资源大小:586k
文件大小:3k
- //
- // CMpegInputPin.cpp
- //
- #include <streams.h>
- #include "CFilterMpeg2VD.h"
- #include "CMpegInputPin.h"
- /////////////////////////////////////////////////////////////////////////////
- CMpegInputPin::CMpegInputPin(TCHAR * inObjectName,
- CFilterMpeg2VD * inFilter,
- HRESULT * outResult) :
- CBaseInputPin(inObjectName, inFilter, inFilter->pStateLock(), outResult, L"Input")
- {
- mDecodeFilter = inFilter;
- }
- CMpegInputPin::~CMpegInputPin()
- {
- }
- //
- // Check input type
- HRESULT CMpegInputPin::CheckMediaType(const CMediaType * mtIn)
- {
- if ((mtIn->majortype == MEDIATYPE_Video ||
- mtIn->majortype == MEDIATYPE_MPEG2_PES) &&
- mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO)
- {
- return NOERROR;
- }
- return E_FAIL;
- }
- STDMETHODIMP CMpegInputPin::Receive(IMediaSample *pSample)
- {
- CAutoLock lck(&mDecodeFilter->m_csReceive);
- ASSERT(pSample);
- // check all is well with the base class
- HRESULT hr = CBaseInputPin::Receive(pSample);
- if (hr == S_OK)
- {
- hr = mDecodeFilter->Receive(pSample);
- }
- return hr;
- }
- STDMETHODIMP CMpegInputPin::EndOfStream(void)
- {
- CAutoLock lck(&mDecodeFilter->m_csReceive);
- HRESULT hr = CheckStreaming();
- if (hr == S_OK)
- {
- hr = mDecodeFilter->EndOfStream();
- }
- return hr;
- }
- // enter flushing state. Call default handler to block Receives, then
- // pass to overridable method in filter
- STDMETHODIMP CMpegInputPin::BeginFlush(void)
- {
- CAutoLock lck(mDecodeFilter->pStateLock());
- // Are we actually doing anything?
- if (!IsConnected() || !mDecodeFilter->m_paStreams[0]->IsConnected())
- {
- return VFW_E_NOT_CONNECTED;
- }
- HRESULT hr = CBaseInputPin::BeginFlush();
- if (FAILED(hr))
- {
- return hr;
- }
- return mDecodeFilter->BeginFlush();
- }
- // leave flushing state.
- // Pass to overridable method in filter, then call base class
- // to unblock receives (finally)
- STDMETHODIMP CMpegInputPin::EndFlush(void)
- {
- CAutoLock lck(mDecodeFilter->pStateLock());
- // Are we actually doing anything?
- if (!IsConnected() || !mDecodeFilter->m_paStreams[0]->IsConnected())
- {
- return VFW_E_NOT_CONNECTED;
- }
- HRESULT hr = mDecodeFilter->EndFlush();
- if (FAILED(hr))
- {
- return hr;
- }
- return CBaseInputPin::EndFlush();
- }
- //
- // Called when we are seeked
- //
- STDMETHODIMP CMpegInputPin::NewSegment(REFERENCE_TIME tStart,
- REFERENCE_TIME tStop, double dRate)
- {
- CBasePin::NewSegment(tStart, tStop, dRate);
- return mDecodeFilter->NewSegment(tStart, tStop, dRate);
- }
- HRESULT CMpegInputPin::CompleteConnect(IPin *pReceivePin)
- {
- HRESULT hr = mDecodeFilter->CompleteConnect(PINDIR_INPUT, pReceivePin);
- if (FAILED(hr))
- {
- return hr;
- }
- return CBaseInputPin::CompleteConnect(pReceivePin);
- }