umlaeute / v4l2loopback

v4l2-loopback device
GNU General Public License v2.0
3.73k stars 531 forks source link

Created attribute active_readers #592

Open kputyra opened 2 months ago

kputyra commented 2 months ago

The attribute active_readers contains the number of openers of a video loopback device that has opened it for streaming (the property active_readers or v4l2_loopback_device).

This parameter is already provided via a client event V4L2_EVENT_PRI_CLIENT_USAGE (emitted each time the loopback device is captured or released), but its value is not easily accessible otherwise, in particular when an application feeding the loopback device starts and no new event has been emitted yet. Exposing this value as an attribute fixes this issue.

I am already using this attribute in an application that feeds a loopback device with a video stream whenever the device is captured. The value of the attribute is checked by the application on start to determine if the device should be fed immediately (for instance after reloading the app due to an error).