mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine kbps, stub wall clock
This commit is contained in:
parent
4c40370986
commit
c26b475bae
15 changed files with 70 additions and 27 deletions
|
|
@ -163,7 +163,8 @@ srs_error_t SrsBandwidth::bandwidth_check(SrsRtmpServer* rtmp, ISrsProtocolStati
|
|||
}
|
||||
|
||||
// create a limit object.
|
||||
SrsKbps kbps;
|
||||
SrsWallClock clk;
|
||||
SrsKbps kbps(&clk);
|
||||
kbps.set_io(io_stat, io_stat);
|
||||
|
||||
int limit_kbps = _srs_config->get_bw_check_limit_kbps(_req->vhost);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ SrsConnection::SrsConnection(IConnectionManager* cm, srs_netfd_t c, string cip)
|
|||
create_time = srs_get_system_time_ms();
|
||||
|
||||
skt = new SrsStSocket();
|
||||
kbps = new SrsKbps(new SrsWallClock());
|
||||
clk = new SrsWallClock();
|
||||
kbps = new SrsKbps(clk);
|
||||
kbps->set_io(skt, skt);
|
||||
|
||||
trd = new SrsSTCoroutine("conn", this);
|
||||
|
|
@ -50,6 +51,7 @@ SrsConnection::~SrsConnection()
|
|||
dispose();
|
||||
|
||||
srs_freep(kbps);
|
||||
srs_freep(clk);
|
||||
srs_freep(skt);
|
||||
srs_freep(trd);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#include <srs_app_reload.hpp>
|
||||
#include <srs_service_conn.hpp>
|
||||
|
||||
class SrsWallClock;
|
||||
|
||||
/**
|
||||
* the basic connection of SRS,
|
||||
* all connections accept from listener must extends from this base class,
|
||||
|
|
@ -71,6 +73,7 @@ protected:
|
|||
* the SrsStatistic will use it indirectly to statistic the bytes delta of current connection.
|
||||
*/
|
||||
SrsKbps* kbps;
|
||||
SrsWallClock* clk;
|
||||
/**
|
||||
* the create time in milliseconds.
|
||||
* for current connection to log self create time and calculate the living time.
|
||||
|
|
|
|||
|
|
@ -110,8 +110,7 @@ SrsClientInfo::~SrsClientInfo()
|
|||
srs_freep(res);
|
||||
}
|
||||
|
||||
SrsRtmpConn::SrsRtmpConn(SrsServer* svr, srs_netfd_t c, string cip)
|
||||
: SrsConnection(svr, c, cip)
|
||||
SrsRtmpConn::SrsRtmpConn(SrsServer* svr, srs_netfd_t c, string cip) : SrsConnection(svr, c, cip)
|
||||
{
|
||||
server = svr;
|
||||
|
||||
|
|
@ -120,8 +119,6 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, srs_netfd_t c, string cip)
|
|||
bandwidth = new SrsBandwidth();
|
||||
security = new SrsSecurity();
|
||||
duration = 0;
|
||||
kbps = new SrsKbps(new SrsWallClock());
|
||||
kbps->set_io(skt, skt);
|
||||
wakable = NULL;
|
||||
|
||||
mw_sleep = SRS_PERF_MW_SLEEP;
|
||||
|
|
@ -143,7 +140,6 @@ SrsRtmpConn::~SrsRtmpConn()
|
|||
srs_freep(refer);
|
||||
srs_freep(bandwidth);
|
||||
srs_freep(security);
|
||||
srs_freep(kbps);
|
||||
}
|
||||
|
||||
void SrsRtmpConn::dispose()
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ private:
|
|||
// for live play duration, for instance, rtmpdump to record.
|
||||
// @see https://github.com/ossrs/srs/issues/47
|
||||
int64_t duration;
|
||||
SrsKbps* kbps;
|
||||
// the MR(merged-write) sleep time in ms.
|
||||
int mw_sleep;
|
||||
// the MR(merged-write) only enabled for play.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ SrsStatisticVhost::SrsStatisticVhost()
|
|||
{
|
||||
id = srs_generate_id();
|
||||
|
||||
kbps = new SrsKbps(new SrsWallClock());
|
||||
clk = new SrsWallClock();
|
||||
kbps = new SrsKbps(clk);
|
||||
kbps->set_io(NULL, NULL);
|
||||
|
||||
nb_clients = 0;
|
||||
|
|
@ -59,6 +60,7 @@ SrsStatisticVhost::SrsStatisticVhost()
|
|||
SrsStatisticVhost::~SrsStatisticVhost()
|
||||
{
|
||||
srs_freep(kbps);
|
||||
srs_freep(clk);
|
||||
}
|
||||
|
||||
srs_error_t SrsStatisticVhost::dumps(SrsJsonObject* obj)
|
||||
|
|
@ -114,7 +116,8 @@ SrsStatisticStream::SrsStatisticStream()
|
|||
width = 0;
|
||||
height = 0;
|
||||
|
||||
kbps = new SrsKbps(new SrsWallClock());
|
||||
clk = new SrsWallClock();
|
||||
kbps = new SrsKbps(clk);
|
||||
kbps->set_io(NULL, NULL);
|
||||
|
||||
nb_clients = 0;
|
||||
|
|
@ -124,6 +127,7 @@ SrsStatisticStream::SrsStatisticStream()
|
|||
SrsStatisticStream::~SrsStatisticStream()
|
||||
{
|
||||
srs_freep(kbps);
|
||||
srs_freep(clk);
|
||||
}
|
||||
|
||||
srs_error_t SrsStatisticStream::dumps(SrsJsonObject* obj)
|
||||
|
|
@ -236,13 +240,15 @@ SrsStatistic::SrsStatistic()
|
|||
{
|
||||
_server_id = srs_generate_id();
|
||||
|
||||
kbps = new SrsKbps(new SrsWallClock());
|
||||
clk = new SrsWallClock();
|
||||
kbps = new SrsKbps(clk);
|
||||
kbps->set_io(NULL, NULL);
|
||||
}
|
||||
|
||||
SrsStatistic::~SrsStatistic()
|
||||
{
|
||||
srs_freep(kbps);
|
||||
srs_freep(clk);
|
||||
|
||||
if (true) {
|
||||
std::map<int64_t, SrsStatisticVhost*>::iterator it;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <srs_rtmp_stack.hpp>
|
||||
|
||||
class SrsKbps;
|
||||
class SrsWallClock;
|
||||
class SrsRequest;
|
||||
class SrsConnection;
|
||||
class SrsJsonObject;
|
||||
|
|
@ -51,6 +52,7 @@ public:
|
|||
* vhost total kbps.
|
||||
*/
|
||||
SrsKbps* kbps;
|
||||
SrsWallClock* clk;
|
||||
public:
|
||||
SrsStatisticVhost();
|
||||
virtual ~SrsStatisticVhost();
|
||||
|
|
@ -75,6 +77,7 @@ public:
|
|||
* stream total kbps.
|
||||
*/
|
||||
SrsKbps* kbps;
|
||||
SrsWallClock* clk;
|
||||
public:
|
||||
bool has_video;
|
||||
SrsVideoCodecId vcodec;
|
||||
|
|
@ -152,6 +155,7 @@ private:
|
|||
std::map<int, SrsStatisticClient*> clients;
|
||||
// server total kbps.
|
||||
SrsKbps* kbps;
|
||||
SrsWallClock* clk;
|
||||
private:
|
||||
SrsStatistic();
|
||||
virtual ~SrsStatistic();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue