mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-03 02:03:48 +00:00
rtprecv: Improve detection of rtcp-mux RTCP packets received on the RTP sink pad
Most RTCP packets are also valid RTP packets and just have the marker bit set and a payload type between 64 and 95. If we don't know RTP caps for such packets, try parsing them as RTCP packet instead. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2362>
This commit is contained in:
parent
20eb83367d
commit
98b61b1e56
1 changed files with 30 additions and 9 deletions
|
@ -712,15 +712,36 @@ impl RtpRecv {
|
||||||
let mut sync_context = self.sync_context.lock().unwrap();
|
let mut sync_context = self.sync_context.lock().unwrap();
|
||||||
let sync_context = sync_context.as_mut().unwrap();
|
let sync_context = sync_context.as_mut().unwrap();
|
||||||
if !sync_context.has_clock_rate(rtp.ssrc()) {
|
if !sync_context.has_clock_rate(rtp.ssrc()) {
|
||||||
let Some(clock_rate) = session_inner.session.clock_rate_from_pt(rtp.payload_type())
|
let clock_rate = match session_inner.session.clock_rate_from_pt(rtp.payload_type())
|
||||||
else {
|
{
|
||||||
gst::warning!(
|
Some(clock_rate) => clock_rate,
|
||||||
CAT,
|
None => {
|
||||||
imp = self,
|
// See RFC 5761 Section 4: An RTP packet with the marker bit
|
||||||
"Have no clock-rate for payload type {}",
|
// and a payload type in this range is potentially an RTCP
|
||||||
rtp.payload_type()
|
// packet, especially if we don't know about the payload type.
|
||||||
);
|
//
|
||||||
return Ok(RecvRtpBuffer::Drop);
|
// FIXME: If this turns out to be too weak / strong of a check
|
||||||
|
// we could make use of explicit signalling of rtcp-mux via the
|
||||||
|
// caps based on the a=rtcp-mux SDP attribute or similar.
|
||||||
|
if rtp.marker_bit() && (64..=95).contains(&rtp.payload_type()) {
|
||||||
|
// If this is a valid RTCP packet then it was muxed with the RTP stream and can be
|
||||||
|
// handled just fine.
|
||||||
|
if rtcp_types::Compound::parse(&mapped)
|
||||||
|
.is_ok_and(|mut rtcp| rtcp.next().is_some_and(|rtcp| rtcp.is_ok()))
|
||||||
|
{
|
||||||
|
drop(mapped);
|
||||||
|
return Ok(RecvRtpBuffer::IsRtcp(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
sync_context.set_clock_rate(rtp.ssrc(), clock_rate);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue