tdesktop/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtpr...

67 lines
1.7 KiB
C
Raw Normal View History

/*
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_loader.h"
#include "mtproto/sender.h"
#include "data/data_file_origin.h"
#include "storage/download_manager_mtproto.h"
namespace Media {
namespace Streaming {
class LoaderMtproto : public Loader, public Storage::DownloadMtprotoTask {
public:
LoaderMtproto(
not_null<Storage::DownloadManagerMtproto*> owner,
const StorageFileLocation &location,
2022-05-10 14:22:28 +00:00
int64 size,
Data::FileOrigin origin);
[[nodiscard]] Storage::Cache::Key baseCacheKey() const override;
2022-05-10 14:22:28 +00:00
[[nodiscard]] int64 size() const override;
2022-05-10 14:22:28 +00:00
void load(int64 offset) override;
void cancel(int64 offset) override;
void resetPriorities() override;
void setPriority(int priority) override;
void stop() override;
void tryRemoveFromQueue() override;
// Parts will be sent from the main thread.
[[nodiscard]] rpl::producer<LoadedPart> parts() const override;
void attachDownloader(
not_null<Storage::StreamedFileDownloader*> downloader) override;
void clearAttachedDownloader() override;
private:
bool readyToRequest() const override;
2022-05-10 14:22:28 +00:00
int64 takeNextRequestOffset() override;
bool feedPart(int64 offset, const QByteArray &bytes) override;
void cancelOnFail() override;
2022-05-10 14:22:28 +00:00
void cancelForOffset(int64 offset);
2019-12-23 09:37:03 +00:00
void addToQueueWithPriority();
2022-05-10 14:22:28 +00:00
const int64 _size = 0;
int _priority = 0;
2019-11-27 08:02:56 +00:00
MTP::Sender _api;
PriorityQueue _requested;
rpl::event_stream<LoadedPart> _parts;
Storage::StreamedFileDownloader *_downloader = nullptr;
};
} // namespace Streaming
} // namespace Media