Skip to main content

SimpleCaptureDevice

Struct SimpleCaptureDevice 

Source
pub struct SimpleCaptureDevice<Q: VirtioMediaEventQueue, HM: VirtioMediaHostMemoryMapper> { /* private fields */ }
Expand description

A simplistic video capture device, used to demonstrate how device code can be written, or for testing VMMs and guests without dedicated hardware support.

This device supports a single pixel format (RGB3) and a single resolution, and generates frames of varying uniform color. The only buffer type supported is MMAP

Implementations§

Source§

impl<Q, HM> SimpleCaptureDevice<Q, HM>

Source

pub fn new(evt_queue: Q, mapper: HM) -> Self

Trait Implementations§

Source§

impl<Q, HM, Reader, Writer> VirtioMediaDevice<Reader, Writer> for SimpleCaptureDevice<Q, HM>

Source§

type Session = SimpleCaptureDeviceSession

Source§

fn new_session(&mut self, session_id: u32) -> Result<Self::Session, i32>

Create a new session which ID is session_id. Read more
Source§

fn close_session(&mut self, session: Self::Session)

Close the passed session.
Source§

fn do_ioctl( &mut self, session: &mut Self::Session, ioctl: V4l2Ioctl, reader: &mut Reader, writer: &mut Writer, ) -> IoResult<()>

Perform the IOCTL command and write the response into writer. Read more
Source§

fn do_mmap( &mut self, session: &mut Self::Session, flags: u32, offset: u32, ) -> Result<(u64, u64), i32>

Performs the MMAP command. Read more
Source§

fn do_munmap(&mut self, guest_addr: u64) -> Result<(), i32>

Performs the MUNMAP command. Read more
Source§

fn process_events(&mut self, _session: &mut Self::Session) -> Result<(), i32>

Source§

impl<Q, HM> VirtioMediaIoctlHandler for SimpleCaptureDevice<Q, HM>

Implementations of the ioctls required by a CAPTURE device.

Source§

type Session = SimpleCaptureDeviceSession

Source§

fn enum_fmt( &mut self, _session: &Self::Session, queue: QueueType, index: u32, ) -> IoctlResult<v4l2_fmtdesc>

Source§

fn g_fmt( &mut self, _session: &Self::Session, queue: QueueType, ) -> IoctlResult<v4l2_format>

Source§

fn s_fmt( &mut self, _session: &mut Self::Session, queue: QueueType, _format: v4l2_format, ) -> IoctlResult<v4l2_format>

Hook for the VIDIOC_S_FMT ioctl. Read more
Source§

fn try_fmt( &mut self, _session: &Self::Session, queue: QueueType, _format: v4l2_format, ) -> IoctlResult<v4l2_format>

Hook for the VIDIOC_TRY_FMT ioctl. Read more
Source§

fn g_parm( &mut self, _session: &Self::Session, queue: QueueType, ) -> IoctlResult<v4l2_streamparm>

Source§

fn s_parm( &mut self, _session: &mut Self::Session, parm: v4l2_streamparm, ) -> IoctlResult<v4l2_streamparm>

Source§

fn reqbufs( &mut self, session: &mut Self::Session, queue: QueueType, memory: MemoryType, count: u32, _flags: MemoryConsistency, ) -> IoctlResult<v4l2_requestbuffers>

Source§

fn querybuf( &mut self, session: &Self::Session, queue: QueueType, index: u32, ) -> IoctlResult<V4l2Buffer>

Source§

fn qbuf( &mut self, session: &mut Self::Session, buffer: V4l2Buffer, _guest_regions: Vec<Vec<SgEntry>>, ) -> IoctlResult<V4l2Buffer>

Source§

fn streamon( &mut self, session: &mut Self::Session, queue: QueueType, ) -> IoctlResult<()>

Source§

fn streamoff( &mut self, session: &mut Self::Session, queue: QueueType, ) -> IoctlResult<()>

Source§

fn g_input(&mut self, _session: &Self::Session) -> IoctlResult<i32>

Source§

fn s_input( &mut self, _session: &mut Self::Session, input: i32, ) -> IoctlResult<i32>

