/* 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 "lottie/lottie_player.h" #include "base/timer.h" #include "base/algorithm.h" #include namespace Lottie { class Animation; class FrameRenderer; struct MultiUpdate { //base::variant< // std::pair, // DisplayMultiFrameRequest, // std::pair> data; }; std::shared_ptr MakeFrameRenderer(); class MultiPlayer final : public Player { public: explicit MultiPlayer(std::shared_ptr renderer = nullptr); ~MultiPlayer(); void start( not_null animation, std::unique_ptr state) override; void failed(not_null animation, Error error) override; void updateFrameRequest( not_null animation, const FrameRequest &request) override; void markFrameShown() override; void checkStep() override; not_null append( FnMut)> get, // Main thread. FnMut put, // Unknown thread. const QByteArray &content, const FrameRequest &request); not_null append( const QByteArray &content, const FrameRequest &request); rpl::producer updates() const; void remove(not_null animation); private: crl::time startAtRightTime(not_null state); void markFrameDisplayed(crl::time now, crl::time delayed); void checkNextFrameAvailability(); void checkNextFrameRender(); base::Timer _timer; const std::shared_ptr _renderer; std::vector> _animations; base::flat_map, not_null> _active; //base::flat_map, not_null> _paused; crl::time _started = kTimeUnknown; crl::time _accumulatedDelay = 0; crl::time _nextFrameTime = kTimeUnknown; rpl::event_stream _updates; rpl::lifetime _lifetime; }; } // namespace Lottie