LTS feature: Added support for setting/overriding the error text for failed streams.

This commit is contained in:
Thulinma 2015-04-17 02:01:27 +02:00
parent 8e3de119b8
commit ac540cdd1d
2 changed files with 21 additions and 2 deletions

View file

@ -214,11 +214,19 @@ function mistembed(streamname) {
if(video.error) { if(video.error) {
// there was an error; display it // there was an error; display it
container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join(''); if (video.on_error){
container.innerHTML = video.on_error;
}else{
container.innerHTML = ['<strong>Error: ', video.error, '</strong>'].join('');
}
} }
else if ((typeof video.source == 'undefined') || (video.source.length < 1)) { else if ((typeof video.source == 'undefined') || (video.source.length < 1)) {
// no stream sources // no stream sources
container.innerHTML = '<strong>Error: no protocols found</strong>'; if (video.on_error){
container.innerHTML = video.on_error;
}else{
container.innerHTML = '<strong>Error: no protocols found</strong>';
}
} }
else { else {
// no error, and sources found. Check the video types and output the best // no error, and sources found. Check the video types and output the best

View file

@ -50,6 +50,14 @@ namespace Mist {
capa["url_match"].append("/json_$.js"); capa["url_match"].append("/json_$.js");
capa["url_match"].append("/embed_$.js"); capa["url_match"].append("/embed_$.js");
cfg->addConnectorOptions(8080, capa); cfg->addConnectorOptions(8080, capa);
/*LTS-START*/
cfg->addOption("nostreamtext", JSON::fromString("{\"arg\":\"string\", \"default\":\"\", \"short\":\"t\",\"long\":\"nostreamtext\",\"help\":\"Text or HTML to display when streams are unavailable.\"}"));
capa["optional"]["nostreamtext"]["name"] = "Stream unavailable text";
capa["optional"]["nostreamtext"]["help"] = "Text or HTML to display when streams are unavailable.";
capa["optional"]["nostreamtext"]["default"] = "";
capa["optional"]["nostreamtext"]["type"] = "str";
capa["optional"]["nostreamtext"]["option"] = "--nostreamtext";
/*LTS-END*/
} }
/// Sorts the JSON::Value objects that hold source information by preference. /// Sorts the JSON::Value objects that hold source information by preference.
@ -260,6 +268,9 @@ namespace Mist {
} }
response = "// Generating info code for stream " + streamName + "\n\nif (!mistvideo){var mistvideo = {};}\n"; response = "// Generating info code for stream " + streamName + "\n\nif (!mistvideo){var mistvideo = {};}\n";
JSON::Value json_resp; JSON::Value json_resp;
if (config->getString("nostreamtext") != ""){
json_resp["on_error"] = config->getString("nostreamtext");
}
IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1);
IPC::semaphore metaLocker(std::string("liveMeta@" + streamName).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1); IPC::semaphore metaLocker(std::string("liveMeta@" + streamName).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1);
bool metaLock = false; bool metaLock = false;