pub struct Capturer<Buffer> {
pub pointer_shape_buffer: Vec<u8>,
pub buffer: Buffer,
pub timeout_ms: u32,
/* private fields */
}
Expand description
This is stateful and holds a buffer of the last captured frame.
Fields§
§pointer_shape_buffer: Vec<u8>
§buffer: Buffer
The buffer to store the captured frame. The data is stored in BGRA32 format.
timeout_ms: u32
Timeout in milliseconds for the next frame. By default it is 300ms.
Implementations§
Source§impl<Buffer> Capturer<Buffer>
impl<Buffer> Capturer<Buffer>
Sourcepub fn new(
monitor: Monitor,
buffer_factory: impl FnOnce(usize) -> Result<Buffer>,
) -> Result<Self>
pub fn new( monitor: Monitor, buffer_factory: impl FnOnce(usize) -> Result<Buffer>, ) -> Result<Self>
Create a new capturer with the provided monitor and buffer factory.
The parameter of buffer_factory
is the size of the buffer, in bytes.
pub const fn monitor(&self) -> &Monitor
Sourcepub fn check_buffer(&self) -> Result<()>where
Buffer: CapturerBuffer,
pub fn check_buffer(&self) -> Result<()>where
Buffer: CapturerBuffer,
Ensure Self::buffer
is large enough to hold the frame.
Sourcepub unsafe fn capture_unchecked(&mut self) -> Result<DXGI_OUTDUPL_FRAME_INFO>where
Buffer: CapturerBuffer,
pub unsafe fn capture_unchecked(&mut self) -> Result<DXGI_OUTDUPL_FRAME_INFO>where
Buffer: CapturerBuffer,
Capture the screen and return the frame info.
The pixel data is stored in the Self::buffer
.
§Safety
You have to ensure Self::buffer
is large enough to hold the frame.
You can use Self::check_buffer
to check the buffer size.
Sourcepub fn capture(&mut self) -> Result<DXGI_OUTDUPL_FRAME_INFO>where
Buffer: CapturerBuffer,
pub fn capture(&mut self) -> Result<DXGI_OUTDUPL_FRAME_INFO>where
Buffer: CapturerBuffer,
Capture the screen and return the frame info.
The pixel data is stored in the Self::buffer
.
This will call Self::check_buffer
to check the buffer size.
Sourcepub unsafe fn capture_with_pointer_shape_unchecked(
&mut self,
) -> Result<(DXGI_OUTDUPL_FRAME_INFO, Option<DXGI_OUTDUPL_POINTER_SHAPE_INFO>)>where
Buffer: CapturerBuffer,
pub unsafe fn capture_with_pointer_shape_unchecked(
&mut self,
) -> Result<(DXGI_OUTDUPL_FRAME_INFO, Option<DXGI_OUTDUPL_POINTER_SHAPE_INFO>)>where
Buffer: CapturerBuffer,
Capture the screen and return the frame info.
The pixel data is stored in the Self::buffer
.
If the pointer shape is updated, the Option<DXGI_OUTDUPL_POINTER_SHAPE_INFO>
will be Some
.
The pointer shape is stored in the Self::pointer_shape_buffer
.
§Safety
You have to ensure Self::buffer
is large enough to hold the frame.
You can use Self::check_buffer
to check the buffer size.
Sourcepub fn capture_with_pointer_shape(
&mut self,
) -> Result<(DXGI_OUTDUPL_FRAME_INFO, Option<DXGI_OUTDUPL_POINTER_SHAPE_INFO>)>where
Buffer: CapturerBuffer,
pub fn capture_with_pointer_shape(
&mut self,
) -> Result<(DXGI_OUTDUPL_FRAME_INFO, Option<DXGI_OUTDUPL_POINTER_SHAPE_INFO>)>where
Buffer: CapturerBuffer,
Check buffer size before capture.
The pixel data is stored in the Self::buffer
.
If mouse is updated, the Option<DXGI_OUTDUPL_POINTER_SHAPE_INFO>
is Some.
The pointer shape is stored in the Self::pointer_shape_buffer
.
This will call Self::check_buffer
to check the buffer size.