forked from ZLMediaKit/ZLMediaKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPacketQueue.hpp
46 lines (36 loc) · 1.07 KB
/
PacketQueue.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef ZLMEDIAKIT_SRT_PACKET_QUEUE_H
#define ZLMEDIAKIT_SRT_PACKET_QUEUE_H
#include "Packet.hpp"
#include <algorithm>
#include <list>
#include <map>
#include <memory>
#include <tuple>
#include <utility>
namespace SRT {
// for recv
class PacketQueue {
public:
using Ptr = std::shared_ptr<PacketQueue>;
using LostPair = std::pair<uint32_t, uint32_t>;
PacketQueue(uint32_t max_size, uint32_t init_seq, uint32_t latency);
~PacketQueue() = default;
bool inputPacket(DataPacket::Ptr pkt, std::list<DataPacket::Ptr> &out);
uint32_t timeLatency();
std::list<LostPair> getLostSeq();
size_t getSize();
size_t getExpectedSize();
size_t getAvailableBufferSize();
uint32_t getExpectedSeq();
std::string dump();
bool drop(uint32_t first, uint32_t last, std::list<DataPacket::Ptr> &out);
private:
void tryInsertPkt(DataPacket::Ptr pkt);
private:
uint32_t _pkt_cap;
uint32_t _pkt_latency;
uint32_t _pkt_expected_seq = 0;
std::map<uint32_t, DataPacket::Ptr> _pkt_map;
};
} // namespace SRT
#endif // ZLMEDIAKIT_SRT_PACKET_QUEUE_H