PacketSendQueue.hpp 889 Bytes
Newer Older
1 2
#ifndef ZLMEDIAKIT_SRT_PACKET_SEND_QUEUE_H
#define ZLMEDIAKIT_SRT_PACKET_SEND_QUEUE_H
ziyue committed
3

4 5 6 7 8 9 10
#include "Packet.hpp"
#include <algorithm>
#include <list>
#include <memory>
#include <set>
#include <tuple>
#include <utility>
ziyue committed
11

12
namespace SRT {
ziyue committed
13

14 15 16 17
class PacketSendQueue {
public:
    using Ptr = std::shared_ptr<PacketSendQueue>;
    using LostPair = std::pair<uint32_t, uint32_t>;
ziyue committed
18

19
    PacketSendQueue(uint32_t max_size, uint32_t latency,uint32_t flag = 0xbf);
20
    ~PacketSendQueue() = default;
ziyue committed
21

22 23
    bool drop(uint32_t num);
    bool inputPacket(DataPacket::Ptr pkt);
ziyue committed
24 25
    std::list<DataPacket::Ptr> findPacketBySeq(uint32_t start, uint32_t end);

26
private:
ziyue committed
27
    uint32_t timeLatency();
28
    bool TLPKTDrop();
29
private:
30
    uint32_t _srt_flag;
31
    uint32_t _pkt_cap;
ziyue committed
32 33
    uint32_t _pkt_latency;
    std::list<DataPacket::Ptr> _pkt_cache;
34
};
ziyue committed
35

36 37 38
} // namespace SRT

#endif // ZLMEDIAKIT_SRT_PACKET_SEND_QUEUE_H