mirror of
https://github.com/koush/scrypted.git
synced 2026-03-20 08:30:24 +00:00
onvif: continuous movement support
This commit is contained in:
2
plugins/onvif/.vscode/settings.json
vendored
2
plugins/onvif/.vscode/settings.json
vendored
@@ -1,4 +1,4 @@
|
||||
|
||||
{
|
||||
"scrypted.debugHost": "127.0.0.1",
|
||||
"scrypted.debugHost": "scrypted-nvr",
|
||||
}
|
||||
4
plugins/onvif/package-lock.json
generated
4
plugins/onvif/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user