2016-06-24 10:37:29 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-06-24 10:37:29 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-06-24 10:37:29 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
#include <QtCore/QBuffer>
|
|
|
|
|
2020-10-13 16:43:18 +00:00
|
|
|
namespace Core {
|
2016-06-24 10:37:29 +00:00
|
|
|
class FileLocation;
|
2020-10-13 16:43:18 +00:00
|
|
|
} // namespace Core
|
2016-06-24 10:37:29 +00:00
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
namespace Clip {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class ReaderImplementation {
|
|
|
|
public:
|
2020-10-13 16:43:18 +00:00
|
|
|
ReaderImplementation(Core::FileLocation *location, QByteArray *data)
|
|
|
|
: _location(location)
|
|
|
|
, _data(data) {
|
2016-06-24 10:37:29 +00:00
|
|
|
}
|
2016-07-05 17:43:30 +00:00
|
|
|
enum class Mode {
|
|
|
|
Silent,
|
2017-03-09 09:47:45 +00:00
|
|
|
Inspecting, // Not playing video, but reading data.
|
2016-07-05 17:43:30 +00:00
|
|
|
};
|
2016-07-10 19:44:55 +00:00
|
|
|
|
2016-07-12 18:04:34 +00:00
|
|
|
enum class ReadResult {
|
|
|
|
Success,
|
|
|
|
Error,
|
2016-07-30 10:03:44 +00:00
|
|
|
EndOfFile,
|
2016-07-12 18:04:34 +00:00
|
|
|
};
|
2019-02-19 06:57:53 +00:00
|
|
|
// Read frames till current frame will have presentation time > frameMs, systemMs = crl::now().
|
|
|
|
virtual ReadResult readFramesTill(crl::time frameMs, crl::time systemMs) = 0;
|
2016-07-10 19:44:55 +00:00
|
|
|
|
2016-07-12 12:28:07 +00:00
|
|
|
// Get current frame real and presentation time.
|
2019-02-19 06:57:53 +00:00
|
|
|
virtual crl::time frameRealTime() const = 0;
|
|
|
|
virtual crl::time framePresentationTime() const = 0;
|
2016-07-10 19:44:55 +00:00
|
|
|
|
|
|
|
// Render current frame to an image with specific size.
|
2016-06-24 10:37:29 +00:00
|
|
|
virtual bool renderFrame(QImage &to, bool &hasAlpha, const QSize &size) = 0;
|
2016-07-10 19:44:55 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
virtual crl::time durationMs() const = 0;
|
2016-07-12 12:28:07 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
virtual bool start(Mode mode, crl::time &positionMs) = 0;
|
2017-03-09 09:47:45 +00:00
|
|
|
|
2016-06-24 10:37:29 +00:00
|
|
|
virtual ~ReaderImplementation() {
|
|
|
|
}
|
|
|
|
int64 dataSize() const {
|
|
|
|
return _dataSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-10-13 16:43:18 +00:00
|
|
|
Core::FileLocation *_location = nullptr;
|
|
|
|
QByteArray *_data = nullptr;
|
2016-06-24 10:37:29 +00:00
|
|
|
QFile _file;
|
|
|
|
QBuffer _buffer;
|
|
|
|
QIODevice *_device = nullptr;
|
|
|
|
int64 _dataSize = 0;
|
|
|
|
|
|
|
|
void initDevice();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace Clip
|
|
|
|
} // namespace Media
|