Improved handling of VoD file metadata, added some failsaves against metadata corruption.
This commit is contained in:
parent
455bce2c34
commit
318af0b353
2 changed files with 47 additions and 21 deletions
|
@ -344,6 +344,9 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
||||||
Controller::fillTotals(Request["totals"], Response["totals"]);
|
Controller::fillTotals(Request["totals"], Response["totals"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controller::writeConfig();
|
||||||
|
|
||||||
}else{//unauthorized
|
}else{//unauthorized
|
||||||
Util::sleep(1000);//sleep a second to prevent bruteforcing
|
Util::sleep(1000);//sleep a second to prevent bruteforcing
|
||||||
logins++;
|
logins++;
|
||||||
|
|
|
@ -108,6 +108,11 @@ namespace Controller {
|
||||||
}
|
}
|
||||||
data["online"] = 0;
|
data["online"] = 0;
|
||||||
return;
|
return;
|
||||||
|
}else{
|
||||||
|
if (!getMeta && data["meta"].packedSize() > 1*1024 * data["meta"]["tracks"].size()){
|
||||||
|
DEBUG_MSG(DLVL_WARN, "Metadata for stream %s is quite big (%u b) - assuming corruption and forcing reload", name.c_str(), data["meta"].packedSize());
|
||||||
|
getMeta = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
DEBUG_MSG(DLVL_INSANE, "Invalid metadata (no tracks object) for stream %s - triggering reload", name.c_str());
|
DEBUG_MSG(DLVL_INSANE, "Invalid metadata (no tracks object) for stream %s - triggering reload", name.c_str());
|
||||||
|
@ -135,29 +140,49 @@ namespace Controller {
|
||||||
data["online"] = 0;
|
data["online"] = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
unsigned int i = 0;
|
||||||
|
JSON::fromDTMI((const unsigned char*)streamIndex.mapped + 8, streamIndex.len - 8, i, data["meta"]);
|
||||||
|
if (data["meta"].isMember("tracks") && data["meta"]["tracks"].size()){
|
||||||
|
for(JSON::ObjIter trackIt = data["meta"]["tracks"].ObjBegin(); trackIt != data["meta"]["tracks"].ObjEnd(); trackIt++){
|
||||||
|
trackIt->second.removeMember("fragments");
|
||||||
|
trackIt->second.removeMember("keys");
|
||||||
|
trackIt->second.removeMember("parts");
|
||||||
|
trackIt->second.removeMember("ivecs");/*LTS*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !data["meta"] || !data["meta"].isMember("tracks") || !data["meta"]["tracks"]){
|
||||||
|
data["error"] = "Stream offline: Corrupt file?";
|
||||||
|
if (data["error"].asStringRef() != prevState){
|
||||||
|
Log("WARN", "Source file " + URL + " seems to be corrupt.");
|
||||||
|
}
|
||||||
|
data["online"] = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DEBUG_MSG(DLVL_INSANE, "Metadata for stream %s (re)loaded", name.c_str());
|
||||||
}
|
}
|
||||||
DEBUG_MSG(DLVL_INSANE, "Stream %s opened", name.c_str());
|
DEBUG_MSG(DLVL_INSANE, "Stream %s opened", name.c_str());
|
||||||
}
|
}else{
|
||||||
//now, run mistinfo on the source - or on the accompanying dtsh file, if it exists
|
//now, run mistinfo on the source - or on the accompanying dtsh file, if it exists
|
||||||
if (stat((URL+".dtsh").c_str(), &fileinfo) == 0){
|
if (stat((URL+".dtsh").c_str(), &fileinfo) == 0){
|
||||||
DEBUG_MSG(DLVL_INSANE, "Stream %s has a DTSH - opening DTSH instead of main stream file", name.c_str());
|
DEBUG_MSG(DLVL_INSANE, "Stream %s has a DTSH - opening DTSH instead of main stream file", name.c_str());
|
||||||
URL += ".dtsh";
|
URL += ".dtsh";
|
||||||
}
|
|
||||||
char * tmp_cmd[3] = {0, 0, 0};
|
|
||||||
std::string mistinfo = Util::getMyPath() + "MistInfo";
|
|
||||||
tmp_cmd[0] = (char*)mistinfo.c_str();
|
|
||||||
tmp_cmd[1] = (char*)URL.c_str();
|
|
||||||
DEBUG_MSG(DLVL_INSANE, "Running MistInfo for stream %s on file %s", name.c_str(), tmp_cmd[1]);
|
|
||||||
data["meta"] = JSON::fromString(Util::Procs::getOutputOf(tmp_cmd));
|
|
||||||
if ( !data["meta"] || !data["meta"].isMember("tracks") || !data["meta"]["tracks"]){
|
|
||||||
data["error"] = "Stream offline: Corrupt file?";
|
|
||||||
if (data["error"].asStringRef() != prevState){
|
|
||||||
Log("WARN", "Source file " + URL + " seems to be corrupt.");
|
|
||||||
}
|
}
|
||||||
data["online"] = 0;
|
char * tmp_cmd[3] = {0, 0, 0};
|
||||||
return;
|
std::string mistinfo = Util::getMyPath() + "MistInfo";
|
||||||
|
tmp_cmd[0] = (char*)mistinfo.c_str();
|
||||||
|
tmp_cmd[1] = (char*)URL.c_str();
|
||||||
|
DEBUG_MSG(DLVL_INSANE, "Running MistInfo for stream %s on file %s", name.c_str(), tmp_cmd[1]);
|
||||||
|
data["meta"] = JSON::fromString(Util::Procs::getOutputOf(tmp_cmd));
|
||||||
|
if ( !data["meta"] || !data["meta"].isMember("tracks") || !data["meta"]["tracks"]){
|
||||||
|
data["error"] = "Stream offline: Corrupt file?";
|
||||||
|
if (data["error"].asStringRef() != prevState){
|
||||||
|
Log("WARN", "Source file " + URL + " seems to be corrupt.");
|
||||||
|
}
|
||||||
|
data["online"] = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DEBUG_MSG(DLVL_INSANE, "Metadata for stream %s succesfully (re)loaded", name.c_str());
|
||||||
}
|
}
|
||||||
DEBUG_MSG(DLVL_INSANE, "Metadata for stream %s succesfully (re)loaded", name.c_str());
|
|
||||||
}
|
}
|
||||||
if (!hasViewers(name)){
|
if (!hasViewers(name)){
|
||||||
if ( !data.isMember("error")){
|
if ( !data.isMember("error")){
|
||||||
|
@ -256,7 +281,6 @@ namespace Controller {
|
||||||
out[jit->first] = jit->second;
|
out[jit->first] = jit->second;
|
||||||
out[jit->first]["name"] = jit->first;
|
out[jit->first]["name"] = jit->first;
|
||||||
Log("STRM", std::string("Updated stream ") + jit->first);
|
Log("STRM", std::string("Updated stream ") + jit->first);
|
||||||
checkStream(jit->first, out[jit->first]);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
out[jit->first]["name"] = jit->first;
|
out[jit->first]["name"] = jit->first;
|
||||||
|
@ -268,7 +292,6 @@ namespace Controller {
|
||||||
out[jit->first]["cut"] = jit->second["cut"].asInt();
|
out[jit->first]["cut"] = jit->second["cut"].asInt();
|
||||||
}
|
}
|
||||||
Log("STRM", std::string("New stream ") + jit->first);
|
Log("STRM", std::string("New stream ") + jit->first);
|
||||||
checkStream(jit->first, out[jit->first]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue