Implemented ?stream=STREAMNAME in load balancer
This commit is contained in:
parent
05fee379ad
commit
bf89c6a3c1
1 changed files with 19 additions and 0 deletions
|
@ -168,6 +168,13 @@ public:
|
||||||
r[jt->first] = r[jt->first].asInt() + jt->second.total;
|
r[jt->first] = r[jt->first].asInt() + jt->second.total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Returns viewcount for the given stream
|
||||||
|
long long getViewers(const std::string &strm){
|
||||||
|
if (!hostMutex){hostMutex = new tthread::mutex();}
|
||||||
|
tthread::lock_guard<tthread::mutex> guard(*hostMutex);
|
||||||
|
if (!streams.count(strm)){return 0;}
|
||||||
|
return streams[strm].total;
|
||||||
|
}
|
||||||
/// Scores a potential new connection to this server
|
/// Scores a potential new connection to this server
|
||||||
/// 0 means not possible, the higher the better.
|
/// 0 means not possible, the higher the better.
|
||||||
unsigned int rate(std::string &s, double lati = 0, double longi = 0){
|
unsigned int rate(std::string &s, double lati = 0, double longi = 0){
|
||||||
|
@ -369,6 +376,7 @@ int handleRequest(Socket::Connection &conn){
|
||||||
}
|
}
|
||||||
std::string host = H.GetVar("host");
|
std::string host = H.GetVar("host");
|
||||||
std::string viewers = H.GetVar("viewers");
|
std::string viewers = H.GetVar("viewers");
|
||||||
|
std::string stream = H.GetVar("stream");
|
||||||
std::string source = H.GetVar("source");
|
std::string source = H.GetVar("source");
|
||||||
std::string fback = H.GetVar("fallback");
|
std::string fback = H.GetVar("fallback");
|
||||||
std::string lstserver = H.GetVar("lstserver");
|
std::string lstserver = H.GetVar("lstserver");
|
||||||
|
@ -472,6 +480,17 @@ int handleRequest(Socket::Connection &conn){
|
||||||
H.Clean();
|
H.Clean();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (stream.size()){
|
||||||
|
long long count = 0;
|
||||||
|
for (HOSTLOOP){
|
||||||
|
HOSTCHECK;
|
||||||
|
count += HOST(i).details->getViewers(stream);
|
||||||
|
}
|
||||||
|
H.SetBody(JSON::Value(count).asString());
|
||||||
|
H.SendResponse("200", "OK", conn);
|
||||||
|
H.Clean();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Find source for given stream
|
// Find source for given stream
|
||||||
if (source.size()){
|
if (source.size()){
|
||||||
INFO_MSG("Finding source for stream %s", source.c_str());
|
INFO_MSG("Finding source for stream %s", source.c_str());
|
||||||
|
|
Loading…
Add table
Reference in a new issue