From 388735e94288c65914f8ed60eb007fab987b759b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 18 Jan 2022 14:30:10 -0500 Subject: [PATCH] Fix relating auth_hash causing repeated reloads. If https, then assume a reverse proxy setup to janus. If video feed is not an img, log it and return --- web/js/MonitorStream.js | 47 +++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index 5a0dd7e25..54669a964 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -47,6 +47,11 @@ function MonitorStream(monitorData) { this.scale = newscale; const oldSrc = img.getAttribute('src'); + if (!oldSrc) { + console.log("No src on img?!"); + console.log(img); + return; + } let newSrc = ''; img.setAttribute('src', ''); @@ -85,7 +90,14 @@ function MonitorStream(monitorData) { if (this.janusEnabled) { var id = parseInt(this.id); - var server = "http://" + window.location.hostname + ":8088/janus"; + var server; + if (window.location.protocol=='https:') { + // Assume reverse proxy setup for now + server = "https://" + window.location.hostname + "/janus"; + } else { + server = "http://" + window.location.hostname + ":8088/janus"; + } + if (janus == null) { Janus.init({debug: "all", callback: function() { janus = new Janus({server: server}); //new Janus @@ -178,11 +190,16 @@ function MonitorStream(monitorData) { this.getStreamCmdResponse = function(respObj, respText) { var stream = $j('#liveStream'+this.id)[0]; - if ( ! stream ) { + if (!stream) { console.log('No live stream'); return; } + //watchdogOk('stream'); + if (streamCmdTimer) { + streamCmdTimer = clearTimeout(streamCmdTimer); + } + if ( respObj.result == 'Ok' ) { if ( respObj.status ) { this.status = respObj.status; @@ -202,13 +219,25 @@ function MonitorStream(monitorData) { !COMPACT_MONTAGE) && (this.type != 'WebSite') ) { - var fpsValue = $j('#fpsValue'+this.id); - var stateValue = $j('#stateValue'+this.id); - var monitorState = $j('#monitorState'+this.id); + const viewingFPSValue = $j('#vewingFPSValue'+this.id); + const captureFPSValue = $j('#captureFPSValue'+this.id); + const analysisFPSValue = $j('#analysisFPSValue'+this.id); - if ( fpsValue.length ) fpsValue.text(this.status.fps); - if ( stateValue.length ) stateValue.text(stateStrings[this.alarmState]); - if ( monitorState.length ) this.setStateClass(monitorState, stateClass); + const stateValue = $j('#stateValue'+this.id); + const monitorState = $j('#monitorState'+this.id); + + if (viewingFPSValue.length && (viewingFPSValue.text != this.status.fps)) { + viewingFPSValue.text(this.status.fps); + } + if (analysisFPSValue.length && (analysisFPSValue.text != this.status.analysisfps)) { + analysisFPSValue.text(this.status.analysisfps); + } + if (captureFPSValue.length && (captureFPSValue.text != this.status.capturefps)) { + captureFPSValue.text(this.status.capturefps); + } + + if (stateValue.length) stateValue.text(stateStrings[this.alarmState]); + if (monitorState.length) this.setStateClass(monitorState, stateClass); } this.setStateClass($j('#monitor'+this.id), stateClass); @@ -238,7 +267,7 @@ function MonitorStream(monitorData) { } } if (this.status.auth) { - if (this.status.auth != auth_hash) { + if (this.status.auth != this.auth_hash) { // Try to reload the image stream. if (stream) { const oldsrc = stream.src;