2019-02-13 18:10:18 +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 LoaderMtproto : public Loader, public base::has_weak_ptr {
|
|
|
|
public:
|
|
|
|
LoaderMtproto(
|
|
|
|
not_null<ApiWrap*> api,
|
2019-03-25 09:17:47 +00:00
|
|
|
const StorageFileLocation &location,
|
2019-02-13 18:10:18 +00:00
|
|
|
int size,
|
|
|
|
Data::FileOrigin origin);
|
|
|
|
|
2019-02-25 17:26:08 +00:00
|
|
|
[[nodiscard]] auto baseCacheKey() const
|
|
|
|
-> std::optional<Storage::Cache::Key> override;
|
2019-02-13 18:10:18 +00:00
|
|
|
[[nodiscard]] int size() const override;
|
|
|
|
|
2019-02-25 17:26:08 +00:00
|
|
|
void load(int offset) override;
|
|
|
|
void cancel(int offset) override;
|
|
|
|
void increasePriority() override;
|
2019-02-13 18:10:18 +00:00
|
|
|
void stop() override;
|
|
|
|
|
|
|
|
// Parts will be sent from the main thread.
|
|
|
|
[[nodiscard]] rpl::producer<LoadedPart> parts() const override;
|
|
|
|
|
|
|
|
~LoaderMtproto();
|
|
|
|
|
|
|
|
private:
|
2019-02-25 17:26:08 +00:00
|
|
|
void sendNext();
|
2019-02-13 18:10:18 +00:00
|
|
|
|
|
|
|
void requestDone(int offset, const MTPupload_File &result);
|
2019-03-01 12:22:47 +00:00
|
|
|
void requestFailed(
|
2019-03-25 09:17:47 +00:00
|
|
|
int offset,
|
|
|
|
const RPCError &error,
|
2019-03-01 12:22:47 +00:00
|
|
|
const QByteArray &usedFileReference);
|
2019-02-13 18:10:18 +00:00
|
|
|
void changeCdnParams(
|
|
|
|
int offset,
|
|
|
|
MTP::DcId dcId,
|
|
|
|
const QByteArray &token,
|
|
|
|
const QByteArray &encryptionKey,
|
|
|
|
const QByteArray &encryptionIV,
|
|
|
|
const QVector<MTPFileHash> &hashes);
|
|
|
|
|
|
|
|
const not_null<ApiWrap*> _api;
|
2019-03-01 12:22:47 +00:00
|
|
|
|
|
|
|
// _location can be changed with an updated file_reference.
|
2019-03-25 09:17:47 +00:00
|
|
|
StorageFileLocation _location;
|
2019-03-01 12:22:47 +00:00
|
|
|
|
2019-02-13 18:10:18 +00:00
|
|
|
const int _size = 0;
|
|
|
|
const Data::FileOrigin _origin;
|
|
|
|
|
|
|
|
MTP::Sender _sender;
|
|
|
|
|
2019-02-25 17:26:08 +00:00
|
|
|
PriorityQueue _requested;
|
2019-02-13 18:10:18 +00:00
|
|
|
base::flat_map<int, mtpRequestId> _requests;
|
|
|
|
rpl::event_stream<LoadedPart> _parts;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|