mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
merge srs2 for kbps
This commit is contained in:
commit
f92db0f87e
3 changed files with 61 additions and 23 deletions
|
@ -95,13 +95,9 @@ public:
|
|||
SrsKbpsSlice();
|
||||
virtual ~SrsKbpsSlice();
|
||||
public:
|
||||
/**
|
||||
* get current total bytes.
|
||||
*/
|
||||
// Get current total bytes, not depend on sample().
|
||||
virtual int64_t get_total_bytes();
|
||||
/**
|
||||
* resample all samples.
|
||||
*/
|
||||
// Resample the slice to calculate the kbps.
|
||||
virtual void sample();
|
||||
};
|
||||
|
||||
|
@ -161,6 +157,13 @@ public:
|
|||
* delta->resample();
|
||||
* printf("delta is %d/%d", delta->get_send_bytes_delta(), delta->get_recv_bytes_delta());
|
||||
* delta->cleanup();
|
||||
* 4. kbps used as ISrsProtocolStatistic, to provides raw bytes:
|
||||
* SrsKbps* kbps = ...;
|
||||
* kbps->set_io(in, out);
|
||||
* // both kbps->get_recv_bytes() and kbps->get_send_bytes() are available.
|
||||
* // we can use the kbps as the data source of another kbps:
|
||||
* SrsKbps* user = ...;
|
||||
* user->set_io(kbps, kbps);
|
||||
* the server never know how many bytes already send/recv, for the connection maybe closed.
|
||||
*/
|
||||
class SrsKbps : public virtual ISrsProtocolStatistic, public virtual IKbpsDelta
|
||||
|
@ -195,26 +198,15 @@ public:
|
|||
// 5m
|
||||
virtual int get_send_kbps_5m();
|
||||
virtual int get_recv_kbps_5m();
|
||||
// interface ISrsProtocolStatistic
|
||||
public:
|
||||
/**
|
||||
* get the total send/recv bytes, from the startup of the oldest io.
|
||||
* @remark, use sample() to update data.
|
||||
*/
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual int64_t get_recv_bytes();
|
||||
// interface IKbpsDelta
|
||||
public:
|
||||
/**
|
||||
* resample to get the delta.
|
||||
*/
|
||||
virtual void resample();
|
||||
/**
|
||||
* get the delta of send/recv bytes.
|
||||
*/
|
||||
virtual int64_t get_send_bytes_delta();
|
||||
virtual int64_t get_recv_bytes_delta();
|
||||
/**
|
||||
* cleanup the delta.
|
||||
*/
|
||||
virtual void cleanup();
|
||||
public:
|
||||
/**
|
||||
|
@ -232,6 +224,9 @@ public:
|
|||
* use the add_delta() is better solutions.
|
||||
*/
|
||||
virtual void sample();
|
||||
// interface ISrsMemorySizer
|
||||
public:
|
||||
virtual int size_memory();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue