motionDetection(target: MotionDetectionTarget): Resource<MotionDetection>
The motion detection resource of one channel.
The path is the NVR's input proxy copy when proxy is set and the device's
own video input otherwise. grid is set when the document has a
<gridMap> and a <Grid> to size it, regions when its <RegionList>
has entries.
Both paths
Both paths
import { assertEquals } from "@std/assert"; import { motionDetection } from "./motion-detection.ts"; assertEquals( motionDetection({ channel: 3, proxy: true }).path, "/ISAPI/ContentMgmt/InputProxy/channels/3/video/motionDetection", ); assertEquals( motionDetection({ channel: 1 }).path, "/ISAPI/System/Video/inputs/channels/1/motionDetection", );
Read channel 2 through an NVR
Read channel 2 through an NVR
import { assertEquals } from "@std/assert"; import { resolvesNext, spy } from "@std/testing/mock"; import { request } from "../request.ts"; import { motionDetection } from "./motion-detection.ts"; const fetch = spy(resolvesNext([ new Response( "<MotionDetection><enabled>false</enabled>" + "<Grid><rowGranularity>1</rowGranularity><columnGranularity>8</columnGranularity></Grid>" + "<MotionDetectionLayout><layout><gridMap>0f</gridMap></layout></MotionDetectionLayout>" + "</MotionDetection>", ), ])); const motion = await request( { baseUrl: "http://192.0.2.10", username: "admin", password: "hunter2", fetch }, motionDetection({ channel: 2, proxy: true }), ); assertEquals(motion.grid, [[false, false, false, false, true, true, true, true]]); assertEquals( fetch.calls[0].args[0], "http://192.0.2.10/ISAPI/ContentMgmt/InputProxy/channels/2/video/motionDetection", );
target: MotionDetectionTarget
Which channel, and whether through an NVR's input proxy.
The resource: its path, and a codec that decodes the grid.