From: Kostya Shishkov Date: Fri, 19 Nov 2021 14:45:31 +0000 (+0100) Subject: add bytes_left() to NAPacketiser so its internal buffer size can be monitored X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;ds=inline;h=7f754c49a843d9b63885a1fa7e06f4d2cf6ccc5f;p=nihav.git add bytes_left() to NAPacketiser so its internal buffer size can be monitored --- diff --git a/nihav-core/src/codecs/mod.rs b/nihav-core/src/codecs/mod.rs index 1072fc4..b6a1820 100644 --- a/nihav-core/src/codecs/mod.rs +++ b/nihav-core/src/codecs/mod.rs @@ -374,6 +374,8 @@ pub trait NAPacketiser { fn get_packet(&mut self, stream: NAStreamRef) -> DecoderResult>; /// Resets the internal buffer. fn reset(&mut self); + /// Tells how much data is left in the internal buffer. + fn bytes_left(&self) -> usize; } /// Decoder information used during creating a packetiser for requested codec. diff --git a/nihav-llaudio/src/codecs/flac.rs b/nihav-llaudio/src/codecs/flac.rs index a3145ac..9f8a884 100644 --- a/nihav-llaudio/src/codecs/flac.rs +++ b/nihav-llaudio/src/codecs/flac.rs @@ -622,6 +622,7 @@ impl NAPacketiser for FLACPacketiser { self.end = 0; self.hdr_ok = false; } + fn bytes_left(&self) -> usize { self.buf.len() } } pub fn get_packetiser() -> Box { diff --git a/nihav-mpeg/src/codecs/mpegaudio/mod.rs b/nihav-mpeg/src/codecs/mpegaudio/mod.rs index 6c908d8..e9400f6 100644 --- a/nihav-mpeg/src/codecs/mpegaudio/mod.rs +++ b/nihav-mpeg/src/codecs/mpegaudio/mod.rs @@ -426,6 +426,7 @@ impl NAPacketiser for MPAPacketiser { fn reset(&mut self) { self.buf.clear(); } + fn bytes_left(&self) -> usize { self.buf.len() } } pub fn get_packetiser() -> Box {