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

STAT: Only stat media streaming clients.

This commit is contained in:
winlin 2022-08-27 18:06:26 +08:00
parent ccf83a3f68
commit 2944fe430f
2 changed files with 8 additions and 5 deletions

View file

@ -20,6 +20,7 @@ using namespace std;
#include <srs_protocol_utility.hpp> #include <srs_protocol_utility.hpp>
#include <srs_app_tencentcloud.hpp> #include <srs_app_tencentcloud.hpp>
#include <srs_kernel_kbps.hpp> #include <srs_kernel_kbps.hpp>
#include <srs_app_utility.hpp>
string srs_generate_stat_vid() 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); client->stream->vhost->kbps->add_delta(in, out);
} }
SrsKbps* SrsStatistic::kbps_sample() void SrsStatistic::kbps_sample()
{ {
kbps->sample(); kbps->sample();
if (true) { if (true) {
@ -522,7 +523,8 @@ SrsKbps* SrsStatistic::kbps_sample()
} }
} }
return kbps; // Update server level data.
srs_update_rtmp_server((int)clients.size(), kbps);
} }
std::string SrsStatistic::server_id() std::string SrsStatistic::server_id()

View file

@ -99,7 +99,9 @@ public:
struct SrsStatisticClient struct SrsStatisticClient
{ {
public: public:
// For HTTP-API to kickoff this connection by expiring it.
ISrsExpire* conn; ISrsExpire* conn;
public:
SrsStatisticStream* stream; SrsStatisticStream* stream;
SrsRequest* req; SrsRequest* req;
SrsRtmpConnType type; SrsRtmpConnType type;
@ -186,8 +188,7 @@ public:
// Use kbps_sample() to get all result of kbps stat. // Use kbps_sample() to get all result of kbps stat.
virtual void kbps_add_delta(std::string id, ISrsKbpsDelta* delta); virtual void kbps_add_delta(std::string id, ISrsKbpsDelta* delta);
// Calc the result for all kbps. // Calc the result for all kbps.
// @return the server kbps. virtual void kbps_sample();
virtual SrsKbps* kbps_sample();
public: public:
// Get the server id, used to identify the server. // Get the server id, used to identify the server.
// For example, when restart, the server id must changed. // For example, when restart, the server id must changed.