ZLMediaKit/srt/Statistic.hpp

63 lines
1.6 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 {
class PacketRecvRateContext {
public:
PacketRecvRateContext(TimePoint start);
2022-06-03 13:25:32 +08:00
~PacketRecvRateContext() = default;
void inputPacket(TimePoint &ts,size_t len = 0);
uint32_t getPacketRecvRate(uint32_t& bytesps);
2022-09-22 01:07:10 +08:00
std::string dump();
static const int SIZE = 16;
2022-06-03 13:25:32 +08:00
private:
TimePoint _last_arrive_time;
int64_t _ts_arr[SIZE];
size_t _size_arr[SIZE];
size_t _cur_idx;
//std::map<int64_t, int64_t> _pkt_map;
2022-06-03 13:25:32 +08:00
};
class EstimatedLinkCapacityContext {
public:
EstimatedLinkCapacityContext(TimePoint start);
2022-06-03 13:25:32 +08:00
~EstimatedLinkCapacityContext() = default;
void setLastSeq(uint32_t seq){
_last_seq = seq;
}
void inputPacket(TimePoint &ts,DataPacket::Ptr& pkt);
2022-06-03 13:25:32 +08:00
uint32_t getEstimatedLinkCapacity();
2022-09-22 01:07:10 +08:00
static const int SIZE = 64;
private:
void probe1Arrival(TimePoint &ts,const DataPacket::Ptr& pkt, bool unordered);
void probe2Arrival(TimePoint &ts,const DataPacket::Ptr& pkt);
2022-06-03 13:25:32 +08:00
private:
TimePoint _start;
TimePoint _ts_probe_time;
int64_t _dur_probe_arr[SIZE];
size_t _cur_idx;
uint32_t _last_seq = 0;
uint32_t _probe1_seq = SEQ_NONE;
//std::map<int64_t, int64_t> _pkt_map;
2022-06-03 13:25:32 +08:00
};
/*
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
};
*/
2022-06-03 13:25:32 +08:00
} // namespace SRT
#endif // ZLMEDIAKIT_SRT_STATISTIC_H