X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fframe.rs;h=26e8640aa5dc236ee7ba605cf2126e91c333a957;hb=c8db9313866c4d7bcf34e45e486d2f909daa16d9;hp=47d60850a5e0a487a725c4a0071c4c1fd7e4e10d;hpb=8057a7fdd5e149ab5dee70b12e4a0e1cac0eb747;p=nihav.git diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index 47d6085..26e8640 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -233,6 +233,8 @@ impl NAAudioBuffer { pub fn get_chmap(&self) -> &NAChannelMap { &self.chmap } /// Returns an immutable reference to the data. pub fn get_data(&self) -> &Vec { self.data.as_ref() } + /// Returns reference to the data. + pub fn get_data_ref(&self) -> NABufferRef> { self.data.clone() } /// Returns a mutable reference to the data. pub fn get_data_mut(&mut self) -> Option<&mut Vec> { self.data.as_mut() } /// Clones current `NAAudioBuffer` into a new one. @@ -857,21 +859,6 @@ pub const DUMMY_CODEC_INFO: NACodecInfo = NACodecInfo { properties: NACodecTypeInfo::None, extradata: None }; -/// A list of accepted option values. -#[derive(Debug,Clone)] -pub enum NAValue { - /// Empty value. - None, - /// Integer value. - Int(i32), - /// Long integer value. - Long(i64), - /// String value. - String(String), - /// Binary data value. - Data(Arc>), -} - /// A list of recognized frame types. #[derive(Debug,Clone,Copy,PartialEq)] #[allow(dead_code)] @@ -1200,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>) -> 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. @@ -1216,6 +1207,11 @@ impl NAPacket { pub fn get_buffer(&self) -> NABufferRef> { self.buffer.clone() } /// Adds side data for a packet. pub fn add_side_data(&mut self, side_data: NASideData) { self.side_data.push(side_data); } + /// Assigns packet to a new stream. + pub fn reassign(&mut self, str: NAStreamRef, ts: NATimeInfo) { + self.stream = str; + self.ts = ts; + } } impl Drop for NAPacket {