diff --git a/src/output/output_http_internal.cpp b/src/output/output_http_internal.cpp index 9ebb950d..6c1b0ecb 100644 --- a/src/output/output_http_internal.cpp +++ b/src/output/output_http_internal.cpp @@ -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); } diff --git a/src/output/output_json.cpp b/src/output/output_json.cpp index a05f02ee..67661d8e 100644 --- a/src/output/output_json.cpp +++ b/src/output/output_json.cpp @@ -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()); } diff --git a/src/output/output_srt.cpp b/src/output/output_srt.cpp index 64cac4ef..2a9e5c5e 100644 --- a/src/output/output_srt.cpp +++ b/src/output/output_srt.cpp @@ -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();