Merge branch 'development' into LTS_development
# Conflicts: # src/output/output_httpts.cpp # src/output/output_ts_base.h
This commit is contained in:
commit
aebeeabd2b
27 changed files with 41179 additions and 385 deletions
|
@ -453,10 +453,12 @@ add_custom_target(embedcode
|
||||||
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/jwplayer.js jwplayer_js ${BINARY_DIR}/jwplayer.js.h
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/jwplayer.js jwplayer_js ${BINARY_DIR}/jwplayer.js.h
|
||||||
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/polytrope.js polytrope_js ${BINARY_DIR}/polytrope.js.h
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/polytrope.js polytrope_js ${BINARY_DIR}/polytrope.js.h
|
||||||
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/dashjs.js dash_js ${BINARY_DIR}/dashjs.js.h
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/dashjs.js dash_js ${BINARY_DIR}/dashjs.js.h
|
||||||
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/wrappers/videojs.js video_js ${BINARY_DIR}/videojs.js.h
|
||||||
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/dash.js playerdash_js ${BINARY_DIR}/playerdash.js.h
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/dash.js playerdash_js ${BINARY_DIR}/playerdash.js.h
|
||||||
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/players/videojs.js playervideo_js ${BINARY_DIR}/playervideo.js.h
|
||||||
COMMAND ./sourcery ${SOURCE_DIR}/embed/core.js core_js ${BINARY_DIR}/core.js.h
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/core.js core_js ${BINARY_DIR}/core.js.h
|
||||||
COMMAND ./sourcery ${SOURCE_DIR}/embed/mist.css mist_css ${BINARY_DIR}/mist.css.h
|
COMMAND ./sourcery ${SOURCE_DIR}/embed/mist.css mist_css ${BINARY_DIR}/mist.css.h
|
||||||
DEPENDS sourcery ${SOURCE_DIR}/src/embed.js ${SOURCE_DIR}/embed/wrappers/html5.js ${SOURCE_DIR}/embed/wrappers/flash_strobe.js ${SOURCE_DIR}/embed/wrappers/silverlight.js ${SOURCE_DIR}/embed/wrappers/theoplayer.js ${SOURCE_DIR}/embed/wrappers/jwplayer.js ${SOURCE_DIR}/embed/wrappers/polytrope.js ${SOURCE_DIR}/embed/wrappers/dashjs.js ${SOURCE_DIR}/embed/players/dash.js ${SOURCE_DIR}/embed/core.js ${SOURCE_DIR}/embed/mist.css
|
DEPENDS sourcery ${SOURCE_DIR}/src/embed.js ${SOURCE_DIR}/embed/wrappers/html5.js ${SOURCE_DIR}/embed/wrappers/flash_strobe.js ${SOURCE_DIR}/embed/wrappers/silverlight.js ${SOURCE_DIR}/embed/wrappers/theoplayer.js ${SOURCE_DIR}/embed/wrappers/jwplayer.js ${SOURCE_DIR}/embed/wrappers/polytrope.js ${SOURCE_DIR}/embed/wrappers/dashjs.js ${SOURCE_DIR}/embed/wrappers/videojs.js ${SOURCE_DIR}/embed/players/dash.js ${SOURCE_DIR}/embed/players/videojs.js ${SOURCE_DIR}/embed/core.js ${SOURCE_DIR}/embed/mist.css
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
479
embed/core.js
479
embed/core.js
|
@ -3,6 +3,7 @@
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
var mistplayers = {};
|
var mistplayers = {};
|
||||||
|
var mistplayer_session_id = Math.round(Math.random()*1e12);
|
||||||
|
|
||||||
function MistPlayer() {};
|
function MistPlayer() {};
|
||||||
MistPlayer.prototype.sendEvent = function(type,message,target) {
|
MistPlayer.prototype.sendEvent = function(type,message,target) {
|
||||||
|
@ -40,18 +41,103 @@ MistPlayer.prototype.build = function () {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
//creates the player element, including custom functions
|
//creates the player element, including custom functions
|
||||||
MistPlayer.prototype.element = function(tag){
|
MistPlayer.prototype.getElement = function(tag){
|
||||||
var ele = document.createElement(tag);
|
var ele = document.createElement(tag);
|
||||||
ele.className = 'mistplayer';
|
ele.className = 'mistplayer';
|
||||||
this.element = ele;
|
this.element = ele;
|
||||||
return ele;
|
return ele;
|
||||||
};
|
};
|
||||||
|
MistPlayer.prototype.onreadylist = [];
|
||||||
|
MistPlayer.prototype.onready = function(dothis){
|
||||||
|
this.onreadylist.push(dothis);
|
||||||
|
};
|
||||||
MistPlayer.prototype.play = false;
|
MistPlayer.prototype.play = false;
|
||||||
MistPlayer.prototype.pause = false;
|
MistPlayer.prototype.pause = false;
|
||||||
|
MistPlayer.prototype.paused = false;
|
||||||
MistPlayer.prototype.volume = false;
|
MistPlayer.prototype.volume = false;
|
||||||
MistPlayer.prototype.loop = false;
|
MistPlayer.prototype.loop = false;
|
||||||
MistPlayer.prototype.fullscreen = false;
|
MistPlayer.prototype.fullscreen = false;
|
||||||
MistPlayer.prototype.setTracks = false;
|
MistPlayer.prototype.setTracks = function(usetracks){
|
||||||
|
if (usetracks == false) {
|
||||||
|
if (!('updateSrc' in this)) { return false; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function urlAddParam(url,params) {
|
||||||
|
var spliturl = url.split('?');
|
||||||
|
var ret = [spliturl.shift()];
|
||||||
|
var splitparams = [];
|
||||||
|
if (spliturl.length) {
|
||||||
|
splitparams = spliturl[0].split('&');
|
||||||
|
}
|
||||||
|
for (var i in params) {
|
||||||
|
splitparams.push(i+'='+params[i]);
|
||||||
|
}
|
||||||
|
if (splitparams.length) { ret.push(splitparams.join('&')); }
|
||||||
|
return ret.join('?');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('subtitle' in usetracks) {
|
||||||
|
//remove previous subtitles
|
||||||
|
var ts = this.element.getElementsByTagName('track');
|
||||||
|
for (var i = ts.length - 1; i >= 0; i--) {
|
||||||
|
this.element.removeChild(ts[i]);
|
||||||
|
}
|
||||||
|
var tracks = this.tracks.subtitle;
|
||||||
|
for (var i in tracks) {
|
||||||
|
if (tracks[i].trackid == usetracks.subtitle) {
|
||||||
|
var t = document.createElement('track');
|
||||||
|
this.element.appendChild(t);
|
||||||
|
t.kind = 'subtitles';
|
||||||
|
t.label = tracks[i].desc;
|
||||||
|
t.srclang = tracks[i].lang;
|
||||||
|
t.src = this.subtitle+'?track='+tracks[i].trackid;
|
||||||
|
t.setAttribute('default','');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete usetracks.subtitle;
|
||||||
|
if (Object.keys(usetracks).length == 0) { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
var time = this.element.currentTime;
|
||||||
|
var newurl;
|
||||||
|
if (this.options.source.type == 'html5/application/vnd.apple.mpegurl') { //for HLS, use a different format for track selection
|
||||||
|
newurl = this.options.src.split('/');
|
||||||
|
var m3u8 = newurl.pop(); //take this off now, it will be added back later
|
||||||
|
var hlstracks = [];
|
||||||
|
for (var i in usetracks) {
|
||||||
|
//for audio or video tracks, just add the tracknumber between slashes
|
||||||
|
switch (i) {
|
||||||
|
case 'audio':
|
||||||
|
case 'video':
|
||||||
|
if (usetracks[i] == 0) { continue; }
|
||||||
|
hlstracks.push(usetracks[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hlstracks.length) { newurl.push(hlstracks.join('_')); }
|
||||||
|
newurl.push(m3u8); //put back index.m3u8
|
||||||
|
newurl = newurl.join('/');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newurl = urlAddParam(this.options.src,usetracks);
|
||||||
|
}
|
||||||
|
this.updateSrc(newurl);
|
||||||
|
if (this.element.readyState) {
|
||||||
|
this.element.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.element.currentTime = time;
|
||||||
|
|
||||||
|
if ('trackselects' in this) {
|
||||||
|
for (var i in usetracks) {
|
||||||
|
if (i in this.trackselects) { this.trackselects[i].value = usetracks[i]; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
MistPlayer.prototype.resize = false;
|
MistPlayer.prototype.resize = false;
|
||||||
MistPlayer.prototype.buildMistControls = function(){
|
MistPlayer.prototype.buildMistControls = function(){
|
||||||
if (!('flex' in document.head.style) || (['iPad','iPod','iPhone'].indexOf(navigator.platform) != -1)) {
|
if (!('flex' in document.head.style) || (['iPad','iPod','iPhone'].indexOf(navigator.platform) != -1)) {
|
||||||
|
@ -72,11 +158,7 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
secs = Math.floor(secs - mins * 60);
|
secs = Math.floor(secs - mins * 60);
|
||||||
var str = [];
|
var str = [];
|
||||||
if (hours) {
|
if (hours) {
|
||||||
var h = '0'+hours;
|
str.push(hours);
|
||||||
if (hours < 100) {
|
|
||||||
h.slice(-2);
|
|
||||||
}
|
|
||||||
str.push(h);
|
|
||||||
}
|
}
|
||||||
str.push(('0'+mins).slice(-2));
|
str.push(('0'+mins).slice(-2));
|
||||||
str.push(('0'+secs).slice(-2));
|
str.push(('0'+secs).slice(-2));
|
||||||
|
@ -93,9 +175,11 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
};
|
};
|
||||||
function whileLivePlaying(track) {
|
function whileLivePlaying(track) {
|
||||||
|
|
||||||
var playtime = (new Date()) - options.initTime;
|
//var playtime = (new Date()) - options.initTime;
|
||||||
|
var playtime = ele.currentTime*1e3;
|
||||||
timestampValue.nodeValue = formatTime((playtime + track.lastms)/1e3);
|
timestampValue.nodeValue = formatTime((playtime + track.lastms)/1e3);
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
if (!ele.paused) {
|
if (!ele.paused) {
|
||||||
whileLivePlaying(track);
|
whileLivePlaying(track);
|
||||||
|
@ -113,7 +197,10 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
var zoom = options.width/480;
|
var zoom = options.width/480;
|
||||||
if (zoom < 1) {
|
if (zoom < 1) {
|
||||||
zoom = Math.max(zoom,0.5);
|
zoom = Math.max(zoom,0.5);
|
||||||
controls.style.zoom = zoom;
|
if ('zoom' in controls.style) { controls.style.zoom = zoom; }
|
||||||
|
else {
|
||||||
|
controls.className += ' smaller'; //if css doesn't support zoom, apply smaller class to use smaller controls
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else { zoom = 1; }
|
else { zoom = 1; }
|
||||||
ele.style['min-width'] = zoom*400+'px';
|
ele.style['min-width'] = zoom*400+'px';
|
||||||
|
@ -136,14 +223,20 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
var progressCont = document.createElement('div');
|
var progressCont = document.createElement('div');
|
||||||
controls.appendChild(progressCont);
|
controls.appendChild(progressCont);
|
||||||
progressCont.className = 'progress_container';
|
progressCont.className = 'progress_container';
|
||||||
|
ele.startTime = 0;
|
||||||
if (!options.live) {
|
if (!options.live) {
|
||||||
var progress = document.createElement('div');
|
var progress = document.createElement('div');
|
||||||
progressCont.appendChild(progress);
|
progressCont.appendChild(progress);
|
||||||
progress.className = 'button progress';
|
progress.className = 'button progress';
|
||||||
progress.getPos = function(e){
|
progress.getPos = function(e){
|
||||||
if (!isFinite(ele.duration)) { return 0; }
|
if (!isFinite(ele.duration)) { return 0; }
|
||||||
var style = e.target.currentStyle || window.getComputedStyle(e.target, null);
|
var style = progress.currentStyle || window.getComputedStyle(progress, null);
|
||||||
return Math.max(0,e.clientX - progress.getBoundingClientRect().left - parseInt(style.borderLeftWidth,10)) / progress.offsetWidth * ele.duration;
|
var zoom = Number(!('zoom' in controls.style) || controls.style.zoom == '' ? 1 : controls.style.zoom);
|
||||||
|
|
||||||
|
var pos0 = progress.getBoundingClientRect().left - parseInt(style.borderLeftWidth,10);
|
||||||
|
var perc = (e.clientX - pos0 * zoom) / progress.offsetWidth / zoom;
|
||||||
|
var secs = Math.max(0,perc) * ele.duration;
|
||||||
|
return secs;
|
||||||
}
|
}
|
||||||
progress.onmousemove = function(e) {
|
progress.onmousemove = function(e) {
|
||||||
if (ele.duration) {
|
if (ele.duration) {
|
||||||
|
@ -200,7 +293,13 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
sound.appendChild(volume);
|
sound.appendChild(volume);
|
||||||
sound.getPos = function(ypos){
|
sound.getPos = function(ypos){
|
||||||
var style = this.currentStyle || window.getComputedStyle(this, null);
|
var style = this.currentStyle || window.getComputedStyle(this, null);
|
||||||
return 1 - Math.min(1,Math.max(0,(ypos - sound.getBoundingClientRect().top - parseInt(style.borderTopWidth,10)) / sound.offsetHeight));
|
|
||||||
|
var zoom = Number(!('zoom' in controls.style) || controls.style.zoom == '' ? 1 : controls.style.zoom);
|
||||||
|
|
||||||
|
var pos0 = sound.getBoundingClientRect().top - parseInt(style.borderTopWidth,10);
|
||||||
|
var perc = (ypos - pos0 * zoom) / sound.offsetHeight / zoom;
|
||||||
|
var secs = Math.max(0,perc) * ele.duration;
|
||||||
|
return 1 - Math.min(1,Math.max(0,perc));
|
||||||
}
|
}
|
||||||
volume.className = 'volume';
|
volume.className = 'volume';
|
||||||
sound.title = 'Volume';
|
sound.title = 'Volume';
|
||||||
|
@ -260,14 +359,19 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
buttons.className = 'column';
|
buttons.className = 'column';
|
||||||
controls.appendChild(buttons);
|
controls.appendChild(buttons);
|
||||||
|
|
||||||
if ((this.setTracks) && ((this.tracks.audio.length) || (this.tracks.video.length) || (this.tracks.subtitle.length)) && (this.source.type != 'application/vnd.apple.mpegurl')) {
|
if (
|
||||||
|
(this.setTracks(false))
|
||||||
|
&& (this.tracks.video.length + this.tracks.audio.length + this.tracks.subtitle.length > 1)
|
||||||
|
&& (this.options.source.type != 'html5/video/ogg')
|
||||||
|
) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- the player supports setting tracks;
|
- the player supports setting tracks;
|
||||||
- there is something to choose
|
- there is something to choose
|
||||||
- it's not HLS, which would have to use a different way of switching tracks than this script currently uses
|
- it's not OGG, which doesn't have track selection yet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//prepare the html stuff
|
||||||
var tracks = this.tracks;
|
var tracks = this.tracks;
|
||||||
var tracksc = document.createElement('div');
|
var tracksc = document.createElement('div');
|
||||||
tracksc.innerHTML = 'Tracks';
|
tracksc.innerHTML = 'Tracks';
|
||||||
|
@ -279,7 +383,7 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
settings.className = 'settings';
|
settings.className = 'settings';
|
||||||
|
|
||||||
me.trackselects = {};
|
me.trackselects = {};
|
||||||
for (var i in tracks) {
|
for (var i in tracks) { //for each track type (video, audio, subtitle..)
|
||||||
if (tracks[i].length) {
|
if (tracks[i].length) {
|
||||||
var l = document.createElement('label');
|
var l = document.createElement('label');
|
||||||
settings.appendChild(l);
|
settings.appendChild(l);
|
||||||
|
@ -291,10 +395,12 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
l.appendChild(s);
|
l.appendChild(s);
|
||||||
me.trackselects[i] = s;
|
me.trackselects[i] = s;
|
||||||
s.setAttribute('data-type',i);
|
s.setAttribute('data-type',i);
|
||||||
for (var j in tracks[i]) {
|
for (var j in tracks[i]) { //for each track
|
||||||
var o = document.createElement('option');
|
var o = document.createElement('option');
|
||||||
s.appendChild(o);
|
s.appendChild(o);
|
||||||
o.value = tracks[i][j].trackid;
|
o.value = tracks[i][j].trackid;
|
||||||
|
|
||||||
|
//make up something logical for the track name
|
||||||
var name;
|
var name;
|
||||||
if ('name' in tracks[i][j]) {
|
if ('name' in tracks[i][j]) {
|
||||||
name = tracks[i][j].name;
|
name = tracks[i][j].name;
|
||||||
|
@ -326,8 +432,23 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
for (var i in me.trackselects) {
|
for (var i in me.trackselects) {
|
||||||
usetracks[me.trackselects[i].getAttribute('data-type')] = me.trackselects[i].value
|
usetracks[me.trackselects[i].getAttribute('data-type')] = me.trackselects[i].value
|
||||||
}
|
}
|
||||||
|
if (this.value == 0) {
|
||||||
|
//if we are disabling a video or audio track, dont allow us to disable another video or audio track because there will be no data
|
||||||
|
var optiontags = this.parentNode.parentNode.querySelectorAll('select:not([data-type="subtitle"]) option[value="0"]');
|
||||||
|
for (var i = 0; i < optiontags.length; i++) {
|
||||||
|
optiontags[i].setAttribute('disabled','');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//put back the disabled track options
|
||||||
|
var optiontags = this.parentNode.parentNode.querySelectorAll('option[value="0"][disabled]');
|
||||||
|
for (var i = 0; i < optiontags.length; i++) {
|
||||||
|
optiontags[i].removeAttribute('disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
me.setTracks(usetracks);
|
me.setTracks(usetracks);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (i == 'subtitle') {
|
if (i == 'subtitle') {
|
||||||
s.value = 0;
|
s.value = 0;
|
||||||
|
@ -476,7 +597,112 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
MistPlayer.prototype.askNextCombo = function(msg){
|
||||||
|
var me = this;
|
||||||
|
if (me.errorstate) { return; }
|
||||||
|
me.errorstate = true;
|
||||||
|
me.addlog('Showing error window');
|
||||||
|
|
||||||
|
var err = document.createElement('div');
|
||||||
|
var msgnode = document.createTextNode(msg ? msg : 'Player or stream error detected');
|
||||||
|
err.appendChild(msgnode);
|
||||||
|
err.className = 'error';
|
||||||
|
var button = document.createElement('button');
|
||||||
|
var t = document.createTextNode('Try next source/player');
|
||||||
|
button.appendChild(t);
|
||||||
|
err.appendChild(button);
|
||||||
|
button.onclick = function(){
|
||||||
|
me.nextCombo();
|
||||||
|
}
|
||||||
|
var button = document.createElement('button');
|
||||||
|
var t = document.createTextNode('Reload this player');
|
||||||
|
button.appendChild(t);
|
||||||
|
err.appendChild(button);
|
||||||
|
button.onclick = function(){
|
||||||
|
me.reload();
|
||||||
|
}
|
||||||
|
err.style.position = 'absolute';
|
||||||
|
err.style.top = 0;
|
||||||
|
err.style.width = '100%';
|
||||||
|
err.style['margin-left'] = 0;
|
||||||
|
|
||||||
|
this.target.appendChild(err);
|
||||||
|
this.element.style.opacity = '0.2';
|
||||||
|
};
|
||||||
|
MistPlayer.prototype.cancelAskNextCombo = function(){
|
||||||
|
if (this.errorstate) {
|
||||||
|
this.errorstate = false;
|
||||||
|
this.addlog('Removing error window');
|
||||||
|
this.element.style.opacity = 1;
|
||||||
|
var err = this.target.querySelector('.error');
|
||||||
|
if (err) {
|
||||||
|
this.target.removeChild(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MistPlayer.prototype.reload = function(){
|
||||||
|
this.unload();
|
||||||
|
mistPlay(this.mistplaySettings.streamname,this.mistplaySettings.options);
|
||||||
|
};
|
||||||
|
MistPlayer.prototype.nextCombo = function(){
|
||||||
|
this.unload();
|
||||||
|
var opts = this.mistplaySettings.options;
|
||||||
|
opts.startCombo = this.mistplaySettings.startCombo;
|
||||||
|
mistPlay(this.mistplaySettings.streamname,opts);
|
||||||
|
};
|
||||||
|
///send information back to mistserver
|
||||||
|
///\param msg object containing the information to report
|
||||||
|
MistPlayer.prototype.report = function(msg) {
|
||||||
|
return false; ///\todo Remove this when the backend reporting function has been coded
|
||||||
|
|
||||||
|
|
||||||
|
///send a http post request
|
||||||
|
///\param url (string) url to send to
|
||||||
|
///\param params object containing post parameters
|
||||||
|
function httpPost(url,params) {
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
|
||||||
|
var postdata = [];
|
||||||
|
for (var i in params) {
|
||||||
|
postdata.push(i+'='+params[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
http.open("POST", url, true);
|
||||||
|
http.send(postdata.join('&'));
|
||||||
|
}
|
||||||
|
|
||||||
|
//add some extra information
|
||||||
|
msg.userinfo = {
|
||||||
|
page: location.href,
|
||||||
|
stream: this.streamname,
|
||||||
|
session: mistplayer_session_id
|
||||||
|
};
|
||||||
|
if ('index' in this) { msg.userinfo.playerindex = this.index; }
|
||||||
|
if ('playername' in this) { msg.userinfo.player = this.playername; }
|
||||||
|
if ('options' in this) {
|
||||||
|
if ('source' in this.options) {
|
||||||
|
msg.userinfo.source = {
|
||||||
|
src: this.options.source.url,
|
||||||
|
type: this.options.source.type
|
||||||
|
};
|
||||||
|
}
|
||||||
|
msg.userinfo.resolution = this.options.width+'x'+this.options.height;
|
||||||
|
msg.userinfo.time = Math.round(((new Date) - this.options.initTime)/1e3); //seconds since the info js was loaded
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
httpPost(this.options.host+'/report',{
|
||||||
|
report: JSON.stringify(msg)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) { }
|
||||||
|
}
|
||||||
|
MistPlayer.prototype.unload = function(){
|
||||||
|
if (('pause' in this) && (this.pause)) { this.pause(); }
|
||||||
|
if ('updateSrc' in this) { this.updateSrc(''); }
|
||||||
|
//delete this.element;
|
||||||
|
this.target.innerHTML = '';
|
||||||
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
// SELECT AND ADD A VIDEO PLAYER TO THE TARGET //
|
// SELECT AND ADD A VIDEO PLAYER TO THE TARGET //
|
||||||
|
@ -485,11 +711,13 @@ MistPlayer.prototype.buildMistControls = function(){
|
||||||
function mistPlay(streamName,options) {
|
function mistPlay(streamName,options) {
|
||||||
|
|
||||||
var protoplay = new MistPlayer();
|
var protoplay = new MistPlayer();
|
||||||
|
protoplay.streamname = streamName;
|
||||||
function embedLog(msg) {
|
function embedLog(msg) {
|
||||||
protoplay.sendEvent('log',msg,options.target);
|
protoplay.sendEvent('log',msg,options.target);
|
||||||
}
|
}
|
||||||
function mistError(msg) {
|
function mistError(msg) {
|
||||||
var info = mistvideo[streamName];
|
var info = {};
|
||||||
|
if ((typeof mistvideo != 'undefined') && ('streamName' in mistvideo)) { info = mistvideo[streamName]; }
|
||||||
var displaymsg = msg;
|
var displaymsg = msg;
|
||||||
if ('on_error' in info) { displaymsg = info.on_error; }
|
if ('on_error' in info) { displaymsg = info.on_error; }
|
||||||
|
|
||||||
|
@ -502,6 +730,7 @@ function mistPlay(streamName,options) {
|
||||||
err.appendChild(button);
|
err.appendChild(button);
|
||||||
button.onclick = function(){
|
button.onclick = function(){
|
||||||
options.target.removeChild(err);
|
options.target.removeChild(err);
|
||||||
|
delete options.startCombo;
|
||||||
mistPlay(streamName,options);
|
mistPlay(streamName,options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +749,8 @@ function mistPlay(streamName,options) {
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
controls: true,
|
controls: true,
|
||||||
loop: false,
|
loop: false,
|
||||||
poster: null
|
poster: null,
|
||||||
|
callback: false
|
||||||
};
|
};
|
||||||
for (var i in global) {
|
for (var i in global) {
|
||||||
options[i] = global[i];
|
options[i] = global[i];
|
||||||
|
@ -557,10 +787,16 @@ function mistPlay(streamName,options) {
|
||||||
embedLog('Retrieving stream info from '+info.src);
|
embedLog('Retrieving stream info from '+info.src);
|
||||||
document.head.appendChild(info);
|
document.head.appendChild(info);
|
||||||
info.onerror = function(){
|
info.onerror = function(){
|
||||||
|
options.target.innerHTML = '';
|
||||||
options.target.removeAttribute('data-loading');
|
options.target.removeAttribute('data-loading');
|
||||||
mistError('Error while loading stream info.');
|
mistError('Error while loading stream info.');
|
||||||
|
protoplay.report({
|
||||||
|
type: 'init',
|
||||||
|
error: 'Failed to load '+info.src
|
||||||
|
});
|
||||||
}
|
}
|
||||||
info.onload = function(){
|
info.onload = function(){
|
||||||
|
options.target.innerHTML = '';
|
||||||
options.target.removeAttribute('data-loading');
|
options.target.removeAttribute('data-loading');
|
||||||
embedLog('Stream info was loaded succesfully');
|
embedLog('Stream info was loaded succesfully');
|
||||||
|
|
||||||
|
@ -572,6 +808,15 @@ function mistPlay(streamName,options) {
|
||||||
//embedLog('Stream info contents: '+JSON.stringify(streaminfo));
|
//embedLog('Stream info contents: '+JSON.stringify(streaminfo));
|
||||||
streaminfo.initTime = new Date();
|
streaminfo.initTime = new Date();
|
||||||
|
|
||||||
|
if (!('source' in streaminfo)) {
|
||||||
|
mistError('Error while loading stream info.');
|
||||||
|
protoplay.report({
|
||||||
|
type: 'init',
|
||||||
|
error: 'No sources'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//sort the sources by priority and mime, but prefer HTTPS
|
//sort the sources by priority and mime, but prefer HTTPS
|
||||||
streaminfo.source.sort(function(a,b){
|
streaminfo.source.sort(function(a,b){
|
||||||
return (b.priority - a.priority) || a.type.localeCompare(b.type) || b.url.localeCompare(a.url);
|
return (b.priority - a.priority) || a.type.localeCompare(b.type) || b.url.localeCompare(a.url);
|
||||||
|
@ -596,17 +841,36 @@ function mistPlay(streamName,options) {
|
||||||
forceSupportCheck = true;
|
forceSupportCheck = true;
|
||||||
}
|
}
|
||||||
var forcePlayer = false;
|
var forcePlayer = false;
|
||||||
if (('forcePlayer' in options) && (options.forcePlayer) && (options.forcePlayer in mistplayers)) {
|
if (('forcePlayer' in options) && (options.forcePlayer)) {
|
||||||
|
if (options.forcePlayer in mistplayers) {
|
||||||
embedLog('Forcing '+mistplayers[options.forcePlayer].name);
|
embedLog('Forcing '+mistplayers[options.forcePlayer].name);
|
||||||
forcePlayer = options.forcePlayer;
|
forcePlayer = options.forcePlayer;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
embedLog('The forced player ('+options.forcePlayer+') isn\'t known, ignoring. Possible values are: '+Object.keys(mistplayers).join(', '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var startCombo = false;
|
||||||
|
if ('startCombo' in options) {
|
||||||
|
startCombo = options.startCombo;
|
||||||
|
startCombo.started = {
|
||||||
|
player: false,
|
||||||
|
source: false
|
||||||
|
};
|
||||||
|
embedLog('Selecting a new player/source combo, starting after '+mistplayers[startCombo.player].name+' with '+streaminfo.source[startCombo.source].type+' @ '+streaminfo.source[startCombo.source].url);
|
||||||
|
}
|
||||||
|
|
||||||
embedLog('Checking available players..');
|
embedLog('Checking available players..');
|
||||||
|
|
||||||
var source = false;
|
var source = false;
|
||||||
var mistPlayer = false;
|
|
||||||
|
|
||||||
function checkPlayer(p_shortname) {
|
function checkPlayer(p_shortname) {
|
||||||
|
if ((startCombo) && (!startCombo.started.player)) {
|
||||||
|
if (p_shortname != startCombo.player) { return false; }
|
||||||
|
else {
|
||||||
|
startCombo.started.player = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
embedLog('Checking '+mistplayers[p_shortname].name+' (priority: '+mistplayers[p_shortname].priority+') ..');
|
embedLog('Checking '+mistplayers[p_shortname].name+' (priority: '+mistplayers[p_shortname].priority+') ..');
|
||||||
streaminfo.working[p_shortname] = [];
|
streaminfo.working[p_shortname] = [];
|
||||||
|
@ -633,22 +897,39 @@ function mistPlay(streamName,options) {
|
||||||
else {
|
else {
|
||||||
loop = streaminfo.source;
|
loop = streaminfo.source;
|
||||||
}
|
}
|
||||||
|
var broadcast = false;
|
||||||
for (var s in loop) {
|
for (var s in loop) {
|
||||||
if (loop[s].type == mime) {
|
if (loop[s].type == mime) {
|
||||||
if (mistplayers[p_shortname].isBrowserSupported(mime,loop[s],options)) {
|
broadcast = true;
|
||||||
|
|
||||||
|
if ((startCombo) && (!startCombo.started.source)) {
|
||||||
|
if (s == startCombo.source) {
|
||||||
|
startCombo.started.source = true;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mistplayers[p_shortname].isBrowserSupported(mime,loop[s],options,streaminfo,embedLog)) {
|
||||||
embedLog('Found a working combo: '+mistplayers[p_shortname].name+' with '+mime+' @ '+loop[s].url);
|
embedLog('Found a working combo: '+mistplayers[p_shortname].name+' with '+mime+' @ '+loop[s].url);
|
||||||
streaminfo.working[p_shortname].push(mime);
|
streaminfo.working[p_shortname].push(mime);
|
||||||
if (!source) {
|
if (!source) {
|
||||||
mistPlayer = p_shortname;
|
mistPlayer = p_shortname;
|
||||||
source = loop[s];
|
source = loop[s];
|
||||||
|
source.index = s;
|
||||||
}
|
}
|
||||||
if (!forceSupportCheck) {
|
if (!forceSupportCheck) {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
embedLog('This browser does not support '+mime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
embedLog('Mist doesn\'t broadcast '+mime+' or there is no browser support.');
|
|
||||||
|
}
|
||||||
|
if (!broadcast) {
|
||||||
|
embedLog('Mist doesn\'t broadcast '+mime);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -669,8 +950,8 @@ function mistPlay(streamName,options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options.target.innerHTML = '';
|
|
||||||
if (mistPlayer) {
|
if (mistPlayer) {
|
||||||
|
|
||||||
//create the options to send to the player
|
//create the options to send to the player
|
||||||
var playerOpts = {
|
var playerOpts = {
|
||||||
src: source.url+(('urlappend' in options) && (options.urlappend) ? options.urlappend : '' ),
|
src: source.url+(('urlappend' in options) && (options.urlappend) ? options.urlappend : '' ),
|
||||||
|
@ -732,6 +1013,7 @@ function mistPlay(streamName,options) {
|
||||||
|
|
||||||
//save the objects for future reference
|
//save the objects for future reference
|
||||||
var player = new mistplayers[mistPlayer].player();
|
var player = new mistplayers[mistPlayer].player();
|
||||||
|
player.playername = mistPlayer;
|
||||||
player.target = options.target;
|
player.target = options.target;
|
||||||
if (!('embedded' in streaminfo)) { streaminfo.embedded = []; }
|
if (!('embedded' in streaminfo)) { streaminfo.embedded = []; }
|
||||||
streaminfo.embedded.push({
|
streaminfo.embedded.push({
|
||||||
|
@ -740,10 +1022,10 @@ function mistPlay(streamName,options) {
|
||||||
player: player,
|
player: player,
|
||||||
playerOptions: playerOpts
|
playerOptions: playerOpts
|
||||||
});
|
});
|
||||||
|
player.index = streaminfo.embedded.length-1;
|
||||||
|
|
||||||
if (player.setTracks) {
|
if (player.setTracks(false)) {
|
||||||
//gather track info
|
//gather track info
|
||||||
//tracks
|
|
||||||
var tracks = {
|
var tracks = {
|
||||||
video: [],
|
video: [],
|
||||||
audio: [],
|
audio: [],
|
||||||
|
@ -797,17 +1079,150 @@ function mistPlay(streamName,options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//build the player
|
//build the player
|
||||||
|
player.mistplaySettings = {
|
||||||
|
streamname: streamName,
|
||||||
|
options: local,
|
||||||
|
startCombo: {
|
||||||
|
player: mistPlayer,
|
||||||
|
source: source.index
|
||||||
|
}
|
||||||
|
};
|
||||||
player.options = playerOpts;
|
player.options = playerOpts;
|
||||||
|
try {
|
||||||
var element = player.build(playerOpts);
|
var element = player.build(playerOpts);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
//show the next player/reload buttons if there is an error in the player build code
|
||||||
|
options.target.appendChild(player.element);
|
||||||
|
player.askNextCombo('Error while building player');
|
||||||
|
throw e;
|
||||||
|
player.report({
|
||||||
|
type: 'init',
|
||||||
|
error: 'Error while building player'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
options.target.appendChild(element);
|
options.target.appendChild(element);
|
||||||
element.setAttribute('data-player',mistPlayer);
|
element.setAttribute('data-player',mistPlayer);
|
||||||
element.setAttribute('data-mime',source.type);
|
element.setAttribute('data-mime',source.type);
|
||||||
|
player.report({
|
||||||
|
type: 'init',
|
||||||
|
info: 'Player built'
|
||||||
|
});
|
||||||
|
|
||||||
if (player.setTracks) {
|
if (player.setTracks(false)) {
|
||||||
player.setTracks(usetracks);
|
player.onready(function(){
|
||||||
if ('setTracks' in options) { player.setTracks(options.setTracks); }
|
if ('setTracks' in options) { player.setTracks(options.setTracks); }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//monitor for errors
|
||||||
|
element.checkStalledTimeout = false;
|
||||||
|
element.checkProgressTimeout = false;
|
||||||
|
element.sendPingTimeout = setInterval(function(){
|
||||||
|
if (player.paused) { return; }
|
||||||
|
player.report({
|
||||||
|
type: 'playback',
|
||||||
|
info: 'ping'
|
||||||
|
});
|
||||||
|
},150e3);
|
||||||
|
element.addEventListener('error',function(e){
|
||||||
|
player.askNextCombo('The player has thrown an error');
|
||||||
|
var r = {
|
||||||
|
type: 'playback',
|
||||||
|
error: 'The player has thrown an error',
|
||||||
|
origin: e.target.outerHTML.slice(0,e.target.outerHTML.indexOf('>')+1),
|
||||||
|
};
|
||||||
|
if ('readyState' in player.element) {
|
||||||
|
r.readyState = player.element.readyState;
|
||||||
|
}
|
||||||
|
if ('networkState' in player.element) {
|
||||||
|
r.networkState = player.element.networkState;
|
||||||
|
}
|
||||||
|
if (('error' in player.element) && ('code' in player.element.error)) {
|
||||||
|
r.code = player.element.error.code;
|
||||||
|
}
|
||||||
|
player.report(r);
|
||||||
|
});
|
||||||
|
var stalled = function(e){
|
||||||
|
if (element.checkStalledTimeout) { return; }
|
||||||
|
element.checkStalledTimeout = setTimeout(function(){
|
||||||
|
if (player.paused) { return; }
|
||||||
|
player.askNextCombo('Playback has stalled');
|
||||||
|
player.report({
|
||||||
|
'type': 'playback',
|
||||||
|
'warn': 'Playback was stalled for > 10 sec'
|
||||||
|
});
|
||||||
|
},10e3);
|
||||||
|
};
|
||||||
|
element.addEventListener('stalled',stalled,true);
|
||||||
|
element.addEventListener('waiting',stalled,true);
|
||||||
|
var progress = function(e){
|
||||||
|
if (element.checkStalledTimeout) {
|
||||||
|
clearTimeout(element.checkStalledTimeout);
|
||||||
|
element.checkStalledTimeout = false;
|
||||||
|
player.cancelAskNextCombo();
|
||||||
|
}
|
||||||
|
if (element.checkStalledTimeout) {
|
||||||
|
clearTimeout(element.checkStalledTimeout);
|
||||||
|
element.checkStalledTimeout = false;
|
||||||
|
player.cancelAskNextCombo();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
element.addEventListener('progress',progress,true);
|
||||||
|
element.addEventListener('playing',progress,true);
|
||||||
|
element.addEventListener('play',function(){
|
||||||
|
player.paused = false;
|
||||||
|
if ((!element.checkProgressTimeout) && (player.element) && ('currentTime' in player.element)) {
|
||||||
|
//check if the progress made is equal to the time spent
|
||||||
|
var lasttime = player.element.currentTime;
|
||||||
|
element.checkProgressTimeout = setInterval(function(){
|
||||||
|
var newtime = player.element.currentTime;
|
||||||
|
if (newtime == 0) { return; }
|
||||||
|
var progress = newtime - lasttime;
|
||||||
|
lasttime = newtime;
|
||||||
|
if (progress == 0) {
|
||||||
|
var msg = 'There should be playback but nothing was played';
|
||||||
|
var r = {
|
||||||
|
type: 'playback',
|
||||||
|
warn: msg
|
||||||
|
};
|
||||||
|
player.addlog(msg);
|
||||||
|
if ('readyState' in player.element) {
|
||||||
|
r.readyState = player.element.readyState;
|
||||||
|
}
|
||||||
|
if ('networkState' in player.element) {
|
||||||
|
r.networkState = player.element.networkState;
|
||||||
|
}
|
||||||
|
if (('error' in player.element) && (player.element.error) && ('code' in player.element.error)) {
|
||||||
|
r.code = player.element.error.code;
|
||||||
|
}
|
||||||
|
player.report(r);
|
||||||
|
player.askNextCombo('No playback');
|
||||||
|
if ('load' in player.element) { player.element.load(); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.cancelAskNextCombo();
|
||||||
|
if (progress < 5) {
|
||||||
|
var msg = 'It seems playback is lagging (progressed '+Math.round(progress*100)/100+'/10s)'
|
||||||
|
player.addlog(msg);
|
||||||
|
player.report({
|
||||||
|
type: 'playback',
|
||||||
|
warn: msg
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},10e3);
|
||||||
|
}
|
||||||
|
},true);
|
||||||
|
element.addEventListener('pause',function(){
|
||||||
|
player.paused = true;
|
||||||
|
if (element.checkProgressTimeout) {
|
||||||
|
clearInterval(element.checkProgressTimeout);
|
||||||
|
element.checkProgressTimeout = false;
|
||||||
|
}
|
||||||
|
},true);
|
||||||
|
|
||||||
if (player.resize) {
|
if (player.resize) {
|
||||||
//monitor for resizes and fire if needed
|
//monitor for resizes and fire if needed
|
||||||
window.addEventListener('resize',function(){
|
window.addEventListener('resize',function(){
|
||||||
|
@ -815,8 +1230,12 @@ function mistPlay(streamName,options) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protoplay.sendEvent('initialized','',options.target);
|
for (var i in player.onreadylist) {
|
||||||
|
player.onreadylist[i]();
|
||||||
|
}
|
||||||
|
|
||||||
|
protoplay.sendEvent('initialized','',options.target);
|
||||||
|
if (options.callback) { options.callback(player); }
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (streaminfo.error) {
|
if (streaminfo.error) {
|
||||||
|
@ -830,6 +1249,10 @@ function mistPlay(streamName,options) {
|
||||||
else {
|
else {
|
||||||
var str = 'Stream not found.';
|
var str = 'Stream not found.';
|
||||||
}
|
}
|
||||||
|
protoplay.report({
|
||||||
|
type: 'init',
|
||||||
|
error: str
|
||||||
|
});
|
||||||
mistError(str);
|
mistError(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,15 +25,15 @@
|
||||||
inkscape:pageopacity="0"
|
inkscape:pageopacity="0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="19.289873"
|
inkscape:zoom="19.289873"
|
||||||
inkscape:cx="7.9448655"
|
inkscape:cx="-2.0603844"
|
||||||
inkscape:cy="14.079113"
|
inkscape:cy="14.079113"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
showgrid="false"
|
showgrid="false"
|
||||||
inkscape:window-width="1181"
|
inkscape:window-width="1918"
|
||||||
inkscape:window-height="865"
|
inkscape:window-height="1040"
|
||||||
inkscape:window-x="64"
|
inkscape:window-x="0"
|
||||||
inkscape:window-y="102"
|
inkscape:window-y="19"
|
||||||
inkscape:window-maximized="0">
|
inkscape:window-maximized="0">
|
||||||
<sodipodi:guide
|
<sodipodi:guide
|
||||||
position="0,0"
|
position="0,0"
|
||||||
|
@ -70,13 +70,13 @@
|
||||||
id="layer1"
|
id="layer1"
|
||||||
transform="translate(0,-1027.3622)">
|
transform="translate(0,-1027.3622)">
|
||||||
<path
|
<path
|
||||||
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||||
d="M 0 0 L 0 25 L 25 25 L 25 0 L 0 0 z M 17.789062 0.74609375 C 18.295139 0.76779043 18.796936 0.91543438 19.25 1.1855469 L 19.25 23.8125 C 18.041512 24.5346 16.481832 24.377494 15.445312 23.308594 L 10.341797 18.046875 L 8.0878906 18.046875 C 6.7997976 18.046875 5.75 16.963266 5.75 15.634766 L 5.75 9.3632812 C 5.75 8.0348812 6.7997976 6.9511719 8.0878906 6.9511719 L 10.341797 6.9511719 L 15.445312 1.6894531 C 16.092759 1.0217031 16.945602 0.70993262 17.789062 0.74609375 z "
|
d="M 0 0 L 0 25 L 25 25 L 25 0 L 0 0 z M 16.955078 2.5175781 C 17.381507 2.5360023 17.80574 2.6612 18.1875 2.890625 L 18.1875 22.109375 C 17.169206 22.722675 15.85386 22.587487 14.980469 21.679688 L 10.681641 17.210938 L 8.7832031 17.210938 C 7.6978331 17.210938 6.8125 16.290409 6.8125 15.162109 L 6.8125 9.8359375 C 6.8125 8.7077375 7.6978331 7.7890625 8.7832031 7.7890625 L 10.681641 7.7890625 L 14.980469 3.3183594 C 15.526019 2.7512344 16.244363 2.4868711 16.955078 2.5175781 z "
|
||||||
transform="translate(0,1027.3622)"
|
transform="translate(0,1027.3622)"
|
||||||
id="rect4159" />
|
id="rect4139" />
|
||||||
<path
|
<path
|
||||||
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
d="m 19.25,1028.5473 c -1.20817,-0.7203 -2.769599,-0.564 -3.805513,0.5044 l -5.102362,5.2622 -2.2535418,0 c -1.288093,0 -2.3385832,1.0834 -2.3385832,2.4118 l 0,6.2709 c 0,1.3285 1.0504902,2.4119 2.3385832,2.4119 l 2.2535418,0 5.102362,5.2623 c 1.03652,1.0689 2.597025,1.2263 3.805513,0.5042 l 0,-22.6277 z"
|
d="m 18.187674,1030.2531 c -1.018026,-0.6118 -2.333715,-0.479 -3.206595,0.4284 l -4.299344,4.4691 -1.8988757,0 c -1.0853708,0 -1.9705331,0.9201 -1.9705331,2.0483 l 0,5.3258 c 0,1.1283 0.8851623,2.0484 1.9705331,2.0484 l 1.8988757,0 4.299344,4.4693 c 0.873391,0.9078 2.188301,1.0415 3.206595,0.4282 l 0,-19.2175 z"
|
||||||
id="rect4574"
|
id="rect4574"
|
||||||
inkscape:connector-curvature="0" />
|
inkscape:connector-curvature="0" />
|
||||||
</g>
|
</g>
|
||||||
|
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.6 KiB |
|
@ -1 +1 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg4659" height="25" width="25"><defs id="defs4661" /><metadata id="metadata4664"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><g transform="translate(0,-1027.3622)" id="layer1"><path id="rect4159" transform="translate(0,1027.3622)" d="M 0 0 L 0 25 L 25 25 L 25 0 L 0 0 z M 17.789062 0.74609375 C 18.295139 0.76779043 18.796936 0.91543438 19.25 1.1855469 L 19.25 23.8125 C 18.041512 24.5346 16.481832 24.377494 15.445312 23.308594 L 10.341797 18.046875 L 8.0878906 18.046875 C 6.7997976 18.046875 5.75 16.963266 5.75 15.634766 L 5.75 9.3632812 C 5.75 8.0348812 6.7997976 6.9511719 8.0878906 6.9511719 L 10.341797 6.9511719 L 15.445312 1.6894531 C 16.092759 1.0217031 16.945602 0.70993262 17.789062 0.74609375 z " style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /><path id="rect4574" d="m 19.25,1028.5473 c -1.20817,-0.7203 -2.769599,-0.564 -3.805513,0.5044 l -5.102362,5.2622 -2.2535418,0 c -1.288093,0 -2.3385832,1.0834 -2.3385832,2.4118 l 0,6.2709 c 0,1.3285 1.0504902,2.4119 2.3385832,2.4119 l 2.2535418,0 5.102362,5.2623 c 1.03652,1.0689 2.597025,1.2263 3.805513,0.5042 l 0,-22.6277 z" style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /></g></svg>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg4659" height="25" width="25"> <defs id="defs4661" /> <metadata id="metadata4664"> <rdf:RDF> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> <dc:title></dc:title> </cc:Work> </rdf:RDF> </metadata> <g transform="translate(0,-1027.3622)" id="layer1"> <path id="rect4139" transform="translate(0,1027.3622)" d="M 0 0 L 0 25 L 25 25 L 25 0 L 0 0 z M 16.955078 2.5175781 C 17.381507 2.5360023 17.80574 2.6612 18.1875 2.890625 L 18.1875 22.109375 C 17.169206 22.722675 15.85386 22.587487 14.980469 21.679688 L 10.681641 17.210938 L 8.7832031 17.210938 C 7.6978331 17.210938 6.8125 16.290409 6.8125 15.162109 L 6.8125 9.8359375 C 6.8125 8.7077375 7.6978331 7.7890625 8.7832031 7.7890625 L 10.681641 7.7890625 L 14.980469 3.3183594 C 15.526019 2.7512344 16.244363 2.4868711 16.955078 2.5175781 z " style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <path id="rect4574" d="m 18.187674,1030.2531 c -1.018026,-0.6118 -2.333715,-0.479 -3.206595,0.4284 l -4.299344,4.4691 -1.8988757,0 c -1.0853708,0 -1.9705331,0.9201 -1.9705331,2.0483 l 0,5.3258 c 0,1.1283 0.8851623,2.0484 1.9705331,2.0484 l 1.8988757,0 4.299344,4.4693 c 0.873391,0.9078 2.188301,1.0415 3.206595,0.4282 l 0,-19.2175 z" style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> </g></svg>
|
||||||
|
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.1 KiB |
1343
embed/mist.css
1343
embed/mist.css
File diff suppressed because one or more lines are too long
38369
embed/players/old_videojs.js
Normal file
38369
embed/players/old_videojs.js
Normal file
File diff suppressed because one or more lines are too long
24
embed/players/video.min.js
vendored
Normal file
24
embed/players/video.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
embed/players/videojs-contrib-hls.min.js
vendored
Normal file
6
embed/players/videojs-contrib-hls.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
29
embed/players/videojs.js
Normal file
29
embed/players/videojs.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,10 @@
|
||||||
// global options can be set here
|
// global options can be set here
|
||||||
var mistoptions = {
|
var mistoptions = {
|
||||||
host: 'http://cat.mistserver.org:8080'
|
host: 'http://cat.mistserver.org:8080'
|
||||||
|
//host: 'http://thulmk3:8080'
|
||||||
//host: 'https://cat.mistserver.org:4433'
|
//host: 'https://cat.mistserver.org:4433'
|
||||||
|
//host: 'http://localhost:8080'
|
||||||
|
//host: 'http://live.us.picarto.tv:8080'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -24,12 +27,14 @@
|
||||||
<!--<script src=wrappers/theoplayer.js></script>-->
|
<!--<script src=wrappers/theoplayer.js></script>-->
|
||||||
<!--<script src=wrappers/jwplayer.js></script>-->
|
<!--<script src=wrappers/jwplayer.js></script>-->
|
||||||
<script src=wrappers/html5.js></script>
|
<script src=wrappers/html5.js></script>
|
||||||
|
<script src=wrappers/videojs.js></script>
|
||||||
<script src=wrappers/dashjs.js></script>
|
<script src=wrappers/dashjs.js></script>
|
||||||
<script src=wrappers/flash_strobe.js></script>
|
<script src=wrappers/flash_strobe.js></script>
|
||||||
<script src=wrappers/silverlight.js></script>
|
<script src=wrappers/silverlight.js></script>
|
||||||
<script src=wrappers/polytrope.js></script>
|
<script src=wrappers/polytrope.js></script>
|
||||||
|
|
||||||
<script src=players/dash.js></script>
|
<script src=players/dash.js></script>
|
||||||
|
<script src=players/videojs.js></script>
|
||||||
|
|
||||||
<link rel=stylesheet href=mist.css id=mist_player_css>
|
<link rel=stylesheet href=mist.css id=mist_player_css>
|
||||||
<style>
|
<style>
|
||||||
|
@ -53,42 +58,73 @@
|
||||||
|
|
||||||
|
|
||||||
function mistinit(){
|
function mistinit(){
|
||||||
|
var logele = document.querySelector('.log');
|
||||||
|
var contele = document.querySelector('.cont');
|
||||||
document.addEventListener('error',function(e){
|
document.addEventListener('error',function(e){
|
||||||
console.log('[Error] '+e.message,e.target);
|
console.log('[Error] '+e.message,e.target);
|
||||||
},true);
|
var msg = document.createTextNode('['+(new Date()).toTimeString().split(' ')[0]+'] '+e.message+' from '+e.target.outerHTML.slice(0,e.target.outerHTML.indexOf('>')+1));
|
||||||
|
var div = document.createElement('div');
|
||||||
|
div.appendChild(msg);
|
||||||
|
div.style.color = 'red';
|
||||||
|
logele.appendChild(div);
|
||||||
|
});
|
||||||
document.addEventListener('log',function(e){
|
document.addEventListener('log',function(e){
|
||||||
console.log('[log] '+e.message)
|
console.log('[log] '+e.message);
|
||||||
|
return;
|
||||||
var msg = document.createTextNode('['+(new Date()).toTimeString().split(' ')[0]+'] '+e.message);
|
var msg = document.createTextNode('['+(new Date()).toTimeString().split(' ')[0]+'] '+e.message);
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.appendChild(msg);
|
div.appendChild(msg);
|
||||||
document.body.appendChild(div);
|
logele.appendChild(div);
|
||||||
},true);
|
});
|
||||||
|
|
||||||
//tryplayers = Object.keys(mistplayers);
|
//tryplayers = Object.keys(mistplayers);
|
||||||
tryplayers = [];
|
tryplayers = [];
|
||||||
|
tryplayers.push('automatic');
|
||||||
//tryplayers.push('html5');
|
//tryplayers.push('html5');
|
||||||
tryplayers.push('dashjs');
|
//tryplayers.push('dashjs');
|
||||||
|
//tryplayers.push('videojs');
|
||||||
//tryplayers.push('flash_strobe');
|
//tryplayers.push('flash_strobe');
|
||||||
//tryplayers.push('silverlight');
|
//tryplayers.push('silverlight');
|
||||||
streams = [];
|
streams = [];
|
||||||
//streams.push('live');
|
streams.push('live');
|
||||||
|
//streams.push('golive+emitan');
|
||||||
|
//streams.push('subtel');
|
||||||
|
//streams.push('ogg');
|
||||||
//streams.push('vids+mist.mp4');
|
//streams.push('vids+mist.mp4');
|
||||||
|
//streams.push('vids+hahalol.mp3');
|
||||||
//streams.push('lama');
|
//streams.push('lama');
|
||||||
streams.push('bunny');
|
//streams.push('bunny');
|
||||||
|
|
||||||
for (var j in streams) {
|
for (var j in streams) {
|
||||||
for (var i in tryplayers) {
|
for (var i in tryplayers) {
|
||||||
|
var d = document.createElement('div');
|
||||||
var c = document.createElement('div');
|
var c = document.createElement('div');
|
||||||
c.className = 'mistvideo';
|
c.className = 'mistvideo';
|
||||||
c.title = tryplayers[i];
|
c.title = tryplayers[i];
|
||||||
document.body.appendChild(c);
|
d.appendChild(c);
|
||||||
mistPlay(streams[j],{
|
contele.appendChild(d);
|
||||||
|
var p = mistPlay(streams[j],{
|
||||||
target: c,
|
target: c,
|
||||||
|
maxwidth: 800,
|
||||||
forcePlayer: tryplayers[i],
|
forcePlayer: tryplayers[i],
|
||||||
//forceType: 'flash/7',
|
//forceType: 'html5/video/mp4',
|
||||||
//forceSource: 5,
|
//forceType: 'html5/audio/mp3',
|
||||||
loop: true
|
//forceType: 'html5/application/vnd.apple.mpegurl',
|
||||||
|
//forceType: 'dash/video/mp4',
|
||||||
|
//forceSource: 3,
|
||||||
|
loop: true,
|
||||||
|
//controls: 'stock'
|
||||||
|
callback: function(player) {
|
||||||
|
var button = document.createElement('button');
|
||||||
|
button.innerHTML = 'askNextCombo();';
|
||||||
|
button.onclick = function(){
|
||||||
|
player.askNextCombo('Button was clicked');
|
||||||
|
d.removeChild(this);
|
||||||
|
};
|
||||||
|
d.append(button);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +190,7 @@
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</div>-->
|
</div>-->
|
||||||
|
<div class=cont></div>
|
||||||
|
<div class=log></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -18,7 +18,7 @@ p.prototype.build = function (options,callback) {
|
||||||
cont.className = 'mistplayer';
|
cont.className = 'mistplayer';
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
var ele = this.element('video');
|
var ele = this.getElement('video');
|
||||||
ele.className = '';
|
ele.className = '';
|
||||||
cont.appendChild(ele);
|
cont.appendChild(ele);
|
||||||
ele.width = options.width;
|
ele.width = options.width;
|
||||||
|
@ -43,20 +43,46 @@ p.prototype.build = function (options,callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ele.addEventListener('error',function(e){
|
ele.addEventListener('error',function(e){
|
||||||
var n = {
|
var msg;
|
||||||
0: 'NETWORK_EMPTY',
|
if ('message' in e) {
|
||||||
1: 'NETWORK_IDLE',
|
msg = e.message;
|
||||||
2: 'NETWORK_LOADING',
|
|
||||||
3: 'NETWORK_NO_SOURCE'
|
|
||||||
}
|
}
|
||||||
var r = {
|
else {
|
||||||
0: 'HAVE_NOTHING',
|
msg = 'readyState: ';
|
||||||
1: 'HAVE_METADATA',
|
switch (me.element.readyState) {
|
||||||
2: 'HAVE_CURRENT_DATA',
|
case 0:
|
||||||
3: 'HAVE_FUTURE_DATA',
|
msg += 'HAVE_NOTHING';
|
||||||
4: 'HAVE_ENOUGH_DATA'
|
break;
|
||||||
};
|
case 1:
|
||||||
me.adderror("Player event fired: error\nnetworkState: "+n[this.networkState]+"\nreadyState: "+r[this.readyState]);
|
msg += 'HAVE_METADATA';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
msg += 'HAVE_CURRENT_DATA';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
msg += 'HAVE_FUTURE_DATA';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
msg += 'HAVE_ENOUGH_DATA';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
msg += ' networkState: ';
|
||||||
|
switch (me.element.networkState) {
|
||||||
|
case 0:
|
||||||
|
msg += 'NETWORK_EMPTY';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
msg += 'NETWORK_IDLE';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
msg += 'NETWORK_LOADING';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
msg += 'NETWORK_NO_SOURCE';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
me.adderror(msg);
|
||||||
},true);
|
},true);
|
||||||
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting'];
|
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting'];
|
||||||
for (var i in events) {
|
for (var i in events) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ p.prototype.build = function (options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var ele = this.element('object');
|
var ele = this.getElement('object');
|
||||||
|
|
||||||
ele.setAttribute('width',options.width);
|
ele.setAttribute('width',options.width);
|
||||||
ele.setAttribute('height',options.height);
|
ele.setAttribute('height',options.height);
|
||||||
|
|
|
@ -5,11 +5,18 @@ mistplayers.html5 = {
|
||||||
isMimeSupported: function (mimetype) {
|
isMimeSupported: function (mimetype) {
|
||||||
return (this.mimes.indexOf(mimetype) == -1 ? false : true);
|
return (this.mimes.indexOf(mimetype) == -1 ? false : true);
|
||||||
},
|
},
|
||||||
isBrowserSupported: function (mimetype) {
|
isBrowserSupported: function (mimetype,source,options,streaminfo) {
|
||||||
if ((['iPad','iPhone','iPod','MacIntel'].indexOf(navigator.platform) != -1) && (mimetype == 'html5/video/mp4')) { return false; }
|
if ((['iPad','iPhone','iPod','MacIntel'].indexOf(navigator.platform) != -1) && (mimetype == 'html5/video/mp4')) { return false; }
|
||||||
|
|
||||||
var support = false;
|
var support = false;
|
||||||
var shortmime = mimetype.split('/');
|
var shortmime = mimetype.split('/');
|
||||||
shortmime.shift();
|
shortmime.shift();
|
||||||
|
|
||||||
|
if ((shortmime[0] == 'audio') && (streaminfo.height) && (!options.forceType) && (!options.forceSource)) {
|
||||||
|
//claim you don't support audio-only playback if there is video data, unless this mime is being forced
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var v = document.createElement((shortmime[0] == 'audio' ? 'audio' : 'video'));
|
var v = document.createElement((shortmime[0] == 'audio' ? 'audio' : 'video'));
|
||||||
shortmime = shortmime.join('/')
|
shortmime = shortmime.join('/')
|
||||||
|
@ -24,7 +31,7 @@ mistplayers.html5 = {
|
||||||
};
|
};
|
||||||
var p = mistplayers.html5.player;
|
var p = mistplayers.html5.player;
|
||||||
p.prototype = new MistPlayer();
|
p.prototype = new MistPlayer();
|
||||||
p.prototype.build = function (options,callback) {
|
p.prototype.build = function (options) {
|
||||||
var cont = document.createElement('div');
|
var cont = document.createElement('div');
|
||||||
cont.className = 'mistplayer';
|
cont.className = 'mistplayer';
|
||||||
var me = this; //to allow nested functions to access the player class itself
|
var me = this; //to allow nested functions to access the player class itself
|
||||||
|
@ -32,12 +39,12 @@ p.prototype.build = function (options,callback) {
|
||||||
var shortmime = options.source.type.split('/');
|
var shortmime = options.source.type.split('/');
|
||||||
shortmime.shift();
|
shortmime.shift();
|
||||||
|
|
||||||
var ele = this.element((shortmime[0] == 'audio' ? 'audio' : 'video'));
|
var ele = this.getElement((shortmime[0] == 'audio' ? 'audio' : 'video'));
|
||||||
ele.className = '';
|
ele.className = '';
|
||||||
cont.appendChild(ele);
|
cont.appendChild(ele);
|
||||||
ele.crossOrigin = 'anonymous';
|
ele.crossOrigin = 'anonymous'; //required for subtitles
|
||||||
if (shortmime[0] == 'audio') {
|
if (shortmime[0] == 'audio') {
|
||||||
this.setTracks = false;
|
this.setTracks = function() { return false; }
|
||||||
this.fullscreen = false;
|
this.fullscreen = false;
|
||||||
cont.className += ' audio';
|
cont.className += ' audio';
|
||||||
}
|
}
|
||||||
|
@ -66,7 +73,6 @@ p.prototype.build = function (options,callback) {
|
||||||
ele.height = options.height;
|
ele.height = options.height;
|
||||||
ele.style.width = options.width+'px';
|
ele.style.width = options.width+'px';
|
||||||
ele.style.height = options.height+'px';
|
ele.style.height = options.height+'px';
|
||||||
ele.startTime = 0;
|
|
||||||
|
|
||||||
if (options.autoplay) {
|
if (options.autoplay) {
|
||||||
ele.setAttribute('autoplay','');
|
ele.setAttribute('autoplay','');
|
||||||
|
@ -92,52 +98,17 @@ p.prototype.build = function (options,callback) {
|
||||||
if (options.live) {
|
if (options.live) {
|
||||||
ele.addEventListener('error',function(e){
|
ele.addEventListener('error',function(e){
|
||||||
if ((ele.error) && (ele.error.code == 3)) {
|
if ((ele.error) && (ele.error.code == 3)) {
|
||||||
|
e.stopPropagation();
|
||||||
ele.load();
|
ele.load();
|
||||||
|
me.cancelAskNextCombo();
|
||||||
|
e.message = 'Handled decoding error';
|
||||||
me.addlog('Decoding error: reloading..');
|
me.addlog('Decoding error: reloading..');
|
||||||
|
me.report({
|
||||||
|
type: 'playback',
|
||||||
|
warn: 'A decoding error was encountered, but handled'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},true);
|
},true);
|
||||||
|
|
||||||
var errorstate = false;
|
|
||||||
function dced(e) {
|
|
||||||
if (errorstate) { return; }
|
|
||||||
|
|
||||||
errorstate = true;
|
|
||||||
me.adderror('Connection lost..');
|
|
||||||
|
|
||||||
var err = document.createElement('div');
|
|
||||||
var msgnode = document.createTextNode('Connection lost..');
|
|
||||||
err.appendChild(msgnode);
|
|
||||||
err.className = 'error';
|
|
||||||
var button = document.createElement('button');
|
|
||||||
var t = document.createTextNode('Reload');
|
|
||||||
button.appendChild(t);
|
|
||||||
err.appendChild(button);
|
|
||||||
button.onclick = function(){
|
|
||||||
errorstate = false;
|
|
||||||
ele.parentNode.removeChild(err);
|
|
||||||
ele.load();
|
|
||||||
ele.style.opacity = '';
|
|
||||||
}
|
|
||||||
err.style.position = 'absolute';
|
|
||||||
err.style.top = 0;
|
|
||||||
err.style.width = '100%';
|
|
||||||
err.style['margin-left'] = 0;
|
|
||||||
|
|
||||||
ele.parentNode.appendChild(err);
|
|
||||||
ele.style.opacity = '0.2';
|
|
||||||
|
|
||||||
function nolongerdced(){
|
|
||||||
ele.removeEventListener('progress',nolongerdced);
|
|
||||||
errorstate = false;
|
|
||||||
ele.parentNode.removeChild(err);
|
|
||||||
ele.style.opacity = '';
|
|
||||||
}
|
|
||||||
ele.addEventListener('progress',nolongerdced);
|
|
||||||
}
|
|
||||||
|
|
||||||
ele.addEventListener('stalled',dced,true);
|
|
||||||
ele.addEventListener('ended',dced,true);
|
|
||||||
ele.addEventListener('pause',dced,true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addlog('Built html');
|
this.addlog('Built html');
|
||||||
|
@ -185,7 +156,7 @@ p.prototype.build = function (options,callback) {
|
||||||
}
|
}
|
||||||
me.adderror(msg);
|
me.adderror(msg);
|
||||||
},true);
|
},true);
|
||||||
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting'];
|
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting','progress'];
|
||||||
for (var i in events) {
|
for (var i in events) {
|
||||||
ele.addEventListener(events[i],function(e){
|
ele.addEventListener(events[i],function(e){
|
||||||
me.addlog('Player event fired: '+e.type);
|
me.addlog('Player event fired: '+e.type);
|
||||||
|
@ -220,60 +191,10 @@ if (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.m
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
p.prototype.setTracks = function(usetracks){
|
p.prototype.updateSrc = function(src){
|
||||||
function urlAddParam(url,params) {
|
this.source.setAttribute('src',src);
|
||||||
var spliturl = url.split('?');
|
|
||||||
var ret = [spliturl.shift()];
|
|
||||||
var splitparams = [];
|
|
||||||
if (spliturl.length) {
|
|
||||||
splitparams = spliturl[0].split('&');
|
|
||||||
}
|
|
||||||
for (var i in params) {
|
|
||||||
splitparams.push(i+'='+params[i]);
|
|
||||||
}
|
|
||||||
if (splitparams.length) { ret.push(splitparams.join('&')); }
|
|
||||||
return ret.join('?');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('subtitle' in usetracks) {
|
|
||||||
//remove previous subtitles
|
|
||||||
var ts = this.element.getElementsByTagName('track');
|
|
||||||
for (var i = ts.length - 1; i >= 0; i--) {
|
|
||||||
this.element.removeChild(ts[i]);
|
|
||||||
}
|
|
||||||
var tracks = this.tracks.subtitle;
|
|
||||||
for (var i in tracks) {
|
|
||||||
if (tracks[i].trackid == usetracks.subtitle) {
|
|
||||||
var t = document.createElement('track');
|
|
||||||
this.element.appendChild(t);
|
|
||||||
t.kind = 'subtitles';
|
|
||||||
t.label = tracks[i].desc;
|
|
||||||
t.srclang = tracks[i].lang;
|
|
||||||
t.src = this.subtitle+'?track='+tracks[i].trackid;
|
|
||||||
t.setAttribute('default','');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete usetracks.subtitle;
|
|
||||||
if (Object.keys(usetracks).length == 0) { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
var time = this.element.currentTime;
|
|
||||||
this.source.setAttribute('src',urlAddParam(this.options.src,usetracks));
|
|
||||||
if (this.element.readyState) {
|
|
||||||
this.element.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.element.currentTime = time;
|
|
||||||
|
|
||||||
if ('trackselects' in this) {
|
|
||||||
for (var i in usetracks) {
|
|
||||||
if (i in this.trackselects) { this.trackselects[i].value = usetracks[i]; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
p.prototype.resize = function(size){
|
p.prototype.resize = function(size){
|
||||||
this.element.width = size.width;
|
this.element.width = size.width;
|
||||||
this.element.height = size.height;
|
this.element.height = size.height;
|
||||||
|
|
|
@ -17,7 +17,7 @@ mistplayers.jwplayer = {
|
||||||
var p = mistplayers.jwplayer.player;
|
var p = mistplayers.jwplayer.player;
|
||||||
p.prototype = new MistPlayer();
|
p.prototype = new MistPlayer();
|
||||||
p.prototype.build = function (options) {
|
p.prototype.build = function (options) {
|
||||||
var ele = this.element('div');
|
var ele = this.getElement('div');
|
||||||
|
|
||||||
this.jw = jwplayer(ele).setup({
|
this.jw = jwplayer(ele).setup({
|
||||||
file: options.src,
|
file: options.src,
|
||||||
|
|
|
@ -32,7 +32,7 @@ p.prototype.build = function (options) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ele = this.element('object');
|
var ele = this.getElement('object');
|
||||||
ele.setAttribute('data','data:application/x-silverlight,');
|
ele.setAttribute('data','data:application/x-silverlight,');
|
||||||
ele.setAttribute('type','application/x-silverlight');
|
ele.setAttribute('type','application/x-silverlight');
|
||||||
ele.setAttribute('width',options.width);
|
ele.setAttribute('width',options.width);
|
||||||
|
|
|
@ -17,7 +17,7 @@ mistplayers.theoplayer = {
|
||||||
var p = mistplayers.theoplayer.player;
|
var p = mistplayers.theoplayer.player;
|
||||||
p.prototype = new MistPlayer();
|
p.prototype = new MistPlayer();
|
||||||
p.prototype.build = function (options) {
|
p.prototype.build = function (options) {
|
||||||
var ele = this.element('video');
|
var ele = this.getElement('video');
|
||||||
|
|
||||||
ele.src = options.src;
|
ele.src = options.src;
|
||||||
ele.width = options.width;
|
ele.width = options.width;
|
||||||
|
|
167
embed/wrappers/videojs.js
Normal file
167
embed/wrappers/videojs.js
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
mistplayers.videojs = {
|
||||||
|
name: 'VideoJS player',
|
||||||
|
mimes: ['html5/video/mp4','html5/application/vnd.apple.mpegurl','html5/video/ogg','html5/video/webm'],
|
||||||
|
priority: Object.keys(mistplayers).length + 1,
|
||||||
|
isMimeSupported: function (mimetype) {
|
||||||
|
return (this.mimes.indexOf(mimetype) == -1 ? false : true);
|
||||||
|
},
|
||||||
|
isBrowserSupported: function (mimetype,source,options,streaminfo,logfunc) {
|
||||||
|
if ((options.host.substr(0,7) == 'http://') && (source.url.substr(0,8) == 'https://')) {
|
||||||
|
if (logfunc) { logfunc('HTTP/HTTPS mismatch for this source'); }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var support = true;
|
||||||
|
if ((location.protocol == 'file:') && (mimetype == 'html5/application/vnd.apple.mpegurl')) {
|
||||||
|
if (logfunc) { logfunc('This source ('+mimetype+') won\'t work if the page is run via file://'); }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ('MediaSource' in window);
|
||||||
|
},
|
||||||
|
player: function(){},
|
||||||
|
};
|
||||||
|
var p = mistplayers.videojs.player;
|
||||||
|
p.prototype = new MistPlayer();
|
||||||
|
p.prototype.build = function (options) {
|
||||||
|
var cont = document.createElement('div');
|
||||||
|
cont.className = 'mistplayer';
|
||||||
|
var me = this; //to allow nested functions to access the player class itself
|
||||||
|
|
||||||
|
this.addlog('Building VideoJS player..');
|
||||||
|
|
||||||
|
var ele = this.getElement('video');
|
||||||
|
cont.appendChild(ele);
|
||||||
|
ele.className = '';
|
||||||
|
ele.crossOrigin = 'anonymous'; //required for subtitles
|
||||||
|
|
||||||
|
var shortmime = options.source.type.split('/');
|
||||||
|
shortmime.shift();
|
||||||
|
|
||||||
|
var source = document.createElement('source');
|
||||||
|
source.setAttribute('src',options.src);
|
||||||
|
this.source = source;
|
||||||
|
ele.appendChild(source);
|
||||||
|
source.type = shortmime.join('/');
|
||||||
|
this.addlog('Adding '+source.type+' source @ '+options.src);
|
||||||
|
if (source.type == 'application/vnd.apple.mpegurl') { source.type = 'application/x-mpegURL'; }
|
||||||
|
|
||||||
|
ele.className += ' video-js';
|
||||||
|
ele.width = options.width;
|
||||||
|
ele.height = options.height;
|
||||||
|
ele.style.width = options.width+'px';
|
||||||
|
ele.style.height = options.height+'px';
|
||||||
|
|
||||||
|
var vjsopts = {
|
||||||
|
preload: 'auto'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.autoplay) { vjsopts.autoplay = true; }
|
||||||
|
if (options.loop) {
|
||||||
|
vjsopts.loop = true;
|
||||||
|
ele.loop = true;
|
||||||
|
}
|
||||||
|
if (options.poster) { vjsopts.poster = options.poster; }
|
||||||
|
if (options.controls) {
|
||||||
|
if ((options.controls == 'stock') || (!this.buildMistControls())) {
|
||||||
|
//MistControls have failed to build in the if condition
|
||||||
|
ele.setAttribute('controls',true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
me.onready(function(){
|
||||||
|
me.videojs = videojs(ele,vjsopts,function(){
|
||||||
|
me.addlog('Videojs initialized');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addlog('Built html');
|
||||||
|
|
||||||
|
//forward events
|
||||||
|
ele.addEventListener('error',function(e){
|
||||||
|
var msg;
|
||||||
|
if ('message' in e) {
|
||||||
|
msg = e.message;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = 'readyState: ';
|
||||||
|
switch (me.element.readyState) {
|
||||||
|
case 0:
|
||||||
|
msg += 'HAVE_NOTHING';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
msg += 'HAVE_METADATA';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
msg += 'HAVE_CURRENT_DATA';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
msg += 'HAVE_FUTURE_DATA';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
msg += 'HAVE_ENOUGH_DATA';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
msg += ' networkState: ';
|
||||||
|
switch (me.element.networkState) {
|
||||||
|
case 0:
|
||||||
|
msg += 'NETWORK_EMPTY';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
msg += 'NETWORK_IDLE';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
msg += 'NETWORK_LOADING';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
msg += 'NETWORK_NO_SOURCE';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
me.adderror(msg);
|
||||||
|
},true);
|
||||||
|
var events = ['abort','canplay','canplaythrough','durationchange','emptied','ended','interruptbegin','interruptend','loadeddata','loadedmetadata','loadstart','pause','play','playing','ratechange','seeked','seeking','stalled','volumechange','waiting','progress'];
|
||||||
|
for (var i in events) {
|
||||||
|
ele.addEventListener(events[i],function(e){
|
||||||
|
me.addlog('Player event fired: '+e.type);
|
||||||
|
},true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cont;
|
||||||
|
}
|
||||||
|
p.prototype.play = function(){ return this.element.play(); };
|
||||||
|
p.prototype.pause = function(){ return this.element.pause(); };
|
||||||
|
p.prototype.volume = function(level){
|
||||||
|
if (typeof level == 'undefined' ) { return this.element.volume; }
|
||||||
|
return this.element.volume = level;
|
||||||
|
};
|
||||||
|
p.prototype.loop = function(bool){
|
||||||
|
if (typeof bool == 'undefined') {
|
||||||
|
return this.element.loop;
|
||||||
|
}
|
||||||
|
return this.element.loop = bool;
|
||||||
|
};
|
||||||
|
p.prototype.load = function(){ return this.element.load(); };
|
||||||
|
if (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) {
|
||||||
|
p.prototype.fullscreen = function(){
|
||||||
|
if(this.element.requestFullscreen) {
|
||||||
|
return this.element.requestFullscreen();
|
||||||
|
} else if(this.element.mozRequestFullScreen) {
|
||||||
|
return this.element.mozRequestFullScreen();
|
||||||
|
} else if(this.element.webkitRequestFullscreen) {
|
||||||
|
return this.element.webkitRequestFullscreen();
|
||||||
|
} else if(this.element.msRequestFullscreen) {
|
||||||
|
return this.element.msRequestFullscreen();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
p.prototype.updateSrc = function(src){
|
||||||
|
if (src == '') {
|
||||||
|
this.videojs.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.videojs.src({
|
||||||
|
src: src,
|
||||||
|
type: this.source.type
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
};
|
|
@ -8,6 +8,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "ts_packet.h"
|
#include "ts_packet.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "bitfields.h"
|
||||||
|
|
||||||
#ifndef FILLER_DATA
|
#ifndef FILLER_DATA
|
||||||
#define FILLER_DATA "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo vulputate urna eu commodo. Cras tempor velit nec nulla placerat volutpat. Proin eleifend blandit quam sit amet suscipit. Pellentesque vitae tristique lorem. Maecenas facilisis consequat neque, vitae iaculis eros vulputate ut. Suspendisse ut arcu non eros vestibulum pulvinar id sed erat. Nam dictum tellus vel tellus rhoncus ut mollis tellus fermentum. Fusce volutpat consectetur ante, in mollis nisi euismod vulputate. Curabitur vitae facilisis ligula. Sed sed gravida dolor. Integer eu eros a dolor lobortis ullamcorper. Mauris interdum elit non neque interdum dictum. Suspendisse imperdiet eros sed sapien cursus pulvinar. Vestibulum ut dolor lectus, id commodo elit. Cras convallis varius leo eu porta. Duis luctus sapien nec dui adipiscing quis interdum nunc congue. Morbi pharetra aliquet mauris vitae tristique. Etiam feugiat sapien quis augue elementum id ultricies magna vulputate. Phasellus luctus, leo id egestas consequat, eros tortor commodo neque, vitae hendrerit nunc sem ut odio."
|
#define FILLER_DATA "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo vulputate urna eu commodo. Cras tempor velit nec nulla placerat volutpat. Proin eleifend blandit quam sit amet suscipit. Pellentesque vitae tristique lorem. Maecenas facilisis consequat neque, vitae iaculis eros vulputate ut. Suspendisse ut arcu non eros vestibulum pulvinar id sed erat. Nam dictum tellus vel tellus rhoncus ut mollis tellus fermentum. Fusce volutpat consectetur ante, in mollis nisi euismod vulputate. Curabitur vitae facilisis ligula. Sed sed gravida dolor. Integer eu eros a dolor lobortis ullamcorper. Mauris interdum elit non neque interdum dictum. Suspendisse imperdiet eros sed sapien cursus pulvinar. Vestibulum ut dolor lectus, id commodo elit. Cras convallis varius leo eu porta. Duis luctus sapien nec dui adipiscing quis interdum nunc congue. Morbi pharetra aliquet mauris vitae tristique. Etiam feugiat sapien quis augue elementum id ultricies magna vulputate. Phasellus luctus, leo id egestas consequat, eros tortor commodo neque, vitae hendrerit nunc sem ut odio."
|
||||||
|
@ -224,6 +225,7 @@ namespace TS {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints a packet to stdout, for analyser purposes.
|
/// Prints a packet to stdout, for analyser purposes.
|
||||||
|
/// If detail level contains bitmask 64, prints raw bytes after packet.
|
||||||
std::string Packet::toPrettyString(size_t indent, int detailLevel) const{
|
std::string Packet::toPrettyString(size_t indent, int detailLevel) const{
|
||||||
if (!(*this)){
|
if (!(*this)){
|
||||||
return "[Invalid packet - no sync byte]";
|
return "[Invalid packet - no sync byte]";
|
||||||
|
@ -234,12 +236,13 @@ namespace TS {
|
||||||
case 0: output << "PAT"; break;
|
case 0: output << "PAT"; break;
|
||||||
case 1: output << "CAT"; break;
|
case 1: output << "CAT"; break;
|
||||||
case 2: output << "TSDT"; break;
|
case 2: output << "TSDT"; break;
|
||||||
|
case 17: output << "SDT"; break;
|
||||||
case 0x1FFF: output << "Null"; break;
|
case 0x1FFF: output << "Null"; break;
|
||||||
default:
|
default:
|
||||||
if (pmt_pids.count(getPID())){
|
if (isPMT()){
|
||||||
output << "PMT";
|
output << "PMT";
|
||||||
}else{
|
}else{
|
||||||
if (stream_pids.count(getPID())){
|
if (isStream()){
|
||||||
output << stream_pids[getPID()];
|
output << stream_pids[getPID()];
|
||||||
}else{
|
}else{
|
||||||
output << "Unknown";
|
output << "Unknown";
|
||||||
|
@ -271,25 +274,23 @@ namespace TS {
|
||||||
output << std::endl;
|
output << std::endl;
|
||||||
if (!getPID()) {
|
if (!getPID()) {
|
||||||
//PAT
|
//PAT
|
||||||
if (detailLevel >= 2){
|
|
||||||
output << ((ProgramAssociationTable *)this)->toPrettyString(indent + 2);
|
output << ((ProgramAssociationTable *)this)->toPrettyString(indent + 2);
|
||||||
}else{
|
|
||||||
((ProgramAssociationTable *)this)->toPrettyString(indent + 2);
|
|
||||||
}
|
|
||||||
return output.str();
|
return output.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmt_pids.count(getPID())){
|
if (pmt_pids.count(getPID())){
|
||||||
//PMT
|
//PMT
|
||||||
if (detailLevel >= 2){
|
|
||||||
output << ((ProgramMappingTable *)this)->toPrettyString(indent + 2);
|
output << ((ProgramMappingTable *)this)->toPrettyString(indent + 2);
|
||||||
}else{
|
|
||||||
((ProgramMappingTable *)this)->toPrettyString(indent + 2);
|
|
||||||
}
|
|
||||||
return output.str();
|
return output.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detailLevel >= 10){
|
if (getPID() == 17){
|
||||||
|
//SDT
|
||||||
|
output << ((ServiceDescriptionTable *)this)->toPrettyString(indent + 2);
|
||||||
|
return output.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (detailLevel & 64){
|
||||||
output << std::string(indent+2, ' ') << "Raw data bytes:";
|
output << std::string(indent+2, ' ') << "Raw data bytes:";
|
||||||
unsigned int size = getDataSize();
|
unsigned int size = getDataSize();
|
||||||
|
|
||||||
|
@ -313,11 +314,17 @@ namespace TS {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this PID contains a PMT.
|
/// Returns true if this PID contains a PMT.
|
||||||
/// Important caveat: only works if the corresponding PAT has been pretty-printed earlier!
|
/// Important caveat: only works if the corresponding PAT has been pretty-printed or had parsePIDs() called on it!
|
||||||
bool Packet::isPMT() const{
|
bool Packet::isPMT() const{
|
||||||
return pmt_pids.count(getPID());
|
return pmt_pids.count(getPID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if this PID contains a stream known from a PMT.
|
||||||
|
/// Important caveat: only works if the corresponding PMT was pretty-printed or had parseStreams() called on it!
|
||||||
|
bool Packet::isStream() const{
|
||||||
|
return stream_pids.count(getPID());
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the start of a new unit in this Packet.
|
/// Sets the start of a new unit in this Packet.
|
||||||
/// \param NewVal The new value for the start of a unit.
|
/// \param NewVal The new value for the start of a unit.
|
||||||
void Packet::setUnitStart(bool NewVal) {
|
void Packet::setUnitStart(bool NewVal) {
|
||||||
|
@ -480,8 +487,13 @@ namespace TS {
|
||||||
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
||||||
/// \param len The length of this frame.
|
/// \param len The length of this frame.
|
||||||
/// \param PTS The timestamp of the frame.
|
/// \param PTS The timestamp of the frame.
|
||||||
std::string & Packet::getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset, bool isAligned) {
|
std::string & Packet::getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset, bool isAligned, uint64_t bps) {
|
||||||
len += (offset ? 13 : 8);
|
len += (offset ? 13 : 8);
|
||||||
|
if (bps >= 50){
|
||||||
|
len += 3;
|
||||||
|
}else{
|
||||||
|
bps = 0;
|
||||||
|
}
|
||||||
static std::string tmpStr;
|
static std::string tmpStr;
|
||||||
tmpStr.clear();
|
tmpStr.clear();
|
||||||
tmpStr.reserve(25);
|
tmpStr.reserve(25);
|
||||||
|
@ -493,12 +505,17 @@ namespace TS {
|
||||||
}else{
|
}else{
|
||||||
tmpStr.append("\200", 1);
|
tmpStr.append("\200", 1);
|
||||||
}
|
}
|
||||||
tmpStr += (char)(offset ? 0xC0 : 0x80) ; //PTS/DTS + Flags
|
tmpStr += (char)((offset ? 0xC0 : 0x80) | (bps?0x10:0)) ; //PTS/DTS + Flags
|
||||||
tmpStr += (char)(offset ? 0x0A : 0x05); //PESHeaderDataLength
|
tmpStr += (char)((offset ? 10 : 5) + (bps?3:0)); //PESHeaderDataLength
|
||||||
encodePESTimestamp(tmpStr, (offset ? 0x30 : 0x20), PTS + offset);
|
encodePESTimestamp(tmpStr, (offset ? 0x30 : 0x20), PTS + offset);
|
||||||
if (offset){
|
if (offset){
|
||||||
encodePESTimestamp(tmpStr, 0x10, PTS);
|
encodePESTimestamp(tmpStr, 0x10, PTS);
|
||||||
}
|
}
|
||||||
|
if (bps){
|
||||||
|
char rate_buf[3];
|
||||||
|
Bit::htob24(rate_buf, (bps/50) | 0x800001);
|
||||||
|
tmpStr.append(rate_buf, 3);
|
||||||
|
}
|
||||||
return tmpStr;
|
return tmpStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,16 +523,28 @@ namespace TS {
|
||||||
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
/// Prepends the lead-in to variable toSend, assumes toSend's length is all other data.
|
||||||
/// \param len The length of this frame.
|
/// \param len The length of this frame.
|
||||||
/// \param PTS The timestamp of the frame.
|
/// \param PTS The timestamp of the frame.
|
||||||
std::string & Packet::getPESAudioLeadIn(unsigned int len, unsigned long long PTS) {
|
std::string & Packet::getPESAudioLeadIn(unsigned int len, unsigned long long PTS, uint64_t bps) {
|
||||||
|
if (bps >= 50){
|
||||||
|
len += 3;
|
||||||
|
}else{
|
||||||
|
bps = 0;
|
||||||
|
}
|
||||||
static std::string tmpStr;
|
static std::string tmpStr;
|
||||||
tmpStr.clear();
|
tmpStr.clear();
|
||||||
tmpStr.reserve(14);
|
tmpStr.reserve(20);
|
||||||
len += 8;
|
len += 8;
|
||||||
tmpStr.append("\000\000\001\300", 4);
|
tmpStr.append("\000\000\001\300", 4);
|
||||||
tmpStr += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
tmpStr += (char)((len & 0xFF00) >> 8); //PES PacketLength
|
||||||
tmpStr += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
tmpStr += (char)(len & 0x00FF); //PES PacketLength (Cont)
|
||||||
tmpStr.append("\204\200\005", 3);
|
tmpStr += (char)0x84;//isAligned
|
||||||
|
tmpStr += (char)(0x80 | (bps?0x10:0)) ; //PTS/DTS + Flags
|
||||||
|
tmpStr += (char)(5 + (bps?3:0)); //PESHeaderDataLength
|
||||||
encodePESTimestamp(tmpStr, 0x20, PTS);
|
encodePESTimestamp(tmpStr, 0x20, PTS);
|
||||||
|
if (bps){
|
||||||
|
char rate_buf[3];
|
||||||
|
Bit::htob24(rate_buf, (bps/50) | 0x800001);
|
||||||
|
tmpStr.append(rate_buf, 3);
|
||||||
|
}
|
||||||
return tmpStr;
|
return tmpStr;
|
||||||
}
|
}
|
||||||
//END PES FUNCTIONS
|
//END PES FUNCTIONS
|
||||||
|
@ -641,7 +670,7 @@ namespace TS {
|
||||||
///Retrieves the "current/next" indicator
|
///Retrieves the "current/next" indicator
|
||||||
bool ProgramAssociationTable::getCurrentNextIndicator() const{
|
bool ProgramAssociationTable::getCurrentNextIndicator() const{
|
||||||
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
return (strBuf[loc] >> 1) & 0x01;
|
return strBuf[loc] & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
///Retrieves the section number
|
///Retrieves the section number
|
||||||
|
@ -876,20 +905,20 @@ namespace TS {
|
||||||
void ProgramMappingTable::setVersionNumber(char newVal) {
|
void ProgramMappingTable::setVersionNumber(char newVal) {
|
||||||
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
updPos(loc+1);
|
updPos(loc+1);
|
||||||
strBuf[loc] = ((newVal & 0x1F) << 1) | 0xC1;
|
strBuf[loc] = ((newVal & 0x1F) << 1) | (strBuf[loc] & 0xC1);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Retrieves the "current/next" indicator
|
///Retrieves the "current/next" indicator
|
||||||
bool ProgramMappingTable::getCurrentNextIndicator() const{
|
bool ProgramMappingTable::getCurrentNextIndicator() const{
|
||||||
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
return (strBuf[loc] >> 1) & 0x01;
|
return strBuf[loc] & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
///Sets the "current/next" indicator
|
///Sets the "current/next" indicator
|
||||||
void ProgramMappingTable::setCurrentNextIndicator(bool newVal) {
|
void ProgramMappingTable::setCurrentNextIndicator(bool newVal) {
|
||||||
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
updPos(loc+1);
|
updPos(loc+1);
|
||||||
strBuf[loc] = (((char)newVal) << 1) | (strBuf[loc] & 0xFD) | 0xC1;
|
strBuf[loc] = (newVal?1:0) | (strBuf[loc] & 0xFE);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Retrieves the section number
|
///Retrieves the section number
|
||||||
|
@ -969,6 +998,15 @@ namespace TS {
|
||||||
memset((void*)(strBuf + loc + 4), 0xFF, 184 - loc);
|
memset((void*)(strBuf + loc + 4), 0xFF, 184 - loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parses the PMT for streams, keeping track of their PIDs to make the Packet::isStream() function work
|
||||||
|
void ProgramMappingTable::parseStreams(){
|
||||||
|
ProgramMappingEntry entry = getEntry(0);
|
||||||
|
while (entry) {
|
||||||
|
stream_pids[entry.getElementaryPid()] = entry.getCodec() + std::string(" ") + entry.getStreamTypeString();
|
||||||
|
entry.advance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///Print all PMT values in a human readable format
|
///Print all PMT values in a human readable format
|
||||||
///\param indent The indentation of the string printed as wanted by the user
|
///\param indent The indentation of the string printed as wanted by the user
|
||||||
///\return The string with human readable data from a PMT table
|
///\return The string with human readable data from a PMT table
|
||||||
|
@ -1028,6 +1066,22 @@ namespace TS {
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case 0x48:{//DVB service descriptor
|
||||||
|
output << std::string(indent, ' ') << "DVB service: ";
|
||||||
|
uint32_t offset = p+2;
|
||||||
|
switch (p_data[offset]){
|
||||||
|
case 0x01: output << "digital TV"; break;
|
||||||
|
case 0x02: output << "digital radio"; break;
|
||||||
|
case 0x10: output << "DVB MHP"; break;
|
||||||
|
default: output << "NOT IMPLEMENTED"; break;
|
||||||
|
}
|
||||||
|
offset++;//move to provider len
|
||||||
|
uint8_t len = p_data[offset];
|
||||||
|
output << ", Provider: " << std::string(p_data+offset+1, len);
|
||||||
|
offset += 1+len;//move to service len
|
||||||
|
len = p_data[offset];
|
||||||
|
output << ", Service: " << std::string(p_data+offset+1, len) << std::endl;
|
||||||
|
} break;
|
||||||
case 0x7C:{//AAC descriptor (EN 300 468)
|
case 0x7C:{//AAC descriptor (EN 300 468)
|
||||||
if (p_data[p+1] < 2 || p+2+p_data[p+1] > p_len){continue;}//skip broken data
|
if (p_data[p+1] < 2 || p+2+p_data[p+1] > p_len){continue;}//skip broken data
|
||||||
output << std::string(indent, ' ') << "AAC profile: ";
|
output << std::string(indent, ' ') << "AAC profile: ";
|
||||||
|
@ -1057,6 +1111,9 @@ namespace TS {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case 0x52:{//DVB stream identifier
|
||||||
|
output << std::string(indent, ' ') << "Stream identifier: Tag #" << (int)p_data[p+2] << std::endl;
|
||||||
|
} break;
|
||||||
default:{
|
default:{
|
||||||
output << std::string(indent, ' ') << "Undecoded descriptor: ";
|
output << std::string(indent, ' ') << "Undecoded descriptor: ";
|
||||||
for (uint32_t i = 0; i<p_data[p+1]+2; ++i){
|
for (uint32_t i = 0; i<p_data[p+1]+2; ++i){
|
||||||
|
@ -1096,7 +1153,7 @@ namespace TS {
|
||||||
PMT.setSectionLength(0xB00D + sectionLen);
|
PMT.setSectionLength(0xB00D + sectionLen);
|
||||||
PMT.setProgramNumber(1);
|
PMT.setProgramNumber(1);
|
||||||
PMT.setVersionNumber(0);
|
PMT.setVersionNumber(0);
|
||||||
PMT.setCurrentNextIndicator(0);
|
PMT.setCurrentNextIndicator(1);
|
||||||
PMT.setSectionNumber(0);
|
PMT.setSectionNumber(0);
|
||||||
PMT.setLastSectionNumber(0);
|
PMT.setLastSectionNumber(0);
|
||||||
PMT.setContinuityCounter(contCounter);
|
PMT.setContinuityCounter(contCounter);
|
||||||
|
@ -1145,6 +1202,297 @@ namespace TS {
|
||||||
return PMT.checkAndGetBuffer();
|
return PMT.checkAndGetBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ServiceDescriptionEntry::ServiceDescriptionEntry(char * begin, char * end){
|
||||||
|
data = begin;
|
||||||
|
boundary = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceDescriptionEntry::operator bool() const {
|
||||||
|
return data && (data < boundary);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t ServiceDescriptionEntry::getServiceID() const{
|
||||||
|
return Bit::btohs(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionEntry::setServiceID(uint16_t val){
|
||||||
|
Bit::htobs(data, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServiceDescriptionEntry::getEITSchedule() const{
|
||||||
|
return data[2] & 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionEntry::setEITSchedule(bool val){
|
||||||
|
data[2] |= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServiceDescriptionEntry::getEITPresentFollowing() const{
|
||||||
|
return data[2] & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionEntry::setEITPresentFollowing(bool val){
|
||||||
|
data[2] |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ServiceDescriptionEntry::getRunningStatus() const{
|
||||||
|
return (data[3] & 0xE0) >> 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionEntry::setRunningStatus(uint8_t val){
|
||||||
|
data[3] = (data[3] & 0x1F) | (val << 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServiceDescriptionEntry::getFreeCAM() const{
|
||||||
|
return data[3] & 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionEntry::setFreeCAM(bool val){
|
||||||
|
data[3] = (data[3] & 0xEF) | (val?0x10:0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ServiceDescriptionEntry::getESInfoLength() const{
|
||||||
|
return ((data[3] << 8) | data[4]) & 0x0FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * ServiceDescriptionEntry::getESInfo() const{
|
||||||
|
return data + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionEntry::setESInfo(const std::string & newInfo){
|
||||||
|
data[3] = ((newInfo.size() >> 8) & 0x0F) | (data[3] & 0xF0);
|
||||||
|
data[4] = newInfo.size() & 0xFF;
|
||||||
|
memcpy(data + 5, newInfo.data(), newInfo.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionEntry::advance(){
|
||||||
|
if (!(*this)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data += 5 + getESInfoLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceDescriptionTable::ServiceDescriptionTable(){
|
||||||
|
strBuf[0] = 0x47;
|
||||||
|
strBuf[1] = 0x50;
|
||||||
|
strBuf[2] = 0x00;
|
||||||
|
strBuf[3] = 0x10;
|
||||||
|
pos=4;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceDescriptionTable & ServiceDescriptionTable::operator = (const Packet & rhs) {
|
||||||
|
memcpy(strBuf, rhs.checkAndGetBuffer(), 188);
|
||||||
|
pos = 188;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
char ServiceDescriptionTable::getOffset() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0);
|
||||||
|
return strBuf[loc];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionTable::setOffset(char newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0);
|
||||||
|
strBuf[loc] = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char ServiceDescriptionTable::getTableId() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 1;
|
||||||
|
return strBuf[loc];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionTable::setTableId(char newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 1;
|
||||||
|
updPos(loc+1);
|
||||||
|
strBuf[loc] = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
short ServiceDescriptionTable::getSectionLength() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 2;
|
||||||
|
return (((short)strBuf[loc] & 0x0F) << 8) | strBuf[loc + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionTable::setSectionLength(short newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 2;
|
||||||
|
updPos(loc+2);
|
||||||
|
strBuf[loc] = (char)(newVal >> 8);
|
||||||
|
strBuf[loc+1] = (char)newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t ServiceDescriptionTable::getTSStreamID() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 4;
|
||||||
|
return (((short)strBuf[loc]) << 8) | strBuf[loc + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionTable::setTSStreamID(uint16_t newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 4;
|
||||||
|
updPos(loc+2);
|
||||||
|
strBuf[loc] = (char)(newVal >> 8);
|
||||||
|
strBuf[loc+1] = (char)newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ServiceDescriptionTable::getVersionNumber() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
|
return (strBuf[loc] >> 1) & 0x1F;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionTable::setVersionNumber(uint8_t newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
|
updPos(loc+1);
|
||||||
|
strBuf[loc] = ((newVal & 0x1F) << 1) | (strBuf[loc] & 0xC1);
|
||||||
|
}
|
||||||
|
|
||||||
|
///Retrieves the "current/next" indicator
|
||||||
|
bool ServiceDescriptionTable::getCurrentNextIndicator() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
|
return strBuf[loc] & 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
///Sets the "current/next" indicator
|
||||||
|
void ServiceDescriptionTable::setCurrentNextIndicator(bool newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 6;
|
||||||
|
updPos(loc+1);
|
||||||
|
strBuf[loc] = (newVal?1:0) | (strBuf[loc] & 0xFE);
|
||||||
|
}
|
||||||
|
|
||||||
|
///Retrieves the section number
|
||||||
|
uint8_t ServiceDescriptionTable::getSectionNumber() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 7;
|
||||||
|
return strBuf[loc];
|
||||||
|
}
|
||||||
|
|
||||||
|
///Sets the section number
|
||||||
|
void ServiceDescriptionTable::setSectionNumber(uint8_t newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 7;
|
||||||
|
updPos(loc+1);
|
||||||
|
strBuf[loc] = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
///Retrieves the last section number
|
||||||
|
uint8_t ServiceDescriptionTable::getLastSectionNumber() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 8;
|
||||||
|
return strBuf[loc];
|
||||||
|
}
|
||||||
|
|
||||||
|
///Sets the last section number
|
||||||
|
void ServiceDescriptionTable::setLastSectionNumber(uint8_t newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 8;
|
||||||
|
updPos(loc+1);
|
||||||
|
strBuf[loc] = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t ServiceDescriptionTable::getOrigID() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 9;
|
||||||
|
return (((short)strBuf[loc] & 0x1F) << 8) | strBuf[loc + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionTable::setOrigID(uint16_t newVal) {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 9;
|
||||||
|
updPos(loc+2);
|
||||||
|
strBuf[loc] = (char)((newVal >> 8) & 0x1F) | 0xE0;//Note: here we set reserved bits on 1
|
||||||
|
strBuf[loc+1] = (char)newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceDescriptionEntry ServiceDescriptionTable::getEntry(int index) const{
|
||||||
|
int dataOffset = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset();
|
||||||
|
ServiceDescriptionEntry res((char*)(strBuf + dataOffset + 12), (char*)(strBuf + dataOffset + getSectionLength()) );
|
||||||
|
for (int i = 0; i < index; i++){
|
||||||
|
res.advance();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ServiceDescriptionTable::getCRC() const{
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + getSectionLength();
|
||||||
|
return ((int)(strBuf[loc]) << 24) | ((int)(strBuf[loc + 1]) << 16) | ((int)(strBuf[loc + 2]) << 8) | strBuf[loc + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceDescriptionTable::calcCRC() {
|
||||||
|
unsigned int loc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + getSectionLength();
|
||||||
|
unsigned int newVal;//this will hold the CRC32 value;
|
||||||
|
unsigned int pidLoc = 4 + (getAdaptationField() > 1 ? getAdaptationFieldLen() + 1 : 0) + getOffset() + 1;
|
||||||
|
newVal = checksum::crc32(-1, strBuf + pidLoc, loc - pidLoc);//calculating checksum over all the fields from table ID to the last stream element
|
||||||
|
updPos(188);
|
||||||
|
strBuf[loc + 3] = (newVal >> 24) & 0xFF;
|
||||||
|
strBuf[loc + 2] = (newVal >> 16) & 0xFF;
|
||||||
|
strBuf[loc + 1] = (newVal >> 8) & 0xFF;
|
||||||
|
strBuf[loc] = newVal & 0xFF;
|
||||||
|
memset((void*)(strBuf + loc + 4), 0xFF, 184 - loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
///Print all SDT values in a human readable format
|
||||||
|
///\param indent The indentation of the string printed as wanted by the user
|
||||||
|
///\return The string with human readable data from a SDT table
|
||||||
|
std::string ServiceDescriptionTable::toPrettyString(size_t indent) const{
|
||||||
|
std::stringstream output;
|
||||||
|
output << std::string(indent, ' ') << "[Service Description Table]" << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Pointer Field: " << (int)getOffset() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Table ID: " << (int)getTableId() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Section Length: " << getSectionLength() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "TS Stream ID: " << getTSStreamID() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Version number: " << (int)getVersionNumber() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Current next indicator: " << (int)getCurrentNextIndicator() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Section number: " << (int)getSectionNumber() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Last Section number: " << (int)getLastSectionNumber() << std::endl;
|
||||||
|
output << std::string(indent + 2, ' ') << "Original Network ID: " << getOrigID() << std::endl;
|
||||||
|
ServiceDescriptionEntry entry = getEntry(0);
|
||||||
|
while (entry) {
|
||||||
|
output << std::string(indent + 4, ' ');
|
||||||
|
output << "Service " << entry.getServiceID() << ":";
|
||||||
|
|
||||||
|
if (entry.getEITSchedule()){output << " EIT";}
|
||||||
|
if (entry.getEITPresentFollowing()){output << " EITPF";}
|
||||||
|
if (entry.getFreeCAM()){output << " Free";}
|
||||||
|
switch (entry.getRunningStatus()){
|
||||||
|
case 0: output << " Undefined"; break;
|
||||||
|
case 1: output << " NotRunning"; break;
|
||||||
|
case 2: output << " StartSoon"; break;
|
||||||
|
case 3: output << " Pausing"; break;
|
||||||
|
case 4: output << " Running"; break;
|
||||||
|
case 5: output << " OffAir"; break;
|
||||||
|
default: output << " UNIMPL?" << (int)entry.getRunningStatus(); break;
|
||||||
|
}
|
||||||
|
output << std::endl;
|
||||||
|
output << ProgramDescriptors(entry.getESInfo(), entry.getESInfoLength()).toPrettyString(indent+6);
|
||||||
|
entry.advance();
|
||||||
|
}
|
||||||
|
output << std::string(indent + 2, ' ') << "CRC32: " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << getCRC() << std::dec << std::endl;
|
||||||
|
return output.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Construct a SDT from a set of selected tracks and metadata.
|
||||||
|
/// This function is not part of the packet class, but it is in the TS namespace.
|
||||||
|
/// It uses an internal static TS packet for SDT storage.
|
||||||
|
///\returns character pointer to a static 188B TS packet
|
||||||
|
const char * createSDT(const std::string & streamName, int contCounter){
|
||||||
|
static ServiceDescriptionTable SDT;
|
||||||
|
SDT.setPID(0x11);
|
||||||
|
SDT.setTableId(0x42);
|
||||||
|
SDT.setSectionLength(0x8020 + streamName.size());
|
||||||
|
SDT.setTSStreamID(1);
|
||||||
|
SDT.setVersionNumber(0);
|
||||||
|
SDT.setCurrentNextIndicator(1);
|
||||||
|
SDT.setSectionNumber(0);
|
||||||
|
SDT.setLastSectionNumber(0);
|
||||||
|
SDT.setOrigID(1);
|
||||||
|
ServiceDescriptionEntry entry = SDT.getEntry(0);
|
||||||
|
entry.setServiceID(1);//Same as ProgramNumber in PMT
|
||||||
|
entry.setRunningStatus(4);//Running
|
||||||
|
entry.setFreeCAM(true);//Not conditional access
|
||||||
|
std::string sdti;
|
||||||
|
sdti += (char)0x48;
|
||||||
|
sdti += (char)(15+streamName.size());//length
|
||||||
|
sdti += (char)1;//digital television service
|
||||||
|
sdti.append("\012MistServer");
|
||||||
|
sdti += (char)streamName.size();
|
||||||
|
sdti.append(streamName);
|
||||||
|
entry.setESInfo(sdti);
|
||||||
|
SDT.setContinuityCounter(contCounter);
|
||||||
|
SDT.calcCRC();
|
||||||
|
return SDT.checkAndGetBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace TS {
|
||||||
//Helper functions
|
//Helper functions
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
bool isPMT() const;
|
bool isPMT() const;
|
||||||
|
bool isStream() const;
|
||||||
void clear();
|
void clear();
|
||||||
void setDefaultPAT();
|
void setDefaultPAT();
|
||||||
unsigned int getDataSize() const;
|
unsigned int getDataSize() const;
|
||||||
|
@ -69,8 +70,8 @@ namespace TS {
|
||||||
void updPos(unsigned int newPos);
|
void updPos(unsigned int newPos);
|
||||||
|
|
||||||
//PES helpers
|
//PES helpers
|
||||||
static std::string & getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset, bool isAligned);
|
static std::string & getPESVideoLeadIn(unsigned int len, unsigned long long PTS, unsigned long long offset, bool isAligned, uint64_t bps=0);
|
||||||
static std::string & getPESAudioLeadIn(unsigned int len, unsigned long long PTS);
|
static std::string & getPESAudioLeadIn(unsigned int len, unsigned long long PTS, uint64_t bps=0);
|
||||||
|
|
||||||
//Printers and writers
|
//Printers and writers
|
||||||
std::string toPrettyString(size_t indent = 0, int detailLevel = 3) const;
|
std::string toPrettyString(size_t indent = 0, int detailLevel = 3) const;
|
||||||
|
@ -157,12 +158,66 @@ namespace TS {
|
||||||
void setPCRPID(short newVal);
|
void setPCRPID(short newVal);
|
||||||
short getProgramInfoLength() const;
|
short getProgramInfoLength() const;
|
||||||
void setProgramInfoLength(short newVal);
|
void setProgramInfoLength(short newVal);
|
||||||
|
void parseStreams();
|
||||||
ProgramMappingEntry getEntry(int index) const;
|
ProgramMappingEntry getEntry(int index) const;
|
||||||
int getCRC() const;
|
int getCRC() const;
|
||||||
void calcCRC();
|
void calcCRC();
|
||||||
std::string toPrettyString(size_t indent) const;
|
std::string toPrettyString(size_t indent) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ServiceDescriptionEntry {
|
||||||
|
public:
|
||||||
|
ServiceDescriptionEntry(char * begin, char * end);
|
||||||
|
operator bool() const;
|
||||||
|
uint16_t getServiceID() const;
|
||||||
|
void setServiceID(uint16_t newType);
|
||||||
|
bool getEITSchedule() const;
|
||||||
|
void setEITSchedule(bool val);
|
||||||
|
bool getEITPresentFollowing() const;
|
||||||
|
void setEITPresentFollowing(bool val);
|
||||||
|
uint8_t getRunningStatus() const;
|
||||||
|
void setRunningStatus(uint8_t val);
|
||||||
|
bool getFreeCAM() const;
|
||||||
|
void setFreeCAM(bool val);
|
||||||
|
int getESInfoLength() const;
|
||||||
|
const char * getESInfo() const;
|
||||||
|
void setESInfo(const std::string & newInfo);
|
||||||
|
void advance();
|
||||||
|
private:
|
||||||
|
char* data;
|
||||||
|
char* boundary;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ServiceDescriptionTable : public Packet {
|
||||||
|
public:
|
||||||
|
ServiceDescriptionTable();
|
||||||
|
ServiceDescriptionTable & operator = (const Packet & rhs);
|
||||||
|
char getOffset() const;
|
||||||
|
void setOffset(char newVal);
|
||||||
|
|
||||||
|
char getTableId() const;
|
||||||
|
void setTableId(char newVal);
|
||||||
|
short getSectionLength() const;
|
||||||
|
void setSectionLength(short newVal);
|
||||||
|
|
||||||
|
uint16_t getTSStreamID() const;
|
||||||
|
void setTSStreamID(uint16_t newVal);
|
||||||
|
uint8_t getVersionNumber() const;
|
||||||
|
void setVersionNumber(uint8_t newVal);
|
||||||
|
bool getCurrentNextIndicator() const;
|
||||||
|
void setCurrentNextIndicator(bool newVal);
|
||||||
|
uint8_t getSectionNumber() const;
|
||||||
|
void setSectionNumber(uint8_t newVal);
|
||||||
|
uint8_t getLastSectionNumber() const;
|
||||||
|
void setLastSectionNumber(uint8_t newVal);
|
||||||
|
uint16_t getOrigID() const;
|
||||||
|
void setOrigID(uint16_t newVal);
|
||||||
|
ServiceDescriptionEntry getEntry(int index) const;
|
||||||
|
int getCRC() const;
|
||||||
|
void calcCRC();
|
||||||
|
std::string toPrettyString(size_t indent) const;
|
||||||
|
};
|
||||||
|
|
||||||
/// Constructs an audio header to be used on each audio frame.
|
/// Constructs an audio header to be used on each audio frame.
|
||||||
/// The length of this header will ALWAYS be 7 bytes, and has to be
|
/// The length of this header will ALWAYS be 7 bytes, and has to be
|
||||||
/// prepended on each audio frame.
|
/// prepended on each audio frame.
|
||||||
|
@ -208,6 +263,7 @@ namespace TS {
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * createPMT(std::set<unsigned long>& selectedTracks, DTSC::Meta& myMeta, int contCounter=0);
|
const char * createPMT(std::set<unsigned long>& selectedTracks, DTSC::Meta& myMeta, int contCounter=0);
|
||||||
|
const char * createSDT(const std::string & streamName, int contCounter=0);
|
||||||
|
|
||||||
} //TS namespace
|
} //TS namespace
|
||||||
|
|
||||||
|
|
283
lsp/minified.js
283
lsp/minified.js
|
@ -1,11 +1,11 @@
|
||||||
var MD5=function(a){function b(a,b){var g,c,d,h,i;d=a&2147483648;h=b&2147483648;g=a&1073741824;c=b&1073741824;i=(a&1073741823)+(b&1073741823);return g&c?i^2147483648^d^h:g|c?i&1073741824?i^3221225472^d^h:i^1073741824^d^h:i^d^h}function c(a,g,c,d,h,i,f){a=b(a,b(b(g&c|~g&d,h),f));return b(a<<i|a>>>32-i,g)}function d(a,g,c,d,h,i,f){a=b(a,b(b(g&d|c&~d,h),f));return b(a<<i|a>>>32-i,g)}function e(a,g,c,d,h,i,f){a=b(a,b(b(g^c^d,h),f));return b(a<<i|a>>>32-i,g)}function k(a,g,c,d,h,i,f){a=b(a,b(b(c^(g|~d),
|
var MD5=function(a){function b(a,b){var c,d,g,e,h;g=a&2147483648;e=b&2147483648;c=a&1073741824;d=b&1073741824;h=(a&1073741823)+(b&1073741823);return c&d?h^2147483648^g^e:c|d?h&1073741824?h^3221225472^g^e:h^1073741824^g^e:h^g^e}function c(a,c,d,g,e,h,i){a=b(a,b(b(c&d|~c&g,e),i));return b(a<<h|a>>>32-h,c)}function d(a,c,d,g,e,h,i){a=b(a,b(b(c&g|d&~g,e),i));return b(a<<h|a>>>32-h,c)}function e(a,c,d,g,e,h,i){a=b(a,b(b(c^d^g,e),i));return b(a<<h|a>>>32-h,c)}function g(a,c,d,g,e,h,i){a=b(a,b(b(d^(c|~g),
|
||||||
h),f));return b(a<<i|a>>>32-i,g)}function m(a){var b="",g="",c;for(c=0;3>=c;c++)g=a>>>8*c&255,g="0"+g.toString(16),b+=g.substr(g.length-2,2);return b}var f=[],q,p,l,v,h,g,i,j,f=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<f.length;q++)p=f.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));f=a;a=f.length;q=a+8;p=16*((q-q%64)/64+1);l=Array(p-1);for(h=v=0;h<a;)q=
|
e),i));return b(a<<h|a>>>32-h,c)}function m(a){var b="",c="",d;for(d=0;3>=d;d++)c=a>>>8*d&255,c="0"+c.toString(16),b+=c.substr(c.length-2,2);return b}var f=[],q,p,l,u,h,i,k,j,f=a.replace(/\r\n/g,"\n"),a="";for(q=0;q<f.length;q++)p=f.charCodeAt(q),128>p?a+=String.fromCharCode(p):(127<p&&2048>p?a+=String.fromCharCode(p>>6|192):(a+=String.fromCharCode(p>>12|224),a+=String.fromCharCode(p>>6&63|128)),a+=String.fromCharCode(p&63|128));f=a;a=f.length;q=a+8;p=16*((q-q%64)/64+1);l=Array(p-1);for(h=u=0;h<a;)q=
|
||||||
(h-h%4)/4,v=8*(h%4),l[q]|=f.charCodeAt(h)<<v,h++;q=(h-h%4)/4;l[q]|=128<<8*(h%4);l[p-2]=a<<3;l[p-1]=a>>>29;f=l;h=1732584193;g=4023233417;i=2562383102;j=271733878;for(a=0;a<f.length;a+=16)q=h,p=g,l=i,v=j,h=c(h,g,i,j,f[a+0],7,3614090360),j=c(j,h,g,i,f[a+1],12,3905402710),i=c(i,j,h,g,f[a+2],17,606105819),g=c(g,i,j,h,f[a+3],22,3250441966),h=c(h,g,i,j,f[a+4],7,4118548399),j=c(j,h,g,i,f[a+5],12,1200080426),i=c(i,j,h,g,f[a+6],17,2821735955),g=c(g,i,j,h,f[a+7],22,4249261313),h=c(h,g,i,j,f[a+8],7,1770035416),
|
(h-h%4)/4,u=8*(h%4),l[q]|=f.charCodeAt(h)<<u,h++;q=(h-h%4)/4;l[q]|=128<<8*(h%4);l[p-2]=a<<3;l[p-1]=a>>>29;f=l;h=1732584193;i=4023233417;k=2562383102;j=271733878;for(a=0;a<f.length;a+=16)q=h,p=i,l=k,u=j,h=c(h,i,k,j,f[a+0],7,3614090360),j=c(j,h,i,k,f[a+1],12,3905402710),k=c(k,j,h,i,f[a+2],17,606105819),i=c(i,k,j,h,f[a+3],22,3250441966),h=c(h,i,k,j,f[a+4],7,4118548399),j=c(j,h,i,k,f[a+5],12,1200080426),k=c(k,j,h,i,f[a+6],17,2821735955),i=c(i,k,j,h,f[a+7],22,4249261313),h=c(h,i,k,j,f[a+8],7,1770035416),
|
||||||
j=c(j,h,g,i,f[a+9],12,2336552879),i=c(i,j,h,g,f[a+10],17,4294925233),g=c(g,i,j,h,f[a+11],22,2304563134),h=c(h,g,i,j,f[a+12],7,1804603682),j=c(j,h,g,i,f[a+13],12,4254626195),i=c(i,j,h,g,f[a+14],17,2792965006),g=c(g,i,j,h,f[a+15],22,1236535329),h=d(h,g,i,j,f[a+1],5,4129170786),j=d(j,h,g,i,f[a+6],9,3225465664),i=d(i,j,h,g,f[a+11],14,643717713),g=d(g,i,j,h,f[a+0],20,3921069994),h=d(h,g,i,j,f[a+5],5,3593408605),j=d(j,h,g,i,f[a+10],9,38016083),i=d(i,j,h,g,f[a+15],14,3634488961),g=d(g,i,j,h,f[a+4],20,3889429448),
|
j=c(j,h,i,k,f[a+9],12,2336552879),k=c(k,j,h,i,f[a+10],17,4294925233),i=c(i,k,j,h,f[a+11],22,2304563134),h=c(h,i,k,j,f[a+12],7,1804603682),j=c(j,h,i,k,f[a+13],12,4254626195),k=c(k,j,h,i,f[a+14],17,2792965006),i=c(i,k,j,h,f[a+15],22,1236535329),h=d(h,i,k,j,f[a+1],5,4129170786),j=d(j,h,i,k,f[a+6],9,3225465664),k=d(k,j,h,i,f[a+11],14,643717713),i=d(i,k,j,h,f[a+0],20,3921069994),h=d(h,i,k,j,f[a+5],5,3593408605),j=d(j,h,i,k,f[a+10],9,38016083),k=d(k,j,h,i,f[a+15],14,3634488961),i=d(i,k,j,h,f[a+4],20,3889429448),
|
||||||
h=d(h,g,i,j,f[a+9],5,568446438),j=d(j,h,g,i,f[a+14],9,3275163606),i=d(i,j,h,g,f[a+3],14,4107603335),g=d(g,i,j,h,f[a+8],20,1163531501),h=d(h,g,i,j,f[a+13],5,2850285829),j=d(j,h,g,i,f[a+2],9,4243563512),i=d(i,j,h,g,f[a+7],14,1735328473),g=d(g,i,j,h,f[a+12],20,2368359562),h=e(h,g,i,j,f[a+5],4,4294588738),j=e(j,h,g,i,f[a+8],11,2272392833),i=e(i,j,h,g,f[a+11],16,1839030562),g=e(g,i,j,h,f[a+14],23,4259657740),h=e(h,g,i,j,f[a+1],4,2763975236),j=e(j,h,g,i,f[a+4],11,1272893353),i=e(i,j,h,g,f[a+7],16,4139469664),
|
h=d(h,i,k,j,f[a+9],5,568446438),j=d(j,h,i,k,f[a+14],9,3275163606),k=d(k,j,h,i,f[a+3],14,4107603335),i=d(i,k,j,h,f[a+8],20,1163531501),h=d(h,i,k,j,f[a+13],5,2850285829),j=d(j,h,i,k,f[a+2],9,4243563512),k=d(k,j,h,i,f[a+7],14,1735328473),i=d(i,k,j,h,f[a+12],20,2368359562),h=e(h,i,k,j,f[a+5],4,4294588738),j=e(j,h,i,k,f[a+8],11,2272392833),k=e(k,j,h,i,f[a+11],16,1839030562),i=e(i,k,j,h,f[a+14],23,4259657740),h=e(h,i,k,j,f[a+1],4,2763975236),j=e(j,h,i,k,f[a+4],11,1272893353),k=e(k,j,h,i,f[a+7],16,4139469664),
|
||||||
g=e(g,i,j,h,f[a+10],23,3200236656),h=e(h,g,i,j,f[a+13],4,681279174),j=e(j,h,g,i,f[a+0],11,3936430074),i=e(i,j,h,g,f[a+3],16,3572445317),g=e(g,i,j,h,f[a+6],23,76029189),h=e(h,g,i,j,f[a+9],4,3654602809),j=e(j,h,g,i,f[a+12],11,3873151461),i=e(i,j,h,g,f[a+15],16,530742520),g=e(g,i,j,h,f[a+2],23,3299628645),h=k(h,g,i,j,f[a+0],6,4096336452),j=k(j,h,g,i,f[a+7],10,1126891415),i=k(i,j,h,g,f[a+14],15,2878612391),g=k(g,i,j,h,f[a+5],21,4237533241),h=k(h,g,i,j,f[a+12],6,1700485571),j=k(j,h,g,i,f[a+3],10,2399980690),
|
i=e(i,k,j,h,f[a+10],23,3200236656),h=e(h,i,k,j,f[a+13],4,681279174),j=e(j,h,i,k,f[a+0],11,3936430074),k=e(k,j,h,i,f[a+3],16,3572445317),i=e(i,k,j,h,f[a+6],23,76029189),h=e(h,i,k,j,f[a+9],4,3654602809),j=e(j,h,i,k,f[a+12],11,3873151461),k=e(k,j,h,i,f[a+15],16,530742520),i=e(i,k,j,h,f[a+2],23,3299628645),h=g(h,i,k,j,f[a+0],6,4096336452),j=g(j,h,i,k,f[a+7],10,1126891415),k=g(k,j,h,i,f[a+14],15,2878612391),i=g(i,k,j,h,f[a+5],21,4237533241),h=g(h,i,k,j,f[a+12],6,1700485571),j=g(j,h,i,k,f[a+3],10,2399980690),
|
||||||
i=k(i,j,h,g,f[a+10],15,4293915773),g=k(g,i,j,h,f[a+1],21,2240044497),h=k(h,g,i,j,f[a+8],6,1873313359),j=k(j,h,g,i,f[a+15],10,4264355552),i=k(i,j,h,g,f[a+6],15,2734768916),g=k(g,i,j,h,f[a+13],21,1309151649),h=k(h,g,i,j,f[a+4],6,4149444226),j=k(j,h,g,i,f[a+11],10,3174756917),i=k(i,j,h,g,f[a+2],15,718787259),g=k(g,i,j,h,f[a+9],21,3951481745),h=b(h,q),g=b(g,p),i=b(i,l),j=b(j,v);return(m(h)+m(g)+m(i)+m(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==q)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
|
k=g(k,j,h,i,f[a+10],15,4293915773),i=g(i,k,j,h,f[a+1],21,2240044497),h=g(h,i,k,j,f[a+8],6,1873313359),j=g(j,h,i,k,f[a+15],10,4264355552),k=g(k,j,h,i,f[a+6],15,2734768916),i=g(i,k,j,h,f[a+13],21,1309151649),h=g(h,i,k,j,f[a+4],6,4149444226),j=g(j,h,i,k,f[a+11],10,3174756917),k=g(k,j,h,i,f[a+2],15,718787259),i=g(i,k,j,h,f[a+9],21,3951481745),h=b(h,q),i=b(i,p),k=b(k,l),j=b(j,u);return(m(h)+m(i)+m(k)+m(j)).toLowerCase()};(function(a){a.fn.stupidtable=function(){a(this).on("click","thead th",function(){a(this).stupidsort()})};a.fn.stupidsort=function(){function b(b){var c=0,d;a(b).children("td,th").each(function(){if(c==q)return d=a(this),!1;var b=a(this).attr("colspan");c+=b?Number(b):1});b="undefined"!=typeof d.data("sort-value")?d.data("sort-value"):"undefined"!=typeof d.attr("data-sort-value")?d.attr("data-sort-value"):d.text();switch(m){case "string":case "string-ins":b=String(b).toLowerCase();break;case "int":b=
|
||||||
parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),e=d.children("tbody"),k=e.children("tr"),m=c.attr("data-sort-type");if(m){var f=!0;c.hasClass("sorting-asc")&&(f=!1);var q=0;c.prevAll().each(function(){var b=a(this).attr("colspan");q+=b?Number(b):1});k.sort(function(a,c){var d=f?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});e.append(k);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(f?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
|
parseInt(Number(b));break;case "float":b=Number(b)}return b}var c=a(this),d=c.closest("table"),e=d.children("tbody"),g=e.children("tr"),m=c.attr("data-sort-type");if(m){var f=!0;c.hasClass("sorting-asc")&&(f=!1);var q=0;c.prevAll().each(function(){var b=a(this).attr("colspan");q+=b?Number(b):1});g.sort(function(a,c){var d=f?1:-1,a=b(a),c=b(c);return a>c?1*d:a<c?-1*d:0});e.append(g);d.find("thead th").removeClass("sorting-asc").removeClass("sorting-desc");c.addClass(f?"sorting-asc":"sorting-desc")}}})(jQuery);$(function(){UI.elements={menu:$("nav > .menu"),main:$("main"),header:$("header"),connection:{status:$("#connection"),user_and_host:$("#user_and_host"),msg:$("#message")}};UI.buildMenu();UI.stored.getOpts();try{if("mistLogin"in sessionStorage){var a=JSON.parse(sessionStorage.mistLogin);mist.user.name=a.name;mist.user.password=a.password;mist.user.host=a.host}}catch(b){}location.hash&&(a=decodeURIComponent(location.hash).substring(1).split("@")[0].split("&"),mist.user.name=a[0],a[1]&&(mist.user.host=
|
||||||
a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
|
a[1]));mist.send(function(){$(window).trigger("hashchange")},{},{timeout:5,hide:!0});var c=0;$("body > div.filler").on("scroll",function(){var a=$(this).scrollLeft();a!=c&&UI.elements.header.css("margin-right",-1*a+"px");c=a})});$(window).on("hashchange",function(){var a=decodeURIComponent(location.hash).substring(1).split("@");a[1]||(a[1]="");a=a[1].split("&");""==a[0]&&(a[0]="Overview");UI.showTab(a[0],a[1])});
|
||||||
var otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,b){this.vars[a]=b;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
|
var otherhost={host:!1,https:!1},UI={debug:!1,elements:{},stored:{getOpts:function(){var a=localStorage.stored;a&&(a=JSON.parse(a));$.extend(!0,this.vars,a);return this.vars},saveOpt:function(a,b){this.vars[a]=b;localStorage.stored=JSON.stringify(this.vars);return this.vars},vars:{helpme:!0}},interval:{clear:function(){"undefined"!=typeof this.opts&&(clearInterval(this.opts.id),delete this.opts)},set:function(a,b){this.opts&&log("[interval]","Set called on interval, but an interval is already active.");
|
||||||
this.opts={delay:b,callback:a};this.opts.id=setInterval(a,b)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",
|
this.opts={delay:b,callback:a};this.opts.id=setInterval(a,b)}},returnTab:["Overview"],countrylist:{AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",
|
||||||
|
@ -21,145 +21,146 @@ clearTimeout(this.hiding);delete this.hiding;var c=$(document).height()-$tooltip
|
||||||
"HLS";break;case "html5/video/mp4":b="MP4";break;case "dash/video/mp4":b="DASH";break;case "flash/11":b="HDS";break;case "flash/10":b="RTMP";break;case "flash/7":b="Progressive";break;case "html5/audio/mp3":b="MP3";break;case "html5/video/mp2t":b="TS";break;case "html5/application/vnd.ms-ss":b="Smooth";break;case "html5/text/vtt":b="VTT Subtitles";break;case "html5/text/plain":b="SRT Subtitles";break;case "html5/text/javascript":b="JSON Subtitles"}return b},popup:{element:null,show:function(a){this.element=
|
"HLS";break;case "html5/video/mp4":b="MP4";break;case "dash/video/mp4":b="DASH";break;case "flash/11":b="HDS";break;case "flash/10":b="RTMP";break;case "flash/7":b="Progressive";break;case "html5/audio/mp3":b="MP3";break;case "html5/video/mp2t":b="TS";break;case "html5/application/vnd.ms-ss":b="Smooth";break;case "html5/text/vtt":b="VTT Subtitles";break;case "html5/text/plain":b="SRT Subtitles";break;case "html5/text/javascript":b="JSON Subtitles"}return b},popup:{element:null,show:function(a){this.element=
|
||||||
$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},
|
$("<div>").attr("id","popup").append($("<button>").text("Close").addClass("close").click(function(){UI.popup.element.fadeOut("fast",function(){UI.popup.element.remove();UI.popup.element=null})})).append(a);$("body").append(this.element)}},menu:[{Overview:{},Protocols:{},Streams:{hiddenmenu:{Edit:{},Preview:{},Embed:{}}},Push:{LTSonly:!0},Triggers:{LTSonly:!1},Logs:{},Statistics:{},"Server Stats":{}},{Disconnect:{classes:["red"]}},{Guides:{link:"http://mistserver.org/documentation#Userdocs"},Tools:{submenu:{"Release notes":{link:"http://mistserver.org/documentation#Devdocs"},
|
||||||
"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},ToS:{link:"http://mistserver.org/documentation#Legal"}}}}],buildMenu:function(){function a(a,b){var c=$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in b.classes)c.addClass(b.classes[d]);"LTSonly"in b&&c.addClass("LTSonly");"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||
|
"Mist Shop":{link:"http://mistserver.org/products"},"Email for Help":{},ToS:{link:"http://mistserver.org/documentation#Legal"}}}}],buildMenu:function(){function a(a,b){var c=$("<a>").addClass("button");c.html($("<span>").addClass("plain").text(a)).append($("<span>").addClass("highlighted").text(a));for(var d in b.classes)c.addClass(b.classes[d]);"LTSonly"in b&&c.addClass("LTSonly");"link"in b?c.attr("href",b.link).attr("target","_blank"):"submenu"in b||c.click(function(b){$(this).closest(".menu").hasClass("hide")||
|
||||||
(UI.navto(a),b.stopPropagation())});return c}var b=UI.elements.menu,c;for(c in UI.menu){0<c&&b.append($("<br>"));for(var d in UI.menu[c]){var e=UI.menu[c][d],k=a(d,e);b.append(k);if("submenu"in e){var m=$("<span>").addClass("submenu");k.addClass("arrowdown").append(m);for(var f in e.submenu)m.append(a(f,e.submenu[f]))}else if("hiddenmenu"in e)for(f in m=$("<span>").addClass("hiddenmenu"),k.append(m),e.hiddenmenu)m.append(a(f,e.hiddenmenu[f]))}}c=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");
|
(UI.navto(a),b.stopPropagation())});return c}var b=UI.elements.menu,c;for(c in UI.menu){0<c&&b.append($("<br>"));for(var d in UI.menu[c]){var e=UI.menu[c][d],g=a(d,e);b.append(g);if("submenu"in e){var m=$("<span>").addClass("submenu");g.addClass("arrowdown").append(m);for(var f in e.submenu)m.append(a(f,e.submenu[f]))}else if("hiddenmenu"in e)for(f in m=$("<span>").addClass("hiddenmenu"),g.append(m),e.hiddenmenu)m.append(a(f,e.hiddenmenu[f]))}}c=$("<div>").attr("id","ih_button").text("?").click(function(){$("body").toggleClass("helpme");
|
||||||
UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");b.after(c).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,b){if("capabilities"in mist.data){var c=mist.data.capabilities[a];return b in c?c[b]:b+".exe"in c?c[b+".exe"]:!1}throw"Request capabilities first";
|
UI.stored.saveOpt("helpme",$("body").hasClass("helpme"))}).attr("title","Click to toggle the display of integrated help");UI.stored.getOpts().helpme&&$("body").addClass("helpme");b.after(c).after($("<div>").addClass("separator"))},findInput:function(a){return this.findInOutput("inputs",a)},findOutput:function(a){return this.findInOutput("connectors",a)},findInOutput:function(a,b){if("capabilities"in mist.data){var c=mist.data.capabilities[a];return b in c?c[b]:b+".exe"in c?c[b+".exe"]:!1}throw"Request capabilities first";
|
||||||
},buildUI:function(a){var b=$("<div>").addClass("input_container"),c;for(c in a){var d=a[c];if(d instanceof jQuery)b.append(d);else if("help"==d.type){var e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));b.append(e);if("classes"in d)for(var k in d.classes)e.addClass(d.classes[k])}else if("text"==d.type)b.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)b.append(d.custom);else if("buttons"==
|
},buildUI:function(a){var b=$("<div>").addClass("input_container"),c;for(c in a){var d=a[c];if(d instanceof jQuery)b.append(d);else if("help"==d.type){var e=$("<span>").addClass("text_container").append($("<span>").addClass("description").append(d.help));b.append(e);if("classes"in d)for(var g in d.classes)e.addClass(d.classes[g])}else if("text"==d.type)b.append($("<span>").addClass("text_container").append($("<span>").addClass("text").append(d.text)));else if("custom"==d.type)b.append(d.custom);else if("buttons"==
|
||||||
d.type)for(k in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in d&&e.css(d.css),b.append(e),d.buttons){var m=d.buttons[k],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);if("classes"in m)for(var q in m.classes)f.addClass(m.classes[q]);e.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),b=!1;a.find(".hasValidate").each(function(){if(b=
|
d.type)for(g in e=$("<span>").addClass("button_container").on("keydown",function(a){a.stopPropagation()}),"css"in d&&e.css(d.css),b.append(e),d.buttons){var m=d.buttons[g],f=$("<button>").text(m.label).data("opts",m);"css"in m&&f.css(m.css);if("classes"in m)for(var q in m.classes)f.addClass(m.classes[q]);e.append(f);switch(m.type){case "cancel":f.addClass("cancel").click(m["function"]);break;case "save":f.addClass("save").click(function(){var a=$(this).closest(".input_container"),b=!1;a.find(".hasValidate").each(function(){if(b=
|
||||||
$(this).data("validate")(this,!0))return!1});b||(a.find(".isSetting").each(function(){var a=$(this).getval(),b=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete b.main[b.index],!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");b.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html("label"in d?d.label+
|
$(this).data("validate")(this,!0))return!1});b||(a.find(".isSetting").each(function(){var a=$(this).getval(),b=$(this).data("pointer");if(""==a)if("default"in $(this).data("opts"))a=$(this).data("opts")["default"];else return delete b.main[b.index],!0;b.main[b.index]=a}),(a=$(this).data("opts")["function"])&&a(this))});break;default:f.click(m["function"])}}else{m=$("<label>").addClass("UIelement");b.append(m);"css"in d&&m.css(d.css);m.append($("<span>").addClass("label").html("label"in d?d.label+
|
||||||
":":""));f=$("<span>").addClass("field_container");m.append(f);switch(d.type){case "password":e=$("<input>").attr("type","password");break;case "int":e=$("<input>").attr("type","number");"min"in d&&e.attr("min",d.min);"max"in d&&e.attr("max",d.min);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":e=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],
|
":":""));f=$("<span>").addClass("field_container");m.append(f);switch(d.type){case "password":e=$("<input>").attr("type","password");break;case "int":e=$("<input>").attr("type","number");"min"in d&&e.attr("min",d.min);"max"in d&&e.attr("max",d.min);"validate"in d?d.validate.push("int"):d.validate=["int"];break;case "span":e=$("<span>");break;case "debug":d.select=[["","Default"],[0,"0 - All debugging messages disabled"],[1,"1 - Messages about failed operations"],[2,"2 - Previous level, and error messages"],
|
||||||
[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":e=$("<select>");for(k in d.select){var p=$("<option>");"string"==typeof d.select[k]?
|
[3,"3 - Previous level, and warning messages"],[4,"4 - Previous level, and status messages for development"],[5,"5 - Previous level, and more status messages for development"],[6,"6 - Previous level, and verbose debugging messages"],[7,"7 - Previous level, and very verbose debugging messages"],[8,"8 - Report everything in extreme detail"],[9,"9 - Report everything in insane detail"],[10,"10 - All messages enabled"]];case "select":e=$("<select>");for(g in d.select){var p=$("<option>");"string"==typeof d.select[g]?
|
||||||
p.text(d.select[k]):p.val(d.select[k][0]).text(d.select[k][1]);e.append(p)}break;case "textarea":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");m.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in d&&e.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":e=
|
p.text(d.select[g]):p.val(d.select[g][0]).text(d.select[g][1]);e.append(p)}break;case "textarea":e=$("<textarea>").on("keydown",function(a){a.stopPropagation()});break;case "checkbox":e=$("<input>").attr("type","checkbox");break;case "hidden":e=$("<input>").attr("type","hidden");m.hide();break;case "email":e=$("<input>").attr("type","email").attr("autocomplete","on").attr("required","");break;case "browse":e=$("<input>").attr("type","text");"filetypes"in d&&e.data("filetypes",d.filetypes);break;case "geolimited":case "hostlimited":e=
|
||||||
$("<input>").attr("type","hidden");break;case "radioselect":e=$("<div>").addClass("radioselect");for(c in d.radioselect){var l=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&l.prop("disabled",!0);p=$("<label>").append(l).append($("<span>").html(d.radioselect[c][1]));e.append(p);if(2<d.radioselect[c].length)for(k in l=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),
|
$("<input>").attr("type","hidden");break;case "radioselect":e=$("<div>").addClass("radioselect");for(c in d.radioselect){var l=$("<input>").attr("type","radio").val(d.radioselect[c][0]).attr("name",d.label);("LTSonly"in d&&!mist.data.LTS||d.readonly)&&l.prop("disabled",!0);p=$("<label>").append(l).append($("<span>").html(d.radioselect[c][1]));e.append(p);if(2<d.radioselect[c].length)for(g in l=$("<select>").change(function(){$(this).parent().find("input[type=radio]:enabled").prop("checked","true")}),
|
||||||
p.append(l),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&l.prop("disabled",!0),d.radioselect[c][2])p=$("<option>"),l.append(p),d.radioselect[c][2][k]instanceof Array?p.val(d.radioselect[c][2][k][0]).html(d.radioselect[c][2][k][1]):p.html(d.radioselect[c][2][k])}break;case "checklist":e=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type",
|
p.append(l),("LTSonly"in d&&!mist.data.LTS||d.readonly)&&l.prop("disabled",!0),d.radioselect[c][2])p=$("<option>"),l.append(p),d.radioselect[c][2][g]instanceof Array?p.val(d.radioselect[c][2][g][0]).html(d.radioselect[c][2][g][1]):p.html(d.radioselect[c][2][g])}break;case "checklist":e=$("<div>").addClass("checkcontainer");$controls=$("<div>").addClass("controls");$checklist=$("<div>").addClass("checklist");e.append($controls).append($checklist);$controls.append($("<label>").text("All").prepend($("<input>").attr("type",
|
||||||
"checkbox").click(function(){$(this).is(":checked")?$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!0):$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!1)})));for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[c][0])));break;case "DOMfield":e=d.DOMfield;break;default:e=
|
"checkbox").click(function(){$(this).is(":checked")?$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!0):$(this).closest(".checkcontainer").find("input[type=checkbox]").prop("checked",!1)})));for(c in d.checklist)"string"==typeof d.checklist[c]&&(d.checklist[c]=[d.checklist[c],d.checklist[c]]),$checklist.append($("<label>").text(d.checklist[c][1]).prepend($("<input>").attr("type","checkbox").attr("name",d.checklist[c][0])));break;case "DOMfield":e=d.DOMfield;break;default:e=
|
||||||
$("<input>").attr("type","text")}e.addClass("field").data("opts",d);"pointer"in d&&e.attr("name",d.pointer.index);f.append(e);if("classes"in d)for(k in d.classes)e.addClass(d.classes[k]);"placeholder"in d&&e.attr("placeholder",d.placeholder);"default"in d&&e.attr("placeholder",d["default"]);"unit"in d&&f.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in d&&f.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",
|
$("<input>").attr("type","text")}e.addClass("field").data("opts",d);"pointer"in d&&e.attr("name",d.pointer.index);f.append(e);if("classes"in d)for(g in d.classes)e.addClass(d.classes[g]);"placeholder"in d&&e.attr("placeholder",d.placeholder);"default"in d&&e.attr("placeholder",d["default"]);"unit"in d&&f.append($("<span>").addClass("unit").html(d.unit));"readonly"in d&&(e.attr("readonly","readonly"),e.click(function(){$(this).select()}));"qrcode"in d&&f.append($("<span>").addClass("unit").html($("<button>").text("QR").on("keydown",
|
||||||
function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&f.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),
|
function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),b=$("<div>").addClass("qrcode");UI.popup.show($("<span>").addClass("qr_container").append($("<p>").text(a)).append(b));b.qrcode({text:a,size:Math.min(b.width(),b.height())})})));"clipboard"in d&&document.queryCommandSupported("copy")&&f.append($("<span>").addClass("unit").html($("<button>").text("Copy").on("keydown",function(a){a.stopPropagation()}).click(function(){var a=String($(this).closest(".field_container").find(".field").getval()),
|
||||||
b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var f=$(this);setTimeout(function(){f.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&e.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(f.addClass("LTSonly"),e.prop("disabled",!0));switch(d.type){case "browse":l=$("<div>").addClass("grouper").append(m);
|
b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.select();var c=false;try{c=document.execCommand("copy")}catch(d){}if(c){$(this).text("Copied to clipboard!");document.body.removeChild(b);var g=$(this);setTimeout(function(){g.text("Copy")},5E3)}else{document.body.removeChild(b);alert("Failed to copy:\n"+a)}})));"rows"in d&&e.attr("rows",d.rows);"LTSonly"in d&&!mist.data.LTS&&(f.addClass("LTSonly"),e.prop("disabled",!0));switch(d.type){case "browse":l=$("<div>").addClass("grouper").append(m);
|
||||||
b.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});f.append(l);l.click(function(){function a(b){k.text("Loading..");mist.send(function(a){m.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");k.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var e=a.browse.subdirectories[b];k.append(l.clone(true).attr("title",m.text()+p+e).text(e))}}if(a.browse.files){a.browse.files.sort();
|
b.append(l);l=$("<button>").text("Browse").on("keydown",function(a){a.stopPropagation()});f.append(l);l.click(function(){function a(b){m.text("Loading..");mist.send(function(a){f.text(a.browse.path[0]);mist.data.LTS&&d.setval(a.browse.path[0]+"/");m.html(l.clone(true).text("..").attr("title","Folder up"));if(a.browse.subdirectories){a.browse.subdirectories.sort();for(var b in a.browse.subdirectories){var e=a.browse.subdirectories[b];m.append(l.clone(true).attr("title",f.text()+q+e).text(e))}}if(a.browse.files){a.browse.files.sort();
|
||||||
for(b in a.browse.files){var e=a.browse.files[b],h=m.text()+p+e,e=$("<a>").text(e).addClass("file").attr("title",h);k.append(e);if(n){var v=true,q;for(q in n)if(typeof n[q]!="undefined"&&mist.inputMatch(n[q],h)){v=false;break}v&&e.hide()}e.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);f.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",
|
for(b in a.browse.files){var e=a.browse.files[b],h=f.text()+q+e,e=$("<a>").text(e).addClass("file").attr("title",h);m.append(e);if(p){var n=true,u;for(u in p)if(typeof p[u]!="undefined"&&mist.inputMatch(p[u],h)){n=false;break}n&&e.hide()}e.click(function(){var a=$(this).attr("title");d.setval(a).removeAttr("readonly").css("opacity",1);g.show();c.remove()})}}},{browse:b})}var b=$(this).closest(".grouper"),c=$("<div>").addClass("browse_container"),d=b.find(".field").attr("readonly","readonly").css("opacity",
|
||||||
0.5),f=$(this),e=$("<button>").text("Stop browsing").click(function(){f.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),m=$("<span>").addClass("field"),k=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),n=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(m).append(e))).append(k);var p="/";mist.data.config.version.indexOf("indows")>
|
0.5),g=$(this),e=$("<button>").text("Stop browsing").click(function(){g.show();c.remove();d.removeAttr("readonly").css("opacity",1)}),f=$("<span>").addClass("field"),m=$("<div>").addClass("browse_contents"),l=$("<a>").addClass("folder"),p=d.data("filetypes");b.append(c);c.append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Current folder:")).append($("<span>").addClass("field_container").append(f).append(e))).append(m);var q="/";mist.data.config.version.indexOf("indows")>
|
||||||
-1&&(p="\\");l.click(function(){var b=m.text()+p+$(this).text();a(b)});b=d.getval();e=b.split("://");e.length>1&&(b=e[0]=="file"?e[1]:"");b=b.split(p);b.pop();b=b.join(p);f.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:e};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":l.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));
|
-1&&(q="\\");l.click(function(){var b=f.text()+q+$(this).text();a(b)});b=d.getval();e=b.split("://");e.length>1&&(b=e[0]=="file"?e[1]:"");b=b.split(q);b.pop();b=b.join(q);g.hide();a(b)});break;case "geolimited":case "hostlimited":l={field:e};l.blackwhite=$("<select>").append($("<option>").val("-").text("Blacklist")).append($("<option>").val("+").text("Whitelist"));l.values=$("<span>").addClass("limit_value_list");switch(d.type){case "geolimited":l.prototype=$("<select>").append($("<option>").val("").text("[Select a country]"));
|
||||||
for(c in UI.countrylist)l.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":l.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}l.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});
|
for(c in UI.countrylist)l.prototype.append($("<option>").val(c).html(UI.countrylist[c]));break;case "hostlimited":l.prototype=$("<input>").attr("type","text").attr("placeholder","type a host")}l.prototype.on("change keyup",function(){$(this).closest(".field_container").data("subUI").blackwhite.trigger("change")});l.blackwhite.change(function(){var a=$(this).closest(".field_container").data("subUI"),b=[],c=false;a.values.children().each(function(){c=$(this).val();c!=""?b.push(c):$(this).remove()});
|
||||||
a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in d&&!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));f.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in d&&(e.data("pointer",d.pointer).addClass("isSetting"),l=d.pointer.main[d.pointer.index],"undefined"!=l&&e.setval(l));"value"in d&&e.setval(d.value);
|
a.values.append(a.prototype.clone(true));b.length>0?a.field.val($(this).val()+b.join(" ")):a.field.val("");a.field.trigger("change")});"LTSonly"in d&&!mist.data.LTS&&(l.blackwhite.prop("disabled",!0),l.prototype.prop("disabled",!0));l.values.append(l.prototype.clone(!0));f.data("subUI",l).addClass("limit_list").append(l.blackwhite).append(l.values)}"pointer"in d&&(e.data("pointer",d.pointer).addClass("isSetting"),l=d.pointer.main[d.pointer.index],"undefined"!=l&&e.setval(l));"value"in d&&e.setval(d.value);
|
||||||
if("datalist"in d)for(c in l="datalist_"+c+MD5(e[0].outerHTML),e.attr("list",l),l=$("<datalist>").attr("id",l),f.append(l),d.datalist)l.append($("<option>").val(d.datalist[c]));f=$("<span>").addClass("help_container");m.append(f);"help"in d&&(f.append($("<span>").addClass("ih_balloon").html(d.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(k in d.validate){l=
|
if("datalist"in d)for(c in l="datalist_"+c+MD5(e[0].outerHTML),e.attr("list",l),l=$("<datalist>").attr("id",l),f.append(l),d.datalist)l.append($("<option>").val(d.datalist[c]));f=$("<span>").addClass("help_container");m.append(f);"help"in d&&(f.append($("<span>").addClass("ih_balloon").html(d.help)),e.on("focus mouseover",function(){$(this).closest("label").addClass("active")}).on("blur mouseout",function(){$(this).closest("label").removeClass("active")}));if("validate"in d){m=[];for(g in d.validate){l=
|
||||||
d.validate[k];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":l=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};
|
d.validate[g];if("function"!=typeof l)switch(l){case "required":l=function(a){return a==""?{msg:"This is a required field.",classes:["red"]}:false};break;case "int":l=function(a,b){var c=$(b).data("opts");if(!$(b)[0].validity.valid){var d=[];"min"in c&&d.push(" greater than or equal to "+c.min);"max"in c&&d.push(" smaller than or equal to "+c.max);return{msg:"Please enter an integer"+d.join(" and")+".",classes:["red"]}}if(parseInt(Number(a))!=a)return{msg:"Please enter an integer.",classes:["red"]}};
|
||||||
break;case "streamname":l=function(a,b){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",
|
break;case "streamname":l=function(a,b){if(!isNaN(a.charAt(0)))return{msg:"The first character may not be a number.",classes:["red"]};if(a.toLowerCase()!=a)return{msg:"Uppercase letters are not allowed.",classes:["red"]};if(a.replace(/[^\da-z_]/g,"")!=a)return{msg:"Special characters (except for underscores) are not allowed.",classes:["red"]};if("streams"in mist.data&&a in mist.data.streams&&$(b).data("pointer").main.name!=a)return{msg:"This streamname already exists.<br>If you want to edit an existing stream, please click edit on the the streams tab.",
|
||||||
classes:["red"]}};break;default:l=function(){}}m.push(l)}e.data("validate_functions",m).data("help_container",f).data("validate",function(a,b){var c=$(a).getval(),d=$(a).data("validate_functions"),f=$(a).data("help_container");f.find(".err_balloon").remove();for(var e in d){var m=d[e](c,a);if(m){$err=$("<span>").addClass("err_balloon").html(m.msg);for(var k in m.classes)$err.addClass(m.classes[k]);f.prepend($err);b&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",
|
classes:["red"]}};break;default:l=function(){}}m.push(l)}e.data("validate_functions",m).data("help_container",f).data("validate",function(a,b){var c=$(a).getval(),d=$(a).data("validate_functions"),e=$(a).data("help_container");e.find(".err_balloon").remove();for(var g in d){var f=d[g](c,a);if(f){$err=$("<span>").addClass("err_balloon").html(f.msg);for(var m in f.classes)$err.addClass(f.classes[m]);e.prepend($err);b&&$(a).focus();return true}}return false}).addClass("hasValidate").on("change keyup",
|
||||||
function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in d&&(e.on("change keyup",d["function"]),e.trigger("change"))}}b.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger("click");break;case 27:$(this).find("button.cancel").first().trigger("click")}});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+
|
function(){$(this).data("validate")($(this))});""!=e.getval()&&e.trigger("change")}"function"in d&&(e.on("change keyup",d["function"]),e.trigger("change"))}}b.on("keydown",function(a){switch(a.which){case 13:$(this).find("button.save").first().trigger("click");break;case 27:$(this).find("button.cancel").first().trigger("click")}});return b},buildVheaderTable:function(a){var b=$("<table>").css("margin","0.2em"),c=$("<tr>").addClass("header").append($("<td>").addClass("vheader").attr("rowspan",a.labels.length+
|
||||||
1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var e in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[e]?" ":a.labels[e]+":")));for(var k in a.content)for(e in c.append($("<td>").html(a.content[k].header)),a.content[k].body)d[e].append($("<td>").html(a.content[k].body[e]));b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),
|
1).append($("<span>").text(a.vheader))),d=[];c.append($("<td>"));for(var e in a.labels)d.push($("<tr>").append($("<td>").html(""==a.labels[e]?" ":a.labels[e]+":")));for(var g in a.content)for(e in c.append($("<td>").html(a.content[g].header)),a.content[g].body)d[e].append($("<td>").html(a.content[g].body[e]));b.append($("<tbody>").append(c).append(d));return b},plot:{addGraph:function(a,b){var c={id:a.id,xaxis:a.xaxis,datasets:[],elements:{cont:$("<div>").addClass("graph"),plot:$("<div>").addClass("plot"),
|
||||||
legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend);b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var e=a[c].datasets[d];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":b.totals.push({fields:[e.datatype],end:-15});break;case "stream":b.totals.push({fields:[e.datatype],
|
legend:$("<div>").addClass("legend").attr("draggable","true")}};UI.draggable(c.elements.legend);c.elements.cont.append(c.elements.plot).append(c.elements.legend);b.append(c.elements.cont);return c},go:function(a){if(!(1>Object.keys(a).length)){var b={totals:[],clients:[]},c;for(c in a)for(var d in a[c].datasets){var e=a[c].datasets[d];switch(e.datatype){case "clients":case "upbps":case "downbps":switch(e.origin[0]){case "total":b.totals.push({fields:[e.datatype],end:-15});break;case "stream":b.totals.push({fields:[e.datatype],
|
||||||
streams:[e.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":b.capabilities={}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var e=[],p;for(p in c.datasets){var l=c.datasets[p];l.display&&(l.getdata(),
|
streams:[e.origin[1]],end:-15});break;case "protocol":b.totals.push({fields:[e.datatype],protocols:[e.origin[1]],end:-15})}break;case "cpuload":case "memload":b.capabilities={}}}0==b.totals.length&&delete b.totals;0==b.clients.length&&delete b.clients;mist.send(function(){for(var b in a){var c=a[b];if(1>c.datasets.length){c.elements.plot.html("");c.elements.legend.html("");break}switch(c.xaxis){case "time":var d=[];c.yaxes={};var e=[],p;for(p in c.datasets){var l=c.datasets[p];l.display&&(l.getdata(),
|
||||||
l.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),c.yaxes[l.yaxistype]=d.length),l.yaxis=c.yaxes[l.yaxistype],e.push(l))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,e,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right",
|
l.yaxistype in c.yaxes||(d.push(UI.plot.yaxes[l.yaxistype]),c.yaxes[l.yaxistype]=d.length),l.yaxis=c.yaxes[l.yaxistype],e.push(l))}d[0]&&(d[0].color=0);c.plot=$.plot(c.elements.plot,e,{legend:{show:!1},xaxis:UI.plot.xaxes[c.xaxis],yaxes:d,grid:{hoverable:!0,borderWidth:{top:0,right:0,bottom:1,left:1},color:"black",backgroundColor:{colors:["rgba(0,0,0,0)","rgba(0,0,0,0.025)"]}},crosshair:{mode:"x"}});d=$("<table>").addClass("legend-list").addClass("nolay").html($("<tr>").html($("<td>").html($("<h3>").text(c.id))).append($("<td>").css("padding-right",
|
||||||
"2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var v=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a==
|
"2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").data("opts",c).text("X").addClass("close").click(function(){var b=$(this).data("opts");if(confirm("Are you sure you want to remove "+b.id+"?")){b.elements.cont.remove();var c=$(".graph_ids option:contains("+b.id+")"),d=c.parent();c.remove();UI.plot.del(b.id);delete a[b.id];d.trigger("change");UI.plot.go(a)}}))));c.elements.legend.html(d);var u=function(a){var b=c.elements.legend.find(".value"),d=1;if(typeof a==
|
||||||
"undefined")b.eq(0).html("Latest:");else{var e=c.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var f in c.datasets){var h=" ";if(c.datasets[f].display){var e=UI.plot.yaxes[c.datasets[f].yaxistype].tickFormatter,k=c.datasets[f].data;if(a)for(var l in k){if(k[l][0]==a){h=e(k[l][1]);break}if(k[l][0]>a){if(l!=0){h=k[l];k=k[l-1];h=e(h[1]+(a-h[0])*(k[1]-h[1])/(k[0]-h[0]))}break}}else h=e(c.datasets[f].data[c.datasets[f].data.length-1][1])}b.eq(d).html(h);
|
"undefined")b.eq(0).html("Latest:");else{var e=c.plot.getXAxes()[0],a=Math.min(e.max,a),a=Math.max(e.min,a);b.eq(0).html(UI.format.time(a/1E3))}for(var g in c.datasets){var f=" ";if(c.datasets[g].display){var e=UI.plot.yaxes[c.datasets[g].yaxistype].tickFormatter,h=c.datasets[g].data;if(a)for(var l in h){if(h[l][0]==a){f=e(h[l][1]);break}if(h[l][0]>a){if(l!=0){f=h[l];h=h[l-1];f=e(f[1]+(a-f[0])*(h[1]-f[1])/(h[0]-f[0]))}break}}else f=e(c.datasets[g].data[c.datasets[g].data.length-1][1])}b.eq(d).html(f);
|
||||||
d++}};c.plot.getOptions();for(p in c.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",c.datasets[p].color)).append(c.datasets[p].label))).append($("<td>").css("padding-right",
|
d++}};c.plot.getOptions();for(p in c.datasets)e=$("<input>").attr("type","checkbox").data("index",p).data("graph",c).click(function(){var a=$(this).data("graph");$(this).is(":checked")?a.datasets[$(this).data("index")].display=true:a.datasets[$(this).data("index")].display=false;var b={};b[a.id]=a;UI.plot.go(b)}),c.datasets[p].display&&e.attr("checked","checked"),d.append($("<tr>").html($("<td>").html($("<label>").html(e).append($("<div>").addClass("series-color").css("background-color",c.datasets[p].color)).append(c.datasets[p].label))).append($("<td>").css("padding-right",
|
||||||
"2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",p).data("graph",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];
|
"2em").css("text-align","right").html($("<span>").addClass("value")).append($("<button>").text("X").addClass("close").data("index",p).data("graph",c).click(function(){var b=$(this).data("index"),c=$(this).data("graph");if(confirm("Are you sure you want to remove "+c.datasets[b].label+" from "+c.id+"?")){c.datasets.splice(b,1);if(c.datasets.length==0){c.elements.cont.remove();var b=$(".graph_ids option:contains("+c.id+")"),d=b.parent();b.remove();d.trigger("change");UI.plot.del(c.id);delete a[c.id];
|
||||||
UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));v();var h=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=h){v(b.x);h=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],
|
UI.plot.go(a)}else{UI.plot.save(c);b={};b[c.id]=c;UI.plot.go(b)}}}))));u();var h=!1;c.elements.plot.on("plothover",function(a,b,c){if(b.x!=h){u(b.x);h=b.x}if(c){a=$("<span>").append($("<h3>").text(c.series.label).prepend($("<div>").addClass("series-color").css("background-color",c.series.color))).append($("<table>").addClass("nolay").html($("<tr>").html($("<td>").text("Time:")).append($("<td>").html(UI.format.dateTime(c.datapoint[0]/1E3,"long")))).append($("<tr>").html($("<td>").text("Value:")).append($("<td>").html(c.series.yaxis.tickFormatter(c.datapoint[1],
|
||||||
c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){v()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general),
|
c.series.yaxis)))));UI.tooltip.show(b,a.children())}else UI.tooltip.hide()}).on("mouseout",function(){u()})}}},b)}},save:function(a){var b={id:a.id,xaxis:a.xaxis,datasets:[]},c;for(c in a.datasets)b.datasets.push({origin:a.datasets[c].origin,datatype:a.datasets[c].datatype});a=mist.stored.get().graphs||{};a[b.id]=b;mist.stored.set("graphs",a)},del:function(a){var b=mist.stored.get().graphs||{};delete b[a];mist.stored.set("graphs",b)},datatype:{getOptions:function(a){var b=$.extend(!0,{},UI.plot.datatype.templates.general),
|
||||||
c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,c,a),a=$.extend(!0,b,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var b=[],d;for(d in a.basecolor)c=a.basecolor[d],c+=50*(0.5-Math.random()),c=Math.round(c),c=Math.min(255,Math.max(0,c)),b.push(c);a.color="rgb("+b.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",
|
c=$.extend(!0,{},UI.plot.datatype.templates[a.datatype]),a=$.extend(!0,c,a),a=$.extend(!0,b,a);switch(a.origin[0]){case "total":switch(a.datatype){case "cpuload":case "memload":break;default:a.label+=" (total)"}break;case "stream":case "protocol":a.label+=" ("+a.origin[1]+")"}var b=[],d;for(d in a.basecolor)c=a.basecolor[d],c+=50*(0.5-Math.random()),c=Math.round(c),c=Math.min(255,Math.max(0,c)),b.push(c);a.color="rgb("+b.join(",")+")";return a},templates:{general:{display:!0,datatype:"general",label:"",
|
||||||
yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,
|
yaxistype:"amount",data:[],lines:{show:!0},points:{show:!1},getdata:function(){var a=mist.data.totals["stream"==this.origin[0]?this.origin[1]:"all_streams"]["protocol"==this.origin[0]?this.origin[1]:"all_protocols"][this.datatype];return this.data=a}},cpuload:{label:"CPU use",yaxistype:"percentage",basecolor:[237,194,64],cores:1,getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,
|
||||||
mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",
|
mist.data.capabilities.cpu_use/10]);return this.data}},memload:{label:"Memory load",yaxistype:"percentage",basecolor:[175,216,248],getdata:function(){var a=!1,b;for(b in this.data)this.data[b][0]<1E3*(mist.data.config.time-600)&&(a=b);!1!==a&&this.data.splice(0,Number(a)+1);this.data.push([1E3*mist.data.config.time,mist.data.capabilities.load.memory]);return this.data}},clients:{label:"Connections",basecolor:[203,75,75]},upbps:{label:"Bandwidth up",yaxistype:"bytespersec",basecolor:[77,167,77]},downbps:{label:"Bandwidth down",
|
||||||
yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,
|
yaxistype:"bytespersec",basecolor:[148,64,237]}}},yaxes:{percentage:{name:"percentage",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.addUnit(UI.format.number(a),"%")},tickLength:0,min:0,max:100},amount:{name:"amount",color:"black",tickColor:0,tickDecimals:0,tickFormatter:function(a){return UI.format.number(a)},tickLength:0,min:0},bytespersec:{name:"bytespersec",color:"black",tickColor:0,tickDecimals:1,tickFormatter:function(a){return UI.format.bytes(a,!0)},tickLength:0,
|
||||||
ticks:function(a){var b=0.3*Math.sqrt($(".graph").first().height()),b=(a.max-a.min)/b,c=Math.floor(Math.log(Math.abs(b))/Math.log(1024)),d=b/Math.pow(1024,c),e=-Math.floor(Math.log(d)/Math.LN10),k=a.tickDecimals;null!=k&&e>k&&(e=k);var m=Math.pow(10,-e),d=d/m,f;if(1.5>d)f=1;else if(3>d){if(f=2,2.25<d&&(null==k||e+1<=k))f=2.5,++e}else f=7.5>d?5:10;f=f*m*Math.pow(1024,c);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=b;a.tickDecimals=Math.max(0,null!=k?k:e);a.tickSize=f;b=[];c=a.tickSize*
|
ticks:function(a){var b=0.3*Math.sqrt($(".graph").first().height()),b=(a.max-a.min)/b,c=Math.floor(Math.log(Math.abs(b))/Math.log(1024)),d=b/Math.pow(1024,c),e=-Math.floor(Math.log(d)/Math.LN10),g=a.tickDecimals;null!=g&&e>g&&(e=g);var m=Math.pow(10,-e),d=d/m,f;if(1.5>d)f=1;else if(3>d){if(f=2,2.25<d&&(null==g||e+1<=g))f=2.5,++e}else f=7.5>d?5:10;f=f*m*Math.pow(1024,c);null!=a.minTickSize&&f<a.minTickSize&&(f=a.minTickSize);a.delta=b;a.tickDecimals=Math.max(0,null!=g?g:e);a.tickSize=f;b=[];c=a.tickSize*
|
||||||
Math.floor(a.min/a.tickSize);e=0;k=Number.NaN;do m=k,k=c+e*a.tickSize,b.push(k),++e;while(k<a.max&&k!=m);return b},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var c=$(this).data("dragstart"),d=c.ele.x-c.click.x+a.originalEvent.pageX,
|
Math.floor(a.min/a.tickSize);e=0;g=Number.NaN;do m=g,g=c+e*a.tickSize,b.push(g),++e;while(g<a.max&&g!=m);return b},min:0}},xaxes:{time:{name:"time",mode:"time",timezone:"browser",ticks:5}}},draggable:function(a){a.attr("draggable",!0);a.on("dragstart",function(a){$(this).css("opacity",0.4).data("dragstart",{click:{x:a.originalEvent.pageX,y:a.originalEvent.pageY},ele:{x:this.offsetLeft,y:this.offsetTop}})}).on("dragend",function(a){var c=$(this).data("dragstart"),d=c.ele.x-c.click.x+a.originalEvent.pageX,
|
||||||
a=c.ele.y-c.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,b){var c=new Date(1E3*a),d=[];d.push(("0"+c.getHours()).slice(-2));d.push(("0"+c.getMinutes()).slice(-2));"short"!=b&&d.push(("0"+c.getSeconds()).slice(-2));return d.join(":")},date:function(a,b){var c=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==b&&e.push(d[c.getDay()]);e.push(("0"+c.getDate()).slice(-2));
|
a=c.ele.y-c.click.y+a.originalEvent.pageY;$(this).css({opacity:1,top:a,left:d,right:"auto",bottom:"auto"})});a.parent().on("dragleave",function(){})},format:{time:function(a,b){var c=new Date(1E3*a),d=[];d.push(("0"+c.getHours()).slice(-2));d.push(("0"+c.getMinutes()).slice(-2));"short"!=b&&d.push(("0"+c.getSeconds()).slice(-2));return d.join(":")},date:function(a,b){var c=new Date(1E3*a),d="Sun Mon Tue Wed Thu Fri Sat".split(" "),e=[];"long"==b&&e.push(d[c.getDay()]);e.push(("0"+c.getDate()).slice(-2));
|
||||||
e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[c.getMonth()]);"short"!=b&&e.push(c.getFullYear());return e.join(" ")},dateTime:function(a,b){return UI.format.date(a,b)+", "+UI.format.time(a,b)},duration:function(a){var b=[0.001,1E3,60,60,24,7,1E9],c="ms sec min hr day week".split(" "),d={},e;for(e in c){var a=a/b[e],k=Math.round(a%b[Number(e)+1]);d[c[e]]=k;a-=k}var m;for(e=c.length-1;0<=e;e--)if(0<d[c[e]]){m=c[e];break}b=$("<span>");switch(m){case "week":b.append(UI.format.addUnit(d.week,
|
e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[c.getMonth()]);"short"!=b&&e.push(c.getFullYear());return e.join(" ")},dateTime:function(a,b){return UI.format.date(a,b)+", "+UI.format.time(a,b)},duration:function(a){var b=[0.001,1E3,60,60,24,7,1E9],c="ms sec min hr day week".split(" "),d={},e;for(e in c){var a=a/b[e],g=Math.round(a%b[Number(e)+1]);d[c[e]]=g;a-=g}var m;for(e=c.length-1;0<=e;e--)if(0<d[c[e]]){m=c[e];break}b=$("<span>");switch(m){case "week":b.append(UI.format.addUnit(d.week,
|
||||||
"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":b.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:b.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return b[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var b=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*b)/b;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=
|
"wks, ")).append(UI.format.addUnit(d.day,"days"));break;case "day":b.append(UI.format.addUnit(d.day,"days, ")).append(UI.format.addUnit(d.hr,"hrs"));break;default:b.append([("0"+d.hr).slice(-2),("0"+d.min).slice(-2),("0"+d.sec).slice(-2)+(d.ms?"."+d.ms:"")].join(":"))}return b[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var b=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)-1),a=Math.round(a*b)/b;if(1E4<a){number=a.toString().split(".");for(a=/(\d+)(\d{3})/;a.test(number[0]);)number[0]=
|
||||||
number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var b=$("<span>");if("undefined"==typeof a.online)return b.text("Unknown, checking.."),"undefined"!=typeof a.error&&b.text(a.error),b;switch(a.online){case -1:b.text("Enabling");break;case 0:b.text("Unavailable").addClass("red");break;case 1:b.text("Active").addClass("green");break;case 2:b.text("Standby").addClass("orange");break;default:b.text(a.online)}"error"in a&&b.text(a.error);return b},capital:function(a){return a.charAt(0).toUpperCase()+
|
number[0].replace(a,"$1 $2");a=number.join(".")}return a},status:function(a){var b=$("<span>");if("undefined"==typeof a.online)return b.text("Unknown, checking.."),"undefined"!=typeof a.error&&b.text(a.error),b;switch(a.online){case -1:b.text("Enabling");break;case 0:b.text("Unavailable").addClass("red");break;case 1:b.text("Active").addClass("green");break;case 2:b.text("Standby").addClass("orange");break;default:b.text(a.online)}"error"in a&&b.text(a.error);return b},capital:function(a){return a.charAt(0).toUpperCase()+
|
||||||
a.substring(1)},addUnit:function(a,b){var c=$("<span>").html(a);c.append($("<span>").addClass("unit").html(b));return c[0].innerHTML},bytes:function(a,b){var c="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=c[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=c[0]:(a/=Math.pow(1024,d),unit=c[d])}return UI.format.addUnit(UI.format.number(a),unit+(b?"/s":""))}},navto:function(a,b){var c=location.hash,d=c.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,b].join("&");
|
a.substring(1)},addUnit:function(a,b){var c=$("<span>").html(a);c.append($("<span>").addClass("unit").html(b));return c[0].innerHTML},bytes:function(a,b){var c="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=c[0];else{var d=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>d?unit=c[0]:(a/=Math.pow(1024,d),unit=c[d])}return UI.format.addUnit(UI.format.number(a),unit+(b?"/s":""))}},navto:function(a,b){var c=location.hash,d=c.split("@");d[0]=[mist.user.name,mist.user.host].join("&");d[1]=[a,b].join("&");
|
||||||
"undefined"!=typeof screenlog&&screenlog.navto(d[1]);location.hash=d.join("@");location.hash==c&&$(window).trigger("hashchange")},showTab:function(a,b){var c=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))c.html("Loading.."),mist.send(function(){UI.showTab(a,b)},{ui_settings:!0});else{var d=UI.elements.menu.removeClass("hide").find('.plain:contains("'+a+'")').closest(".button");0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));UI.interval.clear();
|
"undefined"!=typeof screenlog&&screenlog.navto(d[1]);location.hash=d.join("@");location.hash==c&&$(window).trigger("hashchange")},showTab:function(a,b){var c=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))c.html("Loading.."),mist.send(function(){UI.showTab(a,b)},{ui_settings:!0});else{var d=UI.elements.menu.removeClass("hide").find('.plain:contains("'+a+'")').closest(".button");0<d.length&&(UI.elements.menu.find(".button.active").removeClass("active"),d.addClass("active"));if("undefined"!=
|
||||||
c.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");c.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},{label:"Host",
|
typeof mistvideo)for(var e in mistvideo)if("embedded"in mistvideo[e])for(var g in mistvideo[e].embedded)try{mistvideo[e].embedded[g].player.unload()}catch(m){}UI.interval.clear();c.html($("<h2>").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red");c.append(UI.buildUI([{type:"help",help:"Please provide your account details.<br>You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},
|
||||||
help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password=
|
{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.",validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password=
|
||||||
MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");c.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));c.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",
|
MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");c.append($("<p>").text("No account has been created yet in the MistServer at ").append($("<i>").text(mist.user.host)).append("."));c.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("<br>")},{label:"Desired username",
|
||||||
type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,b){$(".match_password").not($(b)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"rawpassword"},classes:["match_password"]},{label:"Repeat password",
|
type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,b){$(".match_password").not($(b)).trigger("change");return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"rawpassword"},classes:["match_password"]},{label:"Repeat password",
|
||||||
type:"password",validate:["required",function(a,b){return a!=$(".match_password").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);
|
type:"password",validate:["required",function(a,b){return a!=$(".match_password").not($(b)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save",label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);
|
||||||
delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");c.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)c.append("Unable to enable all protocols as protocol settings already exist.<br>");else{c.append("Retrieving available protocols..<br>");
|
delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");c.append($("<p>").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"},{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)c.append("Unable to enable all protocols as protocol settings already exist.<br>");else{c.append("Retrieving available protocols..<br>");
|
||||||
mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{b.push({connector:d});c.append('Enabled protocol "'+d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));
|
mist.send(function(a){var b=[],d;for(d in a.capabilities.connectors)if(a.capabilities.connectors[d].required)c.append('Could not enable protocol "'+d+'" because it has required settings.<br>');else{b.push({connector:d});c.append('Enabled protocol "'+d+'".<br>')}c.append("Saving protocol settings..<br>");mist.send(function(){c.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:b}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));
|
||||||
break;case "Overview":var e=$("<span>").text("Loading.."),k=$("<span>"),m=$("<span>").addClass("logs"),f=$("<span>"),q=$("<span>"),p=$("<span>"),l=$("<span>");c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:e,
|
break;case "Overview":var f=$("<span>").text("Loading.."),q=$("<span>"),p=$("<span>").addClass("logs"),l=$("<span>"),u=$("<span>"),h=$("<span>"),i=$("<span>");c.append(UI.buildUI([{type:"help",help:"You can find most basic information about your MistServer here.<br>You can also set the debug level and force a save to the config.json file that MistServer uses to save your settings. "},{type:"span",label:"Version",pointer:{main:mist.data.config,index:"version"}},{type:"span",label:"Version check",value:f,
|
||||||
LTSonly:!0},{type:"span",label:"Server time",value:q},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:k},{type:"span",label:"Current connections",value:f},{type:"span",label:"Enabled protocols",value:p},{type:"span",label:"Disabled protocols",value:l},{type:"span",label:"Recent problems",value:m},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},
|
LTSonly:!0},{type:"span",label:"Server time",value:u},{type:"span",label:"Configured streams",value:mist.data.streams?Object.keys(mist.data.streams).length:0},{type:"span",label:"Active streams",value:q},{type:"span",label:"Current connections",value:l},{type:"span",label:"Enabled protocols",value:h},{type:"span",label:"Disabled protocols",value:i},{type:"span",label:"Recent problems",value:p},$("<br>"),{type:"str",label:"Human readable name",pointer:{main:mist.data.config,index:"name"},help:"You can name your MistServer here for personal use. You'll still need to set host name within your network yourself."},
|
||||||
{type:"debug",label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"checkbox",label:"Force configurations save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
|
{type:"debug",label:"Debug level",pointer:{main:mist.data.config,index:"debug"},help:"You can set the amount of debug information MistServer saves in the log. A full reboot of MistServer is required before some components of MistServer can post debug information."},{type:"checkbox",label:"Force configurations save",pointer:{main:mist.data,index:"save"},help:"Tick the box in order to force an immediate save to the config.json MistServer uses to save your settings. Saving will otherwise happen upon closing MistServer. Don't forget to press save after ticking the box."},
|
||||||
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var v=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?e.addClass("red").text(a.error):a.uptodate?e.text("Your version is up to date.").addClass("green"):e.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){e.addClass("orange").removeClass("red").text("Rolling update command sent..");
|
{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={config:mist.data.config};if(mist.data.save)a.save=mist.data.save;mist.send(function(){UI.navto("Overview")},a)}}]}]));if(mist.data.LTS){var k=function(){var a=mist.stored.get().update||{};"uptodate"in a?a.error?f.addClass("red").text(a.error):a.uptodate?f.text("Your version is up to date.").addClass("green"):f.addClass("red").text("Version outdated!").append($("<button>").text("Update").css({"font-size":"1em","margin-left":"1em"}).click(function(){if(confirm("Are you sure you want to execute a rolling update?")){f.addClass("orange").removeClass("red").text("Rolling update command sent..");
|
||||||
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):e.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var h=mist.stored.get().update||{};h.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,h,a.update));v()},{checkupdate:!0})}else v()}else e.text("");var g=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=
|
mist.stored.del("update");mist.send(function(){UI.navto("Overview")},{autoupdate:true})}})):f.text("Unknown")};if(!mist.stored.get().update||36E5<(new Date).getTime()-mist.stored.get().update.lastchecked){var j=mist.stored.get().update||{};j.lastchecked=(new Date).getTime();mist.send(function(a){mist.stored.set("update",$.extend(true,j,a.update));k()},{checkupdate:!0})}else k()}else f.text("");g=function(){var a={totals:{fields:["clients"],start:-10},active_streams:true};if(!("cabailities"in mist.data))a.capabilities=
|
||||||
true;mist.send(function(){i()},a)},i=function(){k.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";f.text(a);q.text(UI.format.dateTime(mist.data.config.time,"long"));m.html("");var a=0,b;for(b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>-1){a++;
|
true;mist.send(function(){ga()},a)};var ga=function(){q.text("active_streams"in mist.data?mist.data.active_streams?mist.data.active_streams.length:0:"?");if("totals"in mist.data&&"all_streams"in mist.data.totals)var a=mist.data.totals.all_streams.all_protocols.clients,a=a.length?UI.format.number(a[a.length-1][1]):0;else a="Loading..";l.text(a);u.text(UI.format.dateTime(mist.data.config.time,"long"));p.html("");var a=0,b;for(b in mist.data.log){var c=mist.data.log[b];if(["FAIL","ERROR"].indexOf(c[1])>
|
||||||
var d=$("<span>").addClass("content").addClass("red"),g=c[2].split("|");for(b in g)d.append($("<span>").text(g[b]));m.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&m.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}p.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);l.text(c.length?
|
-1){a++;var d=$("<span>").addClass("content").addClass("red"),e=c[2].split("|");for(b in e)d.append($("<span>").text(e[b]));p.append($("<div>").append($("<span>").append(UI.format.time(c[0]))).append(d));if(a==5)break}}a==0&&p.html("None.");a=[];c=[];for(b in mist.data.config.protocols){d=mist.data.config.protocols[b];a.indexOf(d.connector)>-1||a.push(d.connector)}h.text(a.length?a.join(", "):"None.");if("capabilities"in mist.data){for(b in mist.data.capabilities.connectors)a.indexOf(b)==-1&&c.push(b);
|
||||||
c.join(", "):"None.")}else l.text("Loading..")};g();i();UI.interval.set(g,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var j=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=
|
i.text(c.length?c.join(", "):"None.")}else i.text("Loading..")};g();ga();UI.interval.set(g,3E4);break;case "Protocols":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var z=$("<tbody>");c.append(UI.buildUI([{type:"help",help:"You can find an overview of all the protocols and their relevant information here. You can add, edit or delete protocols."}])).append($("<button>").text("Delete all protocols").click(function(){if(confirm("Are you sure you want to delete all currently configured protocols?")){mist.data.config.protocols=
|
||||||
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";
|
[];mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append($("<button>").text("Enable default protocols").click(function(){var a=Object.keys(mist.data.capabilities.connectors),b;for(b in mist.data.config.protocols){var c=a.indexOf(mist.data.config.protocols[b].connector);c>-1&&a.splice(c,1)}var d=[];for(b in a)(!("required"in mist.data.capabilities.connectors[a[b]])||Object.keys(mist.data.capabilities.connectors[a[b]].required).length==0)&&d.push(a[b]);c="Click OK to enable disabled protocols with their default settings:\n ";
|
||||||
c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear","both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(j));
|
c=d.length?c+d.join(", "):c+"None.";if(d.length!=a.length){a=a.filter(function(a){return d.indexOf(a)<0});c=c+("\n\nThe following protocols can only be set manually:\n "+a.join(", "))}if(confirm(c)&&d.length){for(b in d)mist.data.config.protocols.push({connector:d[b]});mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}})).append("<br>").append($("<button>").text("New protocol").click(function(){UI.navto("Edit Protocol")}).css("clear","both")).append($("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Protocol")).append($("<th>").text("Status")).append($("<th>").text("Settings")).append($("<th>")))).append(z));
|
||||||
var fa=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],g=["required","optional"],y;for(y in g)for(var e in c[g[y]])b[e]&&b[e]!=""?d.push(e+": "+b[e]):c[g[y]][e]["default"]&&d.push(e+": "+c[g[y]][e]["default"]);return $("<span>").addClass("description").text(d.join(", "))}j.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];j.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align",
|
var K=function(){function a(b){var c=mist.data.capabilities.connectors[b.connector];if(!c)return"";var d=[],e=["required","optional"],g;for(g in e)for(var t in c[e[g]])b[t]&&b[t]!=""?d.push(t+": "+b[t]):c[e[g]][t]["default"]&&d.push(t+": "+c[e[g]][t]["default"]);return $("<span>").addClass("description").text(d.join(", "))}z.html("");for(var b in mist.data.config.protocols){var c=mist.data.config.protocols[b];z.append($("<tr>").data("index",b).append($("<td>").text(c.connector)).append($("<td>").html(UI.format.status(c))).append($("<td>").html(a(c))).append($("<td>").css("text-align",
|
||||||
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};fa();UI.interval.set(function(){mist.send(function(){fa()})},
|
"right").html($("<button>").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.data.config.protocols.splice(a,1);mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}}))))}};K();UI.interval.set(function(){mist.send(function(){K()})},
|
||||||
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}var H=!1;""!=b&&0<=b&&(H=!0);var K={};for(g in mist.data.config.protocols)K[mist.data.config.protocols[g].connector]=1;var ga=function(a){var c=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(c,n);d.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
3E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}var H=!1;""!=b&&0<=b&&(H=!0);var L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;var ha=function(a){var c=mist.data.capabilities.connectors[a],d=mist.convertBuildOptions(c,n);d.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});d.push({type:"buttons",buttons:[{type:"save",label:"Save",
|
||||||
"function":function(){if(H)mist.data.config.protocols[b]=n;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(n)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var g in c.deps){a=$("<li>").text(c.deps[g]+
|
"function":function(){if(H)mist.data.config.protocols[b]=n;else{if(!mist.data.config.protocols)mist.data.config.protocols=[];mist.data.config.protocols.push(n)}mist.send(function(){UI.navto("Protocols")},{config:mist.data.config})}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in c&&c.deps!=""){$t=$("<span>").text("Dependencies:");$ul=$("<ul>");$t.append($ul);if(typeof c.deps=="string")c.deps=c.deps.split(", ");for(var e in c.deps){a=$("<li>").text(c.deps[e]+
|
||||||
" ");$ul.append(a);typeof K[c.deps[g]]!="undefined"||typeof K[c.deps[g]+".exe"]!="undefined"?a.append($("<span>").addClass("green").text("(Configured)")):a.append($("<span>").addClass("red").text("(Not yet configured)"))}d.unshift({type:"text",text:$t[0].innerHTML})}return UI.buildUI(d)},K={};for(g in mist.data.config.protocols)K[mist.data.config.protocols[g].connector]=1;if(H)n=d=mist.data.config.protocols[b],c.find("h2").append(' "'+d.connector+'"'),c.append(ga(d.connector));else{c.html($("<h2>").text("New Protocol"));
|
" ");$ul.append(a);typeof L[c.deps[e]]!="undefined"||typeof L[c.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)},L={};for(g in mist.data.config.protocols)L[mist.data.config.protocols[g].connector]=1;if(H)n=d=mist.data.config.protocols[b],c.find("h2").append(' "'+d.connector+'"'),c.append(ha(d.connector));else{c.html($("<h2>").text("New Protocol"));
|
||||||
var n={},t=[["",""]];for(g in mist.data.capabilities.connectors)t.push([g,g]);var I=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:t,"function":function(){$(this).getval()!=""&&I.html(ga($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}var g=$("<button>"),D=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},
|
var n={},s=[["",""]];for(g in mist.data.capabilities.connectors)s.push([g,g]);var I=$("<span>");c.append(UI.buildUI([{label:"Protocol",type:"select",select:s,"function":function(){$(this).getval()!=""&&I.html(ha($(this).getval()))}}])).append(I)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},{capabilities:!0});return}g=$("<button>");var D=$("<span>").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},
|
||||||
$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(g).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(D);if(""==b){var r=mist.stored.get();"viewmode"in r&&(b=r.viewmode)}g.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var z=$.extend(!0,{},mist.data.streams),T=function(a,
|
$("<div>").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(g).append($("<button>").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(D);""==b&&(e=mist.stored.get(),"viewmode"in e&&(b=e.viewmode));g.text("Switch to "+("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var y=$.extend(!0,{},mist.data.streams),U=function(a,
|
||||||
b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},U=function(b,d,g){D.remove();switch(b){case "thumbnails":var e=$("<div>").addClass("preview_icons"),f;f=g||[];d.sort();d.unshift("");D.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=
|
b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},V=function(b,d,e){D.remove();switch(b){case "thumbnails":var g=$("<div>").addClass("preview_icons"),f;f=e||[];d.sort();d.unshift("");D.remove();c.append($("<h2>").text(a)).append(UI.buildUI([{label:"Filter the streams",type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=
|
||||||
$(this).val();e.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(e);for(var h in d){var b=d[h],i="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;
|
$(this).val();g.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("<span>").addClass("description").text("Choose a stream below.")).append(g);for(var h in d){var b=d[h],i="",k=$("<button>").text("Delete").click(function(){var a=$(this).closest("div").attr("data-stream");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;
|
||||||
mist.send(function(){UI.navto("Streams")},b)}}),j=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),g=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),m=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),l=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];j=k="";l.addClass("wildcard")}else{i=
|
mist.send(function(){UI.navto("Streams")},b)}}),j=$("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("div").attr("data-stream"))}),e=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("div").attr("data-stream"))}),m=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("div").attr("data-stream"))}),l=$("<span>").addClass("image");if(b.indexOf("+")>-1){i=b.split("+");i=mist.data.streams[i[0]].source+i[1];j=k="";l.addClass("wildcard")}else{i=
|
||||||
mist.data.streams[b].source;if(f.indexOf(b)>-1){m=g="";l.addClass("folder")}}e.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(l).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(j).append(k).append(g).append(m)).attr("title",b).attr("data-stream",b))}break;default:var n=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
mist.data.streams[b].source;if(f.indexOf(b)>-1){m=e="";l.addClass("folder")}}g.append($("<div>").append($("<span>").addClass("streamname").text(b)).append(l).append($("<span>").addClass("description").text(i)).append($("<span>").addClass("button_container").append(j).append(k).append(e).append(m)).attr("title",b).attr("data-stream",b))}break;default:var n=$("<tbody>").append($("<tr>").append("<td>").attr("colspan",6).text("Loading.."));h=$("<table>").html($("<thead>").html($("<tr>").html($("<th>").text("Stream name").attr("data-sort-type",
|
||||||
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(n);c.append(h);h.stupidtable();var o=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,
|
"string").addClass("sorting-asc")).append($("<th>").text("Source").attr("data-sort-type","string")).append($("<th>").text("Status").attr("data-sort-type","int")).append($("<th>").css("text-align","right").text("Connections").attr("data-sort-type","int")).append($("<th>")).append($("<th>")))).append(n);c.append(h);h.stupidtable();var o=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,
|
||||||
z,mist.data.streams);var a=0;n.html("");d.sort();for(var b in d){var c=d[b],g;g=c in mist.data.streams?mist.data.streams[c]:z[c];var e=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!="undefined"){var y=mist.data.totals[c].all_protocols.clients,f=0;if(y.length){for(a in y)f=f+y[a][1];f=Math.round(f/y.length)}}e.html(UI.format.number(f));if(f==0&&g.online==1)g.online=2;f=$("<td>").css("text-align",
|
y,mist.data.streams);var a=0;n.html("");d.sort();for(var b in d){var c=d[b],e;e=c in mist.data.streams?mist.data.streams[c]:y[c];var g=$("<td>").css("text-align","right").html($("<span>").addClass("description").text("Loading..")),t=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!="undefined"){var f=mist.data.totals[c].all_protocols.clients,t=0;if(f.length){for(a in f)t=t+f[a][1];t=Math.round(t/f.length)}}g.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 g)||!g.ischild)&&f.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));y=$("<span>").text(c);
|
"right").css("white-space","nowrap");(!("ischild"in e)||!e.ischild)&&t.html($("<button>").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));f=$("<span>").text(c);
|
||||||
g.ischild&&y.css("padding-left","1em");var h=UI.format.status(g),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in z[c]){h.html("");i="";e.html("");k=""}n.append($("<tr>").data("index",c).html($("<td>").html(y).attr("title",c).addClass("overflow_ellipsis")).append($("<td>").text(g.source).attr("title",g.source).addClass("description").addClass("overflow_ellipsis").css("max-width",
|
e.ischild&&f.css("padding-left","1em");var h=UI.format.status(e),i=$("<button>").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),k=$("<button>").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in y[c]){h.html("");i="";g.html("");k=""}n.append($("<tr>").data("index",c).html($("<td>").html(f).attr("title",c).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",g.online).html(h)).append(e).append($("<td>").css("white-space","nowrap").html(i).append(k)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(f in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[f].source)){z[f].source=z[f].source+"*";z[f].filesfound=null;mist.send(function(a,b){var c=b.stream,d;for(d in a.browse.files)for(var g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=
|
"20em")).append($("<td>").data("sort-value",e.online).html(h)).append(g).append($("<td>").css("white-space","nowrap").html(i).append(k)).append(t));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=0,q=0;for(f in mist.data.streams){h=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!h)break;if(mist.inputMatch(h.source_match,mist.data.streams[f].source)){y[f].source=y[f].source+"*";y[f].filesfound=null;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||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder")>=0||g.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[d])){var e=c+"+"+a.browse.files[d];z[e]=T(e,mist.data.streams[c]);z[e].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?z[c].filesfound=true:mist.data.streams[c].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[f].source},
|
0||e.indexOf("Buffer.exe")>=0||e.indexOf("Folder")>=0||e.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[d])){var g=c+"+"+a.browse.files[d];y[g]=U(g,mist.data.streams[c]);y[g].source=mist.data.streams[c].source+a.browse.files[d]}"files"in a.browse&&a.browse.files.length?y[c].filesfound=true:mist.data.streams[c].filesfound=false;q++;if(p==q){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}},{browse:mist.data.streams[f].source},
|
||||||
{stream:f});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}};if(mist.data.LTS){var V=0,ha=0,t={},ia=[];for(r in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[r].source))ia.push(r),mist.send(function(a,c){var d=c.stream,g;for(g in a.browse.files)for(var e in mist.data.capabilities.inputs)e.indexOf("Buffer")>=
|
{stream:f});p++}}if(p==0){mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}else{mist.send(function(){o()},{active_streams:true});UI.interval.set(function(){o()},5E3)}}};if(mist.data.LTS){var W=0,ia=0,s={},ja=[];for(e in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[e].source))ja.push(e),mist.send(function(a,c){var d=c.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=
|
||||||
0||e.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[e].source_match,"/"+a.browse.files[g])&&(t[d+"+"+a.browse.files[g]]=true);ha++;V==ha&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;z[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);t=t.concat(Object.keys(mist.data.streams));t.sort();U(b,
|
0||g.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&(s[d+"+"+a.browse.files[e]]=true);ia++;W==ia&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[c[0]])}}s=Object.keys(s);s=s.concat(Object.keys(mist.data.streams));s.sort();V(b,
|
||||||
t,ia)},{active_streams:true})},{browse:mist.data.streams[r].source},{stream:r}),V++;0==V&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){t[mist.data.active_streams[a]]=true;z[mist.data.active_streams[a]]=T(mist.data.active_streams[a],mist.data.streams[c[0]])}}t=Object.keys(t);mist.data.streams&&(t=t.concat(Object.keys(mist.data.streams)));t.sort();U(b,t)},{active_streams:!0})}else U(b,Object.keys(mist.data.streams));
|
s,ja)},{active_streams:true})},{browse:mist.data.streams[e].source},{stream:e}),W++;0==W&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){s[mist.data.active_streams[a]]=true;y[mist.data.active_streams[a]]=U(mist.data.active_streams[a],mist.data.streams[c[0]])}}s=Object.keys(s);mist.data.streams&&(s=s.concat(Object.keys(mist.data.streams)));s.sort();V(b,s)},{active_streams:!0})}else V(b,Object.keys(mist.data.streams));
|
||||||
break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}H=!1;""!=b&&(H=!0);if(H){var s=b,n=mist.data.streams[s];c.find("h2").append(' "'+s+'"')}else c.html($("<h2>").text("New Stream")),n={};s=[];for(g in mist.data.capabilities.inputs)s.push(mist.data.capabilities.inputs[g].source_match);var O=$("<div>"),ja=function(a){if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;b!=n.name&&delete mist.data.streams[b];
|
break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}H=!1;""!=b&&(H=!0);if(H){var r=b,n=mist.data.streams[r];c.find("h2").append(' "'+r+'"')}else c.html($("<h2>").text("New Stream")),n={};r=[];for(g in mist.data.capabilities.inputs)r.push(mist.data.capabilities.inputs[g].source_match);var P=$("<div>"),ka=function(a){if(!mist.data.streams)mist.data.streams={};mist.data.streams[n.name]=n;b!=n.name&&delete mist.data.streams[b];
|
||||||
var c={};if(mist.data.LTS){c.addstream={};c.addstream[n.name]=n;if(b!=n.name)c.deletestream=[b]}else c.streams=mist.data.streams;if(n.stop_sessions&&b!=""){c.stop_sessions=b;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},c)},ka=$("<style>").text("button.saveandpreview { display: none; }"),E=$("<span>"),W=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),d=
|
var c={};if(mist.data.LTS){c.addstream={};c.addstream[n.name]=n;if(b!=n.name)c.deletestream=[b]}else c.streams=mist.data.streams;if(n.stop_sessions&&b!=""){c.stop_sessions=b;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},c)},la=$("<style>").text("button.saveandpreview { display: none; }"),E=$("<span>"),X=function(){var a=c.find("[name=name]").val();if(a){var b=parseURL(mist.user.host),d=
|
||||||
c.find("[name=source]").val().match(/@.*/);d&&(d=d[0].substring(1));var g=c.find("[name=source]").val().replace(/(?:.+?):\/\//,""),g=g.split("/"),g=g[0],g=g.split(":"),g=g[0],e={},f=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],h;for(h in f)f[h]in mist.data.capabilities.connectors&&(e[f[h]]=mist.data.capabilities.connectors[f[h]].optional.port["default"]);var f={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},i;for(i in e){for(h in mist.data.config.protocols){var k=mist.data.config.protocols[h];
|
c.find("[name=source]").val().match(/@.*/);d&&(d=d[0].substring(1));var e=c.find("[name=source]").val().replace(/(?:.+?):\/\//,""),e=e.split("/"),e=e[0],e=e.split(":"),e=e[0],g={},f=["RTMP","RTSP","TS","RTMP.exe","RTSP.exe","TS.exe"],h;for(h in f)f[h]in mist.data.capabilities.connectors&&(g[f[h]]=mist.data.capabilities.connectors[f[h]].optional.port["default"]);var f={RTMP:1935,"RTMP.exe":1935,RTSP:554,"RTSP.exe":554,TS:-1,"TS.exe":-1},i;for(i in g){for(h in mist.data.config.protocols){var k=mist.data.config.protocols[h];
|
||||||
if(k.connector==i){if("port"in k)e[i]=k.port;break}}e[i]=e[i]==f[i]?"":":"+e[i]}E.find(".field").closest("label").hide();for(h in e){var j;switch(h){case "RTMP":case "RTMP.exe":j="rtmp://"+b.host+e[h]+"/"+(d?d:"live")+"/";E.find(".field.RTMPurl").setval(j).closest("label").show();E.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();j=j+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":j="rtsp://"+b.host+e[h]+"/"+(a==""?"STREAMNAME":a)+(d?"?pass="+d:"");break;case "TS":case "TS.exe":j=
|
if(k.connector==i){if("port"in k)g[i]=k.port;break}}g[i]=g[i]==f[i]?"":":"+g[i]}E.find(".field").closest("label").hide();for(h in g){var j;switch(h){case "RTMP":case "RTMP.exe":j="rtmp://"+b.host+g[h]+"/"+(d?d:"live")+"/";E.find(".field.RTMPurl").setval(j).closest("label").show();E.find(".field.RTMPkey").setval(a==""?"STREAMNAME":a).closest("label").show();j=j+(a==""?"STREAMNAME":a);break;case "RTSP":case "RTSP.exe":j="rtsp://"+b.host+g[h]+"/"+(a==""?"STREAMNAME":a)+(d?"?pass="+d:"");break;case "TS":case "TS.exe":j=
|
||||||
"udp://"+(g==""?b.host:g)+e[h]+"/"}E.find(".field."+h.replace(".exe","")).setval(j).closest("label").show()}}};c.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",filetypes:s,pointer:{main:n,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>Input</td><td>Syntax</td><td>Explanation</td></tr> <tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>Password is the application under which to push to MistServer, if it doesn't match the stream will be rejected. Password is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr></table>",
|
"udp://"+(e==""?b.host:e)+g[h]+"/"}E.find(".field."+h.replace(".exe","")).setval(j).closest("label").show()}}};c.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",filetypes:r,pointer:{main:n,index:"source"},help:"<p>Below is the explanation of the input methods for MistServer. Anything between brackets () will go to default settings if not specified.</p><table><tr><td>Input</td><td>Syntax</td><td>Explanation</td></tr> <tr><th>File</th><td>Linux/MacOS: /PATH/FILE<br>Windows: /cygdrive/DRIVE/PATH/FILE</td><td>For file input please specify the proper path and file.<br>Supported inputs are: DTSC, FLV, MP3. MistServer Pro has TS, MP4, ISMV added as input.</td></tr><th>Folder<br>(Pro only)</th><td>Linux/MacOS: /PATH/<br>Windows: /cygdrive/DRIVE/PATH/</td><td>A folder stream makes all the recognised files in the selected folder available as a stream.</td></tr><tr><th>RTMP</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.<br>Password is the application under which to push to MistServer, if it doesn't match the stream will be rejected. Password is MistServer Pro only. <tr><th>RTSP<br>(Pro only)</th><td>push://(IP)(@PASSWORD)</td><td>IP is white listed IP for pushing towards MistServer, if left empty all are white listed.</td></tr> <tr><th>TS<br>(Pro only)</th><td>tsudp://(IP):PORT(/INTERFACE)</td><td>IP is the IP address used to listen for this stream, multi-cast IP range is: 224.0.0.0 - 239.255.255.255. If IP is not set all addresses will listened to.<br>PORT is the port you reserve for this stream on the chosen IP.<br>INTERFACE is the interface used, if left all interfaces will be used.</td></tr></table>",
|
||||||
"function":function(){var a=$(this).val();ka.remove();E.html("");if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)O.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];O.html($("<h3>").text(b.name+" Input options"));
|
"function":function(){var a=$(this).val();la.remove();E.html("");if(a!=""){var b=null,d;for(d in mist.data.capabilities.inputs)if(typeof mist.data.capabilities.inputs[d].source_match!="undefined"&&mist.inputMatch(mist.data.capabilities.inputs[d].source_match,a)){b=d;break}if(b===null)P.html($("<h3>").text("Unrecognized input").addClass("red")).append($("<span>").text("Please edit the stream source.").addClass("red"));else{b=mist.data.capabilities.inputs[b];P.html($("<h3>").text(b.name+" Input options"));
|
||||||
var g=mist.convertBuildOptions(b,n);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&g.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:n,index:"always_on"}});O.append(UI.buildUI(g));if(b.name=="Folder")c.append(ka);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(b.name){case "Buffer":case "Buffer.exe":a.push({label:"RTMP full url",
|
var e=mist.convertBuildOptions(b,n);"always_match"in mist.data.capabilities.inputs[d]&&mist.inputMatch(mist.data.capabilities.inputs[d].always_match,a)&&e.push({label:"Always on",type:"checkbox",help:"Keep this input available at all times, even when there are no active viewers.",pointer:{main:n,index:"always_on"}});P.append(UI.buildUI(e));if(b.name=="Folder")c.append(la);else if(["Buffer","Buffer.exe","TS","TS.exe"].indexOf(b.name)>-1){a=[$("<span>").text("Configure your source to push to:")];switch(b.name){case "Buffer":case "Buffer.exe":a.push({label:"RTMP full url",
|
||||||
type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});a.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});a.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"});a.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});
|
type:"span",clipboard:true,readonly:true,classes:["RTMP"],help:"Use this RTMP url if your client doesn't ask for a stream key"});a.push({label:"RTMP url",type:"span",clipboard:true,readonly:true,classes:["RTMPurl"],help:"Use this RTMP url if your client also asks for a stream key"});a.push({label:"RTMP stream key",type:"span",clipboard:true,readonly:true,classes:["RTMPkey"],help:"Use this key if your client asks for a stream key"});a.push({label:"RTSP",type:"span",clipboard:true,readonly:true,classes:["RTSP"]});
|
||||||
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}E.html("<br>").append(UI.buildUI(a));W()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},E,$("<br>"),{type:"custom",custom:O},$("<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."},
|
break;case "TS":case "TS.exe":a.push({label:"TS",type:"span",clipboard:true,readonly:true,classes:["TS"]})}E.html("<br>").append(UI.buildUI(a));X()}}}}},{label:"Stop sessions",type:"checkbox",help:"When saving these stream settings, kill this stream's current connections.",LTSonly:!0,pointer:{main:n,index:"stop_sessions"}},E,$("<br>"),{type:"custom",custom:P},$("<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(){ja("Streams")}},
|
{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(){ka("Streams")}},
|
||||||
{type:"save",label:"Save and Preview","function":function(){ja("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){W()});W();break;case "Preview":""==b&&UI.navto("Streams");r=":8080";for(g in mist.data.config.protocols)if(d=mist.data.config.protocols[g],"HTTP"==d.connector||"HTTP.exe"==d.connector)r=d.port?":"+d.port:":8080";var s=parseURL(mist.user.host),P=s.protocol+s.host+r+"/",I=$("<div>").css({display:"flex","flex-flow":"row wrap"}),s="";-1==b.indexOf("+")&&(s=
|
{type:"save",label:"Save and Preview","function":function(){ka("Preview")},classes:["saveandpreview"]}]}]));c.find("[name=name]").keyup(function(){X()});X();break;case "Preview":""==b&&UI.navto("Streams");e=":8080";for(g in mist.data.config.protocols)if(d=mist.data.config.protocols[g],"HTTP"==d.connector||"HTTP.exe"==d.connector)e=d.port?":"+d.port:":8080";var r=parseURL(mist.user.host),Q=r.protocol+r.host+e+"/",I=$("<div>").css({display:"flex","flex-flow":"row wrap"}),r="";-1==b.indexOf("+")&&(r=
|
||||||
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(s).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(I);var F=encodeURIComponent(b),g=$("<div>");I.append(g);var X=$("<div>"),Q=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Y()}),
|
$("<button>").text("Settings").addClass("settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Embed").addClass("embed").click(function(){UI.navto("Embed",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Preview of "'+b+'"')).append(I);var F=encodeURIComponent(b);g=$("<div>");I.append(g);var Y=$("<div>"),R=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),
|
||||||
L=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Y()}),s=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:Q,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:L,help:"Choose an output type to preview"}]),M=$("<div>").addClass("mistvideo").text("Loading player..");g.append(M).append(X).append(s);var Y=function(){C.html("");var a={target:M[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-
|
M=$("<select>").append($("<option>").text("Automatic").val("")).change(function(){Z()}),r=UI.buildUI([{label:"Use player",type:"DOMfield",DOMfield:R,help:"Choose a player to preview"},{label:"Use source",type:"DOMfield",DOMfield:M,help:"Choose an output type to preview"}]),N=$("<div>").addClass("mistvideo").text("Loading player..");g.append(N).append(Y).append(r);var Z=function(){A.html("");if(typeof mistvideo!="undefined")for(var a in mistvideo)if("embedded"in mistvideo[a])for(var c in mistvideo[a].embedded)try{mistvideo[a].embedded[c].player.unload()}catch(d){}a=
|
||||||
100,loop:true};if(Q.val()!="")a.forcePlayer=Q.val();if(L.val()!="")a.forceSource=L.val();mistPlay(b,a)},C=$("<div>").addClass("player_log");g.append($("<div>").append($("<h3>").text("Player log:")).append(C));M.on("log error",function(a){var b=false;C.height()+C.scrollTop()==C[0].scrollHeight&&(b=true);C.append($("<div>").append($("<span>").text("["+UI.format.time((new Date).getTime()/1E3)+"]").css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).addClass(a.type=="error"?
|
{target:N[0],maxheight:window.innerHeight-$("header").height(),maxwidth:window.innerWidth-UI.elements.menu.width()-100,loop:true};if(R.val()!="")a.forcePlayer=R.val();if(M.val()!="")a.forceSource=M.val();mistPlay(b,a)},A=$("<div>").addClass("player_log");g.append($("<div>").append($("<h3>").text("Player log:")).append(A));var ma="";N.on("log error",function(a){var b=false;A.height()+A.scrollTop()==A[0].scrollHeight&&(b=true);var c=a.type+a.originalEvent.message,d="["+UI.format.time((new Date).getTime()/
|
||||||
"red":""));b&&C.scrollTop(C[0].scrollHeight)});var la=function(){X.text("");var a=document.createElement("script");c.append(a);a.src=P+"player.js";a.onerror=function(){M.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){la()}))};a.onload=function(){for(var d in mistplayers)Q.append($("<option>").text(mistplayers[d].name).val(d));Y();M.on("initialized",function(){if(L.children().length<=1)for(var a in mistvideo[b].source){var c=mistvideo[b].source[a],
|
1E3)+"]";if(ma==c){var a=A.children().last(),b=a.children("[data-amount]"),e=b.attr("data-amount");e++;b.text("("+e+"x)").attr("data-amount",e);a.children(".timestamp").text(d)}else{A.append($("<div>").append($("<span>").addClass("timestamp").text(d).css("margin-right","0.5em")).append($("<span>").text(a.originalEvent.message)).append($("<span>").attr("data-amount",1).css("margin-left","0.5em")).addClass(a.type=="error"?"red":""));b&&A.scrollTop(A[0].scrollHeight)}ma=c});var na=function(){Y.text("");
|
||||||
d=UI.humanMime(c.type);L.append($("<option>").val(a).text(d?d+" @ "+c.url.substring(c.url.length-c.relurl.length,0):UI.format.capital(c.type)+" @ "+c.url.substring(c.url.length-c.relurl.length,0)))}a=mistvideo[b].embedded[mistvideo[b].embedded.length-1];d=UI.humanMime(a.player.options.source.type);X.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});
|
var a=document.createElement("script");c.append(a);a.src=Q+"player.js";a.onerror=function(){N.html("Failed to load player.js").append($("<button>").text("Reload").css("display","block").click(function(){na()}))};a.onload=function(){for(var d in mistplayers)R.append($("<option>").text(mistplayers[d].name).val(d));Z();N.on("initialized",function(){if(M.children().length<=1)for(var a in mistvideo[b].source){var c=mistvideo[b].source[a],d=UI.humanMime(c.type);M.append($("<option>").val(a).text(d?d+" @ "+
|
||||||
c[0].removeChild(a)}};la();var g=$("<div>").append($("<h3>").text("Meta information")),R=$("<span>").text("Loading..");g.append(R);I.append(g);$.ajax({type:"GET",url:P+"json_"+F+".js",success:function(a){var b=a.meta;if(b){a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(b.buffer_window,"ms")});var c={audio:{vheader:"Audio",labels:["Codec",
|
c.url.substring(c.url.length-c.relurl.length,0):UI.format.capital(c.type)+" @ "+c.url.substring(c.url.length-c.relurl.length,0)))}a=mistvideo[b].embedded[mistvideo[b].embedded.length-1];d=UI.humanMime(a.player.options.source.type);Y.html("You're watching "+(d?d+" <span class=description>("+a.player.options.source.type+")</span>":UI.format.capital(a.player.options.source.type))+" through "+mistplayers[a.selectedPlayer].name+".")});c[0].removeChild(a)}};na();g=$("<div>").append($("<h3>").text("Meta information"));
|
||||||
"Duration","Peak bitrate","Channels","Samplerate","Language"],content:[]},video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(b.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var g in d){var e=d[g],f=b.tracks[e];switch(f.type){case "audio":c.audio.content.push({header:"Track "+e.split("_").pop(),
|
var S=$("<span>").text("Loading..");g.append(S);I.append(g);$.ajax({type:"GET",url:Q+"json_"+F+".js",success:function(a){var b=a.meta;if(b){a=[];a.push({label:"Type",type:"span",value:b.live?"Live":"Pre-recorded (VoD)"});"format"in b&&a.push({label:"Format",type:"span",value:b.format});b.live&&a.push({label:"Buffer window",type:"span",value:UI.format.addUnit(b.buffer_window,"ms")});var c={audio:{vheader:"Audio",labels:["Codec","Duration","Peak bitrate","Channels","Samplerate","Language"],content:[]},
|
||||||
body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz"),"lang"in f?f.lang:"unknown"]});break;case "video":c.video.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/
|
video:{vheader:"Video",labels:["Codec","Duration","Peak bitrate","Size","Framerate","Language"],content:[]},subtitle:{vheader:"Subtitles",labels:["Codec","Duration","Peak bitrate","Language"],content:[]}},d=Object.keys(b.tracks);d.sort(function(a,b){a=a.split("_").pop();b=b.split("_").pop();return a-b});for(var e in d){var g=d[e],f=b.tracks[g];switch(f.type){case "audio":c.audio.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+
|
||||||
1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps"),"lang"in f?f.lang:"unknown"]});break;case "subtitle":c.subtitle.content.push({header:"Track "+e.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),"lang"in f?f.lang:"unknown"]})}}g=
|
UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),f.channels,UI.format.addUnit(UI.format.number(f.rate),"Hz"),"lang"in f?f.lang:"unknown"]});break;case "video":c.video.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),UI.format.addUnit(f.width,
|
||||||
["audio","video","subtitle"];b=$("<div>").css({display:"flex","flex-flow":"row wrap","font-size":"0.9em"});for(e in g)c[g[e]].content.length&&b.append(UI.buildVheaderTable(c[g[e]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(b);R.html(UI.buildUI(a))}else R.html("No meta information available.")},error:function(){R.html("Error while retrieving stream info.")}});break;case "Embed":""==b&&UI.navTo("Streams");s="";-1==b.indexOf("+")&&(s=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",
|
"x ")+UI.format.addUnit(f.height,"px"),UI.format.addUnit(UI.format.number(f.fpks/1E3),"fps"),"lang"in f?f.lang:"unknown"]});break;case "subtitle":c.subtitle.content.push({header:"Track "+g.split("_").pop(),body:[f.codec,UI.format.duration((f.lastms-f.firstms)/1E3)+"<br><span class=description>"+UI.format.duration(f.firstms/1E3)+" to "+UI.format.duration(f.lastms/1E3)+"</span>",UI.format.bytes(f.bps,1),"lang"in f?f.lang:"unknown"]})}}e=["audio","video","subtitle"];b=$("<div>").css({display:"flex",
|
||||||
b)}));c.html($("<div>").addClass("bigbuttons").append(s).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var S=$("<span>");c.append(S);F=encodeURIComponent(b);s=parseURL(mist.user.host);r={"":{port:":8080"}};for(g in mist.data.config.protocols){d=mist.data.config.protocols[g];if("HTTP"==d.connector||
|
"flex-flow":"row wrap","font-size":"0.9em"});for(g in e)c[e[g]].content.length&&b.append(UI.buildVheaderTable(c[e[g]]).css("width","auto"));a.push($("<span>").text("Tracks:"));a.push(b);S.html(UI.buildUI(a))}else S.html("No meta information available.")},error:function(){S.html("Error while retrieving stream info.")}});break;case "Embed":""==b&&UI.navTo("Streams");r="";-1==b.indexOf("+")&&(r=$("<button>").addClass("settings").text("Settings").click(function(){UI.navto("Edit",b)}));c.html($("<div>").addClass("bigbuttons").append(r).append($("<button>").text("Preview").addClass("preview").click(function(){UI.navto("Preview",
|
||||||
"HTTP.exe"==d.connector)r[""].port=d.port?":"+d.port:":8080";if("HTTPS"==d.connector||"HTTPS.exe"==d.connector)r.s={},r.s.port=d.port?":"+d.port:":4433"}var G=P="http://"+s.host+r[""].port+"/";if(otherhost.host||otherhost.https)G=(otherhost.https&&"s"in r?"https://":"http://")+(otherhost.host?otherhost.host:s.host)+(otherhost.https&&"s"in r?r.s.port:r[""].port)+"/";var Z={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",
|
b)})).append($("<button>").addClass("cancel").addClass("return").text("Return").click(function(){UI.navto("Streams")}))).append($("<h2>").text('Embed "'+b+'"'));var T=$("<span>");c.append(T);F=encodeURIComponent(b);r=parseURL(mist.user.host);e={"":{port:":8080"}};for(g in mist.data.config.protocols){d=mist.data.config.protocols[g];if("HTTP"==d.connector||"HTTP.exe"==d.connector)e[""].port=d.port?":"+d.port:":8080";if("HTTPS"==d.connector||"HTTPS.exe"==d.connector)e.s={},e.s.port=d.port?":"+d.port:
|
||||||
setTracks:{}},o=$.extend({},Z),g=UI.stored.getOpts();"embedoptions"in g&&(o=$.extend(o,g.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks={}));g={};switch(o.controls){case "stock":g.controls="stock";break;case !0:g.controls=1;break;case !1:g.controls=0}var w=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}UI.stored.saveOpt("embedoptions",o);for(var c=b+"_",d=12,g="";d--;){var f;f=Math.floor(Math.random()*
|
":4433"}var G=Q="http://"+r.host+e[""].port+"/";if(otherhost.host||otherhost.https)G=(otherhost.https&&"s"in e?"https://":"http://")+(otherhost.host?otherhost.host:r.host)+(otherhost.https&&"s"in e?e.s.port:e[""].port)+"/";var aa={forcePlayer:"",forceType:"",controls:!0,autoplay:!0,loop:!1,width:"",height:"",maxwidth:"",maxheight:"",poster:"",urlappend:"",setTracks:{}},o=$.extend({},aa);g=UI.stored.getOpts();"embedoptions"in g&&(o=$.extend(o,g.embedoptions,!0),"object"!=typeof o.setTracks&&(o.setTracks=
|
||||||
62);f=f<10?f:f<36?String.fromCharCode(f+55):String.fromCharCode(f+61);g=g+f}var c=c+g,d=['target: document.getElementById("'+c+'")'],e;for(e in o)o[e]!=Z[e]&&(typeof o[e]!="object"||JSON.stringify(o[e])!=JSON.stringify(Z[e]))&&d.push(e+": "+a(o[e]));e=[];e.push('<div class="mistvideo" id="'+c+'">');e.push(" <noscript>");e.push(' <a href="'+G+F+'.html" target="_blank">');e.push(" Click here to play this video");e.push(" </a>");e.push(" </noscript>");e.push(" <script>");e.push(" var a = function(){");
|
{}));g={};switch(o.controls){case "stock":g.controls="stock";break;case !0:g.controls=1;break;case !1:g.controls=0}var w=function(){function a(b){switch(typeof b){case "string":return $.isNumeric(b)?b:'"'+b+'"';case "object":return JSON.stringify(b);default:return b}}UI.stored.saveOpt("embedoptions",o);for(var c=b+"_",d=12,e="";d--;){var g;g=Math.floor(Math.random()*62);g=g<10?g:g<36?String.fromCharCode(g+55):String.fromCharCode(g+61);e=e+g}var c=c+e,d=['target: document.getElementById("'+c+'")'],
|
||||||
e.push(' mistPlay("'+b+'",{');e.push(" "+d.join(",\n "));e.push(" });");e.push(" };");e.push(" if (!window.mistplayers) {");e.push(' var p = document.createElement("script");');e.push(' p.src = "'+G+'player.js"');e.push(" document.head.appendChild(p);");e.push(" p.onload = a;");e.push(" }");e.push(" else { a(); }");e.push(" <\/script>");e.push("</div>");return e.join("\n")},aa=$("<span>").text("Loading.."),d=w(o),J=$("<div>").text("Loading..").css("display",
|
f;for(f in o)o[f]!=aa[f]&&(typeof o[f]!="object"||JSON.stringify(o[f])!=JSON.stringify(aa[f]))&&d.push(f+": "+a(o[f]));f=[];f.push('<div class="mistvideo" id="'+c+'">');f.push(" <noscript>");f.push(' <a href="'+G+F+'.html" target="_blank">');f.push(" Click here to play this video");f.push(" </a>");f.push(" </noscript>");f.push(" <script>");f.push(" var a = function(){");f.push(' mistPlay("'+b+'",{');f.push(" "+d.join(",\n "));f.push(" });");f.push(" };");
|
||||||
"flex"),ma="";"s"in r&&(ma=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));S.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type","text").addClass("field").val(otherhost.host?
|
f.push(" if (!window.mistplayers) {");f.push(' var p = document.createElement("script");');f.push(' p.src = "'+G+'player.js"');f.push(" document.head.appendChild(p);");f.push(" p.onload = a;");f.push(" }");f.push(" else { a(); }");f.push(" <\/script>");f.push("</div>");return f.join("\n")},ba=$("<span>").text("Loading.."),d=w(o),J=$("<div>").text("Loading..").css("display","flex"),oa="";"s"in e&&(oa=UI.buildUI([{label:"Use HTTPS",type:"checkbox","function":function(){if($(this).getval()!=
|
||||||
otherhost.host:s.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(ma)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:G+"json_"+F+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:G+"info_"+F+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},
|
otherhost.https){otherhost.https=$(this).getval();UI.navto("Embed",b)}},value:otherhost.https}]).find("label"));T.append($("<span>").addClass("input_container").append($("<label>").addClass("UIelement").append($("<span>").addClass("label").text("Use a different host:")).append($("<span>").addClass("field_container").append($("<input>").attr("type","text").addClass("field").val(otherhost.host?otherhost.host:r.host)).append($("<span>").addClass("unit").append($("<button>").text("Apply").click(function(){otherhost.host=
|
||||||
{label:"HTML page",type:"str",value:G+F+".html",readonly:!0,qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:d,rows:d.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",
|
$(this).closest("label").find("input").val();UI.navto("Embed",b)}))))).append(oa)).append(UI.buildUI([$("<h3>").text("Urls"),{label:"Stream info json",type:"str",value:G+"json_"+F+".js",readonly:!0,clipboard:!0,help:"Information about this stream as a json page."},{label:"Stream info script",type:"str",value:G+"info_"+F+".js",readonly:!0,clipboard:!0,help:"This script loads information about this stream into a mistvideo javascript object."},{label:"HTML page",type:"str",value:G+F+".html",readonly:!0,
|
||||||
help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=
|
qrcode:!0,clipboard:!0,help:"A basic html containing the embedded stream."},$("<h3>").text("Embed code"),{label:"Embed code",type:"textarea",value:d,rows:d.split("\n").length+3,readonly:!0,classes:["embed_code"],clipboard:!0,help:"Include this code on your webpage to embed the stream. The options below can be used to configure how your content is displayed."},$("<h4>").text("Embed code options (optional)").css("margin-top",0),{type:"help",help:"Use these controls to customise what this embedded video will look like.<br>Not all players have all of these options."},
|
||||||
$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular source."},{label:"Controls",type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:g,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(w(o))},help:"The type of controls that should be shown."},{label:"Autoplay",
|
{label:"Force player",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forcePlayer"},classes:["forcePlayer"],"function":function(){o.forcePlayer=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular player."},{label:"Force source",type:"select",select:[["","Automatic"]],pointer:{main:o,index:"forceType"},classes:["forceType"],"function":function(){o.forceType=$(this).getval();$(".embed_code").setval(w(o))},help:"Only use this particular source."},{label:"Controls",
|
||||||
type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(w(o))},help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(w(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=
|
type:"select",select:[["1","MistServer Controls"],["stock","Player controls"],["0","None"]],pointer:{main:g,index:"controls"},"function":function(){o.controls=$(this).getval()==1;switch($(this).getval()){case 0:o.controls=false;break;case 1:o.controls=true;break;case "stock":o.controls="stock"}$(".embed_code").setval(w(o))},help:"The type of controls that should be shown."},{label:"Autoplay",type:"checkbox",pointer:{main:o,index:"autoplay"},"function":function(){o.autoplay=$(this).getval();$(".embed_code").setval(w(o))},
|
||||||
$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(w(o))},help:"The maximum width this video can use."},{label:"Maximum height",
|
help:"Whether or not the video should play as the page is loaded."},{label:"Loop",type:"checkbox",pointer:{main:o,index:"loop"},"function":function(){o.loop=$(this).getval();$(".embed_code").setval(w(o))},help:"If the video should restart when the end is reached."},{label:"Force width",type:"int",min:0,unit:"px",pointer:{main:o,index:"width"},"function":function(){o.width=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed width."},{label:"Force height",type:"int",min:0,unit:"px",
|
||||||
type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(w(o))},help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(w(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",
|
pointer:{main:o,index:"height"},"function":function(){o.height=$(this).getval();$(".embed_code").setval(w(o))},help:"Enforce a fixed height."},{label:"Maximum width",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxwidth"},"function":function(){o.maxwidth=$(this).getval();$(".embed_code").setval(w(o))},help:"The maximum width this video can use."},{label:"Maximum height",type:"int",min:0,unit:"px",pointer:{main:o,index:"maxheight"},"function":function(){o.maxheight=$(this).getval();$(".embed_code").setval(w(o))},
|
||||||
classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=$(this).getval();$(".embed_code").setval(w(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:J,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),aa]));$.ajax({type:"GET",url:G+"json_"+F+".js",success:function(a){var b=[],c=S.find(".forceType"),d;for(d in a.source){var g=a.source[d],e=UI.humanMime(g.type);b.push({label:e?e+" <span class=description>("+g.type+")</span>":UI.format.capital(g.type),type:"str",
|
help:"The maximum height this video can use."},{label:"Poster",type:"str",pointer:{main:o,index:"poster"},"function":function(){o.poster=$(this).getval();$(".embed_code").setval(w(o))},help:"URL to an image that is displayed when the video is not playing."},{label:"Video URL addition",type:"str",pointer:{main:o,index:"urlappend"},help:"The embed script will append this string to the video url, useful for sending through params.",classes:["embed_code_forceprotocol"],"function":function(){o.urlappend=
|
||||||
value:g.url,readonly:true,qrcode:true,clipboard:true});e=UI.humanMime(g.type);c.append($("<option>").text(e?e+" ("+g.type+")":UI.format.capital(g.type)).val(g.type))}aa.html(UI.buildUI(b));J.html("");b={};for(d in a.meta.tracks){c=a.meta.tracks[d];c.type!="audio"&&c.type!="video"||(c.type in b?b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+1)]):b[c.type]=[["",UI.format.capital(c.type)+" track 1"]])}if(Object.keys(b).length){J.closest("label").show();for(d in b){a=
|
$(this).getval();$(".embed_code").setval(w(o))}},{label:"Preselect tracks",type:"DOMfield",DOMfield:J,help:"Pre-select these tracks."},$("<h3>").text("Protocol stream urls"),ba]));$.ajax({type:"GET",url:G+"json_"+F+".js",success:function(a){var b=[],c=T.find(".forceType"),d;for(d in a.source){var e=a.source[d],f=UI.humanMime(e.type);b.push({label:f?f+" <span class=description>("+e.type+")</span>":UI.format.capital(e.type),type:"str",value:e.url,readonly:true,qrcode:true,clipboard:true});f=UI.humanMime(e.type);
|
||||||
$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(o))});J.append(a);b[d].push([-1,"No "+d]);for(var f in b[d])a.append($("<option>").val(b[d][f][0]).text(b[d][f][1]));if(d in o.setTracks){a.val(o.setTracks[d]);if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(w(o))}}}}else J.closest("label").hide()},error:function(){aa.html("Error while retrieving stream info.");
|
c.append($("<option>").text(f?f+" ("+e.type+")":UI.format.capital(e.type)).val(e.type))}ba.html(UI.buildUI(b));J.html("");b={};for(d in a.meta.tracks){c=a.meta.tracks[d];c.type!="audio"&&c.type!="video"||(c.type in b?b[c.type].push([c.trackid,UI.format.capital(c.type)+" track "+(b[c.type].length+1)]):b[c.type]=[["",UI.format.capital(c.type)+" track 1"]])}if(Object.keys(b).length){J.closest("label").show();for(d in b){a=$("<select>").attr("data-type",d).css("flex-grow","1").change(function(){$(this).val()==
|
||||||
J.closest("label").hide();o.setTracks={}}});g=document.createElement("script");g.src=P+"player.js";document.head.appendChild(g);g.onload=function(){var a=S.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)};break;case "Push":var A=$("<div>").text("Loading..");c.append(A);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;
|
""?delete o.setTracks[$(this).attr("data-type")]:o.setTracks[$(this).attr("data-type")]=$(this).val();$(".embed_code").setval(w(o))});J.append(a);b[d].push([-1,"No "+d]);for(var g in b[d])a.append($("<option>").val(b[d][g][0]).text(b[d][g][1]));if(d in o.setTracks){a.val(o.setTracks[d]);if(a.val()==null){a.val("");delete o.setTracks[d];$(".embed_code").setval(w(o))}}}}else J.closest("label").hide()},error:function(){ba.html("Error while retrieving stream info.");J.closest("label").hide();o.setTracks=
|
||||||
if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,e;for(e in c.push_list)if(a.indexOf(c.push_list[e][0])>-1){d=false;break}}else d=true;if(d)for(e in a)g.find("tr[data-pushid="+a[e]+"]").remove();else b()},{push_list:1})},1E3)}function c(e,f){var h=$("<span>");e.length>=4&&e[2]!=e[3]?h.append($("<span>").text(e[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(e[3])):h.append($("<span>").text(e[2]));var i=$("<td>").append($("<button>").text(f==
|
{}}});g=document.createElement("script");g.src=Q+"player.js";document.head.appendChild(g);g.onload=function(){var a=T.find(".forcePlayer"),b;for(b in mistplayers)a.append($("<option>").text(mistplayers[b].name).val(b));document.head.removeChild(this)};g.onerror=function(){document.head.removeChild(this)};break;case "Push":var B=$("<div>").text("Loading..");c.append(B);mist.send(function(a){function b(a){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=
|
||||||
"Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+$(this).text().toLowerCase()+" this push?\n"+e[1]+" to "+e[2])){var a=$(this).closest("tr");a.html($("<td colspan=99>").html($("<span>").addClass("red").text(f=="Automatic"?"Removing..":"Stopping..")));f=="Automatic"?mist.send(function(){a.remove()},{push_auto_remove:{stream:e[1],target:e[2]}}):mist.send(function(){b([e[0]])},{push_stop:[e[0]]})}}));f=="Automatic"&&i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+
|
true,f;for(f in c.push_list)if(a.indexOf(c.push_list[f][0])>-1){d=false;break}}else d=true;if(d)for(f in a)e.find("tr[data-pushid="+a[f]+"]").remove();else b()},{push_list:1})},1E3)}function c(f,g){var h=$("<span>");f.length>=4&&f[2]!=f[3]?h.append($("<span>").text(f[2])).append($("<span>").html("»").addClass("unit").css("margin","0 0.5em")).append($("<span>").text(f[3])):h.append($("<span>").text(f[2]));var i=$("<td>").append($("<button>").text(g=="Automatic"?"Remove":"Stop").click(function(){if(confirm("Are you sure you want to "+
|
||||||
e[1]+" to "+e[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var c=$(this);c.text("Stopping pushes..");var f=[],h;for(h in a.push_list)if(e[1]==a.push_list[h][1]&&e[2]==a.push_list[h][2]){f.push(a.push_list[h][0]);g.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(f)},{push_stop:f,push_settings:{wait:0}})}}));return $("<tr>").attr("data-pushid",
|
$(this).text().toLowerCase()+" this push?\n"+f[1]+" to "+f[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:f[1],target:f[2]}}):mist.send(function(){b([f[0]])},{push_stop:[f[0]]})}}));g=="Automatic"&&i.append($("<button>").text("Stop pushes").click(function(){if(confirm('Are you sure you want to stop all pushes matching \n"'+f[1]+" to "+
|
||||||
e[0]).append($("<td>").text(e[1])).append($("<td>").append(h.children())).append(i)}A.html("");var d=a.push_settings;d||(d={});A.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"},
|
f[2]+'"?'+(d.wait!=0?"\n\nRetrying is enabled. You'll probably want to set that to 0.":""))){var c=$(this);c.text("Stopping pushes..");var g=[],h;for(h in a.push_list)if(f[1]==a.push_list[h][1]&&f[2]==a.push_list[h][2]){g.push(a.push_list[h][0]);e.find("tr[data-pushid="+a.push_list[h][0]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}mist.send(function(){c.text("Stop pushes");b(g)},{push_stop:g,push_settings:{wait:0}})}}));return $("<tr>").attr("data-pushid",
|
||||||
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 g=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=g.clone();
|
f[0]).append($("<td>").text(f[1])).append($("<td>").append(h.children())).append(i)}B.html("");var d=a.push_settings;d||(d={});B.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"},
|
||||||
if("push_list"in a)for(var f in a.push_list)g.append(c(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(c([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));A.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));e.find("tr").length==1?A.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):A.append(e);
|
LTSonly:1},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:d,index:"maxspeed"},LTSonly:1},{type:"buttons",buttons:[{type:"save",label:"Save","function":function(){mist.send(function(){UI.navto("Push")},{push_settings:d})}}]}]));var e=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),f=e.clone();
|
||||||
A.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(g.find("tr").length==1)A.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var e=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),k=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(f in a.push_list){e.indexOf(a.push_list[f][1])==-1&&e.push(a.push_list[f][1]);
|
if("push_list"in a)for(var g in a.push_list)e.append(c(a.push_list[g],"Manual"));if("push_auto_list"in a)for(g in a.push_auto_list)f.append(c([-1,a.push_auto_list[g][0],a.push_auto_list[g][1]],"Automatic"));B.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push","auto")}));f.find("tr").length==1?B.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):B.append(f);
|
||||||
h.indexOf(a.push_list[f][2])==-1&&h.push(a.push_list[f][2])}e.sort();h.sort();for(f in e)i.append($("<option>").text(e[f]));for(f in h)k.append($("<option>").text(h[f]));A.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});g.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
|
B.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));if(e.find("tr").length==1)B.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em"));else{var f=[],h=[],i=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any stream").val("")),j=$("<select>").css("margin-left","0.5em").append($("<option>").text("Any target").val(""));for(g in a.push_list){f.indexOf(a.push_list[g][1])==-1&&f.push(a.push_list[g][1]);
|
||||||
$(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(k).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=k.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var e={},f;for(f in a.push_list)if((c==""||
|
h.indexOf(a.push_list[g][2])==-1&&h.push(a.push_list[g][2])}f.sort();h.sort();for(g in f)i.append($("<option>").text(f[g]));for(g in h)j.append($("<option>").text(h[g]));B.append($("<button>").text("Stop all pushes").click(function(){var c=[],d;for(d in a.push_list)c.push(a.push_list[d][0]);if(c.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){b(c)},{push_stop:c});e.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));
|
||||||
a.push_list[f][1]==c)&&(d==""||a.push_list[f][2]==d))e[a.push_list[f][0]]=a.push_list[f];if(Object.keys(e).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(f in e)c=c+(e[f][1]+" to "+e[f][2]+"\n");if(confirm(c)){e=Object.keys(e);mist.send(function(){b(e)},{push_stop:e});for(f in e)g.find("tr[data-pushid="+e[f]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(g)}},{push_settings:1,push_list:1,push_auto_list:1});
|
$(this).remove()}})).append($("<label>").css("margin-left","1em").append($("<span>").text("Stop all pushes that match: ").css("font-size","0.9em")).append(i).append($("<span>").css("margin-left","0.5em").text("and").css("font-size","0.9em")).append(j).append($("<button>").css("margin-left","0.5em").text("Apply").click(function(){var c=i.val(),d=j.val();if(c==""&&d=="")return alert("Looks like you want to stop all pushes. Maybe you should use that button?");var f={},g;for(g in a.push_list)if((c==""||
|
||||||
break;case "Start Push":if(!("capabilities"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1});return}var u,ba=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var e=mist.data.capabilities.connectors[d];"push_urls"in e&&(a=a.concat(e.push_urls))}b=="auto"&&c.find("h2").text("Add automatic push");var g={};c.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
a.push_list[g][1]==c)&&(d==""||a.push_list[g][2]==d))f[a.push_list[g][0]]=a.push_list[g];if(Object.keys(f).length==0)return alert("No matching pushes.");c="Are you sure you want to stop these pushes?\n\n";for(g in f)c=c+(f[g][1]+" to "+f[g][2]+"\n");if(confirm(c)){f=Object.keys(f);mist.send(function(){b(f)},{push_stop:f});for(g in f)e.find("tr[data-pushid="+f[g]+"]").html($("<td colspan=99>").html($("<span>").addClass("red").text("Stopping..")))}}))).append(e)}},{push_settings:1,push_list:1,push_auto_list:1});
|
||||||
pointer:{main:g,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:u,LTSonly:1},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul> Valid text replacements:<ul><li>$stream - inserts the stream name used to push to MistServer</li><li>$day - inserts the current day number</li><li>$month - inserts the current month number</li><li>$year - inserts the current year number</li><li>$hour - inserts the hour timestamp when stream was received</li><li>$minute - inserts the minute timestamp the stream was received</li><li>$seconds - inserts the seconds timestamp when the stream was received</li><li>$datetime - inserts $year.$month.$day.$hour.$minute.$seconds timestamp when the stream was received</li>",
|
break;case "Start Push":if(!("capabilities"in mist.data)){c.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push",b)},{capabilities:1});return}var v,ca=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}b=="auto"&&c.find("h2").text("Add automatic push");var e={};c.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
||||||
pointer:{main:g,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[b=="auto"?"push_auto_add":"push_start"]=g;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
pointer:{main:e,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>",
|
||||||
mist.send(function(a){(u=a.active_streams)||(u=[]);var a=[],b;for(b in u)u[b].indexOf("+")!=-1&&a.push(u[b].replace(/\+.*/,"")+"+");u=u.concat(a);var c=0,d=0;for(b in mist.data.streams){u.push(b);if(mist.inputMatch(UI.findInput("Folder").source_match,mist.data.streams[b].source)){u.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||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder.exe")>=
|
pointer:{main:e,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",classes:["red"]}}],LTSonly:1},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[b=="auto"?"push_auto_add":"push_start"]=e;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?
|
||||||
0)||mist.inputMatch(mist.data.capabilities.inputs[f].source_match,"/"+a.browse.files[g])&&u.push(e+"+"+a.browse.files[g]);d++;if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ba()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){u=u.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ba()}},{active_streams:1}):(u=Object.keys(mist.data.streams),ba());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});j=$("<tbody>");r=
|
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(UI.findInput("Folder").source_match,mist.data.streams[b].source)){v.push(b+"+");mist.send(function(a,b){var f=b.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||(g.indexOf("Folder")>=0||g.indexOf("Buffer.exe")>=0||g.indexOf("Folder.exe")>=
|
||||||
$("<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(j);c.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(r);
|
0)||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&v.push(f+"+"+a.browse.files[e]);d++;if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{browse:mist.data.streams[b].source},{stream:b});c++}}if(c==d){v=v.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();ca()}},{active_streams:1}):(v=Object.keys(mist.data.streams),ca());break;case "Triggers":"triggers"in mist.data.config||(mist.data.config.triggers={});z=$("<tbody>");e=
|
||||||
r.stupidtable();r=mist.data.config.triggers;for(g in r)for(s in r[g])j.append($("<tr>").attr("data-index",g+","+s).append($("<td>").text(g)).append($("<td>").text(r[g][s][2].join(", "))).append($("<td>").text(r[g][s][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 "+
|
$("<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(z);c.append(UI.buildUI([{type:"help",help:"Triggers are the system you can use to react to events that occur inside MistServer. These allow you to block specific users, redirect streams, keep tabs on what is being pushed where, etcetera. For full documentation, please refer to the developer documentation section on the MistServer website."}])).append($("<button>").text("New trigger").click(function(){UI.navto("Edit Trigger")})).append(e);
|
||||||
|
e.stupidtable();e=mist.data.config.triggers;for(g in e)for(r in e[g])z.append($("<tr>").attr("data-index",g+","+r).append($("<td>").text(g)).append($("<td>").text(e[g][r][2].join(", "))).append($("<td>").text(e[g][r][0])).append($("<td>").html($("<button>").text("Edit").click(function(){UI.navto("Edit Trigger",$(this).closest("tr").attr("data-index"))})).append($("<button>").text("Delete").click(function(){var a=$(this).closest("tr").attr("data-index").split(",");if(confirm("Are you sure you want to delete this "+
|
||||||
a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});b?(b=b.split(","),g=mist.data.config.triggers[b[0]][b[1]],n={triggeron:b[0],appliesto:g[2],url:g[0],async:g[1],"default":g[3]}):(c.html($("<h2>").text("New Trigger")),n={});c.append(UI.buildUI([{label:"Trigger on",
|
a[0]+" trigger?")){mist.data.config.triggers[a[0]].splice(a[1],1);mist.data.config.triggers[a[0]].length==0&&delete mist.data.config.triggers[a[0]];mist.send(function(){UI.navto("Triggers")},{config:mist.data.config})}}))));break;case "Edit Trigger":"triggers"in mist.data.config||(mist.data.config.triggers={});b?(b=b.split(","),g=mist.data.config.triggers[b[0]][b[1]],n={triggeron:b[0],appliesto:g[2],url:g[0],async:g[1],"default":g[3]}):(c.html($("<h2>").text("New Trigger")),n={});c.append(UI.buildUI([{label:"Trigger on",
|
||||||
pointer:{main:n,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD",
|
pointer:{main:n,index:"triggeron"},help:"For what event this trigger should activate.",type:"select",select:[["SYSTEM_START","SYSTEM_START: after MistServer boot"],["SYSTEM_STOP","SYSTEM_STOP: right before MistServer shutdown"],["SYSTEM_CONFIG","SYSTEM_CONFIG: after MistServer configurations have changed"],["OUTPUT_START","OUTPUT_START: right after the start command has been send to a protocol"],["OUTPUT_STOP","OUTPUT_STOP: right after the close command has been send to a protocol "],["STREAM_ADD",
|
||||||
"STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],
|
"STREAM_ADD: right before new stream configured"],["STREAM_CONFIG","STREAM_CONFIG: right before a stream configuration has changed"],["STREAM_REMOVE","STREAM_REMOVE: right before a stream has been deleted"],["STREAM_SOURCE","STREAM_SOURCE: right before stream source is loaded"],["STREAM_LOAD","STREAM_LOAD: right before stream input is loaded in memory"],["STREAM_READY","STREAM_READY: when the stream input is loaded and ready for playback"],["STREAM_UNLOAD","STREAM_UNLOAD: right before the stream input is removed from memory"],
|
||||||
|
@ -168,35 +169,35 @@ pointer:{main:n,index:"triggeron"},help:"For what event this trigger should acti
|
||||||
break;default:$("[name=appliesto]").closest(".UIelement").show()}}},{label:"Applies to",pointer:{main:n,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main:n,index:"url"},validate:["required"],
|
break;default:$("[name=appliesto]").closest(".UIelement").show()}}},{label:"Applies to",pointer:{main:n,index:"appliesto"},help:"For triggers that can apply to specific streams, this value decides what streams they are triggered for. (none checked = always triggered)",type:"checklist",checklist:Object.keys(mist.data.streams),LTSonly:!0},$("<br>"),{label:"Handler (URL or executable)",help:"This can be either an HTTP URL or a full path to an executable.",pointer:{main: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"},
|
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(){b&&mist.data.config.triggers[b[0]].splice(b[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")},
|
LTSonly:!0},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Triggers")}},{type:"save",label:"Save","function":function(){b&&mist.data.config.triggers[b[0]].splice(b[1],1);var a=[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":var na=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){ca();na.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",
|
{config:mist.data.config})}}]}]));$("[name=triggeron]").trigger("change");break;case "Logs":var pa=$("<button>").text("Refresh now").click(function(){$(this).text("Loading..");mist.send(function(){da();pa.text("Refresh now")})}).css("padding","0.2em 0.5em").css("flex-grow",0);c.append(UI.buildUI([{type:"help",help:"Here you have an overview of all edited settings within MistServer and possible warnings or errors MistServer has encountered. MistServer stores up to 100 logs at a time."},{label:"Refresh every",
|
||||||
type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){ca()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:na,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));j=
|
type:"select",select:[[10,"10 seconds"],[30,"30 seconds"],[60,"minute"],[300,"5 minutes"]],value:30,"function":function(){UI.interval.clear();UI.interval.set(function(){mist.send(function(){da()})},$(this).val()*1E3)},help:"How often the table below should be updated."},{label:"..or",type:"DOMfield",DOMfield:pa,help:"Instantly refresh the table below."}]));c.append($("<button>").text("Purge logs").click(function(){mist.send(function(){mist.data.log=[];UI.navto("Logs")},{clearstatlogs:true})}));z=
|
||||||
$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(j));var pa=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},ca=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();j.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),e;for(e in d)c.append($("<span>").text(d[e]));j.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],
|
$("<tbody>").css("font-size","0.9em");c.append($("<table>").addClass("logs").append(z));var ra=function(a){var b=$("<span>").text(a);switch(a){case "WARN":b.addClass("orange");break;case "ERROR":case "FAIL":b.addClass("red")}return b},da=function(){var a=mist.data.log;if(a){a.length>=2&&a[0][0]<a[a.length-1][0]&&a.reverse();z.html("");for(var b in a){var c=$("<span>").addClass("content"),d=a[b][2].split("|"),f;for(f in d)c.append($("<span>").text(d[f]));z.append($("<tr>").html($("<td>").text(UI.format.dateTime(a[b][0],
|
||||||
"long")).css("white-space","nowrap")).append($("<td>").html(pa(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};ca();break;case "Statistics":var B=$("<span>").text("Loading..");c.append(B);var n={graph:"new"},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},N={};for(g in mist.data.streams)N[g]=!0;for(g in mist.data.active_streams)N[mist.data.active_streams[g]]=!0;var N=Object.keys(N).sort(),da=[];for(g in mist.data.config.protocols)da.push(mist.data.config.protocols[g].connector);
|
"long")).css("white-space","nowrap")).append($("<td>").html(ra(a[b][1])).css("text-align","center")).append($("<td>").html(c).css("text-align","left")))}}};da();break;case "Statistics":var C=$("<span>").text("Loading..");c.append(C);var n={graph:"new"},x=mist.stored.get().graphs?$.extend(!0,{},mist.stored.get().graphs):{},O={};for(g in mist.data.streams)O[g]=!0;for(g in mist.data.active_streams)O[mist.data.active_streams[g]]=!0;var O=Object.keys(O).sort(),ea=[];for(g in mist.data.config.protocols)ea.push(mist.data.config.protocols[g].connector);
|
||||||
da.sort();mist.send(function(){UI.plot.datatype.templates.cpuload.cores=0;for(var a in mist.data.capabilities.cpu)UI.plot.datatype.templates.cpuload.cores=UI.plot.datatype.templates.cpuload.cores+mist.data.capabilities.cpu[a].cores;B.html(UI.buildUI([{type:"help",help:"Here you will find the MistServer stream statistics, you can select various categories yourself. All statistics are live: up to five minutes are saved."},$("<h3>").text("Select the data to display"),{label:"Add to",type:"select",select:[["new",
|
ea.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;C.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=B.find(".graph_xaxis"),b=B.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&
|
"New graph"]],pointer:{main:n,index:"graph"},classes:["graph_ids"],"function":function(){if($(this).val()){var a=C.find(".graph_xaxis"),b=C.find(".graph_id");if($(this).val()=="new"){a.children("option").prop("disabled",false);b.setval("Graph "+(Object.keys(x).length+1)).closest("label").show()}else{var c=x[$(this).val()].xaxis;a.children("option").prop("disabled",true).filter('[value="'+c+'"]').prop("disabled",false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disabled').length&&
|
||||||
a.val(a.children("option:enabled").first().val());a.trigger("change")}}},{label:"Graph id",type:"str",pointer:{main:n,index:"id"},classes:["graph_id"],validate:[function(a){return a in x?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=B.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",
|
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 x?{msg:"This graph id has already been used. Please enter something else.",classes:["red"]}:false}]},{label:"Axis type",type:"select",select:[["time","Time line"]],pointer:{main:n,index:"xaxis"},value:"time",classes:["graph_xaxis"],"function":function(){$s=C.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",
|
||||||
true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords",
|
true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords",
|
||||||
"Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=B.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",N],["protocol",
|
"Client location"]],pointer:{main:n,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=C.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:",O],["protocol",
|
||||||
"The protocol:",da]],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,b);x[a.id]=a;B.find("input.graph_id").val("");B.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=x[n.graph];var c=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));
|
"The protocol:",ea]],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,b);x[a.id]=a;C.find("input.graph_id").val("");C.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=x[n.graph];var c=UI.plot.datatype.getOptions({datatype:n.datatype,origin:n.origin});a.datasets.push(c);UI.plot.save(a);UI.plot.go(x)}}]}]));
|
||||||
var b=$("<div>").addClass("graph_container");c.append(b);var d=B.find("select.graph_ids");for(a in x){var e=UI.plot.addGraph(x[a],b);d.append($("<option>").text(e.id)).val(e.id);var g=[],f;for(f in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[f].datatype,origin:x[a].datasets[f].origin});g.push(h)}e.datasets=g;x[e.id]=e}d.trigger("change");UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==
|
var b=$("<div>").addClass("graph_container");c.append(b);var d=C.find("select.graph_ids");for(a in x){var f=UI.plot.addGraph(x[a],b);d.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in x[a].datasets){var h=UI.plot.datatype.getOptions({datatype:x[a].datasets[g].datatype,origin:x[a].datasets[g].origin});e.push(h)}f.datasets=e;x[f.id]=f}d.trigger("change");UI.plot.go(x);UI.interval.set(function(){UI.plot.go(x)},1E4)},{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==
|
||||||
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var ea=$("<table>"),D=$("<table>"),s={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)r=mist.data.capabilities.cpu[g],s.content.push({header:"CPU #"+(Number(g)+1),body:[r.model,UI.format.addUnit(UI.format.number(r.mhz),"MHz"),r.cores,r.threads]});var g=UI.buildVheaderTable(s),oa=function(){var a=mist.data.capabilities.mem,
|
typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});c.append("Loading..");return}var fa=$("<table>"),D=$("<table>"),r={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(g in mist.data.capabilities.cpu)e=mist.data.capabilities.cpu[g],r.content.push({header:"CPU #"+(Number(g)+1),body:[e.model,UI.format.addUnit(UI.format.number(e.mhz),"MHz"),e.cores,e.threads]});g=UI.buildVheaderTable(r);var qa=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);
|
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);
|
||||||
ea.replaceWith(a);ea=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);D.replaceWith(b);D=b};oa();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width",
|
fa.replaceWith(a);fa=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);D.replaceWith(b);D=b};qa();c.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width",
|
||||||
"auto").addClass("nolay").append($("<tr>").append($("<td>").append(ea)).append($("<td>").append(D))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){oa()},{capabilities:true})},3E4);break;case "Email for Help":g=$.extend({},mist.data);delete g.statistics;delete g.totals;delete g.clients;delete g.capabilities;g=JSON.stringify(g);g="Version: "+mist.data.config.version+"\n\nConfig:\n"+g;n={};c.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},
|
"auto").addClass("nolay").append($("<tr>").append($("<td>").append(fa)).append($("<td>").append(D))).append($("<tr>").append($("<td>").append(g).attr("colspan",2))));UI.interval.set(function(){mist.send(function(){qa()},{capabilities:true})},3E4);break;case "Email for Help":g=$.extend({},mist.data);delete g.statistics;delete g.totals;delete g.clients;delete g.capabilities;g=JSON.stringify(g);g="Version: "+mist.data.config.version+"\n\nConfig:\n"+g;n={};c.append(UI.buildUI([{type:"help",help:"You can use this form to email MistServer support if you're having difficulties.<br>A copy of your server config file will automatically be included."},
|
||||||
{type:"str",label:"Your name",validate:["required"],pointer:{main: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:g,
|
{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:g,
|
||||||
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?skin=plain",data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}c.find(".field").filter(function(){return $(this).getval()==
|
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?skin=plain",data:n,success:function(a){a=$("<span>").html(a);a.find("script").remove();c.html(a[0].innerHTML)}})}}]}]));break;case "Disconnect":mist.user.password="";delete mist.user.authstring;delete mist.user.loggedin;sessionStorage.removeItem("mistLogin");UI.navto("Login");break;default:c.append($("<p>").text("This tab does not exist."))}c.find(".field").filter(function(){return $(this).getval()==
|
||||||
""}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}}};"origin"in location||(location.origin=location.protocol+"//"+location.hostname+(location.port?":"+location.port:""));
|
""}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api";
|
||||||
var mist={data:{},user:{name:"",password:"",host:location.origin+location.pathname.replace(/\/+$/,"")+"/api"},send:function(a,b,c){var b=b||{},c=c||{},c=$.extend(true,{timeOut:3E4,sendData:b},c),d={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,b);log("Send",$.extend(true,{},b));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:c.timeout*1E3,async:true,error:function(d,
|
var mist={data:{},user:{name:"",password:"",host:host},send:function(a,b,c){var b=b||{},c=c||{},c=$.extend(true,{timeOut:3E4,sendData:b},c),d={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,d,b);log("Send",$.extend(true,{},b));d={url:mist.user.host,type:"POST",data:{command:JSON.stringify(d)},dataType:"jsonp",crossDomain:true,timeout:c.timeout*1E3,async:true,error:function(d,e){delete mist.user.loggedin;if(!c.hide){switch(e){case "timeout":e=
|
||||||
e){delete mist.user.loggedin;if(!c.hide){switch(e){case "timeout":e=$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(e).append($("<a>").text("Send server request again").click(function(){mist.send(a,b,c)}))}UI.navto("Login")},success:function(d){log("Receive",
|
$("<i>").text("The connection timed out. ");break;case "abort":e=$("<i>").text("The connection was aborted. ");break;default:e=$("<i>").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("<br>")).append(e).append($("<a>").text("Send server request again").click(function(){mist.send(a,b,c)}))}UI.navto("Login")},success:function(d){log("Receive",$.extend(true,{},d),"as reply to",c.sendData);
|
||||||
$.extend(true,{},d),"as reply to",c.sendData);delete mist.user.loggedin;switch(d.authorize.status){case "OK":if("streams"in d)if(d.streams)if("incomplete list"in d.streams){delete d.streams["incomplete list"];$.extend(mist.data.streams,d.streams)}else mist.data.streams=d.streams;else mist.data.streams={};var e=$.extend({},d),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)f.indexOf(q)==-1&&delete e[q];$.extend(true,mist.data,e);mist.user.loggedin=
|
delete mist.user.loggedin;switch(d.authorize.status){case "OK":if("streams"in d)if(d.streams)if("incomplete list"in d.streams){delete d.streams["incomplete list"];$.extend(mist.data.streams,d.streams)}else mist.data.streams=d.streams;else mist.data.streams={};var e=$.extend({},d),f=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals"],q;for(q in e)f.indexOf(q)==-1&&delete e[q];$.extend(true,mist.data,e);mist.user.loggedin=true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");
|
||||||
true;UI.elements.connection.status.text("Connected").removeClass("red").addClass("green");UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){e=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(e[0])+" ["+e[1]+
|
UI.elements.connection.user_and_host.text(mist.user.name+" @ "+mist.user.host);UI.elements.connection.msg.removeClass("red").text("Last communication with the server at "+UI.format.time((new Date).getTime()/1E3));d.LTS&&UI.elements.menu.find(".LTSonly").removeClass("LTSonly");if(d.log){e=d.log[d.log.length-1];UI.elements.connection.msg.append($("<br>")).append("Last log entry: "+UI.format.time(e[0])+" ["+e[1]+"] "+e[2])}if("totals"in d){e=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([m,
|
||||||
"] "+e[2])}if("totals"in d){e=function(a,b,c){var d;d=function(){for(var a in c.fields)e[c.fields[a]].push([k,0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var j=0,k;if(c.data){if(c.start>mist.data.config.time-600){k=(mist.data.config.time-600)*1E3;d();k=c.start*1E3;d()}else k=c.start*1E3;for(f in c.data){if(f==0){k=c.start*1E3;var m=0}else{k=k+c.interval[m][1]*1E3;c.interval[m][0]--;if(c.interval[m][0]<=0){m++;m<c.interval.length-1&&(j=j+2)}}if(j%2==1){d();j--}for(var q in c.data[f])e[c.fields[q]].push([k,
|
0])};var e={},f;for(f in c.fields)e[c.fields[f]]=[];var g=0,m;if(c.data){if(c.start>mist.data.config.time-600){m=(mist.data.config.time-600)*1E3;d();m=c.start*1E3;d()}else m=c.start*1E3;for(f in c.data){if(f==0){m=c.start*1E3;var q=0}else{m=m+c.interval[q][1]*1E3;c.interval[q][0]--;if(c.interval[q][0]<=0){q++;q<c.interval.length-1&&(g=g+2)}}if(g%2==1){d();g--}for(var K in c.data[f])e[c.fields[K]].push([m,c.data[f][K]]);if(g){d();g--}}if(mist.data.config.time-c.end>20){d();m=(mist.data.config.time-
|
||||||
c.data[f][q]]);if(j){d();j--}}if(mist.data.config.time-c.end>20){d();k=(mist.data.config.time-15)*1E3;d()}}else{k=(mist.data.config.time-600)*1E3;d();k=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in d.totals)e(b.totals.streams,
|
15)*1E3;d()}}else{m=(mist.data.config.time-600)*1E3;d();m=(mist.data.config.time-15)*1E3;d()}d=e;stream=a?a.join(" "):"all_streams";protocol=b?b.join("_"):"all_protocols";stream in mist.data.totals||(mist.data.totals[stream]={});protocol in mist.data.totals[stream]||(mist.data.totals[stream][protocol]={});$.extend(mist.data.totals[stream][protocol],d)};mist.data.totals={};if("fields"in d.totals)e(b.totals.streams,b.totals.protocols,d.totals);else for(q in d.totals)e(b.totals[q].streams,b.totals[q].protocols,
|
||||||
b.totals.protocols,d.totals);else for(q in d.totals)e(b.totals[q].streams,b.totals[q].protocols,d.totals[q])}a&&a(d,c);break;case "CHALL":if(d.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=d.authorize.challenge;mist.send(a,b,c);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,
|
d.totals[q])}a&&a(d,c);break;case "CHALL":if(d.authorize.challenge==mist.user.authstring){mist.user.password!=""&&UI.elements.connection.msg.text("The credentials you provided are incorrect.").addClass("red");UI.navto("Login")}else if(mist.user.password=="")UI.navto("Login");else{mist.user.authstring=d.authorize.challenge;mist.send(a,b,c);sessionStorage.setItem("mistLogin",JSON.stringify({host:mist.user.host,name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");
|
||||||
name:mist.user.name,password:mist.user.password}))}break;case "NOACC":UI.navto("Create a new account");break;case "ACC_MADE":delete b.authorize;mist.send(a,b,c);break;default:UI.navto("Login")}}};c.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(d)},inputMatch:function(a,b){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var c in a){var d=
|
break;case "ACC_MADE":delete b.authorize;mist.send(a,b,c);break;default:UI.navto("Login")}}};c.hide||UI.elements.connection.msg.removeClass("red").text("Data sent, waiting for a reply..").append($("<br>")).append($("<a>").text("Cancel request").click(function(){e.abort()}));var e=$.ajax(d)},inputMatch:function(a,b){if(typeof a=="undefined")return false;typeof a=="string"&&(a=[a]);for(var c in a){var d=a[c].replace(/[^\w\s]/g,"\\$&"),d=d.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");if(RegExp("^(?:[a-zA-Z]:)?"+
|
||||||
a[c].replace(/[^\w\s]/g,"\\$&"),d=d.replace(/\\\?/g,".").replace(/\\\*/g,"(?:.)*");if(RegExp("^(?:[a-zA-Z]:)?"+d+"$","i").test(b))return true}return false},convertBuildOptions:function(a,b){var c=[],d=["required","optional"];"desc"in a&&c.push({type:"help",help:a.desc});for(var e in d)if(a[d[e]]){c.push($("<h4>").text(UI.format.capital(d[e])+" parameters"));for(var k in a[d[e]]){var m=a[d[e]][k],f={label:UI.format.capital(m.name),pointer:{main:b,index:k},validate:[]};d[e]=="required"&&(!("default"in
|
d+"$","i").test(b))return true}return false},convertBuildOptions:function(a,b){var c=[],d=["required","optional"];"desc"in a&&c.push({type:"help",help:a.desc});for(var e in d)if(a[d[e]]){c.push($("<h4>").text(UI.format.capital(d[e])+" parameters"));for(var g in a[d[e]]){var m=a[d[e]][g],f={label:UI.format.capital(m.name),pointer:{main:b,index:g},validate:[]};d[e]=="required"&&(!("default"in m)||m["default"]=="")&&f.validate.push("required");if("default"in m)f.placeholder=m["default"];if("help"in m)f.help=
|
||||||
m)||m["default"]=="")&&f.validate.push("required");if("default"in m)f.placeholder=m["default"];if("help"in m)f.help=m.help;if("unit"in m)f.unit=m.unit;switch(m.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=m.select;break;default:f.type="str"}c.push(f)}}return c},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,b){var c=this.get();c[a]=b;mist.send(function(){},{ui_settings:c})},
|
m.help;if("unit"in m)f.unit=m.unit;switch(m.type){case "int":f.type="int";break;case "uint":f.type="int";f.min=0;break;case "debug":f.type="debug";break;case "select":f.type="select";f.select=m.select;break;default:f.type="str"}c.push(f)}}return c},stored:{get:function(){return mist.data.ui_settings||{}},set:function(a,b){var c=this.get();c[a]=b;mist.send(function(){},{ui_settings:c})},del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};
|
||||||
del:function(a){delete mist.data.ui_settings[a];mist.send(function(){},{ui_settings:mist.data.ui_settings})}}};function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
|
function log(){try{UI.debug&&[].push.call(arguments,Error().stack);[].unshift.call(arguments,"["+UI.format.time((new Date).getTime()/1E3)+"]");console.log.apply(console,arguments)}catch(a){}}
|
||||||
$.fn.getval=function(){var a=$(this).data("opts"),b=$(this).val();if(a&&"type"in a)switch(a.type){case "span":b=$(this).html();break;case "checkbox":b=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){b=[];b.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&b.push(a.val())}else b="";break;case "checklist":b=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){b.push($(this).attr("name"))})}return b};
|
$.fn.getval=function(){var a=$(this).data("opts"),b=$(this).val();if(a&&"type"in a)switch(a.type){case "span":b=$(this).html();break;case "checkbox":b=$(this).prop("checked");break;case "radioselect":a=$(this).find("label > input[type=radio]:checked").parent();if(a.length){b=[];b.push(a.children("input[type=radio]").val());a=a.children("select");a.length&&b.push(a.val())}else b="";break;case "checklist":b=[];$(this).find(".checklist input[type=checkbox]:checked").each(function(){b.push($(this).attr("name"))})}return b};
|
||||||
$.fn.setval=function(a){var b=$(this).data("opts");$(this).val(a);if(b&&"type"in b)switch(b.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":b=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";b.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),c;for(c in a)b.values.append(b.prototype.clone(true).val(a[c]));b.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
|
$.fn.setval=function(a){var b=$(this).data("opts");$(this).val(a);if(b&&"type"in b)switch(b.type){case "span":$(this).html(a);break;case "checkbox":$(this).prop("checked",a);break;case "geolimited":case "hostlimited":b=$(this).closest(".field_container").data("subUI");if(typeof a=="undefined"||a.length==0)a="-";b.blackwhite.val(a.charAt(0));var a=a.substr(1).split(" "),c;for(c in a)b.values.append(b.prototype.clone(true).val(a[c]));b.blackwhite.trigger("change");break;case "radioselect":if(typeof a==
|
||||||
"undefined")return $(this);c=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&c.children("select").val(a[1]);break;case "checklist":b=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(c in a)b.filter('[name="'+a[c]+'"]').prop("checked",true)}$(this).trigger("change");return $(this)};function parseURL(a){var b=document.createElement("a");b.href=a;return{protocol:b.protocol+"//",host:b.hostname,port:b.port?":"+b.port:""}};
|
"undefined")return $(this);c=$(this).find('label > input[type=radio][value="'+a[0]+'"]').prop("checked",true).parent();a.length>1&&c.children("select").val(a[1]);break;case "checklist":b=$(this).find(".checklist input[type=checkbox]").prop("checked",false);for(c in a)b.filter('[name="'+a[c]+'"]').prop("checked",true)}$(this).trigger("change");return $(this)};function parseURL(a){var b=document.createElement("a");b.href=a;return{protocol:b.protocol+"//",host:b.hostname,port:b.port?":"+b.port:""}};
|
||||||
|
|
61
lsp/mist.js
61
lsp/mist.js
|
@ -1830,6 +1830,20 @@ var UI = {
|
||||||
$currbut.addClass('active');
|
$currbut.addClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//unload any video's that might still be playing
|
||||||
|
if (typeof mistvideo != 'undefined') {
|
||||||
|
for (var s in mistvideo) {
|
||||||
|
if ('embedded' in mistvideo[s]) {
|
||||||
|
for (var i in mistvideo[s].embedded) {
|
||||||
|
try {
|
||||||
|
mistvideo[s].embedded[i].player.unload();
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UI.interval.clear();
|
UI.interval.clear();
|
||||||
$main.html(
|
$main.html(
|
||||||
$('<h2>').text(tab)
|
$('<h2>').text(tab)
|
||||||
|
@ -3340,8 +3354,22 @@ var UI = {
|
||||||
var $video = $('<div>').addClass('mistvideo').text('Loading player..');
|
var $video = $('<div>').addClass('mistvideo').text('Loading player..');
|
||||||
$preview_cont.append($video).append($title).append($switches);
|
$preview_cont.append($video).append($title).append($switches);
|
||||||
function initPlayer() {
|
function initPlayer() {
|
||||||
//$video.html('');
|
|
||||||
$log.html('');
|
$log.html('');
|
||||||
|
|
||||||
|
//unload any video's that might still be playing
|
||||||
|
if (typeof mistvideo != 'undefined') {
|
||||||
|
for (var s in mistvideo) {
|
||||||
|
if ('embedded' in mistvideo[s]) {
|
||||||
|
for (var i in mistvideo[s].embedded) {
|
||||||
|
try {
|
||||||
|
mistvideo[s].embedded[i].player.unload();
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
target: $video[0],
|
target: $video[0],
|
||||||
maxheight: window.innerHeight - $('header').height(),
|
maxheight: window.innerHeight - $('header').height(),
|
||||||
|
@ -3362,21 +3390,38 @@ var UI = {
|
||||||
$('<h3>').text('Player log:')
|
$('<h3>').text('Player log:')
|
||||||
).append($log)
|
).append($log)
|
||||||
);
|
);
|
||||||
|
var lastlog = '';
|
||||||
$video.on('log error',function(e){
|
$video.on('log error',function(e){
|
||||||
var scroll = false;
|
var scroll = false;
|
||||||
if ($log.height() + $log.scrollTop() == $log[0].scrollHeight) { scroll = true; }
|
if ($log.height() + $log.scrollTop() == $log[0].scrollHeight) { scroll = true; }
|
||||||
|
|
||||||
|
//if this new message is the same as the previous, merge them
|
||||||
|
var newlog = e.type+e.originalEvent.message;
|
||||||
|
var timestamp = '['+UI.format.time((new Date()).getTime() / 1e3)+']';
|
||||||
|
if (lastlog == newlog) {
|
||||||
|
var $div = $log.children().last();
|
||||||
|
var $span = $div.children('[data-amount]');
|
||||||
|
var amount = $span.attr('data-amount');
|
||||||
|
amount++;
|
||||||
|
$span.text('('+amount+'x)').attr('data-amount',amount);
|
||||||
|
$div.children('.timestamp').text(timestamp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$log.append(
|
$log.append(
|
||||||
$('<div>').append(
|
$('<div>').append(
|
||||||
$('<span>').text('['+UI.format.time((new Date()).getTime() / 1e3)+']').css('margin-right','0.5em')
|
$('<span>').addClass('timestamp').text(timestamp).css('margin-right','0.5em')
|
||||||
).append(
|
).append(
|
||||||
$('<span>').text(e.originalEvent.message)
|
$('<span>').text(e.originalEvent.message)
|
||||||
|
).append(
|
||||||
|
$('<span>').attr('data-amount',1).css('margin-left','0.5em')
|
||||||
).addClass((e.type == 'error' ? 'red' : ''))
|
).addClass((e.type == 'error' ? 'red' : ''))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (scroll) {
|
if (scroll) {
|
||||||
$log.scrollTop($log[0].scrollHeight);
|
$log.scrollTop($log[0].scrollHeight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
lastlog = newlog;
|
||||||
});
|
});
|
||||||
|
|
||||||
//load the player js
|
//load the player js
|
||||||
|
@ -5278,15 +5323,21 @@ var UI = {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!('origin' in location)) {
|
if (!('origin' in location)) {
|
||||||
location.origin = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : '');
|
location.origin = location.protocol+'//';
|
||||||
|
}
|
||||||
|
var host;
|
||||||
|
if (location.origin == 'file://') {
|
||||||
|
host = 'http://localhost:4242/api';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
host = location.origin+location.pathname.replace(/\/+$/, "")+'/api';
|
||||||
}
|
}
|
||||||
|
|
||||||
var mist = {
|
var mist = {
|
||||||
data: {},
|
data: {},
|
||||||
user: {
|
user: {
|
||||||
name: '',
|
name: '',
|
||||||
password: '',
|
password: '',
|
||||||
host: location.origin+location.pathname.replace(/\/+$/, "")+'/api'
|
host: host
|
||||||
},
|
},
|
||||||
send: function(callback,sendData,opts){
|
send: function(callback,sendData,opts){
|
||||||
sendData = sendData || {};
|
sendData = sendData || {};
|
||||||
|
|
|
@ -435,12 +435,12 @@ namespace Mist {
|
||||||
uint32_t fragIndice = Trk.timeToFragnum(from);
|
uint32_t fragIndice = Trk.timeToFragnum(from);
|
||||||
contPAT = Trk.missedFrags + fragIndice; //PAT continuity counter
|
contPAT = Trk.missedFrags + fragIndice; //PAT continuity counter
|
||||||
contPMT = Trk.missedFrags + fragIndice; //PMT continuity counter
|
contPMT = Trk.missedFrags + fragIndice; //PMT continuity counter
|
||||||
|
contSDT = Trk.missedFrags + fragIndice; //SDT continuity counter
|
||||||
packCounter = 0;
|
packCounter = 0;
|
||||||
parseData = true;
|
parseData = true;
|
||||||
wantRequest = false;
|
wantRequest = false;
|
||||||
seek(from);
|
seek(from);
|
||||||
ts_from = from;
|
ts_from = from;
|
||||||
lastVid = from * 90;
|
|
||||||
} else {
|
} else {
|
||||||
initialize();
|
initialize();
|
||||||
std::string request = H.url.substr(H.url.find("/", 5) + 1);
|
std::string request = H.url.substr(H.url.find("/", 5) + 1);
|
||||||
|
|
|
@ -79,6 +79,7 @@ namespace Mist {
|
||||||
/*capa["optional"]["wrappers"]["allowed"].append("theoplayer");
|
/*capa["optional"]["wrappers"]["allowed"].append("theoplayer");
|
||||||
capa["optional"]["wrappers"]["allowed"].append("jwplayer");*/
|
capa["optional"]["wrappers"]["allowed"].append("jwplayer");*/
|
||||||
capa["optional"]["wrappers"]["allowed"].append("html5");
|
capa["optional"]["wrappers"]["allowed"].append("html5");
|
||||||
|
capa["optional"]["wrappers"]["allowed"].append("videojs");
|
||||||
capa["optional"]["wrappers"]["allowed"].append("dashjs");
|
capa["optional"]["wrappers"]["allowed"].append("dashjs");
|
||||||
//capa["optional"]["wrappers"]["allowed"].append("polytrope"); //currently borked
|
//capa["optional"]["wrappers"]["allowed"].append("polytrope"); //currently borked
|
||||||
capa["optional"]["wrappers"]["allowed"].append("flash_strobe");
|
capa["optional"]["wrappers"]["allowed"].append("flash_strobe");
|
||||||
|
@ -605,6 +606,13 @@ namespace Mist {
|
||||||
response.append((char*)dash_js, (size_t)dash_js_len);
|
response.append((char*)dash_js, (size_t)dash_js_len);
|
||||||
used = true;
|
used = true;
|
||||||
}
|
}
|
||||||
|
if (it->asStringRef() == "videojs"){
|
||||||
|
#include "playervideo.js.h"
|
||||||
|
response.append((char*)playervideo_js, (size_t)playervideo_js_len);
|
||||||
|
#include "videojs.js.h"
|
||||||
|
response.append((char*)video_js, (size_t)video_js_len);
|
||||||
|
used = true;
|
||||||
|
}
|
||||||
if (!used) {
|
if (!used) {
|
||||||
WARN_MSG("Unknown player type: %s",it->asStringRef().c_str());
|
WARN_MSG("Unknown player type: %s",it->asStringRef().c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
OutHTTPTS::OutHTTPTS(Socket::Connection & conn) : TSOutput(conn){
|
OutHTTPTS::OutHTTPTS(Socket::Connection & conn) : TSOutput(conn){
|
||||||
|
sendRepeatingHeaders = 500;//PAT/PMT every 500ms (DVB spec)
|
||||||
if (config->getString("target").size()){
|
if (config->getString("target").size()){
|
||||||
if (!streamName.size()){
|
if (!streamName.size()){
|
||||||
WARN_MSG("Recording unconnected TS output to file! Cancelled.");
|
WARN_MSG("Recording unconnected TS output to file! Cancelled.");
|
||||||
|
@ -43,7 +44,7 @@ namespace Mist {
|
||||||
capa["codecs"][0u][1u].append("MP3");
|
capa["codecs"][0u][1u].append("MP3");
|
||||||
capa["codecs"][0u][1u].append("AC3");
|
capa["codecs"][0u][1u].append("AC3");
|
||||||
capa["methods"][0u]["handler"] = "http";
|
capa["methods"][0u]["handler"] = "http";
|
||||||
capa["methods"][0u]["type"] = "html5/video/mp2t";
|
capa["methods"][0u]["type"] = "html5/video/mpeg";
|
||||||
capa["methods"][0u]["priority"] = 1ll;
|
capa["methods"][0u]["priority"] = 1ll;
|
||||||
capa["push_urls"].append("/*.ts");
|
capa["push_urls"].append("/*.ts");
|
||||||
|
|
||||||
|
@ -65,6 +66,9 @@ namespace Mist {
|
||||||
H.clearHeader("Range");
|
H.clearHeader("Range");
|
||||||
H.clearHeader("Icy-MetaData");
|
H.clearHeader("Icy-MetaData");
|
||||||
H.clearHeader("User-Agent");
|
H.clearHeader("User-Agent");
|
||||||
|
H.clearHeader("Host");
|
||||||
|
H.clearHeader("Accept-Ranges");
|
||||||
|
H.clearHeader("transferMode.dlna.org");
|
||||||
H.SetHeader("Content-Type", "video/mpeg");
|
H.SetHeader("Content-Type", "video/mpeg");
|
||||||
H.setCORSHeaders();
|
H.setCORSHeaders();
|
||||||
if(method == "OPTIONS" || method == "HEAD"){
|
if(method == "OPTIONS" || method == "HEAD"){
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
OutTS::OutTS(Socket::Connection & conn) : TSOutput(conn){
|
OutTS::OutTS(Socket::Connection & conn) : TSOutput(conn){
|
||||||
|
sendRepeatingHeaders = 500;//PAT/PMT every 500ms (DVB spec)
|
||||||
streamName = config->getString("streamname");
|
streamName = config->getString("streamname");
|
||||||
parseData = true;
|
parseData = true;
|
||||||
wantRequest = false;
|
wantRequest = false;
|
||||||
|
|
|
@ -7,20 +7,23 @@ namespace Mist {
|
||||||
haveHvcc = false;
|
haveHvcc = false;
|
||||||
ts_from = 0;
|
ts_from = 0;
|
||||||
setBlocking(true);
|
setBlocking(true);
|
||||||
sendRepeatingHeaders = false;
|
sendRepeatingHeaders = 0;
|
||||||
appleCompat=false;
|
appleCompat=false;
|
||||||
|
lastHeaderTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSOutput::fillPacket(char const * data, size_t dataLen, bool & firstPack, bool video, bool keyframe, uint32_t pkgPid, int & contPkg){
|
void TSOutput::fillPacket(char const * data, size_t dataLen, bool & firstPack, bool video, bool keyframe, uint32_t pkgPid, int & contPkg){
|
||||||
do {
|
do {
|
||||||
if (!packData.getBytesFree()){
|
if (!packData.getBytesFree()){
|
||||||
if ( (sendRepeatingHeaders && packCounter % 42 == 0) || !packCounter){
|
if ( (sendRepeatingHeaders && thisPacket.getTime() - lastHeaderTime > sendRepeatingHeaders) || !packCounter){
|
||||||
|
lastHeaderTime = thisPacket.getTime();
|
||||||
TS::Packet tmpPack;
|
TS::Packet tmpPack;
|
||||||
tmpPack.FromPointer(TS::PAT);
|
tmpPack.FromPointer(TS::PAT);
|
||||||
tmpPack.setContinuityCounter(++contPAT);
|
tmpPack.setContinuityCounter(++contPAT);
|
||||||
sendTS(tmpPack.checkAndGetBuffer());
|
sendTS(tmpPack.checkAndGetBuffer());
|
||||||
sendTS(TS::createPMT(selectedTracks, myMeta, ++contPMT));
|
sendTS(TS::createPMT(selectedTracks, myMeta, ++contPMT));
|
||||||
packCounter += 2;
|
sendTS(TS::createSDT(streamName, ++contSDT));
|
||||||
|
packCounter += 3;
|
||||||
}
|
}
|
||||||
sendTS(packData.checkAndGetBuffer());
|
sendTS(packData.checkAndGetBuffer());
|
||||||
packCounter ++;
|
packCounter ++;
|
||||||
|
@ -114,7 +117,7 @@ namespace Mist {
|
||||||
|
|
||||||
while (currPack <= splitCount){
|
while (currPack <= splitCount){
|
||||||
unsigned int alreadySent = 0;
|
unsigned int alreadySent = 0;
|
||||||
bs = TS::Packet::getPESVideoLeadIn((currPack != splitCount ? watKunnenWeIn1Ding : dataLen+extraSize - currPack*watKunnenWeIn1Ding), packTime, offset, !currPack);
|
bs = TS::Packet::getPESVideoLeadIn((currPack != splitCount ? watKunnenWeIn1Ding : dataLen+extraSize - currPack*watKunnenWeIn1Ding), packTime, offset, !currPack, Trk.bps);
|
||||||
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
||||||
if (!currPack){
|
if (!currPack){
|
||||||
if (Trk.codec == "H264" && (dataPointer[4] & 0x1f) != 0x09){
|
if (Trk.codec == "H264" && (dataPointer[4] & 0x1f) != 0x09){
|
||||||
|
@ -186,7 +189,7 @@ namespace Mist {
|
||||||
if (Trk.codec == "AAC"){
|
if (Trk.codec == "AAC"){
|
||||||
tempLen += 7;
|
tempLen += 7;
|
||||||
}
|
}
|
||||||
bs = TS::Packet::getPESAudioLeadIn(tempLen, packTime);// myMeta.tracks[thisPacket.getTrackId()].rate / 1000 );
|
bs = TS::Packet::getPESAudioLeadIn(tempLen, packTime, Trk.bps);// myMeta.tracks[thisPacket.getTrackId()].rate / 1000 );
|
||||||
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);
|
||||||
if (Trk.codec == "AAC"){
|
if (Trk.codec == "AAC"){
|
||||||
bs = TS::getAudioHeader(dataLen, Trk.init);
|
bs = TS::getAudioHeader(dataLen, Trk.init);
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Mist {
|
||||||
std::map<unsigned int, int> contCounters;
|
std::map<unsigned int, int> contCounters;
|
||||||
int contPAT;
|
int contPAT;
|
||||||
int contPMT;
|
int contPMT;
|
||||||
|
int contSDT;
|
||||||
unsigned int packCounter; ///\todo update constructors?
|
unsigned int packCounter; ///\todo update constructors?
|
||||||
TS::Packet packData;
|
TS::Packet packData;
|
||||||
bool haveAvcc;
|
bool haveAvcc;
|
||||||
|
@ -31,8 +32,8 @@ namespace Mist {
|
||||||
bool haveHvcc;
|
bool haveHvcc;
|
||||||
MP4::HVCC hvccbox;
|
MP4::HVCC hvccbox;
|
||||||
/*LTS-END*/
|
/*LTS-END*/
|
||||||
bool sendRepeatingHeaders;
|
uint64_t sendRepeatingHeaders; ///< Amount of ms between PAT/PMT. Zero means do not repeat.
|
||||||
long long unsigned int ts_from;
|
uint64_t lastHeaderTime; ///< Timestamp last PAT/PMT were sent.
|
||||||
long long unsigned int lastVid;
|
uint64_t ts_from; ///< Starting time to subtract from timestamps
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue