|
|
|
@ -31,8 +31,9 @@ SrsKbpsSample::SrsKbpsSample()
|
|
|
|
|
kbps = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsKbpsSlice::SrsKbpsSlice()
|
|
|
|
|
SrsKbpsSlice::SrsKbpsSlice(SrsWallClock* c)
|
|
|
|
|
{
|
|
|
|
|
clk = c;
|
|
|
|
|
io.in = NULL;
|
|
|
|
|
io.out = NULL;
|
|
|
|
|
last_bytes = io_bytes_base = starttime = bytes = delta_bytes = 0;
|
|
|
|
@ -49,7 +50,7 @@ int64_t SrsKbpsSlice::get_total_bytes()
|
|
|
|
|
|
|
|
|
|
void SrsKbpsSlice::sample()
|
|
|
|
|
{
|
|
|
|
|
int64_t now = clock->time_ms();
|
|
|
|
|
int64_t now = clk->time_ms();
|
|
|
|
|
int64_t total_bytes = get_total_bytes();
|
|
|
|
|
|
|
|
|
|
if (sample_30s.time <= 0) {
|
|
|
|
@ -116,14 +117,13 @@ int64_t SrsWallClock::time_ms()
|
|
|
|
|
return srs_get_system_time_ms();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsKbps::SrsKbps(SrsWallClock* c)
|
|
|
|
|
SrsKbps::SrsKbps(SrsWallClock* c) : is(c), os(c)
|
|
|
|
|
{
|
|
|
|
|
clock = c;
|
|
|
|
|
clk = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsKbps::~SrsKbps()
|
|
|
|
|
{
|
|
|
|
|
srs_freep(clock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SrsKbps::set_io(ISrsProtocolStatistic* in, ISrsProtocolStatistic* out)
|
|
|
|
@ -131,7 +131,7 @@ void SrsKbps::set_io(ISrsProtocolStatistic* in, ISrsProtocolStatistic* out)
|
|
|
|
|
// set input stream
|
|
|
|
|
// now, set start time.
|
|
|
|
|
if (is.starttime == 0) {
|
|
|
|
|
is.starttime = clock->time_ms();
|
|
|
|
|
is.starttime = clk->time_ms();
|
|
|
|
|
}
|
|
|
|
|
// save the old in bytes.
|
|
|
|
|
if (is.io.in) {
|
|
|
|
@ -149,7 +149,7 @@ void SrsKbps::set_io(ISrsProtocolStatistic* in, ISrsProtocolStatistic* out)
|
|
|
|
|
// set output stream
|
|
|
|
|
// now, set start time.
|
|
|
|
|
if (os.starttime == 0) {
|
|
|
|
|
os.starttime = clock->time_ms();
|
|
|
|
|
os.starttime = clk->time_ms();
|
|
|
|
|
}
|
|
|
|
|
// save the old in bytes.
|
|
|
|
|
if (os.io.out) {
|
|
|
|
@ -167,7 +167,7 @@ void SrsKbps::set_io(ISrsProtocolStatistic* in, ISrsProtocolStatistic* out)
|
|
|
|
|
|
|
|
|
|
int SrsKbps::get_send_kbps()
|
|
|
|
|
{
|
|
|
|
|
int64_t duration = clock->time_ms() - is.starttime;
|
|
|
|
|
int64_t duration = clk->time_ms() - is.starttime;
|
|
|
|
|
if (duration <= 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -177,7 +177,7 @@ int SrsKbps::get_send_kbps()
|
|
|
|
|
|
|
|
|
|
int SrsKbps::get_recv_kbps()
|
|
|
|
|
{
|
|
|
|
|
int64_t duration = clock->time_ms() - os.starttime;
|
|
|
|
|
int64_t duration = clk->time_ms() - os.starttime;
|
|
|
|
|
if (duration <= 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|