Skip to content

Commit

Permalink
rtp/rtcp: add RTCP Generic NACK packet (RFC 4585 6.2.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Sep 4, 2024
1 parent 1bf492a commit 5a9a142
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/re_rtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ int rtcp_send_app(struct rtp_sock *rs, const char name[4],
const uint8_t *data, size_t len);
int rtcp_send_fir(struct rtp_sock *rs, uint32_t ssrc);
int rtcp_send_nack(struct rtp_sock *rs, uint16_t fsn, uint16_t blp);
int rtcp_send_gnack(struct rtp_sock *rs, uint32_t ssrc, uint16_t fsn,
uint16_t blp);
int rtcp_send_pli(struct rtp_sock *rs, uint32_t fb_ssrc);
int rtcp_send_fir_rfc5104(struct rtp_sock *rs, uint32_t ssrc,
uint8_t fir_seqn);
Expand Down
30 changes: 30 additions & 0 deletions src/rtp/rtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,36 @@ int rtcp_send_nack(struct rtp_sock *rs, uint16_t fsn, uint16_t blp)
}


static int encode_gnack(struct mbuf *mb, void *arg)
{
struct gnack *fci = arg;

int err = mbuf_write_u16(mb, htons(fci->pid));
err |= mbuf_write_u16(mb, htons(fci->blp));
return err;
}


/**
* Send an RTCP Generic NACK packet (RFC 4585 6.2.1)
*
* @param rs RTP Socket
* @param ssrc SSRC of the target encoder
* @param fsn First Sequence Number lost
* @param blp Bitmask of lost packets
*
* @return 0 for success, otherwise errorcode
*/
int rtcp_send_gnack(struct rtp_sock *rs, uint32_t ssrc, uint16_t fsn,
uint16_t blp)
{
struct gnack fci = {fsn, blp};
return rtcp_quick_send(rs, RTCP_RTPFB, RTCP_RTPFB_GNACK,
rtp_sess_ssrc(rs), ssrc, &encode_gnack,
&fci);
}


/**
* Send an RTCP Picture Loss Indication (PLI) packet
*
Expand Down

0 comments on commit 5a9a142

Please sign in to comment.