From a7fc967f508069ace7e5a3b981ad846e5c75e419 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 10 Jun 2023 12:30:54 +0200 Subject: [PATCH] core/frame: add means for NAVideoBufferPool to grow and report its usage --- nihav-core/src/frame.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 { -- 2.30.2