[DirectShow] 038 - Enumerating Filters
2009-08-20 20:22
253 查看
The Filter Graph Manager supports the IFilterGraph::EnumFilters
method, which enumerates all the filters in the filter graph. It returns a
pointer to the IEnumFilters
interface. The IEnumFilters::Next
method retrieves IBaseFilter
interface pointers.
Filter Graph Manger
支持
IFilterGraph::EnumFilters
方法用来枚举
filter graph
中的所有
filter
。这个函数返回
IEnumFilters
接口的指针。
IEnumFilters::Next
方法返回
IBaseFilter
接口指针。
The following example shows a function that enumerates the filters
in a graph and displays a message box with each filter's name. It uses the IBaseFilter::QueryFilterInfo
method to retrieve the name of the filter. Note the places where the function
calls Release
on an interface to decrement the reference count.
下面的列子展现枚举
graph
中
filter
的方法并在一个消息框中显示每个
filter
名字。使用
IBaseFilter::QueryFilterInfo
方法获得
filter
的名字。记得调用
Release
来消耗应用计数。
method, which enumerates all the filters in the filter graph. It returns a
pointer to the IEnumFilters
interface. The IEnumFilters::Next
method retrieves IBaseFilter
interface pointers.
Filter Graph Manger
支持
IFilterGraph::EnumFilters
方法用来枚举
filter graph
中的所有
filter
。这个函数返回
IEnumFilters
接口的指针。
IEnumFilters::Next
方法返回
IBaseFilter
接口指针。
The following example shows a function that enumerates the filters
in a graph and displays a message box with each filter's name. It uses the IBaseFilter::QueryFilterInfo
method to retrieve the name of the filter. Note the places where the function
calls Release
on an interface to decrement the reference count.
下面的列子展现枚举
graph
中
filter
的方法并在一个消息框中显示每个
filter
名字。使用
IBaseFilter::QueryFilterInfo
方法获得
filter
的名字。记得调用
Release
来消耗应用计数。
HRESULT EnumFilters (IFilterGraph *pGraph) { IEnumFilters *pEnum = NULL; IBaseFilter *pFilter; ULONG cFetched; HRESULT hr = pGraph->EnumFilters(&pEnum); if (FAILED(hr)) return hr; while(pEnum->Next(1, &pFilter, &cFetched) == S_OK) { FILTER_INFO FilterInfo; hr = pFilter->QueryFilterInfo(&FilterInfo); if (FAILED(hr)) { MessageBox(NULL, TEXT("Could not get the filter info"), TEXT("Error"), MB_OK | MB_ICONERROR); continue; // Maybe the next one will work. } #ifdef UNICODE MessageBox(NULL, FilterInfo.achName, TEXT("Filter Name"), MB_OK); #else char szName[MAX_FILTER_NAME]; int cch = WideCharToMultiByte(CP_ACP, 0, FilterInfo.achName, MAX_FILTER_NAME, szName, MAX_FILTER_NAME, 0, 0); if (chh > 0) MessageBox(NULL, szName, TEXT("Filter Name"), MB_OK); #endif // 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(); return S_OK; }
相关文章推荐
- About DirectShow Filters
- 编写DirectShow Filters—动态格式改变
- [DirectShow] 004 - About DirectShow Filters
- There Are Free RTSP DirectShow Source Filters with full source code
- 3How to Register DirectShow Filters.
- 编写DirectShow Filters—DirectShow and COM
- [DirectShow] 040 - Enumerating Media Types
- 编写DirectShow Filters—概述
- 编写DirectShow Filters—编写transform filters
- Prototyping DirectShow filters in C#
- 【转载】编写DirectShow Filters—编写transform filters
- How DirectShow Decides Which Filters to Use
- 【转载】编写DirectShow Filters—DirectShow and COM
- DirectShow之filters例程详解前言
- 编写DirectShow Filters—Filters如何连接
- 编写DirectShow Filters—线程和关键区
- How DirectShow Decides Which Filters to Use
- 《微软:DirectShow开发指南》第12章 Writing DirectShow Source Filters
- directshow之filters 例程BALL的详细解析
- Morgan RTP DirectShow Filters