From 8367c166622310f931b047c24178fe205cab3207 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 1 Nov 2019 12:16:59 -0400 Subject: remove packery reinit on resize - why did I do that? --- www/js/MontageCtrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'www') diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index edca6dbb..d917c49e 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -148,7 +148,7 @@ angular.module('zmApp.controllers') function jiggleMontage() { if ($scope.reOrderActive) return; NVR.debug ('window resized'); - initPackery(); + //initPackery(); } -- cgit v1.2.3 From 1793deb9977976ef8f390f3458b7e82380d5b445 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 1 Nov 2019 14:38:50 -0400 Subject: start with low quality snapshot first for faster load --- www/js/MontageCtrl.js | 89 +++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 41 deletions(-) (limited to 'www') diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index d917c49e..cc815e49 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -36,12 +36,13 @@ angular.module('zmApp.controllers') var streamState = { SNAPSHOT: 1, - ACTIVE: 2, - STOPPED: 3, - PAUSED: 4 + SNAPSHOT_LOWQUALITY:2, + ACTIVE: 3, + STOPPED: 4, + PAUSED: 5 }; - var currentStreamState = streamState.SNAPSHOT; // first load snapshot + var currentStreamState = streamState.SNAPSHOT_LOWQUALITY; // first load snapshot $scope.isModalStreamPaused = false; // used in Monitor Modal //var reloadPage = 30; @@ -212,7 +213,7 @@ angular.module('zmApp.controllers') duration: zm.loadingTimeout });*/ - currentStreamState = streamState.SNAPSHOT; + currentStreamState = streamState.SNAPSHOT_LOWQUALITY; $scope.areImagesLoading = true; var progressCalled = false; @@ -330,38 +331,31 @@ angular.module('zmApp.controllers') NVR.debug("All images loaded, but some broke, switching to snapshot..."); //console.log ("******** ALL IMAGES LOADED"); // $scope.$digest(); - allImagesLoadedOrFailed(); + $timeout (function () { + allImagesLoadedOrFailed(); + },100); + }); function allImagesLoadedOrFailed() { - - $timeout(function () { - $scope.areImagesLoading = false; - }); - + $scope.areImagesLoading = false; currentStreamState = streamState.SNAPSHOT; - if (simulStreaming) { - - $timeout(function () { - NVR.debug("Switching mode to active..."); + $timeout (function () { + NVR.debug("Switching mode to streaming as multi-port on..."); + //NVR.regenConnKeys(); + //randEachTime(); currentStreamState = streamState.ACTIVE; - }, 100); - } - - $ionicLoading.hide(); - - if (!progressCalled) { - NVR.log("*** PROGRESS WAS NOT CALLED"); - // pckry.reloadItems(); - } + },300); + + } + - $timeout(function () { + $ionicLoading.hide(); pckry.getItemElements().forEach(function (itemElem) { - draggie = new Draggabilly(itemElem); pckry.bindDraggabillyEvents(draggie); draggies.push(draggie); @@ -409,7 +403,6 @@ angular.module('zmApp.controllers') //pckry.onresize(); - }, 20); } @@ -808,7 +801,7 @@ angular.module('zmApp.controllers') } // before reorder array } // montage monitors - // console.log ("AFTER REORDER="+JSON.stringify(beforeReorderPositions)); + console.log ("AFTER REORDER="+JSON.stringify(beforeReorderPositions)); for (var n = 0; i < $scope.MontageMonitors.length; i++) { $scope.MontageMonitors[n].Monitor.connKey = NVR.regenConnKeys($scope.MontageMonitors[i]); @@ -1671,7 +1664,7 @@ angular.module('zmApp.controllers') // in timeout for iOS as we call stopNetwork $timeout(function () { - + console.log ("SIMUL SWITCH MONTAGE CALLING REGEN"); NVR.regenConnKeys(); $scope.monitors = NVR.getMonitorsNow(); $scope.MontageMonitors = angular.copy($scope.monitors); @@ -1683,7 +1676,9 @@ angular.module('zmApp.controllers') } else { + console.log ("NOT SIMUL SWITCH MONTAGE CALLING REGEN"); NVR.regenConnKeys(); + $scope.monitors = NVR.getMonitorsNow(); $scope.MontageMonitors = angular.copy($scope.monitors); $timeout(function () { @@ -1883,16 +1878,23 @@ angular.module('zmApp.controllers') $scope.processImageError = function(monitor) { + // if (1) return; + + if (currentStreamState != streamState.ACTIVE) return; var mintimesec = 10; var nowt = moment(); var thent = monitor.Monitor.regenTime || moment(); if (nowt.diff(thent, 'seconds') >=mintimesec) { + console.log ('IMAGE ERROR CALLING REGEN'); NVR.regenConnKeys(monitor); NVR.debug ("Image load error for: "+monitor.Monitor.Id+" regenerated connKey is:"+monitor.Monitor.connKey); } else { dur = mintimesec - nowt.diff(thent, 'seconds'); NVR.debug ("Image load error for Monitor: "+monitor.Monitor.Id+" scheduling for connkey regen in "+dur+"s"); - monitor.Monitor.regenHandle = $timeout ( function() {NVR.regenConnKeys(monitor);}, dur*1000 ); + monitor.Monitor.regenHandle = $timeout ( function() { + NVR.debug ('deferred image error, calling regen'); + //console.log ('DEFERRED IMAGE ERROR CALLING REGEN'); + NVR.regenConnKeys(monitor);}, dur*1000 ); } @@ -2039,23 +2041,31 @@ angular.module('zmApp.controllers') var fps = NVR.getLogin().montageliveFPS; if (currentStreamState == streamState.STOPPED || monitor.Monitor.listDisplay == 'noshow' ) { //console.log ("STREAM=empty and auth="+$rootScope.authSession); + //sconsole.log ('EMPTY STREAM'); return ""; } - //console.log ("STREAMING="+monitor.Monitor.streamingURL); - stream = monitor.Monitor.streamingURL + + if (currentStreamState == streamState.SNAPSHOT_LOWQUALITY) { + stream = monitor.Monitor.streamingURL + + "/nph-zms?mode=single&scale=10&monitor="+ monitor.Monitor.Id ; + // console.log(stream); + + } else { + stream = monitor.Monitor.streamingURL + "/nph-zms?mode=" + getMode() + "&monitor=" + monitor.Monitor.Id + "&scale=" + $scope.LoginData.montageQuality + - "&rand=" + randToAvoidCacheMem + monitor.Monitor.Id + - "&buffer=1000"; + "&buffer=1000"+ + "&rand=" + randToAvoidCacheMem + monitor.Monitor.Id; if (fps) { stream +='&maxfps='+fps; } - - stream += $rootScope.authSession + - appendConnKey(monitor.Monitor.connKey); + + } + + stream += $rootScope.authSession; + stream += appendConnKey(monitor.Monitor.connKey); if (stream) stream += NVR.insertBasicAuthToken(); @@ -2072,10 +2082,7 @@ angular.module('zmApp.controllers') }; function appendConnKey(ck) { - if (simulStreaming && currentStreamState != streamState.SNAPSHOT) return "&connkey=" + ck; - else - return ""; } @@ -2123,7 +2130,7 @@ angular.module('zmApp.controllers') timeInMontage = new Date(); broadcastHandles = []; randToAvoidCacheMem = new Date().getTime(); - currentStreamState = streamState.SNAPSHOT; + $scope.monitors = NVR.getMonitorsNow(); //console.log ("MONITORS:"+JSON.stringify($scope.monitors)); -- cgit v1.2.3 From c737905b2c20f7a04dbdf3169c51711be71cb94a Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sun, 3 Nov 2019 09:01:17 -0500 Subject: add random to low quality --- www/js/MontageCtrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'www') diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index cc815e49..9abbcd03 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -2047,7 +2047,7 @@ angular.module('zmApp.controllers') if (currentStreamState == streamState.SNAPSHOT_LOWQUALITY) { stream = monitor.Monitor.streamingURL + - "/nph-zms?mode=single&scale=10&monitor="+ monitor.Monitor.Id ; + "/nph-zms?mode=single&scale=10&monitor="+ monitor.Monitor.Id + "&rand=" + randToAvoidCacheMem + monitor.Monitor.Id ; // console.log(stream); } else { -- cgit v1.2.3 From c90e4b23945ce93fd518c1595aa3d9275743f788 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sun, 3 Nov 2019 09:51:31 -0500 Subject: add option to pause streams for simul, turn it off for default --- www/js/MontageCtrl.js | 22 ++++++++++++++++------ www/js/NVR.js | 8 +++++++- www/lang/locale-en.json | 2 ++ www/templates/devoptions.html | 9 +++++++++ 4 files changed, 34 insertions(+), 7 deletions(-) (limited to 'www') diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 9abbcd03..d9bfd19b 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -1276,11 +1276,16 @@ angular.module('zmApp.controllers') if (simulStreaming) { - NVR.debug("Pausing all streams in montage to save memory/nw..."); + var ld = NVR.getLogin(); + if (ld.pauseStreams) { + NVR.debug("Pausing all streams in montage to save memory/nw..."); + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.pauseLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + } - for (var i = 0; i < $scope.MontageMonitors.length; i++) { - if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.pauseLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + } else { + NVR.debug ("Not pausing streams as pauseStreams is off"); } } @@ -1419,11 +1424,16 @@ angular.module('zmApp.controllers') // once regenerated if (simulStreaming) { - NVR.debug("Resuming all stream connkeys in montage ..."); + if (ld.pauseStreams) { + NVR.debug("Resuming all stream connkeys in montage ..."); - for (var i = 0; i < $scope.MontageMonitors.length; i++) { - if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.resumeLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.resumeLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + } + } else { + NVR.debug ("Not resuming streams as pauseStreams is off"); } + } diff --git a/www/js/NVR.js b/www/js/NVR.js index 0d1a9bd2..fed774f4 100644 --- a/www/js/NVR.js +++ b/www/js/NVR.js @@ -207,7 +207,8 @@ angular.module('zmApp.controllers') 'refreshToken': '', 'isKiosk': false, 'kioskPassword': '', - 'useHTTPCaching': true + 'useHTTPCaching': true, + 'pauseStreams': false, }; @@ -1590,6 +1591,11 @@ angular.module('zmApp.controllers') } + if (typeof loginData.pauseStreams == 'undefined') { + loginData.pauseStreams = false; + + } + loginData.canSwipeMonitors = true; loginData.forceImageModePath = false; loginData.enableBlog = true; diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index e4774cb3..d4b48150 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -283,6 +283,8 @@ "kPathToCgiExample" :"e.g. server/zm/cgi-bin", "kPause" :"pause", "kPaused" :"paused", + "kPauseStreams" : "pause/resume streams to save bandwidth", + "kPauseStreamsNote" : "only applies if multi-port is used", "kPinProtect" :"PIN Protect", "kPlaceHolderBasicAuthPass" :"basic auth password", "kPlaceHolderBasicAuthUser" :"basic auth user name", diff --git a/www/templates/devoptions.html b/www/templates/devoptions.html index bd8d6e3b..58dec1fc 100644 --- a/www/templates/devoptions.html +++ b/www/templates/devoptions.html @@ -235,6 +235,15 @@ + +