{
+ return (await this.info(t)).zoom;
+ }
+
private async ptz(t: OnvifTarget): Promise<{ url: string; profile: string; auth: { username: string; password: string; offsetMs: number } }> {
const i = await this.info(t);
if (!i.ptzUrl || !i.profile) throw new Error("Camera does not support PTZ over ONVIF");
diff --git a/server/test/misc.test.ts b/server/test/misc.test.ts
index 49e7cbc..36c2023 100644
--- a/server/test/misc.test.ts
+++ b/server/test/misc.test.ts
@@ -4,7 +4,7 @@ import { parseDemoUrls } from "../src/config.ts";
import { titleCase, demoSource, demoId } from "../src/demo.ts";
import { unzipEntries } from "../src/deps.ts";
import { dayBounds } from "../src/recordings.ts";
-import { wsseHeader, tagValues, attrValues } from "../src/onvif.ts";
+import { wsseHeader, tagValues, attrValues, zoomFromNodes } from "../src/onvif.ts";
import { parseProbeMatch, scopeValue, guessBrand } from "../src/discovery.ts";
import { rcloneToken } from "../src/storage/gdrive.ts";
import { redact } from "../src/log.ts";
@@ -138,3 +138,22 @@ describe("misc", () => {
expect(matchParts(["s", ":site", "*"], ["s", "a", "api", "x"])).toEqual({ site: "a", "*": "api/x" });
});
});
+
+describe("onvif zoom detection", () => {
+ const node = (spaces: string) =>
+ `${spaces}`;
+ const pt = "u";
+ test("pan/tilt only means no zoom", () => {
+ expect(zoomFromNodes(node(pt))).toBe(false);
+ });
+ test("a zoom movement space means zoom", () => {
+ expect(zoomFromNodes(node(pt + "u"))).toBe(true);
+ expect(zoomFromNodes(node(pt + "u"))).toBe(true);
+ });
+ test("zoom speed alone is not zoom", () => {
+ expect(zoomFromNodes(node(pt + "u"))).toBe(false);
+ });
+ test("unknown when spaces are missing", () => {
+ expect(zoomFromNodes("")).toBeUndefined();
+ });
+});
diff --git a/server/web/src/components/LiveViewer.tsx b/server/web/src/components/LiveViewer.tsx
index 06435d7..484b371 100644
--- a/server/web/src/components/LiveViewer.tsx
+++ b/server/web/src/components/LiveViewer.tsx
@@ -115,13 +115,13 @@ export function LiveViewer({
)}
- {camera.capabilities.ptz && camera.status.online && }
+ {camera.capabilities.ptz && camera.status.online && }
);
}
-function PtzPad({ cameraId }: { cameraId: string }) {
+function PtzPad({ cameraId, zoom }: { cameraId: string; zoom: boolean }) {
const moving = useRef(false);
const start = (pan: number, tilt: number, zoom: number) => (e: RPointerEvent) => {
e.preventDefault();
@@ -160,10 +160,12 @@ function PtzPad({ cameraId }: { cameraId: string }) {
{btn('Pan right', 0.6, 0, 0, , 'ptz-right')}
{btn('Tilt down', 0, -0.6, 0, , 'ptz-down')}
-
- {btn('Zoom in', 0, 0, 0.6, , '')}
- {btn('Zoom out', 0, 0, -0.6, , '')}
-
+ {zoom && (
+
+ {btn('Zoom in', 0, 0, 0.6, , '')}
+ {btn('Zoom out', 0, 0, -0.6, , '')}
+
+ )}
);
}
diff --git a/server/web/src/types.ts b/server/web/src/types.ts
index e35e354..c719e22 100644
--- a/server/web/src/types.ts
+++ b/server/web/src/types.ts
@@ -70,7 +70,7 @@ export interface Camera {
source: { kind: SourceKind | string; url: string; subUrl?: string };
recording: { mode: RecordingMode; useSubstream: boolean };
motion: { enabled: boolean; sensitivity: number; notify: boolean };
- capabilities: { audio: boolean; twoWayAudio: boolean; ptz: boolean; substream: boolean };
+ capabilities: { audio: boolean; twoWayAudio: boolean; ptz: boolean; substream: boolean; ptzZoom?: boolean };
status: {
online: boolean;
recording: boolean;