Snapshot requests (cmd 109): a JPEG of the current frame.

The image does not come in the reply. The reply only announces its size, and the image follows in more messages with the same message id:

cmd 109, snapshotXml   ->  <Snap><pictureSize>48213</pictureSize></Snap>
                       ->  payload chunk, payload chunk, ...
                       ->  a message with no payload: the image is done

Each chunk may be partly AES-encrypted, see decryptPayload in @hertzg/reolink-api/protocol/message.

Examples

Build a request and read the announced size

import { assertEquals, assertStringIncludes } from "@std/assert";
import {
  parseSnapshotSize,
  snapshotXml,
} from "@hertzg/reolink-api/protocol/snapshot";

assertStringIncludes(
  snapshotXml({ channel: 0, stream: "main" }),
  "<streamType>main</streamType>",
);
assertEquals(
  parseSnapshotSize("<body><Snap><pictureSize>48213</pictureSize></Snap></body>"),
  48213,
);

Functions

f
parseSnapshotSize(xml: string): number

Reads the announced image size from the reply to a snapshot request.

f
snapshotXml(request: SnapshotRequest): string

Builds the body of a snapshot request.

Type Aliases

T
SnapshotRequest = { channel: number; stream: "main" | "sub"; }

What snapshotXml asks for.