Struct linuxvideo::Device

source ·
pub struct Device { /* private fields */ }
Expand description

A V4L2 device.

Implementations§

source§

impl Device

source

pub fn open(path: &Path) -> 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.

source

pub fn capabilities(&self) -> Result<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<'_>

source

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

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 Debug for Device

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.