ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.

Home Page:https://ossrs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`SrsKbps::get_recv_kbps` may encounter a division by zero exception?

JalySN opened this issue · comments

int SrsKbps::get_recv_kbps()
{
srs_utime_t duration = clk->now() - os.starttime;
if (duration <= 0) {
return 0;
}
int64_t bytes = get_recv_bytes();
return (int)(bytes * 8 / srsu2ms(duration));
}

duration< 1000 will result in division by zero

TRANS_BY_GPT3

SrsKbps::get_send_kbps should also have a similar issue.

TRANS_BY_GPT3

👍 It has been fixed, and I have picked it to the 3.0 branch: 4ccb838#diff-e156a1170da82b924422f8449d015822167081b84e1f9f3bf358edd3aa36537b

TRANS_BY_GPT3