pub struct Buffer { /* private fields */ }Expand description
A buffer returned by a camera to accommodate custom decoding.
Contains information of Resolution, the buffer’s FrameFormat, and the buffer.
Note that decoding on the main thread will decrease your performance and lead to dropped frames.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn new(
res: Resolution,
buf: &[u8],
source_frame_format: FrameFormat,
) -> Buffer
pub fn new( res: Resolution, buf: &[u8], source_frame_format: FrameFormat, ) -> Buffer
Creates a new buffer with a [&[u8]].
Sourcepub fn with_timestamp(
res: Resolution,
buf: &[u8],
source_frame_format: FrameFormat,
capture_timestamp: Option<Duration>,
) -> Buffer
pub fn with_timestamp( res: Resolution, buf: &[u8], source_frame_format: FrameFormat, capture_timestamp: Option<Duration>, ) -> Buffer
Creates a new buffer with a [&[u8]] and a backend-provided capture timestamp.
Sourcepub fn capture_timestamp(&self) -> Option<Duration>
pub fn capture_timestamp(&self) -> Option<Duration>
Get the backend-provided capture timestamp, if available.
Sourcepub fn resolution(&self) -> Resolution
pub fn resolution(&self) -> Resolution
Get the Resolution of this buffer.
Sourcepub fn buffer_bytes(&self) -> Bytes
pub fn buffer_bytes(&self) -> Bytes
Get a owned version of this buffer.
Sourcepub fn source_frame_format(&self) -> FrameFormat
pub fn source_frame_format(&self) -> FrameFormat
Get the FrameFormat of this buffer.
Sourcepub fn decode_image<F>(
&self,
) -> Result<ImageBuffer<<F as FormatDecoder>::Output, Vec<u8>>, NokhwaError>where
F: FormatDecoder,
pub fn decode_image<F>(
&self,
) -> Result<ImageBuffer<<F as FormatDecoder>::Output, Vec<u8>>, NokhwaError>where
F: FormatDecoder,
Decodes a image with allocation using the provided FormatDecoder.
§Errors
Will error when the decoding fails.
Sourcepub fn decode_image_to_buffer<F>(
&self,
buffer: &mut [u8],
) -> Result<(), NokhwaError>where
F: FormatDecoder,
pub fn decode_image_to_buffer<F>(
&self,
buffer: &mut [u8],
) -> Result<(), NokhwaError>where
F: FormatDecoder,
Decodes a image with allocation using the provided FormatDecoder into a buffer.
§Errors
Will error when the decoding fails, or the provided buffer is too small.