From c730981827b2c9a7d9edf458d636ad303cc35dbd Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Thu, 12 Feb 2026 18:48:22 +0200 Subject: [PATCH] janus: set first/last_of_frame only for non-sps/pps packets --- janus/src/rtpv.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/janus/src/rtpv.c b/janus/src/rtpv.c index 9c59b35..c47f61d 100644 --- a/janus/src/rtpv.c +++ b/janus/src/rtpv.c @@ -105,13 +105,28 @@ void _rtpv_process_nalu(us_rtpv_s *rtpv, const u8 *data, uz size, u32 pts, bool const uint type = data[0] & 0x1F; u8 *dg = rtpv->rtp->datagram; + // Set *_of_frame flags only for non-SPS/PPS packages +# define CALL_FOR_SERVICE { \ + const bool m_fof = rtpv->rtp->first_of_frame; \ + const bool m_lof = rtpv->rtp->last_of_frame; \ + rtpv->rtp->first_of_frame = false; \ + rtpv->rtp->last_of_frame = false; \ + rtpv->callback(rtpv->rtp); \ + rtpv->rtp->first_of_frame = m_fof; \ + rtpv->rtp->last_of_frame = m_lof; \ + } + if (size + US_RTP_HEADER_SIZE <= US_RTP_DATAGRAM_SIZE) { us_rtp_write_header(rtpv->rtp, pts, marked); memcpy(dg + US_RTP_HEADER_SIZE, data, size); rtpv->rtp->used = size + US_RTP_HEADER_SIZE; - rtpv->rtp->last_of_frame = true; - rtpv->callback(rtpv->rtp); - rtpv->rtp->first_of_frame = false; + if (type == 7 || type == 8) { + CALL_FOR_SERVICE; + } else { + rtpv->rtp->last_of_frame = true; + rtpv->callback(rtpv->rtp); + rtpv->rtp->first_of_frame = false; + } return; } @@ -143,14 +158,20 @@ void _rtpv_process_nalu(us_rtpv_s *rtpv, const u8 *data, uz size, u32 pts, bool memcpy(dg + fu_overhead, src, frag_size); rtpv->rtp->used = fu_overhead + frag_size; - rtpv->rtp->last_of_frame = last; - rtpv->callback(rtpv->rtp); - rtpv->rtp->first_of_frame = false; + if (type == 7 || type == 8) { + CALL_FOR_SERVICE; + } else { + rtpv->rtp->last_of_frame = last; + rtpv->callback(rtpv->rtp); + rtpv->rtp->first_of_frame = false; + } src += frag_size; remaining -= frag_size; first = false; } + +# undef CALL_FOR_SERVICE } static sz _find_annexb(const u8 *data, uz size) {