Add a verbose var to ONVIF::CLient and allow it to be set during build.

This commit is contained in:
Isaac Connor 2020-05-12 15:47:27 -04:00
parent 69e5feb28b
commit f8249251bd
1 changed files with 15 additions and 12 deletions

View File

@ -74,6 +74,7 @@ my %services_of :ATTR(:default<{}>);
my %serializer_of :ATTR();
my %soap_version_of :ATTR(:default<('1.1')>);
my $verbose;
# =========================================================================
# private methods
@ -121,25 +122,27 @@ sub get_service_urls {
}
);
if ( $result ) {
print "Have results from GetServices\n" if $verbose;
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";
print "Got $short_name service $url_svc\n" if $verbose;
$self->set_service($short_name, 'url', $url_svc);
}
}
#} else {
#print "No results from GetServices: $result\n";
} else {
print "No results from GetServices\n" if $verbose;
}
# 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";
print "No results from GetCapabilities: $result\n" if $verbose;
return;
}
print "Have results from GetCapabilities: $result\n" if $verbose;
# Result is a GetCapabilitiesResponse
foreach my $capabilities ( @{ $result->get_Capabilities() } ) {
foreach my $capability ( 'PTZ', 'Media', 'Imaging', 'Events', 'Device' ) {
@ -160,7 +163,6 @@ sub get_service_urls {
}
} else {
print "No $capability function\n";
} # end if has a get_ function
} # end foreach capability
} # end foreach capabilities
@ -189,9 +191,10 @@ sub http_digest {
sub BUILD {
my ($self, $ident, $args_ref) = @_;
my $url_svc_device = $args_ref->{'url_svc_device'};
my $soap_version = $args_ref->{'soap_version'};
if(! $soap_version) {
$verbose = $args_ref->{verbose};
my $url_svc_device = $args_ref->{url_svc_device};
my $soap_version = $args_ref->{soap_version};
if ( !$soap_version ) {
$soap_version = '1.1';
}
$self->set_soap_version($soap_version);
@ -244,7 +247,7 @@ sub set_credentials {
# TODO: snyc device and client time
if ($create_if_not_exists) {
if ( $create_if_not_exists ) {
# If GetUsers() is ok but empty then CreateUsers()
# if(not get_users()) {
# create_user($username, $password);
@ -280,14 +283,14 @@ sub create_services {
# transport => $transport
}));
}
if(defined $self->service('events', 'url')) {
if ( defined $self->service('events', 'url') ) {
$self->set_service('events', 'ep', WSNotification::Interfaces::WSBaseNotificationSender::NotificationProducerPort->new({
proxy => $self->service('events', 'url'),
serializer => $self->serializer(),
# transport => $transport
}));
}
if(defined $self->service('analytics', 'url')) {
if ( defined $self->service('analytics', 'url') ) {
$self->set_service('analytics', 'ep', ONVIF::Analytics::Interfaces::Analytics::AnalyticsEnginePort->new({
proxy => $self->service('analytics', 'url'),
serializer => $self->serializer(),
@ -299,7 +302,7 @@ sub create_services {
# transport => $transport
}));
}
}
} # end sub create_services
sub get_endpoint {
my ($self, $serviceType) = @_;