简体   繁体   中英

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

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?

找到渲染器过滤器后,找到其输入引脚并检查其是否已连接(IPin :: ConnectedTo)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM