Crate v4l2loopback
source ·Expand description
Safe binding to interact with v4l2loopback.
v4l2loopback allows your to manage virtual video devices on linux. Application are able to pass video content to those devices, and this video feed will be available as a camera.
⚠️ Warning:
This crate is based on an unreleased version of v4l2loopback. To use this crate you will need to build and install v4l2loopback from source. (If you are on archlinux, you can install v4l2loopback-dkms-git from the aur)
Usage
use std::path::Path;
use v4l2loopback::{add_device, delete_device, query_device, DeviceConfig};
// Device configuration
// Here you declare informations about the camera device that will be created.
// It should be matching the content that you will want to pass through
let device_config = DeviceConfig {
label: "Test Device".to_string(),
min_width: 100,
max_width: 4000,
min_height: 100,
max_height: 4000,
max_buffers: 9,
max_openers: 3,
};
// Create a device
let device_num =
add_device(None, device_config.clone()).expect("Error when creating the device");
// Querying informations about a device
// This returns the matchin device's configuration
let cfg =
query_device(device_num).expect("Error when querying the device");
// When you are done with you processing, don't forget to delete the device, otherwise the
// device `/dev/videoN` will not be removed.
delete_device(device_num).expect("Error when removing device");
assert!(!Path::new(&format!("/dev/video{}", device_num)).exists());
Structs
- Wrapper type describing a v4l2loopback device.
Enums
- Error generated when accessing the control device fails
- Error which can occure when calling a function from this crate
Constants
Functions
- Create a new v4l2loopback device.
- Delete a v4l2loopback device.
- Queries the configuration for a specified device.