mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Refine kbps
This commit is contained in:
parent
abfc35c6c7
commit
dcebf8a31f
2 changed files with 37 additions and 37 deletions
|
@ -205,6 +205,33 @@ int SrsKbps::get_recv_kbps_5m()
|
|||
return is.sample_5m.kbps;
|
||||
}
|
||||
|
||||
void SrsKbps::add_delta(IKbpsDelta* delta)
|
||||
{
|
||||
srs_assert(delta);
|
||||
|
||||
// update the total bytes
|
||||
is.last_bytes += delta->get_recv_bytes_delta();
|
||||
os.last_bytes += delta->get_send_bytes_delta();
|
||||
|
||||
// we donot sample, please use sample() to do resample.
|
||||
}
|
||||
|
||||
void SrsKbps::sample()
|
||||
{
|
||||
// update the total bytes
|
||||
if (os.io.out) {
|
||||
os.last_bytes = os.io.out->get_send_bytes();
|
||||
}
|
||||
|
||||
if (is.io.in) {
|
||||
is.last_bytes = is.io.in->get_recv_bytes();
|
||||
}
|
||||
|
||||
// resample
|
||||
is.sample();
|
||||
os.sample();
|
||||
}
|
||||
|
||||
int64_t SrsKbps::get_send_bytes()
|
||||
{
|
||||
// we must calc the send bytes dynamically,
|
||||
|
@ -272,33 +299,6 @@ void SrsKbps::cleanup()
|
|||
is.delta_bytes = is.get_total_bytes();
|
||||
}
|
||||
|
||||
void SrsKbps::add_delta(IKbpsDelta* delta)
|
||||
{
|
||||
srs_assert(delta);
|
||||
|
||||
// update the total bytes
|
||||
is.last_bytes += delta->get_recv_bytes_delta();
|
||||
os.last_bytes += delta->get_send_bytes_delta();
|
||||
|
||||
// we donot sample, please use sample() to do resample.
|
||||
}
|
||||
|
||||
void SrsKbps::sample()
|
||||
{
|
||||
// update the total bytes
|
||||
if (os.io.out) {
|
||||
os.last_bytes = os.io.out->get_send_bytes();
|
||||
}
|
||||
|
||||
if (is.io.in) {
|
||||
is.last_bytes = is.io.in->get_recv_bytes();
|
||||
}
|
||||
|
||||
// resample
|
||||
is.sample();
|
||||
os.sample();
|
||||
}
|
||||
|
||||
int SrsKbps::size_memory()
|
||||
{
|
||||
return sizeof(SrsKbps);
|
||||
|
|
|
@ -218,16 +218,6 @@ public:
|
|||
// 5m
|
||||
virtual int get_send_kbps_5m();
|
||||
virtual int get_recv_kbps_5m();
|
||||
// interface ISrsProtocolStatistic
|
||||
public:
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual int64_t get_recv_bytes();
|
||||
// interface IKbpsDelta
|
||||
public:
|
||||
virtual void resample();
|
||||
virtual int64_t get_send_bytes_delta();
|
||||
virtual int64_t get_recv_bytes_delta();
|
||||
virtual void cleanup();
|
||||
public:
|
||||
/**
|
||||
* add delta to kbps clac mechenism.
|
||||
|
@ -244,6 +234,16 @@ public:
|
|||
* use the add_delta() is better solutions.
|
||||
*/
|
||||
virtual void sample();
|
||||
// interface ISrsProtocolStatistic
|
||||
public:
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual int64_t get_recv_bytes();
|
||||
// interface IKbpsDelta
|
||||
public:
|
||||
virtual void resample();
|
||||
virtual int64_t get_send_bytes_delta();
|
||||
virtual int64_t get_recv_bytes_delta();
|
||||
virtual void cleanup();
|
||||
// interface ISrsMemorySizer
|
||||
public:
|
||||
virtual int size_memory();
|
||||
|
|
Loading…
Reference in a new issue