⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cbranchinputpin.cpp

📁 最近在学习directshow, Directshow实务精选的源代码
💻 CPP
字号:
//
// CBranchInputPin.cpp
//

/*-----------------------------------------------------*\
			HQ Tech, Make Technology Easy!       
 More information, please go to http://hqtech.nease.net.
/*-----------------------------------------------------*/

#include <streams.h>
#include "FilterVideoKeyer.h"
#include "CBranchInputPin.h"

//////////////////////////////////////////////////////////////////////////////////
CBranchInputPin::CBranchInputPin(CFilterVideoKeyer * inFilter, HRESULT * phr, LPCWSTR inPinName) :
CBaseInputPin(NAME("Branch In"), inFilter, &inFilter->m_csFilter, phr, inPinName)
{
	mFilter = inFilter;
}

CBranchInputPin::~CBranchInputPin()
{
}

// Keep the mixing input pin's media type the same as the main input pin.
HRESULT CBranchInputPin::CheckMediaType(const CMediaType* mtIn)
{
	// We require the main input pin finish connection first
	if (mFilter->m_pInput && mFilter->m_pInput->IsConnected())
	{
		CMediaType mtMain = mFilter->m_pInput->CurrentMediaType();
		if (mtMain.majortype == mtIn->majortype && 
			mtMain.subtype == mtIn->subtype &&
			mtMain.formattype == mtIn->formattype)
		{
			VIDEOINFOHEADER * pMain = (VIDEOINFOHEADER *) mtMain.Format();
			VIDEOINFOHEADER * pMix  = (VIDEOINFOHEADER *) mtIn->Format();
			if (pMain->bmiHeader.biWidth == pMix->bmiHeader.biWidth &&
				pMain->bmiHeader.biHeight == pMix->bmiHeader.biHeight)
			{
				return NOERROR;
			}
		}
	}
	return E_FAIL;
}

STDMETHODIMP CBranchInputPin::Receive(IMediaSample * pSample)
{
	CAutoLock lck(&mSyncStream);
	ASSERT(pSample);

	HRESULT hr = CBaseInputPin::Receive(pSample);
	if (S_OK == hr) 
	{
		hr = mFilter->mController.ReceiveMixingVideo(pSample);
	}
	return hr;
}

STDMETHODIMP CBranchInputPin::EndOfStream(void)
{
	CAutoLock lck(&mSyncStream);
	HRESULT hr = CheckStreaming();
	if (S_OK == hr)
	{
		hr = mFilter->mController.MixingEndOfStream();
	}
	return hr;
}

STDMETHODIMP CBranchInputPin::BeginFlush(void)
{
	CAutoLock  lck(&mFilter->m_csFilter);
	if (!IsConnected()) 
	{
		return VFW_E_NOT_CONNECTED;
	}
	
	HRESULT hr = CBaseInputPin::BeginFlush();
	if (FAILED(hr)) 
	{
		return hr;
	}
	return mFilter->mController.MixingBeginFlush();
}

STDMETHODIMP CBranchInputPin::EndFlush(void)
{
	CAutoLock lck(&mFilter->m_csFilter);
	if (!IsConnected()) 
	{
		return VFW_E_NOT_CONNECTED;
	}

	HRESULT hr = mFilter->mController.MixingEndFlush();
	if (FAILED(hr)) 
	{
		return hr;
	}
	return CBaseInputPin::EndFlush();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -