2022-06-03 13:25:32 +08:00
|
|
|
|
#ifndef ZLMEDIAKIT_SRT_PACKET_QUEUE_H
|
|
|
|
|
#define ZLMEDIAKIT_SRT_PACKET_QUEUE_H
|
2022-06-05 11:07:42 +08:00
|
|
|
|
#include "Packet.hpp"
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <list>
|
2022-06-03 13:25:32 +08:00
|
|
|
|
#include <map>
|
2022-06-06 20:40:04 +08:00
|
|
|
|
#include <memory>
|
2022-06-03 13:25:32 +08:00
|
|
|
|
#include <tuple>
|
2022-06-05 11:07:42 +08:00
|
|
|
|
#include <utility>
|
2022-06-03 13:25:32 +08:00
|
|
|
|
|
2022-06-05 11:07:42 +08:00
|
|
|
|
namespace SRT {
|
2022-06-03 13:25:32 +08:00
|
|
|
|
|
2022-06-05 11:07:42 +08:00
|
|
|
|
// for recv
|
|
|
|
|
class PacketQueue {
|
2022-06-03 13:25:32 +08:00
|
|
|
|
public:
|
|
|
|
|
using Ptr = std::shared_ptr<PacketQueue>;
|
2022-06-05 11:07:42 +08:00
|
|
|
|
using LostPair = std::pair<uint32_t, uint32_t>;
|
2022-06-03 13:25:32 +08:00
|
|
|
|
|
2022-06-05 11:07:42 +08:00
|
|
|
|
PacketQueue(uint32_t max_size, uint32_t init_seq, uint32_t lantency);
|
2022-06-03 13:25:32 +08:00
|
|
|
|
~PacketQueue() = default;
|
2022-06-06 20:40:04 +08:00
|
|
|
|
bool inputPacket(DataPacket::Ptr pkt, std::list<DataPacket::Ptr> &out);
|
2022-06-05 11:07:42 +08:00
|
|
|
|
|
2022-06-03 13:25:32 +08:00
|
|
|
|
uint32_t timeLantency();
|
|
|
|
|
std::list<LostPair> getLostSeq();
|
|
|
|
|
|
|
|
|
|
size_t getSize();
|
|
|
|
|
size_t getExpectedSize();
|
|
|
|
|
size_t getAvailableBufferSize();
|
|
|
|
|
uint32_t getExpectedSeq();
|
|
|
|
|
|
2022-06-06 20:40:04 +08:00
|
|
|
|
bool drop(uint32_t first, uint32_t last, std::list<DataPacket::Ptr> &out);
|
2022-06-03 22:47:52 +08:00
|
|
|
|
|
2022-06-05 11:07:42 +08:00
|
|
|
|
std::string dump();
|
2022-06-06 20:40:04 +08:00
|
|
|
|
|
2022-06-03 13:25:32 +08:00
|
|
|
|
private:
|
2022-06-05 11:07:42 +08:00
|
|
|
|
void tryInsertPkt(DataPacket::Ptr pkt);
|
|
|
|
|
|
2022-06-06 20:40:04 +08:00
|
|
|
|
private:
|
2022-06-05 11:07:42 +08:00
|
|
|
|
std::map<uint32_t, DataPacket::Ptr> _pkt_map;
|
2022-06-03 13:25:32 +08:00
|
|
|
|
|
|
|
|
|
uint32_t _pkt_expected_seq = 0;
|
|
|
|
|
uint32_t _pkt_cap;
|
|
|
|
|
uint32_t _pkt_lantency;
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-05 11:07:42 +08:00
|
|
|
|
} // namespace SRT
|
2022-06-03 13:25:32 +08:00
|
|
|
|
|
2022-06-05 11:07:42 +08:00
|
|
|
|
#endif // ZLMEDIAKIT_SRT_PACKET_QUEUE_H
|