From e0d229ca18016f537e9915979c00711a257dba02 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 4 May 2023 19:14:14 +0200 Subject: [PATCH] rmmux: generate monotone timestamps for video stream --- nihav-realmedia/src/muxers/rmvb/videostream.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nihav-realmedia/src/muxers/rmvb/videostream.rs b/nihav-realmedia/src/muxers/rmvb/videostream.rs index d1aecce..1001c51 100644 --- a/nihav-realmedia/src/muxers/rmvb/videostream.rs +++ b/nihav-realmedia/src/muxers/rmvb/videostream.rs @@ -36,6 +36,7 @@ struct VideoStreamWriter { cur_slice: usize, seq_no: u8, time: u32, + mi_time: u32, } impl RMStreamWriter for VideoStreamWriter { @@ -86,6 +87,9 @@ impl RMStreamWriter for VideoStreamWriter { self.buf.resize(src.len(), 0); self.buf.copy_from_slice(&src); self.time = ms; + if ms > 0 { + self.mi_time = ms.max(self.mi_time + 1); + } } true } else { @@ -140,7 +144,7 @@ impl RMStreamWriter for VideoStreamWriter { self.cur_slice = 0; self.seq_no = self.seq_no.wrapping_add(1); } - Some((ret, self.time, first)) + Some((ret, self.mi_time, first)) } else { None } @@ -164,6 +168,7 @@ pub fn create_video_stream(stream: &NAStream) -> MuxerResult