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>where
Q: VirtioMediaEventQueue,
HM: VirtioMediaHostMemoryMapper,
impl<Q, HM> SimpleCaptureDevice<Q, HM>where
Q: VirtioMediaEventQueue,
HM: VirtioMediaHostMemoryMapper,
Trait Implementations§
Source§impl<Q, HM, Reader, Writer> VirtioMediaDevice<Reader, Writer> for SimpleCaptureDevice<Q, HM>where
Q: VirtioMediaEventQueue,
HM: VirtioMediaHostMemoryMapper,
Reader: ReadFromDescriptorChain,
Writer: WriteToDescriptorChain,
impl<Q, HM, Reader, Writer> VirtioMediaDevice<Reader, Writer> for SimpleCaptureDevice<Q, HM>where
Q: VirtioMediaEventQueue,
HM: VirtioMediaHostMemoryMapper,
Reader: ReadFromDescriptorChain,
Writer: WriteToDescriptorChain,
type Session = SimpleCaptureDeviceSession
Source§fn new_session(&mut self, session_id: u32) -> Result<Self::Session, i32>
fn new_session(&mut self, session_id: u32) -> Result<Self::Session, i32>
Create a new session which ID is
session_id. Read moreSource§fn close_session(&mut self, session: Self::Session)
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<()>
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 moreSource§fn do_mmap(
&mut self,
session: &mut Self::Session,
flags: u32,
offset: u32,
) -> Result<(u64, u64), i32>
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>
fn do_munmap(&mut self, guest_addr: u64) -> Result<(), i32>
Performs the MUNMAP command. Read more
fn process_events(&mut self, _session: &mut Self::Session) -> Result<(), i32>
Source§impl<Q, HM> VirtioMediaIoctlHandler for SimpleCaptureDevice<Q, HM>where
Q: VirtioMediaEventQueue,
HM: VirtioMediaHostMemoryMapper,
Implementations of the ioctls required by a CAPTURE device.
impl<Q, HM> VirtioMediaIoctlHandler for SimpleCaptureDevice<Q, HM>where
Q: VirtioMediaEventQueue,
HM: VirtioMediaHostMemoryMapper,
Implementations of the ioctls required by a CAPTURE device.
type Session = SimpleCaptureDeviceSession
fn enum_fmt( &mut self, _session: &Self::Session, queue: QueueType, index: u32, ) -> IoctlResult<v4l2_fmtdesc>
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>
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 moreSource§fn try_fmt(
&mut self,
_session: &Self::Session,
queue: QueueType,
_format: v4l2_format,
) -> IoctlResult<v4l2_format>
fn try_fmt( &mut self, _session: &Self::Session, queue: QueueType, _format: v4l2_format, ) -> IoctlResult<v4l2_format>
Hook for the
VIDIOC_TRY_FMT ioctl. Read morefn g_parm( &mut self, _session: &Self::Session, queue: QueueType, ) -> IoctlResult<v4l2_streamparm>
fn s_parm( &mut self, _session: &mut Self::Session, parm: v4l2_streamparm, ) -> IoctlResult<v4l2_streamparm>
fn reqbufs( &mut self, session: &mut Self::Session, queue: QueueType, memory: MemoryType, count: u32, _flags: MemoryConsistency, ) -> IoctlResult<v4l2_requestbuffers>
fn querybuf( &mut self, session: &Self::Session, queue: QueueType, index: u32, ) -> IoctlResult<V4l2Buffer>
fn qbuf( &mut self, session: &mut Self::Session, buffer: V4l2Buffer, _guest_regions: Vec<Vec<SgEntry>>, ) -> IoctlResult<V4l2Buffer>
fn streamon( &mut self, session: &mut Self::Session, queue: QueueType, ) -> IoctlResult<()>
fn streamoff( &mut self, session: &mut Self::Session, queue: QueueType, ) -> IoctlResult<()>
fn g_input(&mut self, _session: &Self::Session) -> IoctlResult<i32>
fn s_input( &mut self, _session: &mut Self::Session, input: i32, ) -> IoctlResult<i32>
fn enuminput( &mut self, _session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_input>
fn enum_framesizes( &mut self, _session: &Self::Session, index: u32, pixel_format: u32, ) -> IoctlResult<v4l2_frmsizeenum>
fn enum_frameintervals( &mut self, _session: &Self::Session, index: u32, pixel_format: u32, width: u32, height: u32, ) -> IoctlResult<v4l2_frmivalenum>
fn g_std(&mut self, session: &Self::Session) -> IoctlResult<v4l2_std_id>
fn s_std( &mut self, session: &mut Self::Session, std: v4l2_std_id, ) -> IoctlResult<()>
fn enumstd( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_standard>
fn g_ctrl( &mut self, session: &Self::Session, id: u32, ) -> IoctlResult<v4l2_control>
fn s_ctrl( &mut self, session: &mut Self::Session, id: u32, value: i32, ) -> IoctlResult<v4l2_control>
fn g_tuner( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_tuner>
fn s_tuner( &mut self, session: &mut Self::Session, index: u32, mode: TunerMode, ) -> IoctlResult<()>
fn g_audio(&mut self, session: &Self::Session) -> IoctlResult<v4l2_audio>
fn s_audio( &mut self, session: &mut Self::Session, index: u32, mode: Option<AudioMode>, ) -> IoctlResult<()>
fn queryctrl( &mut self, session: &Self::Session, id: CtrlId, flags: QueryCtrlFlags, ) -> IoctlResult<v4l2_queryctrl>
fn g_output(&mut self, session: &Self::Session) -> IoctlResult<i32>
fn s_output( &mut self, session: &mut Self::Session, output: i32, ) -> IoctlResult<i32>
fn enumoutput( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_output>
fn g_audout(&mut self, session: &Self::Session) -> IoctlResult<v4l2_audioout>
fn s_audout( &mut self, session: &mut Self::Session, index: u32, ) -> IoctlResult<()>
fn g_modulator( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_modulator>
fn s_modulator( &mut self, session: &mut Self::Session, index: u32, flags: TunerTransmissionFlags, ) -> IoctlResult<()>
fn g_frequency( &mut self, session: &Self::Session, tuner: u32, ) -> IoctlResult<v4l2_frequency>
fn s_frequency( &mut self, session: &mut Self::Session, tuner: u32, type_: TunerType, frequency: u32, ) -> IoctlResult<()>
fn querystd(&mut self, session: &Self::Session) -> IoctlResult<v4l2_std_id>
fn enumaudio( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_audio>
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<()>
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<()>
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<()>
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.fn g_enc_index(&mut self, session: &Self::Session) -> IoctlResult<v4l2_enc_idx>
fn encoder_cmd( &mut self, session: &mut Self::Session, cmd: v4l2_encoder_cmd, ) -> IoctlResult<v4l2_encoder_cmd>
fn try_encoder_cmd( &mut self, session: &Self::Session, cmd: v4l2_encoder_cmd, ) -> IoctlResult<v4l2_encoder_cmd>
fn s_dv_timings( &mut self, session: &mut Self::Session, timings: v4l2_dv_timings, ) -> IoctlResult<v4l2_dv_timings>
fn g_dv_timings( &mut self, session: &Self::Session, ) -> IoctlResult<v4l2_dv_timings>
fn subscribe_event( &mut self, session: &mut Self::Session, event: V4l2EventType, flags: SubscribeEventFlags, ) -> IoctlResult<()>
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>
fn create_bufs( &mut self, session: &mut Self::Session, count: u32, queue: QueueType, memory: MemoryType, format: v4l2_format, ) -> IoctlResult<v4l2_create_buffers>
fn prepare_buf( &mut self, session: &mut Self::Session, buffer: V4l2Buffer, guest_regions: Vec<Vec<SgEntry>>, ) -> IoctlResult<V4l2Buffer>
fn g_selection( &mut self, session: &Self::Session, sel_type: SelectionType, sel_target: SelectionTarget, ) -> IoctlResult<v4l2_rect>
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>
fn decoder_cmd( &mut self, session: &mut Self::Session, cmd: v4l2_decoder_cmd, ) -> IoctlResult<v4l2_decoder_cmd>
fn try_decoder_cmd( &mut self, session: &Self::Session, cmd: v4l2_decoder_cmd, ) -> IoctlResult<v4l2_decoder_cmd>
fn enum_dv_timings( &mut self, session: &Self::Session, index: u32, ) -> IoctlResult<v4l2_dv_timings>
fn query_dv_timings( &mut self, session: &Self::Session, ) -> IoctlResult<v4l2_dv_timings>
fn dv_timings_cap( &self, session: &Self::Session, ) -> IoctlResult<v4l2_dv_timings_cap>
fn enum_freq_bands( &self, session: &Self::Session, tuner: u32, type_: TunerType, index: u32, ) -> IoctlResult<v4l2_frequency_band>
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>
impl<Q, HM> RefUnwindSafe for SimpleCaptureDevice<Q, HM>where
Q: RefUnwindSafe,
HM: RefUnwindSafe,
impl<Q, HM> Send for SimpleCaptureDevice<Q, HM>
impl<Q, HM> Sync for SimpleCaptureDevice<Q, HM>
impl<Q, HM> Unpin for SimpleCaptureDevice<Q, HM>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more