Meta tracks for everyone!
This commit is contained in:
parent
23d70a616a
commit
6d86f98148
2 changed files with 25 additions and 9 deletions
|
@ -227,7 +227,7 @@ namespace Mist{
|
||||||
};
|
};
|
||||||
|
|
||||||
void addSources(std::string &streamname, std::set<JSON::Value, sourceCompare> &sources, HTTP::URL url,
|
void addSources(std::string &streamname, std::set<JSON::Value, sourceCompare> &sources, HTTP::URL url,
|
||||||
JSON::Value &conncapa, JSON::Value &strmMeta, const std::string &useragent){
|
JSON::Value &conncapa, JSON::Value &strmMeta, const std::string &useragent, bool metaEverywhere){
|
||||||
url.path += "/";
|
url.path += "/";
|
||||||
if (strmMeta.isMember("live") && conncapa.isMember("exceptions") &&
|
if (strmMeta.isMember("live") && conncapa.isMember("exceptions") &&
|
||||||
conncapa["exceptions"].isObject() && conncapa["exceptions"].size()){
|
conncapa["exceptions"].isObject() && conncapa["exceptions"].size()){
|
||||||
|
@ -271,6 +271,7 @@ namespace Mist{
|
||||||
if ((!byType && (*trit)["codec"].asStringRef() == strRef.substr(shift)) ||
|
if ((!byType && (*trit)["codec"].asStringRef() == strRef.substr(shift)) ||
|
||||||
(byType && (*trit)["type"].asStringRef() == strRef.substr(shift)) ||
|
(byType && (*trit)["type"].asStringRef() == strRef.substr(shift)) ||
|
||||||
strRef.substr(shift) == "*"){
|
strRef.substr(shift) == "*"){
|
||||||
|
if (metaEverywhere && (*trit)["type"] == "meta"){continue;}
|
||||||
if (allowBFrames || !(trit->isMember("bframes") && (*trit)["bframes"])){
|
if (allowBFrames || !(trit->isMember("bframes") && (*trit)["bframes"])){
|
||||||
matches++;
|
matches++;
|
||||||
total_matches++;
|
total_matches++;
|
||||||
|
@ -294,6 +295,19 @@ namespace Mist{
|
||||||
if (matches){simul++;}
|
if (matches){simul++;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simulate support for all metadata tracks in every protocol
|
||||||
|
if (metaEverywhere){
|
||||||
|
size_t matches = 0;
|
||||||
|
jsonForEach(strmMeta["tracks"], trit){
|
||||||
|
if ((*trit)["type"] == "meta"){++matches;}
|
||||||
|
}
|
||||||
|
if (matches){
|
||||||
|
total_matches += matches;
|
||||||
|
++simul;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (simul > most_simul){most_simul = simul;}
|
if (simul > most_simul){most_simul = simul;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,7 +440,7 @@ namespace Mist{
|
||||||
H.Clean();
|
H.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON::Value OutHTTP::getStatusJSON(std::string &reqHost, const std::string &useragent){
|
JSON::Value OutHTTP::getStatusJSON(std::string &reqHost, const std::string &useragent, bool metaEverywhere){
|
||||||
JSON::Value json_resp;
|
JSON::Value json_resp;
|
||||||
if (config->getString("nostreamtext") != ""){
|
if (config->getString("nostreamtext") != ""){
|
||||||
json_resp["on_error"] = config->getString("nostreamtext");
|
json_resp["on_error"] = config->getString("nostreamtext");
|
||||||
|
@ -453,7 +467,7 @@ namespace Mist{
|
||||||
streamName = newStrm;
|
streamName = newStrm;
|
||||||
Util::setStreamName(streamName);
|
Util::setStreamName(streamName);
|
||||||
reconnect();
|
reconnect();
|
||||||
return getStatusJSON(reqHost, useragent);
|
return getStatusJSON(reqHost, useragent, metaEverywhere);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +489,7 @@ namespace Mist{
|
||||||
streamName = newStrm;
|
streamName = newStrm;
|
||||||
Util::setStreamName(streamName);
|
Util::setStreamName(streamName);
|
||||||
reconnect();
|
reconnect();
|
||||||
return getStatusJSON(reqHost, useragent);
|
return getStatusJSON(reqHost, useragent, metaEverywhere);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
origStreamName.clear(); // no fallback, don't check again
|
origStreamName.clear(); // no fallback, don't check again
|
||||||
|
@ -595,7 +609,7 @@ namespace Mist{
|
||||||
if (jit->asString().size()){altURL = jit->asString();}
|
if (jit->asString().size()){altURL = jit->asString();}
|
||||||
if (!altURL.host.size()){altURL.host = outURL.host;}
|
if (!altURL.host.size()){altURL.host = outURL.host;}
|
||||||
if (!altURL.protocol.size()){altURL.protocol = outURL.protocol;}
|
if (!altURL.protocol.size()){altURL.protocol = outURL.protocol;}
|
||||||
addSources(streamName, sources, altURL, capa_json, json_resp["meta"], useragent);
|
addSources(streamName, sources, altURL, capa_json, json_resp["meta"], useragent, metaEverywhere);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Make note if this connector can be depended upon by other connectors
|
// Make note if this connector can be depended upon by other connectors
|
||||||
|
@ -623,7 +637,7 @@ namespace Mist{
|
||||||
if (jit->asString().size()){altURL = jit->asString();}
|
if (jit->asString().size()){altURL = jit->asString();}
|
||||||
if (!altURL.host.size()){altURL.host = outURL.host;}
|
if (!altURL.host.size()){altURL.host = outURL.host;}
|
||||||
if (!altURL.protocol.size()){altURL.protocol = outURL.protocol;}
|
if (!altURL.protocol.size()){altURL.protocol = outURL.protocol;}
|
||||||
addSources(streamName, sources, altURL, subcapa_json, json_resp["meta"], useragent);
|
addSources(streamName, sources, altURL, subcapa_json, json_resp["meta"], useragent, metaEverywhere);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,6 +817,7 @@ namespace Mist{
|
||||||
(req.url.length() > 9 && req.url.substr(0, 6) == "/json_" && req.url.substr(req.url.length() - 3, 3) == ".js")){
|
(req.url.length() > 9 && req.url.substr(0, 6) == "/json_" && req.url.substr(req.url.length() - 3, 3) == ".js")){
|
||||||
HTTPOutput::respondHTTP(req, headersOnly);
|
HTTPOutput::respondHTTP(req, headersOnly);
|
||||||
if (websocketHandler(req, headersOnly)){return;}
|
if (websocketHandler(req, headersOnly)){return;}
|
||||||
|
bool metaEverywhere = req.GetVar("metaeverywhere").size();
|
||||||
std::string reqHost = HTTP::URL(req.GetHeader("Host")).host;
|
std::string reqHost = HTTP::URL(req.GetHeader("Host")).host;
|
||||||
std::string useragent = req.GetVar("ua");
|
std::string useragent = req.GetVar("ua");
|
||||||
if (!useragent.size()){useragent = req.GetHeader("User-Agent");}
|
if (!useragent.size()){useragent = req.GetHeader("User-Agent");}
|
||||||
|
@ -820,7 +835,7 @@ namespace Mist{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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 = getStatusJSON(reqHost, useragent);
|
JSON::Value json_resp = getStatusJSON(reqHost, useragent, metaEverywhere);
|
||||||
if (rURL.substr(0, 6) != "/json_"){
|
if (rURL.substr(0, 6) != "/json_"){
|
||||||
response += "mistvideo['" + streamName + "'] = " + json_resp.toString() + ";\n";
|
response += "mistvideo['" + streamName + "'] = " + json_resp.toString() + ";\n";
|
||||||
}else{
|
}else{
|
||||||
|
@ -1116,6 +1131,7 @@ namespace Mist{
|
||||||
bool OutHTTP::websocketHandler(const HTTP::Parser & req, bool headersOnly){
|
bool OutHTTP::websocketHandler(const HTTP::Parser & req, bool headersOnly){
|
||||||
stayConnected = true;
|
stayConnected = true;
|
||||||
std::string reqHost = HTTP::URL(req.GetHeader("Host")).host;
|
std::string reqHost = HTTP::URL(req.GetHeader("Host")).host;
|
||||||
|
bool metaEverywhere = req.GetVar("metaeverywhere").size();
|
||||||
if (req.GetHeader("X-Mst-Path").size()){mistPath = req.GetHeader("X-Mst-Path");}
|
if (req.GetHeader("X-Mst-Path").size()){mistPath = req.GetHeader("X-Mst-Path");}
|
||||||
std::string useragent = req.GetVar("ua");
|
std::string useragent = req.GetVar("ua");
|
||||||
if (!useragent.size()){useragent = req.GetHeader("User-Agent");}
|
if (!useragent.size()){useragent = req.GetHeader("User-Agent");}
|
||||||
|
@ -1160,7 +1176,7 @@ namespace Mist{
|
||||||
JSON::Value resp;
|
JSON::Value resp;
|
||||||
// Check if we have an error message set
|
// Check if we have an error message set
|
||||||
if (thisError == ""){
|
if (thisError == ""){
|
||||||
resp = getStatusJSON(reqHost, useragent);
|
resp = getStatusJSON(reqHost, useragent, metaEverywhere);
|
||||||
}else{
|
}else{
|
||||||
resp["error"] = "Could not retrieve stream. Sorry.";
|
resp["error"] = "Could not retrieve stream. Sorry.";
|
||||||
resp["error_guru"] = thisError;
|
resp["error_guru"] = thisError;
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Mist{
|
||||||
void respondHTTP(const HTTP::Parser & req, bool headersOnly);
|
void respondHTTP(const HTTP::Parser & req, bool headersOnly);
|
||||||
void sendIcon(bool headersOnly);
|
void sendIcon(bool headersOnly);
|
||||||
bool websocketHandler(const HTTP::Parser & req, bool headersOnly);
|
bool websocketHandler(const HTTP::Parser & req, bool headersOnly);
|
||||||
JSON::Value getStatusJSON(std::string &reqHost, const std::string &useragent = "");
|
JSON::Value getStatusJSON(std::string &reqHost, const std::string &useragent = "", bool metaEverywhere = false);
|
||||||
bool stayConnected;
|
bool stayConnected;
|
||||||
virtual bool onFinish(){return stayConnected;}
|
virtual bool onFinish(){return stayConnected;}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue