[DirectShow] 016 - Pull Model

本文探讨了DirectShow中Pull模型的工作原理及其与Push模型的区别。特别关注了IAsyncReader接口的应用,以及如何通过该接口实现从上游filter请求数据的过程。此外,还介绍了Pull模型在实际场景如AVI播放中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

In the IMemInputPin interface, the upstream filter determines what data to send, and it pushes the data to the downstream filter. For some filters, a pull model is more appropriate. Here, the downstream filter requests data from the upstream filter. Samples still travel downstream, from output pin to input pin, but the downstream filter initiates the data flow. This type of connection uses the IAsyncReader interface.

IMemInputPin 接口中,上游 filter 决定发送什么数据,它把数据推给下游 filter 。对于有些 filter pull 模式更适合。在这种模式中,下游 filter 从上游 filter 请求数据。 sample 仍然从 output pin input pin 。但是下游 filter 初始化数据流。这种类型的连接使用 IAsyncReader 接口。

The typical use for the pull model is in file playback. For example, in an AVI playback graph, the Async File Source filter performs generic file reading operations and delivers the data as a byte stream, with no format information. The AVI Splitter filter reads the AVI headers and parses the stream into video and audio samples. The AVI Splitter can determine what data it needs better than the Async File Source filter, and therefore it uses IAsyncReader instead of IMemInputPin .

一般在文件回放中使用 pull 模式。例如在 AVI 回放 graph 中, AsyncFile source filter 不考虑格式的执行一般的读文件操作和传输字节流。 AVI Splitter filter 读取 AVI 头并分析流,分别生成视频和音频 sample AVI Splitter 决定它需要什么数据。因此它使用 IAsyncReader 而不使用 IMemInputPin

To request data from the output pin, the input pin calls one of the following methods:

input pin 调用一下函数从 output pin 请求数据:

·         IAsyncReader::Request

·         IAsyncReader::SyncRead

·         IAsyncReader::SyncReadAligned .

The first method is asynchronous, to support multiple overlapped reads. The others are synchronous.

第一个函数是异步的,支持多重读。其他的都是同步的。

In theory, any filter can support IAsyncReader , but in practice it is designed for source filters that connect to parser filters. The parser acts very much like a source filter in the push model. When it pauses, it creates a streaming thread that pulls data from the IAsyncReader connection and pushes it downstream. The output pins use IMemInputPin , and the rest of the graph uses the standard push model.

理论上,大多数 filter 可以支持 IAsyncReader ,但是实际上 source filter 被设计成连接 parser filter 的。 parser 非常像 push 模式中的 source filter 。当它暂停时,它创建从 IAsyncReader 连接吸取数据的流线程并把数据发送到下游。 output pin 使用 IMemInputPin graph 的其他部分都是用标准的 push 模式。

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值