[DirectShow] 001 - Introduction to DirectShow Application Programming

The building block of DirectShow is a software component called a filter . A filter is a software component that performs some operation on a multimedia stream. For example, DirectShow filters can

read files

get video from a video capture device

decode various stream formats, such as MPEG-1 video

pass data to the graphics or sound card

DirectShow 的开发模块是被称作 Filter 的组件, Filter 是对多媒体流执行操作的组件。 DirectShow Filters 可以读取文件、从视频采集设备获取视频、解码各种格式的数据流、把数据传给显示器或声卡。

Filters receive input and produce output. For example, if a filter decodes MPEG-1 video, the input is the MPEG-encoded stream and the output is a series of uncompressed video frames。

Filters 接收输入并产生输出。例如,如果一个 Filter 解码 MPEG-1 格式的视频,那么输入就是用 MPEG 格式编码的数据流,输出就是一系列没有经过压缩的视屏帧。

In DirectShow, an application performs any task by connecting chains of filters together, so that the output from one filter becomes the input for another. A set of connected filters is called a filter graph . For example, the following diagram shows a filter graph for playing an AVI file.

在 DirectShow 中,应用程序通过把 Filters 的连接链连接起来以执行一些任务,所以,一个 Filter 的输入就是另一个的输入。连接在一起的 Filters 的集合称作 Filter Graph. 接下来的图片显示一个播放 AVI 文件的 Filter Graph:

The File Source filter reads the AVI file from the hard disk. The AVI Splitter filter parses the file into two streams, a compressed video stream and an audio stream. The AVI Decompressor filter decodes the video frames. The Video Renderer filter draws the frames to the display, using DirectDraw or GDI. The Default DirectSound Device filter plays the audio stream, using DirectSound.

File Source filter 从磁盘读取 AVI 文件。AVI Splitter filter 从文件中分离出压缩的视频和音频数据流。AVI Decompressor filter 解压视频帧。Video Renderer filter 使用 DirectDraw 或者 GDI 把数据帧画到显示器上。Default DirectSound Device filter 使用 DirectSound 播放音频流。

The application does not have to manage all of this data flow. Instead, the filters are controlled by a high-level component called the Filter Graph Manager. The application makes high-level API calls such as "Run" (to move data through the graph) or "Stop" (to stop the flow of data). If you require more control over the stream operations, you can access the filters directly through COM interfaces. The Filter Graph Manager also passes event notifications to the application.

应用程序不需要管理所有的数据流。 Filters 被称作 Filter Graph Manager 的高层组件控制。应用程序调用高级 API,例如 Run 和 Stop 。如果需要更多控制流的操作,可以通过 COM 接口直接访问 Filters 。 Filter Graph Manager 还发送通知事件到应用程序。

The Filter Graph Manager serves another purpose as well: It provides methods for the application to build the filter graph, by connecting the filters together. (DirectShow also provides various helper objects that simplify this process. These are thoroughly described in the documentation.)

Filter Graph Manager 还有其他的目的:通过把 Filters 连接在一起来为应用程序开发 Filter Graph 提供方法,(DirectShow 还提供了一些帮助对象以简化这些处理,在文档中有彻底的描述)

The application creates an instance of the Filter Graph Manager。

The application uses the Filter Graph Manager to build a filter graph. The exact set of filters in the graph will depend on the application。

The application uses the Filter Graph Manager to control the filter graph and stream data through the filters. Throughout this process, the application will also respond to events from the Filter Graph Manager。

应用程序创建一个 Filter Graph Manager 的实例。

应用程序使用 Filter Graph Manager 生成一个 Filter Graph 。 Graph 中准确的 Filters 集合将依赖与应用程序。

应用程序通过 Filter Graph Manager 控制 Filter Graph 和穿过 Filters 之间的数据流。这个过程中,应用程序将对来自 Filter Graph Manager 的事件作出响应。

 

When processing is completed, the application releases the Filter Graph Manager and all of the filters.

当进程完成时,应用程序释放 Filter Graph Manager 和所有的 Filters 。

 

DirectShow is based on COM; the Filter Graph Manager and the filters are all COM objects. You should have a general understanding of COM client programming before you begin programming DirectShow. Many books about COM programming are available.

DirectShow 基于 COM , Filter Graph Manager 和 Filters 都是 COM 对象。在开始 DirectShow 编程之前,必须对 COM 客户端编程有大概的了解。许多关于 COM 编程的书都可以。

 

To get started with DirectShow, read the art icle How To Play a File , which presents a simple console application to play a video file. The section About DirectShow explains the DirectShow architecture in more detail, while the section Using DirectShow examines the major scenarios that are supported by DirectShow, such as capture, video editing, DVD playback, and television.

阅读 How To Play a File 这篇文章开始 DirectShwo 的学习,这篇文章演示了一个简单的控制台程序播放视频文件。 About DirectShow 章节详细的解释 DirectShow 的体系结构。 Using DirectShow 章节给出了 DirectShow 支持的主要代码,例如采集,视频编辑, DVD 回放、电视。

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值