您的位置:首页 > 其它

[DirectShow] 007 - About Media Samples and Allocators

2009-07-23 20:45 357 查看
Filters deliver data across pin connections. Data moves from the
output pin of one filter to the input pin of another filter. The most common
way for the output pin to deliver the data is by calling the IMemInputPin::Receive
method on the input, although a few other mechanisms exist as well.

filters
通过
pin
连接传递数据,数据从一个
filter
的输出
pin
传到另外一个
filter
的输入
pin
。输出
pin
传递数据大部分采用调用输入
pin

IMemInputPin::Receive

函数的方法,也还有少数其他的机制。

Depending on the filter, memory for the media data can be allocated
in various ways: on the heap, in a DirectDraw surface, using shared GDI memory,
or using some other allocation mechanism. The object responsible for allocating
the memory is called an allocator, which is a COM object that exposes the IMemAllocator

interface.

依靠
filter
,媒体数据可以采用多种方法申请内存:在堆栈,在
DirectDraw
surface
,使用共享
GDI
内存,或者使用其他分配机制。负责申请内存的对象叫做
allocator
,这是一个由
IMemAllocator

接口暴露的
COM
对象。

When two pins connect, one of the pins must provide an allocator.
DirectShow defines a sequence of method calls that is used to establish which
pin provides the allocator. The pins also agree on the number of buffers that
the allocator will create, and the size of the buffers.

当两个
pin
连接的时候,其中一个
pin
必须提供一个
allocator

DirectShow
对于拿个
pin
提供
allocator
定义了一系列的方法。
pin
通过协商确定
allocator
创建的
buffer
的大小和数量。

Before streaming begins, the allocator creates a pool of buffers.
During streaming, the upstream filter fills buffers with data and delivers them
to the downstream filter. But the upstream filter does not give the downstream
filter raw pointers to the buffers. Instead, it uses COM objects called media
samples, which the allocator creates to manage the buffers. Media samples
expose the IMediaSample

interface. A media sample contains:

a pointer to the underlying buffer

a time stamp

various flags

optionally, a media type

数据流动开始之前,
allocator
创建一个缓冲池。数据流动的时候,上游的
filter
用数据填充缓冲区,传递给下游的
filter
。上游的
filter
不会直接把缓冲区的原始指针交给下游
filter
,而是使用一种叫做
media samples

COM
对象,这个对象是由
allocator
创建,用来管理缓冲区的。
media sample

IMediaSample
接口暴露。一个
media sample
包含:

指向基本数据缓冲区的指针

时间戳

一些标记

可选的,媒体类型

The time stamp defines the presentation time, which the renderer
filter uses to schedule rendering. The flags indicate things like whether there
was a break in the data since the previous sample. The media type provides a
way for filters to change formats mid-stream. Usually, the sample has no media
type, which indicates that the format has not changed since the previous
sample.

时间戳定义现实时间,
renderer filter
使用约定时间演示。
flag
标识一些事物,例如,标识直到前一个
sample
的数据中是否有间隙。
media type

filter
转换格式提供了方法。通常,
sample
没有
media type
的话,表明之前的
sample
都没有发生格式转换。

While a filter is using a buffer, it holds reference count on the
sample. The allocator uses the reference count to determine when it can re-use
the buffer. This prevents a filter from overwriting a buffer that another
filter is still using. A sample does not return to the allocator's pool of available
samples until every filter has released it.


filter
使用一个
buffer
的过程中,
filter
将在
sample
上处理引用计数。
allocator
使用引用计数决定他什么时候能够重新使用
buffer
。这可以防止一个
filter
覆盖另外一个
filter
正在使用的
buffer

A sample does not return to the allocator's pool of available
samples until every filter has released it.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: