diff --git a/include/re_rtp.h b/include/re_rtp.h index 715e9afa3..c7d098f4d 100644 --- a/include/re_rtp.h +++ b/include/re_rtp.h @@ -248,6 +248,7 @@ int rtcp_msg_print(struct re_printf *pf, const struct rtcp_msg *msg); int rtcp_sdes_encode(struct mbuf *mb, uint32_t src, uint32_t itemc, ...); const char *rtcp_type_name(enum rtcp_type type); const char *rtcp_sdes_name(enum rtcp_sdes_type sdes); +bool rtp_is_rtcp_packet(const struct mbuf *mb); static inline bool rtp_pt_is_rtcp(uint8_t pt) diff --git a/src/rtp/rtcp.c b/src/rtp/rtcp.c index 6e708de29..24cac1434 100644 --- a/src/rtp/rtcp.c +++ b/src/rtp/rtcp.c @@ -283,3 +283,16 @@ int rtcp_msg_print(struct re_printf *pf, const struct rtcp_msg *msg) return err; } + + +bool rtp_is_rtcp_packet(const struct mbuf *mb) +{ + uint8_t pt; + + if (mbuf_get_left(mb) < 2) + return false; + + pt = mbuf_buf(mb)[1] & 0x7f; + + return rtp_pt_is_rtcp(pt); +}