LSP: preview folder bugfix
This commit is contained in:
parent
6fc3acd864
commit
a071182da9
2 changed files with 33 additions and 34 deletions
|
@ -86,9 +86,9 @@ var k=function(){function a(c){var b=mist.data.capabilities.connectors[c.connect
|
|||
var o={},x=[];for(q in mist.data.capabilities.connectors)x.push([q,q]);var V=$("<span>");d.append(UI.buildUI([{label:"Protocol",type:"select",select:x,"function":function(){V.html(F($(this).getval()))}}])).append(V)}break;case "Streams":if(!("capabilities"in mist.data)){d.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});break}h=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));e=$("<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(h);d.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(e);
|
||||
e.stupidtable();var E=function(){var a=[],c;for(c in mist.data.active_streams)a.push({streams:[mist.data.active_streams[c]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,z,mist.data.streams);var a=0;h.html("");if(mist.data.LTS)for(a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(!(c.length<2)&&c[0]in mist.data.streams){c=W(mist.data.active_streams[a],mist.data.streams[c[0]]);c.online=1;z[mist.data.active_streams[a]]=c}}c=Object.keys(z);c.sort();for(var b in c){var d=
|
||||
c[b],e;e=d in mist.data.streams?mist.data.streams[d]:z[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),g=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var t=mist.data.totals[d].all_protocols.clients,g=0;if(t.length){for(a in t)g=g+t[a][1];g=Math.round(g/t.length)}}f.html(UI.format.number(g));if(g==0&&e.online==1)e.online=2;g=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
!e.ischild)&&g.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 c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));t=$("<span>").text(d);e.ischild&&t.css("padding-left","1em");var i=
|
||||
UI.format.status(e),j=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){i.html("");j="";f.html("")}h.append($("<tr>").data("index",d).html($("<td>").html(t).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(i)).append(f).append($("<td>").html(j)).append(g));
|
||||
c[b],e;e=d in mist.data.streams?mist.data.streams[d]:z[d];var f=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),t=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[d]!="undefined"){var g=mist.data.totals[d].all_protocols.clients,t=0;if(g.length){for(a in g)t=t+g[a][1];t=Math.round(t/g.length)}}f.html(UI.format.number(t));if(t==0&&e.online==1)e.online=2;t=$("<td>").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||
|
||||
!e.ischild)&&t.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 c={};mist.data.LTS?c.deletestream=[a]:c.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},c)}}));g=$("<span>").text(d);e.ischild&&g.css("padding-left","1em");var i=
|
||||
UI.format.status(e),j=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))});if(e.filesfound){i.html("");j="";f.html("")}h.append($("<tr>").data("index",d).html($("<td>").html(g).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(i)).append(f).append($("<td>").html(j)).append(t));
|
||||
a++}},{totals:a,active_streams:true})},z=$.extend(!0,{},mist.data.streams),W=function(a,c){var b=$.extend({},c);delete b.meta;delete b.error;b.online=2;b.name=a;b.ischild=true;return b};if(mist.data.LTS){var C=0,G=0;for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(z[l].source+="*",mist.send(function(a,c){var b=c.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=b+"+"+a.browse.files[d];z[f]=W(f,mist.data.streams[b]);z[f].source=mist.data.streams[b].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?z[b].filesfound=true:mist.data.streams[b].filesfound=false;G++;if(C==G){mist.send(function(){E()},{active_streams:true});UI.interval.set(function(){E()},1E4)}},{browse:mist.data.streams[l].source},{stream:l}),C++);0==C&&(mist.send(function(){E()},
|
||||
{active_streams:!0}),UI.interval.set(function(){E()},3E4))}else mist.send(function(){E()},{active_streams:!0}),UI.interval.set(function(){E()},1E4);break;case "Edit Stream":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,c)},{capabilities:!0});d.append("Loading..");break}j=!1;""!=c&&(j=!0);j?(l=c,o=mist.data.streams[l],d.find("h2").append(' "'+l+'"')):(d.html($("<h2>").text("New Stream")),o={});l=[];for(q in mist.data.capabilities.inputs)l.push(mist.data.capabilities.inputs[q].source_match);
|
||||
|
@ -98,34 +98,33 @@ o);J.append(UI.buildUI(a))}}}},$("<br>"),{type:"custom",custom:J},$("<br>"),$("<
|
|||
index:"contentkey"}},{type:"text",text:" - or - "},{label:"Key ID",type:"str",LTSonly:!0,pointer:{main:o,index:"keyid"}},{label:"Key seed",type:"str",LTSonly:!0,pointer:{main:o,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[o.name]=o;c!=o.name&&delete mist.data.streams[c];var a={};if(mist.data.LTS){a.addstream={};a.addstream[o.name]=
|
||||
o;if(c!=o.name)a.deletestream=[c]}else a.streams=mist.data.streams;mist.send(function(){delete mist.data.streams[o.name].online;delete mist.data.streams[o.name].error;UI.navto("Streams")},a)}}]}]));break;case "Preview":if(""==c){d.append("Loading..");var N=function(c){var b={};c.sort();d.html($("<h2>").text(a)).append(UI.buildUI([{label:"Select a stream",type:"select",select:c,pointer:{main:b,index:"stream"}},{type:"buttons",buttons:[{type:"save",label:"Go","function":function(){UI.navto(a,b.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");d.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});d.append("Loading..");break}G=C=0;x={};for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(mist.send(function(a,c){var b=c.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])&&(x[b+"+"+mist.data.browse.files[d]]=true);G++;C==G&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");c.length>1&&c[0]in mist.data.streams&&(x[mist.data.active_streams[a]]=true)}x=Object.keys(x);x=x.concat(Object.keys(mist.data.streams));x.sort();N(x)},{active_streams:true})},{browse:mist.data.streams[l].source},{stream:l}),
|
||||
C++);0==C&&mist.send(function(){var c=[],b;for(b in mist.data.active_streams){var e=mist.data.active_streams[b].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[b]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");else{c.sort();N(c)}},{active_streams:!0})}else N(Object.keys(mist.data.streams));break}d.find("h2").append(' of "'+c+'"');l=":8080";for(q in mist.data.config.protocols)if(r=
|
||||
mist.data.config.protocols[q],"HTTP"==r.connector||"HTTP.exe"==r.connector)l=r.port?":"+r.port:":8080";var D={},r=$("<span>").hide();D["Embed urls"]=r;d.append(r);e=mist.user.host;b=document.createElement("a");b.href=e;e=b.protocol+"//";b=b.hostname;var H=e+b+l+"/",y={autoplay:!0},K=function(a){var b=["div"],d='\n <script src="'+H+"embed_"+c+'.js"><\/script>\n';a.autoplay||b.push("data-noautoplay");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>"},X=$("<span>");r.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:H+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:H+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:H+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:K(y),rows:4,
|
||||
readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",0),{label:"Autoplay",type:"checkbox",value:!0,pointer:{main:y,index:"autoplay"},"function":function(){y.autoplay=$(this).getval();$(".embed_code").setval(K(y))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:y,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){y.forceprotocol=$(this).getval();$(".embed_code").setval(K(y))}},{label:"Video URL addition",
|
||||
type:"str",pointer:{main:y,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(){y.urlappend=$(this).getval();$(".embed_code").setval(K(y))}},$("<h3>").text("Protocol stream urls"),X]));l=$("<span>").append($("<h3>").text("Meta information")).hide();D["Meta information"]=l;var O=$("<span>");l.append(O);d.append(l);l=$("<span>").hide();D.Preview=l;d.append(l);var L=$("<div>").css({"float":"left",
|
||||
"margin-right":"1em",width:"100%"}),u=$("<div>").addClass("video_container").attr("data-forcesupportcheck","");L.html(u);var Y=$("<div>").css("float","left");l.append(L).append(Y);mist.stored.get().autoplay||u.attr("data-noautoplay","");var M=function(){u.text("Loading..");L.children(".input_container").remove();var a=document.createElement("script");a.src=H+"embed_"+c+".js";a.onerror=function(){u.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){M()}))};
|
||||
a.onload=function(){if(typeof mistvideo[c].error!="undefined")u.height("5em").html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){M()}));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)}}]);u.height(Math.min(a.height,u.height()));
|
||||
b.find(".help_container").remove();L.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"))));Y.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(){u.attr("data-forcetype",$(this).val()).html("Loading embed..");M()}).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)}}X.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,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});for(var t in d){e=d[t];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");t=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(t));O.html(UI.buildUI(a))}else O.html("No meta information available.")}};u.html("")[0].appendChild(a)};M();var P=UI.elements.secondary_menu;P.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));l=["Preview","Embed urls","Meta information"];A=l[0];for(q in l)r=$("<a>").addClass("button").text(l[q]).click(function(){P.find(".active").removeClass("active");
|
||||
$(this).addClass("active");for(q in D)D[q].hide();D[$(this).text()].show()}),P.append(r),l[q]==A&&(r.addClass("active"),D[A].show());break;case "Push":u=$("<div>").text("Loading..");d.append(u);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=true,g;for(g in b.push_list)if(a.indexOf(b.push_list[g][0])>-1){d=false;break}}else d=true;if(d)for(g in a)e.find("tr[data-pushid="+a[g]+"]").remove();else c()},
|
||||
{push_list:1})},1E3)}function b(d,g){var f=$("<span>");d.length>=4&&d[2]!=d[3]?f.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(d[3])):f.append($("<span>").text(d[2]));var h=$("<td>").append($("<button>").text(g=="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(g==
|
||||
"Automatic"?"Removing..":"Stopping..")));g=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:d[1],target:d[2]}}):mist.send(function(){c([d[0]])},{push_stop:[d[0]]})}}));g=="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 b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text("Removing and stopping..")));
|
||||
var g=[],f;for(f in a.push_list)if(d[1]==a.push_list[f][1]&&d[2]==a.push_list[f][2]){g.push(a.push_list[f][0]);e.find("tr[data-pushid="+a.push_list[f][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.remove();c(g)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:g})}}));return $("<tr>").attr("data-pushid",d[0]).append($("<td>").text(d[1])).append($("<td>").append(f.children())).append(h)}u.html("");var d=a.push_settings;d||(d={});
|
||||
u.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"},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>"))),g=e.clone();if("push_list"in a)for(var f in a.push_list)e.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)g.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],
|
||||
"Automatic"));u.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));g.find("tr").length==1?u.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):u.append(g);u.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)u.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top",
|
||||
"0.5em"));else{var g=[],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(f in a.push_list){g.indexOf(a.push_list[f][1])==-1&&g.push(a.push_list[f][1]);h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}g.sort();h.sort();for(f in g)i.append($("<option>").text(g[f]));for(f in h)j.append($("<option>").text(h[f]));u.append($("<button>").text("Stop all pushes").click(function(){var b=
|
||||
[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});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 b=i.val(),d=j.val();if(b==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var g={},f;for(f in a.push_list)if((b==""||a.push_list[f][1]==b)&&(d==""||a.push_list[f][2]==d))g[a.push_list[f][0]]=a.push_list[f];if(Object.keys(g).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(f in g)b=b+(g[f][1]+
|
||||
" to "+g[f][2]+"\n");if(confirm(b)){g=Object.keys(g);mist.send(function(){c(g)},{push_stop:g});for(f in g)e.find("tr[data-pushid="+g[f]+"]").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)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});break}var v,Q=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var e=
|
||||
mist.data.capabilities.connectors[b];"push_urls"in e&&(a=a.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var g={};d.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>",
|
||||
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});d.append("Loading..");break}G=C=0;x={};for(l in mist.data.streams)r=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"],mist.inputMatch(r.source_match,mist.data.streams[l].source)&&(mist.send(function(a,c){var b=c.stream,d;for(d 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[d])&&(x[b+"+"+a.browse.files[d]]=true);G++;C==G&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");c.length>1&&c[0]in mist.data.streams&&(x[mist.data.active_streams[a]]=true)}x=Object.keys(x);x=x.concat(Object.keys(mist.data.streams));x.sort();N(x)},{active_streams:true})},{browse:mist.data.streams[l].source},{stream:l}),C++);0==C&&mist.send(function(){var c=
|
||||
[],b;for(b in mist.data.active_streams){var e=mist.data.active_streams[b].split("+");e.length>1&&e[0]in mist.data.streams&&(c[mist.data.active_streams[b]]=true)}mist.data.streams&&(c=c.concat(Object.keys(mist.data.streams)));if(c.length==0)d.html($("<h2>").text(a)).append("Please set up a stream first.");else{c.sort();N(c)}},{active_streams:!0})}else N(Object.keys(mist.data.streams));break}d.find("h2").append(' of "'+c+'"');l=":8080";for(q in mist.data.config.protocols)if(r=mist.data.config.protocols[q],
|
||||
"HTTP"==r.connector||"HTTP.exe"==r.connector)l=r.port?":"+r.port:":8080";var D={},r=$("<span>").hide();D["Embed urls"]=r;d.append(r);e=mist.user.host;b=document.createElement("a");b.href=e;e=b.protocol+"//";b=b.hostname;var H=e+b+l+"/",y={autoplay:!0},K=function(a){var b=["div"],d='\n <script src="'+H+"embed_"+c+'.js"><\/script>\n';a.autoplay||b.push("data-noautoplay");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>"},X=$("<span>");r.append($("<h3>").text("Embed urls")).append(UI.buildUI([{label:"Embedable script",type:"str",value:H+"embed_"+c+".js",readonly:!0},{label:"Stream info script",type:"str",value:H+"info_"+c+".js",readonly:!0},{label:"Autodetect player",type:"str",value:H+c+".html",readonly:!0,qrcode:!0},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:K(y),rows:4,readonly:!0,classes:["embed_code"]},$("<h4>").text("Embed code options").css("margin-top",
|
||||
0),{label:"Autoplay",type:"checkbox",value:!0,pointer:{main:y,index:"autoplay"},"function":function(){y.autoplay=$(this).getval();$(".embed_code").setval(K(y))}},{label:"Force protocol",type:"select",select:[["","Automatic"]],pointer:{main:y,index:"protocol"},classes:["embed_code_forceprotocol"],"function":function(){y.forceprotocol=$(this).getval();$(".embed_code").setval(K(y))}},{label:"Video URL addition",type:"str",pointer:{main:y,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(){y.urlappend=$(this).getval();$(".embed_code").setval(K(y))}},$("<h3>").text("Protocol stream urls"),X]));l=$("<span>").append($("<h3>").text("Meta information")).hide();D["Meta information"]=l;var O=$("<span>");l.append(O);d.append(l);l=$("<span>").hide();D.Preview=l;d.append(l);var L=$("<div>").css({"float":"left","margin-right":"1em",width:"100%"}),u=$("<div>").addClass("video_container").attr("data-forcesupportcheck","");L.html(u);var Y=
|
||||
$("<div>").css("float","left");l.append(L).append(Y);mist.stored.get().autoplay||u.attr("data-noautoplay","");var M=function(){u.text("Loading..");L.children(".input_container").remove();var a=document.createElement("script");a.src=H+"embed_"+c+".js";a.onerror=function(){u.html('Error loading "'+a.src+'".<br>').append($("<button>").text("Try again").click(function(){M()}))};a.onload=function(){if(typeof mistvideo[c].error!="undefined")u.height("5em").html(mistvideo[c].error+"<br>").append($("<button>").text("Try again").click(function(){M()}));
|
||||
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)}}]);u.height(Math.min(a.height,u.height()));b.find(".help_container").remove();L.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"))));
|
||||
Y.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(){u.attr("data-forcetype",$(this).val()).html("Loading embed..");M()}).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)}}X.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,c){a=a.split("_").pop();c=c.split("_").pop();return a-c});for(var t in d){e=d[t];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");t=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(t));O.html(UI.buildUI(a))}else O.html("No meta information available.")}};u.html("")[0].appendChild(a)};M();var P=UI.elements.secondary_menu;P.html("").append($("<a>").addClass("button").text("Choose stream").click(function(){UI.navto("Preview")})).append($("<span>").addClass("separator"));
|
||||
l=["Preview","Embed urls","Meta information"];A=l[0];for(q in l)r=$("<a>").addClass("button").text(l[q]).click(function(){P.find(".active").removeClass("active");$(this).addClass("active");for(q in D)D[q].hide();D[$(this).text()].show()}),P.append(r),l[q]==A&&(r.addClass("active"),D[A].show());break;case "Push":u=$("<div>").text("Loading..");d.append(u);mist.send(function(a){function c(a){setTimeout(function(){mist.send(function(b){var d=false;if("push_list"in b&&b.push_list&&b.push_list.length){var d=
|
||||
true,g;for(g in b.push_list)if(a.indexOf(b.push_list[g][0])>-1){d=false;break}}else d=true;if(d)for(g in a)e.find("tr[data-pushid="+a[g]+"]").remove();else c()},{push_list:1})},1E3)}function b(d,g){var f=$("<span>");d.length>=4&&d[2]!=d[3]?f.append($("<span>").text(d[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(d[3])):f.append($("<span>").text(d[2]));var h=$("<td>").append($("<button>").text(g=="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(g=="Automatic"?"Removing..":"Stopping..")));g=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:d[1],target:d[2]}}):mist.send(function(){c([d[0]])},{push_stop:[d[0]]})}}));g=="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 b=$(this).closest("tr");b.html($("<td colspan=99>").html($("<span>").addClass("red").text("Removing and stopping..")));var g=[],f;for(f in a.push_list)if(d[1]==a.push_list[f][1]&&d[2]==a.push_list[f][2]){g.push(a.push_list[f][0]);e.find("tr[data-pushid="+a.push_list[f][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){b.remove();c(g)},{push_auto_remove:{stream:d[1],target:d[2]},push_stop:g})}}));return $("<tr>").attr("data-pushid",
|
||||
d[0]).append($("<td>").text(d[1])).append($("<td>").append(f.children())).append(h)}u.html("");var d=a.push_settings;d||(d={});u.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"},
|
||||
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>"))),g=e.clone();
|
||||
if("push_list"in a)for(var f in a.push_list)e.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)g.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));u.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));g.find("tr").length==1?u.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):u.append(g);
|
||||
u.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)u.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var g=[],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(f in a.push_list){g.indexOf(a.push_list[f][1])==-1&&g.push(a.push_list[f][1]);
|
||||
h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}g.sort();h.sort();for(f in g)i.append($("<option>").text(g[f]));for(f in h)j.append($("<option>").text(h[f]));u.append($("<button>").text("Stop all pushes").click(function(){var b=[],d;for(d in a.push_list)b.push(a.push_list[d][0]);if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){c(b)},{push_stop:b});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 b=i.val(),d=j.val();if(b==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var g={},f;for(f in a.push_list)if((b==""||
|
||||
a.push_list[f][1]==b)&&(d==""||a.push_list[f][2]==d))g[a.push_list[f][0]]=a.push_list[f];if(Object.keys(g).length==0)return alert("No matching pushes.");b="Are you sure you want to stop these pushes?\n\n";for(f in g)b=b+(g[f][1]+" to "+g[f][2]+"\n");if(confirm(b)){g=Object.keys(g);mist.send(function(){c(g)},{push_stop:g});for(f in g)e.find("tr[data-pushid="+g[f]+"]").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)){d.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",c)},{capabilities:1});break}var v,Q=function(){var a=[],b;for(b in mist.data.capabilities.connectors){var e=mist.data.capabilities.connectors[b];"push_urls"in e&&(a=a.concat(e.push_urls))}c=="auto"&&d.find("h2").text("Add automatic push");var g={};d.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:v,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[c=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
||||
mist.send(function(a){(v=a.active_streams)||(v=[]);var a=[],b;for(b in v)v[b].indexOf("+")!=-1&&a.push(v[b].replace(/\+.*/,"")+"+");v=v.concat(a);var c=0,d=0;for(b in mist.data.streams){v.push(b);if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){v.push(b+"+");mist.send(function(a,b){var e=b.stream,g;for(g in a.browse.files)for(var f in mist.data.capabilities.inputs)f.indexOf("Buffer")>=0||f.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,
|
||||
|
|
|
@ -2738,11 +2738,11 @@ var UI = {
|
|||
//this is a folder stream
|
||||
mist.send(function(d,opts){
|
||||
var s = opts.stream;
|
||||
for (var i in mist.data.browse.files) {
|
||||
for (var i in d.browse.files) {
|
||||
for (var j in mist.data.capabilities.inputs) {
|
||||
if ((j.indexOf('Buffer') >= 0) || (j.indexOf('Folder') >= 0)) { continue; }
|
||||
if (mist.inputMatch(mist.data.capabilities.inputs[j].source_match,'/'+mist.data.browse.files[i])) {
|
||||
select[s+'+'+mist.data.browse.files[i]] = true;
|
||||
if (mist.inputMatch(mist.data.capabilities.inputs[j].source_match,'/'+d.browse.files[i])) {
|
||||
select[s+'+'+d.browse.files[i]] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue