onvif: preset support

This commit is contained in:
Koushik Dutta
2024-10-04 15:23:46 -07:00
parent b492e8912e
commit b71f6e8b7e
5 changed files with 48 additions and 9 deletions

View File

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

View File

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

View File

@@ -79,23 +79,53 @@ export class OnvifPtzMixin extends SettingsMixinDeviceBase<Settings> implements
if (e)
return f(e);
r();
})
});
})
}
else if (movement === PanTiltZoomMovement.Continuous) {
let x= command.pan;
let y = command.tilt;
let zoom = command.zoom;
if (command.speed?.pan)
x *= command.speed.pan;
if (command.speed?.tilt)
y *= command.speed.tilt;
if (command.speed?.zoom)
zoom *= command.speed.zoom;
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);
r();
})
})
});
}
else if (movement === PanTiltZoomMovement.Home) {
return new Promise<void>((r, f) => {
client.cam.gotoHomePosition({
speed: speed,
}, (e, result, xml) => {
if (e)
return f(e);
r();
})
});
}
else if (movement === PanTiltZoomMovement.Preset) {
return new Promise<void>((r, f) => {
client.cam.gotoPreset({
preset: command.preset,
}, (e, result, xml) => {
if (e)
return f(e);
r();
})
});
}
else {
// relative movement is default.
@@ -110,7 +140,7 @@ export class OnvifPtzMixin extends SettingsMixinDeviceBase<Settings> implements
return f(e);
r();
})
})
});
}
}

View File

@@ -65,6 +65,8 @@ class PanTiltZoomMovement(str, Enum):
Absolute = "Absolute"
Continuous = "Continuous"
Home = "Home"
Preset = "Preset"
Relative = "Relative"
class ScryptedDeviceType(str, Enum):
@@ -709,8 +711,9 @@ class PanTiltZoomCapabilities(TypedDict):
class PanTiltZoomCommand(TypedDict):
movement: PanTiltZoomMovement # Specify the movement origin. If unspecified, the movement will be relative to the current position.
movement: PanTiltZoomMovement # Specify the movement type. If unspecified, the movement will be relative to the current position.
pan: float # Ranges between -1 and 1.
preset: str # The preset to move to.
speed: Any # The speed of the movement.
tilt: float # Ranges between -1 and 1.
timeout: float # The duration of the movement in milliseconds.

View File

@@ -951,11 +951,13 @@ export enum PanTiltZoomMovement {
Absolute = "Absolute",
Relative = "Relative",
Continuous = "Continuous",
Preset = "Preset",
Home = 'Home',
}
export interface PanTiltZoomCommand {
/**
* Specify the movement origin. If unspecified, the movement will be relative to the current position.
* Specify the movement type. If unspecified, the movement will be relative to the current position.
*/
movement?: PanTiltZoomMovement;
/**
@@ -991,6 +993,10 @@ export interface PanTiltZoomCommand {
* The duration of the movement in milliseconds.
*/
timeout?: number;
/**
* The preset to move to.
*/
preset?: string;
}
export interface PanTiltZoomCapabilities {