====== DirectShow ====== * https://docs.microsoft.com/en-us/windows/win32/directshow/directshow ===== Tips ===== ==== Filter States ==== * https://docs.microsoft.com/en-us/windows/win32/directshow/filter-states * Filters have three possible states: **stopped**, **paused**, and **running** [[https://docs.microsoft.com/en-us/windows/win32/api/strmif/ne-strmif-filter_state|FILTER_STATE]] * Transitions between stopped and running always go through the paused state, so if the application calls Run on a stopped graph, the Filter Graph Manager pauses the graph before running it. 即**每次 running 状态前必定有 paused 状态,包括初次点开始播放时** * The Filter Graph Manager carries out all state transitions in upstream order, starting from the renderer and working backward to the source filter. FGM 控制各 Filter 的状态的顺序是从最下游的渲染层开始,再依次回到最上游资源filter。实时流数据例外 ==== Events ==== * https://docs.microsoft.com/en-us/windows/win32/directshow/retrieving-events * ==== Time and Clocks ==== * https://docs.microsoft.com/en-us/windows/win32/directshow/time-and-clocks-in-directshow * 实现了接口 [[https://docs.microsoft.com/en-us/windows/win32/api/strmif/nn-strmif-ireferenceclock|IReferenceClock]]的对象都可作为DirectShow的参考时钟。 * 参考时钟以 **100 纳秒**(100-nanosecond)为单位。 * 参考时钟的开始值取决于实现,''IReferenceClock::GetTime'' 的返回值没有意义,应只关注两次 GetTime 的增量。 GetTime 始终单调增加,不会回退。 * DirectShow 通常使用音频渲染Filter作为参考时钟,如果没有就使用系统时钟。音频渲染Filter可访问硬件时钟。(oak: 所以VDI虚拟机上视频播放速率与系统时间不一致的原因可能是虚拟机的音频设备的问题)。 * The Filter Graph Manager 选择参考时钟的优先顺序: - 应用指定(''IMediaFilter::SetSyncSource'') - 拥有参考时钟的[[https://docs.microsoft.com/en-us/windows/win32/directshow/live-sources|live source filter]] - 从音频渲染Filter开始,往上游找拥有参考时钟的Filter - [[https://docs.microsoft.com/en-us/windows/win32/directshow/system-reference-clock|系统参考时钟]] * Media Times: 可理解为流的样本计数 ===== Filters ===== ==== EVR ==== * [[https://docs.microsoft.com/en-us/windows/win32/medfound/enhanced-video-renderer|Enhanced video renderer]]