LSP: show a hint where to push a stream when configuring stream source
This commit is contained in:
parent
405195a979
commit
109366e81c
2 changed files with 126 additions and 70 deletions
138
lsp/minified.js
138
lsp/minified.js
|
@ -81,74 +81,76 @@ label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can
|
||||||
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):e.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var p=mist.stored.get().update||{};p.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,p,a.update));q()},{checkupdate:!0})}else q()}else e.text("");var f=function(){mist.send(function(){v()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):e.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var p=mist.stored.get().update||{};p.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,p,a.update));q()},{checkupdate:!0})}else q()}else e.text("");var f=function(){mist.send(function(){v()},{totals:{fields:["clients"],start:-10},active_streams:true})},
|
||||||
v=function(){l.text(("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";n.text(a);h.text(UI.format.dateTime(mist.data.config.time,"long"))};f();v();UI.interval.set(f,3E4);break;case "Protocols":if("undefined"==
|
v=function(){l.text(("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?")+" active, "+(mist.data.streams?Object.keys(mist.data.streams).length:0)+" configured");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";n.text(a);h.text(UI.format.dateTime(mist.data.config.time,"long"))};f();v();UI.interval.set(f,3E4);break;case "Protocols":if("undefined"==
|
||||||
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");break}var g=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")})).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(g));
|
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");break}var g=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")})).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(g));
|
||||||
var i=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],f=["required","optional"],g;for(g in f)for(var e in c[f[g]])b[e]&&b[e]!=""?d.push(e+": "+b[e]):c[f[g]][e]["default"]&&d.push(e+": "+c[f[g]][e]["default"]);return $("<span>").addClass("description").text(d.join(", "))}g.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];g.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align",
|
var i=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],f=["required","optional"],D;for(D in f)for(var g in c[f[D]])b[g]&&b[g]!=""?d.push(g+": "+b[g]):c[f[D]][g]["default"]&&d.push(g+": "+c[f[D]][g]["default"]);return $("<span>").addClass("description").text(d.join(", "))}g.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];g.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align",
|
||||||
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};i();UI.interval.set(function(){mist.send(function(){i()})},
|
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};i();UI.interval.set(function(){mist.send(function(){i()})},
|
||||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}var j=!1;""!=b&&0<=b&&(j=!0);var k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;var aa=function(a){var c=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(c,m);d.push({type:"hidden",pointer:{main:m,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){if(j)mist.data.config.protocols[b]=
|
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}var j=!1;""!=b&&0<=b&&(j=!0);var k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;var ca=function(a){var c=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(c,m);d.push({type:"hidden",pointer:{main:m,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){if(j)mist.data.config.protocols[b]=
|
||||||
m;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(m)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var f in c.deps){a=$("<li>").text(c.deps[f]+" ");$ul.append(a);typeof k[c.deps[f]]!="undefined"||
|
m;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(m)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var f in c.deps){a=$("<li>").text(c.deps[f]+" ");$ul.append(a);typeof k[c.deps[f]]!="undefined"||
|
||||||
typeof k[c.deps[f]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;if(j)m=d=mist.data.config.protocols[b],c.find("h2").append(' "'+d.connector+'"'),c.append(aa(d.connector));else{c.html($("<h2>").text("New Protocol"));var m={},t=[];for(f in mist.data.capabilities.connectors)t.push([f,
|
typeof k[c.deps[f]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},k={};for(f in mist.data.config.protocols)k[mist.data.config.protocols[f].connector]=1;if(j)m=d=mist.data.config.protocols[b],c.find("h2").append(' "'+d.connector+'"'),c.append(ca(d.connector));else{c.html($("<h2>").text("New Protocol"));var m={},t=[];for(f in mist.data.capabilities.connectors)t.push([f,
|
||||||
f]);var F=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){F.html(aa($(this).getval()))}}])).append(F)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}var f=$("<button>"),C=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},
|
f]);var G=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){G.html(ca($(this).getval()))}}])).append(G)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}var f=$("<button>"),C=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},
|
||||||
$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(f).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(C);if(""==b){var s=mist.stored.get();"viewmode"in s&&(b=s.viewmode)}f.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),P=function(a,
|
$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(f).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(C);if(""==b){var s=mist.stored.get();"viewmode"in s&&(b=s.viewmode)}f.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),R=function(a,
|
||||||
b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},Q=function(b,d,f){C.remove();switch(b){case "thumbnails":var e=$("<div>").addClass("preview_icons"),g;g=f||[];d.sort();d.unshift("");C.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=
|
b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},S=function(b,d,f){C.remove();switch(b){case "thumbnails":var g=$("<div>").addClass("preview_icons"),e;e=f||[];d.sort();d.unshift("");C.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=
|
||||||
$(this).val();e.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(e);for(var h in d){var b=d[h],i="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;
|
$(this).val();g.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);for(var h in d){var b=d[h],i="",j=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;
|
||||||
mist.send(function(){UI.navto("Streams")},b)}}),l=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),f=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),n=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];l=j="";n.addClass("wildcard")}else{i=
|
mist.send(function(){UI.navto("Streams")},b)}}),l=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),f=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),n=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];l=j="";n.addClass("wildcard")}else{i=
|
||||||
mist.data.streams[b].source;if(g.indexOf(b)>-1){k=f="";n.addClass("folder")}}e.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(n).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(l).append(j).append(f).append(k)).attr("title",b).attr("data-stream",b))}break;default:var m=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
mist.data.streams[b].source;if(e.indexOf(b)>-1){k=f="";n.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(n).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(l).append(j).append(f).append(k)).attr("title",b).attr("data-stream",b))}break;default:var m=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
||||||
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(m);c.append(h);h.stupidtable();var o=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,
|
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(m);c.append(h);h.stupidtable();var o=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,
|
||||||
y,mist.data.streams);var a=0;m.html("");d.sort();for(var b in d){var c=d[b],f;f=c in mist.data.streams?mist.data.streams[c]:y[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),e=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!="undefined"){var h=mist.data.totals[c].all_protocols.clients,e=0;if(h.length){for(a in h)e=e+h[a][1];e=Math.round(e/h.length)}}g.html(UI.format.number(e));if(e==0&&f.online==1)f.online=2;e=$("<td>").css("text-align",
|
y,mist.data.streams);var a=0;m.html("");d.sort();for(var b in d){var c=d[b],f;f=c in mist.data.streams?mist.data.streams[c]:y[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),e=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!="undefined"){var h=mist.data.totals[c].all_protocols.clients,e=0;if(h.length){for(a in h)e=e+h[a][1];e=Math.round(e/h.length)}}g.html(UI.format.number(e));if(e==0&&f.online==1)f.online=2;e=$("<td>").css("text-align",
|
||||||
"right").css("white-space","nowrap");(!("ischild"in f)||!f.ischild)&&e.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));h=$("<span>").text(c);
|
"right").css("white-space","nowrap");(!("ischild"in f)||!f.ischild)&&e.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));h=$("<span>").text(c);
|
||||||
f.ischild&&h.css("padding-left","1em");var da=UI.format.status(f),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[c]){da.html("");i="";g.html("");j=""}m.append($("<tr>").data("index",c).html($("<td>").html(h).attr("title",c).addClass("overflow_ellipsis")).append($("<td>").text(f.source).attr("title",f.source).addClass("description").addClass("overflow_ellipsis").css("max-width",
|
f.ischild&&h.css("padding-left","1em");var D=UI.format.status(f),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),j=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[c]){D.html("");i="";g.html("");j=""}m.append($("<tr>").data("index",c).html($("<td>").html(h).attr("title",c).addClass("overflow_ellipsis")).append($("<td>").text(f.source).attr("title",f.source).addClass("description").addClass("overflow_ellipsis").css("max-width",
|
||||||
"20em")).append($("<td>").data("sort-value",f.online).html(da)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(e));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(g in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[g].source)){y[g].source=y[g].source+"*";y[g].filesfound=null;mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=
|
"20em")).append($("<td>").data("sort-value",f.online).html(D)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(j)).append(e));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(e in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[e].source)){y[e].source=y[e].source+"*";y[e].filesfound=null;mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=
|
||||||
0||f.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[d])){var e=c+"+"+a.browse.files[d];y[e]=P(e,mist.data.streams[c]);y[e].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[g].source},{stream:g});p++}}if(p==0){mist.send(function(){o()},
|
0||f.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[d])){var e=c+"+"+a.browse.files[d];y[e]=R(e,mist.data.streams[c]);y[e].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[e].source},{stream:e});p++}}if(p==0){mist.send(function(){o()},
|
||||||
{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}};if(mist.data.LTS){var R=0,ba=0,t={},ca=[];for(s in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[s].source))ca.push(s),mist.send(function(a,c){var d=c.stream,f;for(f in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}};if(mist.data.LTS){var T=0,da=0,t={},ea=[];for(s in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[s].source))ea.push(s),mist.send(function(a,c){var d=c.stream,f;for(f in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
||||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[f])&&(t[d+"+"+a.browse.files[f]]=true);ba++;R==ba&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=P(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));t.sort();Q(b,
|
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[f])&&(t[d+"+"+a.browse.files[f]]=true);da++;T==da&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=R(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));t.sort();S(b,
|
||||||
t,ca)},{active_streams:true})},{browse:mist.data.streams[s].source},{stream:s}),R++;0==R&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=P(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);mist.data.streams&&(t=t.concat(Object.keys(mist.data.streams)));t.sort();Q(b,t)},{active_streams:!0})}else Q(b,Object.keys(mist.data.streams));
|
t,ea)},{active_streams:true})},{browse:mist.data.streams[s].source},{stream:s}),T++;0==T&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=R(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);mist.data.streams&&(t=t.concat(Object.keys(mist.data.streams)));t.sort();S(b,t)},{active_streams:!0})}else S(b,Object.keys(mist.data.streams));
|
||||||
break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}j=!1;""!=b&&(j=!0);if(j){var r=b,m=mist.data.streams[r];c.find("h2").append(' "'+r+'"')}else c.html($("<h2>").text("New Stream")),m={};r=[];for(f in mist.data.capabilities.inputs)r.push(mist.data.capabilities.inputs[f].source_match);var K=$("<div>"),ea=function(a){if(!mist.data.streams)mist.data.streams={};mist.data.streams[m.name]=m;b!=m.name&&delete mist.data.streams[b];
|
break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");break}j=!1;""!=b&&(j=!0);if(j){var r=b,m=mist.data.streams[r];c.find("h2").append(' "'+r+'"')}else c.html($("<h2>").text("New Stream")),m={};r=[];for(f in mist.data.capabilities.inputs)r.push(mist.data.capabilities.inputs[f].source_match);var M=$("<div>"),fa=function(a){if(!mist.data.streams)mist.data.streams={};mist.data.streams[m.name]=m;b!=m.name&&delete mist.data.streams[b];
|
||||||
var c={};if(mist.data.LTS){c.addstream={};c.addstream[m.name]=m;if(b!=m.name)c.deletestream=[b]}else c.streams=mist.data.streams;if(m.stop_sessions&&b!=""){c.stop_sessions=b;delete m.stop_sessions}mist.send(function(){delete mist.data.streams[m.name].online;delete mist.data.streams[m.name].error;UI.navto(a,a=="Preview"?m.name:"")},c)},fa=$("<style>").text("button.saveandpreview { display: none; }");c.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:m,
|
var c={};if(mist.data.LTS){c.addstream={};c.addstream[m.name]=m;if(b!=m.name)c.deletestream=[b]}else c.streams=mist.data.streams;if(m.stop_sessions&&b!=""){c.stop_sessions=b;delete m.stop_sessions}mist.send(function(){delete mist.data.streams[m.name].online;delete mist.data.streams[m.name].error;UI.navto(a,a=="Preview"?m.name:"")},c)},ga=$("<style>").text("button.saveandpreview { display: none; }"),J=$("<span>"),ha=function(){var a=c.find("[name=name]").val(),b=parseURL(mist.user.host),d=c.find("[name=source]").val().match(/@.*/);
|
||||||
index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",filetypes:r,pointer:{main:m,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>Input</td><td>Syntax</td><td>Explanation</td></tr> <tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>Password is the application under which to push to MistServer, if it doesn't match the stream will be rejected. Password is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr></table>",
|
d&&(d=d[0].substring(1));var f={RTMP:mist.data.capabilities.connectors.RTMP.optional.port["default"],RTSP:mist.data.capabilities.connectors.RTSP.optional.port["default"]},e={RTMP:1935,RTSP:554},g;for(g in f){for(var h in mist.data.config.protocols){var i=mist.data.config.protocols[h];if(i.connector==g){if("port"in i)f[g]=i.port;break}}f[g]=f[g]==e[g]?"":":"+f[g]}J.find(".field.RTMP").setval("rtmp://"+b.host+f.RTMP+"/"+(d?d:"live")+"/"+(a==""?"STREAMNAME":a));J.find(".field.RTSP").setval("rtsp://"+
|
||||||
"function":function(){var a=$(this).val();fa.remove();if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)K.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];K.html($("<h3>").text(b.name+" Input options"));var f=
|
b.host+f.RTSP+"/"+(a==""?"STREAMNAME":a)+(d?"?pass="+d:""))};c.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:m,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",filetypes:r,pointer:{main:m,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>Input</td><td>Syntax</td><td>Explanation</td></tr> <tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>Password is the application under which to push to MistServer, if it doesn't match the stream will be rejected. Password is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr></table>",
|
||||||
mist.convertBuildOptions(b,m);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&f.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:m,index:"always_on"}});K.append(UI.buildUI(f));b.name=="Folder"&&c.append(fa)}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,
|
"function":function(){var a=$(this).val();ga.remove();J.html("");if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)M.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];M.html($("<h3>").text(b.name+" Input options"));
|
||||||
pointer:{main:m,index:"stop_sessions"}},$("<br>"),{type:"custom",custom:K},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:m,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,
|
var f=mist.convertBuildOptions(b,m);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&f.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:m,index:"always_on"}});M.append(UI.buildUI(f));b.name=="Folder"&&c.append(ga);if(b.name=="Buffer"){J.html("<br>").append(UI.buildUI([$("<span>").text("Configure your source to push to:"),{label:"RTMP",type:"span",
|
||||||
pointer:{main:m,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:m,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:m,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){ea("Streams")}},{type:"save",label:"Save and Preview","function":function(){ea("Preview")},classes:["saveandpreview"]}]}]));break;case "Preview":""==
|
clipboard:true,readonly:true,classes:["RTMP"]},{label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]}]));ha()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:m,index:"stop_sessions"}},J,$("<br>"),{type:"custom",custom:M},$("<br>"),$("<h3>").text("Encryption"),{type:"help",help:"To enable encryption, the licence acquisition url must be entered, as well as either the content key or the key ID and seed.<br>Unsure how you should fill in your encryption or missing your preferred encryption? Please contact us."},
|
||||||
b&&UI.navto("Streams");s=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)s=d.port?":"+d.port:":8080";var r=parseURL(mist.user.host),L=r.protocol+r.host+s+"/",F=$("<div>").css({display:"flex","flex-flow":"row wrap"}),r="";-1==b.indexOf("+")&&(r=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",
|
{label:"License acquisition url",type:"str",LTSonly:!0,pointer:{main:m,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:m,index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:m,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:m,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){fa("Streams")}},
|
||||||
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(F);var D=encodeURIComponent(b),f=$("<div>");F.append(f);var S=$("<div>"),M=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){T()}),I=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){T()}),r=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:M,help:"Choose a player to preview"},
|
{type:"save",label:"Save and Preview","function":function(){fa("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){ha()});break;case "Preview":""==b&&UI.navto("Streams");s=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)s=d.port?":"+d.port:":8080";var r=parseURL(mist.user.host),N=r.protocol+r.host+s+"/",G=$("<div>").css({display:"flex","flex-flow":"row wrap"}),r="";-1==b.indexOf("+")&&(r=$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",
|
||||||
{label:"Use source",type:"DOMfield",DOMfield:I,help:"Choose an output type to preview"}]),G=$("<div>").addClass("mistvideo").text("Loading player..");f.append(G).append(S).append(r);var T=function(){G.html("");A.html("");var a={target:G[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,loop:true};if(M.val()!="")a.forcePlayer=M.val();if(I.val()!="")a.forceType=I.val();mistPlay(b,a)},A=$("<div>").addClass("player_log");f.append($("<div>").append($("<h3>").text("Player log:")).append(A));
|
b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(G);var E=encodeURIComponent(b),f=$("<div>");G.append(f);var U=$("<div>"),O=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){V()}),K=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){V()}),
|
||||||
G.on("log error",function(a){var b=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(b=true);A.append($("<div>").append($("<span>").text("["+UI.format.time((new Date).getTime()/1E3)+"]").css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).addClass(a.type=="error"?"red":""));b&&A.scrollTop(A[0].scrollHeight)});var ga=function(){S.text("");var a=document.createElement("script");c.append(a);a.src=L+"player.js";a.onerror=function(){G.html("Failed to load player.js").append($("<button>").text("Reload").css("display",
|
r=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:O,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:K,help:"Choose an output type to preview"}]),H=$("<div>").addClass("mistvideo").text("Loading player..");f.append(H).append(U).append(r);var V=function(){H.html("");A.html("");var a={target:H[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,loop:true};if(O.val()!="")a.forcePlayer=O.val();if(K.val()!=
|
||||||
"block").click(function(){ga()}))};a.onload=function(){for(var d in mistplayers)M.append($("<option>").text(mistplayers[d].name).val(d));T();G.on("initialized",function(){if(I.children().length<=1)for(var a in mistvideo[b].source){var c=UI.humanMime(mistvideo[b].source[a].type);I.append($("<option>").val(mistvideo[b].source[a].type).text(c?c+" ("+mistvideo[b].source[a].type+")":UI.format.capital(mistvideo[b].source[a].type)))}a=mistvideo[b].embedded[mistvideo[b].embedded.length-1];c=UI.humanMime(a.player.options.source.type);
|
"")a.forceType=K.val();mistPlay(b,a)},A=$("<div>").addClass("player_log");f.append($("<div>").append($("<h3>").text("Player log:")).append(A));H.on("log error",function(a){var b=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(b=true);A.append($("<div>").append($("<span>").text("["+UI.format.time((new Date).getTime()/1E3)+"]").css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).addClass(a.type=="error"?"red":""));b&&A.scrollTop(A[0].scrollHeight)});var ia=function(){U.text("");
|
||||||
S.html("You're watching "+(c?c+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});c[0].removeChild(a)}};ga();var f=$("<div>").append($("<h3>").text("Meta information")),N=$("<span>").text("Loading..");f.append(N);F.append(f);$.ajax({type:"GET",url:L+"json_"+D+".js",success:function(a){var b=a.meta;if(b){a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});
|
var a=document.createElement("script");c.append(a);a.src=N+"player.js";a.onerror=function(){H.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){ia()}))};a.onload=function(){for(var d in mistplayers)O.append($("<option>").text(mistplayers[d].name).val(d));V();H.on("initialized",function(){if(K.children().length<=1)for(var a in mistvideo[b].source){var c=UI.humanMime(mistvideo[b].source[a].type);K.append($("<option>").val(mistvideo[b].source[a].type).text(c?
|
||||||
"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(b.buffer_window,"ms")});var c={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(b.tracks);
|
c+" ("+mistvideo[b].source[a].type+")":UI.format.capital(mistvideo[b].source[a].type)))}a=mistvideo[b].embedded[mistvideo[b].embedded.length-1];c=UI.humanMime(a.player.options.source.type);U.html("You're watching "+(c?c+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});c[0].removeChild(a)}};ia();var f=$("<div>").append($("<h3>").text("Meta information")),P=$("<span>").text("Loading..");
|
||||||
d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var f in d){var e=d[f],g=b.tracks[e];switch(g.type){case "audio":c.audio.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),g.channels,UI.format.addUnit(UI.format.number(g.rate),"Hz"),"lang"in g?g.lang:"unknown"]});break;case "video":c.video.content.push({header:"Track "+
|
f.append(P);G.append(f);$.ajax({type:"GET",url:N+"json_"+E+".js",success:function(a){var b=a.meta;if(b){a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(b.buffer_window,"ms")});var c={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec",
|
||||||
e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),UI.format.addUnit(g.width,"x ")+UI.format.addUnit(g.height,"px"),UI.format.addUnit(UI.format.number(g.fpks/1E3),"fps"),"lang"in g?g.lang:"unknown"]});break;case "subtitle":c.subtitle.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/
|
"Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(b.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var f in d){var e=d[f],g=b.tracks[e];switch(g.type){case "audio":c.audio.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/
|
||||||
1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),"lang"in g?g.lang:"unknown"]})}}f=["audio","video","subtitle"];b=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(e in f)c[f[e]].content.length&&b.append(UI.buildVheaderTable(c[f[e]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(b);N.html(UI.buildUI(a))}else N.html("No meta information available.")},error:function(){N.html("Error while retrieving stream info.")}});
|
1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),g.channels,UI.format.addUnit(UI.format.number(g.rate),"Hz"),"lang"in g?g.lang:"unknown"]});break;case "video":c.video.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),UI.format.addUnit(g.width,"x ")+UI.format.addUnit(g.height,
|
||||||
break;case "Embed":""==b&&UI.navTo("Streams");r="";-1==b.indexOf("+")&&(r=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var O=$("<span>");c.append(O);D=
|
"px"),UI.format.addUnit(UI.format.number(g.fpks/1E3),"fps"),"lang"in g?g.lang:"unknown"]});break;case "subtitle":c.subtitle.content.push({header:"Track "+e.split("_").pop(),body:[g.codec,UI.format.duration((g.lastms-g.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(g.firstms/1E3)+" to "+UI.format.duration(g.lastms/1E3)+"</span>",UI.format.bytes(g.bps,1),"lang"in g?g.lang:"unknown"]})}}f=["audio","video","subtitle"];b=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});
|
||||||
encodeURIComponent(b);r=parseURL(mist.user.host);s=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)s=d.port?":"+d.port:":8080";var E=L=r.protocol+r.host+s+"/";otherhost&&(f=parseURL(otherhost),E=f.protocol+f.host+s+"/");var U={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},U),f=UI.stored.getOpts();"embedoptions"in f&&
|
for(e in f)c[f[e]].content.length&&b.append(UI.buildVheaderTable(c[f[e]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(b);P.html(UI.buildUI(a))}else P.html("No meta information available.")},error:function(){P.html("Error while retrieving stream info.")}});break;case "Embed":""==b&&UI.navTo("Streams");r="";-1==b.indexOf("+")&&(r=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",
|
||||||
(o=$.extend(o,f.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));f={};switch(o.controls){case "stock":f.controls="stock";break;case !0:f.controls=1;break;case !1:f.controls=0}var w=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}UI.stored.saveOpt("embedoptions",o);for(var c=b+"_",d=12,f="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+
|
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var Q=$("<span>");c.append(Q);E=encodeURIComponent(b);r=parseURL(mist.user.host);s=":8080";for(f in mist.data.config.protocols)if(d=mist.data.config.protocols[f],"HTTP"==d.connector||"HTTP.exe"==d.connector)s=d.port?":"+d.port:":8080";var F=N=r.protocol+r.host+s+"/";otherhost&&(f=parseURL(otherhost),F=f.protocol+f.host+s+"/");var W={forcePlayer:"",
|
||||||
61);f=f+g}var c=c+f,d=['target: document.getElementById("'+c+'")'],e;for(e in o)o[e]!=U[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(U[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+E+D+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+
|
forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},W),f=UI.stored.getOpts();"embedoptions"in f&&(o=$.extend(o,f.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));f={};switch(o.controls){case "stock":f.controls="stock";break;case !0:f.controls=1;break;case !1:f.controls=0}var w=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);
|
||||||
d.join(",\n "));e.push(" });");e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+E+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");e.push("</div>");return e.join("\n")},V=$("<span>").text("Loading.."),s=w(o),H=$("<div>").text("Loading..").css("display","flex");O.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type",
|
default:return b}}UI.stored.saveOpt("embedoptions",o);for(var c=b+"_",d=12,f="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+61);f=f+g}var c=c+f,d=['target: document.getElementById("'+c+'")'],e;for(e in o)o[e]!=W[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(W[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+F+E+'.html" target="_blank">');e.push(" Click here to play this video");
|
||||||
"text").addClass("field").val(otherhost?otherhost:r.protocol+r.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost=$(this).closest("label").find("input").val();UI.navto("Embed",b)})))))).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:E+"json_"+D+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:E+"info_"+D+".js",readonly:!0,clipboard:!0,
|
e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");e.push(' mistPlay("'+b+'",{');e.push(" "+d.join(",\n "));e.push(" });");e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+F+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");e.push("</div>");
|
||||||
help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:E+D+".html",readonly:!0,qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:s,rows:s.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},
|
return e.join("\n")},X=$("<span>").text("Loading.."),s=w(o),I=$("<div>").text("Loading..").css("display","flex");Q.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type","text").addClass("field").val(otherhost?otherhost:r.protocol+r.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost=
|
||||||
$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["",
|
$(this).closest("label").find("input").val();UI.navto("Embed",b)})))))).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:F+"json_"+E+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:F+"info_"+E+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:F+E+".html",readonly:!0,qrcode:!0,
|
||||||
"Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular source."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:f,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(w(o))},
|
clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:s,rows:s.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},
|
||||||
help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(w(o))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(w(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,
|
{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular source."},{label:"Controls",
|
||||||
unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(w(o))},
|
type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:f,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(w(o))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(w(o))},
|
||||||
help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(w(o))},help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(w(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",
|
help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(w(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",
|
||||||
pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=$(this).getval();$(".embed_code").setval(w(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:H,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),V]));$.ajax({type:"GET",url:E+"json_"+D+".js",success:function(a){var b=[],c=O.find(".forceType"),d;for(d in a.source){var e=
|
pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(w(o))},help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(w(o))},
|
||||||
a.source[d],f=UI.humanMime(e.type);b.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}V.html(UI.buildUI(b));H.html("");b={};for(d in a.meta.tracks){c=a.meta.tracks[d];c.type!="audio"&&c.type!="video"||(c.type in b?b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+
|
help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(w(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=
|
||||||
1)]):b[c.type]=[["",UI.format.capital(c.type)+" track 1"]])}if(Object.keys(b).length){H.closest("label").show();for(d in b){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(o))});H.append(a);b[d].push([-1,"No "+d]);for(var g in b[d])a.append($("<option>").val(b[d][g][0]).text(b[d][g][1]));if(d in o.setTracks){a.val(o.setTracks[d]);
|
$(this).getval();$(".embed_code").setval(w(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:I,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),X]));$.ajax({type:"GET",url:F+"json_"+E+".js",success:function(a){var b=[],c=Q.find(".forceType"),d;for(d in a.source){var e=a.source[d],f=UI.humanMime(e.type);b.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);
|
||||||
if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(w(o))}}}}else H.closest("label").hide()},error:function(){V.html("Error while retrieving stream info.");H.closest("label").hide();o.setTracks={}}});f=document.createElement("script");f.src=L+"player.js";document.head.appendChild(f);f.onload=function(){var a=O.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};f.onerror=function(){document.head.removeChild(this)};
|
c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}X.html(UI.buildUI(b));I.html("");b={};for(d in a.meta.tracks){c=a.meta.tracks[d];c.type!="audio"&&c.type!="video"||(c.type in b?b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+1)]):b[c.type]=[["",UI.format.capital(c.type)+" track 1"]])}if(Object.keys(b).length){I.closest("label").show();for(d in b){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==
|
||||||
break;case "Push":var z=$("<div>").text("Loading..");c.append(z);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,f;for(f in c.push_list)if(a.indexOf(c.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else b()},{push_list:1})},1E3)}function c(d,f){var g=$("<span>");d.length>=4&&d[2]!=d[3]?g.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin",
|
""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(o))});I.append(a);b[d].push([-1,"No "+d]);for(var g in b[d])a.append($("<option>").val(b[d][g][0]).text(b[d][g][1]));if(d in o.setTracks){a.val(o.setTracks[d]);if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(w(o))}}}}else I.closest("label").hide()},error:function(){X.html("Error while retrieving stream info.");I.closest("label").hide();o.setTracks=
|
||||||
"0 0.5em")).append($("<span>").text(d[3])):g.append($("<span>").text(d[2]));var h=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+d[1]+" to "+d[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));f=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:d[1],target:d[2]}}):
|
{}}});f=document.createElement("script");f.src=N+"player.js";document.head.appendChild(f);f.onload=function(){var a=Q.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};f.onerror=function(){document.head.removeChild(this)};break;case "Push":var z=$("<div>").text("Loading..");c.append(z);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=
|
||||||
mist.send(function(){b([d[0]])},{push_stop:[d[0]]})}}));f=="Automatic"&&h.append($("<button>").text("Remove and stop pushes").click(function(){if(confirm("Are you sure you want to remove this automatic push, and also stop all pushes matching it?\n"+d[1]+" to "+d[2])){var c=$(this).closest("tr");c.html($("<td colspan=99>").html($("<span>").addClass("red").text("Removing and stopping..")));var f=[],g;for(g in a.push_list)if(d[1]==a.push_list[g][1]&&d[2]==a.push_list[g][2]){f.push(a.push_list[g][0]);
|
true,f;for(f in c.push_list)if(a.indexOf(c.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else b()},{push_list:1})},1E3)}function c(d,f){var g=$("<span>");d.length>=4&&d[2]!=d[3]?g.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(d[3])):g.append($("<span>").text(d[2]));var h=$("<td>").append($("<button>").text(f=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+
|
||||||
e.find("tr[data-pushid="+a.push_list[g][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.remove();b(f)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:f})}}));return $("<tr>").attr("data-pushid",d[0]).append($("<td>").text(d[1])).append($("<td>").append(g.children())).append(h)}z.html("");var d=a.push_settings;d||(d={});z.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},
|
$(this).text().toLowerCase()+" this push?\n"+d[1]+" to "+d[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));f=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:d[1],target:d[2]}}):mist.send(function(){b([d[0]])},{push_stop:[d[0]]})}}));f=="Automatic"&&h.append($("<button>").text("Remove and stop pushes").click(function(){if(confirm("Are you sure you want to remove this automatic push, and also stop all pushes matching it?\n"+
|
||||||
$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",
|
d[1]+" to "+d[2])){var c=$(this).closest("tr");c.html($("<td colspan=99>").html($("<span>").addClass("red").text("Removing and stopping..")));var f=[],g;for(g in a.push_list)if(d[1]==a.push_list[g][1]&&d[2]==a.push_list[g][2]){f.push(a.push_list[g][0]);e.find("tr[data-pushid="+a.push_list[g][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.remove();b(f)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:f})}}));return $("<tr>").attr("data-pushid",
|
||||||
label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=e.clone();if("push_list"in a)for(var g in a.push_list)e.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list)f.append(c([-1,a.push_auto_list[g][0],a.push_auto_list[g][1]],"Automatic"));z.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
|
d[0]).append($("<td>").text(d[1])).append($("<td>").append(g.children())).append(h)}z.html("");var d=a.push_settings;d||(d={});z.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:d,index:"wait"},
|
||||||
"auto")}));f.find("tr").length==1?z.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):z.append(f);z.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)z.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var f=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),
|
LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=e.clone();
|
||||||
j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){f.indexOf(a.push_list[g][1])==-1&&f.push(a.push_list[g][1]);h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}f.sort();h.sort();for(g in f)i.append($("<option>").text(f[g]));for(g in h)j.append($("<option>").text(h[g]));z.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},
|
if("push_list"in a)for(var g in a.push_list)e.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list)f.append(c([-1,a.push_auto_list[g][0],a.push_auto_list[g][1]],"Automatic"));z.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?z.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):z.append(f);
|
||||||
{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");
|
z.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)z.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var f=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){f.indexOf(a.push_list[g][1])==-1&&f.push(a.push_list[g][1]);
|
||||||
var f={},g;for(g in a.push_list)if((c==""||a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))f[a.push_list[g][0]]=a.push_list[g];if(Object.keys(f).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in f)c=c+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(c)){f=Object.keys(f);mist.send(function(){b(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},
|
h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}f.sort();h.sort();for(g in f)i.append($("<option>").text(f[g]));for(g in h)j.append($("<option>").text(h[g]));z.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
|
||||||
{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1});break}var u,W=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}b=="auto"&&c.find("h2").text("Add automatic push");var g={};c.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var f={},g;for(g in a.push_list)if((c==""||
|
||||||
|
a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))f[a.push_list[g][0]]=a.push_list[g];if(Object.keys(f).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in f)c=c+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(c)){f=Object.keys(f);mist.send(function(){b(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},{push_settings:1,push_list:1,push_auto_list:1});
|
||||||
|
break;case "Start Push":if(!("capabilities"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1});break}var u,Y=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}b=="auto"&&c.find("h2").text("Add automatic push");var g={};c.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
||||||
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:u,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
|
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:u,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
|
||||||
pointer:{main:g,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[b=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
pointer:{main:g,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[b=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
||||||
mist.send(function(a){(u=a.active_streams)||(u=[]);var a=[],b;for(b in u)u[b].indexOf("+")!=-1&&a.push(u[b].replace(/\+.*/,"")+"+");u=u.concat(a);var c=0,d=0;for(b in mist.data.streams){u.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){u.push(b+"+");mist.send(function(a,b){var f=b.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,
|
mist.send(function(a){(u=a.active_streams)||(u=[]);var a=[],b;for(b in u)u[b].indexOf("+")!=-1&&a.push(u[b].replace(/\+.*/,"")+"+");u=u.concat(a);var c=0,d=0;for(b in mist.data.streams){u.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){u.push(b+"+");mist.send(function(a,b){var f=b.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,
|
||||||
"/"+a.browse.files[g])&&u.push(f+"+"+a.browse.files[g]);d++;if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();W()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();W()}},{active_streams:1}):(u=Object.keys(mist.data.streams),W());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});g=$("<tbody>");s=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type",
|
"/"+a.browse.files[g])&&u.push(f+"+"+a.browse.files[g]);d++;if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Y()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();Y()}},{active_streams:1}):(u=Object.keys(mist.data.streams),Y());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});g=$("<tbody>");s=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Trigger on").attr("data-sort-type",
|
||||||
"string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(g);c.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(s);
|
"string").addClass("sorting-asc")).append($("<th>").text("Applies to").attr("data-sort-type","string")).append($("<th>").text("Handler").attr("data-sort-type","string")).append($("<th>")))).append(g);c.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(s);
|
||||||
s.stupidtable();s=mist.data.config.triggers;for(f in s)for(r in s[f])g.append($("<tr>").attr("data-index",f+","+r).append($("<td>").text(f)).append($("<td>").text(s[f][r][2].join(", "))).append($("<td>").text(s[f][r][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+
|
s.stupidtable();s=mist.data.config.triggers;for(f in s)for(r in s[f])g.append($("<tr>").attr("data-index",f+","+r).append($("<td>").text(f)).append($("<td>").text(s[f][r][2].join(", "))).append($("<td>").text(s[f][r][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+
|
||||||
a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});b?(b=b.split(","),f=mist.data.config.triggers[b[0]][b[1]],m={triggeron:b[0],appliesto:f[2],url:f[0],async:f[1],"default":f[3]}):(c.html($("<h2>").text("New Trigger")),m={});c.append(UI.buildUI([{label:"Trigger on",
|
a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});b?(b=b.split(","),f=mist.data.config.triggers[b[0]][b[1]],m={triggeron:b[0],appliesto:f[2],url:f[0],async:f[1],"default":f[3]}):(c.html($("<h2>").text("New Trigger")),m={});c.append(UI.buildUI([{label:"Trigger on",
|
||||||
|
@ -159,20 +161,20 @@ pointer:{main:m,index:"triggeron"},help:"For what event this trigger should acti
|
||||||
break;default:$("[name=appliesto]").closest(".UIelement").show()}}},{label:"Applies to",pointer:{main:m,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:m,index:"url"},validate:["required"],
|
break;default:$("[name=appliesto]").closest(".UIelement").show()}}},{label:"Applies to",pointer:{main:m,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:m,index:"url"},validate:["required"],
|
||||||
type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",pointer:{main:m,index:"async"},LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:m,index:"default"},
|
type:"str",LTSonly:!0},{label:"Blocking",type:"checkbox",help:"If checked, pauses processing and uses the response of the handler. If the response does not start with 1, true, yes or cont, further processing is aborted. If unchecked, processing is never paused and the response is not checked.",pointer:{main:m,index:"async"},LTSonly:!0},{label:"Default response",type:"str",help:"For blocking requests, the default response in case the handler cannot be executed for any reason.",pointer:{main:m,index:"default"},
|
||||||
LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){b&&mist.data.config.triggers[b[0]].splice(b[1],1);var a=[m.url,m.async?true:false,typeof m.appliesto!="undefined"?m.appliesto:[]];typeof m["default"]!="undefined"&&a.push(m["default"]);m.triggeron in mist.data.config.triggers||(mist.data.config.triggers[m.triggeron]=[]);mist.data.config.triggers[m.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},
|
LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){b&&mist.data.config.triggers[b[0]].splice(b[1],1);var a=[m.url,m.async?true:false,typeof m.appliesto!="undefined"?m.appliesto:[]];typeof m["default"]!="undefined"&&a.push(m["default"]);m.triggeron in mist.data.config.triggers||(mist.data.config.triggers[m.triggeron]=[]);mist.data.config.triggers[m.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},
|
||||||
{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var ha=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){X();ha.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",
|
{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var ja=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){Z();ja.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",
|
||||||
type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){X()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:ha,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));g=$("<tbody>").css("font-size",
|
type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){Z()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:ja,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));g=$("<tbody>").css("font-size",
|
||||||
"0.9em");c.append($("<table>").append(g));var ja=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},X=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();g.html("");for(var b in a)g.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(ja(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align",
|
"0.9em");c.append($("<table>").append(g));var la=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},Z=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();g.html("");for(var b in a)g.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],"long")).css("white-space","nowrap")).append($("<td>").html(la(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align",
|
||||||
"left")))}};X();break;case "Statistics":var B=$("<span>").text("Loading..");c.append(B);var m={},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},J={};for(f in mist.data.streams)J[f]=!0;for(f in mist.data.active_streams)J[mist.data.active_streams[f]]=!0;var J=Object.keys(J).sort(),Y=[];for(f in mist.data.config.protocols)Y.push(mist.data.config.protocols[f].connector);Y.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=
|
"left")))}};Z();break;case "Statistics":var B=$("<span>").text("Loading..");c.append(B);var m={},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},L={};for(f in mist.data.streams)L[f]=!0;for(f in mist.data.active_streams)L[mist.data.active_streams[f]]=!0;var L=Object.keys(L).sort(),aa=[];for(f in mist.data.config.protocols)aa.push(mist.data.config.protocols[f].connector);aa.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=
|
||||||
UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:m,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");
|
UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new","New graph"]],pointer:{main:m,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=B.find(".graph_xaxis"),b=B.find(".graph_id");
|
||||||
if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:m,index:"id"},classes:["graph_id"],validate:[function(a){return a in
|
if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:m,index:"id"},classes:["graph_id"],validate:[function(a){return a in
|
||||||
x?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:m,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",
|
x?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:m,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",
|
||||||
true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:m,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
|
true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:m,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",
|
||||||
true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",J],["protocol","The protocol:",Y]],pointer:{main:m,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(m.graph=="new"){a=UI.plot.addGraph(m,b);x[a.id]=a;B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",L],["protocol","The protocol:",aa]],pointer:{main:m,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(m.graph=="new"){a=UI.plot.addGraph(m,b);x[a.id]=a;B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||||
x[m.graph];var c=UI.plot.datatype.getOptions({datatype:m.datatype,origin:m.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=B.find("select.graph_ids");for(a in x){var f=UI.plot.addGraph(x[a],b);d.append($("<option>").text(f.id)).val(f.id);var g=[],e;for(e in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[e].datatype,origin:x[a].datasets[e].origin});g.push(h)}f.datasets=g;x[f.id]=f}d.trigger("change");
|
x[m.graph];var c=UI.plot.datatype.getOptions({datatype:m.datatype,origin:m.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));var b=$("<div>").addClass("graph_container");c.append(b);var d=B.find("select.graph_ids");for(a in x){var f=UI.plot.addGraph(x[a],b);d.append($("<option>").text(f.id)).val(f.id);var g=[],e;for(e in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[e].datatype,origin:x[a].datasets[e].origin});g.push(h)}f.datasets=g;x[f.id]=f}d.trigger("change");
|
||||||
UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");break}var Z=$("<table>"),C=$("<table>"),r={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(f in mist.data.capabilities.cpu)s=mist.data.capabilities.cpu[f],r.content.push({header:"CPU #"+(Number(f)+1),
|
UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");break}var ba=$("<table>"),C=$("<table>"),r={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(f in mist.data.capabilities.cpu)s=mist.data.capabilities.cpu[f],r.content.push({header:"CPU #"+(Number(f)+
|
||||||
body:[s.model,UI.format.addUnit(UI.format.number(s.mhz),"MHz"),s.cores,s.threads]});var f=UI.buildVheaderTable(r),ia=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used","Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-
|
1),body:[s.model,UI.format.addUnit(UI.format.number(s.mhz),"MHz"),s.cores,s.threads]});var f=UI.buildVheaderTable(r),ka=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used","Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-
|
||||||
a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);Z.replaceWith(a);Z=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);C.replaceWith(b);C=b};
|
a.swapfree)*1048576),UI.format.addUnit("","N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);ba.replaceWith(a);ba=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);C.replaceWith(b);C=
|
||||||
ia();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(Z)).append($("<td>").append(C))).append($("<tr>").append($("<td>").append(f).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ia()},{capabilities:true})},3E4);break;case "Email for Help":f=$.extend({},mist.data);
|
b};ka();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width","auto").addClass("nolay").append($("<tr>").append($("<td>").append(ba)).append($("<td>").append(C))).append($("<tr>").append($("<td>").append(f).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){ka()},{capabilities:true})},3E4);break;case "Email for Help":f=$.extend({},mist.data);
|
||||||
delete f.statistics;delete f.totals;delete f.clients;delete f.capabilities;f=JSON.stringify(f);f="Version: "+mist.data.config.version+"\n\nConfig:\n"+f;m={};c.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:m,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
|
delete f.statistics;delete f.totals;delete f.clients;delete f.capabilities;f=JSON.stringify(f);f="Version: "+mist.data.config.version+"\n\nConfig:\n"+f;m={};c.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},{type:"str",label:"Your name",validate:["required"],pointer:{main:m,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],
|
||||||
pointer:{main:m,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:m,index:"subject"}},{type:"hidden",value:"-",pointer:{main:m,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:m,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:f,pointer:{main:m,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact?skin=plain",
|
pointer:{main:m,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:m,index:"subject"}},{type:"hidden",value:"-",pointer:{main:m,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:m,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:f,pointer:{main:m,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact?skin=plain",
|
||||||
data:m,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}}}};"origin"in location||(location.origin=location.protocol+"//"+location.hostname+(location.port?":"+location.port:""));
|
data:m,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}}}};"origin"in location||(location.origin=location.protocol+"//"+location.hostname+(location.port?":"+location.port:""));
|
||||||
|
|
56
lsp/mist.js
56
lsp/mist.js
|
@ -2876,7 +2876,38 @@ var UI = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var $style = $('<style>').text('button.saveandpreview { display: none; }');
|
var $style = $('<style>').text('button.saveandpreview { display: none; }');
|
||||||
|
var $livestreamhint = $('<span>');
|
||||||
|
function updateLiveStreamHint() {
|
||||||
|
var streamname = $main.find('[name=name]').val();
|
||||||
|
var host = parseURL(mist.user.host);
|
||||||
|
var passw = $main.find('[name=source]').val().match(/@.*/);
|
||||||
|
if (passw) { passw = passw[0].substring(1); }
|
||||||
|
|
||||||
|
var port = {
|
||||||
|
RTMP: mist.data.capabilities.connectors.RTMP.optional.port['default'],
|
||||||
|
RTSP: mist.data.capabilities.connectors.RTSP.optional.port['default']
|
||||||
|
};
|
||||||
|
var defport = {
|
||||||
|
RTMP: 1935,
|
||||||
|
RTSP: 554
|
||||||
|
}
|
||||||
|
for (var protocol in port) {
|
||||||
|
for (var i in mist.data.config.protocols) {
|
||||||
|
var p = mist.data.config.protocols[i];
|
||||||
|
if (p.connector == protocol) {
|
||||||
|
if ('port' in p) {
|
||||||
|
port[protocol] = p.port;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (port[protocol] == defport[protocol]) { port[protocol] = ''; }
|
||||||
|
else { port[protocol] = ':'+port[protocol]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
$livestreamhint.find('.field.RTMP').setval('rtmp://'+host.host+port.RTMP+'/'+(passw ? passw : 'live')+'/'+(streamname == '' ? 'STREAMNAME' : streamname))
|
||||||
|
$livestreamhint.find('.field.RTSP').setval('rtsp://'+host.host+port.RTSP+'/'+(streamname == '' ? 'STREAMNAME' : streamname)+(passw ? '?pass='+passw : ''))
|
||||||
|
}
|
||||||
|
|
||||||
$main.append(UI.buildUI([
|
$main.append(UI.buildUI([
|
||||||
{
|
{
|
||||||
|
@ -2900,6 +2931,7 @@ var UI = {
|
||||||
'function': function(){
|
'function': function(){
|
||||||
var source = $(this).val();
|
var source = $(this).val();
|
||||||
$style.remove();
|
$style.remove();
|
||||||
|
$livestreamhint.html('');
|
||||||
if (source == '') { return; }
|
if (source == '') { return; }
|
||||||
var type = null;
|
var type = null;
|
||||||
for (var i in mist.data.capabilities.inputs) {
|
for (var i in mist.data.capabilities.inputs) {
|
||||||
|
@ -2937,6 +2969,24 @@ var UI = {
|
||||||
if (input.name == 'Folder') {
|
if (input.name == 'Folder') {
|
||||||
$main.append($style);
|
$main.append($style);
|
||||||
}
|
}
|
||||||
|
if (input.name == 'Buffer') {
|
||||||
|
$livestreamhint.html('<br>').append(UI.buildUI([
|
||||||
|
$('<span>').text('Configure your source to push to:')
|
||||||
|
,{
|
||||||
|
label: 'RTMP',
|
||||||
|
type: 'span',
|
||||||
|
clipboard: true,
|
||||||
|
readonly: true,
|
||||||
|
classes: ['RTMP']
|
||||||
|
},{
|
||||||
|
label: 'RTSP',
|
||||||
|
type: 'span',
|
||||||
|
clipboard: true,
|
||||||
|
readonly: true,
|
||||||
|
classes: ['RTSP']
|
||||||
|
}]));
|
||||||
|
updateLiveStreamHint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
label: 'Stop sessions',
|
label: 'Stop sessions',
|
||||||
|
@ -2947,7 +2997,7 @@ var UI = {
|
||||||
main: saveas,
|
main: saveas,
|
||||||
index: 'stop_sessions'
|
index: 'stop_sessions'
|
||||||
}
|
}
|
||||||
},$('<br>'),{
|
},$livestreamhint,$('<br>'),{
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
custom: $inputoptions
|
custom: $inputoptions
|
||||||
},$('<br>'),$('<h3>').text('Encryption'),{
|
},$('<br>'),$('<h3>').text('Encryption'),{
|
||||||
|
@ -3015,6 +3065,10 @@ var UI = {
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
$main.find('[name=name]').keyup(function(){
|
||||||
|
updateLiveStreamHint();
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Preview':
|
case 'Preview':
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue