Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtp: send all RTCP packets as compound packets #1222

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading