diff --git a/include/uvgrtp/frame.hh b/include/uvgrtp/frame.hh index 41870d4..10018c3 100644 --- a/include/uvgrtp/frame.hh +++ b/include/uvgrtp/frame.hh @@ -84,6 +84,8 @@ namespace uvgrtp { uint8_t count = 0; /** \brief Subtype in APP packets. Alternative to count */ uint8_t pkt_subtype; + /** \brief Feedback message type (FMT), specified in RFC 5104 section 4.3. Alternative to count and pkt_subtype */ + uint8_t fmt; }; /** \brief Identifies the RTCP packet type */ uint8_t pkt_type = 0; @@ -158,6 +160,13 @@ namespace uvgrtp { /** \brief Size of the payload in bytes. Added by uvgRTP to help process the payload. */ size_t payload_len = 0; }; + /** \brief Feedback message. See RFC 5104 section 6.1 */ + struct rtcp_fb_packet { + struct rtcp_header header; + uint32_t sender_ssrc = 0; + uint32_t media_ssrc = 0; + uint8_t* fci = nullptr; + }; PACK(struct zrtp_frame { uint8_t version:4; diff --git a/include/uvgrtp/rtcp.hh b/include/uvgrtp/rtcp.hh index 6025c02..11d2f4e 100644 --- a/include/uvgrtp/rtcp.hh +++ b/include/uvgrtp/rtcp.hh @@ -458,6 +458,8 @@ namespace uvgrtp { uvgrtp::frame::rtcp_header& header); rtp_error_t handle_app_packet(uint8_t* buffer, size_t& read_ptr, size_t packet_end, uvgrtp::frame::rtcp_header& header); + rtp_error_t handle_fb_packet(uint8_t* buffer, size_t& read_ptr, size_t packet_end, + uvgrtp::frame::rtcp_header& header); static void rtcp_runner(rtcp *rtcp); diff --git a/src/rtcp.cc b/src/rtcp.cc index 1d73b75..6ef0a61 100644 --- a/src/rtcp.cc +++ b/src/rtcp.cc @@ -1226,11 +1226,11 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(void* args, int rce_flags, uint break; case uvgrtp::frame::RTCP_FT_RTPFB: - UVG_LOG_INFO("Received a transport-layer FB message"); + ret = handle_fb_packet(buffer, read_ptr, packet_end, header); break; case uvgrtp::frame::RTCP_FT_PSFB: - UVG_LOG_INFO("Received a payload-specific FB message"); + ret = handle_fb_packet(buffer, read_ptr, packet_end, header); break; default: @@ -1271,6 +1271,9 @@ void uvgrtp::rtcp::read_rtcp_header(const uint8_t* buffer, size_t& read_ptr, uvg { header.pkt_subtype = buffer[read_ptr] & 0x1f; } + else if (header.pkt_type == uvgrtp::frame::RTCP_FT_RTPFB || header.pkt_type == uvgrtp::frame::RTCP_FT_PSFB) { + header.fmt = buffer[read_ptr] & 0x1f; + } else { header.count = buffer[read_ptr] & 0x1f; } @@ -1583,6 +1586,18 @@ rtp_error_t uvgrtp::rtcp::handle_app_packet(uint8_t* packet, size_t& read_ptr, return RTP_OK; } +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); + + return RTP_OK; +} + rtp_error_t uvgrtp::rtcp::send_rtcp_packet_to_participants(uint8_t* frame, uint32_t frame_size, bool encrypt) { if (!frame)