Add a verbose var to ONVIF::CLient and allow it to be set during build.
This commit is contained in:
parent
69e5feb28b
commit
f8249251bd
|
@ -74,6 +74,7 @@ my %services_of :ATTR(:default<{}>);
|
||||||
|
|
||||||
my %serializer_of :ATTR();
|
my %serializer_of :ATTR();
|
||||||
my %soap_version_of :ATTR(:default<('1.1')>);
|
my %soap_version_of :ATTR(:default<('1.1')>);
|
||||||
|
my $verbose;
|
||||||
|
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
# private methods
|
# private methods
|
||||||
|
@ -121,25 +122,27 @@ sub get_service_urls {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( $result ) {
|
if ( $result ) {
|
||||||
|
print "Have results from GetServices\n" if $verbose;
|
||||||
foreach my $svc ( @{ $result->get_Service() } ) {
|
foreach my $svc ( @{ $result->get_Service() } ) {
|
||||||
my $short_name = $namespace_map{$svc->get_Namespace()};
|
my $short_name = $namespace_map{$svc->get_Namespace()};
|
||||||
my $url_svc = $svc->get_XAddr()->get_value();
|
my $url_svc = $svc->get_XAddr()->get_value();
|
||||||
if ( defined $short_name && defined $url_svc ) {
|
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);
|
$self->set_service($short_name, 'url', $url_svc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#} else {
|
} else {
|
||||||
#print "No results from GetServices: $result\n";
|
print "No results from GetServices\n" if $verbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Some devices do not support getServices, so we have to try getCapabilities
|
# Some devices do not support getServices, so we have to try getCapabilities
|
||||||
|
|
||||||
$result = $self->service('device', 'ep')->GetCapabilities( {}, , );
|
$result = $self->service('device', 'ep')->GetCapabilities( {}, , );
|
||||||
if ( !$result ) {
|
if ( !$result ) {
|
||||||
print "No results from GetCapabilities: $result\n";
|
print "No results from GetCapabilities: $result\n" if $verbose;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
print "Have results from GetCapabilities: $result\n" if $verbose;
|
||||||
# Result is a GetCapabilitiesResponse
|
# Result is a GetCapabilitiesResponse
|
||||||
foreach my $capabilities ( @{ $result->get_Capabilities() } ) {
|
foreach my $capabilities ( @{ $result->get_Capabilities() } ) {
|
||||||
foreach my $capability ( 'PTZ', 'Media', 'Imaging', 'Events', 'Device' ) {
|
foreach my $capability ( 'PTZ', 'Media', 'Imaging', 'Events', 'Device' ) {
|
||||||
|
@ -160,7 +163,6 @@ sub get_service_urls {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "No $capability function\n";
|
print "No $capability function\n";
|
||||||
|
|
||||||
} # end if has a get_ function
|
} # end if has a get_ function
|
||||||
} # end foreach capability
|
} # end foreach capability
|
||||||
} # end foreach capabilities
|
} # end foreach capabilities
|
||||||
|
@ -189,9 +191,10 @@ sub http_digest {
|
||||||
sub BUILD {
|
sub BUILD {
|
||||||
my ($self, $ident, $args_ref) = @_;
|
my ($self, $ident, $args_ref) = @_;
|
||||||
|
|
||||||
my $url_svc_device = $args_ref->{'url_svc_device'};
|
$verbose = $args_ref->{verbose};
|
||||||
my $soap_version = $args_ref->{'soap_version'};
|
my $url_svc_device = $args_ref->{url_svc_device};
|
||||||
if(! $soap_version) {
|
my $soap_version = $args_ref->{soap_version};
|
||||||
|
if ( !$soap_version ) {
|
||||||
$soap_version = '1.1';
|
$soap_version = '1.1';
|
||||||
}
|
}
|
||||||
$self->set_soap_version($soap_version);
|
$self->set_soap_version($soap_version);
|
||||||
|
@ -244,7 +247,7 @@ sub set_credentials {
|
||||||
|
|
||||||
# TODO: snyc device and client time
|
# 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 GetUsers() is ok but empty then CreateUsers()
|
||||||
# if(not get_users()) {
|
# if(not get_users()) {
|
||||||
# create_user($username, $password);
|
# create_user($username, $password);
|
||||||
|
@ -280,14 +283,14 @@ sub create_services {
|
||||||
# transport => $transport
|
# transport => $transport
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if(defined $self->service('events', 'url')) {
|
if ( defined $self->service('events', 'url') ) {
|
||||||
$self->set_service('events', 'ep', WSNotification::Interfaces::WSBaseNotificationSender::NotificationProducerPort->new({
|
$self->set_service('events', 'ep', WSNotification::Interfaces::WSBaseNotificationSender::NotificationProducerPort->new({
|
||||||
proxy => $self->service('events', 'url'),
|
proxy => $self->service('events', 'url'),
|
||||||
serializer => $self->serializer(),
|
serializer => $self->serializer(),
|
||||||
# transport => $transport
|
# 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({
|
$self->set_service('analytics', 'ep', ONVIF::Analytics::Interfaces::Analytics::AnalyticsEnginePort->new({
|
||||||
proxy => $self->service('analytics', 'url'),
|
proxy => $self->service('analytics', 'url'),
|
||||||
serializer => $self->serializer(),
|
serializer => $self->serializer(),
|
||||||
|
@ -299,7 +302,7 @@ sub create_services {
|
||||||
# transport => $transport
|
# transport => $transport
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
} # end sub create_services
|
||||||
|
|
||||||
sub get_endpoint {
|
sub get_endpoint {
|
||||||
my ($self, $serviceType) = @_;
|
my ($self, $serviceType) = @_;
|
||||||
|
|
Loading…
Reference in New Issue