2019-03-04 12:26:29 +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_loader.h"
|
|
|
|
#include "mtproto/sender.h"
|
|
|
|
#include "data/data_file_origin.h"
|
|
|
|
|
|
|
|
class ApiWrap;
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
namespace Streaming {
|
|
|
|
|
|
|
|
class LoaderLocal : public Loader, public base::has_weak_ptr {
|
|
|
|
public:
|
|
|
|
LoaderLocal(std::unique_ptr<QIODevice> device);
|
|
|
|
|
2020-05-20 12:28:18 +00:00
|
|
|
[[nodiscard]] Storage::Cache::Key baseCacheKey() const override;
|
2019-03-04 12:26:29 +00:00
|
|
|
[[nodiscard]] int size() const override;
|
|
|
|
|
|
|
|
void load(int offset) override;
|
|
|
|
void cancel(int offset) override;
|
2019-12-23 10:27:20 +00:00
|
|
|
void resetPriorities() override;
|
|
|
|
void setPriority(int priority) override;
|
2019-03-04 12:26:29 +00:00
|
|
|
void stop() override;
|
|
|
|
|
2019-12-23 11:13:32 +00:00
|
|
|
void tryRemoveFromQueue() override;
|
|
|
|
|
2019-03-04 12:26:29 +00:00
|
|
|
// Parts will be sent from the main thread.
|
|
|
|
[[nodiscard]] rpl::producer<LoadedPart> parts() const override;
|
|
|
|
|
2019-04-12 09:25:00 +00:00
|
|
|
void attachDownloader(
|
2019-12-04 06:51:21 +00:00
|
|
|
not_null<Storage::StreamedFileDownloader*> downloader) override;
|
2019-04-12 09:25:00 +00:00
|
|
|
void clearAttachedDownloader() override;
|
|
|
|
|
2019-03-04 12:26:29 +00:00
|
|
|
private:
|
|
|
|
void fail();
|
|
|
|
|
2019-03-20 10:17:40 +00:00
|
|
|
const std::unique_ptr<QIODevice> _device;
|
|
|
|
const int _size = 0;
|
2019-03-04 12:26:29 +00:00
|
|
|
rpl::event_stream<LoadedPart> _parts;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<LoaderLocal> MakeFileLoader(const QString &path);
|
|
|
|
std::unique_ptr<LoaderLocal> MakeBytesLoader(const QByteArray &bytes);
|
|
|
|
|
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|