Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas
This commit is contained in:
commit
28921a653b
|
@ -528,6 +528,7 @@ CREATE TABLE `Monitor_Status` (
|
|||
`Status` enum('Unknown','NotRunning','Running','Connected','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
`CaptureBandwidth` INT NOT NULL default 0,
|
||||
PRIMARY KEY (`MonitorId`)
|
||||
) ENGINE=MEMORY;
|
||||
--
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
DROP TABLE IF EXISTS `Monitor_Status`;
|
||||
CREATE TABLE `Monitor_Status` (
|
||||
`MonitorId` int(10) unsigned NOT NULL,
|
||||
`Status` enum('Unknown','NotRunning','Running','Connected','Signal') NOT NULL default 'Unknown',
|
||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||
PRIMARY KEY (`MonitorId`)
|
||||
) ENGINE=MEMORY;
|
||||
|
||||
SET SESSION sql_mode='NO_AUTO_VALUE_ON_ZERO';
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM Storage WHERE Name = 'Default' AND Id=0 AND Path='/var/cache/zoneminder/events'
|
||||
) > 0,
|
||||
"SELECT 'Default Storage Area already exists.'",
|
||||
"INSERT INTO Storage (Id,Name,Path,Scheme,ServerId) VALUES (0,'Default','/var/cache/zoneminder/events','Medium',NULL)"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Monitor_Status'
|
||||
AND column_name = 'CaptureBandwidth'
|
||||
) > 0,
|
||||
"SELECT 'Column CaptureBandwidth already exists in Monitor_Status'",
|
||||
"ALTER TABLE `Monitor_Status` ADD `CaptureBandwidth` INT NOT NULL default 0 AFTER `AnalysisFPS`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -53,6 +53,8 @@ protected:
|
|||
int contrast;
|
||||
bool capture;
|
||||
bool record_audio;
|
||||
unsigned int bytes;
|
||||
|
||||
|
||||
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 );
|
||||
|
@ -74,6 +76,7 @@ public:
|
|||
unsigned int SubpixelOrder() const { return( subpixelorder ); }
|
||||
unsigned int Pixels() const { return( pixels ); }
|
||||
unsigned int ImageSize() const { return( imagesize ); }
|
||||
unsigned int Bytes() const { return bytes; };
|
||||
|
||||
virtual int Brightness( int/*p_brightness*/=-1 ) { return( -1 ); }
|
||||
virtual int Hue( int/*p_hue*/=-1 ) { return( -1 ); }
|
||||
|
|
|
@ -292,6 +292,7 @@ int FfmpegCamera::Capture( Image &image ) {
|
|||
} else {
|
||||
Debug( 4, "Different stream_index %d", packet.stream_index );
|
||||
} // end if packet.stream_index == mVideoStreamId
|
||||
bytes += packet.size;
|
||||
zm_av_packet_unref( &packet );
|
||||
} // end while ! frameComplete
|
||||
return 1;
|
||||
|
@ -708,6 +709,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
|
|||
}
|
||||
|
||||
int keyframe = packet.flags & AV_PKT_FLAG_KEY;
|
||||
bytes += packet.size;
|
||||
dumpPacket(&packet);
|
||||
|
||||
//Video recording
|
||||
|
|
|
@ -380,6 +380,7 @@ Monitor::Monitor(
|
|||
ParseEncoderParameters(encoderparams.c_str(), &encoderparamsvec);
|
||||
|
||||
fps = 0.0;
|
||||
last_camera_bytes = 0;
|
||||
event_count = 0;
|
||||
image_count = 0;
|
||||
ready_count = warmup_count;
|
||||
|
@ -2457,15 +2458,21 @@ int Monitor::Capture() {
|
|||
if ( now != last_fps_time ) {
|
||||
// # of images per interval / the amount of time it took
|
||||
double new_fps = double(fps_report_interval)/(now-last_fps_time);
|
||||
unsigned int new_camera_bytes = camera->Bytes();
|
||||
unsigned int new_capture_bandwidth = (new_camera_bytes - last_camera_bytes)/(now-last_fps_time);
|
||||
last_camera_bytes = new_camera_bytes;
|
||||
//Info( "%d -> %d -> %d", fps_report_interval, now, last_fps_time );
|
||||
//Info( "%d -> %d -> %lf -> %lf", now-last_fps_time, fps_report_interval/(now-last_fps_time), double(fps_report_interval)/(now-last_fps_time), fps );
|
||||
Info("%s: images:%d - Capturing at %.2lf fps", name, image_count, new_fps);
|
||||
Info("%s: images:%d - Capturing at %.2lf fps, capturing bandwidth %ubytes/sec", name, image_count, new_fps, new_capture_bandwidth);
|
||||
last_fps_time = now;
|
||||
if ( new_fps != fps ) {
|
||||
fps = new_fps;
|
||||
|
||||
db_mutex.lock();
|
||||
static char sql[ZM_SQL_SML_BUFSIZ];
|
||||
snprintf(sql, sizeof(sql), "INSERT INTO Monitor_Status (MonitorId,CaptureFPS) VALUES (%d, %.2lf) ON DUPLICATE KEY UPDATE CaptureFPS = %.2lf", id, fps, fps);
|
||||
snprintf(sql, sizeof(sql),
|
||||
"INSERT INTO Monitor_Status (MonitorId,CaptureFPS,CaptureBandwidth) VALUES (%d, %.2lf,%u) ON DUPLICATE KEY UPDATE CaptureFPS = %.2lf, CaptureBandwidth=%u",
|
||||
id, fps, new_capture_bandwidth, fps, new_capture_bandwidth);
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't run query: %s", mysql_error(&dbconn));
|
||||
}
|
||||
|
|
|
@ -288,6 +288,8 @@ protected:
|
|||
bool embed_exif; // Whether to embed Exif data into each image frame or not
|
||||
|
||||
double fps;
|
||||
unsigned int last_camera_bytes;
|
||||
|
||||
Image delta_image;
|
||||
Image ref_image;
|
||||
Image alarm_image; // Used in creating analysis images, will be initialized in Analysis
|
||||
|
|
|
@ -24,6 +24,7 @@ private $defaults = array(
|
|||
private $status_fields = array(
|
||||
'AnalysisFPS' => null,
|
||||
'CaptureFPS' => null,
|
||||
'CaptureBandwidth' => null,
|
||||
);
|
||||
private $control_fields = array(
|
||||
'Name' => '',
|
||||
|
|
|
@ -152,7 +152,7 @@ $html .= htmlSelect( 'Status[]', $status_options,
|
|||
) );
|
||||
$html .= '</span>';
|
||||
|
||||
$sql = 'SELECT *,S.Status AS Status, S.CaptureFPS AS CaptureFPS, S.AnalysisFPS AS AnalysisFPS
|
||||
$sql = 'SELECT *,S.Status AS Status, S.CaptureFPS AS CaptureFPS, S.AnalysisFPS AS AnalysisFPS, S.CaptureBandwidth AS CaptureBandwidth
|
||||
FROM Monitors AS M LEFT JOIN Monitor_Status AS S ON MonitorId=Id ' .
|
||||
( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions) : '' ).' ORDER BY Sequence ASC';
|
||||
$monitors = dbFetchAll($sql, null, $values);
|
||||
|
|
|
@ -105,6 +105,7 @@ $show_storage_areas = count($storage_areas) > 1 and canEdit( 'System' ) ? 1 : 0;
|
|||
$maxWidth = 0;
|
||||
$maxHeight = 0;
|
||||
$zoneCount = 0;
|
||||
$total_capturing_bandwidth=0;
|
||||
|
||||
$status_counts = array();
|
||||
for ( $i = 0; $i < count($displayMonitors); $i++ ) {
|
||||
|
@ -176,6 +177,23 @@ xhtmlHeaders( __FILE__, translate('Console') );
|
|||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
<button type="button" name="addBtn" onclick="addMonitor(this);"
|
||||
<?php echo (canEdit('Monitors') && !$user['MonitorIds']) ? '' : ' disabled="disabled"' ?>
|
||||
>
|
||||
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> <?php echo translate('AddNewMonitor') ?>
|
||||
</button>
|
||||
<button type="button" name="cloneBtn" onclick="cloneMonitor(this);"
|
||||
<?php echo (canEdit('Monitors') && !$user['MonitorIds']) ? '' : ' disabled="disabled"' ?>
|
||||
style="display:none;">
|
||||
<span class="glyphicon glyphicon-copy"></span> <?php echo translate('CloneMonitor') ?>
|
||||
</button>
|
||||
<button type="button" name="editBtn" onclick="editMonitor(this);" disabled="disabled">
|
||||
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> <?php echo translate('Edit') ?>
|
||||
</button>
|
||||
<button type="button" name="deleteBtn" onclick="deleteMonitor(this);" disabled="disabled">
|
||||
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <?php echo translate('Delete') ?>
|
||||
</button>
|
||||
<button type="button" name="selectBtn" onclick="selectMonitor(this);" disabled="disabled"><?php echo translate('Select')?></button>
|
||||
<?php
|
||||
ob_start();
|
||||
?>
|
||||
|
@ -275,6 +293,8 @@ if ( $fclass != 'infoText' ) $dot_class=$fclass;
|
|||
$fps_string .= '/' . $monitor['AnalysisFPS'];
|
||||
}
|
||||
if ($fps_string) $fps_string .= ' fps';
|
||||
$fps_string .= ' ' . human_filesize($monitor['CaptureBandwidth']).'/s';
|
||||
$total_capturing_bandwidth += $monitor['CaptureBandwidth'];
|
||||
echo $fps_string;
|
||||
?>
|
||||
</div></td>
|
||||
|
@ -339,27 +359,19 @@ if ( $fclass != 'infoText' ) $dot_class=$fclass;
|
|||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php if ( ZM_WEB_ID_ON_CONSOLE ) { ?>
|
||||
<td class="colId"><?php echo translate('Total').":".count($displayMonitors) ?></td>
|
||||
<td class="colLeftButtons" colspan="<?php echo $left_columns -1?>">
|
||||
<button type="button" name="addBtn" onclick="addMonitor(this);"
|
||||
<?php echo (canEdit('Monitors') && !$user['MonitorIds']) ? '' : ' disabled="disabled"' ?>
|
||||
>
|
||||
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> <?php echo translate('AddNewMonitor') ?>
|
||||
</button>
|
||||
<button type="button" name="cloneBtn" onclick="cloneMonitor(this);"
|
||||
<?php echo (canEdit('Monitors') && !$user['MonitorIds']) ? '' : ' disabled="disabled"' ?>
|
||||
style="display:none;">
|
||||
<span class="glyphicon glyphicon-copy"></span> <?php echo translate('CloneMonitor') ?>
|
||||
</button>
|
||||
<button type="button" name="editBtn" onclick="editMonitor(this);" disabled="disabled">
|
||||
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> <?php echo translate('Edit') ?>
|
||||
</button>
|
||||
<button type="button" name="deleteBtn" onclick="deleteMonitor(this);" disabled="disabled">
|
||||
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <?php echo translate('Delete') ?>
|
||||
</button>
|
||||
<button type="button" name="selectBtn" onclick="selectMonitor(this);" disabled="disabled"><?php echo translate('Select')?></button>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td class="colName"></td>
|
||||
<td class="colFunction"><?php echo human_filesize($total_capturing_bandwidth ).'/s' ?></td>
|
||||
<?php if ( count($servers) ) { ?>
|
||||
<td class="colServer"></td>
|
||||
<?php } ?>
|
||||
<td class="colSource"></td>
|
||||
<?php if ( $show_storage_areas ) { ?>
|
||||
<td class="colStorage"></td>
|
||||
<?php
|
||||
}
|
||||
foreach ( array_keys( $eventCounts ) as $i ) {
|
||||
parseFilter( $eventCounts[$i]['filter'] );
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue