Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

A V4L2 device.

Implementations§

Source§

impl Device

Source

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.

Source

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.

Source

pub fn capabilities(&self) -> Result<Capabilities>

Queries the device’s Capabilities.

Source

pub fn supported_buf_types(&self) -> BufTypes

Source

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.

Source

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).

Source

pub fn frame_intervals( &self, pixel_format: PixelFormat, width: u32, height: u32, ) -> Result<FrameIntervals>

Source

pub fn inputs(&self) -> InputIter<'_>

Returns an iterator over the Inputs of the device.

§Errors

May return ENOTTY if the device is not an input device.

Source

pub fn outputs(&self) -> OutputIter<'_>

Returns an iterator over the Outputs of the device.

§Errors

May return ENOTTY if the device is not an output device.

Source

pub fn controls(&self) -> ControlIter<'_>

Source

pub fn enumerate_menu(&self, ctrl: &ControlDesc) -> TextMenuIter<'_>

Returns an iterator over the valid values of a menu control.

Source

pub fn read_control_raw(&self, cid: Cid) -> Result<i32>

Source

pub fn write_control_raw(&mut self, cid: Cid, value: i32) -> Result<()>

Source

pub fn format(&self, buf_type: BufType) -> Result<Format>

Reads the stream format in use by buf_type.

The returned Format variant will match buf_type.

If no format is set, this returns EINVAL.

§Panics

This will panic if buf_type corresponds to a buffer type that hasn’t yet been implemented in Format.

Source

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.

Source

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.

Source

pub fn meta_capture(self, format: MetaFormat) -> Result<MetaCaptureDevice>

Puts the device into metadata capture mode and negotiates a data format.

Trait Implementations§

Source§

impl AsFd for Device

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

impl AsRawFd for Device

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.