How do I check if my DirectShow Renderer filter is being used?

僤鯓⒐⒋嵵緔 提交于 2019-12-13 04:41:12

问题


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);

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:

(EDIT: 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.

How can I tell when my filter is in use as the video renderer for my DirectShow graph, and when it is not?


回答1:


After finding your renderer filter, find its input pin and check if it's connected or not (IPin::ConnectedTo)



来源:https://stackoverflow.com/questions/10822226/how-do-i-check-if-my-directshow-renderer-filter-is-being-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!