NAME

IPCamera::Reolink - Reolink API provides access to the System, Security, Network, Video input, Enc, Record, PTZ, and Alarm functions of a Reolink IP Camera or NVR via HTTP(S)/REST

VERSION

1.00

SYNOPSIS

use IPCamera::Reolink;

my $camera_url = "http://192.168.1.160";
my $camera_user_name =  "vlc"; # non-admin user recommended
my $camera_password = 'this-is-a-bad-password';

my $camera = IPCamera::Reolink->new($camera_url, $camera_user_name, $camera_password);

# Optionally Login to the camera immmediately to validate the camera URL and credentials, otherwise a Login will be implicitly performed by the API on the first camera command.

die "IPCamera::Reolink::Login failed" if(!$camera->Login());

# Some camera info

my $devinfo_r = $camera->GetDevInfo();
print "Camera model : " . $devinfo_r->{model} . "\n";
print "Camera name : " . $devinfo_r->{name} . "\n";

# Start a camera pan to the left.

$camera->PtzCtrl(IPCamera::Reolink::PTZ_ChannelDefault, IPCamera::Reolink::PTZ_Left, PCamera::Reolink::PTZ_SpeedMax);

# Times passes, stop the last camera PTZ function.

$camera->PtzCtrl(IPCamera::Reolink::PTZ_ChannelDefault, IPCamera::Reolink::PTZ_Stop, PCamera::Reolink::PTZ_SpeedMin);

$camera->Logout();

DESCRIPTION

IPCamera::Reolink provides a simple way to interact with Reolink IP cameras and NVRs.

Based on the "Reolink Camera API User Guide_V8 (Updated in April 2023)" document, available here:

https://github.com/mnpg/Reolink_api_documentations

As the author is primarily interested in accessing the Pan/Tilt/Zoom (PTZ) functions of his Reolink RLC-823A-16x IP camera, only the subset of functions described in the above document needed to access these features have been implemented.

Other functions may be added in the future based on the need/whims of the author and requests from other (if any) users of this module.

ATTRIBUTES

DEBUG

Set $IPCamera::Reolink::DEBUG to a value > 0 for increasingly detailed debug output to STDERR.

default is 0 for no debug output.

VERSION

$IPCamera::Reolink::VERSION is the version of this module.

METHODS

new ($camera_url, $camera_user_name, $camera_password)

Construct a new IPCamera::Reolink object.

Takes the following manditory parameters:

camera_host_url

The camera URL for access via HTTP(S), i.e. "http://192.168.1.123".

camera_user_name

The camera account name for access via HTTP(S), i.e. "vlc".

You should set up a non admin acccount for access via this API, but the admin account will work as well but is not recommended.

camera_password

The camera account password for access via HTTP(S), i.e. "this-is-a-bad-password".

Login()

Login to the camera using the credentials provided to new() (above).

Upon successful Login the camera passes back a Login token that is used internally by IPCamera::Reolink and is passed to the remaining camera API methods.

The token is valid for the specifiec lease time.

IPCamera::Reolink will manage the Login token and will call Login() internally as needed when the Login token expires.

This should all be invisible to the caller.

return

Returns (undef, udef) if the Logon was rejected by the camera.

Returns (camera_login_token, camera_login_lease_time) if the Login is successful.

Usually the caller is not interested in this value but it is used internally by IPCamera::Reolink.

Logout()

Release Login() credentials.

return

Returns 1 if Logout() succeeded else 0 (zero) on failure, typically if Login() not called.

GetDevInfo()

Return useful information about the camera.

return

Returns undef if the GetDevInfo function failed.

Returns hash reference to device information if successful, fields most likely subject to change (typical values in parenthesis):

audioNum (1)

The number of audio channels.

B485 (0)

0: no 485, 1 :have 485

buildDay ("build 23061923")

The establish date.

cfgVer ("v3.1.0.0")

The version number of configuration information.

channelNum (1)

The number of channels.

detail ("IPC_523SD10S16E1W01100000001")

The details of device information.

diskNum (1)

The number of USB disk or SD card.

exactType ("IPC")

Product type.

firmVer ("v3.1.0.2347_23061923_v1.0.0.93")

The version number of the firmware.

frameworkVer (1)

Architecture version.

hardVer ("IPC_523SD10")

The version number of the hardware.

IOInputNum (0)

The number of IO input port.

IOOutputNum (0)

The number of IO output port.

model ("RLC-823A 16X")

Camera/NVR model.

name ("rlc-823a-16x")

Device name.

pakSuffix ("pak,paks")

?

serial ("00000000000000")

?

type ("IPC")

Device type.

wifi (0)

0: no WIFI, 1: have WIFI.

PtzCtrl($camera_channel, $camera_operation, $camera_operation_speed)

