From 542a85924ebfb347b7bf1c7baa471ee5ffe2d961 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:34:56 +0200 Subject: [PATCH] rtcp: send BYE manually (#1154) --- include/re_rtp.h | 1 + src/rtp/sess.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/re_rtp.h b/include/re_rtp.h index 05ae35a0a..449ad1a28 100644 --- a/include/re_rtp.h +++ b/include/re_rtp.h @@ -274,6 +274,7 @@ int rtcp_send_fir_rfc5104(struct rtp_sock *rs, uint32_t ssrc, int rtcp_debug(struct re_printf *pf, const struct rtp_sock *rs); void *rtcp_sock(const struct rtp_sock *rs); int rtcp_stats(struct rtp_sock *rs, uint32_t ssrc, struct rtcp_stats *stats); +int rtcp_send_bye_packet(struct rtp_sock *rs); /* RTCP utils */ int rtcp_encode(struct mbuf *mb, enum rtcp_type type, uint32_t count, ...); diff --git a/src/rtp/sess.c b/src/rtp/sess.c index 88b5773c6..6ee6e767e 100644 --- a/src/rtp/sess.c +++ b/src/rtp/sess.c @@ -65,16 +65,12 @@ struct rtcp_sess { /* Prototypes */ static void schedule(struct rtcp_sess *sess); -static int send_bye_packet(struct rtcp_sess *sess); static void sess_destructor(void *data) { struct rtcp_sess *sess = data; - if (sess->cname) - (void)send_bye_packet(sess); - tmr_cancel(&sess->tmr); mem_deref(sess->cname); @@ -509,9 +505,13 @@ static int send_rtcp_report(struct rtcp_sess *sess) } -static int send_bye_packet(struct rtcp_sess *sess) +int rtcp_send_bye_packet(struct rtp_sock *rs) { - const uint32_t ssrc = rtp_sess_ssrc(sess->rs); + if (!rs) + return EINVAL; + + struct rtcp_sess *sess = rtp_rtcp_sess(rs); + const uint32_t ssrc = rtp_sess_ssrc(rs); struct mbuf *mb; int err;