X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;ds=sidebyside;f=nihav-core%2Fsrc%2Fframe.rs;h=792bfb41953ee9915e9200a93e764ff51dc2b1c0;hb=2a998d8fb46273ffbf62a7e909ad8228c089f1d0;hp=fbdbdf5e391f533e5c75c2fb90b4cd5f11d07248;hpb=6f2630992fe340ad1a122ec10c649f756e478185;p=nihav.git diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index fbdbdf5..792bfb4 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -271,7 +271,8 @@ impl NAAudioBuffer { impl NAAudioBuffer { /// Constructs a new `NAAudioBuffer` instance. pub fn new_from_buf(info: NAAudioInfo, data: NABufferRef>, chmap: NAChannelMap) -> Self { - let len = data.len(); + let len = data.len() * 8 / chmap.num_channels() / (info.format.bits as usize); + NAAudioBuffer { info, data, chmap, offs: Vec::new(), len, stride: 0, step: 0 } } } @@ -1345,6 +1346,10 @@ impl NAStream { } /// Returns stream duration. pub fn get_duration(&self) -> u64 { self.duration } + /// Constructs a new timestamp. + pub fn make_ts(&self, pts: Option, dts: Option, duration: Option) -> NATimeInfo { + NATimeInfo::new(pts, dts, duration, self.tb_num, self.tb_den) + } /// Converts current instance into a reference-counted one. pub fn into_ref(self) -> NAStreamRef { Arc::new(self) } }