DirectShow学习笔记-Filter概述

       Filter 是DirectShow中最基本的概念。DirectShow使用Filter Graph来管理Filter(管理者叫做Filter Graph Manager)。Filter Graph是Filter的“容器“,而Filter是Filter Graph中的最小功能模块。   
Filter一般由一个或多个Pin组成,Filter之间通过Pin相互连接,构成一条顺序的链路,Filter根据实现功能的不同大致分为3类:Source Filters、Transform Filters和Rendering Filters。
Filter的类别:
Source Filters:仅有输出Pin,没有输入Pin的Filter。主要负责获取数据,数据源可以是文件也可以是设备。只有输出Pin。
Transform Filters:既有输入Pin也有输出Pin。主要负责数据的格式转换,例如数据流分离/合成、编码/解码等,然后将数据继续往下传输。既有输入Pin又有输出Pin。
Rendering Filters:仅有输入Pin,没有输出Pin的Filter。主要负责数据的最终去向,送达设备或文件。只有输出Pin。

Filter的类型,如以下示图:



        Filter是一种COM组件。为了实现在Filter Graph中的统一操作,每个Filter上都至少实现了IBaseFilter接口。IBaseFilter继承自IMediaFilter。Filter Graph Manager正是通过IMediaFilter的接口方法来控制Filter Graph的状态(运行、暂停、停止)转换。实现Filter的文件一般是一个DLL,扩展名可以是.dll。Filter的创建是通过API函数CoCreateInstance来完成的,代码如下:

HRESULT CoCreateInstance(
  __in   REFCLSID rclsid, //The CLSID associated with the data and code that will be used to create the object.
  __in   LPUNKNOWN pUnkOuter, //If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown). 
  __in   DWORD dwClsContext, //Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX.
  __in   REFIID riid, //A reference to the identifier of the interface to be used to communicate with the object.
  __out  LPVOID *ppv //Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, * ppv contains the requested interface pointer. Upon failure, * ppv contains NULL. 
);
该方法的使用就不过多介绍。








  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

iot-genius

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值