📄 cfiltermpeg2decinputpin.cpp
字号:
//
// CFilterMpeg2DecInputPin.cpp
//
#include <streams.h>
#include "CFilterMpeg2Dec.h"
#include "CFilterMpeg2DecInputPin.h"
/////////////////////////////////////////////////////////////////////////////
CFilterMpeg2DecInputPin::CFilterMpeg2DecInputPin(TCHAR * inObjectName,
CFilterMpeg2Dec * inFilter,
HRESULT * outResult) :
CBaseInputPin(inObjectName, inFilter, inFilter->pStateLock(), outResult, L"Input")
{
mDecodeFilter = inFilter;
}
CFilterMpeg2DecInputPin::~CFilterMpeg2DecInputPin()
{
}
//
// Check input type
HRESULT CFilterMpeg2DecInputPin::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 CFilterMpeg2DecInputPin::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 CFilterMpeg2DecInputPin::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 CFilterMpeg2DecInputPin::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 CFilterMpeg2DecInputPin::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 CFilterMpeg2DecInputPin::NewSegment(REFERENCE_TIME tStart,
REFERENCE_TIME tStop, double dRate)
{
CBasePin::NewSegment(tStart, tStop, dRate);
return mDecodeFilter->NewSegment(tStart, tStop, dRate);
}
HRESULT CFilterMpeg2DecInputPin::CompleteConnect(IPin *pReceivePin)
{
HRESULT hr = mDecodeFilter->CompleteConnect(PINDIR_INPUT, pReceivePin);
if (FAILED(hr))
{
return hr;
}
return CBaseInputPin::CompleteConnect(pReceivePin);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -