2019-02-17 06:54:57 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "media/streaming/media_streaming_common.h"
|
2019-06-26 15:04:38 +00:00
|
|
|
#include "ffmpeg/ffmpeg_utility.h"
|
2019-02-17 06:54:57 +00:00
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
namespace Streaming {
|
|
|
|
|
2019-02-21 16:01:55 +00:00
|
|
|
struct TimePoint {
|
2019-02-21 14:57:00 +00:00
|
|
|
crl::time trackTime = kTimeUnknown;
|
|
|
|
crl::time worldTime = kTimeUnknown;
|
|
|
|
|
|
|
|
bool valid() const {
|
|
|
|
return (trackTime != kTimeUnknown) && (worldTime != kTimeUnknown);
|
|
|
|
}
|
|
|
|
explicit operator bool() const {
|
|
|
|
return valid();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-17 06:54:57 +00:00
|
|
|
struct Stream {
|
|
|
|
int index = -1;
|
|
|
|
crl::time duration = kTimeUnknown;
|
2019-06-26 15:04:38 +00:00
|
|
|
AVRational timeBase = FFmpeg::kUniversalTimeBase;
|
|
|
|
FFmpeg::CodecPointer codec;
|
|
|
|
FFmpeg::FramePointer frame;
|
|
|
|
std::deque<FFmpeg::Packet> queue;
|
2019-02-17 06:54:57 +00:00
|
|
|
int invalidDataPackets = 0;
|
|
|
|
|
|
|
|
// Audio only.
|
|
|
|
int frequency = 0;
|
|
|
|
|
|
|
|
// Video only.
|
|
|
|
int rotation = 0;
|
2019-06-26 15:04:38 +00:00
|
|
|
AVRational aspect = FFmpeg::kNormalAspect;
|
|
|
|
FFmpeg::SwscalePointer swscale;
|
2019-02-17 06:54:57 +00:00
|
|
|
};
|
|
|
|
|
2019-02-20 13:28:48 +00:00
|
|
|
[[nodiscard]] crl::time FramePosition(const Stream &stream);
|
2019-06-26 15:04:38 +00:00
|
|
|
[[nodiscard]] FFmpeg::AvErrorWrap ProcessPacket(
|
|
|
|
Stream &stream,
|
|
|
|
FFmpeg::Packet &&packet);
|
|
|
|
[[nodiscard]] FFmpeg::AvErrorWrap ReadNextFrame(Stream &stream);
|
2019-02-22 11:58:26 +00:00
|
|
|
|
2019-02-27 11:36:19 +00:00
|
|
|
[[nodiscard]] bool GoodForRequest(
|
|
|
|
const QImage &image,
|
2019-12-18 17:15:42 +00:00
|
|
|
int rotation,
|
2019-02-27 11:36:19 +00:00
|
|
|
const FrameRequest &request);
|
2019-02-17 06:54:57 +00:00
|
|
|
[[nodiscard]] QImage ConvertFrame(
|
2019-02-28 21:03:25 +00:00
|
|
|
Stream &stream,
|
|
|
|
AVFrame *frame,
|
2019-02-17 06:54:57 +00:00
|
|
|
QSize resize,
|
|
|
|
QImage storage);
|
2021-06-03 12:57:48 +00:00
|
|
|
[[nodiscard]] FrameYUV420 ExtractYUV420(Stream &stream, AVFrame *frame);
|
2019-02-27 11:36:19 +00:00
|
|
|
[[nodiscard]] QImage PrepareByRequest(
|
|
|
|
const QImage &original,
|
2020-02-24 13:48:23 +00:00
|
|
|
bool alpha,
|
2019-12-18 17:15:42 +00:00
|
|
|
int rotation,
|
2019-02-27 11:36:19 +00:00
|
|
|
const FrameRequest &request,
|
|
|
|
QImage storage);
|
2019-02-17 06:54:57 +00:00
|
|
|
|
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|