Source§

fn enuminput( &mut self, _session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_input>

Source§

fn enum_framesizes( &mut self, _session: &Self::Session, index: u32, pixel_format: u32, ) -> IoctlResult<v4l2_frmsizeenum>

Source§

fn enum_frameintervals( &mut self, _session: &Self::Session, index: u32, pixel_format: u32, width: u32, height: u32, ) -> IoctlResult<v4l2_frmivalenum>

Source§

fn g_std(&mut self, session: &Self::Session) -> IoctlResult<v4l2_std_id>

Source§

fn s_std( &mut self, session: &mut Self::Session, std: v4l2_std_id, ) -> IoctlResult<()>

Source§

fn enumstd( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_standard>

Source§

fn g_ctrl( &mut self, session: &Self::Session, id: u32, ) -> IoctlResult<v4l2_control>

Source§

fn s_ctrl( &mut self, session: &mut Self::Session, id: u32, value: i32, ) -> IoctlResult<v4l2_control>

Source§

fn g_tuner( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_tuner>

Source§

fn s_tuner( &mut self, session: &mut Self::Session, index: u32, mode: TunerMode, ) -> IoctlResult<()>

Source§

fn g_audio(&mut self, session: &Self::Session) -> IoctlResult<v4l2_audio>

Source§

fn s_audio( &mut self, session: &mut Self::Session, index: u32, mode: Option<AudioMode>, ) -> IoctlResult<()>

Source§

fn queryctrl( &mut self, session: &Self::Session, id: CtrlId, flags: QueryCtrlFlags, ) -> IoctlResult<v4l2_queryctrl>

Source§

fn querymenu( &mut self, session: &Self::Session, id: u32, index: u32, ) -> IoctlResult<v4l2_querymenu>

Source§

fn g_output(&mut self, session: &Self::Session) -> IoctlResult<i32>

Source§

fn s_output( &mut self, session: &mut Self::Session, output: i32, ) -> IoctlResult<i32>

Source§

fn enumoutput( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_output>

Source§

fn g_audout(&mut self, session: &Self::Session) -> IoctlResult<v4l2_audioout>

Source§

fn s_audout( &mut self, session: &mut Self::Session, index: u32, ) -> IoctlResult<()>

Source§

fn g_modulator( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_modulator>

Source§

fn s_modulator( &mut self, session: &mut Self::Session, index: u32, flags: TunerTransmissionFlags, ) -> IoctlResult<()>

Source§

fn g_frequency( &mut self, session: &Self::Session, tuner: u32, ) -> IoctlResult<v4l2_frequency>

Source§

fn s_frequency( &mut self, session: &mut Self::Session, tuner: u32, type_: TunerType, frequency: u32, ) -> IoctlResult<()>

Source§

fn querystd(&mut self, session: &Self::Session) -> IoctlResult<v4l2_std_id>

Source§

fn enumaudio( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_audio>

Source§

fn enumaudout( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_audioout>

Source§

fn g_ext_ctrls( &mut self, session: &Self::Session, which: CtrlWhich, ctrls: &mut v4l2_ext_controls, ctrl_array: &mut Vec<v4l2_ext_control>, user_regions: Vec<Vec<SgEntry>>, ) -> IoctlResult<()>

Ext control ioctls modify ctrls and ctrl_array in place instead of returning them.
Source§

fn s_ext_ctrls( &mut self, session: &mut Self::Session, which: CtrlWhich, ctrls: &mut v4l2_ext_controls, ctrl_array: &mut Vec<v4l2_ext_control>, user_regions: Vec<Vec<SgEntry>>, ) -> IoctlResult<()>

Ext control ioctls modify ctrls and ctrl_array in place instead of returning them.
Source§

fn try_ext_ctrls( &mut self, session: &Self::Session, which: CtrlWhich, ctrls: &mut v4l2_ext_controls, ctrl_array: &mut Vec<v4l2_ext_control>, user_regions: Vec<Vec<SgEntry>>, ) -> IoctlResult<()>

Ext control ioctls modify ctrls and ctrl_array in place instead of returning them.
Source§

fn g_enc_index(&mut self, session: &Self::Session) -> IoctlResult<v4l2_enc_idx>

Source§

fn encoder_cmd( &mut self, session: &mut Self::Session, cmd: v4l2_encoder_cmd, ) -> IoctlResult<v4l2_encoder_cmd>

Source§

fn try_encoder_cmd( &mut self, session: &Self::Session, cmd: v4l2_encoder_cmd, ) -> IoctlResult<v4l2_encoder_cmd>

Source§

fn s_dv_timings( &mut self, session: &mut Self::Session, timings: v4l2_dv_timings, ) -> IoctlResult<v4l2_dv_timings>

Source§

fn g_dv_timings( &mut self, session: &Self::Session, ) -> IoctlResult<v4l2_dv_timings>

Source§

fn subscribe_event( &mut self, session: &mut Self::Session, event: V4l2EventType, flags: SubscribeEventFlags, ) -> IoctlResult<()>

Source§

fn unsubscribe_event( &mut self, session: &mut Self::Session, event: v4l2_event_subscription, ) -> IoctlResult<()>

Source§

fn create_bufs( &mut self, session: &mut Self::Session, count: u32, queue: QueueType, memory: MemoryType, format: v4l2_format, ) -> IoctlResult<v4l2_create_buffers>

queue and memory are validated versions of the information in create_buffers. Read more
Source§

fn prepare_buf( &mut self, session: &mut Self::Session, buffer: V4l2Buffer, guest_regions: Vec<Vec<SgEntry>>, ) -> IoctlResult<V4l2Buffer>

Source§

fn g_selection( &mut self, session: &Self::Session, sel_type: SelectionType, sel_target: SelectionTarget, ) -> IoctlResult<v4l2_rect>

Source§

fn s_selection( &mut self, session: &mut Self::Session, sel_type: SelectionType, sel_target: SelectionTarget, sel_rect: v4l2_rect, sel_flags: SelectionFlags, ) -> IoctlResult<v4l2_rect>

Source§

fn decoder_cmd( &mut self, session: &mut Self::Session, cmd: v4l2_decoder_cmd, ) -> IoctlResult<v4l2_decoder_cmd>

Source§

fn try_decoder_cmd( &mut self, session: &Self::Session, cmd: v4l2_decoder_cmd, ) -> IoctlResult<v4l2_decoder_cmd>

Source§

fn enum_dv_timings( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_dv_timings>

Source§

fn query_dv_timings( &mut self, session: &Self::Session, ) -> IoctlResult<v4l2_dv_timings>

Source§

fn dv_timings_cap( &self, session: &Self::Session, ) -> IoctlResult<v4l2_dv_timings_cap>

Source§

fn enum_freq_bands( &self, session: &Self::Session, tuner: u32, type_: TunerType, index: u32, ) -> IoctlResult<v4l2_frequency_band>

Source§

fn query_ext_ctrl( &mut self, session: &Self::Session, id: CtrlId, flags: QueryCtrlFlags, ) -> IoctlResult<v4l2_query_ext_ctrl>

Auto Trait Implementations§

§

impl<Q, HM> Freeze for SimpleCaptureDevice<Q, HM>
where Q: Freeze, HM: Freeze,

§

impl<Q, HM> RefUnwindSafe for SimpleCaptureDevice<Q, HM>

§

impl<Q, HM> Send for SimpleCaptureDevice<Q, HM>
where Q: Send, HM: Send,

§

impl<Q, HM> Sync for SimpleCaptureDevice<Q, HM>
where Q: Sync, HM: Sync,

§

impl<Q, HM> Unpin for SimpleCaptureDevice<Q, HM>
where Q: Unpin, HM: Unpin,

§

impl<Q, HM> UnsafeUnpin for SimpleCaptureDevice<Q, HM>
where Q: UnsafeUnpin, HM: UnsafeUnpin,

§

impl<Q, HM> UnwindSafe for SimpleCaptureDevice<Q, HM>
where Q: UnwindSafe, HM: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.