Statistic.hpp 1.08 KB
Newer Older
1 2 3 4 5 6 7 8
#ifndef ZLMEDIAKIT_SRT_STATISTIC_H
#define ZLMEDIAKIT_SRT_STATISTIC_H
#include <map>

#include "Common.hpp"
#include "Packet.hpp"

namespace SRT {
ziyue committed
9

10 11
class PacketRecvRateContext {
public:
12 13
    PacketRecvRateContext(TimePoint start)
        : _start(start) {};
14
    ~PacketRecvRateContext() = default;
ziyue committed
15
    void inputPacket(TimePoint &ts);
16
    uint32_t getPacketRecvRate();
ziyue committed
17

18
private:
19
    TimePoint _start;
ziyue committed
20
    std::map<int64_t, int64_t> _pkt_map;
21 22 23 24
};

class EstimatedLinkCapacityContext {
public:
ziyue committed
25
    EstimatedLinkCapacityContext(TimePoint start) : _start(start) {};
26
    ~EstimatedLinkCapacityContext() = default;
ziyue committed
27
    void inputPacket(TimePoint &ts);
28
    uint32_t getEstimatedLinkCapacity();
ziyue committed
29

30
private:
31
    TimePoint _start;
ziyue committed
32
    std::map<int64_t, int64_t> _pkt_map;
33 34 35 36
};

class RecvRateContext {
public:
37 38
    RecvRateContext(TimePoint start)
        : _start(start) {};
39
    ~RecvRateContext() = default;
ziyue committed
40
    void inputPacket(TimePoint &ts, size_t size);
41
    uint32_t getRecvRate();
ziyue committed
42

43
private:
ziyue committed
44 45
    TimePoint _start;
    std::map<int64_t, size_t> _pkt_map;
46 47 48 49
};

} // namespace SRT
#endif // ZLMEDIAKIT_SRT_STATISTIC_H