我有直接显示过滤器,它接受输入并处理它并将结果提供给outputpin。
我想将这个过滤器输出数据写入文件......我想在其过滤器类中进行操作。所以我想得到输出引脚缓冲区数据。
如何在其过滤器中获取outputpin的最终数据?我该怎么做?
不是:输出引脚来自CBaseOutputPin。这是一个开源过滤器,它“神奇地”:-)把wright数据放到它的输出引脚,我无法弄清楚怎么样..
更新
这是一个简单的说明:
Media Source ----> GFilter ----> FileWriter
我有GFilter的源代码......我没有FileWriter的源代码......我想做的是让GFilter编写自己的数据......我调试GFilter了解它的转换数据但是我的尝试用错误的数据写这个数据结果......所以我现在就如何简单地在其输出引脚上获取数据......
更新[2]
在Filter outputpin中,过滤器编写器将文件编写器引脚传递给IStreamPtr变量...... Everthing似乎写入变量m_pIStream,类型为[IStreamPtr]
GFilterOutput::CompleteConnect(IPin *pReceivePin)
{
// make sure that this is the file writer, supporting
// IStream, or we will not be able to write out the metadata
// at stop time
// m_pIStream is IStreamPtr type
m_pIStream = pReceivePin;
if (m_pIStream == NULL)
{
return E_NOINTERFACE;
}
return CBaseOutputPin::CompleteConnect(pReceivePin);
}
...
GFilterOutput::Replace(LONGLONG pos, const BYTE* pBuffer, long cBytes)
{
//OutputDebugStringA("DEBUG: Now at MuxOutput Replace");
// all media content is written when the graph is running,
// using IMemInputPin. On stop (during our stop, but after the
// file writer has stopped), we switch to IStream for the metadata.
// The in-memory index is updated after a successful call to this function, so
// any data not written on completion of Stop will not be in the index.
CAutoLock lock(&m_csWrite);
HRESULT hr = S_OK;
if (m_bUseIStream)
{
IStreamPtr pStream = GetConnected();
if (m_pIStream == NULL)
{
hr = E_NOINTERFACE;
} else {
LARGE_INTEGER liTo;
liTo.QuadPart = pos;
ULARGE_INTEGER uliUnused;
hr = m_pIStream->Seek(liTo, STREAM_SEEK_SET, &uliUnused);
if (SUCCEEDED(hr))
{
ULONG cActual;
hr = m_pIStream->Write(pBuffer, cBytes, &cActual);
if (SUCCEEDED(hr) && ((long)cActual != cBytes))
{
hr = E_FAIL;
}
}
}
} else {
// where the buffer boundaries lie is not important in this
// case, so break writes up into the buffers.
while (cBytes && (hr == S_OK))
{
IMediaSamplePtr pSample;
hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0);
if (SUCCEEDED(hr))
{
long cThis = min(pSample->GetSize(), cBytes);
BYTE* pDest;
pSample->GetPointer(&pDest);
CopyMemory(pDest, pBuffer, cThis);
pSample->SetActualDataLength(cThis);
// time stamps indicate file position in bytes
LONGLONG tStart = pos;
LONGLONG tEnd = pos + cThis;
pSample->SetTime(&tStart, &tEnd);
hr = Deliver(pSample);
if (SUCCEEDED(hr))
{
pBuffer += cThis;
cBytes -= cThis;
pos += cThis;
}
}
}
}
return hr;
}
答案 0 :(得分:0)
您有完整的源代码,使用调试器逐步完成,直到您的过滤器调用对等下游过滤器的IPin::Receive
,更新/覆盖代码,并且您可以完全控制将数据写入文件等