forked from ZoneMinder/zoneminder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzmonvif-probe.pl.in
184 lines (152 loc) · 5.49 KB
/
zmonvif-probe.pl.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!@PERL_EXECUTABLE@ -w
use strict;
#
# ==========================================================================
#
# ZoneMinder ONVIF Control Protocol Module
# Copyright (C) 2014 Jan M. Hochstein
#
# 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.
#
# ==========================================================================
#
# This module contains the implementation of the ONVIF capability prober
#
use Getopt::Std;
require ONVIF::Client;
# ========================================================================
# options processing
$Getopt::Std::STANDARD_HELP_VERSION = 1;
our ($opt_v);
my $OPTIONS = 'v';
sub HELP_MESSAGE {
my ($fh, $pkg, $ver, $opts) = @_;
print $fh "Usage: " . __FILE__ . " [-v] probe <soap versions> <network interface>\n";
print $fh " " . __FILE__ . " [-v] <command> <device URI> <soap version> <user> <password>\n";
print $fh <<EOF
Commands are:
probe - scan for devices on the local network and list them
profiles - print the device's supported stream configurations
metadata - print some of the device's configuration settings
move - move the device (only ptz cameras)
Common parameters:
-v - increase verbosity
Device access parameters (for all commands but 'probe'):
device URL - the ONVIF Device service URL
soap versions - SOAP versions (1.1 or 1.2 or 1.1,1.2)
user - username of a user with access to the device
password - password for the user
EOF
}
# ========================================================================
# MAIN
if ( !getopts($OPTIONS) ) {
HELP_MESSAGE(\*STDOUT);
exit(1);
}
my $action = shift;
if ( !defined $action ) {
HELP_MESSAGE(\*STDOUT);
exit(1);
}
@EXTRA_PERL_LIB@
require ZoneMinder::ONVIF;
if ( defined $opt_v ) {
$ZoneMinder::ONVIF::verbose = 1;
} else {
$ZoneMinder::ONVIF::verbose = 0;
}
if ( $action eq 'probe' ) {
my $soap_version = shift;
my $net_interface = shift;
ZoneMinder::ONVIF::discover($soap_version, $net_interface);
} else {
# all other actions need URI and credentials
my $url_svc_device = shift @ARGV;
my $soap_version = shift @ARGV;
my $username = @ARGV ? shift @ARGV : '';
my $password = @ARGV ? shift @ARGV: '';
my $client = ONVIF::Client->new( {
verbose => $ZoneMinder::ONVIF::verbose,
url_svc_device => $url_svc_device,
soap_version => $soap_version } );
$client->set_credentials($username, $password, 1);
$client->create_services();
if ( $action eq 'profiles' ) {
my @profiles = ZoneMinder::ONVIF::profiles($client);
foreach my $profile ( @profiles ) {
my ( $token, $name, $encoding, $width, $height, $frame_rate_limit, $stream_type, $uri ) = @{$profile};
print join(', ', $token,
$name,
$encoding,
$width,
$height,
$frame_rate_limit,
$stream_type,
$uri,
) . "\n";
} # end foreach profile
} elsif ( $action eq 'move' ) {
my $dir = shift;
ZoneMinder::ONVIF::move($client, $dir);
} elsif ( $action eq 'metadata' ) {
ZoneMinder::ONVIF::metadata($client);
} else {
my $media = $client->get_endpoint('media');
if ( ! $media ) {
print "No media endpoint for client.\n";
return;
}
my $result = $media->$action( { } ,, );
if ( $result ) {
use XML::LibXML;
my $dom = XML::LibXML->load_xml(string=>$result);
print "Received message:\n" . $dom->toString(1) . "\n";
} else {
print("Error: Unknown command \"$action\"");
exit(1);
}
}
} # end if probe or other
1;
__END__
=head1 NAME
zmonvif-probe.pl - ZoneMinder ONVIF probing tool
=head1 SYNOPSIS
zmonfig-probe.pl [-v] probe <soap version>
[-v] <command> <device URI> <soap version> <user> <password>\n";
Commands are:
probe - scan for devices on the local network and list them
profiles - print the device's supported stream configurations
metadata - print some of the device's configuration settings
move - move the device (only ptz cameras)
other - Any command supported by the ONVIF Media element.
Common parameters:
-v - increase verbosity
Device access parameters (for all commands but 'probe'):
device URL - the ONVIF Device service URL
soap version - SOAP version (1.1 or 1.2)
user - username of a user with access to the device
password - password for the user
=head1 DESCRIPTION
=head1 OPTIONS
-c, --continuous - Run continuously
-f, --force - Run even if pid file exists
-i, --interactive - Ask before applying any changes
-m, --monitor_id - Only consider the given monitor
-r, --report - Just report don't actually do anything
-s, --storage_id - Specify a storage area to audit instead of all
-v, --version - Print the installed version of ZoneMinder
=cut