From ae2e8233407aa65ebbebee0e5811d7cb860edea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 11 Jul 2025 19:57:50 +0300 Subject: [PATCH] rtprecv: Drop packets for which we have no clock-rate instead of panicking Panicking if some spurious packet with an unknown payload type is received is not good behaviour. Part-of: --- net/rtp/src/rtpbin2/rtprecv.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/rtp/src/rtpbin2/rtprecv.rs b/net/rtp/src/rtpbin2/rtprecv.rs index 5ef4f8f45..e0d4c3c52 100644 --- a/net/rtp/src/rtpbin2/rtprecv.rs +++ b/net/rtp/src/rtpbin2/rtprecv.rs @@ -712,10 +712,16 @@ impl RtpRecv { let mut sync_context = self.sync_context.lock().unwrap(); let sync_context = sync_context.as_mut().unwrap(); if !sync_context.has_clock_rate(rtp.ssrc()) { - let clock_rate = session_inner - .session - .clock_rate_from_pt(rtp.payload_type()) - .unwrap(); + let Some(clock_rate) = session_inner.session.clock_rate_from_pt(rtp.payload_type()) + else { + gst::warning!( + CAT, + imp = self, + "Have no clock-rate for payload type {}", + rtp.payload_type() + ); + return Ok(RecvRtpBuffer::Drop); + }; sync_context.set_clock_rate(rtp.ssrc(), clock_rate); }