1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-12-12 17:17:24 +01:00
libtgvoip/controller/net/PacketSender.h

76 lines
1.5 KiB
C
Raw Normal View History

2020-01-22 12:43:51 +01:00
//
// Created by Grishka on 19/03/2019.
//
#ifndef LIBTGVOIP_PACKETSENDER_H
#define LIBTGVOIP_PACKETSENDER_H
2020-01-25 16:04:52 +01:00
#include "../VoIPController.h"
2020-01-22 12:43:51 +01:00
#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
2020-01-22 12:43:51 +01:00
{
return controller->rttHistory;
}
MessageThread &GetMessageThread()
{
return controller->messageThread;
}
const VoIPController::ProtocolInfo &GetProtocolInfo() const
2020-01-22 12:43:51 +01:00
{
return controller->protocolInfo;
}
void SendStreamFlags(VoIPController::Stream &stm)
{
controller->SendStreamFlags(stm);
}
const VoIPController::Config &GetConfig() const
2020-01-22 12:43:51 +01:00
{
return controller->config;
}
VoIPController *controller;
};
} // namespace tgvoip
#endif //LIBTGVOIP_PACKETSENDER_H