1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-30 04:39:03 +01:00
libtgvoip/PacketReassembler.h
2019-02-05 14:41:00 +03:00

35 lines
815 B
C++

//
// Created by Grishka on 19.03.2018.
//
#ifndef TGVOIP_PACKETREASSEMBLER_H
#define TGVOIP_PACKETREASSEMBLER_H
#include <vector>
#include <functional>
#include <unordered_map>
#include "Buffers.h"
namespace tgvoip {
class PacketReassembler{
public:
PacketReassembler();
virtual ~PacketReassembler();
void Reset();
void AddFragment(Buffer pkt, unsigned int fragmentIndex, unsigned int fragmentCount, uint32_t pts, bool keyframe);
void SetCallback(std::function<void(Buffer packet, uint32_t pts, bool keyframe)> callback);
private:
uint32_t currentTimestamp;
unsigned int currentPacketPartCount=0;
std::array<Buffer, 255> parts;
std::function<void(Buffer, uint32_t, bool)> callback;
bool currentIsKeyframe;
unsigned int receivedPartCount=0;
};
}
#endif //TGVOIP_PACKETREASSEMBLER_H