aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2021-11-19 15:45:31 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2021-11-19 15:45:31 +0100
commit7f754c49a843d9b63885a1fa7e06f4d2cf6ccc5f (patch)
treee8678169eeca4a0788d671ec744effb0e6647956
parent6a97ae3af1e98b2d7b064c8870aaccae44a47c7d (diff)
downloadnihav-7f754c49a843d9b63885a1fa7e06f4d2cf6ccc5f.tar.gz
add bytes_left() to NAPacketiser so its internal buffer size can be monitored
-rw-r--r--nihav-core/src/codecs/mod.rs2
-rw-r--r--nihav-llaudio/src/codecs/flac.rs1
-rw-r--r--nihav-mpeg/src/codecs/mpegaudio/mod.rs1
3 files changed, 4 insertions, 0 deletions
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<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.
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<dyn NAPacketiser + Send> {
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<dyn NAPacketiser + Send> {