Fixed VoD statistics problems, improved live status display accuracy and messages.

This commit is contained in:
Thulinma 2013-03-08 16:00:24 +01:00
parent d72062ee92
commit 58847705eb
2 changed files with 21 additions and 4 deletions

View file

@ -298,7 +298,7 @@ int main(int argc, char ** argv){
if (Request.isMember("vod")){
std::string thisfile = Request["vod"]["filename"];
for (JSON::ObjIter oit = Controller::Storage["streams"].ObjBegin(); oit != Controller::Storage["streams"].ObjEnd(); ++oit){
if (oit->second["channel"]["URL"].asString() == thisfile){
if ((oit->second.isMember("source") && oit->second["source"].asString() == thisfile) || (oit->second.isMember("channel") && oit->second["channel"]["URL"].asString() == thisfile)){
Controller::lastBuffer[oit->first] = Util::epoch();
if (Request["vod"].isMember("meta")){
Controller::Storage["streams"][oit->first]["meta"] = Request["vod"]["meta"];

View file

@ -91,10 +91,27 @@ namespace Controller {
jit->second["online"] = 0;
}
}else{
if (jit->second.isMember("error") && jit->second["error"].asString() == "Available"){
jit->second.removeMember("error");
}
// assume all is fine
jit->second.removeMember("error");
jit->second["online"] = 1;
// check if source is valid
if ( !jit->second.isMember("meta") || !jit->second["meta"]){
jit->second["online"] = 0;
jit->second["error"] = "No (valid) source connected";
}else{
// for live streams, keep track of activity
if (jit->second["meta"].isMember("live")){
if (jit->second["meta"]["lastms"] != jit->second["lastms"]){
jit->second["lastms"] = jit->second["meta"]["lastms"];
jit->second["last_active"] = currTime;
}
// mark stream as offline if no activity for 5 seconds
if (jit->second.isMember("last_active") && jit->second["last_active"].asInt() < currTime - 5){
jit->second["online"] = 0;
jit->second["error"] = "No (valid) source connected";
}
}
}
}
}
static JSON::Value strlist;