Control camera PTZ functions.

Upon successful return the camera asynchronously executes the requested operation until another operation is specified by PtzCtrl() or until the camera limit is reached for the specified operation, for example the camera has tilted as far Down as physically possible.

Some operations like IPCamera::Reolink::PTZ_Left will execute forever until another PtzCtrl command is executed.

camera_channel - perform camera operation on specified camera channel
IPCamera::Reolink::PTZ_ChannelDefault

If you are connected to a camera then there is (usually) only 1 channel.

integer >= 0

If you are connected to an NVR then there is usually one channel per attached camera starting at integer value 0.

camera_operation - camera operation to perform
IPCamera::Reolink::PTZ_Stop

PTZ stop turning.

IPCamera::Reolink::PTZ_Left

PTZ turn left in the specified speed.

IPCamera::Reolink::PTZ_Right

PTZ turn right in the specified speed.

IPCamera::Reolink::PTZ_Up

PTZ turn up in the specified speed.

IPCamera::Reolink::PTZ_Down

PTZ turn down in the specified speed.

IPCamera::Reolink::PTZ_LeftUp

PTZ turn left-up in the specified speed.

IPCamera::Reolink::PTZ_LeftDown

PTZ turn left-down in the specified speed.

IPCamera::Reolink::PTZ_RightUp

PTZ turn right-up in the specified speed.

IPCamera::Reolink::PTZ_RightDown

PTZ turn right-down in the specified speed.

IPCamera::Reolink::PTZ_IrisDec

Iris shrink in the specified speed.

IPCamera::Reolink::PTZ_IrisInc

Iris enlarge in the specified speed.

IPCamera::Reolink::PTZ_ZoomDec

Zoom in in the specified speed.

IPCamera::Reolink::PTZ_ZoomInc

Zoom out in the specified speed.

IPCamera::Reolink::PTZ_FocusDec

Focus backwards in the specified speed.

IPCamera::Reolink::PTZ_FocusInc

Focus forwards in the specified speed.

IPCamera::Reolink::PTZ_Auto

PTZ turn auto in the specified speed.

IPCamera::Reolink::PTZ_StartPatrol

PTZ patrol in the specified speed.

IPCamera::Reolink::PTZ_StopPatrol

PTZ stop patrol.

IPCamera::Reolink::PTZ_ToPos

PTZ turn to a specified preset in the specified speed.

camera_operation_speed - perform camera operation at the specified speed
IPCamera::Reolink::PTZ_SpeedMin

Minimum camera operation speed.

PTZ_SpeedMin::PTZ_SpeedMax

Maximum camera operation speed.

PTZ_SpeedMin::PTZ_SpeedHalf

1/2 Maximum camera operation speed.

GetZoomFocus($camera_channel)

Return camera current Zoom and Focus values.

camera_channel - perform camera operation on specified camera channel
IPCamera::Reolink::PTZ_ChannelDefault

If you are connected to a camera then there is (usually) only 1 channel.

integer >= 0

If you are connected to an NVR then there is usually one channel per attached camera starting at integer value 0.

return

Returns undef if the GetZoomFocus function failed.

Returns hash reference to Zoom/Focus information if successful, fields most likely subject to change (typical values in parenthesis):

channel (0)

Camera channel.

focus->{pos} (23)

Current camera focus value.

zoom->{pos} (0)

Current camera zoom value.

StartZoomFocus($camera_channel, $camera_operation, $camera_zoom_pos|$camera_focus_pos)

Set camera current Zoom or Focus value.

Note that the current version of the firmware on the authors camera (Firmware Version v3.1.0.2347_23061923_v1.0.0.93) requires a Login() using admin credentials to use this function. According to Reolink this may be fixed in a future firmware version.

If in doubt, set $DEBUG to 1 and if you see a log message of the form:

Tue Dec 19 18:17:07 2023: debug: IPCamera::Reolink::_sendCameraCommand(): command 'StartZoomFocus' token '5b34aab0bb481ba' request '[{ action => 0, cmd => "StartZoomFocus", param => { ZoomFocus => { channel => 0, op => "ZoomPos", pos => 1 } } }]' response '[{ cmd => "StartZoomFocus", code => 1, error => { detail => "ability error", rspCode => -26 } }]' time 0.0480499267578125 seconds

then you need to use admin credentials to use this function.

camera_channel - perform camera operation on specified camera channel
IPCamera::Reolink::PTZ_ChannelDefault

If you are connected to a camera then there is (usually) only 1 channel.

integer >= 0

If you are connected to an NVR then there is usually one channel per attached camera starting at integer value 0.

camera_operation - camera operation to perform
IPCamera::Reolink::ZF_ZoomPos

Set Zoom to specified pos value.

