Whitespace, extra parentheses, google code style

This commit is contained in:
Isaac Connor 2018-09-23 16:47:06 -04:00
parent c8c533ca2f
commit 89cd7ceaf8
11 changed files with 787 additions and 842 deletions

View File

@ -33,8 +33,7 @@ class Camera;
// Abstract base class for cameras. This is intended just to express // Abstract base class for cameras. This is intended just to express
// common attributes // common attributes
// //
class Camera class Camera {
{
protected: protected:
typedef enum { LOCAL_SRC, REMOTE_SRC, FILE_SRC, FFMPEG_SRC, LIBVLC_SRC, CURL_SRC } SourceType; typedef enum { LOCAL_SRC, REMOTE_SRC, FILE_SRC, FFMPEG_SRC, LIBVLC_SRC, CURL_SRC } SourceType;
@ -53,49 +52,48 @@ protected:
int contrast; int contrast;
bool capture; bool capture;
bool record_audio; bool record_audio;
unsigned int bytes; unsigned int bytes;
public: public:
Camera( unsigned int p_monitor_id, SourceType p_type, unsigned int p_width, unsigned int p_height, int p_colours, int p_subpixelorder, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ); Camera( unsigned int p_monitor_id, SourceType p_type, unsigned int p_width, unsigned int p_height, int p_colours, int p_subpixelorder, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
virtual ~Camera(); virtual ~Camera();
unsigned int getId() const { return( monitor_id ); } unsigned int getId() const { return monitor_id; }
Monitor *getMonitor(); Monitor *getMonitor();
void setMonitor( Monitor *p_monitor ); void setMonitor( Monitor *p_monitor );
SourceType Type() const { return( type ); } SourceType Type() const { return type; }
bool IsLocal() const { return( type == LOCAL_SRC ); } bool IsLocal() const { return type == LOCAL_SRC; }
bool IsRemote() const { return( type == REMOTE_SRC ); } bool IsRemote() const { return type == REMOTE_SRC; }
bool IsFile() const { return( type == FILE_SRC ); } bool IsFile() const { return type == FILE_SRC; }
bool IsFfmpeg() const { return( type == FFMPEG_SRC ); } bool IsFfmpeg() const { return type == FFMPEG_SRC; }
bool IsLibvlc() const { return( type == LIBVLC_SRC ); } bool IsLibvlc() const { return type == LIBVLC_SRC; }
bool IscURL() const { return( type == CURL_SRC ); } bool IscURL() const { return type == CURL_SRC; }
unsigned int Width() const { return( width ); } unsigned int Width() const { return width; }
unsigned int Height() const { return( height ); } unsigned int Height() const { return height; }
unsigned int Colours() const { return( colours ); } unsigned int Colours() const { return colours; }
unsigned int SubpixelOrder() const { return( subpixelorder ); } unsigned int SubpixelOrder() const { return subpixelorder; }
unsigned int Pixels() const { return( pixels ); } unsigned int Pixels() const { return pixels; }
unsigned int ImageSize() const { return( imagesize ); } unsigned int ImageSize() const { return imagesize; }
unsigned int Bytes() const { return bytes; }; unsigned int Bytes() const { return bytes; };
virtual int Brightness( int/*p_brightness*/=-1 ) { return( -1 ); } virtual int Brightness( int/*p_brightness*/=-1 ) { return -1; }
virtual int Hue( int/*p_hue*/=-1 ) { return( -1 ); } virtual int Hue( int/*p_hue*/=-1 ) { return -1; }
virtual int Colour( int/*p_colour*/=-1 ) { return( -1 ); } virtual int Colour( int/*p_colour*/=-1 ) { return -1; }
virtual int Contrast( int/*p_contrast*/=-1 ) { return( -1 ); } virtual int Contrast( int/*p_contrast*/=-1 ) { return -1; }
bool CanCapture() const { return( capture ); } bool CanCapture() const { return capture; }
bool SupportsNativeVideo() const { bool SupportsNativeVideo() const {
return (type == FFMPEG_SRC); return (type == FFMPEG_SRC);
//return (type == FFMPEG_SRC )||(type == REMOTE_SRC); //return (type == FFMPEG_SRC )||(type == REMOTE_SRC);
} }
virtual int PrimeCapture() { return( 0 ); } virtual int PrimeCapture() { return 0; }
virtual int PreCapture()=0; virtual int PreCapture() = 0;
virtual int Capture( Image &image )=0; virtual int Capture(Image &image) = 0;
virtual int PostCapture()=0; virtual int PostCapture() = 0;
virtual int CaptureAndRecord( Image &image, timeval recording, char* event_directory ) = 0; virtual int CaptureAndRecord(Image &image, timeval recording, char* event_directory) = 0;
virtual int Close()=0; virtual int Close() = 0;
}; };
#endif // ZM_CAMERA_H #endif // ZM_CAMERA_H

View File

@ -147,9 +147,8 @@ Event::Event(
errno = 0; errno = 0;
if ( mkdir(path, 0755) ) { if ( mkdir(path, 0755) ) {
// FIXME This should not be fatal. Should probably move to a different storage area. // FIXME This should not be fatal. Should probably move to a different storage area.
if ( errno != EEXIST ) { if ( errno != EEXIST )
Error("Can't mkdir %s: %s", path, strerror(errno)); Error("Can't mkdir %s: %s", path, strerror(errno));
}
} }
if ( i == 2 ) if ( i == 2 )
strncpy(date_path, path, sizeof(date_path)); strncpy(date_path, path, sizeof(date_path));

View File

@ -59,7 +59,7 @@ class FfmpegCamera : public Camera {
bool hwaccel; bool hwaccel;
#if HAVE_AVUTIL_HWCONTEXT_H #if HAVE_AVUTIL_HWCONTEXT_H
AVFrame *hwFrame; AVFrame *hwFrame;
DecodeContext decode; DecodeContext decode;
#endif #endif
// Need to keep track of these because apparently the stream can start with values for pts/dts and then subsequent packets start at zero. // Need to keep track of these because apparently the stream can start with values for pts/dts and then subsequent packets start at zero.

View File

@ -649,11 +649,9 @@ void Image::Assign( const Image &image ) {
(*fptr_imgbufcpy)(buffer, image.buffer, size); (*fptr_imgbufcpy)(buffer, image.buffer, size);
} }
Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p_subpixelorder, const Box *limits ) Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p_subpixelorder, const Box *limits ) {
{ if ( colours != ZM_COLOUR_GRAY8 ) {
if ( colours != ZM_COLOUR_GRAY8 ) Panic("Attempt to highlight image edges when colours = %d", colours);
{
Panic( "Attempt to highlight image edges when colours = %d", colours );
} }
/* Convert the colour's RGBA subpixel order into the image's subpixel order */ /* Convert the colour's RGBA subpixel order into the image's subpixel order */

View File

@ -160,16 +160,16 @@ public:
static void Initialise(); static void Initialise();
static void Deinitialise(); static void Deinitialise();
inline unsigned int Width() const { return( width ); } inline unsigned int Width() const { return width; }
inline unsigned int Height() const { return( height ); } inline unsigned int Height() const { return height; }
inline unsigned int Pixels() const { return( pixels ); } inline unsigned int Pixels() const { return pixels; }
inline unsigned int Colours() const { return( colours ); } inline unsigned int Colours() const { return colours; }
inline unsigned int SubpixelOrder() const { return( subpixelorder ); } inline unsigned int SubpixelOrder() const { return subpixelorder; }
inline unsigned int Size() const { return( size ); } inline unsigned int Size() const { return size; }
/* Internal buffer should not be modified from functions outside of this class */ /* Internal buffer should not be modified from functions outside of this class */
inline const uint8_t* Buffer() const { return( buffer ); } inline const uint8_t* Buffer() const { return buffer; }
inline const uint8_t* Buffer( unsigned int x, unsigned int y= 0 ) const { return( &buffer[colours*((y*width)+x)] ); } inline const uint8_t* Buffer( unsigned int x, unsigned int y= 0 ) const { return &buffer[colours*((y*width)+x)]; }
/* Request writeable buffer */ /* Request writeable buffer */
uint8_t* WriteBuffer(const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder); uint8_t* WriteBuffer(const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder);
@ -196,7 +196,7 @@ public:
} }
inline Image &operator=( const unsigned char *new_buffer ) { inline Image &operator=( const unsigned char *new_buffer ) {
(*fptr_imgbufcpy)(buffer, new_buffer, size); (*fptr_imgbufcpy)(buffer, new_buffer, size);
return( *this ); return *this;
} }
bool ReadRaw( const char *filename ); bool ReadRaw( const char *filename );

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
#endif #endif
bool Logger::smInitialised = false; bool Logger::smInitialised = false;
Logger *Logger::smInstance = 0; Logger *Logger::smInstance = NULL;
Logger::StringMap Logger::smCodes; Logger::StringMap Logger::smCodes;
Logger::IntMap Logger::smSyslogPriorities; Logger::IntMap Logger::smSyslogPriorities;
@ -58,9 +58,9 @@ static void subtractTime( struct timeval * const tp1, struct timeval * const tp2
void Logger::usrHandler( int sig ) { void Logger::usrHandler( int sig ) {
Logger *logger = fetch(); Logger *logger = fetch();
if ( sig == SIGUSR1 ) if ( sig == SIGUSR1 )
logger->level( logger->level()+1 ); logger->level(logger->level()+1);
else if ( sig == SIGUSR2 ) else if ( sig == SIGUSR2 )
logger->level( logger->level()-1 ); logger->level(logger->level()-1);
Info("Logger - Level changed to %d", logger->level()); Info("Logger - Level changed to %d", logger->level());
} }
@ -79,7 +79,7 @@ Logger::Logger() :
mFlush(false) { mFlush(false) {
if ( smInstance ) { if ( smInstance ) {
Panic( "Attempt to create second instance of Logger class" ); Panic("Attempt to create second instance of Logger class");
} }
if ( !smInitialised ) { if ( !smInitialised ) {
@ -133,11 +133,11 @@ void Logger::initialise(const std::string &id, const Options &options) {
std::string tempLogFile; std::string tempLogFile;
if ( (envPtr = getTargettedEnv("LOG_FILE")) ) if ( (envPtr = getTargettedEnv("LOG_FILE")) ) {
tempLogFile = envPtr; tempLogFile = envPtr;
else if ( options.mLogFile.size() ) } else if ( options.mLogFile.size() ) {
tempLogFile = options.mLogFile; tempLogFile = options.mLogFile;
else { } else {
if ( options.mLogPath.size() ) { if ( options.mLogPath.size() ) {
mLogPath = options.mLogPath; mLogPath = options.mLogPath;
} }
@ -169,7 +169,7 @@ void Logger::initialise(const std::string &id, const Options &options) {
tempSyslogLevel = config.log_level_syslog >= DEBUG1 ? DEBUG9 : config.log_level_syslog; tempSyslogLevel = config.log_level_syslog >= DEBUG1 ? DEBUG9 : config.log_level_syslog;
// Legacy // Legacy
if ( (envPtr = getenv( "LOG_PRINT" )) ) if ( (envPtr = getenv("LOG_PRINT")) )
tempTerminalLevel = atoi(envPtr) ? DEBUG9 : NOLOG; tempTerminalLevel = atoi(envPtr) ? DEBUG9 : NOLOG;
if ( (envPtr = getTargettedEnv("LOG_LEVEL")) ) if ( (envPtr = getTargettedEnv("LOG_LEVEL")) )
@ -218,7 +218,7 @@ void Logger::initialise(const std::string &id, const Options &options) {
mFlush = false; mFlush = false;
if ( (envPtr = getenv("LOG_FLUSH")) ) { if ( (envPtr = getenv("LOG_FLUSH")) ) {
mFlush = atoi( envPtr ); mFlush = atoi(envPtr);
} else if ( config.log_debug ) { } else if ( config.log_debug ) {
mFlush = true; mFlush = true;
} }
@ -577,12 +577,12 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
} }
} }
void logInit( const char *name, const Logger::Options &options ) { void logInit(const char *name, const Logger::Options &options) {
if ( !Logger::smInstance ) if ( !Logger::smInstance )
Logger::smInstance = new Logger(); Logger::smInstance = new Logger();
Logger::Options tempOptions = options; Logger::Options tempOptions = options;
tempOptions.mLogPath = staticConfig.PATH_LOGS; tempOptions.mLogPath = staticConfig.PATH_LOGS;
Logger::smInstance->initialise( name, tempOptions ); Logger::smInstance->initialise(name, tempOptions);
} }
void logTerm() { void logTerm() {

View File

@ -254,39 +254,41 @@ protected:
VideoWriter videowriter; VideoWriter videowriter;
std::string encoderparams; std::string encoderparams;
std::vector<EncoderParameter_t> encoderparamsvec; std::vector<EncoderParameter_t> encoderparamsvec;
bool record_audio; // Whether to store the audio that we receive bool record_audio; // Whether to store the audio that we receive
int brightness; // The statically saved brightness of the camera int brightness; // The statically saved brightness of the camera
int contrast; // The statically saved contrast of the camera int contrast; // The statically saved contrast of the camera
int hue; // The statically saved hue of the camera int hue; // The statically saved hue of the camera
int colour; // The statically saved colour of the camera int colour; // The statically saved colour of the camera
char event_prefix[64]; // The prefix applied to event names as they are created char event_prefix[64]; // The prefix applied to event names as they are created
char label_format[64]; // The format of the timestamp on the images char label_format[64]; // The format of the timestamp on the images
Coord label_coord; // The coordinates of the timestamp on the images Coord label_coord; // The coordinates of the timestamp on the images
int label_size; // Size of the timestamp on the images int label_size; // Size of the timestamp on the images
int image_buffer_count; // Size of circular image buffer, at least twice the size of the pre_event_count int image_buffer_count; // Size of circular image buffer, at least twice the size of the pre_event_count
int pre_event_buffer_count; // Size of dedicated circular pre event buffer used when analysis is not performed at capturing framerate, int pre_event_buffer_count; // Size of dedicated circular pre event buffer used when analysis is not performed at capturing framerate,
// value is pre_event_count + alarm_frame_count - 1 // value is pre_event_count + alarm_frame_count - 1
int warmup_count; // How many images to process before looking for events int warmup_count; // How many images to process before looking for events
int pre_event_count; // How many images to hold and prepend to an alarm event int pre_event_count; // How many images to hold and prepend to an alarm event
int post_event_count; // How many unalarmed images must occur before the alarm state is reset int post_event_count; // How many unalarmed images must occur before the alarm state is reset
int stream_replay_buffer; // How many frames to store to support DVR functions, IGNORED from this object, passed directly into zms now int stream_replay_buffer; // How many frames to store to support DVR functions, IGNORED from this object, passed directly into zms now
int section_length; // How long events should last in continuous modes int section_length; // How long events should last in continuous modes
bool adaptive_skip; // Whether to use the newer adaptive algorithm for this monitor bool adaptive_skip; // Whether to use the newer adaptive algorithm for this monitor
int frame_skip; // How many frames to skip in continuous modes int frame_skip; // How many frames to skip in continuous modes
int motion_frame_skip; // How many frames to skip in motion detection int motion_frame_skip; // How many frames to skip in motion detection
double analysis_fps; // Target framerate for video analysis double analysis_fps; // Target framerate for video analysis
unsigned int analysis_update_delay; // How long we wait before updating analysis parameters unsigned int analysis_update_delay; // How long we wait before updating analysis parameters
int capture_delay; // How long we wait between capture frames int capture_delay; // How long we wait between capture frames
int alarm_capture_delay; // How long we wait between capture frames when in alarm state int alarm_capture_delay; // How long we wait between capture frames when in alarm state
int alarm_frame_count; // How many alarm frames are required before an event is triggered int alarm_frame_count; // How many alarm frames are required before an event is triggered
int fps_report_interval; // How many images should be captured/processed between reporting the current FPS int fps_report_interval; // How many images should be captured/processed between reporting the current FPS
int ref_blend_perc; // Percentage of new image going into reference image. int ref_blend_perc; // Percentage of new image going into reference image.
int alarm_ref_blend_perc; // Percentage of new image going into reference image during alarm. int alarm_ref_blend_perc; // Percentage of new image going into reference image during alarm.
bool track_motion; // Whether this monitor tries to track detected motion bool track_motion; // Whether this monitor tries to track detected motion
int signal_check_points; // Number of points in the image to check for signal int signal_check_points; // Number of points in the image to check for signal
Rgb signal_check_colour; // The colour that the camera will emit when no video signal detected Rgb signal_check_colour; // The colour that the camera will emit when no video signal detected
bool embed_exif; // Whether to embed Exif data into each image frame or not bool embed_exif; // Whether to embed Exif data into each image frame or not
bool last_signal;
double fps; double fps;
unsigned int last_camera_bytes; unsigned int last_camera_bytes;

View File

@ -83,7 +83,7 @@ int main( int argc, char *argv[] ) {
while (1) { while (1) {
int option_index = 0; int option_index = 0;
int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index); int c = getopt_long(argc, argv, "m:h:v", long_options, &option_index);
if ( c == -1 ) { if ( c == -1 ) {
break; break;
} }
@ -144,7 +144,7 @@ int main( int argc, char *argv[] ) {
unsigned int analysis_update_delay = monitor->GetAnalysisUpdateDelay(); unsigned int analysis_update_delay = monitor->GetAnalysisUpdateDelay();
time_t last_analysis_update_time, cur_time; time_t last_analysis_update_time, cur_time;
monitor->UpdateAdaptiveSkip(); monitor->UpdateAdaptiveSkip();
last_analysis_update_time = time( 0 ); last_analysis_update_time = time(0);
while( (!zm_terminate) && monitor->ShmValid() ) { while( (!zm_terminate) && monitor->ShmValid() ) {
// Process the next image // Process the next image
@ -181,5 +181,5 @@ int main( int argc, char *argv[] ) {
Image::Deinitialise(); Image::Deinitialise();
logTerm(); logTerm();
zmDbClose(); zmDbClose();
return( 0 ); return 0;
} }

View File

@ -300,19 +300,22 @@ int main(int argc, char *argv[]) {
if ( next_delays[i] <= min_delay || next_delays[i] <= 0 ) { if ( next_delays[i] <= min_delay || next_delays[i] <= 0 ) {
if ( monitors[i]->PreCapture() < 0 ) { if ( monitors[i]->PreCapture() < 0 ) {
Error("Failed to pre-capture monitor %d %d (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors); Error("Failed to pre-capture monitor %d %d (%d/%d)",
monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors);
monitors[i]->Close(); monitors[i]->Close();
result = -1; result = -1;
break; break;
} }
if ( monitors[i]->Capture() < 0 ) { if ( monitors[i]->Capture() < 0 ) {
Error("Failed to capture image from monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors); Info("Failed to capture image from monitor %d %s (%d/%d)",
monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors);
monitors[i]->Close(); monitors[i]->Close();
result = -1; result = -1;
break; break;
} }
if ( monitors[i]->PostCapture() < 0 ) { if ( monitors[i]->PostCapture() < 0 ) {
Error("Failed to post-capture monitor %d %s (%d/%d)", monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors); Error("Failed to post-capture monitor %d %s (%d/%d)",
monitors[i]->Id(), monitors[i]->Name(), i+1, n_monitors);
monitors[i]->Close(); monitors[i]->Close();
result = -1; result = -1;
break; break;

View File

@ -93,7 +93,8 @@ if [ "$RELEASE" != "" ]; then
else else
GITHUB_FORK="ZoneMinder"; GITHUB_FORK="ZoneMinder";
fi fi
BRANCH="release-$RELEASE" # We use a tag instead of a branch atm.
BRANCH=$RELEASE
else else
if [ "$GITHUB_FORK" == "" ]; then if [ "$GITHUB_FORK" == "" ]; then
echo "Defaulting to ZoneMinder upstream git" echo "Defaulting to ZoneMinder upstream git"
@ -188,6 +189,12 @@ if [ "$URGENCY" = "" ]; then
URGENCY="medium" URGENCY="medium"
fi; fi;
rm -rf .git
rm .gitignore
cd ../
tar zcf $DIRECTORY.orig.tar.gz $DIRECTORY.orig
cd $DIRECTORY.orig
if [ "$SNAPSHOT" == "stable" ]; then if [ "$SNAPSHOT" == "stable" ]; then
cat <<EOF > debian/changelog cat <<EOF > debian/changelog
zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
@ -221,12 +228,6 @@ zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY
EOF EOF
fi; fi;
rm -rf .git
rm .gitignore
cd ../
tar zcf $DIRECTORY.orig.tar.gz $DIRECTORY.orig
cd $DIRECTORY.orig
if [ $TYPE == "binary" ]; then if [ $TYPE == "binary" ]; then
# Auto-install all ZoneMinder's depedencies using the Debian control file # Auto-install all ZoneMinder's depedencies using the Debian control file
sudo apt-get install devscripts equivs sudo apt-get install devscripts equivs
@ -287,7 +288,8 @@ else
SC="zoneminder_${VERSION}-${DISTRO}${PACKAGE_VERSION}_source.changes"; SC="zoneminder_${VERSION}-${DISTRO}${PACKAGE_VERSION}_source.changes";
PPA=""; PPA="";
if [ "$RELEASE" != "" ]; then if [ "$RELEASE" != "" ]; then
PPA="ppa:iconnor/zoneminder"; IFS='.' read -r -a VERSION <<< "$RELEASE"
PPA="ppa:iconnor/zoneminder-${VERSION[0]}.${VERSION[1]}"
else else
if [ "$BRANCH" == "" ]; then if [ "$BRANCH" == "" ]; then
PPA="ppa:iconnor/zoneminder-master"; PPA="ppa:iconnor/zoneminder-master";