Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ClientMediaDownloader Class Reference

#include <clientmedia.h>

+ Inheritance diagram for ClientMediaDownloader:
+ Collaboration diagram for ClientMediaDownloader:

Classes

struct  FileStatus
 
struct  RemoteServerStatus
 

Public Member Functions

 ClientMediaDownloader ()
 
 ~ClientMediaDownloader ()
 
float getProgress () const
 
bool isStarted () const override
 
bool isDone () const override
 
void addFile (const std::string &name, const std::string &sha1) override
 
void addRemoteServer (const std::string &baseurl) override
 
void step (Client *client) override
 
bool conventionalTransferDone (const std::string &name, const std::string &data, Client *client) override
 

Protected Member Functions

bool loadMedia (Client *client, const std::string &data, const std::string &name) override
 
- Protected Member Functions inherited from IClientMediaDownloader
 IClientMediaDownloader ()
 
virtual ~IClientMediaDownloader ()=default
 
bool tryLoadFromCache (const std::string &name, const std::string &sha1, Client *client)
 
bool checkAndLoad (const std::string &name, const std::string &sha1, const std::string &data, bool is_from_cache, Client *client)
 

Private Member Functions

void initialStep (Client *client)
 
void remoteHashSetReceived (const HTTPFetchResult &fetch_result)
 
void remoteMediaReceived (const HTTPFetchResult &fetch_result, Client *client)
 
s32 selectRemoteServer (FileStatus *filestatus)
 
void startRemoteMediaTransfers ()
 
void startConventionalTransfers (Client *client)
 
std::string serializeRequiredHashSet ()
 

Static Private Member Functions

static void deSerializeHashSet (const std::string &data, std::set< std::string > &result)
 

Private Attributes

std::map< std::string, FileStatus * > m_files
 
std::vector< RemoteServerStatus * > m_remotes
 
bool m_initial_step_done = false
 
s32 m_uncached_count = 0
 
s32 m_uncached_received_count = 0
 
u64 m_httpfetch_caller
 
u64 m_httpfetch_next_id = 0
 
s32 m_httpfetch_active = 0
 
s32 m_httpfetch_active_limit = 0
 
s32 m_outstanding_hash_sets = 0
 
std::unordered_map< u64, std::string > m_remote_file_transfers
 
std::string m_name_bound = ""
 

Additional Inherited Members

- Protected Attributes inherited from IClientMediaDownloader
FileCache m_media_cache
 
bool m_write_to_cache
 

Constructor & Destructor Documentation

◆ ClientMediaDownloader()

ClientMediaDownloader::ClientMediaDownloader ( )

◆ ~ClientMediaDownloader()

ClientMediaDownloader::~ClientMediaDownloader ( )

References httpfetch_caller_free(), HTTPFETCH_DISCARD, m_files, m_httpfetch_caller, and m_remotes.

+ Here is the call graph for this function:

Member Function Documentation

◆ addFile()

void ClientMediaDownloader::addFile ( const std::string & name,
const std::string & sha1 )
overridevirtual

Implements IClientMediaDownloader.

References ClientMediaDownloader::FileStatus::current_remote, errorstream, hex_encode(), m_files, m_initial_step_done, ClientMediaDownloader::FileStatus::received, ClientMediaDownloader::FileStatus::sha1, string_allowed(), and TEXTURENAME_ALLOWED_CHARS.

Referenced by Client::handleCommand_AnnounceMedia().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addRemoteServer()

void ClientMediaDownloader::addRemoteServer ( const std::string & baseurl)
overridevirtual

Implements IClientMediaDownloader.

References ClientMediaDownloader::RemoteServerStatus::active_count, ClientMediaDownloader::RemoteServerStatus::baseurl, g_settings, Settings::getBool(), infostream, m_initial_step_done, and m_remotes.

Referenced by Client::handleCommand_AnnounceMedia().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ conventionalTransferDone()

bool ClientMediaDownloader::conventionalTransferDone ( const std::string & name,
const std::string & data,
Client * client )
overridevirtual

Implements IClientMediaDownloader.

References IClientMediaDownloader::checkAndLoad(), errorstream, m_files, m_uncached_count, m_uncached_received_count, ClientMediaDownloader::FileStatus::received, and ClientMediaDownloader::FileStatus::sha1.

Referenced by Client::handleCommand_Media().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deSerializeHashSet()

void ClientMediaDownloader::deSerializeHashSet ( const std::string & data,
std::set< std::string > & result )
staticprivate

References MTHASHSET_FILE_SIGNATURE, readU16(), and readU32().

Referenced by remoteHashSetReceived().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProgress()

float ClientMediaDownloader::getProgress ( ) const
inline

Referenced by Client::mediaReceiveProgress().

+ Here is the caller graph for this function:

◆ initialStep()

◆ isDone()

bool ClientMediaDownloader::isDone ( ) const
inlineoverridevirtual

Implements IClientMediaDownloader.

Referenced by Client::step().

+ Here is the caller graph for this function:

◆ isStarted()

bool ClientMediaDownloader::isStarted ( ) const
inlineoverridevirtual

Implements IClientMediaDownloader.

Referenced by Client::handleCommand_AnnounceMedia(), Client::handleCommand_Media(), and Client::step().

+ Here is the caller graph for this function:

◆ loadMedia()

bool ClientMediaDownloader::loadMedia ( Client * client,
const std::string & data,
const std::string & name )
overrideprotectedvirtual

◆ remoteHashSetReceived()

void ClientMediaDownloader::remoteHashSetReceived ( const HTTPFetchResult & fetch_result)
private

References ClientMediaDownloader::FileStatus::available_remotes, ClientMediaDownloader::RemoteServerStatus::baseurl, HTTPFetchResult::data, deSerializeHashSet(), infostream, m_files, m_name_bound, m_outstanding_hash_sets, m_remotes, ClientMediaDownloader::FileStatus::received, HTTPFetchResult::request_id, ClientMediaDownloader::FileStatus::sha1, HTTPFetchResult::succeeded, and BaseException::what().

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remoteMediaReceived()

void ClientMediaDownloader::remoteMediaReceived ( const HTTPFetchResult & fetch_result,
Client * client )
private

References ClientMediaDownloader::RemoteServerStatus::active_count, IClientMediaDownloader::checkAndLoad(), ClientMediaDownloader::FileStatus::current_remote, HTTPFetchResult::data, m_files, m_remote_file_transfers, m_remotes, m_uncached_count, m_uncached_received_count, ClientMediaDownloader::FileStatus::received, HTTPFetchResult::request_id, sanity_check, ClientMediaDownloader::FileStatus::sha1, and HTTPFetchResult::succeeded.

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selectRemoteServer()

s32 ClientMediaDownloader::selectRemoteServer ( FileStatus * filestatus)
private

References ClientMediaDownloader::FileStatus::available_remotes, ClientMediaDownloader::FileStatus::current_remote, m_remotes, and ClientMediaDownloader::FileStatus::received.

Referenced by startRemoteMediaTransfers().

+ Here is the caller graph for this function:

◆ serializeRequiredHashSet()

std::string ClientMediaDownloader::serializeRequiredHashSet ( )
private

References FATAL_ERROR_IF, m_files, MTHASHSET_FILE_SIGNATURE, writeU16(), and writeU32().

Referenced by initialStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startConventionalTransfers()

void ClientMediaDownloader::startConventionalTransfers ( Client * client)
private

References m_files, m_httpfetch_active, m_uncached_count, and m_uncached_received_count.

Referenced by initialStep(), and step().

+ Here is the caller graph for this function:

◆ startRemoteMediaTransfers()

void ClientMediaDownloader::startRemoteMediaTransfers ( )
private

◆ step()

void ClientMediaDownloader::step ( Client * client)
overridevirtual

Implements IClientMediaDownloader.

References httpfetch_async_get(), infostream, initialStep(), m_httpfetch_active, m_httpfetch_caller, m_initial_step_done, m_remotes, m_uncached_count, m_uncached_received_count, remoteHashSetReceived(), remoteMediaReceived(), HTTPFetchResult::request_id, startConventionalTransfers(), and startRemoteMediaTransfers().

Referenced by Client::handleCommand_AnnounceMedia(), and Client::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_files

◆ m_httpfetch_active

s32 ClientMediaDownloader::m_httpfetch_active = 0
private

◆ m_httpfetch_active_limit

s32 ClientMediaDownloader::m_httpfetch_active_limit = 0
private

◆ m_httpfetch_caller

u64 ClientMediaDownloader::m_httpfetch_caller
private

◆ m_httpfetch_next_id

u64 ClientMediaDownloader::m_httpfetch_next_id = 0
private

◆ m_initial_step_done

bool ClientMediaDownloader::m_initial_step_done = false
private

Referenced by addFile(), addRemoteServer(), and step().

◆ m_name_bound

std::string ClientMediaDownloader::m_name_bound = ""
private

◆ m_outstanding_hash_sets

s32 ClientMediaDownloader::m_outstanding_hash_sets = 0
private

◆ m_remote_file_transfers

std::unordered_map<u64, std::string> ClientMediaDownloader::m_remote_file_transfers
private

◆ m_remotes

◆ m_uncached_count

s32 ClientMediaDownloader::m_uncached_count = 0
private

◆ m_uncached_received_count

s32 ClientMediaDownloader::m_uncached_received_count = 0
private

The documentation for this class was generated from the following files: