Merge branch 'master' into improve_filter

pull/1504/head
Isaac Connor 2016-11-04 15:20:43 -04:00
commit 1e233c0ce5
37 changed files with 6105 additions and 5977 deletions

View File

@ -96,22 +96,16 @@ A sample output on Ubuntu:
::
pp@camerapc:~$ df -h
pp@camerapc:~$ df -h|grep "Filesystem\|shm"
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 226G 96G 119G 45% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 1.8G 4.0K 1.8G 1% /dev
tmpfs 371M 816K 370M 1% /run
none 5.0M 0 5.0M 0% /run/lock
tmpfs 2.6G 923M 1.7G 36% /run/shm
none 100M 0 100M 0% /run/user
The key item here is tmpfs --> the example above shows we have allocated 1.7G of mapped memory space of which 36% is used which is a healthy number. If you are seeing this to go beyond 70% you should probaby increase mapped memory
The key item here is tmpfs --> the example above shows we have allocated 1.7G of mapped memory space of which 36% is used which is a healthy number. If you are seeing ``Use%`` going beyond 70% you should probaby increase the mapped memory.
If you want to increase this limit to 70% of your memory, add the following to ``/etc/fstab``
``tmpfs /run/shm tmpfs defaults,noexec,nosuid,size=70% 0 0``
For example, if you want to increase this limit to 70% of your memory, add the following to ``/etc/fstab``
``tmpfs SHMPATH tmpfs defaults,noexec,nosuid,size=70% 0 0``
where SHMPATH is the ``Mounted on`` path. Here, that would be ``/run/shm``. Other systems may be ``/dev/shm``.
What does a 'Can't shmget: Invalid argument' error in my logs mean? (and my camera does not display at higher resolutions)

View File

@ -56,7 +56,7 @@ Alarm Colour
These parameters can be used to individually colorize the zone overlay pattern. Alarms in this zone will be highlighted in the alarm colour. This option is irrelevant for Preclusive and Inactive zones and will be disabled.
Alarm Check Methods
There are 3 Alarm Check Methods. They are sequential, and are layered: In AlarmedPixels mode, only the AlarmedPixel analysis is performed. In FilteredPixels mode, the AlarmedPixel analysis is performed first, followed by the AlarmedPixel analysis. In the Blobs mode, all 3 analysis methods are performed in order. An alarm is only triggered if *all* of the enabled analysis modes are triggered. For performance reasons, as soon as the criteria for one of the analysis modes is not met, the alarm checking for the frame is complete. Since the subsequent modes each require progressively more computations, it is a good idea to tune the parameters in each of the activated layers.
There are 3 Alarm Check Methods. They are sequential, and are layered: In AlarmedPixels mode, only the AlarmedPixel analysis is performed. In FilteredPixels mode, the AlarmedPixel analysis is performed first, followed by the FilteredPixel analysis. In the Blobs mode, all 3 analysis methods are performed in order. An alarm is only triggered if *all* of the enabled analysis modes are triggered. For performance reasons, as soon as the criteria for one of the analysis modes is not met, the alarm checking for the frame is complete. Since the subsequent modes each require progressively more computations, it is a good idea to tune the parameters in each of the activated layers.
For reference purposes, the Zone Area box shows the area of the entire region of interest. In percent mode, this is 100. In Pixels mode, this is the pixel count of the region. All 3 Min/Max Area parameter groups are based on the Zone Area as the maximum sensible value, and all 3 are interpreted in the units specified in the Units input.

View File

@ -77,6 +77,8 @@ my %soap_version_of :ATTR(:default<('1.1')>);
sub service
{
my ($self, $serviceName, $attr) = @_;
#print "service: " . $services_of{${$self}}{$serviceName}{$attr} . "\n";
# Please note that the Std::Class::Fast docs say not to use ident.
$services_of{ident $self}{$serviceName}{$attr};
}
@ -113,27 +115,59 @@ sub set_soap_version
delete $serializer_of{ ident $self };
}
sub get_service_urls
{
sub get_service_urls {
my ($self) = @_;
my $result = $self->service('device', 'ep')->GetServices( {
IncludeCapability => 'true', # boolean
},,
);
die $result if not $result;
# print $result . "\n";
foreach my $svc ( @{ $result->get_Service() } ) {
my $short_name = $namespace_map{$svc->get_Namespace()};
my $url_svc = $svc->get_XAddr()->get_value();
if(defined $short_name && defined $url_svc) {
if ( $result ) {
foreach my $svc ( @{ $result->get_Service() } ) {
my $short_name = $namespace_map{$svc->get_Namespace()};
my $url_svc = $svc->get_XAddr()->get_value();
if(defined $short_name && defined $url_svc) {
# print "Got $short_name service\n";
$self->set_service($short_name, 'url', $url_svc);
$self->set_service($short_name, 'url', $url_svc);
}
}
# } else {
#print "No results from GetServices: $result\n";
}
}
# Some devices do not support getServices, so we have to try getCapabilities
$result = $self->service('device', 'ep')->GetCapabilities( {}, , );
if ( ! $result ) {
print "No results from GetCapabilities: $result\n";
return;
}
# Result is a GetCapabilitiesResponse
foreach my $capabilities ( @{ $result->get_Capabilities() } ) {
foreach my $capability ( 'PTZ', 'Media', 'Imaging', 'Events', 'Device' ) {
if ( my $function = $capabilities->can( "get_$capability" ) ) {
my $Services = $function->( $capabilities );
if ( ! $Services ) {
print "Nothing returned ffrom get_$capability\n";
} else {
foreach my $svc ( @{ $Services } ) {
# The capability versions don't have a namespace, so just lowercase them.
my $short_name = lc $capability;
my $url_svc = $svc->get_XAddr()->get_value();
if( defined $url_svc) {
# print "Got $short_name service\n";
$self->set_service($short_name, 'url', $url_svc);
}
} # end foreach svr
}
} else {
print "No $capability function\n";
} # end if has a get_ function
} # end foreach capability
} # end foreach capabilities
} # end sub get_service_urls
sub http_digest {
my ($service, $username, $password) = @_;

View File

@ -272,7 +272,11 @@ sub _initialize {
#
$_method =~s{\.}{__}xg;
$_method =~s{\-}{_}xg;
$list->[-1]->$_method( $current );
if ( $list->[-1]->can( $_method ) ) {
$list->[-1]->$_method( $current );
} else {
print ( "ERror " . $list->[-1] . " cannot $_method\n" );
}
$current = pop @$list; # step up in object hierarchy

View File

@ -15,6 +15,7 @@ __PACKAGE__->__set_ref();
use base qw(
SOAP::WSDL::XSD::Typelib::Element
WSDiscovery10::Types::ProbeType
WSDiscovery10::Types::ProbeMatchesType
);
}

View File

@ -1,4 +1,5 @@
#!/usr/bin/perl -w
use strict;
#
# ==========================================================================
#
@ -41,6 +42,7 @@ require WSDiscovery::TransportUDP;
# Globals
my $verbose = 0;
my $soap_version = undef;
my $client;
# =========================================================================
@ -171,61 +173,66 @@ sub discover
my %services;
my $uuid_gen = Data::UUID->new();
if ( ( ! $soap_version ) or ( $soap_version eq '1.1' ) ) {
if($verbose) {
print "Probing for SOAP 1.1\n"
}
my $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({
if($verbose) {
print "Probing for SOAP 1.1\n"
}
my $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({
# no_dispatch => '1',
});
$svc_discover->set_soap_version('1.1');
});
$svc_discover->set_soap_version('1.1');
my $uuid = $uuid_gen->create_str();
my $uuid = $uuid_gen->create_str();
my $result = $svc_discover->ProbeOp(
{ # WSDiscovery::Types::ProbeType
Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType
Scopes => { value => '' },
},
WSDiscovery10::Elements::Header->new({
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
MessageID => { value => "urn:uuid:$uuid" },
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
})
);
# print $result . "\n";
my $result = $svc_discover->ProbeOp(
{ # WSDiscovery::Types::ProbeType
Types => 'http://www.onvif.org/ver10/network/wsdl:NetworkVideoTransmitter http://www.onvif.org/ver10/device/wsdl:Device', # QNameListType
Scopes => { value => '' },
},
WSDiscovery10::Elements::Header->new({
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
MessageID => { value => "urn:uuid:$uuid" },
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
})
);
print $result . "\n" if $verbose;
interpret_messages($svc_discover, \%services, @responses);
@responses = ();
interpret_messages($svc_discover, \%services, @responses);
@responses = ();
} # end if doing soap 1.1
if($verbose) {
print "Probing for SOAP 1.2\n"
}
$svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({
if ( ( ! $soap_version ) or ( $soap_version eq '1.2' ) ) {
if($verbose) {
print "Probing for SOAP 1.2\n"
}
my $svc_discover = WSDiscovery10::Interfaces::WSDiscovery::WSDiscoveryPort->new({
# no_dispatch => '1',
});
$svc_discover->set_soap_version('1.2');
});
$svc_discover->set_soap_version('1.2');
# copies of the same Probe message must have the same MessageID.
# This is not a copy. So we generate a new uuid.
$uuid = $uuid_gen->create_str();
# copies of the same Probe message must have the same MessageID.
# This is not a copy. So we generate a new uuid.
my $uuid = $uuid_gen->create_str();
$result = $svc_discover->ProbeOp(
{ # WSDiscovery::Types::ProbeType
xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl',
'xmlns:tds' => 'http://www.onvif.org/ver10/device/wsdl', },
Types => 'dn:NetworkVideoTransmitter tds:Device', # QNameListType
Scopes => { value => '' },
},
WSDiscovery10::Elements::Header->new({
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
MessageID => { value => "urn:uuid:$uuid" },
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
})
);
# print $result . "\n";
# Everyone else, like the nodejs onvif code and odm only ask for NetworkVideoTransmitter
my $result = $svc_discover->ProbeOp(
{ # WSDiscovery::Types::ProbeType
xmlattr => { 'xmlns:dn' => 'http://www.onvif.org/ver10/network/wsdl', },
Types => 'dn:NetworkVideoTransmitter', # QNameListType
Scopes => { value => '' },
},
WSDiscovery10::Elements::Header->new({
Action => { value => 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe' },
MessageID => { value => "urn:uuid:$uuid" },
To => { value => 'urn:schemas-xmlsoap-org:ws:2005:04:discovery' },
})
);
print $result . "\n" if $verbose;
interpret_messages($svc_discover, \%services, @responses);
} # end if doing soap 1.2
interpret_messages($svc_discover, \%services, @responses);
}
@ -321,7 +328,7 @@ my $OPTIONS = "v";
sub HELP_MESSAGE
{
my ($fh, $pkg, $ver, $opts) = @_;
print $fh "Usage: " . __FILE__ . " [-v] probe \n";
print $fh "Usage: " . __FILE__ . " [-v] probe <soap version>\n";
print $fh " " . __FILE__ . " [-v] <command> <device URI> <soap version> <user> <password>\n";
print $fh <<EOF
Commands are:
@ -359,14 +366,15 @@ if(!defined $action) {
}
if($action eq "probe") {
$soap_version = shift;
discover();
}
else {
# all other actions need URI and credentials
my $url_svc_device = shift;
my $soap_version = shift;
my $username = shift;
my $password = shift;
my $url_svc_device = shift @ARGV;
$soap_version = shift @ARGV;
my $username = @ARGV ? shift @ARGV : '';
my $password = @ARGV ? shift @ARGV: '';
$client = ONVIF::Client->new( {
'url_svc_device' => $url_svc_device,

View File

@ -58,7 +58,7 @@ ZoneMinder::Base - Base perl module for ZoneMinder
=head1 SYNOPSIS
use ZoneMinder::Base;
use ZoneMinder::Base;
=head1 DESCRIPTION

View File

@ -46,14 +46,14 @@ our @EXPORT_CONFIG = qw( %Config ); # Get populated by BEGIN
our %EXPORT_TAGS = (
functions => [ qw(
zmConfigLoad
loadConfigFromDB
saveConfigToDB
) ],
zmConfigLoad
loadConfigFromDB
saveConfigToDB
) ],
constants => [ qw(
ZM_PID
) ]
);
ZM_PID
) ]
);
push( @{$EXPORT_TAGS{config}}, @EXPORT_CONFIG );
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
@ -71,69 +71,69 @@ use Carp;
# Load the config from the database into the symbol table
BEGIN
{
my $config_file = ZM_CONFIG;
open( my $CONFIG, "<", $config_file )
or croak( "Can't open config file '$config_file': $!" );
foreach my $str ( <$CONFIG> )
{
next if ( $str =~ /^\s*$/ );
next if ( $str =~ /^\s*#/ );
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*(.*?)\s*$/;
if ( ! $name ) {
print( STDERR "Warning, bad line in $config_file: $str\n" );
next;
} # end if
$name =~ tr/a-z/A-Z/;
$Config{$name} = $value;
}
close( $CONFIG );
my $config_file = ZM_CONFIG;
open( my $CONFIG, "<", $config_file )
or croak( "Can't open config file '$config_file': $!" );
foreach my $str ( <$CONFIG> )
{
next if ( $str =~ /^\s*$/ );
next if ( $str =~ /^\s*#/ );
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*(.*?)\s*$/;
if ( ! $name ) {
print( STDERR "Warning, bad line in $config_file: $str\n" );
next;
} # end if
$name =~ tr/a-z/A-Z/;
$Config{$name} = $value;
}
close( $CONFIG );
use DBI;
my $socket;
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
use DBI;
my $socket;
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($portOrSocket) )
if ( defined($portOrSocket) )
{
if ( $portOrSocket =~ /^\// )
{
if ( $portOrSocket =~ /^\// )
{
$socket = ";mysql_socket=".$portOrSocket;
}
else
{
$socket = ";host=".$host.";port=".$portOrSocket;
}
$socket = ";mysql_socket=".$portOrSocket;
}
else
{
$socket = ";host=".$Config{ZM_DB_HOST};
$socket = ";host=".$host.";port=".$portOrSocket;
}
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.$socket
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
) or croak( "Can't connect to db" );
my $sql = 'select * from Config';
my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or croak( "Can't execute: ".$sth->errstr() );
while( my $config = $sth->fetchrow_hashref() ) {
$Config{$config->{Name}} = $config->{Value};
}
else
{
$socket = ";host=".$Config{ZM_DB_HOST};
}
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.$socket
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
) or croak( "Can't connect to db" );
my $sql = 'select * from Config';
my $sth = $dbh->prepare_cached( $sql ) or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or croak( "Can't execute: ".$sth->errstr() );
while( my $config = $sth->fetchrow_hashref() ) {
$Config{$config->{Name}} = $config->{Value};
}
$sth->finish();
#$dbh->disconnect();
if ( ! exists $Config{ZM_SERVER_ID} ) {
$Config{ZM_SERVER_ID} = undef;
$sth = $dbh->prepare_cached( 'SELECT * FROM Servers WHERE Name=?' );
if ( $Config{ZM_SERVER_NAME} ) {
$res = $sth->execute( $Config{ZM_SERVER_NAME} );
my $result = $sth->fetchrow_hashref();
$Config{ZM_SERVER_ID} = $$result{Id};
} elsif ( $Config{ZM_SERVER_HOST} ) {
$res = $sth->execute( $Config{ZM_SERVER_HOST} );
my $result = $sth->fetchrow_hashref();
$Config{ZM_SERVER_ID} = $$result{Id};
}
$sth->finish();
#$dbh->disconnect();
if ( ! exists $Config{ZM_SERVER_ID} ) {
$Config{ZM_SERVER_ID} = undef;
$sth = $dbh->prepare_cached( 'SELECT * FROM Servers WHERE Name=?' );
if ( $Config{ZM_SERVER_NAME} ) {
$res = $sth->execute( $Config{ZM_SERVER_NAME} );
my $result = $sth->fetchrow_hashref();
$Config{ZM_SERVER_ID} = $$result{Id};
} elsif ( $Config{ZM_SERVER_HOST} ) {
$res = $sth->execute( $Config{ZM_SERVER_HOST} );
my $result = $sth->fetchrow_hashref();
$Config{ZM_SERVER_ID} = $$result{Id};
}
$sth->finish();
}
}
}
sub loadConfigFromDB {
@ -315,7 +315,7 @@ Copyright (C) 2001-2008 Philip Coombes
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.
at your option, any later version of Perl 5 you may have available.
=cut
=cut

File diff suppressed because it is too large Load Diff

View File

@ -45,17 +45,17 @@ our $AUTOLOAD;
sub new
{
my $class = shift;
my $id = shift;
my $self = {};
$self->{name} = "PelcoD";
if ( !defined($id) )
{
Fatal( "No monitor defined when invoking protocol ".$self->{name} );
}
$self->{id} = $id;
bless( $self, $class );
return $self;
my $class = shift;
my $id = shift;
my $self = {};
$self->{name} = "PelcoD";
if ( !defined($id) )
{
Fatal( "No monitor defined when invoking protocol ".$self->{name} );
}
$self->{id} = $id;
bless( $self, $class );
return $self;
}
sub DESTROY
@ -64,91 +64,91 @@ sub DESTROY
sub AUTOLOAD
{
my $self = shift;
my $class = ref($self) || croak( "$self not object" );
my $name = $AUTOLOAD;
$name =~ s/.*://;
if ( exists($self->{$name}) )
{
return( $self->{$name} );
}
croak( "Can't access $name member of object of class $class" );
my $self = shift;
my $class = ref($self) || croak( "$self not object" );
my $name = $AUTOLOAD;
$name =~ s/.*://;
if ( exists($self->{$name}) )
{
return( $self->{$name} );
}
croak( "Can't access $name member of object of class $class" );
}
sub getKey
{
my $self = shift;
return( $self->{id} );
my $self = shift;
return( $self->{id} );
}
sub open
{
my $self = shift;
Fatal( "No open method defined for protocol ".$self->{name} );
my $self = shift;
Fatal( "No open method defined for protocol ".$self->{name} );
}
sub close
{
my $self = shift;
Fatal( "No close method defined for protocol ".$self->{name} );
my $self = shift;
Fatal( "No close method defined for protocol ".$self->{name} );
}
sub loadMonitor
{
my $self = shift;
if ( !$self->{Monitor} )
my $self = shift;
if ( !$self->{Monitor} )
{
if ( !($self->{Monitor} = zmDbGetMonitor( $self->{id} )) )
{
if ( !($self->{Monitor} = zmDbGetMonitor( $self->{id} )) )
{
Fatal( "Monitor id ".$self->{id}." not found or not controllable" );
}
if ( defined($self->{Monitor}->{AutoStopTimeout}) )
{
# Convert to microseconds.
$self->{Monitor}->{AutoStopTimeout} = int(1000000*$self->{Monitor}->{AutoStopTimeout});
}
Fatal( "Monitor id ".$self->{id}." not found or not controllable" );
}
if ( defined($self->{Monitor}->{AutoStopTimeout}) )
{
# Convert to microseconds.
$self->{Monitor}->{AutoStopTimeout} = int(1000000*$self->{Monitor}->{AutoStopTimeout});
}
}
}
sub getParam
{
my $self = shift;
my $params = shift;
my $name = shift;
my $default = shift;
my $self = shift;
my $params = shift;
my $name = shift;
my $default = shift;
if ( defined($params->{$name}) )
{
return( $params->{$name} );
}
elsif ( defined($default) )
{
return( $default );
}
Fatal( "Missing mandatory parameter '$name'" );
if ( defined($params->{$name}) )
{
return( $params->{$name} );
}
elsif ( defined($default) )
{
return( $default );
}
Fatal( "Missing mandatory parameter '$name'" );
}
sub executeCommand
{
my $self = shift;
my $params = shift;
my $self = shift;
my $params = shift;
$self->loadMonitor();
$self->loadMonitor();
my $command = $params->{command};
delete $params->{command};
my $command = $params->{command};
delete $params->{command};
#if ( !defined($self->{$command}) )
#{
#Fatal( "Unsupported command '$command'" );
#}
&{$self->{$command}}( $self, $params );
#if ( !defined($self->{$command}) )
#{
#Fatal( "Unsupported command '$command'" );
#}
&{$self->{$command}}( $self, $params );
}
sub printMsg
{
my $self = shift;
Fatal( "No printMsg method defined for protocol ".$self->{name} );
my $self = shift;
Fatal( "No printMsg method defined for protocol ".$self->{name} );
}
1;
@ -161,8 +161,8 @@ ZoneMinder::Database - Perl extension for blah blah blah
=head1 SYNOPSIS
use ZoneMinder::Database;
blah blah blah
use ZoneMinder::Database;
blah blah blah
=head1 DESCRIPTION

View File

@ -42,13 +42,13 @@ our @ISA = qw(Exporter ZoneMinder::Base);
# will save memory.
our %EXPORT_TAGS = (
'functions' => [ qw(
zmDbConnect
zmDbDisconnect
zmDbGetMonitors
zmDbGetMonitor
zmDbGetMonitorAndControl
) ]
);
zmDbConnect
zmDbDisconnect
zmDbGetMonitors
zmDbGetMonitor
zmDbGetMonitorAndControl
) ]
);
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@ -72,48 +72,48 @@ our $dbh = undef;
sub zmDbConnect
{
my $force = shift;
if ( $force )
{
zmDbDisconnect();
}
if ( !defined( $dbh ) )
{
my $socket;
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $force = shift;
if ( $force )
{
zmDbDisconnect();
}
if ( !defined( $dbh ) )
{
my $socket;
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
if ( defined($portOrSocket) )
{
if ( $portOrSocket =~ /^\// )
{
$socket = ";mysql_socket=".$portOrSocket;
}
else
{
$socket = ";host=".$host.";port=".$portOrSocket;
}
}
else
{
$socket = ";host=".$Config{ZM_DB_HOST};
}
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.$socket
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
$dbh->trace( 0 );
if ( defined($portOrSocket) )
{
if ( $portOrSocket =~ /^\// )
{
$socket = ";mysql_socket=".$portOrSocket;
}
else
{
$socket = ";host=".$host.";port=".$portOrSocket;
}
}
return( $dbh );
else
{
$socket = ";host=".$Config{ZM_DB_HOST};
}
$dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}
.$socket
, $Config{ZM_DB_USER}
, $Config{ZM_DB_PASS}
);
$dbh->trace( 0 );
}
return( $dbh );
}
sub zmDbDisconnect
{
if ( defined( $dbh ) )
{
$dbh->disconnect();
$dbh = undef;
}
if ( defined( $dbh ) )
{
$dbh->disconnect();
$dbh = undef;
}
}
use constant DB_MON_ALL => 0; # All monitors
@ -125,86 +125,86 @@ use constant DB_MON_PASSIVE => 5; # All monitors that are in nodect state
sub zmDbGetMonitors
{
zmDbConnect();
zmDbConnect();
my $function = shift || DB_MON_ALL;
my $sql = "select * from Monitors";
my $function = shift || DB_MON_ALL;
my $sql = "select * from Monitors";
if ( $function )
if ( $function )
{
if ( $function == DB_MON_CAPT )
{
if ( $function == DB_MON_CAPT )
{
$sql .= " where Function >= 'Monitor'";
}
elsif ( $function == DB_MON_ACTIVE )
{
$sql .= " where Function > 'Monitor'";
}
elsif ( $function == DB_MON_MOTION )
{
$sql .= " where Function = 'Modect' or Function = 'Mocord'";
}
elsif ( $function == DB_MON_RECORD )
{
$sql .= " where Function = 'Record' or Function = 'Mocord'";
}
elsif ( $function == DB_MON_PASSIVE )
{
$sql .= " where Function = 'Nodect'";
}
$sql .= " where Function >= 'Monitor'";
}
my $sth = $dbh->prepare_cached( $sql )
or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute()
or croak( "Can't execute '$sql': ".$sth->errstr() );
my @monitors;
while( my $monitor = $sth->fetchrow_hashref() )
elsif ( $function == DB_MON_ACTIVE )
{
push( @monitors, $monitor );
$sql .= " where Function > 'Monitor'";
}
$sth->finish();
return( \@monitors );
elsif ( $function == DB_MON_MOTION )
{
$sql .= " where Function = 'Modect' or Function = 'Mocord'";
}
elsif ( $function == DB_MON_RECORD )
{
$sql .= " where Function = 'Record' or Function = 'Mocord'";
}
elsif ( $function == DB_MON_PASSIVE )
{
$sql .= " where Function = 'Nodect'";
}
}
my $sth = $dbh->prepare_cached( $sql )
or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute()
or croak( "Can't execute '$sql': ".$sth->errstr() );
my @monitors;
while( my $monitor = $sth->fetchrow_hashref() )
{
push( @monitors, $monitor );
}
$sth->finish();
return( \@monitors );
}
sub zmDbGetMonitor
{
zmDbConnect();
zmDbConnect();
my $id = shift;
my $id = shift;
return( undef ) if ( !defined($id) );
return( undef ) if ( !defined($id) );
my $sql = "select * from Monitors where Id = ?";
my $sth = $dbh->prepare_cached( $sql )
or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $id )
or croak( "Can't execute '$sql': ".$sth->errstr() );
my $monitor = $sth->fetchrow_hashref();
my $sql = "select * from Monitors where Id = ?";
my $sth = $dbh->prepare_cached( $sql )
or croak( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $id )
or croak( "Can't execute '$sql': ".$sth->errstr() );
my $monitor = $sth->fetchrow_hashref();
return( $monitor );
return( $monitor );
}
sub zmDbGetMonitorAndControl
{
zmDbConnect();
zmDbConnect();
my $id = shift;
my $id = shift;
return( undef ) if ( !defined($id) );
return( undef ) if ( !defined($id) );
my $sql = "SELECT C.*,M.*,C.Protocol
FROM Monitors as M
INNER JOIN Controls as C on (M.ControlId = C.Id)
WHERE M.Id = ?"
my $sql = "SELECT C.*,M.*,C.Protocol
FROM Monitors as M
INNER JOIN Controls as C on (M.ControlId = C.Id)
WHERE M.Id = ?"
;
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $id )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
my $monitor = $sth->fetchrow_hashref();
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $id )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
my $monitor = $sth->fetchrow_hashref();
return( $monitor );
return( $monitor );
}
1;
@ -217,8 +217,8 @@ ZoneMinder::Database - Perl extension for blah blah blah
=head1 SYNOPSIS
use ZoneMinder::Database;
blah blah blah
use ZoneMinder::Database;
blah blah blah
=head1 DESCRIPTION

View File

@ -43,8 +43,8 @@ our @ISA = qw(Exporter ZoneMinder::Base);
# will save memory.
our %EXPORT_TAGS = (
'functions' => [ qw(
) ]
);
) ]
);
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@ -66,214 +66,214 @@ use ZoneMinder::Database qw(:all);
use POSIX;
sub new {
my ( $parent, $id, $data ) = @_;
my ( $parent, $id, $data ) = @_;
my $self = {};
bless $self, $parent;
$$self{dbh} = $ZoneMinder::Database::dbh;
my $self = {};
bless $self, $parent;
$$self{dbh} = $ZoneMinder::Database::dbh;
#zmDbConnect();
if ( ( $$self{Id} = $id ) or $data ) {
if ( ( $$self{Id} = $id ) or $data ) {
#$log->debug("loading $parent $id") if $debug or DEBUG_ALL;
$self->load( $data );
}
return $self;
$self->load( $data );
}
return $self;
} # end sub new
sub load {
my ( $self, $data ) = @_;
my $type = ref $self;
if ( ! $data ) {
my ( $self, $data ) = @_;
my $type = ref $self;
if ( ! $data ) {
#$log->debug("Object::load Loading from db $type");
$data = $$self{dbh}->selectrow_hashref( 'SELECT * FROM Events WHERE Id=?', {}, $$self{Id} );
if ( ! $data ) {
Error( "Failure to load Event record for $$self{Id}: Reason: " . $$self{dbh}->errstr );
} else {
Debug( 3, "Loaded Event $$self{Id}" );
} # end if
} # end if ! $data
if ( $data and %$data ) {
@$self{keys %$data} = values %$data;
} # end if
$data = $$self{dbh}->selectrow_hashref( 'SELECT * FROM Events WHERE Id=?', {}, $$self{Id} );
if ( ! $data ) {
Error( "Failure to load Event record for $$self{Id}: Reason: " . $$self{dbh}->errstr );
} else {
Debug( 3, "Loaded Event $$self{Id}" );
} # end if
} # end if ! $data
if ( $data and %$data ) {
@$self{keys %$data} = values %$data;
} # end if
} # end sub load
sub Name {
if ( @_ > 1 ) {
$_[0]{Name} = $_[1];
}
return $_[0]{Name};
if ( @_ > 1 ) {
$_[0]{Name} = $_[1];
}
return $_[0]{Name};
} # end sub Path
sub find {
shift if $_[0] eq 'ZoneMinder::Event';
my %sql_filters = @_;
shift if $_[0] eq 'ZoneMinder::Event';
my %sql_filters = @_;
my $sql = 'SELECT * FROM Events';
my @sql_filters;
my @sql_values;
my $sql = 'SELECT * FROM Events';
my @sql_filters;
my @sql_values;
if ( exists $sql_filters{Name} ) {
push @sql_filters , ' Name = ? ';
push @sql_values, $sql_filters{Name};
}
if ( exists $sql_filters{Name} ) {
push @sql_filters , ' Name = ? ';
push @sql_values, $sql_filters{Name};
}
$sql .= ' WHERE ' . join(' AND ', @sql_filters ) if @sql_filters;
$sql .= ' LIMIT ' . $sql_filters{limit} if $sql_filters{limit};
$sql .= ' WHERE ' . join(' AND ', @sql_filters ) if @sql_filters;
$sql .= ' LIMIT ' . $sql_filters{limit} if $sql_filters{limit};
my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
my $res = $sth->execute( @sql_values )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
my $res = $sth->execute( @sql_values )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
my @results;
my @results;
while( my $db_filter = $sth->fetchrow_hashref() ) {
my $filter = new ZoneMinder::Event( $$db_filter{Id}, $db_filter );
push @results, $filter;
} # end while
return @results;
while( my $db_filter = $sth->fetchrow_hashref() ) {
my $filter = new ZoneMinder::Event( $$db_filter{Id}, $db_filter );
push @results, $filter;
} # end while
return @results;
}
sub find_one {
my @results = find(@_);
return $results[0] if @results;
my @results = find(@_);
return $results[0] if @results;
}
sub getEventPath
{
my $event = shift;
my $event = shift;
my $event_path = "";
if ( $Config{ZM_USE_DEEP_STORAGE} )
{
$event_path = $Config{ZM_DIR_EVENTS}
.'/'.$event->{MonitorId}
.'/'.strftime( "%y/%m/%d/%H/%M/%S",
localtime($event->{Time})
)
;
}
else
{
$event_path = $Config{ZM_DIR_EVENTS}
.'/'.$event->{MonitorId}
.'/'.$event->{Id}
;
}
my $event_path = "";
if ( $Config{ZM_USE_DEEP_STORAGE} )
{
$event_path = $Config{ZM_DIR_EVENTS}
.'/'.$event->{MonitorId}
.'/'.strftime( "%y/%m/%d/%H/%M/%S",
localtime($event->{Time})
)
;
}
else
{
$event_path = $Config{ZM_DIR_EVENTS}
.'/'.$event->{MonitorId}
.'/'.$event->{Id}
;
}
if ( index($Config{ZM_DIR_EVENTS},'/') != 0 ){
$event_path = $Config{ZM_PATH_WEB}
.'/'.$event_path
;
}
return( $event_path );
if ( index($Config{ZM_DIR_EVENTS},'/') != 0 ){
$event_path = $Config{ZM_PATH_WEB}
.'/'.$event_path
;
}
return( $event_path );
}
sub GenerateVideo {
my ( $self, $rate, $fps, $scale, $size, $overwrite, $format ) = @_;
my ( $self, $rate, $fps, $scale, $size, $overwrite, $format ) = @_;
my $event_path = getEventPath( $self );
chdir( $event_path );
( my $video_name = $self->{Name} ) =~ s/\s/_/g;
my $event_path = getEventPath( $self );
chdir( $event_path );
( my $video_name = $self->{Name} ) =~ s/\s/_/g;
my @file_parts;
if ( $rate )
{
my $file_rate = $rate;
$file_rate =~ s/\./_/;
$file_rate =~ s/_00//;
$file_rate =~ s/(_\d+)0+$/$1/;
$file_rate = 'r'.$file_rate;
push( @file_parts, $file_rate );
}
elsif ( $fps )
{
my $file_fps = $fps;
$file_fps =~ s/\./_/;
$file_fps =~ s/_00//;
$file_fps =~ s/(_\d+)0+$/$1/;
$file_fps = 'R'.$file_fps;
push( @file_parts, $file_fps );
}
my @file_parts;
if ( $rate )
{
my $file_rate = $rate;
$file_rate =~ s/\./_/;
$file_rate =~ s/_00//;
$file_rate =~ s/(_\d+)0+$/$1/;
$file_rate = 'r'.$file_rate;
push( @file_parts, $file_rate );
}
elsif ( $fps )
{
my $file_fps = $fps;
$file_fps =~ s/\./_/;
$file_fps =~ s/_00//;
$file_fps =~ s/(_\d+)0+$/$1/;
$file_fps = 'R'.$file_fps;
push( @file_parts, $file_fps );
}
if ( $scale )
{
my $file_scale = $scale;
$file_scale =~ s/\./_/;
$file_scale =~ s/_00//;
$file_scale =~ s/(_\d+)0+$/$1/;
$file_scale = 's'.$file_scale;
push( @file_parts, $file_scale );
}
elsif ( $size )
{
my $file_size = 'S'.$size;
push( @file_parts, $file_size );
}
my $video_file = "$video_name-".$file_parts[0]."-".$file_parts[1].".$format";
if ( $overwrite || !-s $video_file )
{
Info( "Creating video file $video_file for event $self->{Id}\n" );
if ( $scale )
{
my $file_scale = $scale;
$file_scale =~ s/\./_/;
$file_scale =~ s/_00//;
$file_scale =~ s/(_\d+)0+$/$1/;
$file_scale = 's'.$file_scale;
push( @file_parts, $file_scale );
}
elsif ( $size )
{
my $file_size = 'S'.$size;
push( @file_parts, $file_size );
}
my $video_file = "$video_name-".$file_parts[0]."-".$file_parts[1].".$format";
if ( $overwrite || !-s $video_file )
{
Info( "Creating video file $video_file for event $self->{Id}\n" );
my $frame_rate = sprintf( "%.2f", $self->{Frames}/$self->{FullLength} );
if ( $rate )
{
if ( $rate != 1.0 )
{
$frame_rate *= $rate;
}
}
elsif ( $fps )
{
$frame_rate = $fps;
}
my $frame_rate = sprintf( "%.2f", $self->{Frames}/$self->{FullLength} );
if ( $rate )
{
if ( $rate != 1.0 )
{
$frame_rate *= $rate;
}
}
elsif ( $fps )
{
$frame_rate = $fps;
}
my $width = $self->{MonitorWidth};
my $height = $self->{MonitorHeight};
my $video_size = " ${width}x${height}";
my $width = $self->{MonitorWidth};
my $height = $self->{MonitorHeight};
my $video_size = " ${width}x${height}";
if ( $scale )
{
if ( $scale != 1.0 )
{
$width = int($width*$scale);
$height = int($height*$scale);
$video_size = " ${width}x${height}";
}
}
elsif ( $size )
{
$video_size = $size;
}
my $command = $Config{ZM_PATH_FFMPEG}
." -y -r $frame_rate "
.$Config{ZM_FFMPEG_INPUT_OPTIONS}
." -i %0"
.$Config{ZM_EVENT_IMAGE_DIGITS}
."d-capture.jpg -s $video_size "
if ( $scale )
{
if ( $scale != 1.0 )
{
$width = int($width*$scale);
$height = int($height*$scale);
$video_size = " ${width}x${height}";
}
}
elsif ( $size )
{
$video_size = $size;
}
my $command = $Config{ZM_PATH_FFMPEG}
." -y -r $frame_rate "
.$Config{ZM_FFMPEG_INPUT_OPTIONS}
." -i %0"
.$Config{ZM_EVENT_IMAGE_DIGITS}
."d-capture.jpg -s $video_size "
#. " -f concat -i /tmp/event_files.txt"
." -s $video_size "
.$Config{ZM_FFMPEG_OUTPUT_OPTIONS}
." '$video_file' > ffmpeg.log 2>&1"
;
Debug( $command."\n" );
my $output = qx($command);
." -s $video_size "
.$Config{ZM_FFMPEG_OUTPUT_OPTIONS}
." '$video_file' > ffmpeg.log 2>&1"
;
Debug( $command."\n" );
my $output = qx($command);
my $status = $? >> 8;
if ( $status )
{
Error( "Unable to generate video, check "
.$event_path."/ffmpeg.log for details"
);
return;
}
my $status = $? >> 8;
if ( $status )
{
Error( "Unable to generate video, check "
.$event_path."/ffmpeg.log for details"
);
return;
}
Info( "Finished $video_file\n" );
return $event_path.'/'.$video_file;
} else {
Info( "Video file $video_file already exists for event $self->{Id}\n" );
return $event_path.'/'.$video_file;
}
return;
Info( "Finished $video_file\n" );
return $event_path.'/'.$video_file;
} else {
Info( "Video file $video_file already exists for event $self->{Id}\n" );
return $event_path.'/'.$video_file;
}
return;
} # end sub GenerateVideo
1;
@ -286,8 +286,8 @@ ZoneMinder::Database - Perl extension for blah blah blah
=head1 SYNOPSIS
use ZoneMinder::Event;
blah blah blah
use ZoneMinder::Event;
blah blah blah
=head1 DESCRIPTION

