Merge branch 'master' of github.com:ZoneMinder/ZoneMinder

This commit is contained in:
Isaac Connor 2019-09-09 16:16:49 -04:00
commit 9682edd080
5 changed files with 37 additions and 31 deletions

View File

@ -37,8 +37,16 @@ env:
- SMPFLAGS=-j4 OS=fedora DIST=29 DOCKER_REPO=knnniggett/packpack - SMPFLAGS=-j4 OS=fedora DIST=29 DOCKER_REPO=knnniggett/packpack
- SMPFLAGS=-j4 OS=ubuntu DIST=trusty - SMPFLAGS=-j4 OS=ubuntu DIST=trusty
- SMPFLAGS=-j4 OS=ubuntu DIST=xenial - SMPFLAGS=-j4 OS=ubuntu DIST=xenial
- SMPFLAGS=-j4 OS=ubuntu DIST=bionic
- SMPFLAGS=-j4 OS=ubuntu DIST=disco
- 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=trusty ARCH=i386
- SMPFLAGS=-j4 OS=ubuntu DIST=xenial 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=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 - SMPFLAGS=-j4 OS=raspbian DIST=stretch ARCH=armhf DOCKER_REPO=knnniggett/packpack
compiler: compiler:

View File

@ -20,13 +20,14 @@
#define __STDC_FORMAT_MACROS 1 #define __STDC_FORMAT_MACROS 1
#include <cinttypes>
#include <stdlib.h>
#include <string.h>
#include "zm.h" #include "zm.h"
#include "zm_videostore.h" #include "zm_videostore.h"
#include <stdlib.h>
#include <string.h>
#include <cinttypes>
extern "C" { extern "C" {
#include "libavutil/time.h" #include "libavutil/time.h"
} }
@ -653,7 +654,7 @@ bool VideoStore::setup_resampler() {
#else #else
// codec is already open in ffmpeg_camera // codec is already open in ffmpeg_camera
audio_in_ctx = audio_in_stream->codec; audio_in_ctx = audio_in_stream->codec;
audio_in_codec = (AVCodec *)audio_in_ctx->codec; audio_in_codec = reinterpret_cast<AVCodec *>audio_in_ctx->codec;
//audio_in_codec = avcodec_find_decoder(audio_in_stream->codec->codec_id); //audio_in_codec = avcodec_find_decoder(audio_in_stream->codec->codec_id);
#endif #endif
@ -867,7 +868,7 @@ bool VideoStore::setup_resampler() {
NULL, audio_out_ctx->channels, NULL, audio_out_ctx->channels,
audio_out_ctx->frame_size, audio_out_ctx->frame_size,
audio_out_ctx->sample_fmt, 0); audio_out_ctx->sample_fmt, 0);
converted_in_samples = (uint8_t *)av_malloc(audioSampleBuffer_size); converted_in_samples = reinterpret_cast<uint8_t *>(av_malloc(audioSampleBuffer_size));
if ( !converted_in_samples ) { if ( !converted_in_samples ) {
Error("Could not allocate converted in sample pointers"); Error("Could not allocate converted in sample pointers");
@ -971,7 +972,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
// && ( ipkt->dts >= 0 ) ) { // && ( ipkt->dts >= 0 ) ) {
// This is the first packet. // This is the first packet.
opkt.dts = 0; 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; video_first_dts = ipkt->dts;
#if 1 #if 1
if ( audio_in_stream ) { if ( audio_in_stream ) {
@ -1231,10 +1232,10 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
write_packet(&opkt, audio_out_stream); write_packet(&opkt, audio_out_stream);
zm_av_packet_unref(&opkt); zm_av_packet_unref(&opkt);
} // end if encoding or copying } // end if encoding or copying
return 0; return 0;
} // end int VideoStore::writeAudioFramePacket(AVPacket *ipkt) } // end int VideoStore::writeAudioFramePacket(AVPacket *ipkt)
int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) { int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) {
pkt->pos = -1; pkt->pos = -1;
@ -1267,7 +1268,7 @@ int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) {
} else { } else {
Debug(2, "Success writing packet"); 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() { int VideoStore::resample_audio() {
// Resample the in_frame into the audioSampleBuffer until we process the whole // Resample the in_frame into the audioSampleBuffer until we process the whole
@ -1354,4 +1355,4 @@ int VideoStore::resample_audio() {
return 0; return 0;
#endif #endif
return 1; return 1;
} // end int VideoStore::resample_audio } // end int VideoStore::resample_audio

View File

@ -142,16 +142,14 @@ class Event extends ZM_Object {
# Assumption: All events have a start time # Assumption: All events have a start time
$start_date = date_parse($this->{'StartTime'}); $start_date = date_parse($this->{'StartTime'});
if ( ! $start_date ) { if ( ! $start_date ) {
Error('Unable to parse start time for event ' . $this->{'Id'} . ' not deleting files.'); throw new Exception('Unable to parse start time for event ' . $this->{'Id'} . ' not deleting files.');
return;
} }
$start_date['year'] = $start_date['year'] % 100; $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. # So this is because ZM creates a link under the day pointing to the time that the event happened.
$link_path = $this->Link_Path(); $link_path = $this->Link_Path();
if ( ! $link_path ) { if ( ! $link_path ) {
Error('Unable to determine link path for event '.$this->{'Id'}.' not deleting files.'); throw new Exception('Unable to determine link path for event '.$this->{'Id'}.' not deleting files.');
return;
} }
$Storage = $this->Storage(); $Storage = $this->Storage();
@ -159,8 +157,7 @@ class Event extends ZM_Object {
if ( $id_files = glob($eventlink_path) ) { if ( $id_files = glob($eventlink_path) ) {
if ( ! $eventPath = readlink($id_files[0]) ) { if ( ! $eventPath = readlink($id_files[0]) ) {
Error("Unable to read link at $id_files[0]"); throw new Exception("Unable to read link at $id_files[0]");
return;
} }
# I know we are using arrays here, but really there can only ever be 1 in the array # 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]); $eventPath = preg_replace('/\.'.$this->{'Id'}.'$/', $eventPath, $id_files[0]);
@ -179,8 +176,7 @@ class Event extends ZM_Object {
} else { } else {
$eventPath = $this->Path(); $eventPath = $this->Path();
if ( ! $eventPath ) { if ( ! $eventPath ) {
Error('No event Path in Event delete. Not deleting'); throw new Exception('No event Path in Event delete. Not deleting');
return;
} }
deletePath($eventPath); deletePath($eventPath);
if ( $this->SecondaryStorageId() ) { if ( $this->SecondaryStorageId() ) {
@ -199,6 +195,9 @@ class Event extends ZM_Object {
$dbConn->commit(); $dbConn->commit();
} catch (PDOException $e) { } catch (PDOException $e) {
$dbConn->rollback(); $dbConn->rollback();
} catch (Exception $e) {
Error($e->getMessage());
$dbConn->rollback();
} }
} # end Event->delete } # end Event->delete

View File

@ -44,11 +44,9 @@ if ( $action == 'archive' ) {
$dbConn->commit(); $dbConn->commit();
$refreshParent = true; $refreshParent = true;
} else if ( $action == 'delete' ) { } else if ( $action == 'delete' ) {
$dbConn->beginTransaction();
foreach ( getAffectedIds('eids') as $markEid ) { foreach ( getAffectedIds('eids') as $markEid ) {
deleteEvent($markEid); deleteEvent($markEid);
} }
$dbConn->commit();
$refreshParent = true; $refreshParent = true;
} }
?> ?>

View File

@ -56,7 +56,7 @@ function dbConnect() {
$dbConn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $dbConn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $ex ) { } catch(PDOException $ex) {
echo 'Unable to connect to ZM db.' . $ex->getMessage(); echo 'Unable to connect to ZM db.' . $ex->getMessage();
error_log('Unable to connect to ZM DB ' . $ex->getMessage()); error_log('Unable to connect to ZM DB ' . $ex->getMessage());
$dbConn = null; $dbConn = null;