mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Add alone pithy print
This commit is contained in:
parent
e67207f4b1
commit
c2229d392a
2 changed files with 38 additions and 0 deletions
|
@ -165,6 +165,30 @@ bool SrsErrorPithyPrint::can_print(int error_code, uint32_t* pnn)
|
|||
return new_stage || stage->can_print();
|
||||
}
|
||||
|
||||
SrsAlonePithyPrint::SrsAlonePithyPrint() : info_(0)
|
||||
{
|
||||
previous_tick_ = srs_get_system_time();
|
||||
}
|
||||
|
||||
SrsAlonePithyPrint::~SrsAlonePithyPrint()
|
||||
{
|
||||
}
|
||||
|
||||
void SrsAlonePithyPrint::elapse()
|
||||
{
|
||||
srs_utime_t diff = srs_get_system_time() - previous_tick_;
|
||||
previous_tick_ = srs_get_system_time();
|
||||
|
||||
diff = srs_max(0, diff);
|
||||
|
||||
info_.elapse(diff);
|
||||
}
|
||||
|
||||
bool SrsAlonePithyPrint::can_print()
|
||||
{
|
||||
return info_.can_print();
|
||||
}
|
||||
|
||||
// The global stage manager for pithy print, multiple stages.
|
||||
static SrsStageManager* _srs_stages = new SrsStageManager();
|
||||
|
||||
|
|
|
@ -89,6 +89,20 @@ public:
|
|||
bool can_print(int err, uint32_t* pnn = NULL);
|
||||
};
|
||||
|
||||
// An standalone pithy print, without shared stages.
|
||||
class SrsAlonePithyPrint
|
||||
{
|
||||
private:
|
||||
SrsStageInfo info_;
|
||||
srs_utime_t previous_tick_;
|
||||
public:
|
||||
SrsAlonePithyPrint();
|
||||
virtual ~SrsAlonePithyPrint();
|
||||
public:
|
||||
virtual void elapse();
|
||||
virtual bool can_print();
|
||||
};
|
||||
|
||||
// The stage is used for a collection of object to do print,
|
||||
// the print time in a stage is constant and not changed,
|
||||
// that is, we always got one message to print every specified time.
|
||||
|
|
Loading…
Reference in a new issue