(&'a mut self, _timeout: Duration)
| 36 | |
| 37 | impl crate::TraitCapturer for Capturer { |
| 38 | fn frame<'a>(&'a mut self, _timeout: Duration) -> io::Result<Frame<'a>> { |
| 39 | if let Some(buf) = get_video_raw() { |
| 40 | crate::would_block_if_equal(&mut self.saved_raw_data, buf)?; |
| 41 | // Is it safe to directly return buf without copy? |
| 42 | self.rgba.resize(buf.len(), 0); |
| 43 | unsafe { |
| 44 | std::ptr::copy_nonoverlapping(buf.as_ptr(), self.rgba.as_mut_ptr(), buf.len()) |
| 45 | }; |
| 46 | Ok(Frame::PixelBuffer(PixelBuffer::new( |
| 47 | &self.rgba, |
| 48 | self.width(), |
| 49 | self.height(), |
| 50 | ))) |
| 51 | } else { |
| 52 | return Err(io::ErrorKind::WouldBlock.into()); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | pub struct PixelBuffer<'a> { |
nothing calls this directly
no test coverage detected