mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Eliminate unused stat API
This commit is contained in:
parent
06f7d7d11b
commit
cd45750c9d
8 changed files with 1 additions and 406 deletions
|
@ -1303,95 +1303,6 @@ srs_error_t SrsGoApiClusters::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
||||||
return srs_api_response(w, r, obj->dumps());
|
return srs_api_response(w, r, obj->dumps());
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsGoApiPerf::SrsGoApiPerf()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsGoApiPerf::~SrsGoApiPerf()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsGoApiPerf::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|
||||||
{
|
|
||||||
srs_error_t err = srs_success;
|
|
||||||
|
|
||||||
SrsJsonObject* obj = SrsJsonAny::object();
|
|
||||||
SrsAutoFree(SrsJsonObject, obj);
|
|
||||||
|
|
||||||
obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS));
|
|
||||||
SrsJsonObject* data = SrsJsonAny::object();
|
|
||||||
obj->set("data", data);
|
|
||||||
|
|
||||||
SrsStatistic* stat = SrsStatistic::instance();
|
|
||||||
|
|
||||||
string target = r->query_get("target");
|
|
||||||
string reset = r->query_get("reset");
|
|
||||||
srs_trace("query target=%s, reset=%s, rtc_stat_enabled=%d", target.c_str(), reset.c_str(),
|
|
||||||
_srs_config->get_rtc_server_perf_stat());
|
|
||||||
|
|
||||||
if (true) {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("query", p);
|
|
||||||
|
|
||||||
p->set("target", SrsJsonAny::str(target.c_str()));
|
|
||||||
p->set("reset", SrsJsonAny::str(reset.c_str()));
|
|
||||||
p->set("help", SrsJsonAny::str("?target=avframes|rtc|rtp|writev_iovs|bytes"));
|
|
||||||
p->set("help2", SrsJsonAny::str("?reset=all"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!reset.empty()) {
|
|
||||||
stat->reset_perf();
|
|
||||||
return srs_api_response(w, r, obj->dumps());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "avframes") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("avframes", p);
|
|
||||||
if ((err = stat->dumps_perf_msgs(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "rtc") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("rtc", p);
|
|
||||||
if ((err = stat->dumps_perf_rtc_packets(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "rtp") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("rtp", p);
|
|
||||||
if ((err = stat->dumps_perf_rtp_packets(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "writev_iovs") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("writev_iovs", p);
|
|
||||||
if ((err = stat->dumps_perf_writev_iovs(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.empty() || target == "bytes") {
|
|
||||||
SrsJsonObject* p = SrsJsonAny::object();
|
|
||||||
data->set("bytes", p);
|
|
||||||
if ((err = stat->dumps_perf_bytes(p)) != srs_success) {
|
|
||||||
int code = srs_error_code(err); srs_error_reset(err);
|
|
||||||
return srs_api_response_code(w, r, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return srs_api_response(w, r, obj->dumps());
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsGoApiError::SrsGoApiError()
|
SrsGoApiError::SrsGoApiError()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,15 +213,6 @@ public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsGoApiPerf : public ISrsHttpHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SrsGoApiPerf();
|
|
||||||
virtual ~SrsGoApiPerf();
|
|
||||||
public:
|
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
|
||||||
};
|
|
||||||
|
|
||||||
class SrsGoApiError : public ISrsHttpHandler
|
class SrsGoApiError : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -191,9 +191,6 @@ srs_error_t SrsQueueRecvThread::start()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
SrsStatistic* stat = SrsStatistic::instance();
|
|
||||||
rtmp->set_perf(stat);
|
|
||||||
|
|
||||||
if ((err = trd.start()) != srs_success) {
|
if ((err = trd.start()) != srs_success) {
|
||||||
return srs_error_wrap(err, "queue recv thread");
|
return srs_error_wrap(err, "queue recv thread");
|
||||||
}
|
}
|
||||||
|
|
|
@ -997,9 +997,6 @@ srs_error_t SrsServer::http_handle()
|
||||||
if ((err = http_api_mux->handle("/api/v1/clusters", new SrsGoApiClusters())) != srs_success) {
|
if ((err = http_api_mux->handle("/api/v1/clusters", new SrsGoApiClusters())) != srs_success) {
|
||||||
return srs_error_wrap(err, "handle clusters");
|
return srs_error_wrap(err, "handle clusters");
|
||||||
}
|
}
|
||||||
if ((err = http_api_mux->handle("/api/v1/perf", new SrsGoApiPerf())) != srs_success) {
|
|
||||||
return srs_error_wrap(err, "handle perf");
|
|
||||||
}
|
|
||||||
#ifdef SRS_GB28181
|
#ifdef SRS_GB28181
|
||||||
if ((err = http_api_mux->handle("/api/v1/gb28181", new SrsGoApiGb28181())) != srs_success) {
|
if ((err = http_api_mux->handle("/api/v1/gb28181", new SrsGoApiGb28181())) != srs_success) {
|
||||||
return srs_error_wrap(err, "handle raw");
|
return srs_error_wrap(err, "handle raw");
|
||||||
|
|
|
@ -229,27 +229,6 @@ srs_error_t SrsStatisticClient::dumps(SrsJsonObject* obj)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatisticCategory::SrsStatisticCategory()
|
|
||||||
{
|
|
||||||
nn = 0;
|
|
||||||
|
|
||||||
a = 0;
|
|
||||||
b = 0;
|
|
||||||
c = 0;
|
|
||||||
d = 0;
|
|
||||||
e = 0;
|
|
||||||
|
|
||||||
f = 0;
|
|
||||||
g = 0;
|
|
||||||
h = 0;
|
|
||||||
i = 0;
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsStatisticCategory::~SrsStatisticCategory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsStatistic* SrsStatistic::_instance = NULL;
|
SrsStatistic* SrsStatistic::_instance = NULL;
|
||||||
|
|
||||||
SrsStatistic::SrsStatistic()
|
SrsStatistic::SrsStatistic()
|
||||||
|
@ -259,12 +238,6 @@ SrsStatistic::SrsStatistic()
|
||||||
clk = new SrsWallClock();
|
clk = new SrsWallClock();
|
||||||
kbps = new SrsKbps(clk);
|
kbps = new SrsKbps(clk);
|
||||||
kbps->set_io(NULL, NULL);
|
kbps->set_io(NULL, NULL);
|
||||||
|
|
||||||
perf_iovs = new SrsStatisticCategory();
|
|
||||||
perf_msgs = new SrsStatisticCategory();
|
|
||||||
perf_rtp = new SrsStatisticCategory();
|
|
||||||
perf_rtc = new SrsStatisticCategory();
|
|
||||||
perf_bytes = new SrsStatisticCategory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic::~SrsStatistic()
|
SrsStatistic::~SrsStatistic()
|
||||||
|
@ -298,12 +271,6 @@ SrsStatistic::~SrsStatistic()
|
||||||
rvhosts.clear();
|
rvhosts.clear();
|
||||||
streams.clear();
|
streams.clear();
|
||||||
rstreams.clear();
|
rstreams.clear();
|
||||||
|
|
||||||
srs_freep(perf_iovs);
|
|
||||||
srs_freep(perf_msgs);
|
|
||||||
srs_freep(perf_rtp);
|
|
||||||
srs_freep(perf_rtc);
|
|
||||||
srs_freep(perf_bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic* SrsStatistic::instance()
|
SrsStatistic* SrsStatistic::instance()
|
||||||
|
@ -587,157 +554,6 @@ srs_error_t SrsStatistic::dumps_clients(SrsJsonArray* arr, int start, int count)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsStatistic::perf_on_msgs(int nb_msgs)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_msgs, nb_msgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_msgs(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_msgs, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_rtc_packets(int nb_packets)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_rtc, nb_packets);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_rtc_packets(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_rtc, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_rtp_packets(int nb_packets)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_rtp, nb_packets);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_rtp_packets(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_rtp, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_writev_iovs(int nb_iovs)
|
|
||||||
{
|
|
||||||
perf_on_packets(perf_iovs, nb_iovs);
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_writev_iovs(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
return dumps_perf(perf_iovs, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_rtc_bytes(int nn_bytes, int nn_rtp_bytes, int nn_padding)
|
|
||||||
{
|
|
||||||
// a: AVFrame bytes.
|
|
||||||
// b: RTC bytes.
|
|
||||||
// c: RTC paddings.
|
|
||||||
perf_bytes->a += nn_bytes;
|
|
||||||
perf_bytes->b += nn_rtp_bytes;
|
|
||||||
perf_bytes->c += nn_padding;
|
|
||||||
|
|
||||||
perf_bytes->nn += nn_rtp_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf_bytes(SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
obj->set("avframe_bytes", SrsJsonAny::integer(perf_bytes->a));
|
|
||||||
obj->set("rtc_bytes", SrsJsonAny::integer(perf_bytes->b));
|
|
||||||
obj->set("rtc_padding", SrsJsonAny::integer(perf_bytes->c));
|
|
||||||
|
|
||||||
obj->set("nn", SrsJsonAny::integer(perf_bytes->nn));
|
|
||||||
|
|
||||||
return srs_success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::reset_perf()
|
|
||||||
{
|
|
||||||
srs_freep(perf_iovs);
|
|
||||||
srs_freep(perf_msgs);
|
|
||||||
srs_freep(perf_rtp);
|
|
||||||
srs_freep(perf_rtc);
|
|
||||||
srs_freep(perf_bytes);
|
|
||||||
|
|
||||||
perf_iovs = new SrsStatisticCategory();
|
|
||||||
perf_msgs = new SrsStatisticCategory();
|
|
||||||
perf_rtp = new SrsStatisticCategory();
|
|
||||||
perf_rtc = new SrsStatisticCategory();
|
|
||||||
perf_bytes = new SrsStatisticCategory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsStatistic::perf_on_packets(SrsStatisticCategory* p, int nb_msgs)
|
|
||||||
{
|
|
||||||
// The range for stat:
|
|
||||||
// 2, 3, 5, 9, 16, 32, 64, 128, 256
|
|
||||||
// that is:
|
|
||||||
// a: <2
|
|
||||||
// b: <3
|
|
||||||
// c: <5
|
|
||||||
// d: <9
|
|
||||||
// e: <16
|
|
||||||
// f: <32
|
|
||||||
// g: <64
|
|
||||||
// h: <128
|
|
||||||
// i: <256
|
|
||||||
// j: >=256
|
|
||||||
if (nb_msgs < 2) {
|
|
||||||
p->a++;
|
|
||||||
} else if (nb_msgs < 3) {
|
|
||||||
p->b++;
|
|
||||||
} else if (nb_msgs < 5) {
|
|
||||||
p->c++;
|
|
||||||
} else if (nb_msgs < 9) {
|
|
||||||
p->d++;
|
|
||||||
} else if (nb_msgs < 16) {
|
|
||||||
p->e++;
|
|
||||||
} else if (nb_msgs < 32) {
|
|
||||||
p->f++;
|
|
||||||
} else if (nb_msgs < 64) {
|
|
||||||
p->g++;
|
|
||||||
} else if (nb_msgs < 128) {
|
|
||||||
p->h++;
|
|
||||||
} else if (nb_msgs < 256) {
|
|
||||||
p->i++;
|
|
||||||
} else {
|
|
||||||
p->j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->nn += nb_msgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_perf(SrsStatisticCategory* p, SrsJsonObject* obj)
|
|
||||||
{
|
|
||||||
srs_error_t err = srs_success;
|
|
||||||
|
|
||||||
// The range for stat:
|
|
||||||
// 2, 3, 5, 9, 16, 32, 64, 128, 256
|
|
||||||
// that is:
|
|
||||||
// a: <2
|
|
||||||
// b: <3
|
|
||||||
// c: <5
|
|
||||||
// d: <9
|
|
||||||
// e: <16
|
|
||||||
// f: <32
|
|
||||||
// g: <64
|
|
||||||
// h: <128
|
|
||||||
// i: <256
|
|
||||||
// j: >=256
|
|
||||||
if (p->a) obj->set("lt_2", SrsJsonAny::integer(p->a));
|
|
||||||
if (p->b) obj->set("lt_3", SrsJsonAny::integer(p->b));
|
|
||||||
if (p->c) obj->set("lt_5", SrsJsonAny::integer(p->c));
|
|
||||||
if (p->d) obj->set("lt_9", SrsJsonAny::integer(p->d));
|
|
||||||
if (p->e) obj->set("lt_16", SrsJsonAny::integer(p->e));
|
|
||||||
if (p->f) obj->set("lt_32", SrsJsonAny::integer(p->f));
|
|
||||||
if (p->g) obj->set("lt_64", SrsJsonAny::integer(p->g));
|
|
||||||
if (p->h) obj->set("lt_128", SrsJsonAny::integer(p->h));
|
|
||||||
if (p->i) obj->set("lt_256", SrsJsonAny::integer(p->i));
|
|
||||||
if (p->j) obj->set("gt_256", SrsJsonAny::integer(p->j));
|
|
||||||
|
|
||||||
obj->set("nn", SrsJsonAny::integer(p->nn));
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsStatisticVhost* SrsStatistic::create_vhost(SrsRequest* req)
|
SrsStatisticVhost* SrsStatistic::create_vhost(SrsRequest* req)
|
||||||
{
|
{
|
||||||
SrsStatisticVhost* vhost = NULL;
|
SrsStatisticVhost* vhost = NULL;
|
||||||
|
|
|
@ -124,28 +124,7 @@ public:
|
||||||
virtual srs_error_t dumps(SrsJsonObject* obj);
|
virtual srs_error_t dumps(SrsJsonObject* obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsStatisticCategory
|
class SrsStatistic
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint64_t nn;
|
|
||||||
public:
|
|
||||||
uint64_t a;
|
|
||||||
uint64_t b;
|
|
||||||
uint64_t c;
|
|
||||||
uint64_t d;
|
|
||||||
uint64_t e;
|
|
||||||
public:
|
|
||||||
uint64_t f;
|
|
||||||
uint64_t g;
|
|
||||||
uint64_t h;
|
|
||||||
uint64_t i;
|
|
||||||
uint64_t j;
|
|
||||||
public:
|
|
||||||
SrsStatisticCategory();
|
|
||||||
virtual ~SrsStatisticCategory();
|
|
||||||
};
|
|
||||||
|
|
||||||
class SrsStatistic : public ISrsProtocolPerf
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static SrsStatistic *_instance;
|
static SrsStatistic *_instance;
|
||||||
|
@ -169,12 +148,6 @@ private:
|
||||||
// The server total kbps.
|
// The server total kbps.
|
||||||
SrsKbps* kbps;
|
SrsKbps* kbps;
|
||||||
SrsWallClock* clk;
|
SrsWallClock* clk;
|
||||||
// The perf stat for mw(merged write).
|
|
||||||
SrsStatisticCategory* perf_iovs;
|
|
||||||
SrsStatisticCategory* perf_msgs;
|
|
||||||
SrsStatisticCategory* perf_rtp;
|
|
||||||
SrsStatisticCategory* perf_rtc;
|
|
||||||
SrsStatisticCategory* perf_bytes;
|
|
||||||
private:
|
private:
|
||||||
SrsStatistic();
|
SrsStatistic();
|
||||||
virtual ~SrsStatistic();
|
virtual ~SrsStatistic();
|
||||||
|
@ -231,35 +204,6 @@ public:
|
||||||
// @param start the start index, from 0.
|
// @param start the start index, from 0.
|
||||||
// @param count the max count of clients to dump.
|
// @param count the max count of clients to dump.
|
||||||
virtual srs_error_t dumps_clients(SrsJsonArray* arr, int start, int count);
|
virtual srs_error_t dumps_clients(SrsJsonArray* arr, int start, int count);
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_msgs is the number of RTMP messages.
|
|
||||||
// For example, publish by FFMPEG, Audio and Video frames.
|
|
||||||
virtual void perf_on_msgs(int nb_msgs);
|
|
||||||
virtual srs_error_t dumps_perf_msgs(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_packets is the number of RTC packets.
|
|
||||||
// For example, a RTMP/AAC audio packet maybe transcoded to two RTC/opus packets.
|
|
||||||
virtual void perf_on_rtc_packets(int nb_packets);
|
|
||||||
virtual srs_error_t dumps_perf_rtc_packets(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_packets is the number of RTP packets.
|
|
||||||
// For example, a RTC/opus packet maybe package to three RTP packets.
|
|
||||||
virtual void perf_on_rtp_packets(int nb_packets);
|
|
||||||
virtual srs_error_t dumps_perf_rtp_packets(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for TCP writev, nb_iovs is the total number of iovec.
|
|
||||||
virtual void perf_on_writev_iovs(int nb_iovs);
|
|
||||||
virtual srs_error_t dumps_perf_writev_iovs(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Stat for bytes, nn_bytes is the size of bytes, nb_padding is padding bytes.
|
|
||||||
virtual void perf_on_rtc_bytes(int nn_bytes, int nn_rtp_bytes, int nn_padding);
|
|
||||||
virtual srs_error_t dumps_perf_bytes(SrsJsonObject* obj);
|
|
||||||
public:
|
|
||||||
// Reset all perf stat data.
|
|
||||||
virtual void reset_perf();
|
|
||||||
private:
|
|
||||||
virtual void perf_on_packets(SrsStatisticCategory* p, int nb_msgs);
|
|
||||||
virtual srs_error_t dumps_perf(SrsStatisticCategory* p, SrsJsonObject* obj);
|
|
||||||
private:
|
private:
|
||||||
virtual SrsStatisticVhost* create_vhost(SrsRequest* req);
|
virtual SrsStatisticVhost* create_vhost(SrsRequest* req);
|
||||||
virtual SrsStatisticStream* create_stream(SrsStatisticVhost* vhost, SrsRequest* req);
|
virtual SrsStatisticStream* create_stream(SrsStatisticVhost* vhost, SrsRequest* req);
|
||||||
|
|
|
@ -217,14 +217,6 @@ srs_error_t SrsPacket::encode_packet(SrsBuffer* stream)
|
||||||
return srs_error_new(ERROR_SYSTEM_PACKET_INVALID, "encode");
|
return srs_error_new(ERROR_SYSTEM_PACKET_INVALID, "encode");
|
||||||
}
|
}
|
||||||
|
|
||||||
ISrsProtocolPerf::ISrsProtocolPerf()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ISrsProtocolPerf::~ISrsProtocolPerf()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsProtocol::AckWindowSize::AckWindowSize()
|
SrsProtocol::AckWindowSize::AckWindowSize()
|
||||||
{
|
{
|
||||||
window = 0;
|
window = 0;
|
||||||
|
@ -264,7 +256,6 @@ SrsProtocol::SrsProtocol(ISrsProtocolReadWriter* io)
|
||||||
}
|
}
|
||||||
|
|
||||||
out_c0c3_caches = new char[SRS_CONSTS_C0C3_HEADERS_MAX];
|
out_c0c3_caches = new char[SRS_CONSTS_C0C3_HEADERS_MAX];
|
||||||
perf = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsProtocol::~SrsProtocol()
|
SrsProtocol::~SrsProtocol()
|
||||||
|
@ -312,11 +303,6 @@ void SrsProtocol::set_auto_response(bool v)
|
||||||
auto_response_when_recv = v;
|
auto_response_when_recv = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsProtocol::set_perf(ISrsProtocolPerf* v)
|
|
||||||
{
|
|
||||||
perf = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_error_t SrsProtocol::manual_response_flush()
|
srs_error_t SrsProtocol::manual_response_flush()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -463,11 +449,6 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
||||||
int c0c3_cache_index = 0;
|
int c0c3_cache_index = 0;
|
||||||
char* c0c3_cache = out_c0c3_caches + c0c3_cache_index;
|
char* c0c3_cache = out_c0c3_caches + c0c3_cache_index;
|
||||||
|
|
||||||
// How many messages are merged in written.
|
|
||||||
int nb_msgs_merged_written = 0;
|
|
||||||
// How many bytes of messages are merged in written.
|
|
||||||
int bytes_msgs_merged_written = 0;
|
|
||||||
|
|
||||||
// try to send use the c0c3 header cache,
|
// try to send use the c0c3 header cache,
|
||||||
// if cache is consumed, try another loop.
|
// if cache is consumed, try another loop.
|
||||||
for (int i = 0; i < nb_msgs; i++) {
|
for (int i = 0; i < nb_msgs; i++) {
|
||||||
|
@ -482,10 +463,6 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increase the perf stat data.
|
|
||||||
nb_msgs_merged_written++;
|
|
||||||
bytes_msgs_merged_written += msg->size;
|
|
||||||
|
|
||||||
// p set to current write position,
|
// p set to current write position,
|
||||||
// it's ok when payload is NULL and size is 0.
|
// it's ok when payload is NULL and size is 0.
|
||||||
char* p = msg->payload;
|
char* p = msg->payload;
|
||||||
|
@ -546,13 +523,6 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
||||||
return srs_error_wrap(err, "send iovs");
|
return srs_error_wrap(err, "send iovs");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify about perf stat.
|
|
||||||
if (perf) {
|
|
||||||
perf->perf_on_msgs(nb_msgs_merged_written);
|
|
||||||
perf->perf_on_writev_iovs(iov_index);
|
|
||||||
nb_msgs_merged_written = 0; bytes_msgs_merged_written = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset caches, while these cache ensure
|
// reset caches, while these cache ensure
|
||||||
// atleast we can sendout a chunk.
|
// atleast we can sendout a chunk.
|
||||||
iov_index = 0;
|
iov_index = 0;
|
||||||
|
@ -575,13 +545,6 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg
|
||||||
return srs_error_wrap(err, "send iovs");
|
return srs_error_wrap(err, "send iovs");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify about perf stat.
|
|
||||||
if (perf) {
|
|
||||||
perf->perf_on_msgs(nb_msgs_merged_written);
|
|
||||||
perf->perf_on_writev_iovs(iov_index);
|
|
||||||
nb_msgs_merged_written = 0; bytes_msgs_merged_written = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
#else
|
#else
|
||||||
// try to send use the c0c3 header cache,
|
// try to send use the c0c3 header cache,
|
||||||
|
@ -2251,11 +2214,6 @@ void SrsRtmpServer::set_auto_response(bool v)
|
||||||
protocol->set_auto_response(v);
|
protocol->set_auto_response(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtmpServer::set_perf(ISrsProtocolPerf* v)
|
|
||||||
{
|
|
||||||
protocol->set_perf(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SRS_PERF_MERGED_READ
|
#ifdef SRS_PERF_MERGED_READ
|
||||||
void SrsRtmpServer::set_merge_read(bool v, IMergeReadHandler* handler)
|
void SrsRtmpServer::set_merge_read(bool v, IMergeReadHandler* handler)
|
||||||
{
|
{
|
||||||
|
|
|
@ -147,19 +147,6 @@ protected:
|
||||||
virtual srs_error_t encode_packet(SrsBuffer* stream);
|
virtual srs_error_t encode_packet(SrsBuffer* stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The performance statistic data collect.
|
|
||||||
class ISrsProtocolPerf
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ISrsProtocolPerf();
|
|
||||||
virtual ~ISrsProtocolPerf();
|
|
||||||
public:
|
|
||||||
// Stat for packets merged written, nb_msgs is the number of RTMP messages,
|
|
||||||
virtual void perf_on_msgs(int nb_msgs) = 0;
|
|
||||||
// Stat for TCP writev, nb_iovs is the total number of iovec.
|
|
||||||
virtual void perf_on_writev_iovs(int nb_iovs) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// The protocol provides the rtmp-message-protocol services,
|
// The protocol provides the rtmp-message-protocol services,
|
||||||
// To recv RTMP message from RTMP chunk stream,
|
// To recv RTMP message from RTMP chunk stream,
|
||||||
// and to send out RTMP message over RTMP chunk stream.
|
// and to send out RTMP message over RTMP chunk stream.
|
||||||
|
@ -181,8 +168,6 @@ private:
|
||||||
private:
|
private:
|
||||||
// The underlayer socket object, send/recv bytes.
|
// The underlayer socket object, send/recv bytes.
|
||||||
ISrsProtocolReadWriter* skt;
|
ISrsProtocolReadWriter* skt;
|
||||||
// The performance stat handler.
|
|
||||||
ISrsProtocolPerf* perf;
|
|
||||||
// The requests sent out, used to build the response.
|
// The requests sent out, used to build the response.
|
||||||
// key: transactionId
|
// key: transactionId
|
||||||
// value: the request command name
|
// value: the request command name
|
||||||
|
@ -242,8 +227,6 @@ public:
|
||||||
// @param v, whether auto response message when recv message.
|
// @param v, whether auto response message when recv message.
|
||||||
// @see: https://github.com/ossrs/srs/issues/217
|
// @see: https://github.com/ossrs/srs/issues/217
|
||||||
virtual void set_auto_response(bool v);
|
virtual void set_auto_response(bool v);
|
||||||
// Set the performance stat handler.
|
|
||||||
virtual void set_perf(ISrsProtocolPerf* v);
|
|
||||||
// Flush for manual response when the auto response is disabled
|
// Flush for manual response when the auto response is disabled
|
||||||
// by set_auto_response(false), we default use auto response, so donot
|
// by set_auto_response(false), we default use auto response, so donot
|
||||||
// need to call this api(the protocol sdk will auto send message).
|
// need to call this api(the protocol sdk will auto send message).
|
||||||
|
@ -648,8 +631,6 @@ public:
|
||||||
// @param v, whether auto response message when recv message.
|
// @param v, whether auto response message when recv message.
|
||||||
// @see: https://github.com/ossrs/srs/issues/217
|
// @see: https://github.com/ossrs/srs/issues/217
|
||||||
virtual void set_auto_response(bool v);
|
virtual void set_auto_response(bool v);
|
||||||
// Set the performance stat handler.
|
|
||||||
virtual void set_perf(ISrsProtocolPerf* v);
|
|
||||||
#ifdef SRS_PERF_MERGED_READ
|
#ifdef SRS_PERF_MERGED_READ
|
||||||
// To improve read performance, merge some packets then read,
|
// To improve read performance, merge some packets then read,
|
||||||
// When it on and read small bytes, we sleep to wait more data.,
|
// When it on and read small bytes, we sleep to wait more data.,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue