当我尝试将我的自定义写入过滤器连接到graphedt中的avi mux过滤器时,它会自动在中间添加一个Microsoft DTV-DVD音频解码器,这不需要因为我处理视频流。 graphedt如何决定这样做?我该如何防止这种情况?
两个过滤器如何确定它们是否兼容?
这是输出引脚的头文件:
#pragma once
#include <streams.h>
#include "MyFilter.h"
class MCMyOutputPin : public CBaseOutputPin
{
private:
// parent
CBaseFilter *mux;
IUnknown *position;
public:
MCMyOutputPin(MyFilter* filter, HRESULT *phr, LPCWSTR pName);
virtual ~MCMyOutputPin();
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
// overriden
virtual HRESULT CheckMediaType(const CMediaType *pmt);
virtual HRESULT SetMediaType(const CMediaType *pmt);
virtual HRESULT CompleteConnect(IPin *pReceivePin);
virtual HRESULT BreakConnect();
virtual HRESULT GetMediaType(int i, CMediaType *pmt);
virtual HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProps);
virtual HRESULT Deliver(IMediaSample* sample);
virtual HRESULT AgreeMediaType(IPin* recievePin, const CMediaType *pmt);
// qual prop
STDMETHODIMP Notify(IBaseFilter *pSender, Quality q);
CMediaType &CurrentMediaType() { return m_mt; }
};
这里是它的实施:
#include "CMyOutPutPin.h"
#include <fstream>
MCMyOutputPin::MCMyOutputPin(MyFilter* parent, HRESULT *phr, LPCWSTR pName) : CBaseOutputPin(NAME("MyOutPutPin"), parent, &parent->m_lock_filter, phr, pName)
{
}
MCMyOutputPin::~MCMyOutputPin()
{
}
STDMETHODIMP MCMyOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT MCMyOutputPin::CheckMediaType(const CMediaType *pmt)
{
return S_OK;
}
HRESULT MCMyOutputPin::SetMediaType(const CMediaType *pmt)
{
return CBaseOutputPin::SetMediaType(pmt);
}
HRESULT MCMyOutputPin::CompleteConnect(IPin *pReceivePin)
{
return CBaseOutputPin::CompleteConnect(pReceivePin);
}
HRESULT MCMyOutputPin::BreakConnect()
{
return CBaseOutputPin::BreakConnect();
}
HRESULT MCMyOutputPin::GetMediaType(int i, CMediaType *pmt)
{
return CBaseOutputPin::GetMediaType(i, pmt);
}
HRESULT MCMyOutputPin::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProps)
{
ALLOCATOR_PROPERTIES act;
HRESULT hr;
// by default we do something like this...
pProps->cbAlign = 1;
pProps->cBuffers = 1;
pProps->cbBuffer = this->CurrentMediaType().lSampleSize;
pProps->cbPrefix = 0;
hr = pAlloc->SetProperties(pProps, &act);
if (FAILED(hr)) return hr;
// make sure the allocator is OK with it.
if ((pProps->cBuffers > act.cBuffers) ||
(pProps->cbBuffer > act.cbBuffer) ||
(pProps->cbAlign > act.cbAlign))
return E_FAIL;
return NOERROR;
}
STDMETHODIMP MCMyOutputPin::Notify(IBaseFilter *pSender, Quality q)
{
// right now we don't do anything ...
return NOERROR;
}
HRESULT MCMyOutputPin::Deliver(IMediaSample* sample)
{
std::ofstream outfile;
outfile.open("C:\\TEMP\\yc1.log", std::ios_base::app);
outfile << "receiving data on outputpin" << std::endl;
outfile.close();
m_pInputPin->Receive(sample);
return CBaseOutputPin::Deliver(sample);
//Forward to filter
}
HRESULT MCMyOutputPin::AgreeMediaType(IPin * pin, const CMediaType* pmt)
{
return S_OK;
}
答案 0 :(得分:1)
首先发生这种情况是因为引脚无法直接连接。所以基本上防止意味着你将无法连接引脚,而你会遇到错误。
IPin::Connect
和IPin::ReceiveConnection
方法