[DirectShow] 020 - Reference Clocks

 

One function of the Filter Graph Manager is to synchronize all of the filters in the graph to the same clock, called the reference clock .

Filter Graph Manager 的一个功能就是同步 graph 中的所有 filter 到同一个时钟,这个时钟叫做参考时钟。

Any object that exposes the IReferenceClock interface can act as the reference clock. The reference clock might be provided by a DirectShow filter — typically the audio renderer, which has access to a hardware timer. As a fallback, the Filter Graph Manager can use the system time.

参考时钟由 DirectShow filter 提供,就像 audio renderer ,可以访问硬件时间。 Filter Graph Manager 可以使用系统时间。

Nominally, a reference clock measures time in 100-nanosecond intervals, although the actual accuracy of the clock might be less. To retrieve the clock's current time, call the IReferenceClock::GetTime method. The clock's baseline—the time from which it starts counting—depends on the implementation, so the value returned by GetTime is not inherently meaningful. What matters is the delta from when the graph started running. 

理论上参考时钟每 100 纳秒记录一次时间,实际上时钟的精度会有偏差。要获得当前时钟的时间,可以调用 IReferenceClock::GetTime 函数。时钟的起点 时间从什么时候开始计算 依赖于执行情况,所以 GetTime 返回的值没有意义。

Although the accuracy of a reference clock can vary, the times returned by the GetTime method are guaranteed to increase monotonically. In other words, clock times will never go backward. If a reference clock is generating clock times from a hardware source and the hardware clock jumps backward (for example, if there is an adjustment to the clock), the GetTime method should continue to return the last reported time until the hardware clock catches up. For more information, see CBaseReferenceClock Class .

尽管参考时钟的精准性会不同, GetTime 函数返回的时间也还是保持单调递增。换句话说,时钟时间从不会倒退。如果一个参考时钟从硬件源产生时钟时间且硬件时钟向后调整, GetTime 函数将继续返回最后一次报告的时间,直到硬件时钟赶上。

The Filter Graph Manager automatically selects a reference clock when the graph runs. It uses the following algorithm to select the clock:

graph 运行时, Filter Graph Manager 自动选择参考时钟。使用下列规则选择时钟:

·         If the application has selected a clock (see below), use that clock.

·         If the graph contains a live source filter that supports IReferenceClock , use that filter. For the definition of a live source, see Live Sources .

·         If the graph does not contain any live source filters, use any filter in the graph that supports IReferenceClock , starting from the renderers and working upstream.  Prefer connected filters over unconnected filters. (If the graph is rendering an audio stream, this step in the algorithm will normally select the audio renderer filter.)

·         If no filter provides a suitable clock, use the System Reference Clock , which is based on the system time.

·         如果应用程序已经选择的时钟,那就使用这个时钟。

·         如果 graph 包含了一个支持 IReferenceClock live source filter ,那就使用这个 filter

·         如果 graph 没有包含任何 live source filter ,就使用 graph 中支持 IReferenceClock filter ,从 renderer 开始,工作到上游 . 选择已连接的 filter 而不选择未连接的。(如果 graph 是正在播放一个音频流,那么这一步就选择 audio renderer filter 。)

·         如果没有 filter 提供适当的时钟,就使用 System Reference Clock

An application can select a clock by calling the IMediaFilter::SetSyncSource method on the Filter Graph Manager. You should do this only if you have a particular reason to prefer another clock.

应用程序可以在 Filter Graph Manager 上调用 IMediaFilter::SetSyncSource 函数选择时钟。如果有特殊的原因选择其他的时钟,可以这样做。

You can instruct the Filter Graph Manager not to use a reference clock by calling SetSyncSource with the value NULL. For example, you might do this to process samples as quickly as possible. To restore the default reference clock, call the IFilterGraph::SetDefaultSyncSource method on the Filter Graph Manager.

也可以在调用 SetSynceSource 的时候传入 NULL 作为参数来命令 Filter Graph Manager 不使用参考时钟。例如,

Whenever the reference clock changes, the Filter Graph Manager notifies each filter by calling its IMediaFilter::SetSyncSource method. Applications should never call this method on filters.

当参考时钟改变, Filter Graph Manager 调用 IMediaFilter::SetSyncSource 函数通知每一个 filter 。应用程序不需要调用这个方法。

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值