diff --git a/src/rtp/rtcp.c b/src/rtp/rtcp.c index c3520c265..5df18274f 100644 --- a/src/rtp/rtcp.c +++ b/src/rtp/rtcp.c @@ -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); @@ -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; diff --git a/src/rtp/rtcp.h b/src/rtp/rtcp.h index 980daf523..7e9847a2b 100644 --- a/src/rtp/rtcp.h +++ b/src/rtp/rtcp.h @@ -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); @@ -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); diff --git a/src/rtp/sess.c b/src/rtp/sess.c index 6ee6e767e..9dc769905 100644 --- a/src/rtp/sess.c +++ b/src/rtp/sess.c @@ -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; @@ -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; @@ -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) {