/* 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 "base/timer.h" class DocumentData; namespace Media { namespace Streaming { class Reader; class Document; } // namespace Streaming } // namespace Media namespace Data { class Session; struct FileOrigin; class Streaming final { public: explicit Streaming(not_null owner); Streaming(const Streaming &other) = delete; Streaming &operator=(const Streaming &other) = delete; ~Streaming(); using Reader = ::Media::Streaming::Reader; using Document = ::Media::Streaming::Document; [[nodiscard]] std::shared_ptr sharedReader( not_null document, FileOrigin origin, bool forceRemoteLoader = false); [[nodiscard]] std::shared_ptr sharedDocument( not_null document, FileOrigin origin); void keepAlive(not_null document); private: void clearKeptAlive(); const not_null _owner; base::flat_map, std::weak_ptr> _readers; base::flat_map< not_null, std::weak_ptr> _documents; base::flat_map, crl::time> _keptAlive; base::Timer _keptAliveTimer; }; } // namespace Data