From 60b9641e93c0feb263f961dec5be151b59b5939a Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 11 Jun 2020 12:54:34 +0200 Subject: [PATCH] rmdemux: support index version 2 --- nihav-realmedia/src/demuxers/realmedia.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/nihav-realmedia/src/demuxers/realmedia.rs b/nihav-realmedia/src/demuxers/realmedia.rs index d591eab..b5cd9b7 100644 --- a/nihav-realmedia/src/demuxers/realmedia.rs +++ b/nihav-realmedia/src/demuxers/realmedia.rs @@ -1132,19 +1132,29 @@ impl<'a> RealMediaDemuxer<'a> { Ok(()) } fn parse_index(&mut self, seek_idx: &mut SeekIndex, chunk_size: usize, ver: u16) -> DemuxerResult<()> { - if ver != 0 { return Ok(()); } + if ver != 0 && ver != 2 { return Ok(()); } let num_entries = self.src.read_u32be()? as usize; let str_id = self.src.read_u16be()? as u32; let _next_idx = self.src.read_u32be()?; - validate!(chunk_size == num_entries * 14 + 10); + if ver == 2 { + self.src.read_u32be()?; + } + if ver == 0 { + validate!(chunk_size == num_entries * 14 + 10); + } else { + validate!(chunk_size == num_entries * 18 + 14); + } if num_entries == 0 { return Ok(()); } seek_idx.add_stream(str_id); let idx = seek_idx.get_stream_index(str_id).unwrap(); for _ in 0..num_entries { - let ver = self.src.read_u16be()? as u32; - validate!(ver == 0); + let iver = self.src.read_u16be()?; + validate!(iver == ver); let ts = self.src.read_u32be()? as u64; + if ver == 2 { + self.src.read_u32be()?; + } let pos = self.src.read_u32be()? as u64; let _pkt_no = self.src.read_u32be()?; idx.add_entry(SeekEntry { time: ts, pts: 0, pos }); -- 2.39.5