From 05a38c76ba4bd332727a3383f3cae4da2034aaab Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 24 May 2022 12:11:18 -0400 Subject: [PATCH 01/10] Turn back on flat structure for video Download --- web/ajax/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ajax/event.php b/web/ajax/event.php index a0b9cb57a..14ba7c74e 100644 --- a/web/ajax/event.php +++ b/web/ajax/event.php @@ -116,7 +116,7 @@ if ( canView('Events') or canView('Snapshots') ) { false,#Misc $exportFormat, false#,#Compress - #$exportStructure + , $exportStructure ) ) { ajaxResponse(array( 'exportFile'=>$exportFile, From 72be70f166b4ea00c226691ef09cd585eeb64690 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 24 May 2022 12:11:55 -0400 Subject: [PATCH 02/10] When using flat mode, only rename files that don't aleady include the event id. Turn off master.html if only video is being downloaded --- .../classic/includes/export_functions.php | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/web/skins/classic/includes/export_functions.php b/web/skins/classic/includes/export_functions.php index 5b0cffc52..9573d45ff 100644 --- a/web/skins/classic/includes/export_functions.php +++ b/web/skins/classic/includes/export_functions.php @@ -583,7 +583,7 @@ function eventlist_html($Event, $exportDetail, $exportFrames, $exportStructure) '; } # end if has jpegs if ($Event->DefaultVideo()) { - $html .= ''; + $html .= ''; $html .= ''.$Event->Id().''; $html .= '
'.PHP_EOL; } @@ -931,14 +931,21 @@ function exportEvents( ZM\Error("Can't mkdir $event_dir"); } $event_exportFileList = exportFileList($event, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc); - $exportFileList = array_merge($exportFileList, $event_exportFileList); + #$exportFileList = array_merge($exportFileList, $event_exportFileList); foreach ($event_exportFileList as $file) { #if ( preg_match('/\.html$/', $file) ) #continue; if ($exportStructure == 'flat') { - $cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'_'.$file. ' 2>&1'; + if (false !== strpos($file, $event->Id())) { + $cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$file. ' 2>&1'; + $exportFileList[] = $file; + } else { + $cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'_'.$file. ' 2>&1'; + $exportFileList[] = $event->Id().'_'.$file; + } } else { $cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'/'.$file. ' 2>&1'; + $exportFileList[] = $event->Id().'/'.$file; } exec($cmd, $output, $return); ZM\Debug($cmd.' return code: '.$return.' output: '.print_r($output,true)); @@ -954,16 +961,18 @@ function exportEvents( } //if ( !symlink(ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/video.js', $export_dir.'/video.js') ) //Error("Failed linking video.js"); + // + if (!($exportDetail or $exportFrames or $exportImages or $exportVideo or $exportMisc)) { + $html_eventMaster_file = 'zmEventImagesMaster.html'; + $html_eventMaster_path = $export_dir.'/'.$html_eventMaster_file; - $html_eventMaster_file = 'zmEventImagesMaster.html'; - $html_eventMaster_path = $export_dir.'/'.$html_eventMaster_file; - - if (($fp = fopen($html_eventMaster_path, 'w'))) { - fwrite($fp, exportEventImagesMaster($eids, $exportDetail, $exportFrames, $exportStructure)); - fclose($fp); - $exportFileList[] = $html_eventMaster_file; - } else { - ZM\Error("Can't open event images export file '$html_eventMaster_path'"); + if (($fp = fopen($html_eventMaster_path, 'w'))) { + fwrite($fp, exportEventImagesMaster($eids, $exportDetail, $exportFrames, $exportStructure)); + fclose($fp); + $exportFileList[] = $html_eventMaster_file; + } else { + ZM\Error("Can't open event images export file '$html_eventMaster_path'"); + } } $listFile = $export_dir.'/'.$export_listFile; From 71a1e81dd7c28f8c05b56a0069ee79a746550446 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 25 May 2022 09:50:41 -0400 Subject: [PATCH 03/10] Change has_warned to warned_count, so that we can stop excess locked packet warnings too --- src/zm_packetqueue.cpp | 15 +++++++++------ src/zm_packetqueue.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index d3041be07..805063a06 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -33,7 +33,7 @@ PacketQueue::PacketQueue(): packet_counts(nullptr), deleting(false), keep_keyframes(false), - has_warned(false) + warned_count(0) { } @@ -148,8 +148,8 @@ bool PacketQueue::queuePacket(std::shared_ptr add_packet) { and (packet_counts[video_stream_id] > max_video_packet_count) ) { - if (!has_warned) { - has_warned = true; + if (!warned_count) { + warned_count++; Warning("You have set the max video packets in the queue to %u." " The queue is full. Either Analysis is not keeping up or" " your camera's keyframe interval is larger than this setting." @@ -167,8 +167,11 @@ bool PacketQueue::queuePacket(std::shared_ptr add_packet) { ZMLockedPacket lp(zm_packet); if (!lp.trylock()) { - // Can't delete a locked packet, but can delete one after it. - Warning("Found locked packet when trying to free up video packets. This basically means that decoding is not keeping up."); + if (warned_count <2) { + warned_count++; + // Can't delete a locked packet, but can delete one after it. + Warning("Found locked packet when trying to free up video packets. This basically means that decoding is not keeping up."); + } ++it; continue; } @@ -201,7 +204,7 @@ bool PacketQueue::queuePacket(std::shared_ptr add_packet) { break; } // end while } else { - has_warned = false; + warned_count--; } // end if not able catch up } // end lock scope // We signal on every packet because someday we may analyze sound diff --git a/src/zm_packetqueue.h b/src/zm_packetqueue.h index a9e1228be..340af7ddf 100644 --- a/src/zm_packetqueue.h +++ b/src/zm_packetqueue.h @@ -46,7 +46,7 @@ class PacketQueue { std::mutex mutex; std::condition_variable condition; - bool has_warned; + int warned_count; public: PacketQueue(); From 015744a66514bd478ebedf313d6c1bfb5e6b3bf7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 25 May 2022 16:06:59 -0400 Subject: [PATCH 04/10] Update styles so that alarmed images get red border --- web/skins/classic/css/base/views/montage.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/skins/classic/css/base/views/montage.css b/web/skins/classic/css/base/views/montage.css index 3cb98f839..55d1d4b3d 100644 --- a/web/skins/classic/css/base/views/montage.css +++ b/web/skins/classic/css/base/views/montage.css @@ -68,15 +68,15 @@ background: none; } -#monitors .imageFeed img.idle { +#monitors .idle .imageFeed img { border: 2px solid #ffffff; } -#monitors .imageFeed img.alarm { +#monitors .alarm .imageFeed img { border: 2px solid #ff0000; } -#monitors .imageFeed img.alert { +#monitors .alert .imageFeed img { border: 2px solid #ffa500; } From 082fff850fd124e2abd15d3b32f58e2b9d74d854 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 25 May 2022 16:06:42 -0400 Subject: [PATCH 05/10] Re-instate setting the class of the monitor div on alarm --- web/js/MonitorStream.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index 3110d0edf..83ad5678f 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -306,8 +306,8 @@ function MonitorStream(monitorData) { stateValue.removeClass(); } } - //const monitorState = $j('#monitorState'+this.id); - //if (monitorState.length) this.setStateClass(monitorState, stateClass); + const monitorFrame = $j('#monitor'+this.id); + if (monitorFrame.length) this.setStateClass(monitorFrame, stateClass); const isAlarmed = ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ); const wasAlarmed = ( this.lastAlarmState == STATE_ALARM || this.lastAlarmState == STATE_ALERT ); From 57bd502bb901a0470328292de603383afbf6dfe2 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 May 2022 12:32:26 -0400 Subject: [PATCH 06/10] test for 0 before setting width and height --- web/js/MonitorStream.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index 83ad5678f..675202d42 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -97,7 +97,7 @@ function MonitorStream(monitorData) { } stream_frame = $j('#monitor'+this.id); - if (((newscale == '0') || (newscale=='auto')) && (width=='auto')) { + if (((newscale == '0' || newscale == 0) || (newscale=='auto')) && (width=='auto' || !width)) { if (!this.bottomElement) { newscale = parseInt(100*monitor_frame.width() / this.width); // We don't want to change the existing css, cuz it might be 59% or 123px or auto; @@ -121,9 +121,9 @@ function MonitorStream(monitorData) { width = Math.round(parseInt(this.width) * newscale / 100)+'px'; height = Math.round(parseInt(this.height) * newscale / 100)+'px'; } - monitor_frame.css('width', width); - //img.style.width = width; - img.style.height = height; + if (width && width != '0px') monitor_frame.css('width', width); + if (height && height != '0px') img.style.height = height; + this.setStreamScale(newscale); }; // setscale From 53025e15723bc8032b81ff7d93f7019ba2180b67 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 May 2022 12:37:36 -0400 Subject: [PATCH 07/10] set src='' before new value. Firefox needs it. set scale to 100 when 0, just for consistency. Remove stream_frame which is unused, fixup parenthesis --- web/js/MonitorStream.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index 675202d42..630c438b3 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -95,9 +95,8 @@ function MonitorStream(monitorData) { console.log('Error finding frame'); return; } - stream_frame = $j('#monitor'+this.id); - if (((newscale == '0' || newscale == 0) || (newscale=='auto')) && (width=='auto' || !width)) { + if (((newscale == '0') || (newscale == 0) || (newscale=='auto')) && (width=='auto' || !width)) { if (!this.bottomElement) { newscale = parseInt(100*monitor_frame.width() / this.width); // We don't want to change the existing css, cuz it might be 59% or 123px or auto; @@ -139,11 +138,10 @@ function MonitorStream(monitorData) { } if (img.nodeName == 'IMG') { if (newscale > 100) newscale = 100; // we never request a larger image, as it just wastes bandwidth - if (newscale < 0) newscale = 100; + if (newscale <= 0) newscale = 100; const oldSrc = img.src; if (!oldSrc) { - console.log('No src on img?!'); - console.log(img); + console.log('No src on img?!', img); return; } const newSrc = oldSrc.replace(/scale=\d+/i, 'scale='+newscale); @@ -157,7 +155,7 @@ function MonitorStream(monitorData) { this.streamCommand(CMD_QUIT); } console.log("Changing src to " + newSrc); - //img.src = ''; + img.src = ''; img.src = newSrc; this.statusCmdTimer = setTimeout(this.statusQuery.bind(this), statusRefreshTimeout); } From 72914ea47debecd1d00644b3568c68208d59c31b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 May 2022 12:59:27 -0400 Subject: [PATCH 08/10] Use freeform_layout_id instead of Freeform when selecting layout --- web/skins/classic/views/js/montage.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js index f6b37559d..1d537877f 100644 --- a/web/skins/classic/views/js/montage.js +++ b/web/skins/classic/views/js/montage.js @@ -3,12 +3,11 @@ * is rendered * @param {*} new_layout - the name of a layout to switch to */ -function selectLayout(new_layout) { +function selectLayout(new_layout_id) { const ddm = $j('#zmMontageLayout'); - if (new_layout && (typeof(new_layout) != 'object')) { - console.log("Selecting " + new_layout); - $j('#zmMontageLayout option').attr('selected', false); - $j('#zmMontageLayout option:contains("'+new_layout+'")').attr('selected', true); + if (new_layout_id && (typeof(new_layout_id) != 'object')) { + console.log("Selecting " + new_layout_id); + ddm.val(new_layout_id); } const layout_id = parseInt(ddm.val()); if (!layout_id) { @@ -88,13 +87,12 @@ function changeWidth() { var height = $j('#height').val(); console.log("changeWidth"); - selectLayout('Freeform'); + selectLayout(freeform_layout_id); $j('#width').val(width); $j('#height').val(height); for (var i = 0, length = monitors.length; i < length; i++) { - var monitor = monitors[i]; - monitor.setScale('0', width, height); + monitors[i].setScale('0', width, height); } $j('#scale').val('0'); setCookie('zmMontageScale', '0', 3600); @@ -107,7 +105,7 @@ function changeWidth() { */ function changeScale() { var scale = $j('#scale').val(); - selectLayout('Freeform'); // Will also clear width and height + selectLayout(freeform_layout_id); // Will also clear width and height $j('#scale').val(scale); setCookie('zmMontageScale', scale, 3600); setCookie('zmMontageWidth', 'auto', 3600); @@ -186,7 +184,7 @@ function cancel_layout(button) { //monitor_feed = $j('#imageFeed'+monitor.id); //monitor_feed.click(monitor.onclick); }; - selectLayout('Freeform'); + selectLayout(freeform_layout_id); } function reloadWebSite(ndx) { @@ -216,11 +214,7 @@ function initPage() { monitors[i] = new MonitorStream(monitorData[i]); } selectLayout(); - const scale = $j('#scale').val(); - const width = $j('#width').val(); - const height = $j('#height').val(); for (let i = 0, length = monitorData.length; i < length; i++) { - monitors[i].setScale(scale, width, height); // Start the fps and status updates. give a random delay so that we don't assault the server const delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout ); monitors[i].start(delay); From 544c1a248c624883399305e29c37028a7cb4877c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 May 2022 13:00:13 -0400 Subject: [PATCH 09/10] Only set monitor_frame width if it is auto --- web/js/MonitorStream.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index 630c438b3..b3a513710 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -106,7 +106,6 @@ function MonitorStream(monitorData) { width = newSize.width+'px'; height = newSize.height+'px'; newscale = parseInt(newSize.autoScale); - console.log("Have ottom selement, doing auto scale", newSize); } } else if (parseInt(width) || parseInt(height)) { if (width) { @@ -120,7 +119,7 @@ function MonitorStream(monitorData) { width = Math.round(parseInt(this.width) * newscale / 100)+'px'; height = Math.round(parseInt(this.height) * newscale / 100)+'px'; } - if (width && width != '0px') monitor_frame.css('width', width); + if (width && width != '0px' && monitor_frame.css('width') == 'auto') monitor_frame.css('width', width); if (height && height != '0px') img.style.height = height; this.setStreamScale(newscale); From 30efcc88549192233c3cab233d08b6232360187a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 26 May 2022 13:58:04 -0400 Subject: [PATCH 10/10] fix jsdoc --- web/skins/classic/views/js/montage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js index 1d537877f..56268163a 100644 --- a/web/skins/classic/views/js/montage.js +++ b/web/skins/classic/views/js/montage.js @@ -1,7 +1,7 @@ /** * called when the layoutControl select element is changed, or the page * is rendered - * @param {*} new_layout - the name of a layout to switch to + * @param {*} new_layout_id - the id of a layout to switch to */ function selectLayout(new_layout_id) { const ddm = $j('#zmMontageLayout');