From 2dac4db9fc5995462f96ad89e35fb219be575643 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Fri, 15 May 2026 01:07:59 +0300 Subject: [PATCH] janus: fixed first/last frame logic for sps/pps --- janus/src/rtpv.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/janus/src/rtpv.c b/janus/src/rtpv.c index 938e872..731847c 100644 --- a/janus/src/rtpv.c +++ b/janus/src/rtpv.c @@ -65,8 +65,6 @@ void us_rtpv_wrap(us_rtpv_s *rtpv, const us_frame_s *frame, bool zero_playout_de assert(frame->format == V4L2_PIX_FMT_H264); - rtpv->rtp->first_of_frame = true; - rtpv->rtp->last_of_frame = false; rtpv->rtp->zero_playout_delay = zero_playout_delay; rtpv->rtp->grab_ntp_ts = us_get_now_ntp() - us_ld_to_ntp(us_get_now_monotonic() - frame->grab_begin_ts); @@ -105,30 +103,18 @@ 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_TOTAL_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; -// if (type == 7 || type == 8) { -// CALL_FOR_SERVICE; -// } else {*/ - rtpv->rtp->last_of_frame = true; - rtpv->callback(rtpv->rtp); + if (type == 7 || type == 8) { // SPS || PPS rtpv->rtp->first_of_frame = false; -// } + rtpv->rtp->last_of_frame = false; + } else { + rtpv->rtp->first_of_frame = true; + rtpv->rtp->last_of_frame = true; + } + rtpv->callback(rtpv->rtp); return; } @@ -160,20 +146,14 @@ 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; -// 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; -// } + rtpv->rtp->first_of_frame = first; + rtpv->rtp->last_of_frame = last; + rtpv->callback(rtpv->rtp); src += frag_size; remaining -= frag_size; first = false; } - -# undef CALL_FOR_SERVICE } static sz _find_annexb(const u8 *data, uz size) {