1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
pub mod parameters; pub use parameters::Parameters; use std::convert::TryFrom; use std::{io, mem}; use crate::buffer::Type; use crate::device::Device; use crate::format::FourCC; use crate::format::{Description as FormatDescription, Format}; use crate::frameinterval::FrameInterval; use crate::framesize::FrameSize; use crate::v4l2; use crate::v4l_sys::*; use crate::video::traits::Capture; impl Capture for Device { impl_enum_frameintervals!(); impl_enum_framesizes!(); impl_enum_formats!(Type::VideoCapture); impl_format!(Type::VideoCapture); impl_set_format!(Type::VideoCapture); fn params(&self) -> io::Result<Parameters> { unsafe { let mut v4l2_params: v4l2_streamparm = mem::zeroed(); v4l2_params.type_ = Type::VideoCapture as u32; v4l2::ioctl( self.handle().fd(), v4l2::vidioc::VIDIOC_G_PARM, &mut v4l2_params as *mut _ as *mut std::os::raw::c_void, )?; Ok(Parameters::from(v4l2_params.parm.capture)) } } fn set_params(&self, params: &Parameters) -> io::Result<Parameters> { unsafe { let mut v4l2_params: v4l2_streamparm = mem::zeroed(); v4l2_params.type_ = Type::VideoCapture as u32; v4l2_params.parm.capture = (*params).into(); v4l2::ioctl( self.handle().fd(), v4l2::vidioc::VIDIOC_S_PARM, &mut v4l2_params as *mut _ as *mut std::os::raw::c_void, )?; } self.params() } }