From 8e62e54cc991919f26101bbf6e814e3d6858239c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 12 Jan 2025 11:37:25 +0200 Subject: [PATCH] rtp: basepay: Only forward buffers if we have a segment If there are pending buffers without a segment then they must come from the caps only and should be forwarded at a later time, if any. Also reject any incoming buffers if no segment was received. Part-of: --- net/rtp/src/basepay/imp.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/rtp/src/basepay/imp.rs b/net/rtp/src/basepay/imp.rs index 94df3e3fa..5db4b0a03 100644 --- a/net/rtp/src/basepay/imp.rs +++ b/net/rtp/src/basepay/imp.rs @@ -790,6 +790,15 @@ impl RtpBasePay2 { pub(super) fn finish_pending_packets(&self) -> Result { let mut state = self.state.borrow_mut(); + if state.segment.is_none() { + if !state.pending_buffers.is_empty() { + // The queued buffers must be based on the caps only. They can be forwarded at a later + // time, if there is one. + gst::debug!(CAT, imp = self, "Can't finish buffers yet without segment"); + } + return Ok(gst::FlowSuccess::Ok); + } + // As long as there are packets that can be finished, take all with the same PTS and put // them into a buffer list. while state @@ -1570,6 +1579,11 @@ impl RtpBasePay2 { return Err(gst::FlowError::NotNegotiated); } + if state.segment.is_none() { + gst::error!(CAT, imp = self, "Received buffers without segment"); + return Err(gst::FlowError::Error); + } + if buffer.flags().contains(gst::BufferFlags::HEADER) && self.obj().class().as_ref().drop_header_buffers {