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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
use std::io;
use crate::video::capture::Parameters as CaptureParameters;
use crate::video::output::Parameters as OutputParameters;
use crate::{
format::Description as FormatDescription, format::Format, format::FourCC,
frameinterval::FrameInterval, framesize::FrameSize,
};
/// Capture device protocol
pub trait Capture {
/// Returns a vector of all frame intervals that the device supports for the given pixel format
/// and frame size
fn enum_frameintervals(
&self,
fourcc: FourCC,
width: u32,
height: u32,
) -> io::Result<Vec<FrameInterval>>;
/// Returns a vector of valid framesizes that the device supports for the given pixel format
fn enum_framesizes(&self, fourcc: FourCC) -> io::Result<Vec<FrameSize>>;
/// 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.
fn enum_formats(&self) -> io::Result<Vec<FormatDescription>>;
/// Returns the format currently in use
fn format(&self) -> io::Result<Format>;
/// Modifies the capture 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
fn set_format(&self, fmt: &Format) -> io::Result<Format>;
/// Returns the parameters currently in use
fn params(&self) -> io::Result<CaptureParameters>;
/// Modifies the capture parameters and returns the actual parameters
///
/// # Arguments
///
/// * `params` - Desired parameters
fn set_params(&self, params: &CaptureParameters) -> io::Result<CaptureParameters>;
}
/// Output device protocol
pub trait Output {
/// Returns a vector of all frame intervals that the device supports for the given pixel format
/// and frame size
fn enum_frameintervals(
&self,
fourcc: FourCC,
width: u32,
height: u32,
) -> io::Result<Vec<FrameInterval>>;
/// Returns a vector of valid framesizes that the device supports for the given pixel format
fn enum_framesizes(&self, fourcc: FourCC) -> io::Result<Vec<FrameSize>>;
/// 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.
fn enum_formats(&self) -> io::Result<Vec<FormatDescription>>;
/// Returns the format currently in use
fn format(&self) -> io::Result<Format>;
/// Modifies the capture 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
fn set_format(&self, fmt: &Format) -> io::Result<Format>;
/// Returns the parameters currently in use
fn params(&self) -> io::Result<OutputParameters>;
/// Modifies the output parameters and returns the actual parameters
///
/// # Arguments
///
/// * `params` - Desired parameters
fn set_params(&self, params: &OutputParameters) -> io::Result<OutputParameters>;
}