aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2022-11-04 18:25:56 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2022-11-04 18:25:56 +0100
commit8e14efb001fac3fecb0cb56df8705d23fa2231a8 (patch)
treebdd21683de1db9d4c39d0d68cf8e180e7ea902cb
parent3867d436b51515207e0035e2c6cb127de3935c57 (diff)
downloadnihav-8e14efb001fac3fecb0cb56df8705d23fa2231a8.tar.gz
switch demuxers to use NAStream::make_ts()
-rw-r--r--nihav-commonfmt/src/demuxers/avi.rs4
-rw-r--r--nihav-commonfmt/src/demuxers/y4m.rs3
-rw-r--r--nihav-duck/src/demuxers/ivf.rs3
-rw-r--r--nihav-flash/src/demuxers/flv.rs6
-rw-r--r--nihav-game/src/demuxers/bmv.rs12
-rw-r--r--nihav-game/src/demuxers/fst.rs6
-rw-r--r--nihav-game/src/demuxers/gdv.rs6
-rw-r--r--nihav-game/src/demuxers/hl_fmv.rs6
-rw-r--r--nihav-game/src/demuxers/imax.rs6
-rw-r--r--nihav-game/src/demuxers/q.rs6
-rw-r--r--nihav-game/src/demuxers/siff.rs12
-rw-r--r--nihav-game/src/demuxers/smush.rs19
-rw-r--r--nihav-game/src/demuxers/vmd.rs3
-rw-r--r--nihav-game/src/demuxers/vx.rs3
-rw-r--r--nihav-indeo/src/demuxers/ivf.rs3
-rw-r--r--nihav-llaudio/src/demuxers/ape.rs3
-rw-r--r--nihav-llaudio/src/demuxers/flac.rs3
-rw-r--r--nihav-llaudio/src/demuxers/tta.rs3
-rw-r--r--nihav-llaudio/src/demuxers/wavpack.rs6
-rw-r--r--nihav-realmedia/src/demuxers/realmedia.rs16
20 files changed, 44 insertions, 85 deletions
diff --git a/nihav-commonfmt/src/demuxers/avi.rs b/nihav-commonfmt/src/demuxers/avi.rs
index dc8ea6b..cd33c51 100644
--- a/nihav-commonfmt/src/demuxers/avi.rs
+++ b/nihav-commonfmt/src/demuxers/avi.rs
@@ -184,8 +184,8 @@ impl<'a> DemuxCore<'a> for AVIDemuxer<'a> {
}
continue;
}
- let (tb_num, tb_den) = stream.get_timebase();
- let mut ts = NATimeInfo::new(Some(self.cur_frame[stream_no as usize]), None, None, tb_num, tb_den);
+ let (tb_num, _) = stream.get_timebase();
+ let mut ts = stream.make_ts(Some(self.cur_frame[stream_no as usize]), None, None);
if stream.get_media_type() == StreamType::Audio && tb_num == 1 && stream.get_info().get_name() == "pcm" {
ts.pts = None;
}
diff --git a/nihav-commonfmt/src/demuxers/y4m.rs b/nihav-commonfmt/src/demuxers/y4m.rs
index 05157ca..9340421 100644
--- a/nihav-commonfmt/src/demuxers/y4m.rs
+++ b/nihav-commonfmt/src/demuxers/y4m.rs
@@ -37,8 +37,7 @@ impl<'a> DemuxCore<'a> for Y4MDemuxer<'a> {
};
validate!(&marker == b"FRAME\n");
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.frameno), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.frameno), None, None);
let pkt = self.src.read_packet(stream, ts, true, self.frame_size)?;
self.frameno += 1;
Ok(pkt)
diff --git a/nihav-duck/src/demuxers/ivf.rs b/nihav-duck/src/demuxers/ivf.rs
index 09f7257..1ed7bfe 100644
--- a/nihav-duck/src/demuxers/ivf.rs
+++ b/nihav-duck/src/demuxers/ivf.rs
@@ -59,8 +59,7 @@ impl<'a> DemuxCore<'a> for IVFDemuxer<'a> {
}
if let Some(stream) = strmgr.get_stream(0) {
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(tstamp), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(tstamp), None, None);
return self.src.read_packet(stream, ts, false, fsize);
} else {
return Err(DemuxerError::InvalidData);
diff --git a/nihav-flash/src/demuxers/flv.rs b/nihav-flash/src/demuxers/flv.rs
index 82901ac..5f0dc0b 100644
--- a/nihav-flash/src/demuxers/flv.rs
+++ b/nihav-flash/src/demuxers/flv.rs
@@ -215,9 +215,8 @@ impl<'a> FLVDemuxer<'a> {
data_size -= pkt_hdr_size;
if data_size > 0 {
let stream = strmgr.get_stream(self.astream).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
let pts = (u64::from(ext_time) << 24) | u64::from(time);
- let ts = NATimeInfo::new(Some(pts), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(pts), None, None);
self.apkts.push(self.src.read_packet(stream, ts, true, data_size)?);
}
},
@@ -352,10 +351,9 @@ impl<'a> FLVDemuxer<'a> {
if data_size > 0 {
let stream = strmgr.get_stream(self.vstream).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
let pts = (u64::from(ext_time) << 24) | u64::from(time);
let dts = ((pts as i64) + i64::from(cts)).max(0) as u64;
- let ts = NATimeInfo::new(Some(pts), Some(dts), None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(pts), Some(dts), None);
self.vpkts.push(self.src.read_packet(stream, ts, ftype == FrameType::I, data_size)?);
}
},
diff --git a/nihav-game/src/demuxers/bmv.rs b/nihav-game/src/demuxers/bmv.rs
index ee88262..700c8d0 100644
--- a/nihav-game/src/demuxers/bmv.rs
+++ b/nihav-game/src/demuxers/bmv.rs
@@ -48,8 +48,7 @@ impl<'a> DemuxCore<'a> for BMVDemuxer<'a> {
asize = (nblocks as usize) * 65 + 1;
validate!(asize < size);
let str = strmgr.get_stream(self.aud_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.apos), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.apos), None, None);
let apkt = self.src.read_packet(str, ts, false, asize)?;
self.apos += u64::from(nblocks) * 32;
self.pkt_buf.push(apkt);
@@ -61,8 +60,7 @@ impl<'a> DemuxCore<'a> for BMVDemuxer<'a> {
self.src.read_buf(&mut buf[1..])?;
let str = strmgr.get_stream(self.vid_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.vpos), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.vpos), None, None);
let pkt = NAPacket::new(str, ts, (ctype & 3) == 3, buf);
self.vpos += 1;
@@ -189,8 +187,7 @@ impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> {
self.src.read_buf(&mut buf[1..])?;
let str = strmgr.get_stream(self.aud_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.apos), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.apos), None, None);
let apkt = NAPacket::new(str, ts, false, buf);
self.apos += (asize as u64) / 41 * 32;
@@ -210,8 +207,7 @@ impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> {
self.src.read_buf(&mut buf[1..])?;
let str = strmgr.get_stream(self.vid_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.vpos), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.vpos), None, None);
let pkt = NAPacket::new(str, ts, (ctype & 3) == 3, buf);
self.vpos += 1;
diff --git a/nihav-game/src/demuxers/fst.rs b/nihav-game/src/demuxers/fst.rs
index c70584a..68f9537 100644
--- a/nihav-game/src/demuxers/fst.rs
+++ b/nihav-game/src/demuxers/fst.rs
@@ -73,8 +73,7 @@ impl<'a> DemuxCore<'a> for FutureVisionVideoDemuxer<'a> {
}
let str = strmgr.get_stream(id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(pts), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(pts), None, None);
self.src.read_packet(str, ts, true, size)
}
@@ -148,8 +147,7 @@ impl<'a> DemuxCore<'a> for FutureVisionAudioDemuxer<'a> {
let pts = (self.src.tell() - 14) * 2;
let str = strmgr.get_stream(self.a_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(pts), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(pts), None, None);
self.src.read_packet(str, ts, true, size)
}
diff --git a/nihav-game/src/demuxers/gdv.rs b/nihav-game/src/demuxers/gdv.rs
index 8f54bca..876f3c1 100644
--- a/nihav-game/src/demuxers/gdv.rs
+++ b/nihav-game/src/demuxers/gdv.rs
@@ -143,8 +143,7 @@ pktdta: Vec::new(),
fn read_achunk(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
self.state = GDVState::AudioRead;
let str = strmgr.get_stream(self.a_id.unwrap()).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(u64::from(self.cur_frame)), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(u64::from(self.cur_frame)), None, None);
self.src.read_packet(str, ts, true, self.asize)
}
@@ -158,8 +157,7 @@ pktdta: Vec::new(),
let flags = (tmp & 0xFF) as usize;
self.state = GDVState::NewFrame;
self.cur_frame += 1;
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(u64::from(self.cur_frame - 1)), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(u64::from(self.cur_frame - 1)), None, None);
src.read_packet(str, ts, (flags & 64) != 0, size)
}
}
diff --git a/nihav-game/src/demuxers/hl_fmv.rs b/nihav-game/src/demuxers/hl_fmv.rs
index b511bb9..20a8767 100644
--- a/nihav-game/src/demuxers/hl_fmv.rs
+++ b/nihav-game/src/demuxers/hl_fmv.rs
@@ -41,15 +41,13 @@ impl<'a> DemuxCore<'a> for HighlanderFMVDemuxer<'a> {
match &tag {
b"AUD1" => {
let stream = strmgr.get_stream_by_id(1).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.apts), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.apts), None, None);
self.apts += size as u64;
self.src.read_packet(stream, ts, true, size)
},
b"VID3" => {
let stream = strmgr.get_stream_by_id(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.vpts), None, None);
self.vpts += 1;
self.src.read_packet(stream, ts, true, size)
},
diff --git a/nihav-game/src/demuxers/imax.rs b/nihav-game/src/demuxers/imax.rs
index a477ebe..2cd9f70 100644
--- a/nihav-game/src/demuxers/imax.rs
+++ b/nihav-game/src/demuxers/imax.rs
@@ -49,8 +49,7 @@ impl<'a> DemuxCore<'a> for IMAXDemuxer<'a> {
match ftype {
0xAA97 => {
let str = strmgr.get_stream(self.v_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.cur_frame), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.cur_frame), None, None);
self.cur_frame += 1;
let mut pkt = self.src.read_packet(str, ts, true, fsize)?;
pkt.add_side_data(NASideData::Palette(self.pal_change, self.pal.clone()));
@@ -73,8 +72,7 @@ impl<'a> DemuxCore<'a> for IMAXDemuxer<'a> {
},
0xAA99 => {
let str = strmgr.get_stream(self.a_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.apos), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.apos), None, None);
self.apos += fsize as u64;
return self.src.read_packet(str, ts, true, fsize);
},
diff --git a/nihav-game/src/demuxers/q.rs b/nihav-game/src/demuxers/q.rs
index 6c52ab8..3735bfa 100644
--- a/nihav-game/src/demuxers/q.rs
+++ b/nihav-game/src/demuxers/q.rs
@@ -82,8 +82,7 @@ impl<'a> DemuxCore<'a> for QDemuxer<'a> {
0 => {
if let Some(a_id) = self.a_id {
let str = strmgr.get_stream(a_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.apts), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.apts), None, None);
self.apts += (size / self.bps) as u64;
return self.src.read_packet(str, ts, true, size);
} else {
@@ -101,8 +100,7 @@ impl<'a> DemuxCore<'a> for QDemuxer<'a> {
2 | 3 | 4 | 11 => {
validate!(self.v_id.is_some());
let str = strmgr.get_stream(self.v_id.unwrap_or(0)).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(self.vpts), None, None);
self.vpts += 1;
let cur_len = self.side_data.len();
diff --git a/nihav-game/src/demuxers/siff.rs b/nihav-game/src/demuxers/siff.rs
index 33c26f8..7bc29fc 100644
--- a/nihav-game/src/demuxers/siff.rs
+++ b/nihav-game/src/demuxers/siff.rs
@@ -83,8 +83,7 @@ impl<'a> SIFFDemuxer<'a> {
let size = self.src.read_u16le()? as usize;
validate!(size > 8);
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.vpts), None, None);
let kframe = self.vpts == 0;
self.cframe += 1;
let pkt = self.src.read_packet(stream, ts, kframe, size - 2)?;
@@ -164,8 +163,7 @@ impl<'a> SIFFDemuxer<'a> {
let size = self.src.read_u32le()? as usize;
validate!(size > 6);
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.vpts), None, None);
let kframe = self.vpts == 0;
self.cframe += 1;
let pkt = self.src.read_packet(stream, ts, kframe, size - 4)?;
@@ -238,8 +236,7 @@ impl<'a> SIFFDemuxer<'a> {
let cur_size = self.size.min(1024 * (self.ablock as u32));
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(None, None, None, tb_num, tb_den);
+ let ts = stream.make_ts(None, None, None);
let pkt = self.src.read_packet(stream, ts, true, cur_size as usize)?;
self.size -= cur_size;
@@ -282,8 +279,7 @@ impl<'a> DemuxCore<'a> for SIFFDemuxer<'a> {
std::mem::swap(&mut buf, &mut self.abuf);
if let Some(stream) = strmgr.get_stream(1) {
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.apts), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.apts), None, None);
self.apts += (buf.len() / self.ablock) as u64;
return Ok(NAPacket::new(stream, ts, true, buf));
}
diff --git a/nihav-game/src/demuxers/smush.rs b/nihav-game/src/demuxers/smush.rs
index 6476184..6132d9c 100644
--- a/nihav-game/src/demuxers/smush.rs
+++ b/nihav-game/src/demuxers/smush.rs
@@ -288,8 +288,7 @@ impl<'a> SmushDemuxer<'a> {
let mut buf = Vec::new();
std::mem::swap(&mut self.chunks, &mut buf);
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.cur_frame as u64 - 1), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.cur_frame as u64 - 1), None, None);
return Ok(NAPacket::new(stream, ts, false, buf));
}
if self.cur_frame == self.nframes {
@@ -320,8 +319,7 @@ impl<'a> SmushDemuxer<'a> {
let flags = self.src.read_u16le()?;
if (opcode == 8) && (flags == 0x2E) {
if let Some(stream) = strmgr.get_stream(1) {
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(None, None, None, tb_num, tb_den);
+ let ts = stream.make_ts(None, None, None);
let mut buf = vec![0; size as usize];
write_u16le(&mut buf[0..2], opcode).unwrap();
@@ -342,10 +340,8 @@ impl<'a> SmushDemuxer<'a> {
if size > 0x30 {
self.src.read_skip(0x30)?;
if let Some(stream) = strmgr.get_stream(1) {
- let (tb_num, tb_den) = stream.get_timebase();
-
let audio_size = size - 0x30;
- let ts = NATimeInfo::new(Some(self.asize), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.asize), None, None);
let pkt = self.src.read_packet(stream, ts, true, audio_size as usize)?;
self.asize += audio_size;
if (self.src.tell() & 1) == 1 {
@@ -379,8 +375,7 @@ impl<'a> SmushDemuxer<'a> {
let mut buf = Vec::new();
std::mem::swap(&mut self.chunks, &mut buf);
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.cur_frame as u64 - 1), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.cur_frame as u64 - 1), None, None);
return Ok(NAPacket::new(stream, ts, self.keyframe, buf));
}
if self.cur_frame == self.nframes {
@@ -427,8 +422,7 @@ impl<'a> SmushDemuxer<'a> {
}
}
- let (tb_num, tb_den) = stream.get_timebase();
- let mut ts = NATimeInfo::new(None, None, None, tb_num, tb_den);
+ let mut ts = stream.make_ts(None, None, None);
if nsamples != 0 {
ts.pts = Some(self.asize);
self.asize += u64::from(nsamples);
@@ -616,8 +610,7 @@ impl<'a> DemuxCore<'a> for MCMPDemuxer<'a> {
self.src.read_buf(&mut buf[4..])?;
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.pts[idx]), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.pts[idx]), None, None);
self.cur_frame += 1;
diff --git a/nihav-game/src/demuxers/vmd.rs b/nihav-game/src/demuxers/vmd.rs
index 663a1a8..c1ef0be 100644
--- a/nihav-game/src/demuxers/vmd.rs
+++ b/nihav-game/src/demuxers/vmd.rs
@@ -173,8 +173,7 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> {
let str_id = if is_video { self.vid_id } else { self.aud_id };
let str = strmgr.get_stream(str_id).unwrap();
- let (tb_num, tb_den) = str.get_timebase();
- let ts = NATimeInfo::new(Some(u64::from(cur_frame.ts)), None, None, tb_num, tb_den);
+ let ts = str.make_ts(Some(u64::from(cur_frame.ts)), None, None);
let pkt = NAPacket::new(str, ts, false, buf);
Ok(pkt)
diff --git a/nihav-game/src/demuxers/vx.rs b/nihav-game/src/demuxers/vx.rs
index 1722841..1817682 100644
--- a/nihav-game/src/demuxers/vx.rs
+++ b/nihav-game/src/demuxers/vx.rs
@@ -84,8 +84,7 @@ impl<'a> DemuxCore<'a> for VXDemuxer<'a> {
let stream = strmgr.get_stream(self.vid_id);
if stream.is_none() { return Err(DemuxerError::InvalidData); }
let stream = stream.unwrap();
- let (tn, td) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.vno), None, None, tn, td);
+ let ts = stream.make_ts(Some(self.vno), None, None);
let size = self.src.read_u16le()? as usize;
validate!(size > 2);
let _num_achunks = self.src.read_u16le()?;
diff --git a/nihav-indeo/src/demuxers/ivf.rs b/nihav-indeo/src/demuxers/ivf.rs
index 6ea4623..cccb5ab 100644
--- a/nihav-indeo/src/demuxers/ivf.rs
+++ b/nihav-indeo/src/demuxers/ivf.rs
@@ -218,8 +218,7 @@ impl<'a> DemuxCore<'a> for IVFDemuxer<'a> {
}
if let Some(stream) = strmgr.get_stream(stream_id) {
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(tstamp as u64), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(tstamp as u64), None, None);
return Ok(NAPacket::new_from_refbuf(stream, ts, false, NABufferRef::new(buf)));
} else {
return Err(DemuxerError::InvalidData);
diff --git a/nihav-llaudio/src/demuxers/ape.rs b/nihav-llaudio/src/demuxers/ape.rs
index 1da6cf2..7671737 100644
--- a/nihav-llaudio/src/demuxers/ape.rs
+++ b/nihav-llaudio/src/demuxers/ape.rs
@@ -205,8 +205,7 @@ impl<'a> DemuxCore<'a> for APEDemuxer<'a> {
self.src.read_buf(&mut buf[8..])?;
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.cur_frame as u64), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.cur_frame as u64), None, None);
let pkt = NAPacket::new(stream, ts, true, buf);
self.cur_frame += 1;
diff --git a/nihav-llaudio/src/demuxers/flac.rs b/nihav-llaudio/src/demuxers/flac.rs
index 13ab0e3..055f4fd 100644
--- a/nihav-llaudio/src/demuxers/flac.rs
+++ b/nihav-llaudio/src/demuxers/flac.rs
@@ -207,8 +207,7 @@ impl<'a> DemuxCore<'a> for FLACDemuxer<'a> {
let (buf, pts, duration) = self.read_frame()?;
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(pts), None, Some(duration), tb_num, tb_den);
+ let ts = stream.make_ts(Some(pts), None, Some(duration));
let pkt = NAPacket::new(stream, ts, true, buf);
Ok(pkt)
diff --git a/nihav-llaudio/src/demuxers/tta.rs b/nihav-llaudio/src/demuxers/tta.rs
index 8c2150c..88589a6 100644
--- a/nihav-llaudio/src/demuxers/tta.rs
+++ b/nihav-llaudio/src/demuxers/tta.rs
@@ -81,8 +81,7 @@ impl<'a> DemuxCore<'a> for TTADemuxer<'a> {
self.src.seek(SeekFrom::Start(off))?;
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.cur_frame.into()), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.cur_frame.into()), None, None);
let pkt = self.src.read_packet(stream, ts, true, size)?;
self.cur_frame += 1;
diff --git a/nihav-llaudio/src/demuxers/wavpack.rs b/nihav-llaudio/src/demuxers/wavpack.rs
index 9d01089..2d92e7b 100644
--- a/nihav-llaudio/src/demuxers/wavpack.rs
+++ b/nihav-llaudio/src/demuxers/wavpack.rs
@@ -189,8 +189,7 @@ impl<'a> DemuxCore<'a> for WavPackDemuxer<'a> {
std::mem::swap(&mut fb, &mut self.first_blocks);
let (refhdr, buf) = fb.unwrap();
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.samplepos), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.samplepos), None, None);
let pkt = NAPacket::new(stream, ts, true, buf);
self.samplepos += u64::from(refhdr.block_samples);
@@ -205,8 +204,7 @@ impl<'a> DemuxCore<'a> for WavPackDemuxer<'a> {
let (refhdr, buf) = self.read_blocks()?;
let stream = strmgr.get_stream(0).unwrap();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(self.samplepos), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(self.samplepos), None, None);
let pkt = NAPacket::new(stream, ts, true, buf);
self.samplepos += u64::from(refhdr.block_samples);
diff --git a/nihav-realmedia/src/demuxers/realmedia.rs b/nihav-realmedia/src/demuxers/realmedia.rs
index 911291e..cfcccb8 100644
--- a/nihav-realmedia/src/demuxers/realmedia.rs
+++ b/nihav-realmedia/src/demuxers/realmedia.rs
@@ -152,8 +152,7 @@ impl RMAudioStream {
RMAudioStream { deint, iinfo, buf, sub_packet: 0 }
}
fn read_apackets(&mut self, queued_packets: &mut Vec<NAPacket>, src: &mut ByteReader, stream: NAStreamRef, ts: u32, keyframe: bool, payload_size: usize) -> DemuxerResult<NAPacket> {
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(ts as u64), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(ts as u64), None, None);
if keyframe {
self.sub_packet = 0;
@@ -214,7 +213,7 @@ impl RMAudioStream {
sizes.push(sz);
}
validate!(tot_size + num_entries * 2 + 2 == payload_size);
- let pkt_ts = NATimeInfo::new(None, None, None, tb_num, tb_den);
+ let pkt_ts = stream.make_ts(None, None, None);
let mut first = true;
for size in sizes.iter() {
let cur_ts = if first { ts } else { pkt_ts };
@@ -246,7 +245,7 @@ impl RMAudioStream {
let mut frames_iter = self.buf.chunks(fsize);
let pkt0 = frames_iter.next().unwrap();
- let pkt_ts = NATimeInfo::new(None, None, None, tb_num, tb_den);
+ let pkt_ts = stream.make_ts(None, None, None);
for pkts in frames_iter {
let pkt = NAPacket::new(stream.clone(), pkt_ts, true, pkts.to_vec());
queued_packets.push(pkt);
@@ -405,8 +404,7 @@ fn read_video_buf(src: &mut ByteReader, stream: NAStreamRef, ts: u32, keyframe:
vec[4] = 1;
src.read_buf(&mut vec[9..])?;
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(ts as u64), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(ts as u64), None, None);
Ok(NAPacket::new(stream, ts, keyframe, vec))
}
@@ -603,8 +601,7 @@ println!(" got ainfo {:?}", ainfo);
return Err(DemuxerError::TryAgain);
}
//todo: check if full frame is received
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(ts as u64), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(ts as u64), None, None);
let pkt = NAPacket::new(stream, ts, keyframe, vstr.get_frame_data());
Ok(pkt)
},
@@ -636,8 +633,7 @@ println!(" got ainfo {:?}", ainfo);
queued_pkts.push(res.unwrap());
}
queued_pkts.reverse();
- let (tb_num, tb_den) = stream.get_timebase();
- let ts = NATimeInfo::new(Some(ts as u64), None, None, tb_num, tb_den);
+ let ts = stream.make_ts(Some(ts as u64), None, None);
let pkt = NAPacket::new(stream, ts, keyframe, vstr.get_frame_data());
Ok(pkt)
},