mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add srs bytes and kbps to api summaries. 0.9.126
This commit is contained in:
parent
8fabd5d987
commit
6ee2ba049b
17 changed files with 325 additions and 36 deletions
|
@ -240,6 +240,7 @@ Supported operating systems and hardware:
|
||||||
* 2013-10-17, Created.<br/>
|
* 2013-10-17, Created.<br/>
|
||||||
|
|
||||||
## History
|
## History
|
||||||
|
* v1.0, 2014-06-19, add srs bytes and kbps to api summaries. 0.9.126
|
||||||
* v1.0, 2014-06-18, add network bytes to api summaries. 0.9.125
|
* v1.0, 2014-06-18, add network bytes to api summaries. 0.9.125
|
||||||
* v1.0, 2014-06-14, fix [#98](https://github.com/winlinvip/simple-rtmp-server/issues/98), workaround for librtmp ping(fmt=1,cid=2 fresh stream). 0.9.124
|
* v1.0, 2014-06-14, fix [#98](https://github.com/winlinvip/simple-rtmp-server/issues/98), workaround for librtmp ping(fmt=1,cid=2 fresh stream). 0.9.124
|
||||||
* v1.0, 2014-05-29, support flv inject and flv http streaming with start=bytes. 0.9.122
|
* v1.0, 2014-05-29, support flv inject and flv http streaming with start=bytes. 0.9.122
|
||||||
|
|
|
@ -34,9 +34,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_app_st.hpp>
|
#include <srs_app_st.hpp>
|
||||||
#include <srs_app_thread.hpp>
|
#include <srs_app_thread.hpp>
|
||||||
|
#include <srs_app_kbps.hpp>
|
||||||
|
|
||||||
class SrsServer;
|
class SrsServer;
|
||||||
class SrsConnection : public ISrsThreadHandler
|
class SrsConnection : public virtual ISrsThreadHandler, public virtual IKbpsDelta
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsThread* pthread;
|
SrsThread* pthread;
|
||||||
|
@ -52,6 +53,8 @@ public:
|
||||||
virtual int start();
|
virtual int start();
|
||||||
virtual int cycle();
|
virtual int cycle();
|
||||||
virtual void on_thread_stop();
|
virtual void on_thread_stop();
|
||||||
|
public:
|
||||||
|
virtual void kbps_resample() = 0;
|
||||||
protected:
|
protected:
|
||||||
virtual int do_cycle() = 0;
|
virtual int do_cycle() = 0;
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
|
|
@ -182,8 +182,8 @@ int SrsEdgeIngester::ingest()
|
||||||
srs_trace("<- "SRS_LOG_ID_EDGE_PLAY
|
srs_trace("<- "SRS_LOG_ID_EDGE_PLAY
|
||||||
" time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
" time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
||||||
pithy_print.age(),
|
pithy_print.age(),
|
||||||
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
|
kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
||||||
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_kbps_sample_medium());
|
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m());
|
||||||
}
|
}
|
||||||
|
|
||||||
// read from client.
|
// read from client.
|
||||||
|
@ -479,8 +479,8 @@ int SrsEdgeForwarder::cycle()
|
||||||
srs_trace("-> "SRS_LOG_ID_EDGE_PUBLISH
|
srs_trace("-> "SRS_LOG_ID_EDGE_PUBLISH
|
||||||
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
||||||
pithy_print.age(), count,
|
pithy_print.age(), count,
|
||||||
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
|
kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
||||||
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_kbps_sample_medium());
|
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore when no messages.
|
// ignore when no messages.
|
||||||
|
|
|
@ -351,8 +351,8 @@ int SrsForwarder::forward()
|
||||||
srs_trace("-> "SRS_LOG_ID_FOWARDER
|
srs_trace("-> "SRS_LOG_ID_FOWARDER
|
||||||
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
||||||
pithy_print.age(), count,
|
pithy_print.age(), count,
|
||||||
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
|
kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
||||||
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_kbps_sample_medium());
|
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore when no messages.
|
// ignore when no messages.
|
||||||
|
|
|
@ -390,6 +390,7 @@ int SrsApiSummaries::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
|
||||||
SrsMemInfo* m = srs_get_meminfo();
|
SrsMemInfo* m = srs_get_meminfo();
|
||||||
SrsPlatformInfo* p = srs_get_platform_info();
|
SrsPlatformInfo* p = srs_get_platform_info();
|
||||||
SrsNetworkDevices* n = srs_get_network_devices();
|
SrsNetworkDevices* n = srs_get_network_devices();
|
||||||
|
SrsNetworkRtmpServer* nrs = srs_get_network_rtmp_server();
|
||||||
|
|
||||||
float self_mem_percent = 0;
|
float self_mem_percent = 0;
|
||||||
if (m->MemTotal > 0) {
|
if (m->MemTotal > 0) {
|
||||||
|
@ -429,6 +430,7 @@ int SrsApiSummaries::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
|
||||||
<< JFIELD_ORG("meminfo_ok", (m->ok? "true":"false")) << JFIELD_CONT
|
<< JFIELD_ORG("meminfo_ok", (m->ok? "true":"false")) << JFIELD_CONT
|
||||||
<< JFIELD_ORG("platform_ok", (p->ok? "true":"false")) << JFIELD_CONT
|
<< JFIELD_ORG("platform_ok", (p->ok? "true":"false")) << JFIELD_CONT
|
||||||
<< JFIELD_ORG("network_ok", (n_ok? "true":"false")) << JFIELD_CONT
|
<< JFIELD_ORG("network_ok", (n_ok? "true":"false")) << JFIELD_CONT
|
||||||
|
<< JFIELD_ORG("network_srs_ok", (nrs->ok? "true":"false")) << JFIELD_CONT
|
||||||
<< JFIELD_ORG("now_ms", now) << JFIELD_CONT
|
<< JFIELD_ORG("now_ms", now) << JFIELD_CONT
|
||||||
<< JFIELD_ORG("self", JOBJECT_START)
|
<< JFIELD_ORG("self", JOBJECT_START)
|
||||||
<< JFIELD_ORG("pid", getpid()) << JFIELD_CONT
|
<< JFIELD_ORG("pid", getpid()) << JFIELD_CONT
|
||||||
|
@ -455,7 +457,12 @@ int SrsApiSummaries::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
|
||||||
<< JFIELD_ORG("load_15m", p->load_fifteen_minutes) << JFIELD_CONT
|
<< JFIELD_ORG("load_15m", p->load_fifteen_minutes) << JFIELD_CONT
|
||||||
<< JFIELD_ORG("net_sample_time", n_sample_time) << JFIELD_CONT
|
<< JFIELD_ORG("net_sample_time", n_sample_time) << JFIELD_CONT
|
||||||
<< JFIELD_ORG("net_recv_bytes", nr_bytes) << JFIELD_CONT
|
<< JFIELD_ORG("net_recv_bytes", nr_bytes) << JFIELD_CONT
|
||||||
<< JFIELD_ORG("net_send_bytes", ns_bytes)
|
<< JFIELD_ORG("net_send_bytes", ns_bytes) << JFIELD_CONT
|
||||||
|
<< JFIELD_ORG("srs_sample_time", nrs->sample_time) << JFIELD_CONT
|
||||||
|
<< JFIELD_ORG("srs_recv_bytes", nrs->rbytes) << JFIELD_CONT
|
||||||
|
<< JFIELD_ORG("srs_recv_kbps", nrs->rkbps) << JFIELD_CONT
|
||||||
|
<< JFIELD_ORG("srs_send_bytes", nrs->sbytes) << JFIELD_CONT
|
||||||
|
<< JFIELD_ORG("srs_send_kbps", nrs->skbps)
|
||||||
<< JOBJECT_END
|
<< JOBJECT_END
|
||||||
<< JOBJECT_END
|
<< JOBJECT_END
|
||||||
<< JOBJECT_END;
|
<< JOBJECT_END;
|
||||||
|
@ -707,6 +714,23 @@ SrsHttpApi::~SrsHttpApi()
|
||||||
srs_freep(parser);
|
srs_freep(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsHttpApi::kbps_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;
|
||||||
|
}
|
||||||
|
|
||||||
int SrsHttpApi::do_cycle()
|
int SrsHttpApi::do_cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
|
@ -196,6 +196,12 @@ private:
|
||||||
public:
|
public:
|
||||||
SrsHttpApi(SrsServer* srs_server, st_netfd_t client_stfd, SrsHttpHandler* _handler);
|
SrsHttpApi(SrsServer* srs_server, st_netfd_t client_stfd, SrsHttpHandler* _handler);
|
||||||
virtual ~SrsHttpApi();
|
virtual ~SrsHttpApi();
|
||||||
|
public:
|
||||||
|
virtual void kbps_resample();
|
||||||
|
// interface IKbpsDelta
|
||||||
|
public:
|
||||||
|
virtual int64_t get_send_bytes_delta();
|
||||||
|
virtual int64_t get_recv_bytes_delta();
|
||||||
protected:
|
protected:
|
||||||
virtual int do_cycle();
|
virtual int do_cycle();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -511,6 +511,23 @@ SrsHttpConn::~SrsHttpConn()
|
||||||
srs_freep(parser);
|
srs_freep(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsHttpConn::kbps_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;
|
||||||
|
}
|
||||||
|
|
||||||
int SrsHttpConn::do_cycle()
|
int SrsHttpConn::do_cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
|
@ -90,6 +90,12 @@ private:
|
||||||
public:
|
public:
|
||||||
SrsHttpConn(SrsServer* srs_server, st_netfd_t client_stfd, SrsHttpHandler* _handler);
|
SrsHttpConn(SrsServer* srs_server, st_netfd_t client_stfd, SrsHttpHandler* _handler);
|
||||||
virtual ~SrsHttpConn();
|
virtual ~SrsHttpConn();
|
||||||
|
public:
|
||||||
|
virtual void kbps_resample();
|
||||||
|
// interface IKbpsDelta
|
||||||
|
public:
|
||||||
|
virtual int64_t get_send_bytes_delta();
|
||||||
|
virtual int64_t get_recv_bytes_delta();
|
||||||
protected:
|
protected:
|
||||||
virtual int do_cycle();
|
virtual int do_cycle();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -38,7 +38,7 @@ SrsKbpsSlice::SrsKbpsSlice()
|
||||||
{
|
{
|
||||||
io.in = NULL;
|
io.in = NULL;
|
||||||
io.out = NULL;
|
io.out = NULL;
|
||||||
last_bytes = io_bytes_base = starttime = bytes = 0;
|
last_bytes = io_bytes_base = starttime = bytes = delta_bytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsKbpsSlice::~SrsKbpsSlice()
|
SrsKbpsSlice::~SrsKbpsSlice()
|
||||||
|
@ -98,6 +98,14 @@ void SrsKbpsSlice::sample()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IKbpsDelta::IKbpsDelta()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IKbpsDelta::~IKbpsDelta()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SrsKbps::SrsKbps()
|
SrsKbps::SrsKbps()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -165,22 +173,22 @@ int SrsKbps::get_recv_kbps()
|
||||||
return bytes * 8 / duration;
|
return bytes * 8 / duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsKbps::get_send_kbps_sample_high()
|
int SrsKbps::get_send_kbps_30s()
|
||||||
{
|
{
|
||||||
return os.sample_30s.kbps;
|
return os.sample_30s.kbps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsKbps::get_recv_kbps_sample_high()
|
int SrsKbps::get_recv_kbps_30s()
|
||||||
{
|
{
|
||||||
return is.sample_30s.kbps;
|
return is.sample_30s.kbps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsKbps::get_send_kbps_sample_medium()
|
int SrsKbps::get_send_kbps_5m()
|
||||||
{
|
{
|
||||||
return os.sample_5m.kbps;
|
return os.sample_5m.kbps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsKbps::get_recv_kbps_sample_medium()
|
int SrsKbps::get_recv_kbps_5m()
|
||||||
{
|
{
|
||||||
return is.sample_5m.kbps;
|
return is.sample_5m.kbps;
|
||||||
}
|
}
|
||||||
|
@ -195,20 +203,44 @@ int64_t SrsKbps::get_recv_bytes()
|
||||||
return is.get_total_bytes();
|
return is.get_total_bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t SrsKbps::get_send_bytes_delta()
|
||||||
|
{
|
||||||
|
int64_t delta = os.get_total_bytes() - os.delta_bytes;
|
||||||
|
os.delta_bytes = os.get_total_bytes();
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t SrsKbps::get_recv_bytes_delta()
|
||||||
|
{
|
||||||
|
int64_t delta = is.get_total_bytes() - is.delta_bytes;
|
||||||
|
is.delta_bytes = is.get_total_bytes();
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsKbps::add_delta(IKbpsDelta* delta)
|
||||||
|
{
|
||||||
|
srs_assert(delta);
|
||||||
|
|
||||||
|
// update the total bytes
|
||||||
|
is.last_bytes += delta->get_recv_bytes_delta();
|
||||||
|
os.last_bytes += delta->get_send_bytes_delta();
|
||||||
|
|
||||||
|
// we donot sample, please use sample() to do resample.
|
||||||
|
}
|
||||||
|
|
||||||
void SrsKbps::sample()
|
void SrsKbps::sample()
|
||||||
{
|
{
|
||||||
|
// update the total bytes
|
||||||
if (os.io.out) {
|
if (os.io.out) {
|
||||||
os.last_bytes = os.io.out->get_send_bytes();
|
os.last_bytes = os.io.out->get_send_bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// resample
|
|
||||||
os.sample();
|
|
||||||
|
|
||||||
if (is.io.in) {
|
if (is.io.in) {
|
||||||
is.last_bytes = is.io.in->get_recv_bytes();
|
is.last_bytes = is.io.in->get_recv_bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// resample
|
// resample
|
||||||
is.sample();
|
is.sample();
|
||||||
|
os.sample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_core.hpp>
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
class ISrsProtocolStatistic;
|
#include <srs_protocol_io.hpp>
|
||||||
class ISrsProtocolStatistic;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a kbps sample, for example, 1minute kbps,
|
* a kbps sample, for example, 1minute kbps,
|
||||||
|
@ -59,7 +58,8 @@ public:
|
||||||
* send_bytes = bytes + last_bytes - io_bytes_base
|
* send_bytes = bytes + last_bytes - io_bytes_base
|
||||||
* so, the bytes sent duration current session is:
|
* so, the bytes sent duration current session is:
|
||||||
* send_bytes = last_bytes - io_bytes_base
|
* send_bytes = last_bytes - io_bytes_base
|
||||||
* @remark user use set_io to start new session.
|
* @remark use set_io to start new session.
|
||||||
|
* @remakr the slice is a data collection object driven by SrsKbps.
|
||||||
*/
|
*/
|
||||||
class SrsKbpsSlice
|
class SrsKbpsSlice
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,8 @@ private:
|
||||||
ISrsProtocolStatistic* out;
|
ISrsProtocolStatistic* out;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
|
// the slice io used for SrsKbps to invoke,
|
||||||
|
// the SrsKbpsSlice itself never use it.
|
||||||
slice_io io;
|
slice_io io;
|
||||||
// session startup bytes
|
// session startup bytes
|
||||||
// @remark, use total_bytes() to get the total bytes of slice.
|
// @remark, use total_bytes() to get the total bytes of slice.
|
||||||
|
@ -86,6 +88,9 @@ public:
|
||||||
SrsKbpsSample sample_1m;
|
SrsKbpsSample sample_1m;
|
||||||
SrsKbpsSample sample_5m;
|
SrsKbpsSample sample_5m;
|
||||||
SrsKbpsSample sample_60m;
|
SrsKbpsSample sample_60m;
|
||||||
|
public:
|
||||||
|
// for the delta bytes.
|
||||||
|
int64_t delta_bytes;
|
||||||
public:
|
public:
|
||||||
SrsKbpsSlice();
|
SrsKbpsSlice();
|
||||||
virtual ~SrsKbpsSlice();
|
virtual ~SrsKbpsSlice();
|
||||||
|
@ -101,9 +106,36 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to statistic the kbps of io.
|
* the interface which provices delta of bytes.
|
||||||
*/
|
*/
|
||||||
class SrsKbps
|
class IKbpsDelta
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IKbpsDelta();
|
||||||
|
virtual ~IKbpsDelta();
|
||||||
|
public:
|
||||||
|
virtual int64_t get_send_bytes_delta() = 0;
|
||||||
|
virtual int64_t get_recv_bytes_delta() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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:
|
||||||
|
* set_io(in, out)
|
||||||
|
* sample()
|
||||||
|
* get_xxx_kbps().
|
||||||
|
* the connections know how many bytes already send/recv.
|
||||||
|
* 2. server to calc kbps:
|
||||||
|
* set_io(NULL, NULL)
|
||||||
|
* for each connection in connections:
|
||||||
|
* add_delta(connections) // where connection is a IKbpsDelta*
|
||||||
|
* sample()
|
||||||
|
* get_xxx_kbps().
|
||||||
|
* the server never know how many bytes already send/recv, for the connection maybe closed.
|
||||||
|
*/
|
||||||
|
class SrsKbps : public virtual ISrsProtocolStatistic, public virtual IKbpsDelta
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsKbpsSlice is;
|
SrsKbpsSlice is;
|
||||||
|
@ -130,11 +162,11 @@ public:
|
||||||
virtual int get_send_kbps();
|
virtual int get_send_kbps();
|
||||||
virtual int get_recv_kbps();
|
virtual int get_recv_kbps();
|
||||||
// 30s
|
// 30s
|
||||||
virtual int get_send_kbps_sample_high();
|
virtual int get_send_kbps_30s();
|
||||||
virtual int get_recv_kbps_sample_high();
|
virtual int get_recv_kbps_30s();
|
||||||
// 5m
|
// 5m
|
||||||
virtual int get_send_kbps_sample_medium();
|
virtual int get_send_kbps_5m();
|
||||||
virtual int get_recv_kbps_sample_medium();
|
virtual int get_recv_kbps_5m();
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* get the total send/recv bytes, from the startup of the oldest io.
|
* get the total send/recv bytes, from the startup of the oldest io.
|
||||||
|
@ -142,9 +174,26 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual int64_t get_send_bytes();
|
virtual int64_t get_send_bytes();
|
||||||
virtual int64_t get_recv_bytes();
|
virtual int64_t get_recv_bytes();
|
||||||
|
/**
|
||||||
|
* get the delta of send/recv bytes.
|
||||||
|
* @remark, used for add_delta to calc the total system bytes/kbps.
|
||||||
|
*/
|
||||||
|
virtual int64_t get_send_bytes_delta();
|
||||||
|
virtual int64_t get_recv_bytes_delta();
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* resample all samples.
|
* add delta to kbps clac mechenism.
|
||||||
|
* we donot know the total bytes, but know the delta, for instance,
|
||||||
|
* for rtmp server to calc total bytes and kbps.
|
||||||
|
* @remark user must invoke sample() when invoke this method.
|
||||||
|
* @param delta, assert should never be NULL.
|
||||||
|
*/
|
||||||
|
virtual void add_delta(IKbpsDelta* delta);
|
||||||
|
/**
|
||||||
|
* resample all samples, ignore if in/out is NULL.
|
||||||
|
* used for user to calc the kbps, to sample new kbps value.
|
||||||
|
* @remark if user, for instance, the rtmp server to calc the total bytes,
|
||||||
|
* use the add_delta() is better solutions.
|
||||||
*/
|
*/
|
||||||
virtual void sample();
|
virtual void sample();
|
||||||
};
|
};
|
||||||
|
|
|
@ -94,6 +94,11 @@ SrsRtmpConn::~SrsRtmpConn()
|
||||||
srs_freep(kbps);
|
srs_freep(kbps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtmpConn::kbps_resample()
|
||||||
|
{
|
||||||
|
kbps->sample();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: return detail message when error for client.
|
// TODO: return detail message when error for client.
|
||||||
int SrsRtmpConn::do_cycle()
|
int SrsRtmpConn::do_cycle()
|
||||||
{
|
{
|
||||||
|
@ -169,6 +174,16 @@ int SrsRtmpConn::on_reload_vhost_removed(string vhost)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
int SrsRtmpConn::service_cycle()
|
int SrsRtmpConn::service_cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
@ -510,8 +525,8 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
srs_trace("-> "SRS_LOG_ID_PLAY
|
srs_trace("-> "SRS_LOG_ID_PLAY
|
||||||
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
||||||
pithy_print.age(), count,
|
pithy_print.age(), count,
|
||||||
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
|
kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
||||||
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_kbps_sample_medium());
|
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
|
@ -601,8 +616,8 @@ int SrsRtmpConn::fmle_publish(SrsSource* source)
|
||||||
kbps->sample();
|
kbps->sample();
|
||||||
srs_trace("<- "SRS_LOG_ID_CLIENT_PUBLISH
|
srs_trace("<- "SRS_LOG_ID_CLIENT_PUBLISH
|
||||||
" time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d", pithy_print.age(),
|
" time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d", pithy_print.age(),
|
||||||
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
|
kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
||||||
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_kbps_sample_medium());
|
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m());
|
||||||
}
|
}
|
||||||
|
|
||||||
// process UnPublish event.
|
// process UnPublish event.
|
||||||
|
@ -683,8 +698,8 @@ int SrsRtmpConn::flash_publish(SrsSource* source)
|
||||||
srs_trace("<- "SRS_LOG_ID_WEB_PUBLISH
|
srs_trace("<- "SRS_LOG_ID_WEB_PUBLISH
|
||||||
" time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
" time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d",
|
||||||
pithy_print.age(),
|
pithy_print.age(),
|
||||||
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
|
kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
||||||
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_kbps_sample_medium());
|
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m());
|
||||||
}
|
}
|
||||||
|
|
||||||
// process UnPublish event.
|
// process UnPublish event.
|
||||||
|
|
|
@ -51,7 +51,7 @@ class SrsKbps;
|
||||||
/**
|
/**
|
||||||
* the client provides the main logic control for RTMP clients.
|
* the client provides the main logic control for RTMP clients.
|
||||||
*/
|
*/
|
||||||
class SrsRtmpConn : public SrsConnection, public ISrsReloadHandler
|
class SrsRtmpConn : public virtual SrsConnection, public virtual ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsRequest* req;
|
SrsRequest* req;
|
||||||
|
@ -68,11 +68,17 @@ private:
|
||||||
public:
|
public:
|
||||||
SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd);
|
SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd);
|
||||||
virtual ~SrsRtmpConn();
|
virtual ~SrsRtmpConn();
|
||||||
|
public:
|
||||||
|
virtual void kbps_resample();
|
||||||
protected:
|
protected:
|
||||||
virtual int do_cycle();
|
virtual int do_cycle();
|
||||||
// interface ISrsReloadHandler
|
// interface ISrsReloadHandler
|
||||||
public:
|
public:
|
||||||
virtual int on_reload_vhost_removed(std::string vhost);
|
virtual int on_reload_vhost_removed(std::string vhost);
|
||||||
|
// interface IKbpsDelta
|
||||||
|
public:
|
||||||
|
virtual int64_t get_send_bytes_delta();
|
||||||
|
virtual int64_t get_recv_bytes_delta();
|
||||||
private:
|
private:
|
||||||
// when valid and connected to vhost/app, service the client.
|
// when valid and connected to vhost/app, service the client.
|
||||||
virtual int service_cycle();
|
virtual int service_cycle();
|
||||||
|
|
|
@ -45,6 +45,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_app_source.hpp>
|
#include <srs_app_source.hpp>
|
||||||
#include <srs_app_utility.hpp>
|
#include <srs_app_utility.hpp>
|
||||||
#include <srs_app_heartbeat.hpp>
|
#include <srs_app_heartbeat.hpp>
|
||||||
|
#include <srs_app_kbps.hpp>
|
||||||
|
|
||||||
// signal defines.
|
// signal defines.
|
||||||
#define SIGNAL_RELOAD SIGHUP
|
#define SIGNAL_RELOAD SIGHUP
|
||||||
|
@ -82,6 +83,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES
|
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES
|
||||||
#define SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES 90
|
#define SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES 90
|
||||||
|
|
||||||
|
// update network devices info interval:
|
||||||
|
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES
|
||||||
|
#define SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES 90
|
||||||
|
|
||||||
SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
|
SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
|
||||||
{
|
{
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
@ -312,7 +317,8 @@ SrsServer::SrsServer()
|
||||||
signal_gmc_stop = false;
|
signal_gmc_stop = false;
|
||||||
pid_fd = -1;
|
pid_fd = -1;
|
||||||
|
|
||||||
signal_manager = new SrsSignalManager(this);
|
signal_manager = NULL;
|
||||||
|
kbps = NULL;
|
||||||
|
|
||||||
// donot new object in constructor,
|
// donot new object in constructor,
|
||||||
// for some global instance is not ready now,
|
// for some global instance is not ready now,
|
||||||
|
@ -372,6 +378,7 @@ void SrsServer::destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_freep(signal_manager);
|
srs_freep(signal_manager);
|
||||||
|
srs_freep(kbps);
|
||||||
|
|
||||||
for (std::vector<SrsConnection*>::iterator it = conns.begin(); it != conns.end();) {
|
for (std::vector<SrsConnection*>::iterator it = conns.begin(); it != conns.end();) {
|
||||||
SrsConnection* conn = *it;
|
SrsConnection* conn = *it;
|
||||||
|
@ -398,6 +405,13 @@ int SrsServer::initialize()
|
||||||
srs_assert(_srs_config);
|
srs_assert(_srs_config);
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
|
|
||||||
|
srs_assert(!signal_manager);
|
||||||
|
signal_manager = new SrsSignalManager(this);
|
||||||
|
|
||||||
|
srs_assert(!kbps);
|
||||||
|
kbps = new SrsKbps();
|
||||||
|
kbps->set_io(NULL, NULL);
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HTTP_API
|
#ifdef SRS_AUTO_HTTP_API
|
||||||
srs_assert(!http_api_handler);
|
srs_assert(!http_api_handler);
|
||||||
http_api_handler = SrsHttpHandler::create_http_api();
|
http_api_handler = SrsHttpHandler::create_http_api();
|
||||||
|
@ -610,6 +624,9 @@ void SrsServer::remove(SrsConnection* conn)
|
||||||
|
|
||||||
srs_info("conn removed. conns=%d", (int)conns.size());
|
srs_info("conn removed. conns=%d", (int)conns.size());
|
||||||
|
|
||||||
|
// resample the resource of specified connection.
|
||||||
|
resample_kbps(conn);
|
||||||
|
|
||||||
// all connections are created by server,
|
// all connections are created by server,
|
||||||
// so we free it here.
|
// so we free it here.
|
||||||
srs_freep(conn);
|
srs_freep(conn);
|
||||||
|
@ -651,11 +668,12 @@ int SrsServer::do_cycle()
|
||||||
max = srs_max(max, SRS_SYS_MEMINFO_RESOLUTION_TIMES);
|
max = srs_max(max, SRS_SYS_MEMINFO_RESOLUTION_TIMES);
|
||||||
max = srs_max(max, SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES);
|
max = srs_max(max, SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES);
|
||||||
max = srs_max(max, SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES);
|
max = srs_max(max, SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES);
|
||||||
|
max = srs_max(max, SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES);
|
||||||
|
|
||||||
// the deamon thread, update the time cache
|
// the deamon thread, update the time cache
|
||||||
while (true) {
|
while (true) {
|
||||||
// the interval in config.
|
// the interval in config.
|
||||||
int64_t heartbeat_max_resolution = _srs_config->get_heartbeat_interval() / 100;
|
int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() / 100);
|
||||||
|
|
||||||
// dynamic fetch the max.
|
// dynamic fetch the max.
|
||||||
int __max = max;
|
int __max = max;
|
||||||
|
@ -689,30 +707,43 @@ int SrsServer::do_cycle()
|
||||||
|
|
||||||
// update the cache time or rusage.
|
// update the cache time or rusage.
|
||||||
if ((i % SRS_SYS_TIME_RESOLUTION_MS_TIMES) == 0) {
|
if ((i % SRS_SYS_TIME_RESOLUTION_MS_TIMES) == 0) {
|
||||||
|
srs_info("update current time cache.");
|
||||||
srs_update_system_time_ms();
|
srs_update_system_time_ms();
|
||||||
}
|
}
|
||||||
if ((i % SRS_SYS_RUSAGE_RESOLUTION_TIMES) == 0) {
|
if ((i % SRS_SYS_RUSAGE_RESOLUTION_TIMES) == 0) {
|
||||||
|
srs_info("update resource info, rss.");
|
||||||
srs_update_system_rusage();
|
srs_update_system_rusage();
|
||||||
}
|
}
|
||||||
if ((i % SRS_SYS_CPU_STAT_RESOLUTION_TIMES) == 0) {
|
if ((i % SRS_SYS_CPU_STAT_RESOLUTION_TIMES) == 0) {
|
||||||
|
srs_info("update cpu info, usage.");
|
||||||
srs_update_proc_stat();
|
srs_update_proc_stat();
|
||||||
}
|
}
|
||||||
if ((i % SRS_SYS_MEMINFO_RESOLUTION_TIMES) == 0) {
|
if ((i % SRS_SYS_MEMINFO_RESOLUTION_TIMES) == 0) {
|
||||||
|
srs_info("update memory info, usage/free.");
|
||||||
srs_update_meminfo();
|
srs_update_meminfo();
|
||||||
}
|
}
|
||||||
if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) {
|
if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) {
|
||||||
|
srs_info("update platform info, uptime/load.");
|
||||||
srs_update_platform_info();
|
srs_update_platform_info();
|
||||||
}
|
}
|
||||||
if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) {
|
if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) {
|
||||||
|
srs_info("update network devices info.");
|
||||||
srs_update_network_devices();
|
srs_update_network_devices();
|
||||||
}
|
}
|
||||||
|
if ((i % SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES) == 0) {
|
||||||
|
srs_info("update network rtmp server info.");
|
||||||
|
resample_kbps(NULL);
|
||||||
|
srs_update_rtmp_server(kbps);
|
||||||
|
}
|
||||||
#ifdef SRS_AUTO_HTTP_PARSER
|
#ifdef SRS_AUTO_HTTP_PARSER
|
||||||
if (_srs_config->get_heartbeat_enabled()) {
|
if (_srs_config->get_heartbeat_enabled()) {
|
||||||
if ((i % heartbeat_max_resolution) == 0) {
|
if ((i % heartbeat_max_resolution) == 0) {
|
||||||
|
srs_info("do http heartbeat, for internal server to report.");
|
||||||
http_heartbeat->heartbeat();
|
http_heartbeat->heartbeat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
srs_info("server main thread loop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,6 +832,32 @@ void SrsServer::close_listeners(SrsListenerType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsServer::resample_kbps(SrsConnection* conn, bool do_resample)
|
||||||
|
{
|
||||||
|
// resample all when conn is NULL.
|
||||||
|
if (!conn) {
|
||||||
|
for (std::vector<SrsConnection*>::iterator it = conns.begin(); it != conns.end(); ++it) {
|
||||||
|
SrsConnection* client = *it;
|
||||||
|
srs_assert(client);
|
||||||
|
|
||||||
|
// only resample, do resample when all finished.
|
||||||
|
resample_kbps(client, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
kbps->sample();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resample for connection.
|
||||||
|
conn->kbps_resample();
|
||||||
|
|
||||||
|
kbps->add_delta(conn);
|
||||||
|
|
||||||
|
if (do_resample) {
|
||||||
|
kbps->sample();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
|
int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
|
@ -41,6 +41,7 @@ class SrsConnection;
|
||||||
class SrsHttpHandler;
|
class SrsHttpHandler;
|
||||||
class SrsIngester;
|
class SrsIngester;
|
||||||
class SrsHttpHeartbeat;
|
class SrsHttpHeartbeat;
|
||||||
|
class SrsKbps;
|
||||||
|
|
||||||
// listener type for server to identify the connection,
|
// listener type for server to identify the connection,
|
||||||
// that is, use different type to process the connection.
|
// that is, use different type to process the connection.
|
||||||
|
@ -107,6 +108,10 @@ private:
|
||||||
static void sig_catcher(int signo);
|
static void sig_catcher(int signo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SRS RTMP server, initialize and listen,
|
||||||
|
* start connection service thread, destroy client.
|
||||||
|
*/
|
||||||
class SrsServer : public ISrsReloadHandler
|
class SrsServer : public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -127,6 +132,7 @@ private:
|
||||||
std::vector<SrsConnection*> conns;
|
std::vector<SrsConnection*> conns;
|
||||||
std::vector<SrsListener*> listeners;
|
std::vector<SrsListener*> listeners;
|
||||||
SrsSignalManager* signal_manager;
|
SrsSignalManager* signal_manager;
|
||||||
|
SrsKbps* kbps;
|
||||||
bool signal_reload;
|
bool signal_reload;
|
||||||
bool signal_gmc_stop;
|
bool signal_gmc_stop;
|
||||||
public:
|
public:
|
||||||
|
@ -150,6 +156,8 @@ private:
|
||||||
virtual int listen_http_api();
|
virtual int listen_http_api();
|
||||||
virtual int listen_http_stream();
|
virtual int listen_http_stream();
|
||||||
virtual void close_listeners(SrsListenerType type);
|
virtual void close_listeners(SrsListenerType type);
|
||||||
|
// resample the server kbps. resample all when conn is NULL.
|
||||||
|
virtual void resample_kbps(SrsConnection* conn, bool do_resample = true);
|
||||||
// internal only
|
// internal only
|
||||||
public:
|
public:
|
||||||
virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd);
|
virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd);
|
||||||
|
|
|
@ -34,6 +34,7 @@ using namespace std;
|
||||||
#include <srs_app_config.hpp>
|
#include <srs_app_config.hpp>
|
||||||
#include <srs_kernel_utility.hpp>
|
#include <srs_kernel_utility.hpp>
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
|
#include <srs_app_kbps.hpp>
|
||||||
|
|
||||||
#define SRS_LOCAL_LOOP_IP "127.0.0.1"
|
#define SRS_LOCAL_LOOP_IP "127.0.0.1"
|
||||||
|
|
||||||
|
@ -523,6 +524,38 @@ void srs_update_network_devices()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsNetworkRtmpServer::SrsNetworkRtmpServer()
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
sample_time = rbytes = sbytes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SrsNetworkRtmpServer _srs_network_rtmp_server;
|
||||||
|
|
||||||
|
SrsNetworkRtmpServer* srs_get_network_rtmp_server()
|
||||||
|
{
|
||||||
|
return &_srs_network_rtmp_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
void srs_update_rtmp_server(SrsKbps* kbps)
|
||||||
|
{
|
||||||
|
SrsNetworkRtmpServer& r = _srs_network_rtmp_server;
|
||||||
|
|
||||||
|
r.ok = true;
|
||||||
|
|
||||||
|
r.sample_time = srs_get_system_time_ms();
|
||||||
|
|
||||||
|
r.rbytes = kbps->get_recv_bytes();
|
||||||
|
r.rkbps = kbps->get_recv_kbps();
|
||||||
|
r.rkbps_30s = kbps->get_recv_kbps_30s();
|
||||||
|
r.rkbps_5m = kbps->get_recv_kbps_5m();
|
||||||
|
|
||||||
|
r.sbytes = kbps->get_send_bytes();
|
||||||
|
r.skbps = kbps->get_send_kbps();
|
||||||
|
r.skbps_30s = kbps->get_send_kbps_30s();
|
||||||
|
r.skbps_5m = kbps->get_send_kbps_5m();
|
||||||
|
}
|
||||||
|
|
||||||
vector<string> _srs_system_ipv4_ips;
|
vector<string> _srs_system_ipv4_ips;
|
||||||
|
|
||||||
void retrieve_local_ipv4_ips()
|
void retrieve_local_ipv4_ips()
|
||||||
|
|
|
@ -35,6 +35,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
||||||
|
class SrsKbps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert level in string to log level in int.
|
* convert level in string to log level in int.
|
||||||
* @return the log level defined in SrsLogLevel.
|
* @return the log level defined in SrsLogLevel.
|
||||||
|
@ -390,6 +392,36 @@ extern int srs_get_network_devices_count();
|
||||||
// the deamon st-thread will update it.
|
// the deamon st-thread will update it.
|
||||||
extern void srs_update_network_devices();
|
extern void srs_update_network_devices();
|
||||||
|
|
||||||
|
// srs rtmp network summary
|
||||||
|
class SrsNetworkRtmpServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// whether the network device is ok.
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
// the sample time in ms.
|
||||||
|
int64_t sample_time;
|
||||||
|
|
||||||
|
// data for receive.
|
||||||
|
int64_t rbytes;
|
||||||
|
int rkbps;
|
||||||
|
int rkbps_30s;
|
||||||
|
int rkbps_5m;
|
||||||
|
|
||||||
|
// data for transmit
|
||||||
|
int64_t sbytes;
|
||||||
|
int skbps;
|
||||||
|
int skbps_30s;
|
||||||
|
int skbps_5m;
|
||||||
|
|
||||||
|
SrsNetworkRtmpServer();
|
||||||
|
};
|
||||||
|
|
||||||
|
// get network devices info, use cache to avoid performance problem.
|
||||||
|
extern SrsNetworkRtmpServer* srs_get_network_rtmp_server();
|
||||||
|
// the deamon st-thread will update it.
|
||||||
|
extern void srs_update_rtmp_server(SrsKbps* kbps);
|
||||||
|
|
||||||
// get local ip, fill to @param ips
|
// get local ip, fill to @param ips
|
||||||
extern void srs_retrieve_local_ipv4_ips();
|
extern void srs_retrieve_local_ipv4_ips();
|
||||||
extern std::vector<std::string>& srs_get_local_ipv4_ips();
|
extern std::vector<std::string>& srs_get_local_ipv4_ips();
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR "0"
|
#define VERSION_MAJOR "0"
|
||||||
#define VERSION_MINOR "9"
|
#define VERSION_MINOR "9"
|
||||||
#define VERSION_REVISION "125"
|
#define VERSION_REVISION "126"
|
||||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue