windows 上的 OBS-Studio 虚拟相机中的数据如何通过引脚在过滤器之间移动?

How data is moving across filters through pins in OBS-Studio virtual camera on windows?

我喜欢 OBS-Studio 的虚拟相机功能。

我试图理解它的工作原理,但无法正确理解。我只知道它是使用 DirectShow 构建的。项目包含 OutputFilter, OutputPin, CaptureFilter and CapturePin

class OutputFilter : public IBaseFilter {
    // ...
    friend class OutputPin;
    IFilterGraph *graph;
    ComPtr<OutputPin> pin;
    // ...
}

class OutputPin : public IPin, public IAMStreamConfig, public IKsPropertySet {
    // ...
    friend class OutputFilter;
    // ...
}

class CaptureFilter : public IBaseFilter {
    // ...
    friend class CapturePin;
    ComPtr<IFilterGraph> graph;
    ComPtr<CapturePin> pin;
    // ...
}

class CapturePin : public IPin, public IMemInputPin {
    // ...
    CaptureFilter *filter;
    // ...
}

当我们启用虚拟相机时,数据如何在这些过滤器和引脚之间移动?

他们正在使用 shared memory server. Basically, they have a rendering filter that copies the incoming bitmaps into the shared memory. And then they have a capture filter that reads the bitmaps from the shared memory. You can see some of their code here: win-dshow