From: Kostya Shishkov Date: Sat, 10 Jun 2023 10:30:54 +0000 (+0200) Subject: core/frame: add means for NAVideoBufferPool to grow and report its usage X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=a7fc967f508069ace7e5a3b981ad846e5c75e419 core/frame: add means for NAVideoBufferPool to grow and report its usage --- diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index 61741d7..10db18d 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -746,6 +746,22 @@ impl NAVideoBufferPool { pub fn reset(&mut self) { self.pool.clear(); } + /// Returns the number of frames currently in use. + pub fn get_num_used(&self) -> usize { + self.pool.iter().filter(|el| el.get_num_refs() != 1).count() + } + /// Adds a manually allocated frame to the pool. + pub fn add_frame(&mut self, buf: NAVideoBufferRef) { + self.pool.push(buf); + } + /// Returns current video format (if available). + pub fn get_info(&self) -> Option { + if !self.pool.is_empty() { + Some(self.pool[0].get_info()) + } else { + None + } + } } impl NAVideoBufferPool {