Even more JSON/VTT/SRT fixes and internal URL handler improvements
This commit is contained in:
parent
56dd4ac98c
commit
d5fee4d656
3 changed files with 32 additions and 17 deletions
|
@ -150,6 +150,12 @@ namespace Mist {
|
|||
relurl = "/";
|
||||
}
|
||||
jsonForEach(conncapa["methods"], it) {
|
||||
if (it->isMember("url_rel")){
|
||||
size_t foundb = (*it)["url_rel"].asStringRef().find('$');
|
||||
if (foundb != std::string::npos){
|
||||
relurl = (*it)["url_rel"].asStringRef().substr(0, foundb) + streamname + (*it)["url_rel"].asStringRef().substr(foundb+1);
|
||||
}
|
||||
}
|
||||
if (!strmMeta.isMember("live") || !it->isMember("nolive")){
|
||||
addSource(relurl, sources, host, port, *it, most_simul, total_matches, "http://" + httpHost);
|
||||
}
|
||||
|
@ -381,6 +387,7 @@ namespace Mist {
|
|||
jsonForEach(json_resp["meta"]["tracks"], it) {
|
||||
it->removeMember("fragments");
|
||||
it->removeMember("keys");
|
||||
it->removeMember("keysizes");
|
||||
it->removeMember("parts");
|
||||
}
|
||||
|
||||
|
@ -405,7 +412,7 @@ namespace Mist {
|
|||
port = capa.getMember("optional").getMember("port").getMember("default").asString();
|
||||
}
|
||||
//and a URL - then list the URL
|
||||
if (capa.getMember("url_rel")){
|
||||
if (capa.getMember("url_rel") || capa.getMember("methods")){
|
||||
JSON::Value capa_json = capa.asJSON();
|
||||
addSources(streamName, capa.getMember("url_rel").asString(), sources, host, port, capa_json, json_resp["meta"], fullHost);
|
||||
}
|
||||
|
|
|
@ -9,24 +9,30 @@ namespace Mist {
|
|||
HTTPOutput::init(cfg);
|
||||
capa["name"] = "JSON";
|
||||
capa["desc"] = "Enables HTTP protocol JSON streaming.";
|
||||
capa["url_rel"] = "/$.json";
|
||||
capa["url_match"] = "/$.json";
|
||||
capa["url_handler"] = "http";
|
||||
capa["url_type"] = "json";
|
||||
capa["codecs"][0u][0u].append("srt");
|
||||
capa["codecs"][0u][0u].append("TTXT");
|
||||
capa["methods"][0u]["handler"] = "http";
|
||||
capa["methods"][0u]["type"] = "html5/text/javascript";
|
||||
capa["methods"][0u]["priority"] = 0ll;
|
||||
capa["methods"][0u]["url_rel"] = "/$.json";
|
||||
}
|
||||
|
||||
void OutJSON::sendNext(){
|
||||
if(!first) {
|
||||
myConn.SendNow(", ", 2);
|
||||
}else{
|
||||
if (jsonp == ""){
|
||||
myConn.SendNow("[", 1);
|
||||
if (!jsonp.size()){
|
||||
if(!first) {
|
||||
myConn.SendNow(", ", 2);
|
||||
}else{
|
||||
myConn.SendNow(jsonp + "([");
|
||||
myConn.SendNow("[", 1);
|
||||
first = false;
|
||||
}
|
||||
first = false;
|
||||
}else{
|
||||
myConn.SendNow(jsonp + "(");
|
||||
}
|
||||
myConn.SendNow(thisPacket.toJSON().toString());
|
||||
if (jsonp.size()){
|
||||
myConn.SendNow(");\n", 3);
|
||||
}
|
||||
}
|
||||
|
||||
void OutJSON::sendHeader(){
|
||||
|
@ -40,11 +46,10 @@ namespace Mist {
|
|||
}
|
||||
|
||||
bool OutJSON::onFinish(){
|
||||
if (jsonp == ""){
|
||||
myConn.SendNow("]\n\n", 3);
|
||||
}else{
|
||||
if (!jsonp.size()){
|
||||
myConn.SendNow("]);\n\n", 5);
|
||||
}
|
||||
myConn.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -54,6 +59,7 @@ namespace Mist {
|
|||
if (H.GetVar("callback") != ""){jsonp = H.GetVar("callback");}
|
||||
if (H.GetVar("jsonp") != ""){jsonp = H.GetVar("jsonp");}
|
||||
if (H.GetVar("track") != ""){
|
||||
selectedTracks.clear();
|
||||
selectedTracks.insert(JSON::Value(H.GetVar("track")).asInt());
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace Mist {
|
|||
HTTPOutput::init(cfg);
|
||||
capa["name"] = "SRT";
|
||||
capa["desc"] = "Enables HTTP protocol subtitle streaming in subrip and WebVTT formats.";
|
||||
capa["url_rel"] = "/$.srt";
|
||||
capa["url_match"].append("/$.srt");
|
||||
capa["url_match"].append("/$.vtt");
|
||||
capa["codecs"][0u][0u].append("srt");
|
||||
|
@ -20,9 +19,11 @@ namespace Mist {
|
|||
capa["methods"][0u]["handler"] = "http";
|
||||
capa["methods"][0u]["type"] = "html5/text/plain";
|
||||
capa["methods"][0u]["priority"] = 8ll;
|
||||
capa["methods"][0u]["url_rel"] = "/$.srt";
|
||||
capa["methods"][1u]["handler"] = "http";
|
||||
capa["methods"][1u]["type"] = "html5/text/vtt";
|
||||
capa["methods"][1u]["priority"] = 9ll;
|
||||
capa["methods"][1u]["url_rel"] = "/$.vtt";
|
||||
}
|
||||
|
||||
void OutProgressiveSRT::sendNext(){
|
||||
|
@ -39,14 +40,14 @@ namespace Mist {
|
|||
}
|
||||
long long unsigned int time = thisPacket.getTime();
|
||||
char tmpBuf[50];
|
||||
int tmpLen = sprintf(tmpBuf, "%.2llu:%.2llu:%.2llu,%.3llu", (time / 3600000), ((time % 3600000) / 60000), (((time % 3600000) % 60000) / 1000), time % 1000);
|
||||
int tmpLen = sprintf(tmpBuf, "%.2llu:%.2llu:%.2llu.%.3llu", (time / 3600000), ((time % 3600000) / 60000), (((time % 3600000) % 60000) / 1000), time % 1000);
|
||||
tmp.write(tmpBuf, tmpLen);
|
||||
tmp << " --> ";
|
||||
time += thisPacket.getInt("duration");
|
||||
if (time == thisPacket.getTime()){
|
||||
time += len * 75 + 800;
|
||||
}
|
||||
tmpLen = sprintf(tmpBuf, "%.2llu:%.2llu:%.2llu,%.3llu", (time / 3600000), ((time % 3600000) / 60000), (((time % 3600000) % 60000) / 1000), time % 1000);
|
||||
tmpLen = sprintf(tmpBuf, "%.2llu:%.2llu:%.2llu.%.3llu", (time / 3600000), ((time % 3600000) / 60000), (((time % 3600000) % 60000) / 1000), time % 1000);
|
||||
tmp.write(tmpBuf, tmpLen);
|
||||
tmp << std::endl;
|
||||
myConn.SendNow(tmp.str());
|
||||
|
@ -74,6 +75,7 @@ namespace Mist {
|
|||
std::string method = H.method;
|
||||
webVTT = (H.url.find(".vtt") != std::string::npos);
|
||||
if (H.GetVar("track") != ""){
|
||||
selectedTracks.clear();
|
||||
selectedTracks.insert(JSON::Value(H.GetVar("track")).asInt());
|
||||
}
|
||||
H.Clean();
|
||||
|
|
Loading…
Add table
Reference in a new issue