mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the kbps comments, add one usage.
This commit is contained in:
parent
6ca46e84bc
commit
d645411392
2 changed files with 29 additions and 21 deletions
|
@ -135,27 +135,34 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to statistic the kbps of io.
|
* to statistic the kbps of io.
|
||||||
* itself can be a statistic source, for example, used for SRS bytes stat.
|
* itself can be a statistic source, for example, used for SRS bytes stat.
|
||||||
* there are two usage scenarios:
|
* there are some usage scenarios:
|
||||||
* 1. connections to calc kbps by sample():
|
* 1. connections to calc kbps by sample():
|
||||||
* SrsKbps* kbps = ...;
|
* SrsKbps* kbps = ...;
|
||||||
* kbps->set_io(in, out)
|
* kbps->set_io(in, out)
|
||||||
* kbps->sample()
|
* kbps->sample()
|
||||||
* kbps->get_xxx_kbps().
|
* kbps->get_xxx_kbps().
|
||||||
* the connections know how many bytes already send/recv.
|
* the connections know how many bytes already send/recv.
|
||||||
* 2. server to calc kbps by add_delta():
|
* 2. server to calc kbps by add_delta():
|
||||||
* SrsKbps* kbps = ...;
|
* SrsKbps* kbps = ...;
|
||||||
* kbps->set_io(NULL, NULL)
|
* kbps->set_io(NULL, NULL)
|
||||||
* for each connection in connections:
|
* for each connection in connections:
|
||||||
* IKbpsDelta* delta = connection; // where connection implements IKbpsDelta
|
* IKbpsDelta* delta = connection; // where connection implements IKbpsDelta
|
||||||
* delta->resample()
|
* delta->resample()
|
||||||
* kbps->add_delta(delta)
|
* kbps->add_delta(delta)
|
||||||
* delta->cleanup()
|
* delta->cleanup()
|
||||||
* kbps->sample()
|
* kbps->sample()
|
||||||
* kbps->get_xxx_kbps().
|
* kbps->get_xxx_kbps().
|
||||||
* the server never know how many bytes already send/recv, for the connection maybe closed.
|
* 3. kbps used as IKbpsDelta, to provides delta bytes:
|
||||||
*/
|
* SrsKbps* kbps = ...;
|
||||||
|
* kbps->set_io(in, out);
|
||||||
|
* IKbpsDelta* delta = (IKbpsDelta*)kbps;
|
||||||
|
* delta->resample();
|
||||||
|
* printf("delta is %d/%d", delta->get_send_bytes_delta(), delta->get_recv_bytes_delta());
|
||||||
|
* delta->cleanup();
|
||||||
|
* the server never know how many bytes already send/recv, for the connection maybe closed.
|
||||||
|
*/
|
||||||
class SrsKbps : public virtual ISrsProtocolStatistic, public virtual IKbpsDelta
|
class SrsKbps : public virtual ISrsProtocolStatistic, public virtual IKbpsDelta
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -167,6 +167,7 @@ public:
|
||||||
* sample the kbps, add delta bytes of conn.
|
* sample the kbps, add delta bytes of conn.
|
||||||
* use kbps_sample() to get all result of kbps stat.
|
* use kbps_sample() to get all result of kbps stat.
|
||||||
*/
|
*/
|
||||||
|
// TODO: FIXME: the add delta must use IKbpsDelta interface instead.
|
||||||
virtual void kbps_add_delta(SrsConnection* conn);
|
virtual void kbps_add_delta(SrsConnection* conn);
|
||||||
/**
|
/**
|
||||||
* calc the result for all kbps.
|
* calc the result for all kbps.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue