From ab1c9f7c9814ed52446ddf765147a1900eff3097 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 31 Oct 2017 16:27:43 -0400 Subject: [PATCH 1/8] add more debugging --- src/zm_monitorstream.cpp | 3 +++ src/zm_stream.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 85b223f6a..ac99aefdb 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -693,6 +693,8 @@ Debug(2, "checking command Queue"); } // end if buffered playback frame_count++; } + unsigned long sleep_time = (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))); + Debug(2,"Sleep for (%d) microseconds"); usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) ); if ( ttl ) { if ( (now.tv_sec - stream_start_time) > ttl ) { @@ -704,6 +706,7 @@ Debug(2, "checking command Queue"); break; } } // end while + if ( buffered_playback ) { Debug( 1, "Cleaning swap files from %s", swap_path ); struct stat stat_buf; diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 8002c4f18..cee3ffa25 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -88,6 +88,7 @@ bool StreamBase::checkCommandQueue() { //Error( "Partial message received, expected %d bytes, got %d", sizeof(msg), nbytes ); //} else { +Debug(2, "Message length is (%d)", nbytes ); processCommand( &msg ); return( true ); } From 97be2bf0a3ce02b58270fa601871113c51bbeb23 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 15 Nov 2017 13:01:07 -0500 Subject: [PATCH 2/8] fix events js vars, eliminating doing the sql query twice --- web/skins/classic/views/events.php | 38 +++++++++++++----------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/web/skins/classic/views/events.php b/web/skins/classic/views/events.php index 9fda0536a..54cf1542b 100644 --- a/web/skins/classic/views/events.php +++ b/web/skins/classic/views/events.php @@ -84,28 +84,10 @@ if ( !empty($page) ) { $eventsSql .= ' limit 0, '.$limit; } -if ( 0 ) { $maxWidth = 0; $maxHeight = 0; $archived = false; $unarchived = false; -$events = array(); -foreach ( dbFetchAll( $eventsSql ) as $event_row ) { - $events[] = $event = new Event( $event_row ); - -# Doesn this code do anything? - $scale = max( reScale( SCALE_BASE, $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ), SCALE_BASE ); - $eventWidth = reScale( $event_row['Width'], $scale ); - $eventHeight = reScale( $event_row['Height'], $scale ); - if ( $maxWidth < $eventWidth ) $maxWidth = $eventWidth; - if ( $maxHeight < $eventHeight ) $maxHeight = $eventHeight; - if ( $event_row['Archived'] ) - $archived = true; - else - $unarchived = true; -} -} - $maxShortcuts = 5; $pagination = getPagination( $pages, $page, $maxShortcuts, $filterQuery.$sortQuery.'&limit='.$limit ); @@ -165,9 +147,16 @@ $disk_space_total = 0; $results = dbQuery( $eventsSql ); while ( $event_row = dbFetchNext( $results ) ) { $event = new Event( $event_row ); -#foreach ( dbFetchAll( $eventsSql ) as $event_row ) { - #$events[] = $event = new Event( $event_row ); -#foreach ( $events as $event ) { + $scale = max( reScale( SCALE_BASE, $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE ), SCALE_BASE ); + $eventWidth = reScale( $event_row['Width'], $scale ); + $eventHeight = reScale( $event_row['Height'], $scale ); + if ( $maxWidth < $eventWidth ) $maxWidth = $eventWidth; + if ( $maxHeight < $eventHeight ) $maxHeight = $eventHeight; + if ( $event_row['Archived'] ) + $archived = true; + else + $unarchived = true; + if ( ($count++%ZM_WEB_EVENTS_PER_PAGE) == 0 ) { ?> @@ -300,5 +289,12 @@ if ( true || canEdit( 'Events' ) ) { + From 087a9026982bb09ca8ed39f3d424bea3cf1299b4 Mon Sep 17 00:00:00 2001 From: Daniel Hodgson Date: Wed, 15 Nov 2017 17:44:59 -0800 Subject: [PATCH 3/8] Update zm_create.sql.in The `CaptureFPS` column is missing in the db creation script, causing errors in the Log whenever a monitor is queried. --- db/zm_create.sql.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index a4802ef98..51937678d 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -428,9 +428,10 @@ CREATE TABLE `Monitors` ( `WebColour` varchar(32) NOT NULL default 'red', `Exif` tinyint(1) unsigned NOT NULL default '0', `Sequence` smallint(5) unsigned default NULL, -`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown', -`zmcFPS` DECIMAL(5,2) NOT NULL default 0, -`zmaFPS` DECIMAL(5,2) NOT NULL default 0, + `Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown', + `CaptureFPS` DECIMAL(10,2) NOT NULL default 0, + `zmcFPS` DECIMAL(5,2) NOT NULL default 0, + `zmaFPS` DECIMAL(5,2) NOT NULL default 0, PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; From bfd28dda71a6b0c9a841b4548ada17606ea2f670 Mon Sep 17 00:00:00 2001 From: Daniel Hodgson Date: Wed, 15 Nov 2017 17:59:07 -0800 Subject: [PATCH 4/8] Update zm_create.sql.in Added missing column `AnalysisFPS` --- db/zm_create.sql.in | 1 + 1 file changed, 1 insertion(+) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 51937678d..b78c6ba8a 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -430,6 +430,7 @@ CREATE TABLE `Monitors` ( `Sequence` smallint(5) unsigned default NULL, `Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown', `CaptureFPS` DECIMAL(10,2) NOT NULL default 0, + `AnalysisFPS` DECIMAL(5,2) NOT NULL default 0, `zmcFPS` DECIMAL(5,2) NOT NULL default 0, `zmaFPS` DECIMAL(5,2) NOT NULL default 0, PRIMARY KEY (`Id`) From d411ed329bb0b9c3c3d3a104223ac9a948c8e691 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Nov 2017 09:14:26 -0500 Subject: [PATCH 5/8] get rid of mistyped zmaFPS and zmcFPS --- db/zm_create.sql.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index b78c6ba8a..1ca81553f 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -431,8 +431,6 @@ CREATE TABLE `Monitors` ( `Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown', `CaptureFPS` DECIMAL(10,2) NOT NULL default 0, `AnalysisFPS` DECIMAL(5,2) NOT NULL default 0, - `zmcFPS` DECIMAL(5,2) NOT NULL default 0, - `zmaFPS` DECIMAL(5,2) NOT NULL default 0, PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; From a956ffe7b3832fe6223e5457806a3ec00fedc821 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Nov 2017 09:15:04 -0500 Subject: [PATCH 6/8] add Copy and =operators to satisfy cppcheck --- src/zm_box.h | 2 +- src/zm_config.cpp | 12 ++++++++++++ src/zm_coord.h | 15 +++++++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/zm_box.h b/src/zm_box.h index 3432bacc5..fa377e593 100644 --- a/src/zm_box.h +++ b/src/zm_box.h @@ -43,7 +43,7 @@ public: inline Box() { } - inline Box( int p_size ) : lo( 0, 0 ), hi ( p_size-1, p_size-1 ), size( Coord::Range( hi, lo ) ) { } + explicit inline Box( int p_size ) : lo( 0, 0 ), hi ( p_size-1, p_size-1 ), size( Coord::Range( hi, lo ) ) { } inline Box( int p_x_size, int p_y_size ) : lo( 0, 0 ), hi ( p_x_size-1, p_y_size-1 ), size( Coord::Range( hi, lo ) ) { } inline Box( int lo_x, int lo_y, int hi_x, int hi_y ) : lo( lo_x, lo_y ), hi( hi_x, hi_y ), size( Coord::Range( hi, lo ) ) { } inline Box( const Coord &p_lo, const Coord &p_hi ) : lo( p_lo ), hi( p_hi ), size( Coord::Range( hi, lo ) ) { } diff --git a/src/zm_config.cpp b/src/zm_config.cpp index 4025b4f43..65a3f6591 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -215,6 +215,7 @@ ConfigItem::ConfigItem( const char *p_name, const char *p_value, const char *con accessed = false; } + ConfigItem::ConfigItem( const ConfigItem &item ) { name = new char[strlen(item.name)+1]; strcpy( name, item.name ); @@ -227,6 +228,17 @@ ConfigItem::ConfigItem( const ConfigItem &item ) { accessed = false; } +void ConfigItem::Copy( const ConfigItem &item ) { + name = new char[strlen(item.name)+1]; + strcpy( name, item.name ); + value = new char[strlen(item.value)+1]; + strcpy( value, item.value ); + type = new char[strlen(item.type)+1]; + strcpy( type, item.type ); + + //Info( "Created new config item %s = %s (%s)\n", name, value, type ); + accessed = false; +} ConfigItem::~ConfigItem() { delete[] name; diff --git a/src/zm_coord.h b/src/zm_coord.h index 5858cef23..9bf31144c 100644 --- a/src/zm_coord.h +++ b/src/zm_coord.h @@ -31,14 +31,13 @@ private: int x, y; public: - inline Coord() : x(0), y(0) - { - } - inline Coord( int p_x, int p_y ) : x(p_x), y(p_y) - { - } - inline Coord( const Coord &p_coord ) : x(p_coord.x), y(p_coord.y) - { + inline Coord() : x(0), y(0) { } + inline Coord( int p_x, int p_y ) : x(p_x), y(p_y) { } + inline Coord( const Coord &p_coord ) : x(p_coord.x), y(p_coord.y) { } + inline Coord &operator =( const Coord &coord ) { + x = coord.x; + y = coord.y; + return *this; } inline int &X() { return( x ); } inline const int &X() const { return( x ); } From 168658490899db404664b86f12cc03c57be6bac7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Nov 2017 09:19:27 -0500 Subject: [PATCH 7/8] more cppcheck fixes --- src/zm_buffer.h | 2 +- web/skins/classic/css/classic/skin.css | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/zm_buffer.h b/src/zm_buffer.h index 31898eb95..8f47c7cbc 100644 --- a/src/zm_buffer.h +++ b/src/zm_buffer.h @@ -36,7 +36,7 @@ protected: public: Buffer() : mStorage( 0 ), mAllocation( 0 ), mSize( 0 ), mHead( 0 ), mTail( 0 ) { } - Buffer( unsigned int pSize ) : mAllocation( pSize ), mSize( 0 ) { + explicit Buffer( unsigned int pSize ) : mAllocation( pSize ), mSize( 0 ) { mHead = mStorage = new unsigned char[mAllocation]; mTail = mHead; } diff --git a/web/skins/classic/css/classic/skin.css b/web/skins/classic/css/classic/skin.css index 743386622..1d5af9a16 100644 --- a/web/skins/classic/css/classic/skin.css +++ b/web/skins/classic/css/classic/skin.css @@ -63,10 +63,6 @@ p { font-weight: normal; } -th { - font-weight: bold; - color: #016A9d; -} a:link, a:visited { @@ -79,6 +75,11 @@ a:hover { text-decoration: underline; } +th, th a { + font-weight: bold; + color: #016A9d; +} + input,textarea,select,button { border: 1px #7f7fb2 solid; font-family: inherit; From 0318fb54a63f1c605316c339120843bb5d10afed Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 16 Nov 2017 18:23:02 -0500 Subject: [PATCH 8/8] add missing initializers --- src/zm_stream.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zm_stream.h b/src/zm_stream.h index dbe4c1db6..5623f8a0d 100644 --- a/src/zm_stream.h +++ b/src/zm_stream.h @@ -141,6 +141,8 @@ public: #if HAVE_LIBAVCODEC vid_stream = 0; #endif // HAVE_LIBAVCODEC + last_frame_sent = 0.0; + msg = { 0, { 0 } }; } virtual ~StreamBase();