2016-06-24 10:37:29 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2016-06-24 10:37:29 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "media/media_clip_implementation.h"
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
namespace Clip {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class QtGifReaderImplementation : public ReaderImplementation {
|
|
|
|
public:
|
|
|
|
|
|
|
|
QtGifReaderImplementation(FileLocation *location, QByteArray *data);
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
ReadResult readFramesTill(TimeMs frameMs, TimeMs systemMs) override;
|
2016-07-13 11:24:31 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
TimeMs frameRealTime() const override;
|
|
|
|
TimeMs framePresentationTime() const override;
|
2016-07-13 11:24:31 +00:00
|
|
|
|
2016-06-24 10:37:29 +00:00
|
|
|
bool renderFrame(QImage &to, bool &hasAlpha, const QSize &size) override;
|
2016-07-13 11:24:31 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
TimeMs durationMs() const override;
|
2016-07-12 18:04:34 +00:00
|
|
|
bool hasAudio() const override {
|
|
|
|
return false;
|
|
|
|
}
|
2016-07-13 11:24:31 +00:00
|
|
|
void pauseAudio() override {
|
|
|
|
}
|
|
|
|
void resumeAudio() override {
|
|
|
|
}
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
bool start(Mode mode, TimeMs &positionMs) override;
|
2016-06-24 10:37:29 +00:00
|
|
|
|
|
|
|
~QtGifReaderImplementation();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool jumpToStart();
|
2016-07-12 18:04:34 +00:00
|
|
|
ReadResult readNextFrame();
|
|
|
|
|
|
|
|
Mode _mode = Mode::Normal;
|
2016-06-24 10:37:29 +00:00
|
|
|
|
2017-03-09 09:47:45 +00:00
|
|
|
std::unique_ptr<QImageReader> _reader;
|
2016-06-24 10:37:29 +00:00
|
|
|
int _framesLeft = 0;
|
2016-12-01 19:20:33 +00:00
|
|
|
TimeMs _frameRealTime = 0;
|
|
|
|
TimeMs _frameTime = 0;
|
2016-06-24 10:37:29 +00:00
|
|
|
int _frameDelay = 0;
|
|
|
|
QImage _frame;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace Clip
|
|
|
|
} // namespace Media
|