Merge branch 'storageareas' of http://github.com/connortechnology/ZoneMinder into storageareas
commit
d07f36a7ee
|
@ -1,25 +0,0 @@
|
|||
snprintf( swap_path, sizeof(swap_path), "%s/zmswap-m%d/zmswap-q%06d", staticConfig.PATH_SWAP.c_str(), monitor->Id(), connkey );
|
||||
|
||||
int len = snprintf(NULL, 0, "/zmswap-m%d", monitor->Id());
|
||||
|
||||
|
||||
int swap_path_length = strlen(staticConfig.PATH_SWAP.c_str()) + snprintf(NULL, 0, "/zmswap-m%d", monitor->Id() ) + snprintf(NULL, 0, "/zmswap-q%06d", connkey ) + 1; // +1 for NULL terminator
|
||||
|
||||
if ( connkey && playback_buffer > 0 ) {
|
||||
|
||||
if ( swap_path_length + max_swap_len_suffix > PATH_MAX ) {
|
||||
Error( "Swap Path is too long. %d > %d ", swap_path_length+max_swap_len_suffix, PATH_MAX );
|
||||
} else {
|
||||
swap_path = (char *)malloc( swap_path_length+max_swap_len_suffix );
|
||||
Debug( 3, "Checking swap image path %s", staticConfig.PATH_SWAP.c_str() );
|
||||
strncpy( swap_path, staticConfig.PATH_SWAP.c_str(), swap_path_length );
|
||||
if ( checkSwapPath( swap_path, false ) ) {
|
||||
snprintf( &(swap_path[swap_path_length]), max_swap_len_suffix, "/zmswap-m%d", monitor->Id() );
|
||||
if ( checkSwapPath( swap_path, true ) ) {
|
||||
snprintf( &(swap_path[swap_path_length]), max_swap_len_suffix, "/zmswap-q%06d", connkey );
|
||||
if ( checkSwapPath( swap_path, true ) ) {
|
||||
buffered_playback = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -215,6 +215,18 @@ 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 );
|
||||
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;
|
||||
|
|
|
@ -107,7 +107,8 @@ private:
|
|||
mutable bool accessed;
|
||||
|
||||
public:
|
||||
ConfigItem( const char *p_name, const char *p_value, const char *const p_type );
|
||||
ConfigItem(const char *p_name, const char *p_value, const char *const p_type);
|
||||
ConfigItem(const ConfigItem &);
|
||||
~ConfigItem();
|
||||
void ConvertValue() const;
|
||||
bool BooleanValue() const;
|
||||
|
@ -116,16 +117,16 @@ public:
|
|||
const char *StringValue() const;
|
||||
|
||||
inline operator bool() const {
|
||||
return( BooleanValue() );
|
||||
return BooleanValue();
|
||||
}
|
||||
inline operator int() const {
|
||||
return( IntegerValue() );
|
||||
return IntegerValue();
|
||||
}
|
||||
inline operator double() const {
|
||||
return( DecimalValue() );
|
||||
return DecimalValue();
|
||||
}
|
||||
inline operator const char *() const {
|
||||
return( StringValue() );
|
||||
return StringValue();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -593,6 +593,7 @@ bool EventStream::sendFrame( int delta_us ) {
|
|||
FILE *fdj = NULL;
|
||||
|
||||
// This needs to be abstracted. If we are saving jpgs, then load the capture file. If we are only saving analysis frames, then send that.
|
||||
// // This is also wrong, need to have this info stored in the event! FIXME
|
||||
if ( monitor->GetOptSaveJPEGs() & 1 ) {
|
||||
snprintf( filepath, sizeof(filepath), staticConfig.capture_file_format, event_data->path, curr_frame_id );
|
||||
} else if ( monitor->GetOptSaveJPEGs() & 2 ) {
|
||||
|
|
|
@ -1534,34 +1534,28 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers
|
|||
return( false );
|
||||
}
|
||||
|
||||
if ( verbose )
|
||||
{
|
||||
if ( verbose ) {
|
||||
sprintf( output+strlen(output), " Input %d\n", input.index );
|
||||
sprintf( output+strlen(output), " Name: %s\n", input.name );
|
||||
sprintf( output+strlen(output), " Type: %s\n", input.type==V4L2_INPUT_TYPE_TUNER?"Tuner":(input.type==V4L2_INPUT_TYPE_CAMERA?"Camera":"Unknown") );
|
||||
sprintf( output+strlen(output), " Audioset: %08x\n", input.audioset );
|
||||
sprintf( output+strlen(output), " Standards: 0x%llx\n", input.std );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sprintf( output+strlen(output), "i%d:%s|", input.index, input.name );
|
||||
sprintf( output+strlen(output), "i%dT:%s|", input.index, input.type==V4L2_INPUT_TYPE_TUNER?"Tuner":(input.type==V4L2_INPUT_TYPE_CAMERA?"Camera":"Unknown") );
|
||||
sprintf( output+strlen(output), "i%dS:%llx|", input.index, input.std );
|
||||
}
|
||||
|
||||
if ( verbose )
|
||||
{
|
||||
if ( verbose ) {
|
||||
sprintf( output+strlen(output), " %s", capString( input.status&V4L2_IN_ST_NO_POWER, "Power ", "off", "on", " (X)" ) );
|
||||
sprintf( output+strlen(output), " %s", capString( input.status&V4L2_IN_ST_NO_SIGNAL, "Signal ", "not detected", "detected", " (X)" ) );
|
||||
sprintf( output+strlen(output), " %s", capString( input.status&V4L2_IN_ST_NO_COLOR, "Colour Signal ", "not detected", "detected", "" ) );
|
||||
sprintf( output+strlen(output), " %s", capString( input.status&V4L2_IN_ST_NO_H_LOCK, "Horizontal Lock ", "not detected", "detected", "" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( output+strlen(output), "i%dSP:%d|", input.index, input.status&V4L2_IN_ST_NO_POWER?0:1 );
|
||||
sprintf( output+strlen(output), "i%dSS:%d|", input.index, input.status&V4L2_IN_ST_NO_SIGNAL?0:1 );
|
||||
sprintf( output+strlen(output), "i%dSC:%d|", input.index, input.status&V4L2_IN_ST_NO_COLOR?0:1 );
|
||||
sprintf( output+strlen(output), "i%dHP:%d|", input.index, input.status&V4L2_IN_ST_NO_H_LOCK?0:1 );
|
||||
} else {
|
||||
sprintf( output+strlen(output), "i%dSP:%d|", input.index, (input.status&V4L2_IN_ST_NO_POWER)?0:1 );
|
||||
sprintf( output+strlen(output), "i%dSS:%d|", input.index, (input.status&V4L2_IN_ST_NO_SIGNAL)?0:1 );
|
||||
sprintf( output+strlen(output), "i%dSC:%d|", input.index, (input.status&V4L2_IN_ST_NO_COLOR)?0:1 );
|
||||
sprintf( output+strlen(output), "i%dHP:%d|", input.index, (input.status&V4L2_IN_ST_NO_H_LOCK)?0:1 );
|
||||
}
|
||||
}
|
||||
while ( inputIndex++ >= 0 );
|
||||
|
@ -1570,12 +1564,10 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers
|
|||
}
|
||||
#endif // ZM_HAS_V4L2
|
||||
#if ZM_HAS_V4L1
|
||||
if ( version == 1 )
|
||||
{
|
||||
if ( version == 1 ) {
|
||||
struct video_capability vid_cap;
|
||||
memset( &vid_cap, 0, sizeof(video_capability) );
|
||||
if ( ioctl( vid_fd, VIDIOCGCAP, &vid_cap ) < 0 )
|
||||
{
|
||||
if ( ioctl( vid_fd, VIDIOCGCAP, &vid_cap ) < 0 ) {
|
||||
Error( "Failed to get video capabilities: %s", strerror(errno) );
|
||||
if ( verbose )
|
||||
sprintf( output, "Error, failed to get video capabilities %s: %s\n", queryDevice, strerror(errno) );
|
||||
|
@ -1583,8 +1575,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers
|
|||
sprintf( output, "error%d\n", errno );
|
||||
return( false );
|
||||
}
|
||||
if ( verbose )
|
||||
{
|
||||
if ( verbose ) {
|
||||
sprintf( output+strlen(output), "Video Capabilities\n" );
|
||||
sprintf( output+strlen(output), " Name: %s\n", vid_cap.name );
|
||||
sprintf( output+strlen(output), " Type: %d\n%s%s%s%s%s%s%s%s%s%s%s%s%s%s", vid_cap.type,
|
||||
|
@ -2047,9 +2038,8 @@ int LocalCamera::PreCapture() {
|
|||
int LocalCamera::Capture( Image &image ) {
|
||||
Debug( 3, "Capturing" );
|
||||
static uint8_t* buffer = NULL;
|
||||
static uint8_t* directbuffer = NULL;
|
||||
static int capture_frame = -1;
|
||||
int buffer_bytesused = 0;
|
||||
int capture_frame = -1;
|
||||
|
||||
int captures_per_frame = 1;
|
||||
if ( channel_count > 1 )
|
||||
|
@ -2059,7 +2049,6 @@ int LocalCamera::Capture( Image &image ) {
|
|||
Warning( "Invalid Captures Per Frame setting: %d", captures_per_frame );
|
||||
}
|
||||
|
||||
|
||||
// Do the capture, unless we are the second or subsequent camera on a channel, in which case just reuse the buffer
|
||||
if ( channel_prime ) {
|
||||
#if ZM_HAS_V4L2
|
||||
|
@ -2135,7 +2124,7 @@ int LocalCamera::Capture( Image &image ) {
|
|||
Debug( 3, "Performing format conversion" );
|
||||
|
||||
/* Request a writeable buffer of the target image */
|
||||
directbuffer = image.WriteBuffer(width, height, colours, subpixelorder);
|
||||
uint8_t* directbuffer = image.WriteBuffer(width, height, colours, subpixelorder);
|
||||
if ( directbuffer == NULL ) {
|
||||
Error("Failed requesting writeable buffer for the captured image.");
|
||||
return -1;
|
||||
|
@ -2153,7 +2142,13 @@ int LocalCamera::Capture( Image &image ) {
|
|||
avpicture_fill( (AVPicture *)tmpPicture, directbuffer,
|
||||
imagePixFormat, width, height );
|
||||
#endif
|
||||
sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize );
|
||||
sws_scale( imgConversionContext,
|
||||
capturePictures[capture_frame]->data,
|
||||
capturePictures[capture_frame]->linesize,
|
||||
0,
|
||||
height,
|
||||
tmpPicture->data,
|
||||
tmpPicture->linesize );
|
||||
}
|
||||
#endif
|
||||
if ( conversion_type == 2 ) {
|
||||
|
@ -2174,7 +2169,7 @@ int LocalCamera::Capture( Image &image ) {
|
|||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
} // end int LocalCamera::Capture()
|
||||
|
||||
int LocalCamera::PostCapture()
|
||||
{
|
||||
|
|
|
@ -55,9 +55,9 @@ class MonitorStream : public StreamBase {
|
|||
bool sendFrame( const char *filepath, struct timeval *timestamp );
|
||||
bool sendFrame( Image *image, struct timeval *timestamp );
|
||||
void processCommand( const CmdMsg *msg );
|
||||
void SingleImage( int scale=100 );
|
||||
void SingleImageRaw( int scale=100 );
|
||||
void SingleImageZip( int scale=100 );
|
||||
void SingleImage( int scale=100 );
|
||||
void SingleImageRaw( int scale=100 );
|
||||
void SingleImageZip( int scale=100 );
|
||||
|
||||
public:
|
||||
MonitorStream() : playback_buffer( 0 ), delayed( false ), frame_count( 0 ) {
|
||||
|
|
|
@ -90,12 +90,12 @@ bool User::canAccess( int monitor_id ) {
|
|||
User *zmLoadUser( const char *username, const char *password ) {
|
||||
char sql[ZM_SQL_SML_BUFSIZ] = "";
|
||||
char safer_username[65]; // current db username size is 32
|
||||
char safer_password[129]; // current db password size is 64
|
||||
|
||||
// According to docs, size of safer_whatever must be 2*length+1 due to unicode conversions + null terminator.
|
||||
mysql_real_escape_string(&dbconn, safer_username, username, strlen( username ) );
|
||||
|
||||
if ( password ) {
|
||||
char safer_password[129]; // current db password size is 64
|
||||
mysql_real_escape_string(&dbconn, safer_password, password, strlen( password ) );
|
||||
snprintf( sql, sizeof(sql), "select Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds from Users where Username = '%s' and Password = password('%s') and Enabled = 1", safer_username, safer_password );
|
||||
} else {
|
||||
|
|
|
@ -80,7 +80,7 @@ const std::string stringtf( const char *format, ... )
|
|||
return( tempString );
|
||||
}
|
||||
|
||||
const std::string stringtf( const std::string &format, ... )
|
||||
const std::string stringtf( const std::string format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
char tempBuffer[8192];
|
||||
|
@ -100,7 +100,7 @@ bool startsWith( const std::string &haystack, const std::string &needle )
|
|||
return( haystack.substr( 0, needle.length() ) == needle );
|
||||
}
|
||||
|
||||
StringVector split( const std::string &string, const std::string chars, int limit )
|
||||
StringVector split( const std::string &string, const std::string &chars, int limit )
|
||||
{
|
||||
StringVector stringVector;
|
||||
std::string tempString = string;
|
||||
|
@ -134,7 +134,7 @@ StringVector split( const std::string &string, const std::string chars, int limi
|
|||
return( stringVector );
|
||||
}
|
||||
|
||||
const std::string join(const StringVector v, const char * delim ) {
|
||||
const std::string join(const StringVector &v, const char * delim ) {
|
||||
std::stringstream ss;
|
||||
|
||||
for(size_t i = 0; i < v.size(); ++i) {
|
||||
|
|
|
@ -33,11 +33,11 @@ std::string trimSet(std::string str, std::string trimset);
|
|||
std::string replaceAll(std::string str, std::string from, std::string to);
|
||||
|
||||
const std::string stringtf( const char *format, ... );
|
||||
const std::string stringtf( const std::string &format, ... );
|
||||
const std::string stringtf( const std::string format, ... );
|
||||
|
||||
bool startsWith( const std::string &haystack, const std::string &needle );
|
||||
StringVector split( const std::string &string, const std::string chars, int limit=0 );
|
||||
const std::string join( const StringVector, const char * );
|
||||
StringVector split( const std::string &string, const std::string &chars, int limit=0 );
|
||||
const std::string join( const StringVector &, const char * );
|
||||
|
||||
const std::string base64Encode( const std::string &inString );
|
||||
|
||||
|
|
|
@ -204,7 +204,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) {
|
|||
int diff_width = diff_image->Width();
|
||||
uint8_t* diff_buff = (uint8_t*)diff_image->Buffer();
|
||||
uint8_t* pdiff;
|
||||
const uint8_t* ppoly;
|
||||
|
||||
unsigned int pixel_diff_count = 0;
|
||||
|
||||
|
@ -267,6 +266,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) {
|
|||
int bx1 = bx-1;
|
||||
int by1 = by-1;
|
||||
|
||||
|
||||
Debug( 5, "Checking for filtered pixels" );
|
||||
if ( bx > 1 || by > 1 ) {
|
||||
// Now remove any pixels smaller than our filter size
|
||||
|
@ -679,7 +679,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) {
|
|||
}
|
||||
}
|
||||
|
||||
ppoly = pg_image->Buffer( lo_x2, y );
|
||||
const uint8_t* ppoly = pg_image->Buffer( lo_x2, y );
|
||||
for ( int x = lo_x2; x <= hi_x2; x++, pdiff++, ppoly++ ) {
|
||||
if ( !*ppoly ) {
|
||||
*pdiff = BLACK;
|
||||
|
|
|
@ -161,7 +161,7 @@ int main(int argc, char *argv[]) {
|
|||
Usage();
|
||||
}
|
||||
|
||||
int modes = (device[0]?1:0 + host[0]?1:0 + file[0]?1:0 + (monitor_id > 0 ? 1 : 0));
|
||||
int modes = ( (device[0]?1:0) + (host[0]?1:0) + (file[0]?1:0) + (monitor_id > 0 ? 1 : 0));
|
||||
if ( modes > 1 ) {
|
||||
fprintf(stderr, "Only one of device, host/port/path, file or monitor id allowed\n");
|
||||
Usage();
|
||||
|
|
353
src/zmf.cpp
353
src/zmf.cpp
|
@ -1,353 +0,0 @@
|
|||
//
|
||||
// ZoneMinder Image File Writer Implementation, $Date$, $Revision$
|
||||
// Copyright (C) 2001-2008 Philip Coombes
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
/*
|
||||
|
||||
=head1 NAME
|
||||
|
||||
zmf - The ZoneMinder Frame daemon
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
zmf -m <monitor_id>
|
||||
zmf --monitor <monitor_id>
|
||||
zmf -h
|
||||
zmf --help
|
||||
zmf -v
|
||||
zmf --version
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is an optional daemon that can run in concert with the Analysis daemon and
|
||||
whose function it is to actually write captured frames to disk. This frees up
|
||||
the Analysis daemon to do more analysis (!) and so keep up with the Capture
|
||||
daemon better. If it isn't running or dies then the Analysis daemon just writes
|
||||
them itself.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
-m, --monitor_id - ID of the monitor to use
|
||||
-h, --help - Display usage information
|
||||
-v, --version - Print the installed version of ZoneMinder
|
||||
|
||||
=cut
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "zm.h"
|
||||
#include "zm_db.h"
|
||||
#include "zm_signal.h"
|
||||
#include "zm_monitor.h"
|
||||
|
||||
#include "zmf.h"
|
||||
|
||||
int OpenSocket( int monitor_id )
|
||||
{
|
||||
int sd = socket( AF_UNIX, SOCK_STREAM, 0);
|
||||
if ( sd < 0 )
|
||||
{
|
||||
Error( "Can't create socket: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
char sock_path[PATH_MAX] = "";
|
||||
snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.path_socks, monitor_id );
|
||||
if ( unlink( sock_path ) < 0 )
|
||||
{
|
||||
Warning( "Can't unlink '%s': %s", sock_path, strerror(errno) );
|
||||
}
|
||||
|
||||
struct sockaddr_un addr;
|
||||
|
||||
strncpy( addr.sun_path, sock_path, sizeof(addr.sun_path) );
|
||||
addr.sun_family = AF_UNIX;
|
||||
|
||||
if ( bind( sd, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0 )
|
||||
{
|
||||
Error( "Can't bind: %s", strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
if ( listen( sd, SOMAXCONN ) < 0 )
|
||||
{
|
||||
Error( "Can't listen: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
struct sockaddr_un rem_addr;
|
||||
socklen_t rem_addr_len = sizeof(rem_addr);
|
||||
int new_sd = -1;
|
||||
if ( (new_sd = accept( sd, (struct sockaddr *)&rem_addr, &rem_addr_len )) < 0 )
|
||||
{
|
||||
Error( "Can't accept: %s", strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
close( sd );
|
||||
|
||||
sd = new_sd;
|
||||
|
||||
Info( "Frame server socket open, awaiting images" );
|
||||
return( sd );
|
||||
}
|
||||
|
||||
int ReopenSocket( int &sd, int monitor_id )
|
||||
{
|
||||
close( sd );
|
||||
return( sd = OpenSocket( monitor_id ) );
|
||||
}
|
||||
|
||||
void Usage()
|
||||
{
|
||||
fprintf( stderr, "zmf -m <monitor_id>\n" );
|
||||
fprintf( stderr, "Options:\n" );
|
||||
fprintf( stderr, " -m, --monitor <monitor_id> : Specify which monitor to use\n" );
|
||||
fprintf( stderr, " -h, --help : This screen\n" );
|
||||
fprintf( stderr, " -v, --version : Report the installed version of ZoneMinder\n" );
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
self = argv[0];
|
||||
|
||||
srand( getpid() * time( 0 ) );
|
||||
|
||||
int id = -1;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"monitor", 1, 0, 'm'},
|
||||
{"help", 0, 0, 'h'},
|
||||
{"version", 0, 0, 'v'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
while (1)
|
||||
{
|
||||
int option_index = 0;
|
||||
|
||||
int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index);
|
||||
if (c == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'm':
|
||||
id = atoi(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
Usage();
|
||||
break;
|
||||
case 'v':
|
||||
std::cout << ZM_VERSION << "\n";
|
||||
exit(0);
|
||||
default:
|
||||
//fprintf( stderr, "?? getopt returned character code 0%o ??\n", c );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
fprintf( stderr, "Extraneous options, " );
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
Usage();
|
||||
}
|
||||
|
||||
if ( id < 0 )
|
||||
{
|
||||
fprintf( stderr, "Bogus monitor %d\n", id );
|
||||
Usage();
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
char log_id_string[16];
|
||||
snprintf( log_id_string, sizeof(log_id_string), "m%d", id );
|
||||
|
||||
zmLoadConfig();
|
||||
|
||||
logInit( "zmf" );
|
||||
|
||||
hwcaps_detect();
|
||||
|
||||
Monitor *monitor = Monitor::Load( id, false, Monitor::QUERY );
|
||||
|
||||
if ( !monitor )
|
||||
{
|
||||
fprintf( stderr, "Can't find monitor with id of %d\n", id );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
Storage *Storage = monitor->getStorage();
|
||||
|
||||
char capt_path[PATH_MAX];
|
||||
char anal_path[PATH_MAX];
|
||||
snprintf( capt_path, sizeof(capt_path), "%s/%d/%%s/%%0%dd-capture.jpg", Storage->Path(), monitor->Id(), config.event_image_digits );
|
||||
snprintf( anal_path, sizeof(anal_path), "%s/%d/%%s/%%0%dd-analyse.jpg", Storage->Path(), monitor->Id(), config.event_image_digits );
|
||||
zmSetDefaultTermHandler();
|
||||
zmSetDefaultDieHandler();
|
||||
|
||||
sigset_t block_set;
|
||||
sigemptyset( &block_set );
|
||||
|
||||
int sd = OpenSocket( monitor->Id() );
|
||||
|
||||
FrameHeader frame_header = { 0, 0, false, 0 };
|
||||
//unsigned char *image_data = 0;
|
||||
|
||||
fd_set rfds;
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
while( 1 )
|
||||
{
|
||||
struct timeval temp_timeout = timeout;
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(sd, &rfds);
|
||||
int n_found = select( sd+1, &rfds, NULL, NULL, &temp_timeout );
|
||||
if( n_found == 0 )
|
||||
{
|
||||
Debug( 1, "Select timed out" );
|
||||
continue;
|
||||
}
|
||||
else if ( n_found < 0)
|
||||
{
|
||||
Error( "Select error: %s", strerror(errno) );
|
||||
ReopenSocket( sd, monitor->Id() );
|
||||
continue;
|
||||
}
|
||||
|
||||
sigprocmask( SIG_BLOCK, &block_set, 0 );
|
||||
|
||||
int n_bytes = read( sd, &frame_header, sizeof(frame_header) );
|
||||
if ( n_bytes != sizeof(frame_header) )
|
||||
{
|
||||
if ( n_bytes < 0 )
|
||||
{
|
||||
Error( "Can't read frame header: %s", strerror(errno) );
|
||||
}
|
||||
else if ( n_bytes > 0 )
|
||||
{
|
||||
Error( "Incomplete read of frame header, %d bytes only", n_bytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "Socket closed at remote end" );
|
||||
}
|
||||
ReopenSocket( sd, monitor->Id() );
|
||||
continue;
|
||||
}
|
||||
Debug( 1, "Read frame header, expecting %ld bytes of image", frame_header.image_length );
|
||||
static unsigned char image_data[ZM_MAX_IMAGE_SIZE];
|
||||
|
||||
// Read for pipe and loop until bytes expected have been read or an error occurs
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
n_bytes = read( sd, image_data+bytes_read, frame_header.image_length-bytes_read );
|
||||
if (n_bytes < 0) break; // break on error
|
||||
if (n_bytes < (int)frame_header.image_length)
|
||||
{
|
||||
// print some informational messages
|
||||
if (bytes_read == 0)
|
||||
{
|
||||
Debug(4,"Image read : Short read %d bytes of %d expected bytes",n_bytes,frame_header.image_length);
|
||||
}
|
||||
else if (bytes_read+n_bytes == (int)frame_header.image_length)
|
||||
{
|
||||
Debug(5,"Image read : Read rest of short read: %d bytes read total of %d bytes",n_bytes,frame_header.image_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug(6,"Image read : continuing, read %d bytes (%d so far)", n_bytes, bytes_read+n_bytes);
|
||||
}
|
||||
}
|
||||
bytes_read+= n_bytes;
|
||||
} while (n_bytes>0 && (bytes_read < (ssize_t)frame_header.image_length) );
|
||||
|
||||
// Print errors if there was a problem
|
||||
if ( n_bytes < 1 )
|
||||
{
|
||||
|
||||
Error( "Only read %d bytes of %d\n", bytes_read, frame_header.image_length);
|
||||
if ( n_bytes < 0 )
|
||||
{
|
||||
Error( "Can't read frame image data: %s", strerror(errno) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "Socket closed at remote end" );
|
||||
}
|
||||
ReopenSocket( sd, monitor->Id() );
|
||||
continue;
|
||||
}
|
||||
|
||||
static char subpath[PATH_MAX] = "";
|
||||
if ( config.use_deep_storage )
|
||||
{
|
||||
struct tm *time = localtime( &frame_header.event_time );
|
||||
snprintf( subpath, sizeof(subpath), "%02d/%02d/%02d/%02d/%02d/%02d", time->tm_year-100, time->tm_mon+1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( subpath, sizeof(subpath), "%ld", frame_header.event_id );
|
||||
}
|
||||
|
||||
static char path[PATH_MAX] = "";
|
||||
snprintf( path, sizeof(path), frame_header.alarm_frame?anal_path:capt_path, subpath, frame_header.frame_id );
|
||||
Debug( 1, "Got image, writing to %s", path );
|
||||
|
||||
FILE *fd = 0;
|
||||
if ( (fd = fopen( path, "w" )) < 0 )
|
||||
{
|
||||
Error( "Can't fopen '%s': %s", path, strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
if ( 0 == fwrite( image_data, frame_header.image_length, 1, fd ) )
|
||||
{
|
||||
Error( "Can't fwrite image data: %s", strerror(errno) );
|
||||
exit( -1 );
|
||||
}
|
||||
fclose( fd );
|
||||
|
||||
sigprocmask( SIG_UNBLOCK, &block_set, 0 );
|
||||
}
|
||||
logTerm();
|
||||
zmDbClose();
|
||||
}
|
|
@ -37,6 +37,8 @@ if ( $$opts{protocol} eq 'https' ) {
|
|||
die "https requires a server_name";
|
||||
}
|
||||
$VirtualHostPorts = ' *:443';
|
||||
} else {
|
||||
$VirtualHostPorts = ' *:80';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ private $defaults = array(
|
|||
'Width' => null,
|
||||
'Height' => null,
|
||||
'Orientation' => null,
|
||||
'AnalysisFPSLimit' => null,
|
||||
);
|
||||
private $control_fields = array(
|
||||
'Name' => '',
|
||||
|
|
|
@ -68,11 +68,7 @@ th {
|
|||
color: #016A9d;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #7f7fb2;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:link,
|
||||
a:visited {
|
||||
color: #7f7fb2;
|
||||
text-decoration: none;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
var popupOptions = "resizable,scrollbars,status=no,toolbar=yes";
|
||||
|
||||
function checkSize() {
|
||||
if ( 0 ) {
|
||||
if (window.outerHeight) {
|
||||
var w = window.outerWidth;
|
||||
var prevW = w;
|
||||
|
@ -37,6 +38,7 @@ function checkSize() {
|
|||
if (w != prevW || h != prevH)
|
||||
window.resizeTo(w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
|
|
|
@ -84,6 +84,7 @@ if ( !empty($page) ) {
|
|||
$eventsSql .= ' limit 0, '.$limit;
|
||||
}
|
||||
|
||||
if ( 0 ) {
|
||||
$maxWidth = 0;
|
||||
$maxHeight = 0;
|
||||
$archived = false;
|
||||
|
@ -103,6 +104,7 @@ foreach ( dbFetchAll( $eventsSql ) as $event_row ) {
|
|||
else
|
||||
$unarchived = true;
|
||||
}
|
||||
}
|
||||
|
||||
$maxShortcuts = 5;
|
||||
$pagination = getPagination( $pages, $page, $maxShortcuts, $filterQuery.$sortQuery.'&limit='.$limit );
|
||||
|
@ -160,7 +162,12 @@ if ( $pagination ) {
|
|||
$count = 0;
|
||||
$disk_space_total = 0;
|
||||
|
||||
foreach ( $events as $event ) {
|
||||
$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 ) {
|
||||
if ( ($count++%ZM_WEB_EVENTS_PER_PAGE) == 0 ) {
|
||||
?>
|
||||
<tr>
|
||||
|
|
|
@ -91,8 +91,11 @@ function Monitor( monitorData ) {
|
|||
console.error( respObj.message );
|
||||
// Try to reload the image stream.
|
||||
if ( stream ) {
|
||||
if ( stream.src ) {
|
||||
console.log('Reloading stream: ' + stream.src );
|
||||
stream.src = stream.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
console.log( 'No stream to reload?' );
|
||||
}
|
||||
|
@ -118,6 +121,9 @@ function Monitor( monitorData ) {
|
|||
this.onFailure = function( xhr ) {
|
||||
console.log('onFailure: ' );
|
||||
console.log(xhr );
|
||||
// Requeue
|
||||
var streamCmdTimeout = statusRefreshTimeout;
|
||||
this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this );
|
||||
};
|
||||
|
||||
this.streamCmdReq = new Request.JSON( {
|
||||
|
@ -246,6 +252,7 @@ function changeSize() {
|
|||
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } );
|
||||
Cookie.write( 'zmMontageWidth', width, { duration: 10*365 } );
|
||||
Cookie.write( 'zmMontageHeight', height, { duration: 10*365 } );
|
||||
selectLayout('#zmMontageLayout');
|
||||
} // end function changeSize()
|
||||
|
||||
function changeScale() {
|
||||
|
|
Loading…
Reference in New Issue