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

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

namespace SRT {
class PacketRecvRateContext {
public:
11
    PacketRecvRateContext(TimePoint start);
12
    ~PacketRecvRateContext() = default;
13 14
    void inputPacket(TimePoint &ts,size_t len = 0);
    uint32_t getPacketRecvRate(uint32_t& bytesps);
xiongguangjie committed
15
    std::string dump();
16
    static const int SIZE = 16;
17
private:
18 19 20 21 22
    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;
23 24 25 26
};

class EstimatedLinkCapacityContext {
public:
27
    EstimatedLinkCapacityContext(TimePoint start);
28
    ~EstimatedLinkCapacityContext() = default;
29 30 31 32
    void setLastSeq(uint32_t seq){
        _last_seq = seq;
    }
    void inputPacket(TimePoint &ts,DataPacket::Ptr& pkt);
33
    uint32_t getEstimatedLinkCapacity();
xiongguangjie committed
34
    static const int SIZE = 64;
35 36 37
private:
    void probe1Arrival(TimePoint &ts,const DataPacket::Ptr& pkt, bool unordered);
    void probe2Arrival(TimePoint &ts,const DataPacket::Ptr& pkt);
38
private:
39
    TimePoint _start;
40 41 42 43 44 45
    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;
46 47
};

48
/*
49 50
class RecvRateContext {
public:
51 52
    RecvRateContext(TimePoint start)
        : _start(start) {};
53
    ~RecvRateContext() = default;
ziyue committed
54
    void inputPacket(TimePoint &ts, size_t size);
55
    uint32_t getRecvRate();
ziyue committed
56

57
private:
ziyue committed
58 59
    TimePoint _start;
    std::map<int64_t, size_t> _pkt_map;
60
};
61
*/
62 63
} // namespace SRT
#endif // ZLMEDIAKIT_SRT_STATISTIC_H