mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refactor ISrsKbpsDelta
This commit is contained in:
parent
dcebf8a31f
commit
6234905532
13 changed files with 146 additions and 159 deletions
|
@ -58,24 +58,9 @@ SrsConnection::~SrsConnection()
|
|||
srs_close_stfd(stfd);
|
||||
}
|
||||
|
||||
void SrsConnection::resample()
|
||||
void SrsConnection::remark(int64_t* in, int64_t* out)
|
||||
{
|
||||
kbps->resample();
|
||||
}
|
||||
|
||||
int64_t SrsConnection::get_send_bytes_delta()
|
||||
{
|
||||
return kbps->get_send_bytes_delta();
|
||||
}
|
||||
|
||||
int64_t SrsConnection::get_recv_bytes_delta()
|
||||
{
|
||||
return kbps->get_recv_bytes_delta();
|
||||
}
|
||||
|
||||
void SrsConnection::cleanup()
|
||||
{
|
||||
kbps->cleanup();
|
||||
kbps->remark(in, out);
|
||||
}
|
||||
|
||||
void SrsConnection::dispose()
|
||||
|
|
|
@ -42,7 +42,7 @@ class SrsWallClock;
|
|||
* server will add the connection to manager, and delete it when remove.
|
||||
*/
|
||||
class SrsConnection : virtual public ISrsConnection, virtual public ISrsCoroutineHandler
|
||||
, virtual public IKbpsDelta, virtual public ISrsReloadHandler
|
||||
, virtual public ISrsKbpsDelta, virtual public ISrsReloadHandler
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
|
@ -82,12 +82,9 @@ protected:
|
|||
public:
|
||||
SrsConnection(IConnectionManager* cm, srs_netfd_t c, std::string cip);
|
||||
virtual ~SrsConnection();
|
||||
// interface IKbpsDelta
|
||||
// interface ISrsKbpsDelta
|
||||
public:
|
||||
virtual void resample();
|
||||
virtual int64_t get_send_bytes_delta();
|
||||
virtual int64_t get_recv_bytes_delta();
|
||||
virtual void cleanup();
|
||||
virtual void remark(int64_t* in, int64_t* out);
|
||||
public:
|
||||
/**
|
||||
* to dipose the connection.
|
||||
|
|
|
@ -1336,24 +1336,7 @@ SrsHttpApi::~SrsHttpApi()
|
|||
_srs_config->unsubscribe(this);
|
||||
}
|
||||
|
||||
void SrsHttpApi::resample()
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
}
|
||||
|
||||
int64_t SrsHttpApi::get_send_bytes_delta()
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t SrsHttpApi::get_recv_bytes_delta()
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SrsHttpApi::cleanup()
|
||||
void SrsHttpApi::remark(int64_t* in, int64_t* out)
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
}
|
||||
|
|
|
@ -219,12 +219,9 @@ private:
|
|||
public:
|
||||
SrsHttpApi(IConnectionManager* cm, srs_netfd_t fd, SrsHttpServeMux* m, std::string cip);
|
||||
virtual ~SrsHttpApi();
|
||||
// interface IKbpsDelta
|
||||
// interface ISrsKbpsDelta
|
||||
public:
|
||||
virtual void resample();
|
||||
virtual int64_t get_send_bytes_delta();
|
||||
virtual int64_t get_recv_bytes_delta();
|
||||
virtual void cleanup();
|
||||
virtual void remark(int64_t* in, int64_t* out);
|
||||
protected:
|
||||
virtual srs_error_t do_cycle();
|
||||
private:
|
||||
|
|
|
@ -72,24 +72,7 @@ SrsHttpConn::~SrsHttpConn()
|
|||
srs_freep(cors);
|
||||
}
|
||||
|
||||
void SrsHttpConn::resample()
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
}
|
||||
|
||||
int64_t SrsHttpConn::get_send_bytes_delta()
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t SrsHttpConn::get_recv_bytes_delta()
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SrsHttpConn::cleanup()
|
||||
void SrsHttpConn::remark(int64_t* in, int64_t* out)
|
||||
{
|
||||
// TODO: FIXME: implements it
|
||||
}
|
||||
|
|
|
@ -67,12 +67,9 @@ protected:
|
|||
public:
|
||||
SrsHttpConn(IConnectionManager* cm, srs_netfd_t fd, ISrsHttpServeMux* m, std::string cip);
|
||||
virtual ~SrsHttpConn();
|
||||
// interface IKbpsDelta
|
||||
// interface ISrsKbpsDelta
|
||||
public:
|
||||
virtual void resample();
|
||||
virtual int64_t get_send_bytes_delta();
|
||||
virtual int64_t get_recv_bytes_delta();
|
||||
virtual void cleanup();
|
||||
virtual void remark(int64_t* in, int64_t* out);
|
||||
protected:
|
||||
virtual srs_error_t do_cycle();
|
||||
protected:
|
||||
|
|
|
@ -334,24 +334,9 @@ srs_error_t SrsRtmpConn::on_reload_vhost_publish(string vhost)
|
|||
return err;
|
||||
}
|
||||
|
||||
void SrsRtmpConn::resample()
|
||||
void SrsRtmpConn::remark(int64_t* in, int64_t* out)
|
||||
{
|
||||
kbps->resample();
|
||||
}
|
||||
|
||||
int64_t SrsRtmpConn::get_send_bytes_delta()
|
||||
{
|
||||
return kbps->get_send_bytes_delta();
|
||||
}
|
||||
|
||||
int64_t SrsRtmpConn::get_recv_bytes_delta()
|
||||
{
|
||||
return kbps->get_recv_bytes_delta();
|
||||
}
|
||||
|
||||
void SrsRtmpConn::cleanup()
|
||||
{
|
||||
kbps->cleanup();
|
||||
kbps->remark(in, out);
|
||||
}
|
||||
|
||||
srs_error_t SrsRtmpConn::service_cycle()
|
||||
|
|
|
@ -140,12 +140,9 @@ public:
|
|||
virtual srs_error_t on_reload_vhost_tcp_nodelay(std::string vhost);
|
||||
virtual srs_error_t on_reload_vhost_realtime(std::string vhost);
|
||||
virtual srs_error_t on_reload_vhost_publish(std::string vhost);
|
||||
// interface IKbpsDelta
|
||||
// interface ISrsKbpsDelta
|
||||
public:
|
||||
virtual void resample();
|
||||
virtual int64_t get_send_bytes_delta();
|
||||
virtual int64_t get_recv_bytes_delta();
|
||||
virtual void cleanup();
|
||||
virtual void remark(int64_t* in, int64_t* out);
|
||||
private:
|
||||
// when valid and connected to vhost/app, service the client.
|
||||
virtual srs_error_t service_cycle();
|
||||
|
|
|
@ -459,16 +459,14 @@ void SrsStatistic::kbps_add_delta(SrsConnection* conn)
|
|||
SrsStatisticClient* client = clients[id];
|
||||
|
||||
// resample the kbps to collect the delta.
|
||||
conn->resample();
|
||||
int64_t in, out;
|
||||
conn->remark(&in, &out);
|
||||
|
||||
// add delta of connection to kbps.
|
||||
// for next sample() of server kbps can get the stat.
|
||||
kbps->add_delta(conn);
|
||||
client->stream->kbps->add_delta(conn);
|
||||
client->stream->vhost->kbps->add_delta(conn);
|
||||
|
||||
// cleanup the delta.
|
||||
conn->cleanup();
|
||||
kbps->add_delta(in, out);
|
||||
client->stream->kbps->add_delta(in, out);
|
||||
client->stream->vhost->kbps->add_delta(in, out);
|
||||
}
|
||||
|
||||
SrsKbps* SrsStatistic::kbps_sample()
|
||||
|
|
|
@ -212,7 +212,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.
|
||||
// TODO: FIXME: the add delta must use ISrsKbpsDelta interface instead.
|
||||
virtual void kbps_add_delta(SrsConnection* conn);
|
||||
/**
|
||||
* calc the result for all kbps.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue