DirectShow学习笔记

DirectShow, as you might have guessed, is a COM based multimedia framework that makes the task of capturing, playing back, and manipulating media streams easier(DirectShow是一个基于组件对象模块(COM)的多媒体框架,可以让捕捉、播放以及操作媒体流变的更容易). It was formerly known as ActiveMovie, until it became known as DirectShow. DirectShow might internally use DirectSound and DirectDraw when playing a media, provided there is support from the hardware; otherwise, it might use the traditional Wave APIs and GDI APIs(DirectShow在硬件支持的情况下,可能内部会使用DirectSound以及DirectDraw来播放媒体。否则的话,它就可能会使用传统的Wave  APIs和GDI APIs).

Filters: Technically, Filters are just C++ classes complying(遵从) with the COM interface, which take input in some form, process the data, and produce some output in the same/or different form(Filters是遵循COM接口的C++类,以一些方式获取输入,处理数据,并且以同样/或不同的方式产生输出). A Filter represents each stage in the processing of a media type.

Pins: A Pin is an interface in itself, and every Filter must implement at least one Pin(Pin自身是一个接口,并且每个Filter必须实现至少一个Pin). Pins are a way for Filters to talk to other Filters(Pins是Filters之间互相联系的一种方式). Typically, a Filter might have an input pin and an output pin(典型地,一个Filter可能有一个输入pin和一个输出pin). During the processing of the media, a Filter takes input through its input pin, processes the data, and passes the output to another filter through its output pin(在处理媒体时,Filter从输入pin获取输入,处理数据,并且通过输出pin将输出传递给另一个Filter). The other filter, as is obvious, receives the processed data through its input pin. So, basically, the output pin of one filter is connected with the input pin of another filter, and that is how they talk(所以,本质上,一个Filter的输出pin是与另一个Filter的输入pin相连接的,这就是它们之间互相联系的方式).

Filter Graph and Filter Graph Manager: A Filter Graph is a sequence of connected filters(Filter Graph是一系列相连接的Filters). The processing of any type of media involves a Filter Graph with a specific set of filters most suitable for that media type(处理任何类型的媒体都涉及到一个Filter Graph,它由一组特定的最适合该媒体类型的Filters组成). The Filter Graph Manager is the divine power that lets you create these Filter Graphs, add Filters to a Filter Graph, connect the Pins of the appropriate Filters, and finally, run the graph which accomplishes our objective, which is, if you remember, playing the media(Filter Graph Manager允许你创建Filter Graphs,添加Filters到Filter Graph,将合适的Filters的Pins相连接,并且最终运行Graph来播放媒体).

Source Filter takes the input from a file or a URL or a capture device, and processes the data in a form which can be consumed by other filters(Source Filter从一个文件或URL或捕获设备中获取输入,并且处理生成可供其他Filters使用的数据). A characteristic of a source filter is that it has no input pins and only one output pin(Source Filter的一个特性是它没有输入pins,只有一个输出pin). Note: Pins are a secret between filters only. A Renderer Filter takes the input from the previous filter, and renders it to a sound device or a display device or a file, in case of capture(Renderer Filter从先前的Filter获取输入,并且将数据以捕获的方式渲染到一个音频设备,或一个显示设备,或一个文件). Remember, this might use DirectSound or DirectDraw internally. A characteristic of a renderer filter is that it has one input pin and no output pins(Render Filter的一个特性是它由一个输入pin,却没有输出pins). Everything in between a source filter and a renderer filter is called a Transform Filter. A transform filter might have one or more input pins and one or more output pins.

Any application that wants to use DirectShow must follow these steps:

1. Create the Filter Graph Manager

2. Create the Filter Graph using the Filter Graph Manager

3. Run the Filter Graph (to play the media)

4. Release the resources

There are three ways in which you can create a filter graph: Automatic Graph Creation, Manual Graph Creation, and Semi-Automatic Graph Creation.
Automatic Graph Creation: This is the easiest of all methods, but doesn‘t give your application much flexibility in choosing filters. Here, you just call the RenderFile method on the IGraphBuilder interface, passing in the filename or any other source(你只需要调用IGraphBuilder接口的RenderFile函数,传入文件名或任何其他源). The graph manager will take all the pains(麻烦的事) to create an appropriate graph for you. The graph builder has its own algorithm to select various filters and then connect their pins to complete the graph(Graph Builder有它自己的算法来选择不同的Filters,并且把它们的pins连接起来以完成Graph). For example, if you pass the filename "love.mp3", the graph builder will identify the file format and then choose the appropriate filters to build a graph suitable for MP3 media.
Manual Graph Creation: This method is the most painful, but provides you with super flexibility in choosing the filters. I won‘t go into the details of this, but in the most abstract terms, first, you have to create the instances of the individual filters that you need(首先,你必须创建你所需要的独立的Filter实例). Then, you add each of these filters to the graph(接着,你将这些Filters添加到Graph中). At this point, the filters just lie in the graph like beans on a table(此时,这些Filters就像散落在桌子上的豆). The next step is to connect the pins of these filters(接着要做的就是将这些Filters的pins连接起来); this is again painful as it involves enumerating the pins of the filters and selecting the output pin of one and the input pin of another and then connecting the two together(这又是一件麻烦事儿,因为需要枚举Filters的pins,然后选定一个Filter的输出pin以及另一个Filter的输入pin,并将它们连接起来). Once you have connected all the pins, the graph is complete and ready to be run, assuming you haven‘t messed up the pins.
Semi-Automatic Graph Creation: This method provides you the flexibility while also trying to reduce the amount of pain. Here, you just choose a few priority filters (that you most surely want present in the graph) and then add them to the graph(你只需要选择一些主要的Filters(那些你肯定想要它们出现在Graph中的),然后把它们添加到Graph中). These filters lie in the graph just like beans on a table. Then, you ask the graph manager to complete the graph(你请求Graph Manager来完成Graph). The graph manager will add the missing pieces (filters) and build a graph for you(Graph Manager会添加缺漏的Filters,并且为你构建Graph). One thing to note here is that the graph manager will try its ever best to include your priority filters in the final graph, so this way, you have the control to override some of the default filters which the graph manager would have otherwise chosen(要注意的是Graph Manager会尽最大可能在最终的Graph中包含你选择的重要的Filters,这样的话,你就能够有权替换一些Graph Manager本来会选用的默认的Filters).

