有人知道DirectShow过滤器如何交换媒体样本吗?
我们知道源过滤器抓取样本(来自MIC或Live),并将其传递到图形中的下一个过滤器。
显然我想知道过滤器如何将样本传递给另一个过滤器?
是否有已知的模式?
如果我决定在没有任何第三方组件的情况下实现音频处理过滤器,
是否可以使用多生产者/消费者队列来实现媒体样本交换?
假设源过滤器F1是媒体捕获过滤器,过滤器F2是DSP过滤器。
F1写入Multi Producer / Consumer队列,如果有可用样本,F2消耗F1排队的捕获样本。有它自己的线程)。
有什么更好的办法吗?
*EDIT : our solution must looks like Publisher Subscriber pattern , but i think this not suitable for media processing.
非常感谢你
最佳答案
MSDN在Overview of Data Flow in DirectShow中提供了非常详细的描述。您需要整篇文章,以下是有关过滤器之间专门交换数据的摘录:
[...] Whenever a filter needs to fill a buffer with data, it requests a sample from the allocator by calling IMemAllocator::GetBuffer. If the allocator has any samples that are not currently in use by another filter, the GetBuffer method returns immediately with a pointer to the sample. If all of the allocator's samples are in use, the method blocks until a sample becomes available. When the method does return a sample, the filter puts data into the buffer, sets the appropriate flags on the sample (typically including a time stamp), and delivers the sample downstream. [...]
关于audio - Directshow筛选器如何交换媒体样本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24851868/