matterbridge-example-camera 0.0.2-dev-20260714-b39fe14 → 0.0.2-dev-20260714-1646dcf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -39,6 +39,7 @@ If you like this project and find it useful, please consider giving it a star on
39
39
  - [chime]: Add validation in `MatterbridgeChimeServer.playChimeSound` to reject a `chimeId` that is not present in `installedChimeSounds` with a `NotFound` status response.
40
40
  - [snapshot camera]: Add the Snapshot Camera device with configurable snapshot capabilities, stream allocation, stream priorities, snapshot capture, Identify, and Power Source support.
41
41
  - [snapshot camera]: Add `MatterbridgeCameraAvStreamManagementServer` with the Snapshot and Image Control features.
42
+ - [snapshot camera]: Add to `MatterbridgeCameraAvStreamManagementServer` a real jpeg image to allow test.
42
43
 
43
44
  ### Changed
44
45
 
@@ -2,6 +2,7 @@ import { MatterbridgeServer } from 'matterbridge/behaviors';
2
2
  import { CameraAvStreamManagementServer } from 'matterbridge/matter/behaviors';
3
3
  import { CameraAvStreamManagement } from 'matterbridge/matter/clusters';
4
4
  import { Status, StatusResponseError } from 'matterbridge/matter/types';
5
+ import { getSnapshotPayload } from '../werift/snapshot.js';
5
6
  export class MatterbridgeCameraAvStreamManagementServer extends CameraAvStreamManagementServer.with(CameraAvStreamManagement.Feature.Snapshot, CameraAvStreamManagement.Feature.ImageControl) {
6
7
  async snapshotStreamAllocate(request) {
7
8
  const device = this.endpoint.stateOf(MatterbridgeServer);
@@ -39,9 +40,10 @@ export class MatterbridgeCameraAvStreamManagementServer extends CameraAvStreamMa
39
40
  async captureSnapshot(request) {
40
41
  const device = this.endpoint.stateOf(MatterbridgeServer);
41
42
  device.log.info(`Capturing snapshot ${request.snapshotStreamId ?? 'auto'} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
42
- device.log.debug(`MatterbridgeCameraAvStreamManagementServer: captureSnapshot called with snapshotStreamId ${request.snapshotStreamId}`);
43
+ const snapshotPayload = await getSnapshotPayload();
44
+ device.log.debug(`MatterbridgeCameraAvStreamManagementServer: returning snapshot payload with ${snapshotPayload.length} bytes`);
43
45
  return {
44
- data: new Uint8Array(0),
46
+ data: snapshotPayload,
45
47
  imageCodec: CameraAvStreamManagement.ImageCodec.Jpeg,
46
48
  resolution: request.requestedResolution,
47
49
  };
@@ -0,0 +1,40 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ const FALLBACK_SNAPSHOT_JPEG = new Uint8Array([
4
+ 255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 1, 0, 72, 0, 72, 0, 0, 255, 219, 0, 67, 0, 8, 6, 6, 7, 6, 5, 8, 7, 7,
5
+ 7, 9, 9, 8, 10, 12, 20, 13, 12, 11, 11, 12, 25, 18, 19, 15, 20, 29, 26, 31, 30, 29, 26, 28, 28, 32, 36, 46, 39, 32, 34, 44,
6
+ 35, 28, 28, 40, 55, 41, 44, 48, 49, 52, 52, 52, 31, 39, 57, 61, 56, 50, 60, 46, 51, 52, 50, 255, 219, 0, 67, 1, 9, 9, 9, 12,
7
+ 11, 12, 24, 13, 13, 24, 50, 33, 28, 33, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
8
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 255,
9
+ 192, 0, 17, 8, 0, 1, 0, 1, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, 255, 196, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
10
+ 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 196, 0, 181, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 1, 2,
11
+ 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240,
12
+ 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72,
13
+ 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 131,
14
+ 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170,
15
+ 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216,
16
+ 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 255, 196, 0,
17
+ 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 196, 0, 181, 17, 0,
18
+ 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129,
19
+ 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39,
20
+ 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103,
21
+ 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150,
22
+ 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196,
23
+ 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242,
24
+ 243, 244, 245, 246, 247, 248, 249, 250, 255, 218, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0, 248, 254, 138, 40, 175, 204, 207,
25
+ 255, 217,
26
+ ]);
27
+ let cachedSnapshotPayload;
28
+ export async function getSnapshotPayload() {
29
+ if (cachedSnapshotPayload !== undefined) {
30
+ return cachedSnapshotPayload;
31
+ }
32
+ try {
33
+ const snapshotPath = path.resolve(process.cwd(), 'assets', 'snapshots', 'cartoon-sample-1280x720.jpg');
34
+ cachedSnapshotPayload = new Uint8Array(await readFile(snapshotPath));
35
+ }
36
+ catch {
37
+ cachedSnapshotPayload = FALLBACK_SNAPSHOT_JPEG;
38
+ }
39
+ return cachedSnapshotPayload;
40
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge-example-camera",
3
- "version": "0.0.2-dev-20260714-b39fe14",
3
+ "version": "0.0.2-dev-20260714-1646dcf",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge-example-camera",
9
- "version": "0.0.2-dev-20260714-b39fe14",
9
+ "version": "0.0.2-dev-20260714-1646dcf",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "node-ansi-logger": "3.3.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-example-camera",
3
- "version": "0.0.2-dev-20260714-b39fe14",
3
+ "version": "0.0.2-dev-20260714-1646dcf",
4
4
  "description": "Matterbridge camera example plugin",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",