onvif: continuous movement support

This commit is contained in:
Koushik Dutta
2024-10-04 14:57:29 -07:00
parent e663f5d3fc
commit b492e8912e
6 changed files with 44 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
{
"scrypted.debugHost": "127.0.0.1",
"scrypted.debugHost": "scrypted-nvr",
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/onvif",
"version": "0.1.24",
"version": "0.1.25",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@scrypted/onvif",
"version": "0.1.24",
"version": "0.1.25",
"license": "Apache",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/onvif",
"version": "0.1.24",
"version": "0.1.25",
"description": "ONVIF Camera Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",

View File

@@ -25,7 +25,19 @@ export class OnvifPtzMixin extends SettingsMixinDeviceBase<Settings> implements
zoom: ptz.includes('Zoom'),
}
}
}
},
ptzMovementType: {
title: 'PTZ Movement Type',
description: 'The type of movement to use for PTZ commands by default.',
type: 'string',
choices: [
'Default',
PanTiltZoomMovement.Absolute,
PanTiltZoomMovement.Relative,
PanTiltZoomMovement.Continuous,
],
defaultValue: 'Default',
},
});
constructor(options: SettingsMixinDeviceOptions<Settings>) {
@@ -55,13 +67,29 @@ export class OnvifPtzMixin extends SettingsMixinDeviceBase<Settings> implements
};
}
if (command.movement === PanTiltZoomMovement.Absolute) {
let movement = command.movement || this.storageSettings.values.ptzMovementType;
if (movement === PanTiltZoomMovement.Absolute) {
return new Promise<void>((r, f) => {
client.cam.absoluteMove({
x: command.pan,
y: command.tilt,
zoom: command.zoom,
speed: speed
speed: speed,
}, (e, result, xml) => {
if (e)
return f(e);
r();
})
})
}
else if (movement === PanTiltZoomMovement.Continuous) {
return new Promise<void>((r, f) => {
client.cam.continuousMove({
x: command.pan,
y: command.tilt,
zoom: command.zoom,
speed: speed,
timeout: command.timeout || 1000,
}, (e, result, xml) => {
if (e)
return f(e);

View File

@@ -64,6 +64,7 @@ class MediaPlayerState(str, Enum):
class PanTiltZoomMovement(str, Enum):
Absolute = "Absolute"
Continuous = "Continuous"
Relative = "Relative"
class ScryptedDeviceType(str, Enum):
@@ -712,6 +713,7 @@ class PanTiltZoomCommand(TypedDict):
pan: float # Ranges between -1 and 1.
speed: Any # The speed of the movement.
tilt: float # Ranges between -1 and 1.
timeout: float # The duration of the movement in milliseconds.
zoom: float # Ranges between 0 and 1 for max zoom.
class Position(TypedDict):

View File

@@ -949,7 +949,8 @@ export interface VideoCameraMask {
export enum PanTiltZoomMovement {
Absolute = "Absolute",
Relative = "Relative"
Relative = "Relative",
Continuous = "Continuous",
}
export interface PanTiltZoomCommand {
@@ -985,7 +986,11 @@ export interface PanTiltZoomCommand {
* Ranges between 0 and 1 for max zoom.
*/
zoom?: number;
}
};
/**
* The duration of the movement in milliseconds.
*/
timeout?: number;
}
export interface PanTiltZoomCapabilities {