Minetest  5.4.0
ClientMediaDownloader Class Reference

#include <clientmedia.h>

+ Collaboration diagram for ClientMediaDownloader:

Classes

struct  FileStatus
 
struct  RemoteServerStatus
 

Public Member Functions

 ClientMediaDownloader ()
 
 ~ClientMediaDownloader ()
 
float getProgress () const
 
bool isStarted () const
 
bool isDone () const
 
void addFile (const std::string &name, const std::string &sha1)
 
void addRemoteServer (const std::string &baseurl)
 
void step (Client *client)
 
void conventionalTransferDone (const std::string &name, const std::string &data, 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)
 
bool checkAndLoad (const std::string &name, const std::string &sha1, const std::string &data, bool is_from_cache, 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
 
FileCache m_media_cache
 
bool m_initial_step_done = false
 
s32 m_uncached_count = 0
 
s32 m_uncached_received_count = 0
 
unsigned long m_httpfetch_caller
 
unsigned long m_httpfetch_next_id = 0
 
long m_httpfetch_timeout = 0
 
s32 m_httpfetch_active = 0
 
s32 m_httpfetch_active_limit = 0
 
s32 m_outstanding_hash_sets = 0
 
std::unordered_map< unsigned long, std::string > m_remote_file_transfers
 
std::string m_name_bound = ""
 

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 
)

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)

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:

◆ checkAndLoad()

bool ClientMediaDownloader::checkAndLoad ( const std::string &  name,
const std::string &  sha1,
const std::string &  data,
bool  is_from_cache,
Client client 
)
private

References SHA1::addBytes(), SHA1::getDigest(), hex_encode(), infostream, m_media_cache, FileCache::update(), and verbosestream.

Referenced by conventionalTransferDone(), initialStep(), and remoteMediaReceived().

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

◆ conventionalTransferDone()

void ClientMediaDownloader::conventionalTransferDone ( const std::string &  name,
const std::string &  data,
Client client 
)

References 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

References m_uncached_count, and m_uncached_received_count.

Referenced by Client::mediaReceiveProgress().

+ Here is the caller graph for this function:

◆ initialStep()

◆ isDone()

bool ClientMediaDownloader::isDone ( ) const
inline

References m_initial_step_done, m_uncached_count, and m_uncached_received_count.

Referenced by Client::step().

+ Here is the caller graph for this function:

◆ isStarted()

bool ClientMediaDownloader::isStarted ( ) const
inline

References m_initial_step_done.

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

+ Here is the caller graph for this function:

◆ 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, 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)

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

unsigned long ClientMediaDownloader::m_httpfetch_caller
private

◆ m_httpfetch_next_id

unsigned long ClientMediaDownloader::m_httpfetch_next_id = 0
private

◆ m_httpfetch_timeout

long ClientMediaDownloader::m_httpfetch_timeout = 0
private

◆ m_initial_step_done

bool ClientMediaDownloader::m_initial_step_done = false
private

◆ m_media_cache

FileCache ClientMediaDownloader::m_media_cache
private

Referenced by checkAndLoad(), and initialStep().

◆ 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<unsigned long, 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: