1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "media/streaming/media_streaming_common.h" 11 #include "ffmpeg/ffmpeg_utility.h" 12 13 namespace Media { 14 namespace Streaming { 15 16 struct TimePoint { 17 crl::time trackTime = kTimeUnknown; 18 crl::time worldTime = kTimeUnknown; 19 validTimePoint20 bool valid() const { 21 return (trackTime != kTimeUnknown) && (worldTime != kTimeUnknown); 22 } 23 explicit operator bool() const { 24 return valid(); 25 } 26 }; 27 28 struct Stream { 29 int index = -1; 30 crl::time duration = kTimeUnknown; 31 AVRational timeBase = FFmpeg::kUniversalTimeBase; 32 FFmpeg::CodecPointer codec; 33 FFmpeg::FramePointer frame; 34 std::deque<FFmpeg::Packet> queue; 35 int invalidDataPackets = 0; 36 37 // Audio only. 38 int frequency = 0; 39 40 // Video only. 41 int rotation = 0; 42 AVRational aspect = FFmpeg::kNormalAspect; 43 FFmpeg::SwscalePointer swscale; 44 }; 45 46 [[nodiscard]] crl::time FramePosition(const Stream &stream); 47 [[nodiscard]] FFmpeg::AvErrorWrap ProcessPacket( 48 Stream &stream, 49 FFmpeg::Packet &&packet); 50 [[nodiscard]] FFmpeg::AvErrorWrap ReadNextFrame(Stream &stream); 51 52 [[nodiscard]] bool GoodForRequest( 53 const QImage &image, 54 int rotation, 55 const FrameRequest &request); 56 [[nodiscard]] QImage ConvertFrame( 57 Stream &stream, 58 AVFrame *frame, 59 QSize resize, 60 QImage storage); 61 [[nodiscard]] FrameYUV420 ExtractYUV420(Stream &stream, AVFrame *frame); 62 [[nodiscard]] QImage PrepareByRequest( 63 const QImage &original, 64 bool alpha, 65 int rotation, 66 const FrameRequest &request, 67 QImage storage); 68 69 } // namespace Streaming 70 } // namespace Media 71