tdesktop/Telegram/SourceFiles/media/streaming/media_streaming_utility.h

70 lines
1.6 KiB
C
Raw Normal View History

/*
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"
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();
}
};
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;
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;
};
[[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);
[[nodiscard]] QImage ConvertFrame(
2019-02-28 21:03:25 +00:00
Stream &stream,
AVFrame *frame,
QSize resize,
QImage storage);
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);
} // namespace Streaming
} // namespace Media