Skip to content

Commit

Permalink
rtcp: make rtcp_calc_rtt() public
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored and sreimers committed Mar 7, 2023
1 parent e9ba44d commit a3190a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/re_rtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ 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);
void rtcp_calc_rtt(uint32_t *rtt, uint32_t lsr, uint32_t dlsr);


/**
Expand Down
15 changes: 11 additions & 4 deletions src/rtp/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ static struct rtp_member *get_member(struct rtcp_sess *sess, uint32_t src)
}


/** Calculate Round-Trip Time in [microseconds] */
static void calc_rtt(uint32_t *rtt, uint32_t lsr, uint32_t dlsr)
/**
* Calculate Round-Trip Time in [microseconds]
*
* @param rtt Calculated Rount-Trip time [us]
* @param lsr Last SR packet from this source [compact NTP timestamp]
* @param dlsr Delay since last SR packet [units of 1/65536 seconds]
*/
void rtcp_calc_rtt(uint32_t *rtt, uint32_t lsr, uint32_t dlsr)
{
struct ntp_time ntp_time;
uint64_t a_us, lsr_us, dlsr_us;
Expand All @@ -118,7 +124,8 @@ static void calc_rtt(uint32_t *rtt, uint32_t lsr, uint32_t dlsr)
dlsr_us = 1000000ULL * dlsr / 65536;

/* RTT delay is (A - LSR - DLSR) */
*rtt = MAX((int)(a_us - lsr_us - dlsr_us), 0);
if (rtt)
*rtt = MAX((int)(a_us - lsr_us - dlsr_us), 0);
}


Expand All @@ -135,7 +142,7 @@ static void handle_rr_block(struct rtcp_sess *sess, struct rtp_member *mbr,

/* round-trip propagation delay as (A - LSR - DLSR) */
if (rr->lsr && rr->dlsr)
calc_rtt(&mbr->rtt, rr->lsr, rr->dlsr);
rtcp_calc_rtt(&mbr->rtt, rr->lsr, rr->dlsr);
}


Expand Down

0 comments on commit a3190a9

Please sign in to comment.