2019-04-15 01:43:10 +02:00
|
|
|
//
|
|
|
|
// Created by Grishka on 19/03/2019.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef LIBTGVOIP_VIDEOPACKETSENDER_H
|
|
|
|
#define LIBTGVOIP_VIDEOPACKETSENDER_H
|
|
|
|
|
2020-03-21 21:33:51 +01:00
|
|
|
#include "../controller/protocol/packets/PacketSender.h"
|
2020-01-22 12:51:17 +01:00
|
|
|
#include "../tools/Buffers.h"
|
2020-03-25 15:49:13 +01:00
|
|
|
#include "../tools/MessageThread.h"
|
2020-01-22 12:51:17 +01:00
|
|
|
#include "../tools/threading.h"
|
2020-03-25 15:49:13 +01:00
|
|
|
#include "ScreamCongestionController.h"
|
2019-04-15 01:43:10 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-01-25 18:11:15 +01:00
|
|
|
namespace tgvoip
|
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
|
|
|
class VideoSource;
|
2019-04-15 01:43:10 +02:00
|
|
|
|
2020-01-25 18:11:15 +01:00
|
|
|
class VideoPacketSender : public PacketSender
|
|
|
|
{
|
|
|
|
public:
|
2020-03-26 20:37:25 +01:00
|
|
|
VideoPacketSender(VoIPController *controller, std::shared_ptr<OutgoingVideoStream> stream, VideoSource *videoSource);
|
2020-03-25 15:49:13 +01:00
|
|
|
virtual ~VideoPacketSender();
|
|
|
|
virtual void PacketAcknowledged(const RecentOutgoingPacket &packet) override;
|
|
|
|
virtual void PacketLost(const RecentOutgoingPacket &packet) override;
|
|
|
|
void SetSource(VideoSource *source);
|
2019-04-15 01:43:10 +02:00
|
|
|
|
2020-03-25 15:49:13 +01:00
|
|
|
uint32_t GetBitrate()
|
|
|
|
{
|
|
|
|
return currentVideoBitrate;
|
|
|
|
}
|
2019-04-15 01:43:10 +02:00
|
|
|
|
2020-01-25 18:11:15 +01:00
|
|
|
private:
|
2020-03-25 15:49:13 +01:00
|
|
|
struct SentVideoFrame
|
|
|
|
{
|
|
|
|
uint32_t seq;
|
|
|
|
uint32_t fragmentCount;
|
|
|
|
std::vector<uint32_t> unacknowledgedPackets;
|
|
|
|
uint32_t fragmentsInQueue;
|
|
|
|
};
|
2019-04-15 01:43:10 +02:00
|
|
|
|
2020-03-25 15:49:13 +01:00
|
|
|
void SendFrame(const Buffer &frame, uint32_t flags, uint32_t rotation);
|
|
|
|
int GetVideoResolutionForCurrentBitrate();
|
2019-04-15 01:43:10 +02:00
|
|
|
|
2020-03-25 15:49:13 +01:00
|
|
|
VideoSource *source = NULL;
|
|
|
|
video::ScreamCongestionController videoCongestionControl;
|
|
|
|
double firstVideoFrameTime = 0.0;
|
|
|
|
uint32_t videoFrameCount = 0;
|
|
|
|
std::vector<SentVideoFrame> sentVideoFrames;
|
|
|
|
bool videoKeyframeRequested = false;
|
|
|
|
uint32_t sendVideoPacketID = MessageThread::INVALID_ID;
|
|
|
|
uint32_t videoPacketLossCount = 0;
|
|
|
|
uint32_t currentVideoBitrate = 0;
|
|
|
|
double lastVideoResolutionChangeTime = 0.0;
|
|
|
|
double sourceChangeTime = 0.0;
|
2019-04-15 01:43:10 +02:00
|
|
|
|
2020-03-26 20:37:25 +01:00
|
|
|
std::shared_ptr<OutgoingVideoStream> stream;
|
2020-03-25 15:49:13 +01:00
|
|
|
|
|
|
|
std::vector<Buffer>
|
|
|
|
packetsForFEC;
|
|
|
|
size_t fecFrameCount = 0;
|
|
|
|
uint32_t frameSeq = 0;
|
2020-01-25 18:11:15 +01:00
|
|
|
};
|
|
|
|
} // namespace video
|
|
|
|
} // namespace tgvoip
|
2019-04-15 01:43:10 +02:00
|
|
|
|
|
|
|
#endif //LIBTGVOIP_VIDEOPACKETSENDER_H
|