add bytes_left() to NAPacketiser so its internal buffer size can be monitored
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 19 Nov 2021 14:45:31 +0000 (15:45 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 19 Nov 2021 14:45:31 +0000 (15:45 +0100)
nihav-core/src/codecs/mod.rs
nihav-llaudio/src/codecs/flac.rs
nihav-mpeg/src/codecs/mpegaudio/mod.rs

index 1072fc40ca2ad0d4b3952a2dad07950c879cd1e3..b6a1820d6bcf6bb87b3c9cad6f0c41aea7af6dc4 100644 (file)
@@ -374,6 +374,8 @@ pub trait NAPacketiser {
     fn get_packet(&mut self, stream: NAStreamRef) -> DecoderResult<Option<NAPacket>>;
     /// Resets the internal buffer.
     fn reset(&mut self);
     fn get_packet(&mut self, stream: NAStreamRef) -> DecoderResult<Option<NAPacket>>;
     /// 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.
 }
 
 /// Decoder information used during creating a packetiser for requested codec.
index a3145ac4e732ae95011ca7eb89e55d5962112808..9f8a884faa6600c06d022f5bc047c178f5b5c77a 100644 (file)
@@ -622,6 +622,7 @@ impl NAPacketiser for FLACPacketiser {
         self.end = 0;
         self.hdr_ok = false;
     }
         self.end = 0;
         self.hdr_ok = false;
     }
+    fn bytes_left(&self) -> usize { self.buf.len() }
 }
 
 pub fn get_packetiser() -> Box<dyn NAPacketiser + Send> {
 }
 
 pub fn get_packetiser() -> Box<dyn NAPacketiser + Send> {
index 6c908d825e35609cc262c9ec621421a47428a72a..e9400f6f02f9b1f2224c48de0aa8a358a147ce9c 100644 (file)
@@ -426,6 +426,7 @@ impl NAPacketiser for MPAPacketiser {
     fn reset(&mut self) {
         self.buf.clear();
     }
     fn reset(&mut self) {
         self.buf.clear();
     }
+    fn bytes_left(&self) -> usize { self.buf.len() }
 }
 
 pub fn get_packetiser() -> Box<dyn NAPacketiser + Send> {
 }
 
 pub fn get_packetiser() -> Box<dyn NAPacketiser + Send> {