View File

@ -88,7 +88,7 @@ sub load {
if ( ! $data ) {
Error( "Failure to load Filter record for $$self{Id}: Reason: " . $$self{dbh}->errstr );
} else {
Debug( 3, "Loaded Filter $$self{Id}" );
Debug( 3, "Loaded Filter $$self{Id}" );
} # end if
} # end if ! $data
if ( $data and %$data ) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -42,8 +42,8 @@ our @ISA = qw(Exporter ZoneMinder::Base);
# will save memory.
our %EXPORT_TAGS = (
'functions' => [ qw(
) ]
);
) ]
);
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@ -65,46 +65,46 @@ use ZoneMinder::Database qw(:all);
use POSIX;
sub new {
my ( $parent, $id, $data ) = @_;
my ( $parent, $id, $data ) = @_;
my $self = {};
bless $self, $parent;
if ( ( $$self{Id} = $id ) or $data ) {
my $self = {};
bless $self, $parent;
if ( ( $$self{Id} = $id ) or $data ) {
#$log->debug("loading $parent $id") if $debug or DEBUG_ALL;
$self->load( $data );
}
return $self;
$self->load( $data );
}
return $self;
} # end sub new
sub load {
my ( $self, $data ) = @_;
my $type = ref $self;
if ( ! $data ) {
my ( $self, $data ) = @_;
my $type = ref $self;
if ( ! $data ) {
#$log->debug("Object::load Loading from db $type");
$data = $ZoneMinder::Database::dbh->selectrow_hashref( 'SELECT * FROM Servers WHERE Id=?', {}, $$self{Id} );
if ( ! $data ) {
if ( $ZoneMinder::Database::dbh->errstr ) {
Error( "Failure to load Server record for $$self{id}: Reason: " . $ZoneMinder::Database::dbh->errstr );
} # end if
} # end if
} # end if ! $data
if ( $data and %$data ) {
@$self{keys %$data} = values %$data;
} # end if
$data = $ZoneMinder::Database::dbh->selectrow_hashref( 'SELECT * FROM Servers WHERE Id=?', {}, $$self{Id} );
if ( ! $data ) {
if ( $ZoneMinder::Database::dbh->errstr ) {
Error( "Failure to load Server record for $$self{id}: Reason: " . $ZoneMinder::Database::dbh->errstr );
} # end if
} # end if
} # end if ! $data
if ( $data and %$data ) {
@$self{keys %$data} = values %$data;
} # end if
} # end sub load
sub Name {
if ( @_ > 1 ) {
$_[0]{Name} = $_[1];
}
return $_[0]{Name};
if ( @_ > 1 ) {
$_[0]{Name} = $_[1];
}
return $_[0]{Name};
} # end sub Name
sub Hostname {
if ( @_ > 1 ) {
$_[0]{Hostname} = $_[1];
}
return $_[0]{Hostname};
if ( @_ > 1 ) {
$_[0]{Hostname} = $_[1];
}
return $_[0]{Hostname};
} # end sub Hostname
1;
@ -117,8 +117,8 @@ ZoneMinder::Database - Perl extension for blah blah blah
=head1 SYNOPSIS
use ZoneMinder::Server;
blah blah blah
use ZoneMinder::Server;
blah blah blah
=head1 DESCRIPTION

