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:
parent
9d08318581
commit
2e56aeba96
2 changed files with 11 additions and 5 deletions
|
@ -31,12 +31,13 @@ using namespace std;
|
|||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
|
||||
SrsStageInfo::SrsStageInfo(int _stage_id)
|
||||
SrsStageInfo::SrsStageInfo(int _stage_id, double ratio)
|
||||
{
|
||||
stage_id = _stage_id;
|
||||
nb_clients = 0;
|
||||
age = 0;
|
||||
nn_count = 0;
|
||||
interval_ratio = ratio;
|
||||
|
||||
update_print_time();
|
||||
|
||||
|
@ -50,7 +51,7 @@ SrsStageInfo::~SrsStageInfo()
|
|||
|
||||
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)
|
||||
|
@ -115,9 +116,10 @@ SrsStageInfo* SrsStageManager::fetch_or_create(int stage_id, bool* pnew)
|
|||
return stage;
|
||||
}
|
||||
|
||||
SrsErrorPithyPrint::SrsErrorPithyPrint()
|
||||
SrsErrorPithyPrint::SrsErrorPithyPrint(double ratio)
|
||||
{
|
||||
nn_count = 0;
|
||||
ratio_ = ratio;
|
||||
}
|
||||
|
||||
SrsErrorPithyPrint::~SrsErrorPithyPrint()
|
||||
|
@ -146,6 +148,7 @@ bool SrsErrorPithyPrint::can_print(int error_code, uint32_t* pnn)
|
|||
// Always and only one client.
|
||||
if (new_stage) {
|
||||
stage->nb_clients = 1;
|
||||
stage->interval_ratio = ratio_;
|
||||
}
|
||||
|
||||
srs_utime_t tick = ticks[error_code];
|
||||
|
|
|
@ -39,10 +39,12 @@ public:
|
|||
int nb_clients;
|
||||
// The number of call of can_print().
|
||||
uint32_t nn_count;
|
||||
// The ratio for interval, 1.0 means no change.
|
||||
double interval_ratio;
|
||||
public:
|
||||
srs_utime_t age;
|
||||
public:
|
||||
SrsStageInfo(int _stage_id);
|
||||
SrsStageInfo(int _stage_id, double ratio = 1.0);
|
||||
virtual ~SrsStageInfo();
|
||||
virtual void update_print_time();
|
||||
public:
|
||||
|
@ -74,10 +76,11 @@ public:
|
|||
// The number of call of can_print().
|
||||
uint32_t nn_count;
|
||||
private:
|
||||
double ratio_;
|
||||
SrsStageManager stages;
|
||||
std::map<int, srs_utime_t> ticks;
|
||||
public:
|
||||
SrsErrorPithyPrint();
|
||||
SrsErrorPithyPrint(double ratio = 1.0);
|
||||
virtual ~SrsErrorPithyPrint();
|
||||
public:
|
||||
// Whether specified stage is ready for print.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue