Skip to content

Commit

Permalink
rtp: send all RTCP packets as compound packets
Browse files Browse the repository at this point in the history
According to RFC 3550 section 6.1 this is a MUST.
  • Loading branch information
maximilianfridrich committed Dec 2, 2024
1 parent a07bc3e commit 67061a5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rtp/rtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ static int rtcp_quick_send(struct rtp_sock *rs, enum rtcp_type type,

mb->pos = RTCP_HEADROOM;

err = rtcp_make_sr(rs, mb);
err |= rtcp_make_sdes_cname(rs, mb);
if (err)
goto out;

va_start(ap, count);
err = rtcp_vencode(mb, type, count, ap);
va_end(ap);
Expand All @@ -36,6 +41,7 @@ static int rtcp_quick_send(struct rtp_sock *rs, enum rtcp_type type,
if (!err)
err = rtcp_send(rs, mb);

out:
mem_deref(mb);

return err;
Expand Down
4 changes: 4 additions & 0 deletions src/rtp/rtcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ int rtcp_rr_alloc(struct rtcp_rr **rrp, size_t count);
int rtcp_rr_encode(struct mbuf *mb, const struct rtcp_rr *rr);
int rtcp_rr_decode(struct mbuf *mb, struct rtcp_rr *rr);

/* SR (Sender report) */
int rtcp_make_sr(const struct rtp_sock *rs, struct mbuf *mb);

/* SDES (Source Description) */
int rtcp_sdes_decode(struct mbuf *mb, struct rtcp_sdes *sdes);
int rtcp_make_sdes_cname(const struct rtp_sock *rs, struct mbuf *mb);

/* RTCP Feedback */
int rtcp_rtpfb_gnack_encode(struct mbuf *mb, uint16_t pid, uint16_t blp);
Expand Down
20 changes: 20 additions & 0 deletions src/rtp/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,16 @@ static int mk_sr(struct rtcp_sess *sess, struct mbuf *mb)
}


int rtcp_make_sr(const struct rtp_sock *rs, struct mbuf *mb)
{
struct rtcp_sess *sess = rtp_rtcp_sess(rs);
if (!sess)
return EINVAL;

return mk_sr(sess, mb);
}


static int sdes_encode_handler(struct mbuf *mb, void *arg)
{
struct rtcp_sess *sess = arg;
Expand All @@ -479,6 +489,16 @@ static int mk_sdes(struct rtcp_sess *sess, struct mbuf *mb)
}


int rtcp_make_sdes_cname(const struct rtp_sock *rs, struct mbuf *mb)
{
struct rtcp_sess *sess = rtp_rtcp_sess(rs);
if (!sess)
return EINVAL;

return mk_sdes(sess, mb);
}


static int send_rtcp_report(struct rtcp_sess *sess)
{
struct mbuf *mb;
Expand Down

0 comments on commit 67061a5

Please sign in to comment.