Fix HMAC calculation for HLS streams
This commit is contained in:
parent
306c3eaf3c
commit
dbcd7f488e
|
@ -244,7 +244,7 @@
|
||||||
name: '',
|
name: '',
|
||||||
url: modelUrl
|
url: modelUrl
|
||||||
};
|
};
|
||||||
console.log(model);
|
if(console) console.log(model);
|
||||||
let action = '{"action": "startByUrl", "model": ' + JSON.stringify(model) + '}';
|
let action = '{"action": "startByUrl", "model": ' + JSON.stringify(model) + '}';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'POST',
|
type : 'POST',
|
||||||
|
@ -264,11 +264,11 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
$.notify('Adding model failed', 'error');
|
$.notify('Adding model failed', 'error');
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -292,11 +292,11 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
$.notify('Resuming recording of model ' + model.name + ' failed', 'error');
|
$.notify('Resuming recording of model ' + model.name + ' failed', 'error');
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -320,11 +320,11 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
$.notify('Suspending recording of model ' + model.name + ' failed', 'error');
|
$.notify('Suspending recording of model ' + model.name + ' failed', 'error');
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -349,11 +349,11 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
$.notify('Removing model ' + model.name + ' failed', 'error');
|
$.notify('Removing model ' + model.name + ' failed', 'error');
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -379,19 +379,20 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
$.notify('Removing recording ' + name + ' failed', 'error');
|
$.notify('Removing recording ' + name + ' failed', 'error');
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function play(recording) {
|
function play(recording) {
|
||||||
let src = recording.playlist;
|
let src = recording.playlist;
|
||||||
src = '..' + src;
|
|
||||||
let hmacOfPath = CryptoJS.HmacSHA256(src, hmac);
|
let hmacOfPath = CryptoJS.HmacSHA256(src, hmac);
|
||||||
|
src = '..' + src;
|
||||||
|
if(console) console.log("Path", src, "HMAC", hmacOfPath);
|
||||||
if (hmac.length > 0) {
|
if (hmac.length > 0) {
|
||||||
src += "?hmac=" + hmacOfPath;
|
src += "?hmac=" + hmacOfPath;
|
||||||
}
|
}
|
||||||
|
@ -407,20 +408,19 @@
|
||||||
$('#player-window').css('display', 'block');
|
$('#player-window').css('display', 'block');
|
||||||
video.play();
|
video.play();
|
||||||
}
|
}
|
||||||
video.onloadedmetadata = function() {
|
|
||||||
console.log(video);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (Hls.isSupported()) {
|
if (Hls.isSupported()) {
|
||||||
var video = document.getElementById('player');
|
var video = document.getElementById('player');
|
||||||
var hls = new Hls();
|
var hls = new Hls();
|
||||||
hls.attachMedia(video);
|
hls.attachMedia(video);
|
||||||
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
|
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
|
||||||
console.log(src);
|
if(console) console.log(src);
|
||||||
hls.loadSource(src);
|
hls.loadSource(src);
|
||||||
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
|
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
|
||||||
|
if(console) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
console.log("manifest loaded, found " + data.levels.length + " quality level");
|
console.log("manifest loaded, found " + data.levels.length + " quality level");
|
||||||
|
}
|
||||||
$('#player-window').css('display', 'block');
|
$('#player-window').css('display', 'block');
|
||||||
video.play();
|
video.play();
|
||||||
});
|
});
|
||||||
|
@ -428,7 +428,7 @@
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$.notify('Loading HLS video streaming support failed', 'error');
|
$.notify('Loading HLS video streaming support failed', 'error');
|
||||||
console.log('HLS is not supported');
|
if(console) console.log('HLS is not supported');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,10 +451,10 @@
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if (localStorage !== undefined && localStorage.hmac !== undefined) {
|
if (localStorage !== undefined && localStorage.hmac !== undefined) {
|
||||||
console.log('using hmac from local storage');
|
if(console) console.log('using hmac from local storage');
|
||||||
hmac = localStorage.hmac;
|
hmac = localStorage.hmac;
|
||||||
} else {
|
} else {
|
||||||
console.log('hmac not found in local storage. requesting hmac from server');
|
if(console) console.log('hmac not found in local storage. requesting hmac from server');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'GET',
|
type : 'GET',
|
||||||
url : '../secured/hmac',
|
url : '../secured/hmac',
|
||||||
|
@ -465,12 +465,12 @@
|
||||||
.done(function(data) {
|
.done(function(data) {
|
||||||
hmac = data.hmac;
|
hmac = data.hmac;
|
||||||
if (localStorage !== undefined) {
|
if (localStorage !== undefined) {
|
||||||
console.log('saving hmac to local storage');
|
if(console) console.log('saving hmac to local storage');
|
||||||
localStorage.setItem("hmac", hmac);
|
localStorage.setItem("hmac", hmac);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
$.notify('Couldn\'t get HMAC', 'error');
|
$.notify('Couldn\'t get HMAC', 'error');
|
||||||
hmac = '';
|
hmac = '';
|
||||||
});
|
});
|
||||||
|
@ -508,15 +508,15 @@
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
onlineModels = data.models;
|
onlineModels = data.models;
|
||||||
} else {
|
} else {
|
||||||
console.log('request failed', data);
|
if(console) console.log('request failed', data);
|
||||||
}
|
}
|
||||||
updateModels();
|
updateModels();
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(jqXHR, textStatus, errorThrown);
|
if(console) console.log(jqXHR, textStatus, errorThrown);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
setTimeout(updateOnlineModels, 3000);
|
setTimeout(updateOnlineModels, 3000);
|
||||||
}
|
}
|
||||||
|
@ -619,14 +619,14 @@
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
syncModels(data.models);
|
syncModels(data.models);
|
||||||
} else {
|
} else {
|
||||||
console.log('request failed', data);
|
if(console) console.log('request failed', data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,14 +716,14 @@
|
||||||
syncRecordings(data.recordings);
|
syncRecordings(data.recordings);
|
||||||
updateDiskSpace();
|
updateDiskSpace();
|
||||||
} else {
|
} else {
|
||||||
console.log('request failed', data);
|
if(console) console.log('request failed', data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unexpected error', e);
|
if(console) console.log('Unexpected error', e);
|
||||||
}
|
}
|
||||||
setTimeout(updateRecordings, 3000);
|
setTimeout(updateRecordings, 3000);
|
||||||
}
|
}
|
||||||
|
@ -746,11 +746,11 @@
|
||||||
space.percent( (data.spaceFree/data.spaceTotal*100).toFixed(2) );
|
space.percent( (data.spaceFree/data.spaceTotal*100).toFixed(2) );
|
||||||
space.text(calculateSize(data.spaceFree) + ' / ' + calculateSize(data.spaceTotal));
|
space.text(calculateSize(data.spaceFree) + ' / ' + calculateSize(data.spaceTotal));
|
||||||
} else {
|
} else {
|
||||||
console.log('request failed', data);
|
if(console) console.log('request failed', data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||||
console.log(textStatus, errorThrown);
|
if(console) console.log(textStatus, errorThrown);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue