From acba0d67fb3ea65e82fba1eba1964df5ad7414ff Mon Sep 17 00:00:00 2001 From: Heikki Tampio Date: Mon, 31 Jul 2023 15:41:46 +0300 Subject: [PATCH] rtcp: Add functionality to RTCP FB packet handler --- include/uvgrtp/frame.hh | 2 ++ src/rtcp.cc | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/uvgrtp/frame.hh b/include/uvgrtp/frame.hh index 10018c3..57025df 100644 --- a/include/uvgrtp/frame.hh +++ b/include/uvgrtp/frame.hh @@ -166,6 +166,8 @@ namespace uvgrtp { uint32_t sender_ssrc = 0; uint32_t media_ssrc = 0; uint8_t* fci = nullptr; + /** \brief Size of the payload in bytes. Added by uvgRTP to help process the payload. */ + size_t payload_len = 0; }; PACK(struct zrtp_frame { diff --git a/src/rtcp.cc b/src/rtcp.cc index 6ef0a61..186ab0e 100644 --- a/src/rtcp.cc +++ b/src/rtcp.cc @@ -1589,12 +1589,30 @@ rtp_error_t uvgrtp::rtcp::handle_app_packet(uint8_t* packet, size_t& read_ptr, rtp_error_t uvgrtp::rtcp::handle_fb_packet(uint8_t* packet, size_t& read_ptr, size_t packet_end, uvgrtp::frame::rtcp_header& header) { - UVG_LOG_INFO("Received an RTCP FB message"); auto frame = new uvgrtp::frame::rtcp_fb_packet; frame->header = header; read_ssrc(packet, read_ptr, frame->sender_ssrc); - read_ssrc(packet, read_ptr, frame->media_ssrc); + if (!is_participant(frame->sender_ssrc)) + { + UVG_LOG_INFO("Got an RTCP FB packet from a previously unknown participant SSRC %lu", frame->sender_ssrc); + add_participant(frame->sender_ssrc); + } + + // copy media ssrc and Feedback Control Information from network packet to RTCP structures + read_ssrc(packet, read_ptr, frame->media_ssrc); + frame->payload_len = packet_end - read_ptr; + + if (frame->payload_len > 0) + { + // payload data is saved to fci + frame->fci = new uint8_t[frame->payload_len]; + memcpy(frame->fci, &packet[read_ptr], frame->payload_len); + } + else + { + frame->fci = nullptr; + } return RTP_OK; }