时间: 2024-11-06 13:31:15

DirectShow学习笔记的相关文章

DirectShow学习笔记总结

DirectShow是微软公司在ActiveMovie和Video for Windows的基础上推出的新一代基于COM(Component Object Model)的流媒体处理的开发包,9.0之前与DirectX开发包一起发布,之后包含在windows SDK中..DirectShow使用一种叫Filter Graph的模型来管理整个数据流的处理过程,运用DirectShow,我们可以很方便地从支持WDM驱动模型的采集卡上捕获数据,并且进行相应的后期处理乃至存储到文件中.这样使在多媒体数据库

vector 学习笔记

vector 使用练习: /**************************************** * File Name: vector.cpp * Author: sky0917 * Created Time: 2014年04月27日 11:07:33 ****************************************/ #include <iostream> #include <vector> using namespace std; int main

Caliburn.Micro学习笔记(一)----引导类和命名匹配规则

Caliburn.Micro学习笔记(一)----引导类和命名匹配规则 用了几天时间看了一下开源框架Caliburn.Micro 这是他源码的地址http://caliburnmicro.codeplex.com/ 文档也写的很详细,自己在看它的文档和代码时写了一些demo和笔记,还有它实现的原理记录一下 学习Caliburn.Micro要有MEF和MVVM的基础 先说一下他的命名规则和引导类 以后我会把Caliburn.Micro的 Actions IResult,IHandle ICondu

jQuery学习笔记(一):入门

jQuery学习笔记(一):入门 一.JQuery是什么 JQuery是什么?始终是萦绕在我心中的一个问题: 借鉴网上同学们的总结,可以从以下几个方面观察. 不使用JQuery时获取DOM文本的操作如下: 1 document.getElementById('info').value = 'Hello World!'; 使用JQuery时获取DOM文本操作如下: 1 $('#info').val('Hello World!'); 嗯,可以看出,使用JQuery的优势之一是可以使代码更加简练,使开

[原创]java WEB学习笔记93:Hibernate学习之路---Hibernate 缓存介绍,缓存级别,使用二级缓存的情况,二级缓存的架构集合缓存,二级缓存的并发策略,实现步骤,集合缓存,查询缓存,时间戳缓存

本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱好者,互联网技术发烧友 微博:伊直都在0221 QQ:951226918 -----------------------------------------------------------------------------------------------------------------

Activiti 学习笔记记录(三)

上一篇:Activiti 学习笔记记录(二) 导读:上一篇学习了bpmn 画图的常用图形标记.那如何用它们组成一个可用文件呢? 我们知道 bpmn 其实是一个xml 文件

HTML&CSS基础学习笔记8-预格式文本

<pre>标签的主要作用是预格式化文本.被包围在 pre 标签中的文本通常会保留空格和换行符.而文本也会呈现为等宽字体. <pre>标签的一个常见应用就是用来表示计算机的源代码.当然你也可以在你需要在网页中预显示格式时使用它. 会使你的文本换行的标签(例如<h>.<p>)绝不能包含在 <pre> 所定义的块里.尽管有些浏览器会把段落结束标签解释为简单地换行,但是这种行为在所有浏览器上并不都是一样的. 更多学习内容,就在码芽网http://www.

java/android 设计模式学习笔记(14)---外观模式

这篇博客来介绍外观模式(Facade Pattern),外观模式也称为门面模式,它在开发过程中运用频率非常高,尤其是第三方 SDK 基本很大概率都会使用外观模式.通过一个外观类使得整个子系统只有一个统一的高层的接口,这样能够降低用户的使用成本,也对用户屏蔽了很多实现细节.当然,在我们的开发过程中,外观模式也是我们封装 API 的常用手段,例如网络模块.ImageLoader 模块等.其实我们在开发过程中可能已经使用过很多次外观模式,只是没有从理论层面去了解它. 转载请注明出处:http://bl

[原创]java WEB学习笔记48:其他的Servlet 监听器:域对象中属性的变更的事件监听器 (3 个),感知 Session 绑定的事件监听器(2个)

本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱好者,互联网技术发烧友 微博:伊直都在0221 QQ:951226918 ---------------------------------