Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2019-09-04 15:17:39 +02:00
commit 1e2469c9b5
7 changed files with 53 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -420,7 +420,9 @@ var MistUtil = {
},
sanitizeHost: function(host){
var split = MistUtil.http.url.split(host);
return split.protocol + "//" + split.host + (split.port && (split.port != "") ? ":"+split.port : "") + (split.hash && (split.hash != "") ? "#"+split.hash : "") + (split.path ? split.path : "");
var out = split.protocol + "//" + split.host + (split.port && (split.port != "") ? ":"+split.port : "") + (split.hash && (split.hash != "") ? "#"+split.hash : "") + (split.path ? (split.path.charAt(0) == "/" ? split.path : "/"+split.path) : "");
console.log("converted",host,"to",out);
return out;
}
}
},

View file

@ -136,9 +136,15 @@ p.prototype.build = function (MistVideo,callback) {
currenttracks = ev.tracks;
}
},
on_seek: function(){
on_seek: function(e){
var thisPlayer = this;
MistUtil.event.send("seeked",seekoffset,video);
//set playback rate to auto if seek was to live point
if (e.live_point) {
thisPlayer.webrtc.playbackrate("auto");
}
if ("seekPromise" in this.webrtc.signaling){
video.play().then(function(){
if ("seekPromise" in thisPlayer.webrtc.signaling) {
@ -152,6 +158,10 @@ p.prototype.build = function (MistVideo,callback) {
}
else { video.play(); }
},
on_speed: function(e){
this.webrtc.play_rate = e.play_rate_curr;
MistUtil.event.send("ratechange",e,video);
},
on_stop: function(){
MistVideo.log("Websocket sent on_stop");
MistUtil.event.send("ended",null,video);
@ -164,6 +174,7 @@ p.prototype.build = function (MistVideo,callback) {
this.peerConn = null;
this.localOffer = null;
this.isConnected = false;
this.play_rate = "auto";
var thisWebRTCPlayer = this;
this.on_event = function(ev) {
@ -256,6 +267,19 @@ p.prototype.build = function (MistVideo,callback) {
obj.type = "tracks";
this.signaling.send(obj);
};
this.playbackrate = function(value) {
if (typeof value == "undefined") {
return (me.webrtc.play_rate == "auto" ? 1 : me.webrtc.play_rate);
}
if (!this.isConnected) { throw "Not connected, cannot change playback rate." }
this.signaling.send({
type: "set_speed",
play_rate: value
});
};
this.getStats = function(callback){
this.peerConn.getStats().then(function(d){
var output = {};
@ -342,6 +366,17 @@ p.prototype.build = function (MistVideo,callback) {
}
});
//override playbackrate
Object.defineProperty(this.api,"playbackRate",{
get: function(){
return me.webrtc.playbackrate();
},
set: function(value){
return me.webrtc.playbackrate(value);
//TODO send playbackrate changed event?
}
});
//redirect properties
//using a function to make sure the "item" is in the correct scope
function reroute(item) {

View file

@ -142,11 +142,11 @@ style:{flexShrink:1},children:[{"if":function(){return this.playerName&&this.sou
classes:["mistvideo-devbuttons"],style:{"flex-wrap":"wrap"},children:[{"if":function(){return!(!this.player||!this.player.api)},then:{type:"button",title:"Reload the video source",label:"Reload video",onclick:function(){this.player.api.load()}}},{type:"button",title:"Build MistVideo again",label:"Reload player",onclick:function(){this.reload()}},{type:"button",title:"Switch to the next available player and source combination",label:"Try next combination",onclick:function(){this.nextCombo()}}]},{type:"forcePlayer"},
{type:"forceType"},{type:"forceSource"}]},{type:"log"}]}))};if(!(a!="Preview"||!c||c==""||g!=c)){N[0].addEventListener("initialized",f);N[0].addEventListener("initializeFailed",f);MistVideoObject.reference=mistPlay(g,{target:N[0],host:K,skin:"dev",loop:true,MistVideoObject:MistVideoObject})}d[0].removeChild(b)};MistVideoObject.reference={unload:function(){b.onload=function(){this.parentElement&&this.parentElement.removeChild(this)}}}};qa();o=$("<div>").append($("<h3>").text("Meta information"));var S=
$("<span>").text("Loading..");o.append(S);J.append(o);""!=C&&$.ajax({type:"GET",url:K+"json_"+C+".js",success:function(a){var b=function(a,b){return"maxbps"in a?UI.format.bytes(a[b],1):b=="maxbps"?UI.format.bytes(a.bps,1):"unknown"},c=a.meta;if(!c||!c.tracks)S.html("No meta information available.");else{a=[];a.push({label:"Type",type:"span",value:c.live?"Live":"Pre-recorded (VoD)"});"format"in c&&a.push({label:"Format",type:"span",value:c.format});c.live&&a.push({label:"Buffer window",type:"span",
value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Size","Framerate","Language","Track index"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},g=Object.keys(c.tracks);g.sort(function(a,b){a=
a.split("_").pop();b=b.split("_").pop();return a-b});var f=1,e=1,i=1,h;for(h in g){var k=g[h],j=c.tracks[k];switch(j.type){case "audio":d.audio.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),j.channels,UI.format.addUnit(UI.format.number(j.rate),"Hz"),"language"in j?j.language:"unknown",f]});f++;break;
case "video":d.video.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),UI.format.addUnit(j.width,"x ")+UI.format.addUnit(j.height,"px"),UI.format.addUnit(UI.format.number(j.fpks/1E3),"fps"),"language"in j?j.language:"unknown",e]});e++;break;case "meta":case "subtitle":if(j.codec=="subtitle"||j.type=="subtitle"){d.subtitle.content.push({header:"Track "+
k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),"language"in j?j.language:"unknown",i]});i++}}}b=["audio","video","subtitle"];h=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&h.append(UI.buildVheaderTable(d[b[k]]).css("width","auto"));a.push($("<span>").text("Tracks:"));
a.push(h);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");j="";-1==c.indexOf("+")&&(j=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(j).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+
value:UI.format.addUnit(c.buffer_window,"ms")});var d={audio:{vheader:"Audio",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Channels","Samplerate","Language","Track index"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Size","Framerate","Language","Track index","Has B-Frames"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Avg bitrate","Peak bitrate","Language","Track index"],content:[]}},g=Object.keys(c.tracks);g.sort(function(a,
b){a=a.split("_").pop();b=b.split("_").pop();return a-b});var f=1,e=1,i=1,h;for(h in g){var k=g[h],j=c.tracks[k];switch(j.type){case "audio":d.audio.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),j.channels,UI.format.addUnit(UI.format.number(j.rate),"Hz"),"language"in j?j.language:"unknown",f]});f++;
break;case "video":d.video.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),UI.format.addUnit(j.width,"x ")+UI.format.addUnit(j.height,"px"),UI.format.addUnit(UI.format.number(j.fpks/1E3),"fps"),"language"in j?j.language:"unknown",e,"bframes"in j?"yes":"no"]});e++;break;case "meta":case "subtitle":if(j.codec==
"subtitle"||j.type=="subtitle"){d.subtitle.content.push({header:"Track "+k.split("_").pop(),body:[j.codec,UI.format.duration((j.lastms-j.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(j.firstms/1E3)+" to "+UI.format.duration(j.lastms/1E3)+"</span>",b(j,"bps"),b(j,"maxbps"),"language"in j?j.language:"unknown",i]});i++}}}b=["audio","video","subtitle"];h=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(k in b)d[b[k]].content.length&&h.append(UI.buildVheaderTable(d[b[k]]).css("width",
"auto"));a.push($("<span>").text("Tracks:"));a.push(h);S.html(UI.buildUI(a))}},error:function(){S.html("Error while retrieving stream info.")}});break;case "Embed":""==c&&UI.navTo("Streams");j="";-1==c.indexOf("+")&&(j=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",c)}));d.html($("<div>").addClass("bigbuttons").append(j).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",c)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+
c+'"'));var O=$("<span>");d.append(O);C=encodeURIComponent(c);j=parseURL(mist.user.host);b={"":{port:":8080"}};for(o in mist.data.config.protocols){t=mist.data.config.protocols[o];if("HTTP"==t.connector||"HTTP.exe"==t.connector)b[""].port=t.port?":"+t.port:":8080";if("HTTPS"==t.connector||"HTTPS.exe"==t.connector)b.s={},b.s.port=t.port?":"+t.port:":4433"}var H=K="http://"+j.host+b[""].port+"/";if(otherhost.host||otherhost.https)H=(otherhost.https&&"s"in b?"https://":"http://")+(otherhost.host?otherhost.host:
j.host)+(otherhost.https&&"s"in b?b.s.port:b[""].port)+"/";var P=!1,aa={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,muted:!1,fillSpace:!1,poster:"",urlappend:"",setTracks:{}},q=$.extend({},aa);o=UI.stored.getOpts();"embedoptions"in o&&(q=$.extend(q,o.embedoptions,!0),"object"!=typeof q.setTracks&&(q.setTracks={}));o={};switch(q.controls){case "stock":o.controls="stock";break;case !0:o.controls=1;break;case !1:o.controls=0}var x=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?
b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}P&&UI.stored.saveOpt("embedoptions",q);for(var b=c+"_",d=12,g="";d--;){var f;f=Math.floor(Math.random()*62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);g=g+f}var b=b+g,d=['target: document.getElementById("'+b+'")'],e;for(e in q)e=="prioritize_type"?q[e]&&q[e]!=""&&d.push("forcePriority: "+JSON.stringify({source:[["type",[q[e]]]]})):e=="monitor_action"?q[e]&&q[e]!=""&&q[e]=="nextCombo"&&d.push('monitor: {\n action: function(){\n this.MistVideo.log("Switching to nextCombo because of poor playback in "+this.MistVideo.source.type+" ("+Math.round(this.vars.score*1000)/10+"%)");\n this.MistVideo.nextCombo();\n }\n }'):

View file

@ -4205,7 +4205,7 @@ var UI = {
},
video: {
vheader: 'Video',
labels: ['Codec','Duration','Avg bitrate','Peak bitrate','Size','Framerate','Language','Track index'],
labels: ['Codec','Duration','Avg bitrate','Peak bitrate','Size','Framerate','Language','Track index','Has B-Frames'],
content: []
},
subtitle: {
@ -4263,7 +4263,8 @@ var UI = {
UI.format.addUnit(track.width,'x ')+UI.format.addUnit(track.height,'px'),
UI.format.addUnit(UI.format.number(track.fpks/1000),'fps'),
('language' in track ? track.language : 'unknown'),
(trackindex.video)
(trackindex.video),
("bframes" in track ? "yes" : "no")
]
});
trackindex.video++

View file

@ -308,6 +308,9 @@ namespace Mist {
/*LTS-END*/
std::string uAgent = H.GetHeader("User-Agent");
std::string forceType = "";
if (H.GetVar("forcetype").size()) { forceType = ",forceType:\""+H.GetVar("forcetype")+"\""; }
std::string devSkin = "";
if (H.GetVar("dev").size()) { devSkin = ",skin:\"dev\""; }
H.SetVar("stream", "");
@ -328,7 +331,7 @@ namespace Mist {
std::string hlsUrl = "/hls/"+streamName+"/index.m3u8";
std::string mp4Url = "/"+streamName+".mp4";
H.SetBody("<!DOCTYPE html><html><head><title>"+streamName+"</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><style>html{margin:0;padding:0;display:table;width:100%;height:100%;}body{color:white;background:#0f0f0f;margin:0;padding:0;display:table-cell;vertical-align:middle;text-align:center}body>div>div{text-align:left;}</style></head><body><div class=mistvideo id=\""+streamName+"\"><noscript><video controls autoplay><source src=\""+hlsUrl+"\" type=\"application/vnd.apple.mpegurl\"><source src=\""+mp4Url+"\" type=\"video/mp4\"><a href=\""+hlsUrl+"\">Click here to play the video [Apple]</a><br><a href=\""+mp4Url+"\">Click here to play the video [MP4]</a></video></noscript><script src=\"player.js\"></script><script>mistPlay('"+streamName+"',{host:'"+fullURL.getUrl()+"',target:document.getElementById('"+streamName+"')"+devSkin+"})</script></div></body></html>");
H.SetBody("<!DOCTYPE html><html><head><title>"+streamName+"</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><style>html{margin:0;padding:0;display:table;width:100%;height:100%;}body{color:white;background:#0f0f0f;margin:0;padding:0;display:table-cell;vertical-align:middle;text-align:center}body>div>div{text-align:left;}</style></head><body><div class=mistvideo id=\""+streamName+"\"><noscript><video controls autoplay><source src=\""+hlsUrl+"\" type=\"application/vnd.apple.mpegurl\"><source src=\""+mp4Url+"\" type=\"video/mp4\"><a href=\""+hlsUrl+"\">Click here to play the video [Apple]</a><br><a href=\""+mp4Url+"\">Click here to play the video [MP4]</a></video></noscript><script src=\"player.js\"></script><script>mistPlay('"+streamName+"',{host:'"+fullURL.getUrl()+"',target:document.getElementById('"+streamName+"')"+forceType+devSkin+"})</script></div></body></html>");
if ((uAgent.find("iPad") != std::string::npos) || (uAgent.find("iPod") != std::string::npos) || (uAgent.find("iPhone") != std::string::npos)) {
H.SetHeader("Location",hlsUrl);
H.SendResponse("307", "HLS redirect", myConn);