mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
Kernel: Extract SrsPps to kernel
This commit is contained in:
parent
df6e47ebfc
commit
d8ba72fdc5
7 changed files with 236 additions and 161 deletions
3
trunk/configure
vendored
3
trunk/configure
vendored
|
@ -216,7 +216,8 @@ ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
|
||||||
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_buffer"
|
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_buffer"
|
||||||
"srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_io"
|
"srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_io"
|
||||||
"srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"
|
"srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"
|
||||||
"srs_kernel_stream" "srs_kernel_balance" "srs_kernel_mp4" "srs_kernel_file")
|
"srs_kernel_stream" "srs_kernel_balance" "srs_kernel_mp4" "srs_kernel_file"
|
||||||
|
"srs_kernel_kbps")
|
||||||
if [[ $SRS_RTC == YES ]]; then
|
if [[ $SRS_RTC == YES ]]; then
|
||||||
MODULE_FILES+=("srs_kernel_rtc_rtp" "srs_kernel_rtc_rtcp")
|
MODULE_FILES+=("srs_kernel_rtc_rtp" "srs_kernel_rtc_rtcp")
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -75,6 +75,8 @@ extern SrsPps* _srs_pps_rnack2;
|
||||||
extern SrsPps* _srs_pps_rhnack;
|
extern SrsPps* _srs_pps_rhnack;
|
||||||
extern SrsPps* _srs_pps_rmnack;
|
extern SrsPps* _srs_pps_rmnack;
|
||||||
|
|
||||||
|
extern SrsPps* _srs_pps_objs_rtps;
|
||||||
|
|
||||||
SrsRtcBlackhole::SrsRtcBlackhole()
|
SrsRtcBlackhole::SrsRtcBlackhole()
|
||||||
{
|
{
|
||||||
blackhole = false;
|
blackhole = false;
|
||||||
|
@ -676,6 +678,13 @@ srs_error_t SrsRtcServer::notify(int type, srs_utime_t interval, srs_utime_t tic
|
||||||
}
|
}
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
|
|
||||||
|
string objs_desc;
|
||||||
|
_srs_pps_objs_rtps->update();
|
||||||
|
if (_srs_pps_objs_rtps->r10s()) {
|
||||||
|
snprintf(buf, sizeof(buf), ", objs=%d", _srs_pps_objs_rtps->r10s());
|
||||||
|
objs_desc = buf;
|
||||||
|
}
|
||||||
|
|
||||||
string rpkts_desc;
|
string rpkts_desc;
|
||||||
_srs_pps_rpkts->update(); _srs_pps_rrtps->update(); _srs_pps_rstuns->update(); _srs_pps_rrtcps->update();
|
_srs_pps_rpkts->update(); _srs_pps_rrtps->update(); _srs_pps_rstuns->update(); _srs_pps_rrtcps->update();
|
||||||
if (_srs_pps_rpkts->r10s() || _srs_pps_rrtps->r10s() || _srs_pps_rstuns->r10s() || _srs_pps_rrtcps->r10s()) {
|
if (_srs_pps_rpkts->r10s() || _srs_pps_rrtps->r10s() || _srs_pps_rstuns->r10s() || _srs_pps_rrtcps->r10s()) {
|
||||||
|
@ -725,9 +734,9 @@ srs_error_t SrsRtcServer::notify(int type, srs_utime_t interval, srs_utime_t tic
|
||||||
fid_desc = buf;
|
fid_desc = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_trace("RTC: Server conns=%u%s%s%s%s%s%s%s",
|
srs_trace("RTC: Server conns=%u%s%s%s%s%s%s%s%s",
|
||||||
nn_rtc_conns,
|
nn_rtc_conns,
|
||||||
rpkts_desc.c_str(), spkts_desc.c_str(), rtcp_desc.c_str(), snk_desc.c_str(), rnk_desc.c_str(), drop_desc.c_str(), fid_desc.c_str()
|
rpkts_desc.c_str(), spkts_desc.c_str(), rtcp_desc.c_str(), snk_desc.c_str(), rnk_desc.c_str(), drop_desc.c_str(), fid_desc.c_str(), objs_desc.c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
123
trunk/src/kernel/srs_kernel_kbps.cpp
Normal file
123
trunk/src/kernel/srs_kernel_kbps.cpp
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2020 Winlin
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <srs_kernel_kbps.hpp>
|
||||||
|
|
||||||
|
#include <srs_kernel_utility.hpp>
|
||||||
|
|
||||||
|
SrsRateSample::SrsRateSample()
|
||||||
|
{
|
||||||
|
total = time = -1;
|
||||||
|
rate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsRateSample::~SrsRateSample()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsRateSample* SrsRateSample::update(int64_t nn, srs_utime_t t, int k)
|
||||||
|
{
|
||||||
|
total = nn;
|
||||||
|
time = t;
|
||||||
|
rate = k;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void srs_pps_init(SrsRateSample& sample, int64_t nn, srs_utime_t now)
|
||||||
|
{
|
||||||
|
if (sample.time < 0 || nn < sample.total) {
|
||||||
|
sample.update(nn, now, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void srs_pps_update(SrsRateSample& sample, int64_t nn, srs_utime_t now)
|
||||||
|
{
|
||||||
|
int pps = (int)((nn - sample.total) * 1000 / srsu2ms(now - sample.time));
|
||||||
|
if (pps == 0 && nn > sample.total) {
|
||||||
|
pps = 1; // For pps in (0, 1), we set to 1.
|
||||||
|
}
|
||||||
|
sample.update(nn, now, pps);
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsPps::SrsPps(SrsWallClock* c)
|
||||||
|
{
|
||||||
|
clk_ = c;
|
||||||
|
sugar = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsPps::~SrsPps()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsPps::update()
|
||||||
|
{
|
||||||
|
update(sugar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsPps::update(int64_t nn)
|
||||||
|
{
|
||||||
|
srs_utime_t now = clk_->now();
|
||||||
|
|
||||||
|
srs_pps_init(sample_10s_, nn, now);
|
||||||
|
srs_pps_init(sample_30s_, nn, now);
|
||||||
|
srs_pps_init(sample_1m_, nn, now);
|
||||||
|
srs_pps_init(sample_5m_, nn, now);
|
||||||
|
srs_pps_init(sample_60m_, nn, now);
|
||||||
|
|
||||||
|
if (now - sample_10s_.time >= 10 * SRS_UTIME_SECONDS) {
|
||||||
|
srs_pps_update(sample_10s_, nn, now);
|
||||||
|
}
|
||||||
|
if (now - sample_30s_.time >= 30 * SRS_UTIME_SECONDS) {
|
||||||
|
srs_pps_update(sample_30s_, nn, now);
|
||||||
|
}
|
||||||
|
if (now - sample_1m_.time >= 60 * SRS_UTIME_SECONDS) {
|
||||||
|
srs_pps_update(sample_1m_, nn, now);
|
||||||
|
}
|
||||||
|
if (now - sample_5m_.time >= 300 * SRS_UTIME_SECONDS) {
|
||||||
|
srs_pps_update(sample_5m_, nn, now);
|
||||||
|
}
|
||||||
|
if (now - sample_60m_.time >= 3600 * SRS_UTIME_SECONDS) {
|
||||||
|
srs_pps_update(sample_60m_, nn, now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsPps::r10s()
|
||||||
|
{
|
||||||
|
return sample_10s_.rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsWallClock::SrsWallClock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsWallClock::~SrsWallClock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
srs_utime_t SrsWallClock::now()
|
||||||
|
{
|
||||||
|
return srs_get_system_time();
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsWallClock* _srs_clock = new SrsWallClock();
|
||||||
|
|
93
trunk/src/kernel/srs_kernel_kbps.hpp
Normal file
93
trunk/src/kernel/srs_kernel_kbps.hpp
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2020 Winlin
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRS_KERNEL_KBPS_HPP
|
||||||
|
#define SRS_KERNEL_KBPS_HPP
|
||||||
|
|
||||||
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
|
#include <srs_kernel_kbps.hpp>
|
||||||
|
|
||||||
|
class SrsWallClock;
|
||||||
|
|
||||||
|
// A sample for rate-based stat, such as kbps or kps.
|
||||||
|
class SrsRateSample
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int64_t total;
|
||||||
|
srs_utime_t time;
|
||||||
|
// kbps or kps
|
||||||
|
int rate;
|
||||||
|
public:
|
||||||
|
SrsRateSample();
|
||||||
|
virtual ~SrsRateSample();
|
||||||
|
public:
|
||||||
|
virtual SrsRateSample* update(int64_t nn, srs_utime_t t, int k);
|
||||||
|
};
|
||||||
|
|
||||||
|
// A pps manager every some duration.
|
||||||
|
class SrsPps
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
SrsWallClock* clk_;
|
||||||
|
private:
|
||||||
|
// samples
|
||||||
|
SrsRateSample sample_10s_;
|
||||||
|
SrsRateSample sample_30s_;
|
||||||
|
SrsRateSample sample_1m_;
|
||||||
|
SrsRateSample sample_5m_;
|
||||||
|
SrsRateSample sample_60m_;
|
||||||
|
public:
|
||||||
|
// Sugar for target to stat.
|
||||||
|
int64_t sugar;
|
||||||
|
public:
|
||||||
|
SrsPps(SrsWallClock* clk);
|
||||||
|
virtual ~SrsPps();
|
||||||
|
public:
|
||||||
|
// Update with the nn which is target.
|
||||||
|
void update();
|
||||||
|
// Update with the nn.
|
||||||
|
void update(int64_t nn);
|
||||||
|
// Get the 10s average stat.
|
||||||
|
int r10s();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A time source to provide wall clock.
|
||||||
|
*/
|
||||||
|
class SrsWallClock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SrsWallClock();
|
||||||
|
virtual ~SrsWallClock();
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Current time in srs_utime_t.
|
||||||
|
*/
|
||||||
|
virtual srs_utime_t now();
|
||||||
|
};
|
||||||
|
|
||||||
|
// The global clock.
|
||||||
|
extern SrsWallClock* _srs_clock;
|
||||||
|
|
||||||
|
#endif
|
|
@ -34,6 +34,10 @@ using namespace std;
|
||||||
#include <srs_kernel_utility.hpp>
|
#include <srs_kernel_utility.hpp>
|
||||||
#include <srs_kernel_flv.hpp>
|
#include <srs_kernel_flv.hpp>
|
||||||
|
|
||||||
|
#include <srs_kernel_kbps.hpp>
|
||||||
|
|
||||||
|
SrsPps* _srs_pps_objs_rtps = new SrsPps(_srs_clock);
|
||||||
|
|
||||||
/* @see https://tools.ietf.org/html/rfc1889#section-5.1
|
/* @see https://tools.ietf.org/html/rfc1889#section-5.1
|
||||||
0 1 2 3
|
0 1 2 3
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
@ -764,6 +768,8 @@ SrsRtpPacket2::SrsRtpPacket2()
|
||||||
shared_msg = NULL;
|
shared_msg = NULL;
|
||||||
frame_type = SrsFrameTypeReserved;
|
frame_type = SrsFrameTypeReserved;
|
||||||
cached_payload_size = 0;
|
cached_payload_size = 0;
|
||||||
|
|
||||||
|
++_srs_pps_objs_rtps->sugar;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtpPacket2::~SrsRtpPacket2()
|
SrsRtpPacket2::~SrsRtpPacket2()
|
||||||
|
|
|
@ -25,87 +25,6 @@
|
||||||
|
|
||||||
#include <srs_kernel_utility.hpp>
|
#include <srs_kernel_utility.hpp>
|
||||||
|
|
||||||
SrsRateSample::SrsRateSample()
|
|
||||||
{
|
|
||||||
total = time = -1;
|
|
||||||
rate = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsRateSample::~SrsRateSample()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsRateSample* SrsRateSample::update(int64_t nn, srs_utime_t t, int k)
|
|
||||||
{
|
|
||||||
total = nn;
|
|
||||||
time = t;
|
|
||||||
rate = k;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void srs_pps_init(SrsRateSample& sample, int64_t nn, srs_utime_t now)
|
|
||||||
{
|
|
||||||
if (sample.time < 0 || nn < sample.total) {
|
|
||||||
sample.update(nn, now, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void srs_pps_update(SrsRateSample& sample, int64_t nn, srs_utime_t now)
|
|
||||||
{
|
|
||||||
int pps = (int)((nn - sample.total) * 1000 / srsu2ms(now - sample.time));
|
|
||||||
if (pps == 0 && nn > sample.total) {
|
|
||||||
pps = 1; // For pps in (0, 1), we set to 1.
|
|
||||||
}
|
|
||||||
sample.update(nn, now, pps);
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsPps::SrsPps(SrsWallClock* c)
|
|
||||||
{
|
|
||||||
clk_ = c;
|
|
||||||
sugar = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsPps::~SrsPps()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsPps::update()
|
|
||||||
{
|
|
||||||
update(sugar);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsPps::update(int64_t nn)
|
|
||||||
{
|
|
||||||
srs_utime_t now = clk_->now();
|
|
||||||
|
|
||||||
srs_pps_init(sample_10s_, nn, now);
|
|
||||||
srs_pps_init(sample_30s_, nn, now);
|
|
||||||
srs_pps_init(sample_1m_, nn, now);
|
|
||||||
srs_pps_init(sample_5m_, nn, now);
|
|
||||||
srs_pps_init(sample_60m_, nn, now);
|
|
||||||
|
|
||||||
if (now - sample_10s_.time >= 10 * SRS_UTIME_SECONDS) {
|
|
||||||
srs_pps_update(sample_10s_, nn, now);
|
|
||||||
}
|
|
||||||
if (now - sample_30s_.time >= 30 * SRS_UTIME_SECONDS) {
|
|
||||||
srs_pps_update(sample_30s_, nn, now);
|
|
||||||
}
|
|
||||||
if (now - sample_1m_.time >= 60 * SRS_UTIME_SECONDS) {
|
|
||||||
srs_pps_update(sample_1m_, nn, now);
|
|
||||||
}
|
|
||||||
if (now - sample_5m_.time >= 300 * SRS_UTIME_SECONDS) {
|
|
||||||
srs_pps_update(sample_5m_, nn, now);
|
|
||||||
}
|
|
||||||
if (now - sample_60m_.time >= 3600 * SRS_UTIME_SECONDS) {
|
|
||||||
srs_pps_update(sample_60m_, nn, now);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsPps::r10s()
|
|
||||||
{
|
|
||||||
return sample_10s_.rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsKbpsSlice::SrsKbpsSlice(SrsWallClock* c)
|
SrsKbpsSlice::SrsKbpsSlice(SrsWallClock* c)
|
||||||
{
|
{
|
||||||
clk = c;
|
clk = c;
|
||||||
|
@ -166,19 +85,6 @@ ISrsKbpsDelta::~ISrsKbpsDelta()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsWallClock::SrsWallClock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsWallClock::~SrsWallClock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
srs_utime_t SrsWallClock::now()
|
|
||||||
{
|
|
||||||
return srs_get_system_time();
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsKbps::SrsKbps(SrsWallClock* c) : is(c), os(c)
|
SrsKbps::SrsKbps(SrsWallClock* c) : is(c), os(c)
|
||||||
{
|
{
|
||||||
clk = c;
|
clk = c;
|
||||||
|
@ -360,5 +266,3 @@ int SrsKbps::size_memory()
|
||||||
return sizeof(SrsKbps);
|
return sizeof(SrsKbps);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsWallClock* _srs_clock = new SrsWallClock();
|
|
||||||
|
|
||||||
|
|
|
@ -27,50 +27,7 @@
|
||||||
#include <srs_core.hpp>
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
#include <srs_protocol_io.hpp>
|
#include <srs_protocol_io.hpp>
|
||||||
|
#include <srs_kernel_kbps.hpp>
|
||||||
class SrsWallClock;
|
|
||||||
|
|
||||||
// A sample for rate-based stat, such as kbps or kps.
|
|
||||||
class SrsRateSample
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int64_t total;
|
|
||||||
srs_utime_t time;
|
|
||||||
// kbps or kps
|
|
||||||
int rate;
|
|
||||||
public:
|
|
||||||
SrsRateSample();
|
|
||||||
virtual ~SrsRateSample();
|
|
||||||
public:
|
|
||||||
virtual SrsRateSample* update(int64_t nn, srs_utime_t t, int k);
|
|
||||||
};
|
|
||||||
|
|
||||||
// A pps manager every some duration.
|
|
||||||
class SrsPps
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
SrsWallClock* clk_;
|
|
||||||
private:
|
|
||||||
// samples
|
|
||||||
SrsRateSample sample_10s_;
|
|
||||||
SrsRateSample sample_30s_;
|
|
||||||
SrsRateSample sample_1m_;
|
|
||||||
SrsRateSample sample_5m_;
|
|
||||||
SrsRateSample sample_60m_;
|
|
||||||
public:
|
|
||||||
// Sugar for target to stat.
|
|
||||||
int64_t sugar;
|
|
||||||
public:
|
|
||||||
SrsPps(SrsWallClock* clk);
|
|
||||||
virtual ~SrsPps();
|
|
||||||
public:
|
|
||||||
// Update with the nn which is target.
|
|
||||||
void update();
|
|
||||||
// Update with the nn.
|
|
||||||
void update(int64_t nn);
|
|
||||||
// Get the 10s average stat.
|
|
||||||
int r10s();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a slice of kbps statistic, for input or output.
|
* a slice of kbps statistic, for input or output.
|
||||||
|
@ -144,21 +101,6 @@ public:
|
||||||
virtual void remark(int64_t* in, int64_t* out) = 0;
|
virtual void remark(int64_t* in, int64_t* out) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A time source to provide wall clock.
|
|
||||||
*/
|
|
||||||
class SrsWallClock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SrsWallClock();
|
|
||||||
virtual ~SrsWallClock();
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Current time in srs_utime_t.
|
|
||||||
*/
|
|
||||||
virtual srs_utime_t now();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to statistic the kbps of io.
|
* to statistic the kbps of io.
|
||||||
* itself can be a statistic source, for example, used for SRS bytes stat.
|
* itself can be a statistic source, for example, used for SRS bytes stat.
|
||||||
|
@ -258,7 +200,4 @@ public:
|
||||||
virtual int size_memory();
|
virtual int size_memory();
|
||||||
};
|
};
|
||||||
|
|
||||||
// The global clock.
|
|
||||||
extern SrsWallClock* _srs_clock;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue