MCPcopy Create free account
hub / github.com/RustCV/RustCV / next_frame

Method next_frame

rustcv-backend-msmf/src/stream.rs:495–518  ·  view source on GitHub ↗

Waits for and returns the next available frame. This method uses a semaphore to efficiently wait for new frames without busy-waiting.

(&mut self)

Source from the content-addressed store, hash-verified

493 /// This method uses a semaphore to efficiently wait for new frames
494 /// without busy-waiting.
495 async fn next_frame(&mut self) -> Result<Frame<'_>> {
496 let sample = self.wait_for_sample().await?;
497 let ts_raw = self.shared.timestamp.load(Ordering::Acquire);
498
499 self.copy_sample_to_linear_buffer(&sample.0)?;
500
501 self.sequence += 1;
502 let hw_ns = (ts_raw as u64) * 100;
503
504 Ok(Frame {
505 data: &self.linear_buffer,
506 width: self.width,
507 height: self.height,
508 stride: self.line_width_bytes,
509 format: self.format,
510 sequence: self.sequence,
511 timestamp: Timestamp {
512 hw_raw_ns: hw_ns,
513 system_synced: self.clock_sync.correct(hw_ns, Instant::now()),
514 },
515 metadata: FrameMetadata::default(),
516 backend_handle: &MSMF_HANDLE_INSTANCE,
517 })
518 }
519}
520
521impl MsmfStream {

Callers 1

main_bodyFunction · 0.45

Calls 3

wait_for_sampleMethod · 0.80
correctMethod · 0.80

Tested by

no test coverage detected