X-Git-Url: https://git.nihav.org/?p=nihav.git;a=blobdiff_plain;f=nihav-vivo%2Fsrc%2Fdemuxers%2Fvivo.rs;h=4a6f25469b29fc5d3f9e5906dc9b586f942d60ab;hp=06decd12f1aefc32085994c879d7025a0611bfb7;hb=a480a0de101483d802a11e72d758dae00fa4860a;hpb=31cf33aceca7798294e1ce5c01702ef5e6ef7adc diff --git a/nihav-vivo/src/demuxers/vivo.rs b/nihav-vivo/src/demuxers/vivo.rs index 06decd1..4a6f254 100644 --- a/nihav-vivo/src/demuxers/vivo.rs +++ b/nihav-vivo/src/demuxers/vivo.rs @@ -14,6 +14,7 @@ struct VivoDemuxer<'a> { fps: f32, width: usize, height: usize, + duration: u64, vname: &'static str, aname: &'static str, } @@ -57,7 +58,7 @@ impl<'a> DemuxCore<'a> for VivoDemuxer<'a> { let vhdr = NAVideoInfo::new(self.width, self.height, false, YUV420_FORMAT); let vinfo = NACodecInfo::new(self.vname, NACodecTypeInfo::Video(vhdr), None); - let res = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, self.v_num, self.v_den)); + let res = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, self.v_num, self.v_den, 0)); validate!(res.is_some()); self.video_id = res.unwrap(); @@ -69,7 +70,7 @@ impl<'a> DemuxCore<'a> for VivoDemuxer<'a> { if self.aname != "none" { let ahdr = NAAudioInfo::new(self.a_den, 1, SND_S16_FORMAT, self.a_num as usize); let ainfo = NACodecInfo::new(self.aname, NACodecTypeInfo::Audio(ahdr), None); - let res = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, self.a_num, self.a_den)); + let res = strmgr.add_stream(NAStream::new(StreamType::Audio, 1, ainfo, self.a_num, self.a_den, 0)); validate!(res.is_some()); self.audio_id = res.unwrap(); } @@ -129,9 +130,16 @@ impl<'a> DemuxCore<'a> for VivoDemuxer<'a> { } } } - fn seek(&mut self, _time: u64, _seek_idx: &SeekIndex) -> DemuxerResult<()> { + fn seek(&mut self, _time: NATimePoint, _seek_idx: &SeekIndex) -> DemuxerResult<()> { Err(DemuxerError::NotPossible) } + fn get_duration(&self) -> u64 { self.duration } +} + +impl<'a> NAOptionHandler for VivoDemuxer<'a> { + fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] } + fn set_options(&mut self, _options: &[NAOption]) { } + fn query_option_value(&self, _name: &str) -> Option { None } } impl<'a> VivoDemuxer<'a> { @@ -150,6 +158,7 @@ impl<'a> VivoDemuxer<'a> { width: 0, height: 0, fps: 0.0, + duration: 0, vname: "none", aname: "none", } @@ -157,7 +166,7 @@ impl<'a> VivoDemuxer<'a> { fn parse_header_packet(&mut self, pkt: &[u8]) -> DemuxerResult<()> { for entry in pkt.split(|ch| *ch == 0xD) { if entry.len() < 3 || !entry.contains(&b':') { continue; } - let entry = if entry.len() > 0 && entry[0] == 0xA { &entry[1..] } else { entry }; + let entry = if !entry.is_empty() && entry[0] == 0xA { &entry[1..] } else { entry }; let mut split = entry.split(|ch| *ch == b':'); let name = split.next().unwrap(); let value = split.next().unwrap(); @@ -210,6 +219,11 @@ impl<'a> VivoDemuxer<'a> { return Err(DemuxerError::InvalidData); }; }, + b"Duration" => { + self.duration = if let Ok(val) = valstr.parse() { + val + } else { 0 }; + }, /* b"TimeUnitNumerator" => { self.v_num = if let Ok(val) = valstr.parse() { val