aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2020-06-06 12:39:46 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2020-06-06 12:49:45 +0200
commit89f25cd7aaba43aa728c4923c27da59b7285b170 (patch)
tree879740e21795567ddd7791af6edf9e58acb9567f
parentc9c7f64823f07e1e1dcd3d4a78ef149bf29fc7f5 (diff)
downloadnihav-89f25cd7aaba43aa728c4923c27da59b7285b170.tar.gz
core/frame: add helper functions for dealing with reference-counted buffer
-rw-r--r--nihav-core/src/frame.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs
index 4e317fe..26e8640 100644
--- a/nihav-core/src/frame.rs
+++ b/nihav-core/src/frame.rs
@@ -233,6 +233,8 @@ impl<T: Clone> NAAudioBuffer<T> {
pub fn get_chmap(&self) -> &NAChannelMap { &self.chmap }
/// Returns an immutable reference to the data.
pub fn get_data(&self) -> &Vec<T> { self.data.as_ref() }
+ /// Returns reference to the data.
+ pub fn get_data_ref(&self) -> NABufferRef<Vec<T>> { self.data.clone() }
/// Returns a mutable reference to the data.
pub fn get_data_mut(&mut self) -> Option<&mut Vec<T>> { self.data.as_mut() }
/// Clones current `NAAudioBuffer` into a new one.
@@ -1185,6 +1187,10 @@ impl NAPacket {
// vec.resize(size, 0);
NAPacket { stream: str, ts, keyframe: kf, buffer: NABufferRef::new(vec), side_data: Vec::new() }
}
+ /// Constructs a new `NAPacket` instance reusing a buffer reference.
+ pub fn new_from_refbuf(str: NAStreamRef, ts: NATimeInfo, kf: bool, buffer: NABufferRef<Vec<u8>>) -> Self {
+ NAPacket { stream: str, ts, keyframe: kf, buffer, side_data: Vec::new() }
+ }
/// Returns information about the stream packet belongs to.
pub fn get_stream(&self) -> NAStreamRef { self.stream.clone() }
/// Returns packet timestamp.