| 6 |
| #define LIBTGVOIP_VIDEOPACKETSENDER_H |
| 7 |
| 8 | #include "../threading.h" |
| 9 | #include "../Buffers.h" |
| 10 | #include "../PacketSender.h" |
| 11 |
| 12 | #include <memory> |
| 13 | #include <cstdint> |
| 14 | #include <vector> |
| 15 |
| 16 | namespace tgvoip |
| 17 | { |
| 18 |
| 19 | namespace video |
| 20 | { |
| 21 |
| 22 | class VideoSource; |
| 23 |
| 24 | class VideoPacketSender : public PacketSender |
| 25 | { |
| 26 | public: |
| 27 | VideoPacketSender(VoIPController* m_controller, VideoSource* videoSource, std::shared_ptr<VoIPController::Stream> stream); |
| 28 | ~VideoPacketSender() override; |
| 29 | void PacketAcknowledged(std::uint32_t seq, double sendTime, double ackTime, PktType type, std::uint32_t size) override; |
| 30 | void PacketLost(std::uint32_t seq, PktType type, std::uint32_t size) override; |
| 31 | void SetSource(VideoSource* m_source); |
| 32 | [[nodiscard]] std::uint32_t GetBitrate() const; |
| 33 |
| 34 | private: |
| 35 | struct SentVideoFrame |
| 36 | { |
| 37 | std::vector<std::uint32_t> unacknowledgedPackets; |
| 38 | std::uint32_t seq; |
| 39 | std::uint32_t fragmentCount; |
| 40 | std::uint32_t fragmentsInQueue; |
| 41 | }; |
| 42 |
| 43 | struct QueuedPacket |
| 44 | { |
| 45 | VoIPController::PendingOutgoingPacket packet; |
| 46 | std::uint32_t seq; |
| 47 | }; |
| 48 |
| 49 | video::ScreamCongestionController m_videoCongestionControl; |
| 50 | std::vector<SentVideoFrame> m_sentVideoFrames; |
| 51 | std::vector<Buffer> m_packetsForFEC; |
| 52 |
| 53 | std::shared_ptr<VoIPController::Stream> m_stm; |
| 54 | VideoSource* m_source = nullptr; |
| 55 |
| 56 | std::size_t m_fecFrameCount = 0; |
| 57 |
| 58 | double m_firstVideoFrameTime = 0.0; |
| 59 | double m_lastVideoResolutionChangeTime = 0.0; |
| 60 | double m_sourceChangeTime = 0.0; |
| 61 |
| 62 | std::uint32_t m_videoFrameCount = 0; |
| 63 | std::uint32_t m_sendVideoPacketID = MessageThread::INVALID_ID; |
| 64 | std::uint32_t m_videoPacketLossCount = 0; |
| 65 | std::uint32_t m_currentVideoBitrate = 0; |
| 66 | std::uint32_t m_frameSeq = 0; |
| 67 |
| 68 | bool m_videoKeyframeRequested = false; |
| 69 |
| 70 | void SendFrame(const Buffer& frame, std::uint32_t flags, std::uint32_t rotation); |
| 71 | InitVideoRes GetVideoResolutionForCurrentBitrate(); |
| 72 | }; |
| 73 |
| 74 | } // namespace video |
| 75 |
| 76 | } // namespace tgvoip |
| 77 |
| 78 | #endif // LIBTGVOIP_VIDEOPACKETSENDER_H |
| 79 |