Add getGlobalStat API

pull/92/head
Tatsuhiro Tsujikawa 2013-05-18 15:41:40 +09:00
parent c688f51f2e
commit a4b29ac2f7
2 changed files with 51 additions and 0 deletions

View File

@ -521,6 +521,21 @@ int changeGlobalOption(Session* session, const KeyVals& options)
return 0;
}
GlobalStat getGlobalStat(Session* session)
{
const SharedHandle<DownloadEngine>& e =
session->context->reqinfo->getDownloadEngine();
const SharedHandle<RequestGroupMan>& rgman = e->getRequestGroupMan();
TransferStat ts = rgman->calculateStat();
GlobalStat res;
res.downloadSpeed = ts.downloadSpeed;
res.uploadSpeed = ts.uploadSpeed;
res.numActive = rgman->getRequestGroups().size();
res.numWaiting = rgman->getReservedGroups().size();
res.numStopped = rgman->getDownloadResults().size();
return res;
}
std::vector<A2Gid> getActiveDownload(Session* session)
{
const SharedHandle<DownloadEngine>& e =

View File

@ -485,6 +485,42 @@ KeyVals getGlobalOptions(Session* session);
*/
int changeGlobalOption(Session* session, const KeyVals& options);
/**
* @struct
*
* Global statistics of current aria2 session.
*/
struct GlobalStat {
/**
* Overall download speed (byte/sec).
*/
int downloadSpeed;
/**
* Overall upload speed(byte/sec).
*/
int uploadSpeed;
/**
* The number of active downloads.
*/
int numActive;
/**
* The number of waiting downloads.
*/
int numWaiting;
/**
* The number of stopped downloads.
*/
int numStopped;
};
/**
* @function
*
* Returns global statistics such as overall download and upload
* speed.
*/
GlobalStat getGlobalStat(Session* session);
/**
* @enum
*