PTZ (pan, tilt, zoom) requests.
cmd 18, ptzControlXml -> empty status-200 reply; moves until "Stop" cmd 19, ptzPresetXml -> empty status-200 reply cmd 190, no body -> <PtzPreset><presetList><preset>...</preset> cmd 433, no body -> <ptzCurPos><pPos>...</pPos><tPos>...</tPos>
Cameras that push no PTZ state can only tell a move has finished by polling cmd 433 until the position stops changing.
All three address the channel through the message extension.
Pan left, then stop
Pan left, then stop
import { assertStringIncludes } from "@std/assert"; import { PTZ_COMMAND, ptzControlXml } from "@hertzg/reolink-api/protocol/ptz"; assertStringIncludes( ptzControlXml({ channel: 0, command: PTZ_COMMAND.LEFT, speed: 32 }), "<command>Left</command>", ); assertStringIncludes( ptzControlXml({ channel: 0, command: PTZ_COMMAND.STOP }), "<command>Stop</command>", );
Reads the current position from the reply to a cmd 433 request.
Reads the saved presets from the reply to a cmd 190 request.
Builds the body of a PTZ move (cmd 18).
Builds the body of a request that moves to a saved preset (cmd 19).
Union of the PTZ_COMMAND values.
What ptzControlXml asks the camera to do.
-
channel: number
The zero-based channel number.
-
command: PtzCommand
The move to make.
-
speed: number
Move speed. Leave it out for the camera's default.
Where the camera points, in the camera's own motor units.
-
pan: number
Pan position (
pPos). Wraps around on cameras that turn a full circle. -
tilt: number
Tilt position (
tPos).
A saved PTZ position.
-
id: number
The id to pass to ptzPresetXml.
-
name: string
The name it was saved under.
PTZ commands for ptzControlXml. A move keeps going until STOP.
-
AUTO: string
Start the camera's automatic scan.
-
DOWN: string
Tilt down.
-
LEFT: string
Pan left.
-
LEFT_DOWN: string
Pan left and tilt down.
-
LEFT_UP: string
Pan left and tilt up.
-
RIGHT: string
Pan right.
-
RIGHT_DOWN: string
Pan right and tilt down.
-
RIGHT_UP: string
Pan right and tilt up.
-
STOP: string
Stop any move or zoom.
-
UP: string
Tilt up.
-
ZOOM_IN: string
Zoom in.
-
ZOOM_OUT: string
Zoom out.
Usage
import * as mod from "protocol/ptz.ts";