1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-11 16:49:52 +01:00
libtgvoip/controller/net/PacketSender.h
2020-01-25 18:11:15 +01:00

76 lines
1.5 KiB
C++

//
// Created by Grishka on 19/03/2019.
//
#ifndef LIBTGVOIP_PACKETSENDER_H
#define LIBTGVOIP_PACKETSENDER_H
#include "../VoIPController.h"
#include <functional>
#include <stdint.h>
namespace tgvoip
{
class PacketSender
{
public:
PacketSender(VoIPController *controller) : controller(controller){};
virtual ~PacketSender(){};
virtual void PacketAcknowledged(uint32_t seq, double sendTime, double ackTime, uint8_t type, uint32_t size) = 0;
virtual void PacketLost(uint32_t seq, uint8_t type, uint32_t size) = 0;
protected:
void SendExtra(Buffer &data, unsigned char type)
{
controller->SendExtra(data, type);
}
void IncrementUnsentStreamPackets()
{
controller->unsentStreamPackets++;
}
uint32_t SendPacket(VoIPController::PendingOutgoingPacket pkt)
{
uint32_t seq = controller->GenerateOutSeq();
pkt.seq = seq;
controller->SendOrEnqueuePacket(std::move(pkt), true, this);
return seq;
}
double GetConnectionInitTime()
{
return controller->connectionInitTime;
}
const HistoricBuffer<double, 32> &RTTHistory() const
{
return controller->rttHistory;
}
MessageThread &GetMessageThread()
{
return controller->messageThread;
}
const VoIPController::ProtocolInfo &GetProtocolInfo() const
{
return controller->protocolInfo;
}
void SendStreamFlags(VoIPController::Stream &stm)
{
controller->SendStreamFlags(stm);
}
const VoIPController::Config &GetConfig() const
{
return controller->config;
}
VoIPController *controller;
};
} // namespace tgvoip
#endif //LIBTGVOIP_PACKETSENDER_H