Merge branch 'master' of github.com:ZoneMinder/ZoneMinder
This commit is contained in:
commit
9682edd080
|
@ -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:
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ VideoStore::VideoStore(
|
||||||
|
|
||||||
if ( !video_out_ctx->codec_tag ) {
|
if ( !video_out_ctx->codec_tag ) {
|
||||||
Debug(2, "No codec_tag");
|
Debug(2, "No codec_tag");
|
||||||
if (
|
if (
|
||||||
!oc->oformat->codec_tag
|
!oc->oformat->codec_tag
|
||||||
||
|
||
|
||||||
av_codec_get_id(oc->oformat->codec_tag, video_in_ctx->codec_tag) == video_out_ctx->codec_id
|
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;
|
video_out_stream->time_base = video_in_stream->time_base;
|
||||||
if ( video_in_stream->avg_frame_rate.num ) {
|
if ( video_in_stream->avg_frame_rate.num ) {
|
||||||
Debug(3,"Copying avg_frame_rate (%d/%d)",
|
Debug(3,"Copying avg_frame_rate (%d/%d)",
|
||||||
video_in_stream->avg_frame_rate.num,
|
video_in_stream->avg_frame_rate.num,
|
||||||
video_in_stream->avg_frame_rate.den
|
video_in_stream->avg_frame_rate.den
|
||||||
);
|
);
|
||||||
video_out_stream->avg_frame_rate = video_in_stream->avg_frame_rate;
|
video_out_stream->avg_frame_rate = video_in_stream->avg_frame_rate;
|
||||||
}
|
}
|
||||||
if ( video_in_stream->r_frame_rate.num ) {
|
if ( video_in_stream->r_frame_rate.num ) {
|
||||||
Debug(3,"Copying r_frame_rate (%d/%d) to out (%d/%d)",
|
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_in_stream->r_frame_rate.den ,
|
||||||
video_out_stream->r_frame_rate.num,
|
video_out_stream->r_frame_rate.num,
|
||||||
video_out_stream->r_frame_rate.den
|
video_out_stream->r_frame_rate.den
|
||||||
);
|
);
|
||||||
video_out_stream->r_frame_rate = video_in_stream->r_frame_rate;
|
video_out_stream->r_frame_rate = video_in_stream->r_frame_rate;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +302,7 @@ VideoStore::VideoStore(
|
||||||
audio_out_stream = NULL;
|
audio_out_stream = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
audio_out_stream = avformat_new_stream(oc, audio_out_codec);
|
audio_out_stream = avformat_new_stream(oc, audio_out_codec);
|
||||||
audio_out_ctx = audio_out_stream->codec;
|
audio_out_ctx = audio_out_stream->codec;
|
||||||
#endif
|
#endif
|
||||||
|
@ -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");
|
||||||
|
@ -921,7 +922,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
|
||||||
duration
|
duration
|
||||||
);
|
);
|
||||||
if ( duration <= 0 ) {
|
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);
|
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 ) ) {
|
// && ( 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 ) {
|
||||||
|
@ -1137,7 +1138,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) {
|
||||||
} else {
|
} else {
|
||||||
opkt.dts = AV_NOPTS_VALUE;
|
opkt.dts = AV_NOPTS_VALUE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
opkt.pts = av_rescale_q(
|
opkt.pts = av_rescale_q(
|
||||||
opkt.pts,
|
opkt.pts,
|
||||||
audio_out_ctx->time_base,
|
audio_out_ctx->time_base,
|
||||||
|
@ -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
|
||||||
|
@ -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.
|
// 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) ) {
|
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));
|
frame_size, av_audio_fifo_size(fifo));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue