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

RTC: Use error pithy print to reduce dup logs

This commit is contained in:
winlin 2020-07-22 15:51:48 +08:00
parent c2c35a7330
commit c115f77038
3 changed files with 118 additions and 18 deletions

View file

@ -26,6 +26,8 @@
#include <srs_core.hpp>
#include <map>
#include <srs_app_reload.hpp>
// The stage info to calc the age.
@ -48,6 +50,35 @@ public:
virtual srs_error_t on_reload_pithy_print();
};
// The manager for stages, it's used for a single client stage.
// Of course, we can add the multiple user support, which is SrsPithyPrint.
class SrsStageManager
{
private:
std::map<int, SrsStageInfo*> stages;
public:
SrsStageManager();
virtual ~SrsStageManager();
public:
// Fetch a stage, create one if not exists.
SrsStageInfo* fetch_or_create(int stage_id, bool* pnew = NULL);
};
// The error pithy print is a single client stage manager, each stage only has one client.
// For example, we use it for error pithy print for each UDP packet processing.
class SrsErrorPithyPrint
{
private:
SrsStageManager stages;
std::map<int, srs_utime_t> ticks;
public:
SrsErrorPithyPrint();
virtual ~SrsErrorPithyPrint();
public:
// Whether specified stage is ready for print.
bool can_print(srs_error_t err);
};
// 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.