From 2944fe430fe98894012ed993664dcb77e0d61794 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 27 Aug 2022 18:06:26 +0800 Subject: [PATCH] STAT: Only stat media streaming clients. --- trunk/src/app/srs_app_statistic.cpp | 8 +++++--- trunk/src/app/srs_app_statistic.hpp | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index 8aa9610d6..f5a202f64 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -20,6 +20,7 @@ using namespace std; #include #include #include +#include string srs_generate_stat_vid() { @@ -496,7 +497,7 @@ void SrsStatistic::kbps_add_delta(std::string id, ISrsKbpsDelta* delta) client->stream->vhost->kbps->add_delta(in, out); } -SrsKbps* SrsStatistic::kbps_sample() +void SrsStatistic::kbps_sample() { kbps->sample(); if (true) { @@ -521,8 +522,9 @@ SrsKbps* SrsStatistic::kbps_sample() client->kbps->sample(); } } - - return kbps; + + // Update server level data. + srs_update_rtmp_server((int)clients.size(), kbps); } std::string SrsStatistic::server_id() diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index a15539181..7c4ea5317 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -99,7 +99,9 @@ public: struct SrsStatisticClient { public: + // For HTTP-API to kickoff this connection by expiring it. ISrsExpire* conn; +public: SrsStatisticStream* stream; SrsRequest* req; SrsRtmpConnType type; @@ -186,8 +188,7 @@ public: // Use kbps_sample() to get all result of kbps stat. virtual void kbps_add_delta(std::string id, ISrsKbpsDelta* delta); // Calc the result for all kbps. - // @return the server kbps. - virtual SrsKbps* kbps_sample(); + virtual void kbps_sample(); public: // Get the server id, used to identify the server. // For example, when restart, the server id must changed.