camera_zoom_pos - set the camera Zoom to the specified pos value.
IPCamera::Reolink::ZF_ZoomPosMin

Minimum camera zoom value.

IPCamera::Reolink::ZF_ZoomPosMax

Maximum camera zoom value.

IPCamera::Reolink::ZF_FocusPos

Set Focus to specified pos value.

camera_focus_pos - set the camera Focus to the specified pos value.
IPCamera::Reolink::ZF_FocusPosMin

Minimum camera focus value.

IPCamera::Reolink::ZF_FocusPosMax

Maximum camera focus value.

GetOsd($camera_channel)

Return camera current, range and inital On Screen Display (OSD) values.

camera_channel - perform camera operation on specified camera channel
IPCamera::Reolink::PTZ_ChannelDefault

If you are connected to a camera then there is (usually) only 1 channel.

integer >= 0

If you are connected to an NVR then there is usually one channel per attached camera starting at integer value 0.

return

Returns (undef, undef, undef) if the GetOsd function failed or ($osd_value_r, $osd_range_r, $osd_initial_r) on success, hash references to OSD current value, range and initial values information if successful, fields most likely subject to change (typical values in parenthesis):

osd_value_r

Hash reference to current camera OSD values.

$osd_value_r->{Osd}

Current camera OSD values.

$osd_value_r->{Osd}->{bgcolor} (0/1)

Current camera OSD background color disabled (0) or enabled (1).

$osd_value_r->{Osd}->{channel} (0)
IPCamera::Reolink::PTZ_ChannelDefault

If you are connected to a camera then there is (usually) only 1 channel.

integer >= 0

If you are connected to an NVR then there is usually one channel per attached camera starting at integer value 0.

$osd_value_r->{Osd}->{osdChannel}

Current OSD values for specified camera channel.

$osd_value_r->{Osd}->{osdChannel}->{enable} (0/1)

OSD enabled if 1 else disabled if 0.

$osd_value_r->{Osd}->{osdChannel}->{name} ("rlc-823a-16x")

OSD display value.

$osd_value_r->{Osd}->{osdChannel}->{pos} ("Lower Right")

OSD display position.

$osd_value_r->{Osd}->{osdTime}

Current OSD time display values for specified camera channel.

$osd_value_r->{Osd}->{osdTime}->{enable} (0/1)

OSD time display enabled if 1 else disabled if 0.

$osd_value_r->{Osd}->{osdTime}->{pos} ("Lower Right")

OSD time display position.

osd_range_r

Hash reference to camera OSD value ranges.

TBD
osd_initial_r

Hash reference to camera OSD initial values.

TBD

SetOsd($camera_channel, $enableChannel, $channelName, $channelPos, $enableTime, $timePos)

Set camera On Screen Display (OSD) values.

Note that the current version of the firmware on the authors camera (Firmware Version v3.1.0.2347_23061923_v1.0.0.93) requires a Login() using admin credentials to use this function.

camera_channel - perform camera operation on specified camera channel
IPCamera::Reolink::PTZ_ChannelDefault

If you are connected to a camera then there is (usually) only 1 channel.

integer >= 0

If you are connected to an NVR then there is usually one channel per attached camera starting at integer value 0.

enableChannel (0/1)

1 to enable display of channelName else 0

channelName ("rlc-823a-16x")

Channel OSD text to display

channelPos ("Lower Right") - Channel OSD text position
IPCamera::Reolink::OSD_UpperLeft

OSD position "Upper Left"

IPCamera::Reolink::OSD_TopCenter

OSD position "Top Center"

IPCamera::Reolink::OSD_UpperRight

OSD position "Upper Right"

IPCamera::Reolink::OSD_LowerLeft

OSD position "Lower Left"

IPCamera::Reolink::OSD_BottomCenter

OSD position "Bottom Center"

IPCamera::Reolink::OSD_LowerRight

OSD position "Lower Right"

enableTime

1 to enable display of date/time else 0

timePos ("Upper Left") - Date/Time OSD text position
IPCamera::Reolink::OSD_UpperLeft

OSD position "Upper Left"

IPCamera::Reolink::OSD_TopCenter

OSD position "Top Center"

IPCamera::Reolink::OSD_UpperRight

OSD position "Upper Right"

IPCamera::Reolink::OSD_LowerLeft

OSD position "Lower Left"

IPCamera::Reolink::OSD_BottomCenter

OSD position "Bottom Center"

IPCamera::Reolink::OSD_LowerRight

OSD position "Lower Right"

AUTHOR

Stephen Oberski, <cpan at cargocult.ca>

BUGS

Please report any bugs or feature requests to bug-ipcamera-reolink at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPCamera-Reolink. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc IPCamera::Reolink

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by Stephen Oberski.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)