View File

@ -152,11 +152,13 @@ Image::Image( const Image &p_image )
strncpy( text, p_image.text, sizeof(text) );
}
Image::~Image()
{
Image::~Image() {
DumpImgBuffer();
if ( initialised )
{
}
/* Should be called as part of program shutdown to free everything */
void Image::Deinitialise() {
if ( initialised ) {
/*
delete[] y_table;
delete[] uv_table;
@ -166,18 +168,24 @@ Image::~Image()
delete[] b_u_table;
*/
initialised = false;
}
if ( readjpg_dcinfo )
{
jpeg_destroy_decompress( readjpg_dcinfo );
delete readjpg_dcinfo;
readjpg_dcinfo = 0;
}
if ( decodejpg_dcinfo )
{
jpeg_destroy_decompress( decodejpg_dcinfo );
delete decodejpg_dcinfo;
decodejpg_dcinfo = 0;
if ( readjpg_dcinfo ) {
jpeg_destroy_decompress( readjpg_dcinfo );
delete readjpg_dcinfo;
readjpg_dcinfo = 0;
}
if ( decodejpg_dcinfo )
{
jpeg_destroy_decompress( decodejpg_dcinfo );
delete decodejpg_dcinfo;
decodejpg_dcinfo = 0;
}
for ( unsigned int quality=0; quality <= 100; quality += 1 ) {
if ( writejpg_ccinfo[quality] ) {
jpeg_destroy_compress( writejpg_ccinfo[quality] );
delete writejpg_ccinfo[quality];
writejpg_ccinfo[quality] = NULL;
}
} // end foreach quality
}
}
@ -187,14 +195,14 @@ void Image::Initialise()
if(config.fast_image_blends) {
if(config.cpu_extensions && sseversion >= 20) {
fptr_blend = &sse2_fastblend; /* SSE2 fast blend */
Debug(2,"Blend: Using SSE2 fast blend function");
Debug(4,"Blend: Using SSE2 fast blend function");
} else {
fptr_blend = &std_fastblend; /* standard fast blend */
Debug(2,"Blend: Using fast blend function");
Debug(4,"Blend: Using fast blend function");
}
} else {
fptr_blend = &std_blend;
Debug(2,"Blend: Using standard blend function");
Debug(4,"Blend: Using standard blend function");
}
__attribute__((aligned(16))) uint8_t blend1[16] = {142,255,159,91,88,227,0,52,37,80,152,97,104,252,90,82};
@ -223,7 +231,7 @@ void Image::Initialise()
fptr_delta8_argb = &ssse3_delta8_argb;
fptr_delta8_abgr = &ssse3_delta8_abgr;
fptr_delta8_gray8 = &sse2_delta8_gray8;
Debug(2,"Delta: Using SSSE3 delta functions");
Debug(4,"Delta: Using SSSE3 delta functions");
} else if(sseversion >= 20) {
/* SSE2 available */
fptr_delta8_rgba = &sse2_delta8_rgba;
@ -240,7 +248,7 @@ void Image::Initialise()
// fptr_delta8_argb = &std_delta8_argb;
// fptr_delta8_abgr = &std_delta8_abgr;
fptr_delta8_gray8 = &sse2_delta8_gray8;
Debug(2,"Delta: Using SSE2 delta functions");
Debug(4,"Delta: Using SSE2 delta functions");
} else {
/* No suitable SSE version available */
fptr_delta8_rgba = &std_delta8_rgba;
@ -248,7 +256,7 @@ void Image::Initialise()
fptr_delta8_argb = &std_delta8_argb;
fptr_delta8_abgr = &std_delta8_abgr;
fptr_delta8_gray8 = &std_delta8_gray8;
Debug(2,"Delta: Using standard delta functions");
Debug(4,"Delta: Using standard delta functions");
}
} else {
/* CPU extensions disabled */
@ -257,7 +265,7 @@ void Image::Initialise()
fptr_delta8_argb = &std_delta8_argb;
fptr_delta8_abgr = &std_delta8_abgr;
fptr_delta8_gray8 = &std_delta8_gray8;
Debug(2,"Delta: CPU extensions disabled, using standard delta functions");
Debug(4,"Delta: CPU extensions disabled, using standard delta functions");
}
/* Use SSSE3 deinterlace functions? */
@ -267,23 +275,23 @@ void Image::Initialise()
fptr_deinterlace_4field_argb = &ssse3_deinterlace_4field_argb;
fptr_deinterlace_4field_abgr = &ssse3_deinterlace_4field_abgr;
fptr_deinterlace_4field_gray8 = &ssse3_deinterlace_4field_gray8;
Debug(2,"Deinterlace: Using SSSE3 delta functions");
Debug(4,"Deinterlace: Using SSSE3 delta functions");
} else {
fptr_deinterlace_4field_rgba = &std_deinterlace_4field_rgba;
fptr_deinterlace_4field_bgra = &std_deinterlace_4field_bgra;
fptr_deinterlace_4field_argb = &std_deinterlace_4field_argb;
fptr_deinterlace_4field_abgr = &std_deinterlace_4field_abgr;
fptr_deinterlace_4field_gray8 = &std_deinterlace_4field_gray8;
Debug(2,"Deinterlace: Using standard delta functions");
Debug(4,"Deinterlace: Using standard delta functions");
}
/* Use SSE2 aligned memory copy? */
if(config.cpu_extensions && sseversion >= 20) {
fptr_imgbufcpy = &sse2_aligned_memcpy;
Debug(2,"Image buffer copy: Using SSE2 aligned memcpy");
Debug(4,"Image buffer copy: Using SSE2 aligned memcpy");
} else {
fptr_imgbufcpy = &memcpy;
Debug(2,"Image buffer copy: Using standard memcpy");
Debug(4,"Image buffer copy: Using standard memcpy");
}
/* Code below relocated from zm_local_camera */

