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

rtcp: make rtcp_calc_rtt() public #731

Merged
merged 1 commit into from
Mar 7, 2023
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
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