mirror of https://github.com/aria2/aria2
Add getGlobalStat API
parent
c688f51f2e
commit
a4b29ac2f7
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue