1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +00:00

refine the kbps comments, add one usage.

This commit is contained in:
winlin 2015-05-22 20:31:07 +08:00
parent 6ca46e84bc
commit d645411392
2 changed files with 29 additions and 21 deletions

View file

@ -135,27 +135,34 @@ public:
};
/**
* to statistic the kbps of io.
* itself can be a statistic source, for example, used for SRS bytes stat.
* there are two usage scenarios:
* 1. connections to calc kbps by sample():
* SrsKbps* kbps = ...;
* kbps->set_io(in, out)
* kbps->sample()
* kbps->get_xxx_kbps().
* the connections know how many bytes already send/recv.
* 2. server to calc kbps by add_delta():
* SrsKbps* kbps = ...;
* kbps->set_io(NULL, NULL)
* for each connection in connections:
* IKbpsDelta* delta = connection; // where connection implements IKbpsDelta
* delta->resample()
* kbps->add_delta(delta)
* delta->cleanup()
* kbps->sample()
* kbps->get_xxx_kbps().
* the server never know how many bytes already send/recv, for the connection maybe closed.
*/
* to statistic the kbps of io.
* itself can be a statistic source, for example, used for SRS bytes stat.
* there are some usage scenarios:
* 1. connections to calc kbps by sample():
* SrsKbps* kbps = ...;
* kbps->set_io(in, out)
* kbps->sample()
* kbps->get_xxx_kbps().
* the connections know how many bytes already send/recv.
* 2. server to calc kbps by add_delta():
* SrsKbps* kbps = ...;
* kbps->set_io(NULL, NULL)
* for each connection in connections:
* IKbpsDelta* delta = connection; // where connection implements IKbpsDelta
* delta->resample()
* kbps->add_delta(delta)
* delta->cleanup()
* kbps->sample()
* kbps->get_xxx_kbps().
* 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
{
private:

View file

@ -167,6 +167,7 @@ public:
* sample the kbps, add delta bytes of conn.
* 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);
/**
* calc the result for all kbps.