cnetoutpin.cpp

来自「VC vod源码 放出来供大家交流学习」· C++ 代码 · 共 87 行

CPP
87
字号
//
// CNetOutPin.cpp
//

#include "stdafx.h"
#include "GlobalDefs.h"
#include <streams.h>
#include "CFilterNetReceiver.h"
#include "CNetOutPin.h"

///////////////////////////////////////////////////////////////////////////////
CNetOutPin::CNetOutPin(CFilterNetReceiver *inFilter, HRESULT *phr, LPCWSTR pName) :
CBaseOutputPin(NAME("Net_Stream"), inFilter, &inFilter->mFilterLock, phr, pName)
{
	mFilter = inFilter;
	mPreferredMt.InitMediaType();
}

CNetOutPin::~CNetOutPin()
{
}

void CNetOutPin::SetupMediaType(long inType, char * inFormat, long inLength)
{
	if (inType == PT_VideoMediaType)
	{
		mPreferredMt.SetType(&MEDIATYPE_Video);
		mPreferredMt.SetSubtype(&(mFilter->subtype));
		mPreferredMt.SetFormatType(&(mFilter->formattype));
		mPreferredMt.SetFormat((BYTE*)inFormat, inLength);
	}
	else
	{
		mPreferredMt.SetType(&MEDIATYPE_Audio);
		mPreferredMt.SetSubtype(&(mFilter->subtype));
		mPreferredMt.SetFormatType(&(mFilter->formattype));
		mPreferredMt.SetFormat((BYTE*)inFormat, inLength);
	}
}

HRESULT CNetOutPin::CheckMediaType(const CMediaType * inMediaType)
{
	if (*inMediaType == mPreferredMt)
	{
		return NOERROR;
	}
	return E_FAIL;
}

HRESULT CNetOutPin::DecideBufferSize(IMemAllocator * pAlloc, ALLOCATOR_PROPERTIES * pprop)
{
	ASSERT(pAlloc);
	ASSERT(pprop);
	HRESULT hr = NOERROR;

	pprop->cbBuffer = 900000;//mFilter->mSampleLength;
	pprop->cBuffers  = 1;
	pprop->cbAlign   = 1;

	ASSERT(pprop->cbBuffer);

	ALLOCATOR_PROPERTIES Actual;
	hr = pAlloc->SetProperties(pprop, &Actual);
	if (FAILED(hr)) 
	{
		return hr;
	}

	ASSERT( Actual.cBuffers == 1 );

	if (pprop->cBuffers > Actual.cBuffers ||
		pprop->cbBuffer > Actual.cbBuffer) 
	{
		return E_FAIL;
	}
	return NOERROR;
}

HRESULT CNetOutPin::GetMediaType(int iPosition,CMediaType *pMediaType)
{
	if (iPosition == 0)
	{
		*pMediaType = mPreferredMt;
		return NOERROR;
	}
	return E_INVALIDARG;
}

⌨️ 快捷键说明

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