[−][src]Struct v4l::output::device::Device
Linux output device abstraction
Implementations
impl Device
[src]
pub fn new(index: usize) -> Result<Self>
[src]
Returns an output device by index
Devices are usually enumerated by the system. An index of zero thus represents the first device the system got to know about.
Arguments
index
- Index (0: first, 1: second, ..)
Example
use v4l::output::Device; let dev = Device::new(0);
pub fn with_path<P: AsRef<Path>>(path: P) -> Result<Self>
[src]
Returns an output device by path
Linux device nodes are usually found in /dev/videoX or /sys/class/video4linux/videoX.
Arguments
path
- Path (e.g. "/dev/video0")
Example
use v4l::output::Device; let dev = Device::with_path("/dev/video0");
pub fn enum_formats(&self) -> Result<Vec<Description>>
[src]
Returns a vector of valid formats for this device
The "emulated" field describes formats filled in by libv4lconvert. There may be a conversion related performance penalty when using them.
Example
use v4l::output::Device; if let Ok(dev) = Device::new(0) { let formats = dev.enum_formats(); if let Ok(formats) = formats { for fmt in formats { print!("{}", fmt); } } }
pub fn format(&self) -> Result<Format>
[src]
Returns the format currently in use
Example
use v4l::output::Device; if let Ok(dev) = Device::new(0) { let fmt = dev.format(); if let Ok(fmt) = fmt { print!("Active format:\n{}", fmt); } }
pub fn set_format(&mut self, fmt: &Format) -> Result<Format>
[src]
Modifies the output format and returns the actual format
The driver tries to match the format parameters on a best effort basis. Thus, if the combination of format properties cannot be achieved, the closest possible settings are used and reported back.
Arguments
fmt
- Desired format
Example
use v4l::output::Device; if let Ok(mut dev) = Device::new(0) { let fmt = dev.format(); if let Ok(mut fmt) = fmt { fmt.width = 640; fmt.height = 480; print!("Desired format:\n{}", fmt); let fmt = dev.set_format(&fmt); match fmt { Ok(fmt) => print!("Actual format:\n{}", fmt), Err(e) => print!("{}", e), } } }
pub fn params(&self) -> Result<Parameters>
[src]
Returns the parameters currently in use
Example
use v4l::output::Device; if let Ok(dev) = Device::new(0) { let params = dev.params(); if let Ok(params) = params { print!("Active parameters:\n{}", params); } }
pub fn set_params(&mut self, params: &Parameters) -> Result<Parameters>
[src]
Modifies the output parameters and returns the actual parameters
Arguments
params
- Desired parameters
Example
use v4l::output::{Device, Parameters}; if let Ok(mut dev) = Device::new(0) { let params = dev.params(); if let Ok(mut params) = params { params = Parameters::with_fps(30); print!("Desired parameters:\n{}", params); let params = dev.set_params(¶ms); match params { Ok(params) => print!("Actual parameters:\n{}", params), Err(e) => print!("{}", e), } } }
pub fn control(&self, id: u32) -> Result<Control>
[src]
Returns the control value for an ID
Arguments
id
- Control identifier
Example
use v4l::output::Device; use v4l::Control; use v4l2_sys::V4L2_CID_BRIGHTNESS; if let Ok(dev) = Device::new(0) { let ctrl = dev.control(V4L2_CID_BRIGHTNESS); if let Ok(val) = ctrl { match val { Control::Value(val) => { println!("Brightness: {}", val) } _ => {} } } }
pub fn set_control(&mut self, id: u32, val: Control) -> Result<()>
[src]
Trait Implementations
impl Device for Device
[src]
fn handle(&self) -> Arc<Handle>
[src]
Returns the handle of the device
Example
use v4l::output::Device as OutputDevice; use v4l::device::Device; if let Ok(dev) = OutputDevice::new(0) { print!("Device file descriptor: {}", dev.handle().fd()); }
fn typ(&self) -> Type
[src]
impl TryFrom<Info> for Device
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(info: Info) -> Result<Self, Self::Error>
[src]
impl Write for Device
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnwindSafe for Device
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> QueryDevice for T where
T: Device,
[src]
T: Device,
fn enum_frameintervals(
&Self,
FourCC,
u32,
u32
) -> Result<Vec<FrameInterval>, Error>
[src]
&Self,
FourCC,
u32,
u32
) -> Result<Vec<FrameInterval>, Error>
fn enum_framesizes(&Self, FourCC) -> Result<Vec<FrameSize>, Error>
[src]
fn query_caps(&Self) -> Result<Capabilities, Error>
[src]
fn query_controls(&Self) -> Result<Vec<Description>, Error>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,