Commit 73317c9b authored by Ghislain MARY's avatar Ghislain MARY

Fix possible error in bandwidth computing (update time of computing start on...

Fix possible error in bandwidth computing (update time of computing start on last compute, not on last packet handled after last compute).
parent cf526666
......@@ -1696,19 +1696,27 @@ static float compute_bw(struct timeval *orig, unsigned int bytes){
return bw;
}
static void compute_recv_bandwidth(OrtpStream *os) {
os->download_bw = compute_bw(&os->recv_bw_start, os->recv_bytes);
os->recv_bytes = 0;
ortp_gettimeofday(&os->recv_bw_start, NULL);
}
static void compute_send_bandwidth(OrtpStream *os) {
os->upload_bw = compute_bw(&os->send_bw_start, os->sent_bytes);
os->sent_bytes = 0;
ortp_gettimeofday(&os->send_bw_start, NULL);
}
float rtp_session_compute_recv_bandwidth(RtpSession *session) {
session->rtp.gs.download_bw = compute_bw(&session->rtp.gs.recv_bw_start, session->rtp.gs.recv_bytes);
session->rtp.gs.recv_bytes = 0;
session->rtcp.gs.download_bw = compute_bw(&session->rtcp.gs.recv_bw_start, session->rtcp.gs.recv_bytes);
session->rtcp.gs.recv_bytes = 0;
compute_recv_bandwidth(&session->rtp.gs);
compute_recv_bandwidth(&session->rtcp.gs);
return session->rtp.gs.download_bw + session->rtcp.gs.download_bw;
}
float rtp_session_compute_send_bandwidth(RtpSession *session) {
session->rtp.gs.upload_bw = compute_bw(&session->rtp.gs.send_bw_start, session->rtp.gs.sent_bytes);
session->rtp.gs.sent_bytes = 0;
session->rtcp.gs.upload_bw = compute_bw(&session->rtcp.gs.send_bw_start, session->rtcp.gs.sent_bytes);
session->rtcp.gs.sent_bytes = 0;
compute_send_bandwidth(&session->rtp.gs);
compute_send_bandwidth(&session->rtcp.gs);
return session->rtp.gs.upload_bw + session->rtcp.gs.upload_bw;
}
......
......@@ -919,7 +919,8 @@ static bool_t is_ipv6(OrtpStream *os) {
static void update_sent_bytes(OrtpStream *os, int nbytes) {
int overhead = is_ipv6(os) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
if (os->sent_bytes == 0) {
if ((os->sent_bytes == 0) && (os->send_bw_start.tv_sec == 0) && (os->send_bw_start.tv_usec == 0)) {
/* Initialize bandwidth computing time when has not been started yet. */
ortp_gettimeofday(&os->send_bw_start, NULL);
}
os->sent_bytes += nbytes + overhead;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment