add srs bytes and kbps to api summaries. 0.9.126

pull/133/head
winlin 11 years ago
parent 8fabd5d987
commit 6ee2ba049b

@ -240,6 +240,7 @@ Supported operating systems and hardware:
* 2013-10-17, Created.<br/>
## 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-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

@ -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_thread.hpp>
#include <srs_app_kbps.hpp>
class SrsServer;
class SrsConnection : public ISrsThreadHandler
class SrsConnection : public virtual ISrsThreadHandler, public virtual IKbpsDelta
{
private:
SrsThread* pthread;
@ -52,6 +53,8 @@ public:
virtual int start();
virtual int cycle();
virtual void on_thread_stop();
public:
virtual void kbps_resample() = 0;
protected:
virtual int do_cycle() = 0;
virtual void stop();

@ -182,8 +182,8 @@ int SrsEdgeIngester::ingest()
srs_trace("<- "SRS_LOG_ID_EDGE_PLAY
" 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_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_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_30s(), kbps->get_recv_kbps_5m());
}
// read from client.
@ -479,8 +479,8 @@ int SrsEdgeForwarder::cycle()
srs_trace("-> "SRS_LOG_ID_EDGE_PUBLISH
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
pithy_print.age(), count,
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_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_30s(), kbps->get_recv_kbps_5m());
}
// ignore when no messages.

@ -351,8 +351,8 @@ int SrsForwarder::forward()
srs_trace("-> "SRS_LOG_ID_FOWARDER
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
pithy_print.age(), count,
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_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_30s(), kbps->get_recv_kbps_5m());
}
// ignore when no messages.

@ -390,6 +390,7 @@ int SrsApiSummaries::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
SrsMemInfo* m = srs_get_meminfo();
SrsPlatformInfo* p = srs_get_platform_info();
SrsNetworkDevices* n = srs_get_network_devices();
SrsNetworkRtmpServer* nrs = srs_get_network_rtmp_server();
float self_mem_percent = 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("platform_ok", (p->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("self", JOBJECT_START)
<< 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("net_sample_time", n_sample_time) << 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;
@ -707,6 +714,23 @@ SrsHttpApi::~SrsHttpApi()
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 ret = ERROR_SUCCESS;

@ -196,6 +196,12 @@ private:
public:
SrsHttpApi(SrsServer* srs_server, st_netfd_t client_stfd, SrsHttpHandler* _handler);
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:
virtual int do_cycle();
private:

@ -511,6 +511,23 @@ SrsHttpConn::~SrsHttpConn()
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 ret = ERROR_SUCCESS;

@ -90,6 +90,12 @@ private:
public:
SrsHttpConn(SrsServer* srs_server, st_netfd_t client_stfd, SrsHttpHandler* _handler);
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:
virtual int do_cycle();
private:

@ -38,7 +38,7 @@ SrsKbpsSlice::SrsKbpsSlice()
{
io.in = NULL;
io.out = NULL;
last_bytes = io_bytes_base = starttime = bytes = 0;
last_bytes = io_bytes_base = starttime = bytes = delta_bytes = 0;
}
SrsKbpsSlice::~SrsKbpsSlice()
@ -98,6 +98,14 @@ void SrsKbpsSlice::sample()
}
}
IKbpsDelta::IKbpsDelta()
{
}
IKbpsDelta::~IKbpsDelta()
{
}
SrsKbps::SrsKbps()
{
}
@ -165,22 +173,22 @@ int SrsKbps::get_recv_kbps()
return bytes * 8 / duration;
}
int SrsKbps::get_send_kbps_sample_high()
int SrsKbps::get_send_kbps_30s()
{
return os.sample_30s.kbps;
}
int SrsKbps::get_recv_kbps_sample_high()
int SrsKbps::get_recv_kbps_30s()
{
return is.sample_30s.kbps;
}
int SrsKbps::get_send_kbps_sample_medium()
int SrsKbps::get_send_kbps_5m()
{
return os.sample_5m.kbps;
}
int SrsKbps::get_recv_kbps_sample_medium()
int SrsKbps::get_recv_kbps_5m()
{
return is.sample_5m.kbps;
}
@ -195,20 +203,44 @@ int64_t SrsKbps::get_recv_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()
{
// update the total bytes
if (os.io.out) {
os.last_bytes = os.io.out->get_send_bytes();
}
// resample
os.sample();
if (is.io.in) {
is.last_bytes = is.io.in->get_recv_bytes();
}
// resample
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>
class ISrsProtocolStatistic;
class ISrsProtocolStatistic;
#include <srs_protocol_io.hpp>
/**
* a kbps sample, for example, 1minute kbps,
@ -59,7 +58,8 @@ public:
* send_bytes = bytes + last_bytes - io_bytes_base
* so, the bytes sent duration current session is:
* 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
{
@ -69,6 +69,8 @@ private:
ISrsProtocolStatistic* out;
};
public:
// the slice io used for SrsKbps to invoke,
// the SrsKbpsSlice itself never use it.
slice_io io;
// session startup bytes
// @remark, use total_bytes() to get the total bytes of slice.
@ -86,6 +88,9 @@ public:
SrsKbpsSample sample_1m;
SrsKbpsSample sample_5m;
SrsKbpsSample sample_60m;
public:
// for the delta bytes.
int64_t delta_bytes;
public:
SrsKbpsSlice();
virtual ~SrsKbpsSlice();
@ -100,10 +105,37 @@ public:
virtual void sample();
};
/**
* the interface which provices delta of bytes.
*/
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
class SrsKbps : public virtual ISrsProtocolStatistic, public virtual IKbpsDelta
{
private:
SrsKbpsSlice is;
@ -130,11 +162,11 @@ public:
virtual int get_send_kbps();
virtual int get_recv_kbps();
// 30s
virtual int get_send_kbps_sample_high();
virtual int get_recv_kbps_sample_high();
virtual int get_send_kbps_30s();
virtual int get_recv_kbps_30s();
// 5m
virtual int get_send_kbps_sample_medium();
virtual int get_recv_kbps_sample_medium();
virtual int get_send_kbps_5m();
virtual int get_recv_kbps_5m();
public:
/**
* 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_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:
/**
* 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();
};

@ -94,6 +94,11 @@ SrsRtmpConn::~SrsRtmpConn()
srs_freep(kbps);
}
void SrsRtmpConn::kbps_resample()
{
kbps->sample();
}
// TODO: return detail message when error for client.
int SrsRtmpConn::do_cycle()
{
@ -168,6 +173,16 @@ int SrsRtmpConn::on_reload_vhost_removed(string vhost)
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()
{
@ -510,8 +525,8 @@ int SrsRtmpConn::playing(SrsSource* source)
srs_trace("-> "SRS_LOG_ID_PLAY
" time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d",
pithy_print.age(), count,
kbps->get_send_kbps(), kbps->get_send_kbps_sample_high(), kbps->get_send_kbps_sample_medium(),
kbps->get_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_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_30s(), kbps->get_recv_kbps_5m());
}
if (count <= 0) {
@ -601,8 +616,8 @@ int SrsRtmpConn::fmle_publish(SrsSource* source)
kbps->sample();
srs_trace("<- "SRS_LOG_ID_CLIENT_PUBLISH
" 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_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_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_30s(), kbps->get_recv_kbps_5m());
}
// process UnPublish event.
@ -683,8 +698,8 @@ int SrsRtmpConn::flash_publish(SrsSource* source)
srs_trace("<- "SRS_LOG_ID_WEB_PUBLISH
" 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_recv_kbps(), kbps->get_recv_kbps_sample_high(), kbps->get_recv_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_30s(), kbps->get_recv_kbps_5m());
}
// process UnPublish event.

@ -51,7 +51,7 @@ class SrsKbps;
/**
* 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:
SrsRequest* req;
@ -68,11 +68,17 @@ private:
public:
SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd);
virtual ~SrsRtmpConn();
public:
virtual void kbps_resample();
protected:
virtual int do_cycle();
// interface ISrsReloadHandler
public:
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:
// when valid and connected to vhost/app, service the client.
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_utility.hpp>
#include <srs_app_heartbeat.hpp>
#include <srs_app_kbps.hpp>
// signal defines.
#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
#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)
{
fd = -1;
@ -312,7 +317,8 @@ SrsServer::SrsServer()
signal_gmc_stop = false;
pid_fd = -1;
signal_manager = new SrsSignalManager(this);
signal_manager = NULL;
kbps = NULL;
// donot new object in constructor,
// for some global instance is not ready now,
@ -372,6 +378,7 @@ void SrsServer::destroy()
}
srs_freep(signal_manager);
srs_freep(kbps);
for (std::vector<SrsConnection*>::iterator it = conns.begin(); it != conns.end();) {
SrsConnection* conn = *it;
@ -398,6 +405,13 @@ int SrsServer::initialize()
srs_assert(_srs_config);
_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
srs_assert(!http_api_handler);
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());
// resample the resource of specified connection.
resample_kbps(conn);
// all connections are created by server,
// so we free it here.
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_PLATFORM_INFO_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
while (true) {
// 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.
int __max = max;
@ -689,30 +707,43 @@ int SrsServer::do_cycle()
// update the cache time or rusage.
if ((i % SRS_SYS_TIME_RESOLUTION_MS_TIMES) == 0) {
srs_info("update current time cache.");
srs_update_system_time_ms();
}
if ((i % SRS_SYS_RUSAGE_RESOLUTION_TIMES) == 0) {
srs_info("update resource info, rss.");
srs_update_system_rusage();
}
if ((i % SRS_SYS_CPU_STAT_RESOLUTION_TIMES) == 0) {
srs_info("update cpu info, usage.");
srs_update_proc_stat();
}
if ((i % SRS_SYS_MEMINFO_RESOLUTION_TIMES) == 0) {
srs_info("update memory info, usage/free.");
srs_update_meminfo();
}
if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) {
srs_info("update platform info, uptime/load.");
srs_update_platform_info();
}
if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) {
srs_info("update network devices info.");
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
if (_srs_config->get_heartbeat_enabled()) {
if ((i % heartbeat_max_resolution) == 0) {
srs_info("do http heartbeat, for internal server to report.");
http_heartbeat->heartbeat();
}
}
#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 ret = ERROR_SUCCESS;

@ -41,6 +41,7 @@ class SrsConnection;
class SrsHttpHandler;
class SrsIngester;
class SrsHttpHeartbeat;
class SrsKbps;
// listener type for server to identify the connection,
// that is, use different type to process the connection.
@ -107,6 +108,10 @@ private:
static void sig_catcher(int signo);
};
/**
* SRS RTMP server, initialize and listen,
* start connection service thread, destroy client.
*/
class SrsServer : public ISrsReloadHandler
{
private:
@ -127,6 +132,7 @@ private:
std::vector<SrsConnection*> conns;
std::vector<SrsListener*> listeners;
SrsSignalManager* signal_manager;
SrsKbps* kbps;
bool signal_reload;
bool signal_gmc_stop;
public:
@ -150,6 +156,8 @@ private:
virtual int listen_http_api();
virtual int listen_http_stream();
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
public:
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_kernel_utility.hpp>
#include <srs_kernel_error.hpp>
#include <srs_app_kbps.hpp>
#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;
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>
class SrsKbps;
/**
* convert level in string to log level in int.
* @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.
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
extern void srs_retrieve_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
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "125"
#define VERSION_REVISION "126"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"

Loading…
Cancel
Save