View File

@ -137,7 +137,6 @@ protected:
static jpeg_decompress_struct *decodejpg_dcinfo;
static struct zm_error_mgr jpg_err;
protected:
unsigned int width;
unsigned int height;
unsigned int pixels;
@ -150,8 +149,6 @@ protected:
int holdbuffer; /* Hold the buffer instead of replacing it with new one */
char text[1024];
protected:
static void Initialise();
public:
Image();
@ -159,6 +156,8 @@ public:
Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer=0);
Image( const Image &p_image );
~Image();
static void Initialise();
static void Deinitialise();
inline unsigned int Width() const { return( width ); }
inline unsigned int Height() const { return( height ); }

View File

@ -198,6 +198,7 @@ int main( int argc, char *argv[] )
{
fprintf( stderr, "Can't find monitor with id of %d\n", id );
}
Image::Deinitialise();
logTerm();
zmDbClose();
return( 0 );

View File

@ -357,6 +357,7 @@ int main( int argc, char *argv[] )
delete [] next_delays;
delete [] last_capture_times;
Image::Deinitialise();
logTerm();
zmDbClose();

View File

@ -1,5 +1,5 @@
<VirtualHost *:80>
DocumentRoot /var/www/zm
DocumentRoot /usr/local/share/zoneminder
DirectoryIndex index.php
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

