如何检查是否正在使用我的DirectShow Renderer过滤器?
在我的DirectShow项目中,我创建了一个过滤器(从 CBaseVideoRenderer
派生)来渲染内存块。这在大多数情况下都很好,添加了过滤器
In my DirectShow project I create a filter (derived from CBaseVideoRenderer
) to render to a block of memory. This works in most cases perfectly well, with me adding the filter
mGraphBuilder->AddFilter(pInterfaceInfo, MemoryRendererName);
并依靠GraphBuilder做剩下的工作。但是在某些情况下,图形生成器和我的过滤器不能就一个通用格式达成一致,它会创建一个新的ActiveMovie窗口,绕过我的过滤器。
and relying on GraphBuilder to do the rest. However in some cases the graph builder and my filter cannot agree on a common format and it creates a new ActiveMovie window, bypassing my filter.
发生,所以我知道我的过滤器没有被使用,但不能解决如何。
I would like to detect when this occurs so that I know my filter is not being used, but cannot work out how.
我枚举图中的所有过滤器,寻找我的过滤器,使用以下方法:
I enumerate all filters in my graph, looking for my filter, using the following method:
(编辑:当我调用这个参数时,我传递了我的GraphBuilder对象作为pGraph参数)
( I pass my my GraphBuilder object as the pGraph parameter when I call this)
HRESULT MediaPlayer::CheckFilterGraphFor(IFilterGraph *pGraph, IBaseFilter* pFilterToLookFor)
{
IEnumFilters *pEnum = NULL;
IBaseFilter *pFilter;
ULONG cFetched;
HRESULT enumeratedFilterCount = 0;
FILTER_INFO pRefFilterInfo;
pFilterToLookFor->QueryFilterInfo(&pRefFilterInfo);
HRESULT hr = pGraph->EnumFilters(&pEnum);
if (SUCCEEDED(hr))
{
while(pEnum->Next(1, &pFilter, &cFetched) == S_OK)
{
enumeratedFilterCount--;
FILTER_INFO FilterInfo;
hr = pFilter->QueryFilterInfo(&FilterInfo);
if (SUCCEEDED(hr))
{
if(wcscmp(FilterInfo.achName, pRefFilterInfo.achName) == 0)
{
pRefFilterInfo.pGraph->Release();
return S_OK;
}
// The FILTER_INFO structure holds a pointer to the Filter Graph
// Manager, with a reference count that must be released.
if (FilterInfo.pGraph != NULL)
{
FilterInfo.pGraph->Release();
}
pFilter->Release();
}
}
pEnum->Release();
}
pRefFilterInfo.pGraph->Release();
return enumeratedFilterCount;
}
但它不能按预期工作,
But it does not work as expected, as my filter is always found regardless of whether it is in use or not.
我如何知道当我的过滤器用作DirectShow图形的视频渲染器时,以及当它不是
How can I tell when my filter is in use as the video renderer for my DirectShow graph, and when it is not?
找到您的渲染器过滤器后,找到其输入引脚并检查是否已连接(IPin: :ConnectedTo)
After finding your renderer filter, find its input pin and check if it's connected or not (IPin::ConnectedTo)