1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine framework to calc the kbps

This commit is contained in:
winlin 2014-05-12 17:27:50 +08:00
parent 3f33dffdb3
commit 9006194cd7
21 changed files with 153 additions and 131 deletions

View file

@ -44,9 +44,6 @@ SimpleSocketStream::SimpleSocketStream()
fd = -1;
send_timeout = recv_timeout = ST_UTIME_NO_TIMEOUT;
recv_bytes = send_bytes = 0;
srs_update_system_time_ms();
start_time_ms = srs_get_system_time_ms();
}
SimpleSocketStream::~SimpleSocketStream()
@ -122,18 +119,6 @@ int64_t SimpleSocketStream::get_recv_bytes()
return recv_bytes;
}
int SimpleSocketStream::get_recv_kbps()
{
srs_update_system_time_ms();
int64_t diff_ms = srs_get_system_time_ms() - start_time_ms;
if (diff_ms <= 0) {
return 0;
}
return recv_bytes * 8 / diff_ms;
}
// ISrsProtocolWriter
void SimpleSocketStream::set_send_timeout(int64_t timeout_us)
{
@ -150,18 +135,6 @@ int64_t SimpleSocketStream::get_send_bytes()
return send_bytes;
}
int SimpleSocketStream::get_send_kbps()
{
srs_update_system_time_ms();
int64_t diff_ms = srs_get_system_time_ms() - start_time_ms;
if (diff_ms <= 0) {
return 0;
}
return send_bytes * 8 / diff_ms;
}
int SimpleSocketStream::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
{
int ret = ERROR_SUCCESS;