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