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 acdfe6a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
9 changes: 9 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,10 @@ static int rtcp_quick_send(struct rtp_sock *rs, enum rtcp_type type,
if (!err)
err = rtcp_send(rs, mb);

if (!err)
rtcp_schedule_report(rs);

out:
mem_deref(mb);

return err;
Expand Down
5 changes: 5 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 Expand Up @@ -86,3 +90,4 @@ void rtcp_sess_tx_rtp(struct rtcp_sess *sess, uint32_t ts, uint64_t jfs_rt,
size_t payload_size);
void rtcp_sess_rx_rtp(struct rtcp_sess *sess, struct rtp_header *hdr,
size_t payload_size, const struct sa *peer);
void rtcp_schedule_report(const struct rtp_sock *rs);
30 changes: 30 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 Expand Up @@ -556,6 +576,16 @@ static void schedule(struct rtcp_sess *sess)
}


void rtcp_schedule_report(const struct rtp_sock *rs)
{
struct rtcp_sess *sess = rtp_rtcp_sess(rs);
if (!sess)
return;

tmr_start(&sess->tmr, sess->interval, timeout, sess);
}


void rtcp_sess_tx_rtp(struct rtcp_sess *sess, uint32_t ts, uint64_t jfs_rt,
size_t payload_size)
{
Expand Down

0 comments on commit acdfe6a

Please sign in to comment.