View File

@ -53,10 +53,10 @@ escaped="$(echo $temp | sed 's/\//\\\//g')"
}
# Assign variables once they are properly escaped
escape $1
variable=$escaped
escape $2
default=$escaped
escape "$1"
variable="$escaped"
escape "$2"
default="$escaped"
# Set the path to ConfigData
if [ -n "$3" ]; then
@ -82,7 +82,7 @@ fi
# Don't stare too closely. You will burn your eyes out.
sed -i '/.*'${variable}'.*/{
$!{ N
s/\(.*'${variable}'.*\n.*\)\"\(.*\)\"/\1\"'${default}'\"/
s/\(.*'${variable}'.*\n.*\)\"\(.*\)\"/\1\"'"${default}"'\"/
t yes
P
D

View File

@ -71,7 +71,7 @@ class DATABASE_CONFIG {
'password' => ZM_DB_PASS,
'database' => ZM_DB_NAME,
'prefix' => '',
//'encoding' => 'utf8',
'encoding' => 'utf8',
);
public $test = array(

View File

@ -99,7 +99,18 @@ class HostController extends AppController {
));
}
function getTimeZone()
{
//http://php.net/manual/en/function.date-default-timezone-get.php
$tz = date_default_timezone_get();
$this->set(array(
'tz' => $tz,
'_serialize' => array('tz')
));
}
function getVersion() {
//throw new UnauthorizedException(__('API Disabled'));
$version = Configure::read('ZM_VERSION');
// not going to use the ZM_API_VERSION
// requires recompilation and dependency on ZM upgrade

View File

@ -338,7 +338,9 @@ if ( !empty($action) )
$monitor = dbFetchOne( "SELECT * FROM Monitors WHERE Id=?", NULL, array($mid) );
$newFunction = validStr($_REQUEST['newFunction']);
$newEnabled = isset( $_REQUEST['newEnabled'] ) and $_REQUEST['newEnabled'] != "1" ? "0" : "1";
# Because we use a checkbox, it won't get passed in the request. So not being in _REQUEST means 0
$newEnabled = ( !isset( $_REQUEST['newEnabled'] ) or $_REQUEST['newEnabled'] != '1' ) ? '0' : '1';
$oldFunction = $monitor['Function'];
$oldEnabled = $monitor['Enabled'];
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled )

View File

@ -544,6 +544,28 @@ function makePopupButton( $url, $winName, $winSize, $buttonValue, $condition=1,
return( $string );
}
function htmlSelect( $name, $contents, $values, $behaviours=false ) {
$behaviourText = "";
if ( !empty($behaviours) ) {
if ( is_array($behaviours) ) {
foreach ( $behaviours as $event=>$action ) {
$behaviourText .= ' '.$event.'="'.$action.'"';
}
} else {
$behaviourText = ' onchange="'.$behaviours.'"';
}
}
$html = "<select name=\"$name\" id=\"$name\"$behaviourText>";
foreach ( $contents as $value=>$text ) {
$selected = is_array( $values ) ? in_array( $value, $values ) : $value==$values;
$html .= "<option value=\"$value\"".($selected?" selected=\"selected\"":'').">$text</option>";
}
$html .= "</select>";
return $html;
}
function truncText( $text, $length, $deslash=1 ) {
return( preg_replace( "/^(.{".$length.",}?)\b.*$/", "\\1&hellip;", ($deslash?stripslashes($text):$text) ) );
}

View File

