Zoneminder: control module for Vstarcam C7816WIP

Perl module to control the Vstarcam C7816WIP with Zoneminder.

C7816WIP.pm:

# ==========================================================================
#
# ZoneMinder Vstarcam C7816WIP IP Control Protocol Module, $Date: 2017-01-15 01:18:10 +0100 (Wed, 04 Nov 2009) $, $Revision: 1 $
# Copyright (C) 2017 Mentor (http://www.internauta37.altervista.org)
#
# 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 is based on WanscamHW0025.pm
#
# ==========================================================================
#
# This module contains the implementation of the Vstarcam C7816WIP IP camera control
# protocol
#
package ZoneMinder::Control::C7816WIP;
 
use 5.006;
use strict;
use warnings;

require ZoneMinder::Base;
require ZoneMinder::Control;

our @ISA = qw(ZoneMinder::Control);
 
# ==========================================================================
#
# Vstarcam C7816WIP IP Control Protocol
#
# ==========================================================================
 
use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);

use Time::HiRes qw( usleep );
 
sub new
{ 
	my $class = shift;
	my $id = shift;
	my $self = ZoneMinder::Control->new( $id );
	bless( $self, $class );
	srand( time() );
	return $self;
}
 
our $AUTOLOAD;
 
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} );
    }
    Fatal( "Can't access $name member of object of class $class" );
}
 
sub open
{
    my $self = shift;

    $self->loadMonitor();

    use LWP::UserAgent;
    $self->{ua} = LWP::UserAgent->new;
    $self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );

    $self->{state} = 'open';
}
 
sub close
{ 
	my $self = shift;
	$self->{state} = 'closed';
}
 
sub printMsg
{
	my $self = shift;
	my $msg = shift;
	my $msg_len = length($msg);
 
	Debug( $msg."[".$msg_len."]" );
}

sub sendCmd
{
    my $self = shift;
    my $cmd = shift;

    my $result = undef;

    printMsg( $cmd, "Tx" );

    my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd".$self->{Monitor}->{ControlDevice} );
	Info( "http://".$self->{Monitor}->{ControlAddress}."/$cmd".$self->{Monitor}->{ControlDevice} );
    my $res = $self->{ua}->request($req);

    if ( $res->is_success )
    {
        $result = !undef;
    }
    else
    {
        Error( "Error check failed: '".$res->status_line()."'" );
    }

    return( $result );
}

 
sub reset
{
	my $self = shift;
	Debug( "Camera Reset" );
	my $cmd = "reboot.cgi?";
	$self->sendCmd( $cmd );
}
 
#Turn IR on
sub wake
{
	my $self = shift;
	Debug( "Wake - IR on" );
	my $cmd = "camera_control.cgi?param=14&value=1&";
	$self->sendCmd( $cmd );
}
 
#Turn IR off
sub sleep
{
	my $self = shift;
	Debug( "Sleep - IR off" );
	my $cmd = "camera_control.cgi?param=14&value=0&";
	$self->sendCmd( $cmd );
}
1;
__END__
=head1 NAME
ZoneMinder::Database - Perl extension for Vstarcam C7816WIP
=head1 SYNOPSIS
  use ZoneMinder::Control::C7816WIP
  Control module for for Vstarcam C7816WIP
=head1 DESCRIPTION
This module contains the implementation of the Vstarcam C7816WIP IP
camera control protocol.
=head2 EXPORT
None by default.
=head1 SEE ALSO
You can find the documentation at:
http://www.internauta37.altervista.org/en/zoneminder-control-module-vstarcam-c7816wip
=head1 AUTHOR
Philip Coombes, <[email protected]>
=head1 COPYRIGHT AND LICENSE
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.
=cut

The module C7816WIP.pm have to be put in the path:

/usr/share/perl5/ZoneMinder/Control

with permissions 644.

In Zoneminder Options>System>OPT_CONTROL √ have to be enabled.

The monitor for the Vstarcam C7816WIP can be configured as follow:

Main

Name: NAME_YOU_WANT
Source Type: Remote
Function: Modect
Enabled: √
 
Source
 
Remote Protocol: HTTP
Remote Method: Simple
Remote Host Name: IP
Remote Host Port: 81 (81 is the default port of Vstarcam C7816WIP)
Remote Host Path: /videostream.cgi?user=admin&pwd=888888 (888888 is the default password of Vstarcam C7816WIP)
Target colorspace: 24 bit colour
Capture Width (pixels): 640
Capture Width (pixels): 360
 
Control
 
Controllable: √
Control Type: Edit
Add New Control
 
Main
 
Name: C7816WIP
Type: Remote
Protocol: C7816WIP
Can Wake: √
Can Sleep: √
Can Reset: √
 
Control Type: C7816WIP
Control Device: loginuse=admin&loginpas=888888
Control Address: IP:PORT (ex. 192.168.1.100:81)

 

The Vstarcam C7816WIP can also be configured to use the ffmpeg for the video stream as follow:

Main stream:                   rtsp://admin:PWD@IP:10554/udp/av0_0       1280*720
Secondary stream:         rtsp://admin:PWD@IP:10554/udp/av0_1        640*360
The third stream:            rtsp://admin:PWD@IP:10554/udp/av0_2        320*180
Secondary stream + Audio: rtsp://admin:PWD@IP:10554/udp/av1_1  640*360

Section: 

Comments

Add new comment