pub struct Device { /* private fields */ }Expand description
A V4L2 device.
Implementations§
Source§impl Device
impl Device
Sourcepub fn open<A: AsRef<Path>>(path: A) -> Result<Self>
pub fn open<A: AsRef<Path>>(path: A) -> Result<Self>
Opens a V4L2 device file from the given path.
If the path does not refer to a V4L2 device node, an error will be returned.
Sourcepub fn path(&self) -> Result<PathBuf>
pub fn path(&self) -> Result<PathBuf>
Returns the path to the V4L2 device.
This will invoke readlink(2) on /proc/self/fd/N to find the path, so it will not work
on FreeBSD or other Unix-likes that don’t expose a procfs with this functionality.
Sourcepub fn capabilities(&self) -> Result<Capabilities>
pub fn capabilities(&self) -> Result<Capabilities>
Queries the device’s Capabilities.
pub fn supported_buf_types(&self) -> BufTypes
Sourcepub fn formats(&self, buf_type: BufType) -> FormatDescIter<'_> ⓘ
pub fn formats(&self, buf_type: BufType) -> FormatDescIter<'_> ⓘ
Enumerates the supported pixel formats of a stream.
buf_type must be one of VIDEO_CAPTURE, VIDEO_CAPTURE_MPLANE, VIDEO_OUTPUT,
VIDEO_OUTPUT_MPLANE, VIDEO_OVERLAY, SDR_CAPTURE, SDR_OUTPUT, META_CAPTURE, or
META_OUTPUT.
Sourcepub fn frame_sizes(&self, pixel_format: PixelFormat) -> Result<FrameSizes>
pub fn frame_sizes(&self, pixel_format: PixelFormat) -> Result<FrameSizes>
Returns the supported frame sizes for a given pixel format.
§Errors
An ENOTTY error will be returned if pixel_format specifies a format that does not
describe video data (for example, PixelFormat::UVC or other metadata formats).
pub fn frame_intervals( &self, pixel_format: PixelFormat, width: u32, height: u32, ) -> Result<FrameIntervals>
Sourcepub fn outputs(&self) -> OutputIter<'_> ⓘ
pub fn outputs(&self) -> OutputIter<'_> ⓘ
pub fn controls(&self) -> ControlIter<'_> ⓘ
Returns an iterator over the valid values of a menu control.
pub fn read_control_raw(&self, cid: Cid) -> Result<i32>
pub fn write_control_raw(&mut self, cid: Cid, value: i32) -> Result<()>
Sourcepub fn video_capture(self, format: PixFormat) -> Result<VideoCaptureDevice>
pub fn video_capture(self, format: PixFormat) -> Result<VideoCaptureDevice>
Puts the device into video capture mode and negotiates a pixel format.
§Format Negotiation
Generally, the driver is allowed to change most properties of the PixFormat, including
the requested dimensions and the PixelFormat, if the provided value is not supported.
However, it is not required to do so and may instead return EINVAL if the parameters are
not supported. One example where this happens is with v4l2loopback.
Sourcepub fn video_output(self, format: PixFormat) -> Result<VideoOutputDevice>
pub fn video_output(self, format: PixFormat) -> Result<VideoOutputDevice>
Puts the device into video output mode and negotiates a pixel format.
§Format Negotiation
Generally, the driver is allowed to change most properties of the PixFormat, including
the requested dimensions and the PixelFormat, if the provided value is not supported.
However, it is not required to do so and may instead return EINVAL if the parameters are
not supported. One example where this happens is with v4l2loopback.
Sourcepub fn meta_capture(self, format: MetaFormat) -> Result<MetaCaptureDevice>
pub fn meta_capture(self, format: MetaFormat) -> Result<MetaCaptureDevice>
Puts the device into metadata capture mode and negotiates a data format.