#![allow(bad_style)]
pub mod controls;
use std::ffi::{c_int, c_void};
use std::os::raw::c_ulong;
use libc::timeval;
use uoctl::{Ioctl, _IOR, _IOW, _IOWR};
use crate::buf_type::BufType;
use crate::{shared::*, PixelFormat};
pub const VIDEO_MAX_PLANES: usize = 8;
#[repr(C)]
#[derive(Debug)]
pub struct Capabilities {
pub driver: [u8; 16],
pub card: [u8; 32],
pub bus_info: [u8; 32],
pub version: u32,
pub capabilities: CapabilityFlags,
pub device_caps: CapabilityFlags,
reserved: [u32; 3],
}
#[repr(C)]
pub struct FmtDesc {
pub index: u32,
pub type_: BufType,
pub flags: FormatFlags,
pub description: [u8; 32],
pub pixel_format: PixelFormat,
pub mbus_code: u32,
pub reserved: [u32; 3],
}
#[repr(C)]
pub struct Format {
pub type_: BufType,
pub fmt: FormatUnion,
}
#[repr(C)]
pub union FormatUnion {
pub pix: PixFormat,
pub pix_mp: PixFormatMplane,
pub win: Window,
pub meta: MetaFormat,
pub raw_data: [u8; 200],
}
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct Rect {
pub left: i32,
pub top: i32,
pub width: u32,
pub height: u32,
}
#[allow(dead_code)] #[derive(Clone, Copy)]
#[repr(C)]
pub struct Area {
pub width: u32,
pub height: u32,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Clip {
pub c: Rect,
pub next: *mut Clip,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Window {
pub w: Rect,
pub field: Field,
pub chromakey: u32,
pub clips: *mut Clip,
pub clipcount: u32,
pub bitmap: *mut c_void,
pub global_alpha: u8,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct PixFormat {
pub width: u32,
pub height: u32,
pub pixel_format: PixelFormat,
pub field: Field,
pub bytesperline: u32,
pub sizeimage: u32,
pub colorspace: Colorspace,
pub priv_: u32,
pub flags: PixFmtFlag,
pub enc: u32,
pub quantization: Quantization,
pub xfer_func: XferFunc,
}
#[derive(Clone, Copy)]
#[repr(C, packed)]
pub struct PlanePixFormat {
pub sizeimage: u32,
pub bytesperline: u32,
pub reserved: [u16; 6],
}
#[derive(Clone, Copy)]
#[repr(C, packed)]
pub struct PixFormatMplane {
pub width: u32,
pub height: u32,
pub pixel_format: PixelFormat,
pub field: u32,
pub colorspace: u32,
pub plane_fmt: [PlanePixFormat; VIDEO_MAX_PLANES],
pub num_planes: u8,
pub flags: u8,
pub enc: u8,
pub quantization: u8,
pub xfer_func: u8,
pub reserved: [u8; 7],
}
#[repr(C)]
pub struct Output {
pub index: u32,
pub name: [u8; 32],
pub type_: OutputType,
pub audioset: u32,
pub modulator: u32,
pub std: AnalogStd,
pub capabilities: OutputCapabilities,
pub reserved: [u32; 3],
}
#[derive(Clone, Copy)]
#[repr(C, packed)]
pub struct MetaFormat {
pub dataformat: PixelFormat,
pub buffersize: u32,
}
#[repr(C)]
pub struct Input {
pub index: u32,
pub name: [u8; 32],
pub type_: InputType,
pub audioset: u32,
pub tuner: u32,
pub std: AnalogStd,
pub status: InputStatus,
pub capabilities: InputCapabilities,
pub reserved: [u32; 3],
}
#[repr(C)]
pub struct QueryCtrl {
pub id: u32,
pub type_: CtrlType,
pub name: [u8; 32],
pub minimum: i32,
pub maximum: i32,
pub step: i32,
pub default_value: i32,
pub flags: ControlFlags,
pub reserved: [u32; 2],
}
#[repr(C, packed)]
pub struct QueryMenu {
pub id: u32,
pub index: u32,
pub name_or_value: QueryMenuUnion,
pub reserved: u32,
}
#[repr(C)]
pub union QueryMenuUnion {
pub name: [u8; 32],
pub value: i64,
}
#[derive(Debug)]
#[repr(C)]
pub struct RequestBuffers {
pub count: u32,
pub type_: BufType,
pub memory: Memory,
pub capabilities: BufCap,
pub reserved: [u32; 1],
}
#[repr(C)]
pub struct Timecode {
pub type_: TimecodeType,
pub flags: TimecodeFlags,
pub frames: u8,
pub seconds: u8,
pub minutes: u8,
pub hours: u8,
pub userbits: [u8; 4],
}
#[repr(C)]
pub struct Buffer {
pub index: u32,
pub type_: BufType,
pub bytesused: u32,
pub flags: BufFlag,
pub field: u32,
pub timestamp: timeval,
pub timecode: Timecode,
pub sequence: u32,
pub memory: Memory,
pub m: BufferMemoryUnion,
pub length: u32,
pub reserved2: u32,
pub tail: BufferTailUnion,
}
#[repr(C)]
pub union BufferMemoryUnion {
pub offset: u32,
pub userptr: c_ulong,
pub planes: *mut Plane,
pub fd: i32,
}
#[repr(C)]
pub union BufferTailUnion {
pub request_fd: i32,
pub reserved: u32,
}
#[repr(C)]
pub struct Plane {
pub bytesused: u32,
pub length: u32,
pub m: PlaneMemoryUnion,
pub data_offset: u32,
pub reserved: [u32; 11],
}
#[repr(C)]
pub union PlaneMemoryUnion {
pub mem_offset: u32,
pub userptr: c_ulong,
pub fd: i32,
}
#[repr(C)]
pub struct FrmSizeEnum {
pub index: u32,
pub pixel_format: PixelFormat,
pub type_: FrmSizeType,
pub union: FrmSizeUnion,
pub reserved: [u32; 2],
}
#[repr(C)]
pub union FrmSizeUnion {
pub discrete: FrmSizeDiscrete,
pub stepwise: FrmSizeStepwise,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct FrmSizeDiscrete {
pub width: u32,
pub height: u32,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct FrmSizeStepwise {
pub min_width: u32,
pub max_width: u32,
pub step_width: u32,
pub min_height: u32,
pub max_height: u32,
pub step_height: u32,
}
#[repr(C)]
pub struct FrmIvalEnum {
pub index: u32,
pub pixel_format: PixelFormat,
pub width: u32,
pub height: u32,
pub type_: FrmIvalType,
pub union: FrmIvalUnion,
pub reserved: [u32; 2],
}
#[repr(C)]
pub union FrmIvalUnion {
pub discrete: Fract,
pub stepwise: FrmIvalStepwise,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct FrmIvalStepwise {
pub min: Fract,
pub max: Fract,
pub step: Fract,
}
#[repr(C)]
pub struct StreamParm {
pub type_: BufType,
pub union: StreamParmUnion,
}
#[repr(C)]
pub union StreamParmUnion {
pub capture: CaptureParm,
pub output: OutputParm,
pub raw_data: [u8; 200],
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CaptureParm {
pub capability: StreamParamCaps,
pub capturemode: CaptureParamFlags,
pub timeperframe: Fract,
pub extendedmode: u32,
pub readbuffers: u32,
pub reserved: [u32; 4],
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct OutputParm {
pub capability: StreamParamCaps,
pub outputmode: u32,
pub timeperframe: Fract,
pub extendedmode: u32,
pub writebuffers: u32,
pub reserved: [u32; 4],
}
pub const VIDIOC_QUERYCAP: Ioctl<*mut Capabilities> = _IOR(b'V', 0);
pub const VIDIOC_ENUM_FMT: Ioctl<*mut FmtDesc> = _IOWR(b'V', 2);
pub const VIDIOC_G_FMT: Ioctl<*mut Format> = _IOWR(b'V', 4);
pub const VIDIOC_S_FMT: Ioctl<*mut Format> = _IOWR(b'V', 5);
pub const VIDIOC_REQBUFS: Ioctl<*mut RequestBuffers> = _IOWR(b'V', 8);
pub const VIDIOC_QUERYBUF: Ioctl<*mut Buffer> = _IOWR(b'V', 9);
pub const VIDIOC_QBUF: Ioctl<*mut Buffer> = _IOWR(b'V', 15);
pub const VIDIOC_DQBUF: Ioctl<*mut Buffer> = _IOWR(b'V', 17);
pub const VIDIOC_STREAMON: Ioctl<*const c_int> = _IOW(b'V', 18);
pub const VIDIOC_STREAMOFF: Ioctl<*const c_int> = _IOW(b'V', 19);
pub const VIDIOC_S_PARM: Ioctl<*mut StreamParm> = _IOWR(b'V', 22);
pub const VIDIOC_ENUMINPUT: Ioctl<*mut Input> = _IOWR(b'V', 26);
pub const VIDIOC_G_CTRL: Ioctl<*mut controls::Control> = _IOWR(b'V', 27);
pub const VIDIOC_S_CTRL: Ioctl<*mut controls::Control> = _IOWR(b'V', 28);
pub const VIDIOC_QUERYCTRL: Ioctl<*mut QueryCtrl> = _IOWR(b'V', 36);
pub const VIDIOC_QUERYMENU: Ioctl<*mut QueryMenu> = _IOWR(b'V', 37);
pub const VIDIOC_ENUMOUTPUT: Ioctl<*mut Output> = _IOWR(b'V', 48);
pub const VIDIOC_ENUM_FRAMESIZES: Ioctl<*mut FrmSizeEnum> = _IOWR(b'V', 74);
pub const VIDIOC_ENUM_FRAMEINTERVALS: Ioctl<*mut FrmIvalEnum> = _IOWR(b'V', 75);