@ -518,6 +518,7 @@ $SLANG = array(
'NewUser' => 'New User',
'Next' => 'Next',
'NoDetectedCameras' => 'No Detected Cameras',
'NoDetectedProfiles' => 'No Detected Profiles',
'NoFramesRecorded' => 'There are no frames recorded for this event',
'NoGroup' => 'No Group',
'NoneAvailable' => 'None available',

View File

@ -1,4 +1,3 @@
<?php
//
// ZoneMinder web UK English language file, $Date$, $Revision$

View File

@ -102,7 +102,12 @@ function getPopupSize( tag, width, height )
function zmWindow()
{
var zmWin = window.open( 'http://www.zoneminder.com', 'ZoneMinder' );
zmWin.focus();
if ( ! zmWin ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
zmWin.focus();
}
}
function createPopup( url, name, tag, width, height )
@ -114,7 +119,12 @@ function createPopup( url, name, tag, width, height )
if ( popupSize.height > 0 )
popupDimensions += ",height="+popupSize.height;
var popup = window.open( url, name, popupOptions+popupDimensions );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function createEventPopup( eventId, eventFilter, width, height )
@ -125,7 +135,12 @@ function createEventPopup( eventId, eventFilter, width, height )
var name = 'zmEvent';
var popupSize = getPopupSize( 'event', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function createFramesPopup( eventId, width, height )
@ -134,7 +149,12 @@ function createFramesPopup( eventId, width, height )
var name = 'zmFrames';
var popupSize = getPopupSize( 'frames', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function createFramePopup( eventId, frameId, width, height )
@ -143,7 +163,12 @@ function createFramePopup( eventId, frameId, width, height )
var name = 'zmFrame';
var popupSize = getPopupSize( 'frame', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function windowToFront()

View File

@ -41,10 +41,14 @@ if ( isset( $_REQUEST['rate'] ) )
$rate = validInt($_REQUEST['rate']);
else
$rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE );
if ( isset( $_REQUEST['scale'] ) )
$scale = validInt($_REQUEST['scale']);
else
$scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
if ( isset( $_REQUEST['scale'] ) ) {
$scale = validInt($_REQUEST['scale']);
} else if ( isset( $_COOKIE['zmEventScale'.$event['MonitorId']] ) ) {
$scale = $_COOKIE['zmEventScale'.$event['MonitorId']];
} else {
$scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
}
$replayModes = array(
'single' => translate('ReplaySingle'),

View File

@ -13,6 +13,7 @@ function changeScale()
var newHeight = ( baseHeight * scale ) / SCALE_BASE;
streamScale( scale );
Cookie.write( 'zmEventScale'+eventData.MonitorId, scale, { duration: 10*365 } );
/*Stream could be an applet so can't use moo tools*/
var streamImg = document.getElementById('evtStream');

View File

@ -27,6 +27,7 @@ var connKey = '<?php echo $connkey ?>';
var eventData = {
Id: <?php echo $event['Id'] ?>,
MonitorId: <?php echo $event['MonitorId'] ?>,
Width: <?php echo $event['Width'] ?>,
Height: <?php echo $event['Height'] ?>,
Length: <?php echo $event['Length'] ?>

View File

@ -32,8 +32,7 @@ function changeScale()
var newWidth = ( monitorWidth * scale ) / SCALE_BASE;
var newHeight = ( monitorHeight * scale ) / SCALE_BASE;
// This causes FF3 to kill the stream now, ok with FF2
//streamCmdScale( scale );
Cookie.write( 'zmWatchScale'+monitorId, scale, { duration: 10*365 } );
/*Stream could be an applet so can't use moo tools*/
var streamImg = document.getElementById('liveStream');

View File

@ -41,7 +41,7 @@ xhtmlHeaders(__FILE__, translate('Login') );
<tbody>
<tr>
<td class="colLeft"><?php echo translate('Username') ?></td>
<td class="colRight"><input type="text" name="username" value="<?php echo isset($_REQUEST['username'])?validHtmlStr($_REQUEST['username']):"" ?>" size="12"/></td>
<td class="colRight"><input type="text" name="username" autocorrect="off" autocapitalize="off" spellcheck="false" value="<?php echo isset($_REQUEST['username'])?validHtmlStr($_REQUEST['username']):"" ?>" size="12"/></td>
</tr>
<tr>
<td class="colLeft"><?php echo translate('Password') ?></td>

View File

@ -27,13 +27,21 @@ if ( !canEdit( 'Monitors' ) )
$cameras = array();
$cameras[0] = translate('ChooseDetectedCamera');
$profiles = array();
$profiles[0] = translate('ChooseDetectedProfile');
function execONVIF( $cmd )
{
exec( escapeshellcmd(ZM_PATH_BIN . "/zmonvif-probe.pl $cmd"), $output, $status );
if ( $status )
Fatal( "Unable to probe network cameras, status is '$status'" );
function execONVIF( $cmd ) {
$shell_command = escapeshellcmd(ZM_PATH_BIN . "/zmonvif-probe.pl $cmd");
exec( $shell_command, $output, $status );
if ( $status ) {
$html_output = implode( '<br/>', $output );
Fatal( "Unable to probe network cameras, status is '$status'. Output was:<br/><br/>
$html_output<br/><br/>
Please the following command from a command line for more information:<br/><br/>$shell_command"
);
}
return $output;
}
@ -216,9 +224,10 @@ if( !isset($_REQUEST['step']) || ($_REQUEST['step'] == "1")) {
}
else if($_REQUEST['step'] == "2")
{
if ( empty($_REQUEST['probe']) || empty($_REQUEST['username']) ||
empty($_REQUEST['password']) )
Fatal("Internal error. Please re-open this page.");
if ( empty($_REQUEST['probe']) )
Fatal("No probe passed in request. Please go back and try again.");
#|| empty($_REQUEST['username']) ||
#empty($_REQUEST['password']) )
$probe = unserialize(base64_decode($_REQUEST['probe']));
foreach ( $probe as $name=>$value )
@ -248,11 +257,11 @@ else if($_REQUEST['step'] == "2")
$monitor['Path'] = $profile['Path'];
// $sourceDesc = htmlspecialchars(serialize($monitor));
$sourceDesc = base64_encode(serialize($monitor));
$cameras[$sourceDesc] = $sourceString;
$profiles[$sourceDesc] = $sourceString;
}
if ( count($cameras) <= 0 )
$cameras[0] = translate('NoDetectedCameras');
if ( count($profiles) <= 0 )
$profiles[0] = translate('NoDetectedProfiles');
?>
<body>
@ -269,7 +278,7 @@ else if($_REQUEST['step'] == "2")
<?php echo translate('ProfileProbeIntro') ?>
</p>
<p>
<label for="probe"><?php echo translate('DetectedProfiles') ?></label><?php echo buildSelect( "probe", $cameras, 'configureButtons( this )' ); ?>
<label for="probe"><?php echo translate('DetectedProfiles') ?></label><?php echo buildSelect( 'probe', $profiles, 'configureButtons( this )' ); ?>
</p>
<div id="contentButtons">
<input type="button" name="prevBtn" value="<?php echo translate('Prev') ?>" onclick="gotoStep1( this )"/>

View File

@ -44,10 +44,13 @@ else
$showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable() && canView( 'Control' ) );
if ( isset( $_REQUEST['scale'] ) )
$scale = validInt($_REQUEST['scale']);
else
$scale = reScale( SCALE_BASE, $monitor->DefaultScale, ZM_WEB_DEFAULT_SCALE );
if ( isset( $_REQUEST['scale'] ) ) {
$scale = validInt($_REQUEST['scale']);
} else if ( isset( $_COOKIE['zmWatchScale'.$mid] ) ) {
$scale = $_COOKIE['zmWatchScale'.$mid];
} else {
$scale = reScale( SCALE_BASE, $monitor->DefaultScale, ZM_WEB_DEFAULT_SCALE );
}
$connkey = generateConnKey();