1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

RTC: update stat for pli, timer and dispose

This commit is contained in:
winlin 2021-02-08 11:45:34 +08:00
parent aefd7fccd0
commit 18c27111e0
5 changed files with 34 additions and 10 deletions

View file

@ -41,6 +41,7 @@ using namespace std;
SrsPps* _srs_pps_ids = new SrsPps(_srs_clock); SrsPps* _srs_pps_ids = new SrsPps(_srs_clock);
SrsPps* _srs_pps_fids = new SrsPps(_srs_clock); SrsPps* _srs_pps_fids = new SrsPps(_srs_clock);
SrsPps* _srs_pps_fids_level0 = new SrsPps(_srs_clock); SrsPps* _srs_pps_fids_level0 = new SrsPps(_srs_clock);
SrsPps* _srs_pps_dispose = new SrsPps(_srs_clock);
ISrsDisposingHandler::ISrsDisposingHandler() ISrsDisposingHandler::ISrsDisposingHandler()
{ {
@ -343,6 +344,8 @@ void SrsResourceManager::do_clear()
i, conn->desc().c_str(), conn, (int)conns_.size(), (int)copy.size(), (int)zombies_.size()); i, conn->desc().c_str(), conn, (int)conns_.size(), (int)copy.size(), (int)zombies_.size());
} }
++_srs_pps_dispose->sugar;
dispose(conn); dispose(conn);
} }

View file

@ -28,6 +28,10 @@ using namespace std;
#include <srs_kernel_error.hpp> #include <srs_kernel_error.hpp>
#include <srs_kernel_log.hpp> #include <srs_kernel_log.hpp>
#include <srs_protocol_kbps.hpp>
SrsPps* _srs_pps_timer = new SrsPps(_srs_clock);
ISrsHourGlass::ISrsHourGlass() ISrsHourGlass::ISrsHourGlass()
{ {
} }
@ -36,12 +40,13 @@ ISrsHourGlass::~ISrsHourGlass()
{ {
} }
SrsHourGlass::SrsHourGlass(ISrsHourGlass* h, srs_utime_t resolution) SrsHourGlass::SrsHourGlass(string label, ISrsHourGlass* h, srs_utime_t resolution)
{ {
label_ = label;
handler = h; handler = h;
_resolution = resolution; _resolution = resolution;
total_elapse = 0; total_elapse = 0;
trd = new SrsSTCoroutine("timer", this, _srs_context->get_id()); trd = new SrsSTCoroutine("timer-" + label, this, _srs_context->get_id());
} }
SrsHourGlass::~SrsHourGlass() SrsHourGlass::~SrsHourGlass()
@ -94,6 +99,8 @@ srs_error_t SrsHourGlass::cycle()
srs_utime_t interval = it->second; srs_utime_t interval = it->second;
if (interval == 0 || (total_elapse % interval) == 0) { if (interval == 0 || (total_elapse % interval) == 0) {
++_srs_pps_timer->sugar;
if ((err = handler->notify(event, interval, total_elapse)) != srs_success) { if ((err = handler->notify(event, interval, total_elapse)) != srs_success) {
return srs_error_wrap(err, "notify"); return srs_error_wrap(err, "notify");
} }

View file

@ -29,6 +29,7 @@
#include <srs_app_st.hpp> #include <srs_app_st.hpp>
#include <map> #include <map>
#include <string>
class SrsCoroutine; class SrsCoroutine;
@ -70,6 +71,7 @@ public:
class SrsHourGlass : virtual public ISrsCoroutineHandler class SrsHourGlass : virtual public ISrsCoroutineHandler
{ {
private: private:
std::string label_;
SrsCoroutine* trd; SrsCoroutine* trd;
ISrsHourGlass* handler; ISrsHourGlass* handler;
srs_utime_t _resolution; srs_utime_t _resolution;
@ -81,7 +83,7 @@ private:
// for each cycle, we increase it with a resolution. // for each cycle, we increase it with a resolution.
srs_utime_t total_elapse; srs_utime_t total_elapse;
public: public:
SrsHourGlass(ISrsHourGlass* h, srs_utime_t resolution); SrsHourGlass(std::string label, ISrsHourGlass* h, srs_utime_t resolution);
virtual ~SrsHourGlass(); virtual ~SrsHourGlass();
public: public:
// Start the hourglass. // Start the hourglass.

View file

@ -58,6 +58,10 @@ using namespace std;
#include <srs_app_rtc_source.hpp> #include <srs_app_rtc_source.hpp>
#include <srs_protocol_utility.hpp> #include <srs_protocol_utility.hpp>
#include <srs_protocol_kbps.hpp>
SrsPps* _srs_pps_pli = new SrsPps(_srs_clock);
#define SRS_TICKID_RTCP 0 #define SRS_TICKID_RTCP 0
#define SRS_TICKID_TWCC 2 #define SRS_TICKID_TWCC 2
@ -331,6 +335,8 @@ srs_error_t SrsRtcPLIWorker::cycle()
uint32_t ssrc = it->first; uint32_t ssrc = it->first;
SrsContextId cid = it->second; SrsContextId cid = it->second;
++_srs_pps_pli->sugar;
if ((err = handler_->do_request_keyframe(ssrc, cid)) != srs_success) { if ((err = handler_->do_request_keyframe(ssrc, cid)) != srs_success) {
srs_warn("PLI error, %s", srs_error_desc(err).c_str()); srs_warn("PLI error, %s", srs_error_desc(err).c_str());
srs_error_reset(err); srs_error_reset(err);
@ -373,7 +379,7 @@ SrsRtcPlayStream::SrsRtcPlayStream(SrsRtcConnection* s, const SrsContextId& cid)
nack_enabled_ = false; nack_enabled_ = false;
_srs_config->subscribe(this); _srs_config->subscribe(this);
timer_ = new SrsHourGlass(this, 1000 * SRS_UTIME_MILLISECONDS); timer_ = new SrsHourGlass("play", this, 1000 * SRS_UTIME_MILLISECONDS);
nack_epp = new SrsErrorPithyPrint(); nack_epp = new SrsErrorPithyPrint();
pli_worker_ = new SrsRtcPLIWorker(this); pli_worker_ = new SrsRtcPLIWorker(this);
} }
@ -855,7 +861,7 @@ srs_error_t SrsRtcPlayStream::do_request_keyframe(uint32_t ssrc, SrsContextId ci
SrsRtcPublishStream::SrsRtcPublishStream(SrsRtcConnection* session, const SrsContextId& cid) SrsRtcPublishStream::SrsRtcPublishStream(SrsRtcConnection* session, const SrsContextId& cid)
{ {
timer_ = new SrsHourGlass(this, 20 * SRS_UTIME_MILLISECONDS); timer_ = new SrsHourGlass("publish", this, 20 * SRS_UTIME_MILLISECONDS);
cid_ = cid; cid_ = cid;
is_started = false; is_started = false;
@ -1268,7 +1274,7 @@ srs_error_t SrsRtcPublishStream::send_periodic_twcc()
uint32_t nn = 0; uint32_t nn = 0;
srs_utime_t duration = srs_duration(last_time_send_twcc_, srs_get_system_time()); srs_utime_t duration = srs_duration(last_time_send_twcc_, srs_get_system_time());
if (duration > 80 * SRS_UTIME_MILLISECONDS && twcc_epp_->can_print(0, &nn)) { if (duration > 80 * SRS_UTIME_MILLISECONDS && twcc_epp_->can_print(0, &nn)) {
srs_warn2(TAG_LARGE_TIMER, "send_twcc interval exceeded %dms > 100ms, count=%u/%u", srs_warn2(TAG_LARGE_TIMER, "send_twcc interval exceeded %dms > 80ms, count=%u/%u",
srsu2msi(duration), nn, twcc_epp_->nn_count); srsu2msi(duration), nn, twcc_epp_->nn_count);
} }
} }
@ -1569,7 +1575,7 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, const SrsContextId& cid)
req = NULL; req = NULL;
cid_ = cid; cid_ = cid;
stat_ = new SrsRtcConnectionStatistic(); stat_ = new SrsRtcConnectionStatistic();
timer_ = new SrsHourGlass(this, 1000 * SRS_UTIME_MILLISECONDS); timer_ = new SrsHourGlass("conn", this, 1000 * SRS_UTIME_MILLISECONDS);
hijacker_ = NULL; hijacker_ = NULL;
sendonly_skt = NULL; sendonly_skt = NULL;

View file

@ -56,6 +56,10 @@ extern SrsPps* _srs_pps_fids_level0;
extern SrsPps* _srs_pps_cids_get; extern SrsPps* _srs_pps_cids_get;
extern SrsPps* _srs_pps_cids_set; extern SrsPps* _srs_pps_cids_set;
extern SrsPps* _srs_pps_pli;
extern SrsPps* _srs_pps_timer;
extern SrsPps* _srs_pps_dispose;
SrsRtcBlackhole::SrsRtcBlackhole() SrsRtcBlackhole::SrsRtcBlackhole()
{ {
blackhole = false; blackhole = false;
@ -228,7 +232,7 @@ SrsRtcServer::SrsRtcServer()
{ {
handler = NULL; handler = NULL;
hijacker = NULL; hijacker = NULL;
timer = new SrsHourGlass(this, 1 * SRS_UTIME_SECONDS); timer = new SrsHourGlass("server", this, 1 * SRS_UTIME_SECONDS);
} }
SrsRtcServer::~SrsRtcServer() SrsRtcServer::~SrsRtcServer()
@ -653,13 +657,15 @@ srs_error_t SrsRtcServer::notify(int type, srs_utime_t interval, srs_utime_t tic
_srs_pps_pkts->update(); _srs_pps_addrs->update(); _srs_pps_fast_addrs->update(); _srs_pps_pkts->update(); _srs_pps_addrs->update(); _srs_pps_fast_addrs->update();
_srs_pps_ids->update(); _srs_pps_fids->update(); _srs_pps_fids_level0->update(); _srs_pps_ids->update(); _srs_pps_fids->update(); _srs_pps_fids_level0->update();
_srs_pps_cids_get->update(); _srs_pps_cids_set->update(); _srs_pps_cids_get->update(); _srs_pps_cids_set->update();
_srs_pps_pli->update(); _srs_pps_timer->update(); _srs_pps_dispose->update();
// TODO: FIXME: Show more data for RTC server. // TODO: FIXME: Show more data for RTC server.
srs_trace("RTC: Server conns=%u, cpu=%.2f%%, rss=%dMB, pkts=%d, addrs=%d,%d, fid=%d,%d,%d, cid=%d,%d", srs_trace("RTC: Server conns=%u, cpu=%.2f%%, rss=%dMB, pkts=%d, addrs=%d,%d, fid=%d,%d,%d, cid=%d,%d, pli=%d, timer=%d, dispose=%d",
nn_rtc_conns, u->percent * 100, memory, nn_rtc_conns, u->percent * 100, memory,
_srs_pps_pkts->r10s(), _srs_pps_addrs->r10s(), _srs_pps_fast_addrs->r10s(), _srs_pps_pkts->r10s(), _srs_pps_addrs->r10s(), _srs_pps_fast_addrs->r10s(),
_srs_pps_ids->r10s(), _srs_pps_fids->r10s(), _srs_pps_fids_level0->r10s(), _srs_pps_ids->r10s(), _srs_pps_fids->r10s(), _srs_pps_fids_level0->r10s(),
_srs_pps_cids_get->r10s(), _srs_pps_cids_set->r10s() _srs_pps_cids_get->r10s(), _srs_pps_cids_set->r10s(),
_srs_pps_pli->r10s(), _srs_pps_timer->r10s(), _srs_pps_dispose->r10s()
); );
return err; return err;