From f1cffa6fe1dabd6fd02385276524ee5d5befe860 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 9 Sep 2019 08:22:58 -0400 Subject: [PATCH 1/4] Add more debian based distros to packpack builds --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 80541eaab..d16829c11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,8 +37,16 @@ env: - SMPFLAGS=-j4 OS=fedora DIST=29 DOCKER_REPO=knnniggett/packpack - SMPFLAGS=-j4 OS=ubuntu DIST=trusty - SMPFLAGS=-j4 OS=ubuntu DIST=xenial + - SMPFLAGS=-j4 OS=ubuntu DIST=bionic + - SMPFLAGS=-j4 OS=ubuntu DIST=disco + - SMPFLAGS=-j4 OS=ubuntu DIST=buster + - SMPFLAGS=-j4 OS=ubuntu DIST=stretch - SMPFLAGS=-j4 OS=ubuntu DIST=trusty ARCH=i386 - SMPFLAGS=-j4 OS=ubuntu DIST=xenial ARCH=i386 + - SMPFLAGS=-j4 OS=ubuntu DIST=bionic ARCH=i386 + - SMPFLAGS=-j4 OS=ubuntu DIST=disco ARCH=i386 + - SMPFLAGS=-j4 OS=ubuntu DIST=buster ARCH=i386 + - SMPFLAGS=-j4 OS=ubuntu DIST=stretch ARCH=i386 - SMPFLAGS=-j4 OS=raspbian DIST=stretch ARCH=armhf DOCKER_REPO=knnniggett/packpack compiler: From 8103156436173db679dae579a41042eb69313e1e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 9 Sep 2019 09:16:52 -0400 Subject: [PATCH 2/4] when deleting multiple events, each event has to be it's own transaction due to locking --- web/includes/Event.php | 15 +++++++-------- web/includes/actions/events.php | 2 -- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/web/includes/Event.php b/web/includes/Event.php index e8b6d15be..19d28e0ec 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -142,16 +142,14 @@ class Event extends ZM_Object { # Assumption: All events have a start time $start_date = date_parse($this->{'StartTime'}); if ( ! $start_date ) { - Error('Unable to parse start time for event ' . $this->{'Id'} . ' not deleting files.'); - return; + throw new Exception('Unable to parse start time for event ' . $this->{'Id'} . ' not deleting files.'); } $start_date['year'] = $start_date['year'] % 100; # So this is because ZM creates a link under the day pointing to the time that the event happened. $link_path = $this->Link_Path(); if ( ! $link_path ) { - Error('Unable to determine link path for event '.$this->{'Id'}.' not deleting files.'); - return; + throw new Exception('Unable to determine link path for event '.$this->{'Id'}.' not deleting files.'); } $Storage = $this->Storage(); @@ -159,8 +157,7 @@ class Event extends ZM_Object { if ( $id_files = glob($eventlink_path) ) { if ( ! $eventPath = readlink($id_files[0]) ) { - Error("Unable to read link at $id_files[0]"); - return; + throw new Exception("Unable to read link at $id_files[0]"); } # I know we are using arrays here, but really there can only ever be 1 in the array $eventPath = preg_replace('/\.'.$this->{'Id'}.'$/', $eventPath, $id_files[0]); @@ -179,8 +176,7 @@ class Event extends ZM_Object { } else { $eventPath = $this->Path(); if ( ! $eventPath ) { - Error('No event Path in Event delete. Not deleting'); - return; + throw new Exception('No event Path in Event delete. Not deleting'); } deletePath($eventPath); if ( $this->SecondaryStorageId() ) { @@ -199,6 +195,9 @@ class Event extends ZM_Object { $dbConn->commit(); } catch (PDOException $e) { $dbConn->rollback(); + } catch (Exception $e) { + Error($e->getMessage()); + $dbConn->rollback(); } } # end Event->delete diff --git a/web/includes/actions/events.php b/web/includes/actions/events.php index 08782a8a2..abea69b60 100644 --- a/web/includes/actions/events.php +++ b/web/includes/actions/events.php @@ -44,11 +44,9 @@ if ( $action == 'archive' ) { $dbConn->commit(); $refreshParent = true; } else if ( $action == 'delete' ) { - $dbConn->beginTransaction(); foreach ( getAffectedIds('eids') as $markEid ) { deleteEvent($markEid); } - $dbConn->commit(); $refreshParent = true; } ?> From 922273410ba36f7e6b40f0f2df8132b0e88a2661 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 9 Sep 2019 10:04:57 -0400 Subject: [PATCH 3/4] correct dist for debian --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d16829c11..e41dcb35f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,14 +39,14 @@ env: - SMPFLAGS=-j4 OS=ubuntu DIST=xenial - SMPFLAGS=-j4 OS=ubuntu DIST=bionic - SMPFLAGS=-j4 OS=ubuntu DIST=disco - - SMPFLAGS=-j4 OS=ubuntu DIST=buster - - SMPFLAGS=-j4 OS=ubuntu DIST=stretch + - SMPFLAGS=-j4 OS=debian DIST=buster + - SMPFLAGS=-j4 OS=debian DIST=stretch - SMPFLAGS=-j4 OS=ubuntu DIST=trusty ARCH=i386 - SMPFLAGS=-j4 OS=ubuntu DIST=xenial ARCH=i386 - SMPFLAGS=-j4 OS=ubuntu DIST=bionic ARCH=i386 - SMPFLAGS=-j4 OS=ubuntu DIST=disco ARCH=i386 - - SMPFLAGS=-j4 OS=ubuntu DIST=buster ARCH=i386 - - SMPFLAGS=-j4 OS=ubuntu DIST=stretch ARCH=i386 + - SMPFLAGS=-j4 OS=debian DIST=buster ARCH=i386 + - SMPFLAGS=-j4 OS=debian DIST=stretch ARCH=i386 - SMPFLAGS=-j4 OS=raspbian DIST=stretch ARCH=armhf DOCKER_REPO=knnniggett/packpack compiler: From d5aa95e45fde34289034c7ec27eae1534644466c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 9 Sep 2019 16:13:32 -0400 Subject: [PATCH 4/4] cpplint fixes --- src/zm_videostore.cpp | 41 ++++++++++++++++++++------------------- web/includes/database.php | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index c003f165b..b10cb4a00 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -20,13 +20,14 @@ #define __STDC_FORMAT_MACROS 1 -#include -#include -#include #include "zm.h" #include "zm_videostore.h" +#include +#include +#include + extern "C" { #include "libavutil/time.h" } @@ -162,7 +163,7 @@ VideoStore::VideoStore( if ( !video_out_ctx->codec_tag ) { Debug(2, "No codec_tag"); - if ( + if ( !oc->oformat->codec_tag || av_codec_get_id(oc->oformat->codec_tag, video_in_ctx->codec_tag) == video_out_ctx->codec_id @@ -178,17 +179,17 @@ VideoStore::VideoStore( video_out_stream->time_base = video_in_stream->time_base; if ( video_in_stream->avg_frame_rate.num ) { Debug(3,"Copying avg_frame_rate (%d/%d)", - video_in_stream->avg_frame_rate.num, - video_in_stream->avg_frame_rate.den + video_in_stream->avg_frame_rate.num, + video_in_stream->avg_frame_rate.den ); video_out_stream->avg_frame_rate = video_in_stream->avg_frame_rate; } if ( video_in_stream->r_frame_rate.num ) { Debug(3,"Copying r_frame_rate (%d/%d) to out (%d/%d)", - video_in_stream->r_frame_rate.num, + video_in_stream->r_frame_rate.num, video_in_stream->r_frame_rate.den , - video_out_stream->r_frame_rate.num, - video_out_stream->r_frame_rate.den + video_out_stream->r_frame_rate.num, + video_out_stream->r_frame_rate.den ); video_out_stream->r_frame_rate = video_in_stream->r_frame_rate; } @@ -301,7 +302,7 @@ VideoStore::VideoStore( audio_out_stream = NULL; return; } -#else +#else audio_out_stream = avformat_new_stream(oc, audio_out_codec); audio_out_ctx = audio_out_stream->codec; #endif @@ -653,7 +654,7 @@ bool VideoStore::setup_resampler() { #else // codec is already open in ffmpeg_camera audio_in_ctx = audio_in_stream->codec; - audio_in_codec = (AVCodec *)audio_in_ctx->codec; + audio_in_codec = reinterpret_castaudio_in_ctx->codec; //audio_in_codec = avcodec_find_decoder(audio_in_stream->codec->codec_id); #endif @@ -867,7 +868,7 @@ bool VideoStore::setup_resampler() { NULL, audio_out_ctx->channels, audio_out_ctx->frame_size, audio_out_ctx->sample_fmt, 0); - converted_in_samples = (uint8_t *)av_malloc(audioSampleBuffer_size); + converted_in_samples = reinterpret_cast(av_malloc(audioSampleBuffer_size)); if ( !converted_in_samples ) { Error("Could not allocate converted in sample pointers"); @@ -921,7 +922,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) { duration ); if ( duration <= 0 ) { - // Why are we setting the duration to 1? + // Why are we setting the duration to 1? duration = ipkt->duration ? ipkt->duration : av_rescale_q(1,video_in_stream->time_base, video_out_stream->time_base); } } @@ -971,7 +972,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) { // && ( ipkt->dts >= 0 ) ) { // This is the first packet. opkt.dts = 0; - Debug(1, "Starting video first_dts will become (%" PRId64 ")", ipkt->dts); + Debug(2, "Starting video first_dts will become (%" PRId64 ")", ipkt->dts); video_first_dts = ipkt->dts; #if 1 if ( audio_in_stream ) { @@ -1137,7 +1138,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { } else { opkt.dts = AV_NOPTS_VALUE; } -#else +#else opkt.pts = av_rescale_q( opkt.pts, audio_out_ctx->time_base, @@ -1231,10 +1232,10 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { write_packet(&opkt, audio_out_stream); zm_av_packet_unref(&opkt); - } // end if encoding or copying + } // end if encoding or copying return 0; -} // end int VideoStore::writeAudioFramePacket(AVPacket *ipkt) +} // end int VideoStore::writeAudioFramePacket(AVPacket *ipkt) int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) { pkt->pos = -1; @@ -1267,7 +1268,7 @@ int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) { } else { Debug(2, "Success writing packet"); } -} // end int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) +} // end int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) int VideoStore::resample_audio() { // Resample the in_frame into the audioSampleBuffer until we process the whole @@ -1303,7 +1304,7 @@ int VideoStore::resample_audio() { // AAC requires 1024 samples per encode. Our input tends to be something else, so need to buffer them. if ( frame_size > av_audio_fifo_size(fifo) ) { - Debug(1, "Not enough samples in fifo for AAC codec frame_size %d > fifo size %d", + Debug(1, "Not enough samples in fifo for AAC codec frame_size %d > fifo size %d", frame_size, av_audio_fifo_size(fifo)); return 0; } @@ -1354,4 +1355,4 @@ int VideoStore::resample_audio() { return 0; #endif return 1; -} // end int VideoStore::resample_audio +} // end int VideoStore::resample_audio diff --git a/web/includes/database.php b/web/includes/database.php index d941a01e0..5ec54f163 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -56,7 +56,7 @@ function dbConnect() { $dbConn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } catch(PDOException $ex ) { + } catch(PDOException $ex) { echo 'Unable to connect to ZM db.' . $ex->getMessage(); error_log('Unable to connect to ZM DB ' . $ex->getMessage()); $dbConn = null;