ZLMediaKit/srt/Statistic.hpp

49 lines
1.1 KiB
C++
Raw Normal View History

2022-06-03 13:25:32 +08:00
#ifndef ZLMEDIAKIT_SRT_STATISTIC_H
#define ZLMEDIAKIT_SRT_STATISTIC_H
#include <map>
#include "Common.hpp"
#include "Packet.hpp"
namespace SRT {
2022-06-07 09:52:20 +08:00
2022-06-03 13:25:32 +08:00
class PacketRecvRateContext {
public:
PacketRecvRateContext(TimePoint start)
: _start(start) {};
2022-06-03 13:25:32 +08:00
~PacketRecvRateContext() = default;
2022-06-07 09:52:20 +08:00
void inputPacket(TimePoint &ts);
2022-06-03 13:25:32 +08:00
uint32_t getPacketRecvRate();
2022-06-07 09:52:20 +08:00
2022-06-03 13:25:32 +08:00
private:
TimePoint _start;
2022-06-07 09:52:20 +08:00
std::map<int64_t, int64_t> _pkt_map;
2022-06-03 13:25:32 +08:00
};
class EstimatedLinkCapacityContext {
public:
2022-06-07 09:52:20 +08:00
EstimatedLinkCapacityContext(TimePoint start) : _start(start) {};
2022-06-03 13:25:32 +08:00
~EstimatedLinkCapacityContext() = default;
2022-06-07 09:52:20 +08:00
void inputPacket(TimePoint &ts);
2022-06-03 13:25:32 +08:00
uint32_t getEstimatedLinkCapacity();
2022-06-07 09:52:20 +08:00
2022-06-03 13:25:32 +08:00
private:
TimePoint _start;
2022-06-07 09:52:20 +08:00
std::map<int64_t, int64_t> _pkt_map;
2022-06-03 13:25:32 +08:00
};
class RecvRateContext {
public:
RecvRateContext(TimePoint start)
: _start(start) {};
2022-06-03 13:25:32 +08:00
~RecvRateContext() = default;
2022-06-07 09:52:20 +08:00
void inputPacket(TimePoint &ts, size_t size);
2022-06-03 13:25:32 +08:00
uint32_t getRecvRate();
2022-06-07 09:52:20 +08:00
2022-06-03 13:25:32 +08:00
private:
2022-06-07 09:52:20 +08:00
TimePoint _start;
std::map<int64_t, size_t> _pkt_map;
2022-06-03 13:25:32 +08:00
};
} // namespace SRT
#endif // ZLMEDIAKIT_SRT_STATISTIC_H