1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

RTC: Support interval ratio for pithy print

This commit is contained in:
winlin 2020-08-12 17:18:51 +08:00
parent 9d08318581
commit 2e56aeba96
2 changed files with 11 additions and 5 deletions

View file

@ -31,12 +31,13 @@ using namespace std;
#include <srs_kernel_error.hpp> #include <srs_kernel_error.hpp>
#include <srs_kernel_utility.hpp> #include <srs_kernel_utility.hpp>
SrsStageInfo::SrsStageInfo(int _stage_id) SrsStageInfo::SrsStageInfo(int _stage_id, double ratio)
{ {
stage_id = _stage_id; stage_id = _stage_id;
nb_clients = 0; nb_clients = 0;
age = 0; age = 0;
nn_count = 0; nn_count = 0;
interval_ratio = ratio;
update_print_time(); update_print_time();
@ -50,7 +51,7 @@ SrsStageInfo::~SrsStageInfo()
void SrsStageInfo::update_print_time() void SrsStageInfo::update_print_time()
{ {
interval = _srs_config->get_pithy_print(); interval = (srs_utime_t)(interval_ratio * _srs_config->get_pithy_print());
} }
void SrsStageInfo::elapse(srs_utime_t diff) void SrsStageInfo::elapse(srs_utime_t diff)
@ -115,9 +116,10 @@ SrsStageInfo* SrsStageManager::fetch_or_create(int stage_id, bool* pnew)
return stage; return stage;
} }
SrsErrorPithyPrint::SrsErrorPithyPrint() SrsErrorPithyPrint::SrsErrorPithyPrint(double ratio)
{ {
nn_count = 0; nn_count = 0;
ratio_ = ratio;
} }
SrsErrorPithyPrint::~SrsErrorPithyPrint() SrsErrorPithyPrint::~SrsErrorPithyPrint()
@ -146,6 +148,7 @@ bool SrsErrorPithyPrint::can_print(int error_code, uint32_t* pnn)
// Always and only one client. // Always and only one client.
if (new_stage) { if (new_stage) {
stage->nb_clients = 1; stage->nb_clients = 1;
stage->interval_ratio = ratio_;
} }
srs_utime_t tick = ticks[error_code]; srs_utime_t tick = ticks[error_code];

View file

@ -39,10 +39,12 @@ public:
int nb_clients; int nb_clients;
// The number of call of can_print(). // The number of call of can_print().
uint32_t nn_count; uint32_t nn_count;
// The ratio for interval, 1.0 means no change.
double interval_ratio;
public: public:
srs_utime_t age; srs_utime_t age;
public: public:
SrsStageInfo(int _stage_id); SrsStageInfo(int _stage_id, double ratio = 1.0);
virtual ~SrsStageInfo(); virtual ~SrsStageInfo();
virtual void update_print_time(); virtual void update_print_time();
public: public:
@ -74,10 +76,11 @@ public:
// The number of call of can_print(). // The number of call of can_print().
uint32_t nn_count; uint32_t nn_count;
private: private:
double ratio_;
SrsStageManager stages; SrsStageManager stages;
std::map<int, srs_utime_t> ticks; std::map<int, srs_utime_t> ticks;
public: public:
SrsErrorPithyPrint(); SrsErrorPithyPrint(double ratio = 1.0);
virtual ~SrsErrorPithyPrint(); virtual ~SrsErrorPithyPrint();
public: public:
// Whether specified stage is ready for print. // Whether specified stage is ready for print.