}
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;
}
};
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)
}
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);
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)?);
}
},
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)?);
}
},
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);
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;
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;
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;
}
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)
}
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)
}
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)
}
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)
}
}
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)
},
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()));
},
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);
},
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 {
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();
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)?;
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)?;
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;
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));
}
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 {
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();
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 {
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 {
}
}
- 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);
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;
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)
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()?;
}
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);
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;
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)
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;
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);
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);
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;
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 };
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);
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))
}
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)
},
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)
},