c++webcamvideo-capturems-media-foundationwebcam-capture

Can mediafoundation allow multiple clients to simultaneously access a single webcam device?


I intend to build an adapter exposing methods such as "StartCapture" and "StopCapture" using mediafoundation and would like multiple clients to be able to access these methods simultaneously from a single webcam device.

Currently the code I've seen in samples allows only for 1 stream to capture data in a file (the other ends up being empty).

Does mediafoundation allow for simultaneous device access? If so how?


Solution

  • Video input devices have traditionally been exclusive use resources. Once one client started a session, other clients cannot use the camera before it's released by the running session.

    Windows 10 Anniversary Update introduced so called Frame Server, which is a middleware layer that, as was advertised, shared the camera between clients under certain circumstances.

    This puts an end to the "exclusive" use of devices, and it's arguably a change that Windows should have made long ago. Third-party software for sharing cameras between applications exists, but the operating system should support this scenario natively, as it already does for audio devices.

    To my best knowledge this does not work. At least it did not work for a few cameras I tried, and as of now the sharing does not work with Windows 10 Creators Update. Quote possibly though certain cameras/modes exist for which the feature is implementing the sharing.