mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Kernel: Never depends on another globals for global variables
This commit is contained in:
parent
20df644a05
commit
1909cfb3ff
11 changed files with 88 additions and 76 deletions
|
@ -59,9 +59,9 @@ void srs_pps_update(SrsRateSample& sample, int64_t nn, srs_utime_t now)
|
|||
sample.update(nn, now, pps);
|
||||
}
|
||||
|
||||
SrsPps::SrsPps(SrsWallClock* c)
|
||||
SrsPps::SrsPps()
|
||||
{
|
||||
clk_ = c;
|
||||
clk_ = NULL;
|
||||
sugar = 0;
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,11 @@ SrsPps::~SrsPps()
|
|||
{
|
||||
}
|
||||
|
||||
void SrsPps::set_clock(SrsWallClock* clk)
|
||||
{
|
||||
clk_ = clk;
|
||||
}
|
||||
|
||||
void SrsPps::update()
|
||||
{
|
||||
update(sugar);
|
||||
|
@ -76,6 +81,11 @@ void SrsPps::update()
|
|||
|
||||
void SrsPps::update(int64_t nn)
|
||||
{
|
||||
// Lazy setup the clock.
|
||||
if (!clk_) {
|
||||
clk_ = _srs_clock;
|
||||
}
|
||||
|
||||
srs_utime_t now = clk_->now();
|
||||
|
||||
srs_pps_init(sample_10s_, nn, now);
|
||||
|
|
|
@ -61,9 +61,11 @@ public:
|
|||
// Sugar for target to stat.
|
||||
int64_t sugar;
|
||||
public:
|
||||
SrsPps(SrsWallClock* clk);
|
||||
SrsPps();
|
||||
virtual ~SrsPps();
|
||||
public:
|
||||
// Setup the clock, use global clock if not set.
|
||||
void set_clock(SrsWallClock* clk);
|
||||
// Update with the nn which is target.
|
||||
void update();
|
||||
// Update with the nn.
|
||||
|
|
|
@ -36,7 +36,7 @@ using namespace std;
|
|||
|
||||
#include <srs_kernel_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_objs_rtps = new SrsPps(_srs_clock);
|
||||
SrsPps* _srs_pps_objs_rtps = new SrsPps();
|
||||
|
||||
/* @see https://tools.ietf.org/html/rfc1889#section-5.1
|
||||
0 1 2 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue