目前我的過濾器只是將數據從一個輸入引腳轉發到渲染器過濾器。我正在Graphstudio中測試它。 現在,一切似乎工作得很好,除了在我的輸出引腳的傳遞方法中調用 連接的輸入引腳返回拒絕樣本的錯誤代碼。 ( VFW_E_SAMPLE_REJECTED 0x8004022B)視頻渲染器過濾器拒絕示例
根據MSDN會發生這種情況如果符合下列條件:
- 的引腳沖洗(見沖洗)。
- 引腳未連接。
- 過濾器停止。
- 發生
其他一些錯誤,我不認爲第一個是真實的。它不能沖洗所有輸入樣品
第二個不能是真實的,因爲過濾器已經連接。
第三個不太可能。爲什麼要停止過濾器。
所以我認爲它一定是一些其他的錯誤,但我找不到有用的信息。
HRESULT MCMyOutputPin::Deliver(IMediaSample* sample)
{
HRESULT hr = NO_ERROR;
myLogger->LogDebug("In Outputpin Deliver", L"D:\\TEMP\\yc.log");
if (sample->GetActualDataLength() > 0)
{
hr = m_pInputPin->Receive(sample);
sample->AddRef();
}
return hr;
//Forward to filter
}
正如你可以看到我確信使用由輸入引腳
HRESULT MCMyOutputPin::DecideAllocator(IMemInputPin *pPin, IMemAllocator **ppAlloc)
{
ALLOCATOR_PROPERTIES *pprops = new ALLOCATOR_PROPERTIES;
/*HRESULT hr = pPin->GetAllocatorRequirements(pprops);
if (FAILED(hr))*/
//return hr;
HRESULT hr = pPin->GetAllocator(ppAlloc);
if (hr == VFW_E_NO_ALLOCATOR)
{
hr = InitAllocator(ppAlloc);
if (FAILED(hr))
return hr;
}
hr = DecideBufferSize(*ppAlloc, pprops);
if (FAILED(hr))
return hr;
hr = pPin->NotifyAllocator(*ppAlloc, TRUE);
if (FAILED(hr))
{
return hr;
}
*ppAlloc = m_pAllocator;
m_pAllocator->AddRef();
return hr;
}
這裏提供的IMemAllocator是我從precdeing過濾我inputpin得到樣本:
HRESULT CMyInputPin::Receive(IMediaSample *pSample)
{
mylogger->LogDebug("In Inputpin Receive", L"D:\\TEMP\\yc.log");
//Forward to filter
filter->acceptFilterInput(pinname, pSample);
return S_OK;
}
這就叫我的過濾器中的acceptFilterInput:
void MyFilter::acceptFilterInput(LPCWSTR pinname, IMediaSample* sample)
{
//samplesPin0.insert(samplesPin0.end(), sample);
mylogger->LogDebug("In acceptFIlterInput", L"D:\\TEMP\\yc.log");
outpin->Deliver(sample);
}
的交付方法已經張貼以上
謝謝你的回答羅馬。我編輯了我的答案以包含相關的代碼。我確實使用輸入引腳(videorender)的分配器 – Luke
不,它不能讓我相信媒體樣本屬於合適的分配器。 –
我需要做些什麼才能確保它屬於正確的分配器? – Luke