2019-07-30 14:57:39 +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_player.h"
|
|
|
|
#include "ui/effects/radial_animation.h"
|
|
|
|
#include "ui/effects/animations.h"
|
|
|
|
#include "base/timer.h"
|
|
|
|
|
|
|
|
class DocumentData;
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
namespace Streaming {
|
|
|
|
|
2019-12-11 12:09:21 +00:00
|
|
|
class Instance;
|
2020-05-20 11:04:56 +00:00
|
|
|
class Loader;
|
2019-07-30 14:57:39 +00:00
|
|
|
|
|
|
|
class Document {
|
|
|
|
public:
|
|
|
|
Document(
|
|
|
|
not_null<DocumentData*> document,
|
2019-12-11 10:15:48 +00:00
|
|
|
std::shared_ptr<Reader> reader);
|
2020-07-03 10:48:55 +00:00
|
|
|
Document(
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
std::shared_ptr<Reader> reader);
|
2020-05-20 11:04:56 +00:00
|
|
|
explicit Document(std::unique_ptr<Loader> loader);
|
2019-07-30 14:57:39 +00:00
|
|
|
|
|
|
|
void play(const PlaybackOptions &options);
|
|
|
|
void saveFrameToCover();
|
|
|
|
|
2019-12-11 12:09:21 +00:00
|
|
|
[[nodiscard]] Player &player();
|
|
|
|
[[nodiscard]] const Player &player() const;
|
|
|
|
[[nodiscard]] const Information &info() const;
|
2019-07-30 14:57:39 +00:00
|
|
|
|
|
|
|
[[nodiscard]] bool waitingShown() const;
|
|
|
|
[[nodiscard]] float64 waitingOpacity() const;
|
|
|
|
[[nodiscard]] Ui::RadialState waitingState() const;
|
|
|
|
|
|
|
|
private:
|
2020-07-03 10:48:55 +00:00
|
|
|
Document(
|
|
|
|
std::shared_ptr<Reader> reader,
|
|
|
|
DocumentData *document,
|
|
|
|
PhotoData *photo);
|
2020-05-20 11:04:56 +00:00
|
|
|
|
2019-12-11 12:09:21 +00:00
|
|
|
friend class Instance;
|
|
|
|
|
|
|
|
void registerInstance(not_null<Instance*> instance);
|
|
|
|
void unregisterInstance(not_null<Instance*> instance);
|
2019-12-23 10:27:20 +00:00
|
|
|
void refreshPlayerPriority();
|
2019-12-11 12:09:21 +00:00
|
|
|
|
2019-07-30 14:57:39 +00:00
|
|
|
void waitingCallback();
|
|
|
|
|
|
|
|
void handleUpdate(Update &&update);
|
|
|
|
void handleError(Error &&error);
|
|
|
|
|
|
|
|
void ready(Information &&info);
|
|
|
|
void waitingChange(bool waiting);
|
|
|
|
|
|
|
|
void validateGoodThumbnail();
|
2022-03-30 10:08:36 +00:00
|
|
|
void resubscribe();
|
2019-07-30 14:57:39 +00:00
|
|
|
|
2020-05-20 11:04:56 +00:00
|
|
|
DocumentData *_document = nullptr;
|
2020-07-03 10:48:55 +00:00
|
|
|
PhotoData *_photo = nullptr;
|
2019-07-30 14:57:39 +00:00
|
|
|
Player _player;
|
|
|
|
Information _info;
|
|
|
|
|
2022-03-30 10:08:36 +00:00
|
|
|
rpl::lifetime _subscription;
|
|
|
|
|
2019-07-30 14:57:39 +00:00
|
|
|
bool _waiting = false;
|
|
|
|
mutable Ui::InfiniteRadialAnimation _radial;
|
|
|
|
Ui::Animations::Simple _fading;
|
|
|
|
base::Timer _timer;
|
2019-12-11 12:09:21 +00:00
|
|
|
base::flat_set<not_null<Instance*>> _instances;
|
2019-07-30 14:57:39 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|