Merge branch 'development' into LTS_development
This commit is contained in:
commit
d887e01aed
4 changed files with 77 additions and 41 deletions
|
@ -85,40 +85,41 @@ var l=function(){function a(b){var c=mist.data.capabilities.connectors[b.connect
|
|||
" ");$ul.append(a);typeof h[b.deps[e]]!="undefined"||typeof h[b.deps[e]+".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)},h={};for(r in mist.data.config.protocols)h[mist.data.config.protocols[r].connector]=1;if(j){var q=mist.data.config.protocols[c],n=q;b.find("h2").append(' "'+q.connector+'"');b.append(P(q.connector))}else{b.html($("<h2>").text("New Protocol"));
|
||||
var n={},t=[];for(r in mist.data.capabilities.connectors)t.push([r,r]);var Q=$("<span>");b.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){Q.html(P($(this).getval()))}}])).append(Q)}break;case "Streams":if(!("capabilities"in mist.data)){b.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}g=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));q=$("<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(g);b.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Immidiately go to the stream preview or view the information available about the stream with the info button."}])).append($("<button>").text("New stream").click(function(){UI.navto("Edit Stream")})).append(q);
|
||||
q.stupidtable();var D=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,x,mist.data.streams);var a=0;g.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=R(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;x[mist.data.active_streams[a]]=b}}b=Object.keys(x);b.sort();for(var c in b){var d=
|
||||
b[c],e;e=d in mist.data.streams?mist.data.streams[d]:x[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),h=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var i=mist.data.totals[d].all_protocols.clients,h=0;if(i.length){for(a in i)h=h+i[a][1];h=Math.round(h/i.length)}}f.html(UI.format.number(h));if(h==0&&e.online==1)e.online=2;h=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
q.stupidtable();var D=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;g.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");if(!(b.length<2)&&b[0]in mist.data.streams){b=R(mist.data.active_streams[a],mist.data.streams[b[0]]);b.online=1;y[mist.data.active_streams[a]]=b}}b=Object.keys(y);b.sort();for(var c in b){var d=
|
||||
b[c],e;e=d in mist.data.streams?mist.data.streams[d]:y[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),h=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var i=mist.data.totals[d].all_protocols.clients,h=0;if(i.length){for(a in i)h=h+i[a][1];h=Math.round(h/i.length)}}f.html(UI.format.number(h));if(h==0&&e.online==1)e.online=2;h=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
!e.ischild)&&h.html($("<button>").text("Edit").click(function(){UI.navto("Edit Stream",$(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)}}));i=$("<span>").text(d);e.ischild&&i.css("padding-left","1em");var j=
|
||||
UI.format.status(e),k=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){j.html("");k="";f.html("")}g.append($("<tr>").data("index",d).html($("<td>").html(i).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(j)).append(f).append($("<td>").html(k)).append(h));
|
||||
a++}},{totals:a,active_streams:true})},x=$.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};if(mist.data.LTS){var A=0,E=0;for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&(x[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var f=c+"+"+a.browse.files[d];x[f]=R(f,mist.data.streams[c]);x[f].source=mist.data.streams[c].source+a.browse.files[d]}a.browse.files.length?x[c].filesfound=true:mist.data.streams[c].filesfound=false;E++;if(A==E){mist.send(function(){D()},{active_streams:true});UI.interval.set(function(){D()},1E4)}},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&(mist.send(function(){D()},
|
||||
UI.format.status(e),S=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){j.html("");S="";f.html("")}g.append($("<tr>").data("index",d).html($("<td>").html(i).attr("title",d).addClass("overflow_ellipsis")).append($("<td>").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($("<td>").data("sort-value",e.online).html(j)).append(f).append($("<td>").html(S)).append(h));
|
||||
a++}},{totals:a,active_streams:true})},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};if(mist.data.LTS){var B=0,E=0;for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&(y[i].source+="*",mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var e in mist.data.capabilities.inputs)if(!(e.indexOf("Buffer")>=
|
||||
0||e.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var f=c+"+"+a.browse.files[d];y[f]=R(f,mist.data.streams[c]);y[f].source=mist.data.streams[c].source+a.browse.files[d]}a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;E++;if(B==E){mist.send(function(){D()},{active_streams:true});UI.interval.set(function(){D()},1E4)}},{browse:mist.data.streams[i].source},{stream:i}),B++);0==B&&(mist.send(function(){D()},
|
||||
{active_streams:!0}),UI.interval.set(function(){D()},3E4))}else mist.send(function(){D()},{active_streams:!0}),UI.interval.set(function(){D()},1E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(q=c,n=mist.data.streams[q],b.find("h2").append(' "'+q+'"')):(b.html($("<h2>").text("New Stream")),n={});i=[];for(r in mist.data.capabilities.inputs)i.push(mist.data.capabilities.inputs[r].source_match);
|
||||
var G=$("<div>");b.append(UI.buildUI([{label:"Stream name",type:"str",validate:["required","streamname"],pointer:{main:n,index:"name"},help:"Set the name this stream will be recognised by for players and/or stream pushing."},{label:"Source",type:"browse",validate:["required"],filetypes:i,pointer:{main:n,index:"source"},help:'Set the stream source.<table><tr><td>VoD:</td><td>You can browse to the file or folder as a source or simply enter the path to the file.</td></tr><tr><td>Live:</td><td>You\'ll need to enter "push://IP" with the IP of the machine pushing towards MistServer.<br>You can use "push://" to accept any source.</td></tr><tr><td>(Pro only)</td><td>Use "push://(IP)@password" to set a password protection for pushes.</td></tr></table>If you\'re unsure how to set the source properly, please view our Live pushing guide at the tools section.',
|
||||
"function":function(){var a=$(this).val();if(a!=""){var b=null,c;for(c in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[c].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[c].source_match,a)){b=c;break}if(b===null)G.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{a=mist.data.capabilities.inputs[b];G.html($("<h3>").text(a.name+" Input options"));a=mist.convertBuildOptions(a,
|
||||
n);G.append(UI.buildUI(a))}}}},$("<br>"),{type:"custom",custom:G},$("<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:n,index:"la_url"}},$("<br>"),{label:"Content key",type:"str",LTSonly:!0,pointer:{main:n,
|
||||
index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:n,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:n,index:"keyseed"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Streams")}},{type:"save",label:"Save","function":function(){if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;c!=n.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[n.name]=
|
||||
n;if(c!=n.name)a.deletestream=[c]}else a.streams=mist.data.streams;mist.send(function(){delete mist.data.streams[n.name].online;delete mist.data.streams[n.name].error;UI.navto("Streams")},a)}}]}]));j&&(i={streams:{}},i.streams[q]=mist.data.streams[q].limits,b.append($("<h3>").text("Limits")).append(UI.buildLimits(i,a,c)));break;case "Preview":if(""==c){b.append("Loading..");var I=function(c){var d={};c.sort();b.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,
|
||||
n;if(c!=n.name)a.deletestream=[c]}else a.streams=mist.data.streams;mist.send(function(){delete mist.data.streams[n.name].online;delete mist.data.streams[n.name].error;UI.navto("Streams")},a)}}]}]));j&&(i={streams:{}},i.streams[q]=mist.data.streams[q].limits,b.append($("<h3>").text("Limits")).append(UI.buildLimits(i,a,c)));break;case "Preview":if(""==c){b.append("Loading..");var J=function(c){var d={};c.sort();b.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,
|
||||
pointer:{main:d,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,d.stream)}}]}]));UI.elements.secondary_menu.html("").append($("<a>").addClass("button").addClass("active").text("Choose stream").click(function(){UI.navto("Preview")}));var e=$("<div>").addClass("preview_icons");b.append($("<span>").addClass("description").text("Or, click a stream from the list below.")).append(e);for(var f in c){var g=c[f],h="";if(g.indexOf("+")>-1){h=g.split("+");h=
|
||||
mist.data.streams[h[0]].source+h[1]}else h=mist.data.streams[g].source;e.append($("<button>").append($("<span>").text(g)).append($("<span>").addClass("description").text(h)).attr("title",g).attr("data-stream",g).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}E=A=0;t={};for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||
|
||||
mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&(mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.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.data.browse.files[d])&&(t[c+"+"+mist.data.browse.files[d]]=true);E++;A==E&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");
|
||||
b.length>1&&b[0]in mist.data.streams&&(t[mist.data.active_streams[a]]=true)}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));t.sort();I(t)},{active_streams:true})},{browse:mist.data.streams[i].source},{stream:i}),A++);0==A&&mist.send(function(){var c=[],d;for(d in mist.data.active_streams){var e=mist.data.active_streams[d].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[d]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)b.html($("<h2>").text(a)).append("Please set up a stream first.");
|
||||
else{c.sort();I(c)}},{active_streams:!0})}else I(Object.keys(mist.data.streams));break}b.find("h2").append(' of "'+c+'"');i=":8080";for(r in mist.data.config.protocols)if(q=mist.data.config.protocols[r],"HTTP"==q.connector||"HTTP.exe"==q.connector)i=q.port?":"+q.port:":8080";var B={},q=$("<span>").hide();B["Embed urls"]=q;b.append(q);var w="",d=mist.user.host.match(/(https?)\:\/\/([^:\/]+)\:(\d+)?/i);null!=d&&(w=d[2]);var F="http://"+w+i+"/",C={},J=function(a){var b=["div"],d='\n <script src="'+
|
||||
F+"embed_"+c+'.js"><\/script>\n';a.autoplay&&b.push("data-autoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');return"<"+b.join(" ")+">"+d+"</div>"},S=$("<span>");q.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:F+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:F+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:F+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),
|
||||
{label:"Embed code",type:"textarea",value:J(C),rows:4,readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",pointer:{main:C,index:"autoplay"},"function":function(){C.autoplay=$(this).getval();$(".embed_code").setval(J(C))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:C,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){C.forceprotocol=$(this).getval();$(".embed_code").setval(J(C))}},
|
||||
$("<h3>").text("Protocol stream urls"),S]));i=$("<span>").append($("<h3>").text("Meta information")).hide();B["Meta information"]=i;var K=$("<span>");i.append(K);b.append(i);i=$("<span>").hide();B.Preview=i;b.append(i);var y=$("<div>").css("float","left").css("margin-right","1em").attr("data-forcesupportcheck",""),T=$("<div>").css("float","left");i.append(y).append(T);mist.stored.get().autoplay&&y.attr("data-autoplay","");var H=function(){y.text("Loading..");var a=document.createElement("script");
|
||||
a.src=F+"embed_"+c+".js";a.onerror=function(){y.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){H()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")y.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){H()}));else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true,value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,
|
||||
"function":function(){mist.stored.set("autoplay",$(this).getval()?1:0)}}]);b.find(".help_container").remove();y.append(b);var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support"))));T.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var f in a.source){var g=
|
||||
a.source[f],h=g.type.split("/"),i=h[0];i.length<6&&(i=i.toUpperCase());switch(h.length){case 1:break;case 2:i=UI.format.capital(h[0])+" v"+h[1];if(h[0]=="flash")switch(h[1]){case "7":i="Progressive ("+i+")";break;case "10":i="RTMP ("+i+")";break;case "11":i="HDS ("+i+")"}break;case 3:switch(h[2]){case "vnd.apple.mpegurl":i=i+" HLS";break;case "vnd.ms-ss":i=i+" Smooth";break;case "mp2t":i=i+" TS";break;default:h[2].length<6&&(h[2]=h[2].toUpperCase());i=i+(" "+h[2]);h[1]!="video"&&(i=i+(" ("+h[1]+")"))}break;
|
||||
default:i=g.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(g.type).addClass("clear"));e.push({label:i,type:"str",value:g.url,readonly:true,qrcode:true});h=$("<tr>");b.append(h);h.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){y.attr("data-forcetype",$(this).val()).html("Loading embed..");H()}).val(g.type))).append($("<td>").text(i)).append($("<td>").text(g.priority)).append($("<td>").text(g.simul_tracks+"/"+g.total_matches)).append($("<td>").text(g.browser_support?
|
||||
"yes":"no"));if(a.embedded&&a.embedded.type==g.type){h.css("outline","1px solid rgba(0,0,0,0.5)");h.find("input[type=radio]").prop("checked",true)}}S.html(UI.buildUI(e));var j;if(c in mistvideo)j=mistvideo[c].meta;if(j){a=[];a.push({label:"Type",type:"span",value:j.live?"Live":"Pre-recorded (VoD)"});"format"in j&&a.push({label:"Format",type:"span",value:j.format});j.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(j.buffer_window,"ms")});b={vheader:"Audio",labels:["Codec","Duration",
|
||||
"Peak bitrate","Channels","Samplerate"],content:[]};f={vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var k in d){e=d[k];g=j.tracks[e];switch(g.type){case "audio":b.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")]});break;case "video":f.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,"px"),UI.format.addUnit(UI.format.number(g.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width",
|
||||
"auto");k=UI.buildVheaderTable(f).css("width","auto");a.push($("<span>").text("Tracks:"));a.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(j).append(k));K.html(UI.buildUI(a))}else K.html("No meta information available.")}};y.html("")[0].appendChild(a)};H();var L=UI.elements.secondary_menu;L.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));
|
||||
i=["Preview","Embed urls","Meta information"];h=i[0];for(r in i)q=$("<a>").addClass("button").text(i[r]).click(function(){L.find(".active").removeClass("active");$(this).addClass("active");for(r in B)B[r].hide();B[$(this).text()].show()}),L.append(q),i[r]==h&&(q.addClass("active"),B[h].show());break;case "Limits":b.append(UI.buildUI([{type:"help",help:"Here you can see an overview of all the limits you currently have. Limits are an LTS only feature and you can simply add new limits by selecting new, by selecting edit you can edit the existing limit, by selecting delete you can delete the existing limit."}]));
|
||||
i={server:mist.data.config.limits,streams:{}};for(r in mist.data.streams)"limits"in mist.data.streams[r]&&(i.streams[r]=mist.data.streams[r].limits);b.append(UI.buildLimits(i,a,c));break;case "Edit Limit":j=!1;""!=c&&(j=!0);n={};i=[{type:"help",help:"Here you can set the limit specifications, soft limits only warn while hard limits restrict access. Please feel free to set up limits according to your preferences."}];"Overview"==UI.returnTab[0]&&(UI.returnTab=["Limits"]);if(j){q=c.split("^");w=a;switch(q[0]){case "server":n=
|
||||
mist.data.config.limits[q[1]];w="For the entire server";break;case "stream":n=mist.data.streams[q[1]].limits[q[2]],w='For the stream "'+q[1]+'"'}i.push({type:"text",text:w})}else{b.html($("<h2>").text("New limit"));var z=[];for(r in mist.data.streams)z.push(r);t=[["server","The entire server"],["stream","The stream:",z]];q={label:"Applies to",type:"radioselect",radioselect:t,pointer:{main:n,index:"applies_to"},LTSonly:!0,validate:["required"]};"Edit Stream"==UI.returnTab[0]&&UI.returnTab[1]&&(q.value=
|
||||
["stream",UI.returnTab[1]],q.readonly=!0);i.push(q)}var i=i.concat([$("<br>"),{label:"Kind",type:"select",select:[["soft","Soft"],["hard","Hard"]],pointer:{main:n,index:"type"},help:"The server will not allow a hard limit to be passed. A soft limit can be used to set alerts.",LTSonly:!0,validate:["required"]},{label:"Value",pointer:{main:n,index:"value"},classes:["limit_value"],LTSonly:!0},{label:"Type",type:"select",select:[["kbps_max","Maximum bandwidth"],["users","Maximum connected users"],["geo",
|
||||
"Geo limited"],["host","Host limited"]],pointer:{main:n,index:"name"},LTSonly:!0,validate:["required"],classes:["limit_type"],"function":function(){var a=$(this).getval(),b=$(this).closest(".input_container").find(".limit_value"),c=b.closest("label"),b=b.data("opts");delete b.type;delete b.min;delete b.unit;b.validate=["required"];switch(a){case "kbps_max":b.type="int";b.min=1;b.unit="bytes/s";break;case "users":b.type="int";b.min=1;break;case "geo":b.type="geolimited";break;case "host":b.type="hostlimited"}a=
|
||||
UI.buildUI([b]);c.replaceWith(a.children())}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto(UI.returnTab[0],UI.returnTab[1])}},{type:"save",label:"Save","function":function(){var a={};if(j){var b=c.split("^");switch(b[0]){case "server":a={config:{limits:mist.data.config.limits}};break;case "stream":if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}else{b=n.applies_to;delete n.applies_to;switch(b[0]){case "server":if(!mist.data.config.limits)mist.data.config.limits=
|
||||
mist.data.streams[h[0]].source+h[1]}else h=mist.data.streams[g].source;e.append($("<button>").append($("<span>").text(g)).append($("<span>").addClass("description").text(h)).attr("title",g).attr("data-stream",g).click(function(){UI.navto("Preview",$(this).attr("data-stream"))}))}};if(mist.data.LTS){if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});b.append("Loading..");break}E=B=0;t={};for(i in mist.data.streams)q=mist.data.capabilities.inputs.Folder||
|
||||
mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(q.source_match,mist.data.streams[i].source)&&(mist.send(function(a,b){var c=b.stream,d;for(d in mist.data.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.data.browse.files[d])&&(t[c+"+"+mist.data.browse.files[d]]=true);E++;B==E&&mist.send(function(){for(var a in mist.data.active_streams){var b=mist.data.active_streams[a].split("+");
|
||||
b.length>1&&b[0]in mist.data.streams&&(t[mist.data.active_streams[a]]=true)}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));t.sort();J(t)},{active_streams:true})},{browse:mist.data.streams[i].source},{stream:i}),B++);0==B&&mist.send(function(){var c=[],d;for(d in mist.data.active_streams){var e=mist.data.active_streams[d].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[d]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)b.html($("<h2>").text(a)).append("Please set up a stream first.");
|
||||
else{c.sort();J(c)}},{active_streams:!0})}else J(Object.keys(mist.data.streams));break}b.find("h2").append(' of "'+c+'"');i=":8080";for(r in mist.data.config.protocols)if(q=mist.data.config.protocols[r],"HTTP"==q.connector||"HTTP.exe"==q.connector)i=q.port?":"+q.port:":8080";var C={},q=$("<span>").hide();C["Embed urls"]=q;b.append(q);var w="",d=mist.user.host.match(/(https?)\:\/\/([^:\/]+)\:(\d+)?/i);null!=d&&(w=d[2]);var F="http://"+w+i+"/",x={},H=function(a){var b=["div"],d='\n <script src="'+
|
||||
F+"embed_"+c+'.js"><\/script>\n';a.autoplay&&b.push("data-autoplay");a.forceprotocol&&a.forceprotocol!=""&&b.push('data-forcetype="'+a.forceprotocol+'"');a.urlappend&&a.urlappend!=""&&b.push('data-urlappend="'+a.urlappend.replace(/\"/g,'\\"')+'"');return"<"+b.join(" ")+">"+d+"</div>"},T=$("<span>");q.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:F+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:F+"info_"+c+".js",readonly:!0},
|
||||
{label:"Autodetect player",type:"str",value:F+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:H(x),rows:4,readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",pointer:{main:x,index:"autoplay"},"function":function(){x.autoplay=$(this).getval();$(".embed_code").setval(H(x))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:x,index:"protocol"},
|
||||
classes:["embed_code_forceprotocol"],"function":function(){x.forceprotocol=$(this).getval();$(".embed_code").setval(H(x))}},{label:"Video URL addition",type:"str",pointer:{main:x,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(){x.urlappend=$(this).getval();$(".embed_code").setval(H(x))}},$("<h3>").text("Protocol stream urls"),T]));i=$("<span>").append($("<h3>").text("Meta information")).hide();
|
||||
C["Meta information"]=i;var K=$("<span>");i.append(K);b.append(i);i=$("<span>").hide();C.Preview=i;b.append(i);var z=$("<div>").css("float","left").css("margin-right","1em").attr("data-forcesupportcheck",""),U=$("<div>").css("float","left");i.append(z).append(U);mist.stored.get().autoplay&&z.attr("data-autoplay","");var I=function(){z.text("Loading..");var a=document.createElement("script");a.src=F+"embed_"+c+".js";a.onerror=function(){z.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){I()}))};
|
||||
a.onload=function(){if(typeof mistvideo[c].error!="undefined")z.html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){I()}));else{var a=mistvideo[c],b=UI.buildUI([{label:"Protocol stream url",type:"str",readonly:true,value:a.embedded?a.embedded.url:"",qrcode:true},{label:"Autoplay (from now on)",type:"checkbox",value:mist.stored.get().autoplay,"function":function(){mist.stored.set("autoplay",$(this).getval()?1:0)}}]);b.find(".help_container").remove();z.append(b);
|
||||
var d=$("<table>").css("font-size","0.9em").html($("<thead>").html($("<tr>").html($("<th>")).append($("<th>").text("Type")).append($("<th>").text("Priority")).append($("<th>").text("Simul. tracks")).append($("<th>").html("Your browser<br>support"))));U.html(d);b=$("<tbody>");d.append(b);var d=$(".embed_code_forceprotocol"),e=[];d.find(".clear").remove();for(var f in a.source){var g=a.source[f],h=g.type.split("/"),i=h[0];i.length<6&&(i=i.toUpperCase());switch(h.length){case 1:break;case 2:i=UI.format.capital(h[0])+
|
||||
" v"+h[1];if(h[0]=="flash")switch(h[1]){case "7":i="Progressive ("+i+")";break;case "10":i="RTMP ("+i+")";break;case "11":i="HDS ("+i+")"}break;case 3:switch(h[2]){case "vnd.apple.mpegurl":i=i+" HLS";break;case "vnd.ms-ss":i=i+" Smooth";break;case "mp2t":i=i+" TS";break;default:h[2].length<6&&(h[2]=h[2].toUpperCase());i=i+(" "+h[2]);h[1]!="video"&&(i=i+(" ("+h[1]+")"))}break;default:i=g.type}i=UI.format.capital(i);d.append($("<option>").text(i).val(g.type).addClass("clear"));e.push({label:i,type:"str",
|
||||
value:g.url,readonly:true,qrcode:true});h=$("<tr>");b.append(h);h.html($("<td>").html($("<input>").attr("type","radio").attr("name","protocolforce").change(function(){z.attr("data-forcetype",$(this).val()).html("Loading embed..");I()}).val(g.type))).append($("<td>").text(i)).append($("<td>").text(g.priority)).append($("<td>").text(g.simul_tracks+"/"+g.total_matches)).append($("<td>").text(g.browser_support?"yes":"no"));if(a.embedded&&a.embedded.type==g.type){h.css("outline","1px solid rgba(0,0,0,0.5)");
|
||||
h.find("input[type=radio]").prop("checked",true)}}T.html(UI.buildUI(e));var j;if(c in mistvideo)j=mistvideo[c].meta;if(j){a=[];a.push({label:"Type",type:"span",value:j.live?"Live":"Pre-recorded (VoD)"});"format"in j&&a.push({label:"Format",type:"span",value:j.format});j.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(j.buffer_window,"ms")});b={vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate"],content:[]};f={vheader:"Video",labels:["Codec","Duration",
|
||||
"Peak bitrate","Size","Framerate"],content:[]};d=Object.keys(j.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var k in d){e=d[k];g=j.tracks[e];switch(g.type){case "audio":b.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")]});break;case "video":f.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,"px"),UI.format.addUnit(UI.format.number(g.fpks/1E3),"fps")]})}}j=UI.buildVheaderTable(b).css("width","auto");k=UI.buildVheaderTable(f).css("width","auto");a.push($("<span>").text("Tracks:"));
|
||||
a.push($("<div>").css({display:"flex","flex-flow":"row wrap","justify-content":"center","font-size":"0.9em"}).append(j).append(k));K.html(UI.buildUI(a))}else K.html("No meta information available.")}};z.html("")[0].appendChild(a)};I();var L=UI.elements.secondary_menu;L.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));i=["Preview","Embed urls","Meta information"];h=i[0];for(r in i)q=$("<a>").addClass("button").text(i[r]).click(function(){L.find(".active").removeClass("active");
|
||||
$(this).addClass("active");for(r in C)C[r].hide();C[$(this).text()].show()}),L.append(q),i[r]==h&&(q.addClass("active"),C[h].show());break;case "Limits":b.append(UI.buildUI([{type:"help",help:"Here you can see an overview of all the limits you currently have. Limits are an LTS only feature and you can simply add new limits by selecting new, by selecting edit you can edit the existing limit, by selecting delete you can delete the existing limit."}]));i={server:mist.data.config.limits,streams:{}};for(r in mist.data.streams)"limits"in
|
||||
mist.data.streams[r]&&(i.streams[r]=mist.data.streams[r].limits);b.append(UI.buildLimits(i,a,c));break;case "Edit Limit":j=!1;""!=c&&(j=!0);n={};i=[{type:"help",help:"Here you can set the limit specifications, soft limits only warn while hard limits restrict access. Please feel free to set up limits according to your preferences."}];"Overview"==UI.returnTab[0]&&(UI.returnTab=["Limits"]);if(j){q=c.split("^");w=a;switch(q[0]){case "server":n=mist.data.config.limits[q[1]];w="For the entire server";break;
|
||||
case "stream":n=mist.data.streams[q[1]].limits[q[2]],w='For the stream "'+q[1]+'"'}i.push({type:"text",text:w})}else{b.html($("<h2>").text("New limit"));var A=[];for(r in mist.data.streams)A.push(r);t=[["server","The entire server"],["stream","The stream:",A]];q={label:"Applies to",type:"radioselect",radioselect:t,pointer:{main:n,index:"applies_to"},LTSonly:!0,validate:["required"]};"Edit Stream"==UI.returnTab[0]&&UI.returnTab[1]&&(q.value=["stream",UI.returnTab[1]],q.readonly=!0);i.push(q)}var i=
|
||||
i.concat([$("<br>"),{label:"Kind",type:"select",select:[["soft","Soft"],["hard","Hard"]],pointer:{main:n,index:"type"},help:"The server will not allow a hard limit to be passed. A soft limit can be used to set alerts.",LTSonly:!0,validate:["required"]},{label:"Value",pointer:{main:n,index:"value"},classes:["limit_value"],LTSonly:!0},{label:"Type",type:"select",select:[["kbps_max","Maximum bandwidth"],["users","Maximum connected users"],["geo","Geo limited"],["host","Host limited"]],pointer:{main:n,
|
||||
index:"name"},LTSonly:!0,validate:["required"],classes:["limit_type"],"function":function(){var a=$(this).getval(),b=$(this).closest(".input_container").find(".limit_value"),c=b.closest("label"),b=b.data("opts");delete b.type;delete b.min;delete b.unit;b.validate=["required"];switch(a){case "kbps_max":b.type="int";b.min=1;b.unit="bytes/s";break;case "users":b.type="int";b.min=1;break;case "geo":b.type="geolimited";break;case "host":b.type="hostlimited"}a=UI.buildUI([b]);c.replaceWith(a.children())}},
|
||||
{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto(UI.returnTab[0],UI.returnTab[1])}},{type:"save",label:"Save","function":function(){var a={};if(j){var b=c.split("^");switch(b[0]){case "server":a={config:{limits:mist.data.config.limits}};break;case "stream":if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}else{b=n.applies_to;delete n.applies_to;switch(b[0]){case "server":if(!mist.data.config.limits)mist.data.config.limits=
|
||||
[];mist.data.config.limits.push(n);a={config:{limits:mist.data.config.limits}};break;case "stream":if(typeof mist.data.streams[b[1]].limits=="undefined")mist.data.streams[b[1]].limits=[];mist.data.streams[b[1]].limits.push(n);if(mist.data.LTS){a={addstream:{}};a.addstream[b[1]]=mist.data.streams[b[1]]}else a={streams:mist.data.streams}}}mist.send(function(){UI.navto(UI.returnTab[0],UI.returnTab[1])},a)}}]}]),u=UI.buildUI(i);b.append(u);u.find(".limit_type").closest("label").after(u.find(".limit_value").closest("label"));
|
||||
u.find(".limit_type").trigger("change");break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});g=$("<tbody>");q=$("<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);b.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(q);
|
||||
q.stupidtable();i=mist.data.config.triggers;for(r in i)for(w in i[r])g.append($("<tr>").attr("data-index",r+","+w).append($("<td>").text(r)).append($("<td>").text(i[r][w][2].join(", "))).append($("<td>").text(i[r][w][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 "+
|
||||
|
@ -130,19 +131,19 @@ LTSonly:!0,"function":function(){switch($(this).getval()){case "SYSTEM_START":ca
|
|||
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:n,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:n,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:n,index:"default"},LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){c&&mist.data.config.triggers[c[0]].splice(c[1],1);var a=[n.url,n.async?true:false,typeof n.appliesto!="undefined"?n.appliesto:
|
||||
[]];typeof n["default"]!="undefined"&&a.push(n["default"]);n.triggeron in mist.data.config.triggers||(mist.data.config.triggers[n.triggeron]=[]);mist.data.config.triggers[n.triggeron].push(a);mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":b.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(){clearInterval(UI.interval);UI.interval.set(function(){mist.send(function(){U()})},$(this).val()*1E3)}}]));b.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");b.append($("<table>").append(g));var W=function(a){var b=$("<span>").text(a);
|
||||
switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},U=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(W(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align","left")))}};U();break;case "Statistics":u=$("<span>").text("Loading..");
|
||||
b.append(u);var n={},s=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},z={};for(r in mist.data.streams)z[r]=!0;for(r in mist.data.active_streams)z[mist.data.active_streams[r]]=!0;var z=Object.keys(z).sort(),M=[];for(r in mist.data.config.protocols)M.push(mist.data.config.protocols[r].connector);M.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+
|
||||
{label:"Refresh every",type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){clearInterval(UI.interval);UI.interval.set(function(){mist.send(function(){V()})},$(this).val()*1E3)}}]));b.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");b.append($("<table>").append(g));var X=function(a){var b=$("<span>").text(a);
|
||||
switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},V=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(X(a[b][1])).css("text-align","center")).append($("<td>").text(a[b][2]).css("text-align","left")))}};V();break;case "Statistics":u=$("<span>").text("Loading..");
|
||||
b.append(u);var n={},s=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},A={};for(r in mist.data.streams)A[r]=!0;for(r in mist.data.active_streams)A[mist.data.active_streams[r]]=!0;var A=Object.keys(A).sort(),M=[];for(r in mist.data.config.protocols)M.push(mist.data.config.protocols[r].connector);M.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;u.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:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=u.find(".graph_xaxis"),b=u.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",
|
||||
false);b.setval("Graph "+(Object.keys(s).length+1)).closest("label").show()}else{var c=s[$(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:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in s?{msg:"This graph id has already been used. Please enter something else.",
|
||||
classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"],["coords","Geographical"]],pointer:{main:n,index:"xaxis"},classes:["graph_xaxis"],"function":function(){$s=u.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 load"],["memload","Memory load"],["coords","Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=u.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:",z],["protocol","The protocol:",M]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,c);s[a.id]=a;u.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:",A],["protocol","The protocol:",M]],pointer:{main:n,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(n.graph=="new"){a=UI.plot.addGraph(n,c);s[a.id]=a;u.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=
|
||||
s[n.graph];var b=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(s)}}]}]));var c=$("<div>").addClass("graph_container");b.append(c);var d=u.find("select.graph_ids");for(a in s){var e=UI.plot.addGraph(s[a],c);d.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in s[a].datasets){var h=UI.plot.datatype.getOptions({datatype:s[a].datasets[f].datatype,origin:s[a].datasets[f].origin});g.push(h)}e.datasets=g;s[e.id]=e}d.trigger("change");
|
||||
UI.plot.go(s);UI.interval.set(function(){UI.plot.go(s)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});b.append("Loading..");break}var N=$("<table>"),O=$("<table>"),i={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(r in mist.data.capabilities.cpu)q=mist.data.capabilities.cpu[r],i.content.push({header:"CPU #"+(Number(r)+1),
|
||||
body:[q.model,UI.format.addUnit(UI.format.number(q.mhz),"MHz"),q.cores,q.threads]});var i=UI.buildVheaderTable(i),V=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);N.replaceWith(a);N=a;b={vheader:"Load average",labels:["1 minute","5 minutes","15 minutes",""],content:[{header:" ",body:[UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100),""]}]};b=UI.buildVheaderTable(b);O.replaceWith(b);O=b};V();b.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(N)).append($("<td>").append(O))).append($("<tr>").append($("<td>").append(i).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){V()},{capabilities:true})},3E4);break;case "Email for Help":i=$.extend({},mist.data);delete i.statistics;delete i.totals;delete i.clients;delete i.capabilities;i=JSON.stringify(i);i="Version: "+mist.data.config.version+"\n\nConfig:\n"+i;n={};b.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."},
|
||||
body:[q.model,UI.format.addUnit(UI.format.number(q.mhz),"MHz"),q.cores,q.threads]});var i=UI.buildVheaderTable(i),W=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);N.replaceWith(a);N=a;b={vheader:"Load average",labels:["1 minute","5 minutes","15 minutes",""],content:[{header:" ",body:[UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100),""]}]};b=UI.buildVheaderTable(b);O.replaceWith(b);O=b};W();b.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(N)).append($("<td>").append(O))).append($("<tr>").append($("<td>").append(i).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){W()},{capabilities:true})},3E4);break;case "Email for Help":i=$.extend({},mist.data);delete i.statistics;delete i.totals;delete i.clients;delete i.capabilities;i=JSON.stringify(i);i="Version: "+mist.data.config.version+"\n\nConfig:\n"+i;n={};b.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:n,index:"name"},value:mist.user.name},{type:"email",label:"Your email address",validate:["required"],pointer:{main:n,index:"email"}},{type:"hidden",value:"Integrated Help",pointer:{main:n,index:"subject"}},{type:"hidden",value:"-",pointer:{main:n,index:"company"}},{type:"textarea",rows:20,label:"Your message",validate:["required"],pointer:{main:n,index:"message"}},{type:"textarea",rows:20,label:"Your config file",readonly:!0,value:i,
|
||||
pointer:{main:n,index:"configfile"}},{type:"buttons",buttons:[{type:"save",label:"Send","function":function(a){$(a).text("Sending..");$.ajax({type:"POST",url:"http://mistserver.org/contact_us?skin=plain",data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();b.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;UI.navto("Login");break;default:b.append($("<p>").text("This tab does not exist."))}}}},mist=
|
||||
{data:{},user:{name:"",password:"",host:"http://"+(location.hostname?location.hostname:"localhost")+":4242/api"},send:function(a,c,b){var c=c||{},b=b||{},b=$.extend(!0,{timeout:30,sendData:c},b),d={authorize:{password:mist.user.authstring?MD5(MD5(mist.user.password)+mist.user.authstring):"",username:mist.user.name}};$.extend(!0,d,c);log("Send",$.extend(!0,{},c));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:!0,timeout:1E3*b.timeout,async:!0,error:function(d,
|
||||
|
|
16
lsp/mist.js
16
lsp/mist.js
|
@ -2862,6 +2862,9 @@ var UI = {
|
|||
if ((opts.forceprotocol) && (opts.forceprotocol != '')) {
|
||||
open.push('data-forcetype="'+opts.forceprotocol+'"');
|
||||
}
|
||||
if ((opts.urlappend) && (opts.urlappend != '')) {
|
||||
open.push('data-urlappend="'+opts.urlappend.replace(/\"/g,'\\"')+'"');
|
||||
}
|
||||
return '<'+open.join(' ')+'>'+inner+'</div>';
|
||||
}
|
||||
|
||||
|
@ -2916,6 +2919,19 @@ var UI = {
|
|||
embedoptions.forceprotocol = $(this).getval();
|
||||
$('.embed_code').setval(embedhtml(embedoptions));
|
||||
}
|
||||
},{
|
||||
label: 'Video URL addition',
|
||||
type: 'str',
|
||||
pointer: {
|
||||
main: embedoptions,
|
||||
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(){
|
||||
embedoptions.urlappend = $(this).getval();
|
||||
$('.embed_code').setval(embedhtml(embedoptions));
|
||||
}
|
||||
},$('<h3>').text('Protocol stream urls'),$protocolurls
|
||||
]));
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<title>Test the stream embedding</title>
|
||||
<style></style>
|
||||
<script src=plugins/jquery.js></script>
|
||||
<script src='../src/embed.js'></script>
|
||||
<script src='../src/embed.js?video=0'></script>
|
||||
<script>
|
||||
var embed_settings = {};
|
||||
$(function(){
|
||||
|
@ -14,7 +14,7 @@
|
|||
var embedtype = $('input[name=force]').val();
|
||||
|
||||
var info = document.createElement('script');
|
||||
info.src = 'http://'+(window.location.hostname == '' ? 'localhost' : window.location.hostname)+':8080/info_'+streamName+'.js';
|
||||
info.src = 'http://'+(window.location.hostname == '' ? 'localhost' : window.location.hostname)+':8080/info_'+streamName+'.js?video=0';
|
||||
document.getElementById('embedcontainer').appendChild(info);
|
||||
info.onload = function(){
|
||||
if (embedtype == '') {
|
||||
|
|
29
src/embed.js
29
src/embed.js
|
@ -215,16 +215,23 @@ function mistembed(streamname) {
|
|||
}
|
||||
|
||||
var video = mistvideo[streamname],
|
||||
container = document.createElement('div');
|
||||
container = document.createElement('div'),
|
||||
forceType = false,
|
||||
forceSupportCheck = false,
|
||||
autoplay = false,
|
||||
urlappend = false;
|
||||
|
||||
if (me.parentNode.hasAttribute('data-forcetype')) {
|
||||
var forceType = me.parentNode.getAttribute('data-forcetype');
|
||||
forceType = me.parentNode.getAttribute('data-forcetype');
|
||||
}
|
||||
if (me.parentNode.hasAttribute('data-forcesupportcheck')) {
|
||||
var forceSupportCheck = true;
|
||||
forceSupportCheck = true;
|
||||
}
|
||||
if (me.parentNode.hasAttribute('data-autoplay')) {
|
||||
var autoplay = true;
|
||||
autoplay = true;
|
||||
}
|
||||
if (me.parentNode.hasAttribute('data-urlappend')) {
|
||||
urlappend = me.parentNode.getAttribute('data-urlappend');
|
||||
}
|
||||
|
||||
if (video.width == 0) { video.width = 250; }
|
||||
|
@ -281,7 +288,19 @@ function mistembed(streamname) {
|
|||
}
|
||||
else {
|
||||
// we support this kind of video, so build it.
|
||||
buildPlayer(video.source[foundPlayer], container, video.width, video.height, vtype);
|
||||
var source = video.source[foundPlayer];
|
||||
if (urlappend) {
|
||||
source.url += urlappend;
|
||||
source.relurl += urlappend;
|
||||
}
|
||||
else if (me.src.indexOf('?') != -1) {
|
||||
var params = me.src.split('?');
|
||||
params.shift();
|
||||
params.join('?');
|
||||
source.url += '?'+params;
|
||||
source.relurl += '?'+params;
|
||||
}
|
||||
buildPlayer(source, container, video.width, video.height, vtype);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue