diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-04 11:53:21 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-04 11:53:21 +0200 |
commit | a480a0de101483d802a11e72d758dae00fa4860a (patch) | |
tree | b433ba04fc397f6e7297aeb56103105254dcb3f7 /nihav-game | |
parent | b4bf2c3f1a94b2b4ebbfc704e17fbaf366f8fa8b (diff) | |
download | nihav-a480a0de101483d802a11e72d758dae00fa4860a.tar.gz |
introduce stream and container duration
Diffstat (limited to 'nihav-game')
-rw-r--r-- | nihav-game/src/demuxers/bmv.rs | 10 | ||||
-rw-r--r-- | nihav-game/src/demuxers/gdv.rs | 5 | ||||
-rw-r--r-- | nihav-game/src/demuxers/vmd.rs | 6 | ||||
-rw-r--r-- | nihav-game/src/demuxers/vx.rs | 6 |
4 files changed, 17 insertions, 10 deletions
diff --git a/nihav-game/src/demuxers/bmv.rs b/nihav-game/src/demuxers/bmv.rs index 83f75b1..f548fdc 100644 --- a/nihav-game/src/demuxers/bmv.rs +++ b/nihav-game/src/demuxers/bmv.rs @@ -18,11 +18,11 @@ impl<'a> DemuxCore<'a> for BMVDemuxer<'a> { let vhdr = NAVideoInfo::new(640, 429, false, PAL8_FORMAT); let vci = NACodecTypeInfo::Video(vhdr); let vinfo = NACodecInfo::new("bmv-video", vci, None); - self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, 12)).unwrap(); + self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, 12, 0)).unwrap(); let ahdr = NAAudioInfo::new(22050, 2, SND_S16_FORMAT, 1); let ainfo = NACodecInfo::new("bmv-audio", NACodecTypeInfo::Audio(ahdr), None); - self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, 22050)).unwrap(); + self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, 22050, 0)).unwrap(); self.vpos = 0; self.apos = 0; @@ -73,6 +73,7 @@ impl<'a> DemuxCore<'a> for BMVDemuxer<'a> { fn seek(&mut self, _time: NATimePoint, _seek_index: &SeekIndex) -> DemuxerResult<()> { Err(DemuxerError::NotPossible) } + fn get_duration(&self) -> u64 { 0 } } impl<'a> NAOptionHandler for BMVDemuxer<'a> { @@ -151,11 +152,11 @@ impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> { let vhdr = NAVideoInfo::new(width, height, false, RGB565_FORMAT); let vci = NACodecTypeInfo::Video(vhdr); let vinfo = NACodecInfo::new("bmv3-video", vci, None); - self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 256, fps)).unwrap(); + self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 256, fps, nframes as u64)).unwrap(); let ahdr = NAAudioInfo::new(22050, 2, SND_S16_FORMAT, audio_blob_size); let ainfo = NACodecInfo::new("bmv3-audio", NACodecTypeInfo::Audio(ahdr), None); - self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, 22050)).unwrap(); + self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, 22050, 0)).unwrap(); self.vpos = 0; self.apos = 0; @@ -221,6 +222,7 @@ impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> { fn seek(&mut self, _time: NATimePoint, _seek_index: &SeekIndex) -> DemuxerResult<()> { Err(DemuxerError::NotPossible) } + fn get_duration(&self) -> u64 { 0 } } impl<'a> NAOptionHandler for BMV3Demuxer<'a> { diff --git a/nihav-game/src/demuxers/gdv.rs b/nihav-game/src/demuxers/gdv.rs index af0f857..778329a 100644 --- a/nihav-game/src/demuxers/gdv.rs +++ b/nihav-game/src/demuxers/gdv.rs @@ -81,7 +81,7 @@ impl<'a> DemuxCore<'a> for GremlinVideoDemuxer<'a> { let vhdr = NAVideoInfo::new(width as usize, height as usize, false, PAL8_FORMAT); let vci = NACodecTypeInfo::Video(vhdr); let vinfo = NACodecInfo::new("gdv-video", vci, if edata.is_empty() { None } else { Some(edata) }); - self.v_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, u32::from(fps))); + self.v_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, u32::from(fps), u64::from(frames))); } if (aflags & 1) != 0 { let channels = if (aflags & 2) != 0 { 2 } else { 1 }; @@ -91,7 +91,7 @@ impl<'a> DemuxCore<'a> for GremlinVideoDemuxer<'a> { let ahdr = NAAudioInfo::new(u32::from(rate), channels as u8, if depth == 16 { SND_S16_FORMAT } else { SND_U8_FORMAT }, 2); let ainfo = NACodecInfo::new(if packed != 0 { "gdv-audio" } else { "pcm" }, NACodecTypeInfo::Audio(ahdr), None); - self.a_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, u32::from(rate))); + self.a_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, u32::from(rate), 0)); self.asize = (((rate / fps) * channels * (depth / 8)) >> packed) as usize; self.apacked = (aflags & 8) != 0; @@ -113,6 +113,7 @@ impl<'a> DemuxCore<'a> for GremlinVideoDemuxer<'a> { fn seek(&mut self, _time: NATimePoint, _seek_index: &SeekIndex) -> DemuxerResult<()> { Err(DemuxerError::NotPossible) } + fn get_duration(&self) -> u64 { 0 } } impl<'a> NAOptionHandler for GremlinVideoDemuxer<'a> { fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } diff --git a/nihav-game/src/demuxers/vmd.rs b/nihav-game/src/demuxers/vmd.rs index f693e73..a2c93f6 100644 --- a/nihav-game/src/demuxers/vmd.rs +++ b/nihav-game/src/demuxers/vmd.rs @@ -61,7 +61,7 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> { let vhdr = NAVideoInfo::new(width, height, false, PAL8_FORMAT); let vci = NACodecTypeInfo::Video(vhdr); let vinfo = NACodecInfo::new(if !self.is_indeo { "vmd-video" } else { "indeo3" }, vci, Some(edata)); - self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, 12)).unwrap(); + self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, 12, nframes as u64)).unwrap(); let is_ext_audio = (hdr_size & 0xF) == 4; let ext_audio_id = if is_ext_audio { @@ -100,7 +100,7 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> { } }; let ainfo = NACodecInfo::new(ac_name, NACodecTypeInfo::Audio(ahdr), Some(aedata)); - self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, srate)).unwrap(); + self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, srate, 0)).unwrap(); } else { block_size = 0; } @@ -183,6 +183,8 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> { fn seek(&mut self, _time: NATimePoint, _seek_index: &SeekIndex) -> DemuxerResult<()> { Err(DemuxerError::NotPossible) } + + fn get_duration(&self) -> u64 { 0 } } impl<'a> NAOptionHandler for VMDDemuxer<'a> { diff --git a/nihav-game/src/demuxers/vx.rs b/nihav-game/src/demuxers/vx.rs index cfc44e0..5d2786d 100644 --- a/nihav-game/src/demuxers/vx.rs +++ b/nihav-game/src/demuxers/vx.rs @@ -47,7 +47,7 @@ impl<'a> DemuxCore<'a> for VXDemuxer<'a> { let vci = NACodecTypeInfo::Video(vhdr); let edata = [fps as u8].to_vec(); let vinfo = NACodecInfo::new("vxvideo", vci, Some(edata)); - self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, fps)).unwrap(); + self.vid_id = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, 1, fps, nframes as u64)).unwrap(); if num_audio_tracks != 0 { validate!(audio_off + ((num_audio_tracks * AUDIO_EXTRADATA_LEN) as u64) == vinfo_off); @@ -56,7 +56,7 @@ impl<'a> DemuxCore<'a> for VXDemuxer<'a> { src.read_buf(edata.as_mut_slice())?; let ahdr = NAAudioInfo::new(srate, 1, SND_S16P_FORMAT, 1); let ainfo = NACodecInfo::new("vxaudio", NACodecTypeInfo::Audio(ahdr), Some(edata)); - self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, srate)).unwrap(); + self.aud_id = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, 1, srate, 0)).unwrap(); self.num_afrm = nframes as u64; self.ano = 0; self.num_aud = num_audio_tracks; @@ -98,6 +98,8 @@ impl<'a> DemuxCore<'a> for VXDemuxer<'a> { fn seek(&mut self, _time: NATimePoint, _seek_index: &SeekIndex) -> DemuxerResult<()> { Err(DemuxerError::NotPossible) } + + fn get_duration(&self) -> u64 { 0 } } impl<'a> NAOptionHandler for VXDemuxer<'a> { |