matterbridge-example-camera 0.0.9-dev-20260727-771e037 → 0.1.0

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
@@ -28,7 +28,43 @@ If you like this project and find it useful, please consider giving it a star on
28
28
 
29
29
  <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="120"></a>
30
30
 
31
- ## [0.0.9] - Deb branch
31
+ ## [0.1.0] - Dev branch
32
+
33
+ ### Added
34
+
35
+ - [camera]: Bump MatterbridgeWebRtcTransportProviderServer v.2.0.0.
36
+ - [camera]: Bump MatterbridgeCameraAvStreamManagementServer v.2.0.0.
37
+ - [chip]: Add chip test toolchain.
38
+
39
+ <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="120"></a>
40
+
41
+ ## [0.0.9] - Not published
42
+
43
+ ### Added
44
+
45
+ - [Dev Container]: Update Dev Container v.1.2.0.
46
+ - [scripts]: Add `scripts/run-chip-tests.mjs` to manage the `luligu/matterbridge:chip-test` docker container and run the CHIP python test suite defined in `chipTests.json`. `--start` builds and adds the plugin to a fresh container, `--stop` stops it and restores the local dev environment (reinstall, relink, rebuild), `--test NAME` filters to matching tests, and results are logged to `chipTests.log`.
47
+ - [scripts]: `run-chip-tests.mjs` now supports a per-test `"reset": true` field in `chipTests.json` that clears persisted stateful cluster storage and restarts the plugin (without recreating the container) before a test that needs a clean device state, and a per-test `"comment"` field that documents a known/expected failure, printed under its ❌ line in the run summary. The run summary is also written to `chipTestsSummary.log`, separate from the full `chipTests.log`.
48
+ - [tests]: Add `TC_AVSUM_2_1`, `TC_AVSUM_2_2`, `TC_AVSUM_2_3` and `TC_AVSUM_2_9` (Camera AV Settings User Level Management / Mechanical PTZ) to `chipTests.json` and the README, running against the `PTZCamera` example device (endpoint 7).
49
+ - [camera]: Add a `MATTERBRIDGE_STRICT_WEBRTCTRANSPORT` environment variable for `MatterbridgeWebRtcTransportProviderServer.solicitOffer`/`provideOffer`. When set to `1`: (1) a request with none of `videoStreams`, `audioStreams`, `videoStreamId` or `audioStreamId` present is rejected with `INVALID_COMMAND`, matching the Matter specification's choice conformance for these commands; (2) `videoStreams`/`audioStreams` are resolved and validated against `AllocatedVideoStreams`/`AllocatedAudioStreams` per Matter 1.6/1.5.1 §11.5.6.1.10/§11.5.6.3.5 — `INVALID_IN_STATE` when nothing is allocated, `ALREADY_EXISTS` on duplicate ids, `DYNAMIC_CONSTRAINT_ERROR` when an id isn't allocated — instead of the default lenient auto-allocate-on-demand behavior. Fixes the CHIP WebRTC Transport Provider conformance test suite's expectations (`TC_WEBRTCP_2_2`, `2_3`, `2_5`, `2_27`, `2_28`, `2_29`, `2_31`; `2_3`/`2_29` now fully pass, `2_5`/`2_31` progress past this scenario into an unrelated, still-open `StreamUsage` validation gap). Left unset (the default), behavior is completely unchanged: a completely empty request triggers automatic stream selection, and a present stream id/list is used without validating it against `Allocated*Streams` at all — required for compatibility with real clients observed in production that never call `VideoStreamAllocate`/`AudioStreamAllocate` (e.g. SmartThings, and Home Assistant's Matter camera integration).
50
+ - [tests]: Add coverage for `MATTERBRIDGE_STRICT_WEBRTCTRANSPORT`'s `Allocated*Streams` validation in `vitest/behaviors/webRtcTransportProviderServer.test.ts` (up to 53 tests, 100% statements/branches/functions/lines maintained project-wide).
51
+ - [camera]: `MatterbridgeCameraAvStreamManagementServer` now self-allocates a default video/audio/snapshot stream on construction for any feature the endpoint supports that has none allocated yet (`Camera`, `SnapshotCamera`, `AudioDoorbell`, `Intercom`, and the composite `FloodlightCamera`/`VideoDoorbell`), so `AllocatedVideoStreams`/`AllocatedAudioStreams`/`AllocatedSnapshotStreams` are never unexpectedly empty for a client that never calls `VideoStreamAllocate`/`AudioStreamAllocate`/`SnapshotStreamAllocate` itself (e.g. SmartThings in production) or after matter.js legitimately discards persisted state on a `FeatureMap` change between restarts. Add a `MATTERBRIDGE_SKIP_AUTO_ALLOCATE_CAMERA_AV_STREAM_MANAGEMENT` environment variable to disable this (set to `1`) for the CHIP conformance suite, whose `TC_AVSM_2_2`/`TC_AVSM_2_5` assert the lists are empty immediately after commissioning — see `chipTests.md`'s "Camera AV Stream Management — Default Stream Self-Allocation" for the full rationale and verification. The self-allocated default snapshot stream's `minResolution`/`maxResolution` now span the full range of the endpoint's `snapshotCapabilities` (smallest to largest entry) instead of a single fixed point (the first/smallest entry), so a real client requesting any of the device's own advertised snapshot resolutions dedup-matches this default stream in `snapshotStreamAllocate` (Matter 1.6/1.5.1 §11.2.8.8.8) instead of allocating an unwanted duplicate — confirmed against a real `python-matter-server` dashboard trace that previously allocated a second, orphaned snapshot stream for exactly this reason.
52
+
53
+ ### Changed
54
+
55
+ - [screenshots]: Update screenshots.
56
+
57
+ ### Fixed
58
+
59
+ - [chime]: `MatterbridgeChimeServer` now rejects writes to the `SelectedChime` attribute with `NOT_FOUND` when the written chime ID is not present in `InstalledChimeSounds`, per Matter 1.6 Application Cluster spec §11.8.5.2. Previously any value was silently accepted, failing `TC_CHIME_2_3`.
60
+ - [camera]: `CameraAvStreamManagement.captureSnapshot` now rejects with `NOT_FOUND` when the requested `snapshotStreamId` (or automatic selection with no allocated snapshot stream) does not match an entry in `AllocatedSnapshotStreams`, per Matter 1.6 §11.2.8.13. Previously it always returned a snapshot. Fixed `TC_AVSM_2_10`.
61
+ - [camera]: `SnapshotStreamAllocate` now reuses an existing snapshot stream whose resolution range overlaps the request (narrowing its stored resolution to the new range) instead of only matching on exact field equality, per Matter 1.6 §11.2.8.8.8. Fixed `TC_AVSM_2_15` and `TC_AVSM_StreamReuseRangeParams`.
62
+ - [camera]: `VideoStreamAllocate` now enforces `MaxConcurrentEncoders`, rejecting a new (non-reused) allocation with `RESOURCE_EXHAUSTED` once the limit is reached, and validates the `MinFrameRate`/`MaxFrameRate` and `MinBitRate`/`MaxBitRate` cross-field constraints ("1 to Max...", Matter 1.6 §11.2.8.4) with `CONSTRAINT_ERROR`, neither of which matter.js enforces automatically.
63
+ - [camera]: `MPTZSetPosition` and `MPTZRelativeMove` now reject with `INVALID_COMMAND` when all of their fields (pan/tilt/zoom, or panDelta/tiltDelta/zoomDelta) are omitted, per Matter 1.6 §11.3.7. Previously an empty command was silently accepted as a no-op. Fixed `TC_AVSUM_2_2` and `TC_AVSUM_2_3`.
64
+ - [camera]: Remove the temporary `ImageControl` feature workaround from Audio Doorbell and Intercom, now that the underlying matter.js choice-conformance bug (ImageRotation/ImageFlipHorizontal/ImageFlipVertical enforced unconditionally instead of only when `ImageControl` is enabled) is fixed upstream. Both device types now correctly omit `ImageControl` and its attributes, matching the Matter specification for their device type. Also removed the now-obsolete `comment` on `TC_DeviceConformance` in `chipTests.json`.
65
+ - [camera]: Remove the same now-unneeded `ImageControl` attributes from Snapshot Camera (Snapshot feature only). Camera keeps `ImageControl` enabled: unlike the other three device types, its `webRtcTransportProviderServer.ts` automatic stream assignment gates on `endpoint.behaviors.has(MatterbridgeCameraAvStreamManagementServer)`, an exact match against that base class's declared Video/Audio/Snapshot/ImageControl feature set, so dropping `ImageControl` there breaks WebRTC `SolicitOffer`/`ProvideOffer` auto-assignment.
66
+ - [tests]: Add `SelectedChime` write coverage (accepted and rejected chime IDs) in `vitest/behaviors/chimeServer.test.ts`.
67
+ - [tests]: Add coverage for all the `CameraAvStreamManagement` and `CameraAvSettingsUserLevelManagement` fixes above in `vitest/behaviors/cameraAvStreamManagementServer.test.ts` and `vitest/behaviors/cameraAvSettingsUserLevelManagementServer.test.ts` (both files at 100% statements/branches/functions/lines).
32
68
 
33
69
  <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="120"></a>
34
70
 
package/README.md CHANGED
@@ -38,29 +38,30 @@ Thanks to [Ludovic BOUÉ](https://github.com/lboue) for his contributions to thi
38
38
 
39
39
  ## Requirements
40
40
 
41
- Requires [`ffmpeg`](https://ffmpeg.org/) to be installed. The resolver checks the system command and common installation directories on Linux, macOS, and Windows.
41
+ Requires [`ffmpeg`](https://ffmpeg.org/) to be installed on the host or in the container. The resolver checks the system command and common installation directories on Linux, macOS, and Windows.
42
42
 
43
43
  Install it with the platform's package manager:
44
44
 
45
+ ### Linux (Debian/Ubuntu)
46
+
47
+ If you run in a container, install it in the same way.
48
+
45
49
  ```bash
46
- # Linux (Debian/Ubuntu)
47
50
  sudo apt update && sudo apt install -y ffmpeg
48
51
  ```
49
52
 
53
+ ### Windows
54
+
50
55
  ```powershell
51
- # Windows
52
56
  winget install --id Gyan.FFmpeg -e
53
57
  ```
54
58
 
59
+ ### macOS
60
+
55
61
  ```bash
56
- # macOS
57
62
  brew install ffmpeg
58
63
  ```
59
64
 
60
- ## TODO
61
-
62
- - Track matter.js PR #4128 (https://github.com/matter-js/matter.js/pull/4128) and, once merged and released in the consumed `@matter/*` version, remove the temporary ImageControl workaround used by Audio Doorbell and Intercom for CameraAvStreamManagement choice conformance.
63
-
64
65
  ## Supported device types
65
66
 
66
67
  ### Chime
@@ -89,7 +90,7 @@ Features:
89
90
 
90
91
  Features:
91
92
 
92
- - Exposes the Camera AV Stream Management cluster with the Video, Audio and ImageControl features (the Snapshot feature is not implemented in this example; see Snapshot Camera).
93
+ - Exposes the Camera AV Stream Management cluster with the Video, Audio, Snapshot and ImageControl features.
93
94
  - Exposes the WebRtcTransportProvider cluster and registers a WebRtcTransportRequestor client, so a bound device can solicit and receive WebRTC offers.
94
95
  - Allocates WebRTC session identifiers monotonically from 0 through 65534, wrapping to 0 and skipping identifiers that still belong to active sessions, as required by Matter 1.6.
95
96
  - Automatically selects or allocates a video/audio stream when a client's `SolicitOffer`/`ProvideOffer` omits `videoStreams`/`audioStreams` (and their deprecated single-id counterparts), per the Matter specification's automatic stream selection for revision 1 clients. This is required to interoperate with clients that never allocate streams explicitly, such as Home Assistant's Matter camera integration.
@@ -105,11 +106,13 @@ Supported by:
105
106
 
106
107
  - [Matterserver dashboard](screenshots/matterserver-camera.png)
107
108
 
109
+ - [Matterserver dashboard with MPTZ](screenshots/matterserver-ptz-camera.png)
110
+
108
111
  ### Snapshot Camera
109
112
 
110
113
  Features:
111
114
 
112
- - Exposes the Camera AV Stream Management cluster with the Snapshot and Image Control features.
115
+ - Exposes the Camera AV Stream Management cluster with the Snapshot feature.
113
116
  - Supports configurable snapshot capabilities, encoder limits, content buffer size, and network bandwidth.
114
117
  - Supports configuring stream usages and their priority order with the SetStreamPriorities command.
115
118
  - Allocates and deallocates snapshot streams with generated stream identifiers.
@@ -131,7 +134,6 @@ Features:
131
134
  - Adds the required Chime client cluster automatically via `addChimeClient`, so a bound Chime device can be triggered when the doorbell button is pressed.
132
135
  - Identify cluster is always created (it is a required server cluster for this device type), with configurable identify time and type.
133
136
  - Configurable Power Source cluster type: Rechargeable, Replaceable, Battery, Wired, or None to omit the Power Source cluster entirely.
134
- - Deviation from the Matter specification: the CameraAvStreamManagement ImageControl feature is also enabled, even though the specification only allows it when Video or Snapshot is present, to work around a matter.js bug where the ImageRotation/ImageFlipHorizontal/ImageFlipVertical "at least one shall be present" choice conformance is enforced unconditionally instead of only when ImageControl is enabled (see the JSDoc in `src/devices/audioDoorbell.ts`).
135
137
 
136
138
  ### Floodlight Camera
137
139
 
@@ -160,44 +162,34 @@ Features:
160
162
  - Adds the optional Chime client cluster automatically via `addChimeClient`, so a bound Chime device can be triggered.
161
163
  - Optional Identify cluster support, with configurable identify time and type. Set to Identify.IdentifyType.None to omit the cluster entirely.
162
164
  - Configurable Power Source cluster type: Rechargeable, Replaceable, Battery, Wired, or None to omit the Power Source cluster entirely.
163
- - Deviation from the Matter specification: the CameraAvStreamManagement ImageControl feature is also enabled, even though the specification only allows it when Video or Snapshot is present, to work around the same matter.js bug described above for Audio Doorbell.
164
165
 
165
- #### Pairing two Intercoms for two-way calling
166
+ Supported by:
167
+
168
+ - [Matterserver dashboard](screenshots/matterserver-intercom.png)
166
169
 
167
- `src/module.ts` registers exactly this pair for testing: `Intercom 1` (bridged, under the Matterbridge aggregator) and `Intercom 2` (`mode: 'server'`, its own Matter node) — commission both and follow the steps below to bind them together.
170
+ ### Pairing the Server Chime and Server Doorbell to let the Doorbell play a chime
168
171
 
169
- `Intercom 2` has to be `mode: 'server'` rather than a second bridged endpoint: peer resolution (see below) identifies the caller from the `peerNodeId`/`fabricIndex` of the command's CASE session, and a CASE session only exists between two distinct node identities on the fabric. Two bridged endpoints share the bridge's single node identity, so there is no CASE session, Binding, or ACL between them to test — invoking one from the other would just be a local, in-process behavior call. `mode: 'server'` is what gives an endpoint its own independent Matter node, which is what a real second, physical Intercom would be.
172
+ `src/module.ts` registers exactly this pair for testing: `Server Chime` (`mode: 'server'`, its own Matter node) and `Server Doorbell` (`mode: 'server'`, its own Matter node) — commission both and follow the steps below to bind them together.
170
173
 
171
- Unlike a Doorbell/Chime pair, where only the Doorbell invokes commands on the Chime, an Intercom both hosts (server) and invokes (client) WebRtcTransportProvider and WebRtcTransportRequestor (see `#resolvePeerRequestorEndpoint` in `src/behaviors/webRtcTransportProviderServer.ts`). Once a peer invokes SolicitOffer/ProvideOffer on an Intercom's WebRtcTransportProvider, that Intercom resolves the caller's WebRtcTransportRequestor endpoint directly from the invoking peer's node id/fabric index carried by the command's CASE session — not via the Binding cluster — so the Offer/Answer "return leg" needs no binding of its own. Only the initiating invoke needs one.
174
+ 1. **Binding on Server Doorbell → Server Chime**, so Server Doorbell knows where to play a chime.
172
175
 
173
- So, to let either Intercom 1 or Intercom 2 start a call, on the fabric they share (commission both onto the same controller/ecosystem first, e.g. via chip-tool, Apple Home, or Google Home):
176
+ Bind Server Doorbell to Server Chime with ![Matter Server Dashboard](screenshots/binding.png)
174
177
 
175
- 1. **Binding on 1 → 2**, so Intercom 1 knows where to send SolicitOffer/ProvideOffer. Binding on 2 → 1 is the mirror, for the other direction:
178
+ ### Pairing the two Server Intercoms for two-way calling
176
179
 
177
- ```bash
178
- chip-tool binding write binding '[{"fabricIndex": 1, "node": <NODE_ID_2>, "endpoint": <ENDPOINT_2>, "cluster": 1363}]' <NODE_ID_1> <ENDPOINT_1>
179
- chip-tool binding write binding '[{"fabricIndex": 1, "node": <NODE_ID_1>, "endpoint": <ENDPOINT_1>, "cluster": 1363}]' <NODE_ID_2> <ENDPOINT_2>
180
- ```
180
+ `src/module.ts` registers exactly this pair for testing: `Server Intercom 1` (`mode: 'server'`, its own Matter node) and `Server Intercom 2` (`mode: 'server'`, its own Matter node) — commission both and follow the steps below to bind them together.
181
181
 
182
- `1363` (`0x553`) is the WebRtcTransportProvider cluster id; `<ENDPOINT_1>`/`<ENDPOINT_2>` are each Intercom's endpoint number (find them from the commissioning output or the Matterbridge frontend).
182
+ Unlike a Doorbell/Chime pair, where only the Doorbell invokes commands on the Chime, an Intercom both hosts (server) and invokes (client) WebRtcTransportProvider and WebRtcTransportRequestor (see `#resolvePeerRequestorEndpoint` in `src/behaviors/webRtcTransportProviderServer.ts`). Once a peer invokes SolicitOffer/ProvideOffer on an Intercom's WebRtcTransportProvider, that Intercom resolves the caller's WebRtcTransportRequestor endpoint directly from the invoking peer's node id/fabric index carried by the command's CASE session — not via the Binding cluster — so the Offer/Answer "return leg" needs no binding of its own. Only the initiating invoke needs one.
183
183
 
184
- 2. **ACL on 2 granting 1**, and **ACL on 1 granting 2**, Operate access to both WebRtcTransportProvider (`1363`) and WebRtcTransportRequestor (`1364`, `0x554`) — Intercom 1 needs it on 2 for the initiating invoke, and Intercom 2 needs it on 1 for the return invoke, regardless of who starts the call:
184
+ So, to let either Server Intercom 1 or Server Intercom 2 start a call, on the fabric they share.
185
185
 
186
- ```bash
187
- chip-tool accesscontrol write acl '[
188
- {"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [<ADMIN_NODE_ID>], "targets": null},
189
- {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": [<NODE_ID_1>], "targets": [{"cluster": 1363, "endpoint": null, "deviceType": null}, {"cluster": 1364, "endpoint": null, "deviceType": null}]}
190
- ]' <NODE_ID_2> 0
186
+ 1. **Binding on Server Intercom 1 → Server Intercom 2**, so Server Intercom 1 knows where to send SolicitOffer/ProvideOffer.
191
187
 
192
- chip-tool accesscontrol write acl '[
193
- {"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [<ADMIN_NODE_ID>], "targets": null},
194
- {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": [<NODE_ID_2>], "targets": [{"cluster": 1363, "endpoint": null, "deviceType": null}, {"cluster": 1364, "endpoint": null, "deviceType": null}]}
195
- ]' <NODE_ID_1> 0
196
- ```
188
+ Bind Server Intercom 1 to Server Intercom 2 with ![Matter Server Dashboard](screenshots/binding-intercom1.png)
197
189
 
198
- The ACL attribute is a full replace, not a merge: keep the existing Administer entry for `<ADMIN_NODE_ID>` (your controller/commissioner) in the list, or you lock yourself out of that node.
190
+ 2. **Binding on Server Intercom 2 → Server Intercom 1**, so Server Intercom 2 knows where to send SolicitOffer/ProvideOffer.
199
191
 
200
- With both directions in place, either Intercom can call the other; a call initiated the other way only needs its own binding/ACL pair, already covered above since both were set up symmetrically.
192
+ Bind Server Intercom 2 to Server Intercom 1 with ![Matter Server Dashboard](screenshots/binding-intercom2.png)
201
193
 
202
194
  ## WebRTC video and audio injection
203
195
 
@@ -393,153 +385,3 @@ All three calibration cards above are kept well under the Matter message size ce
393
385
  A `CaptureSnapshot` response whose `data` field doesn't fit fails to send: the client gets a generic invoke failure instead of an image, since the encoder cannot represent the required plaintext length in the message header. `CameraAvStreamManagement.CaptureSnapshot` returns its image as a single field of a single command response, so it inherits this ceiling directly. Matter has a dedicated mechanism for transferring larger payloads — BDX (Bulk Data Exchange), used for OTA updates and diagnostic logs — which splits big content across a sequence of acknowledged messages instead of one oversized one, but `CaptureSnapshot` doesn't use it.
394
386
 
395
387
  WebRTC media tracks transport encoded H.264 or Opus frames in RTP packets; they do not send an MP4, Ogg, or MPEG container directly. The current MP4 transfer deliberately uses the separate data-channel path. A future video-track test should parse the relevant elementary frames, packetize them as RTP, call werift's media track `writeRtp()`, and verify reception through `onTrack` and `onReceiveRtp`.
396
-
397
- ## Chip tests
398
-
399
- ### Create the container (Linux, macOS, and Windows)
400
-
401
- Run the `luligu/matterbridge:chip-test` docker image:
402
-
403
- - frontend on port 8585
404
- - plugin mapped to .
405
- - container test logs directory mapped on ./temp directory
406
-
407
- ```shell
408
- docker rm plugin-chip-test -f && docker pull luligu/matterbridge:chip-test && docker run -dit --network matterbridge --restart always --stop-timeout 60 --name plugin-chip-test -p 8585:8283 -v "$(pwd)/temp:/tmp/matter_testing/logs" -v "$(pwd):/root/Matterbridge/matterbridge-example-camera" luligu/matterbridge:chip-test
409
- ```
410
-
411
- ### Add the plugin
412
-
413
- Add the plugin and restart the container
414
-
415
- ```shell
416
- npm install --no-fund --no-audit --verbose
417
- npm link matterbridge --no-fund --no-audit --verbose
418
- npm run build
419
- npm prune --omit=dev --no-fund --no-audit --verbose
420
- docker exec -it plugin-chip-test matterbridge --add matterbridge-example-camera
421
- docker restart plugin-chip-test
422
- ```
423
-
424
- ### Run the tests inside the container
425
-
426
- Open a shell in the container
427
-
428
- ```shell
429
- docker exec -it plugin-chip-test bash
430
- ```
431
-
432
- In the shell:
433
-
434
- ```bash
435
- # Generic device composition and conformance ✅ (one test fails for a known matter.js bug)
436
- python3 src/python_testing/TC_DeviceBasicComposition.py
437
- python3 src/python_testing/TC_DeviceConformance.py --bool-arg allow_provisional:true
438
- python3 src/python_testing/TC_DefaultWarnings.py --bool-arg pixit_allow_default_vendor_id:true
439
-
440
- # Doorbell mandatory Switch server
441
- python3 src/python_testing/TC_SWTCH.py
442
-
443
- # Chime cluster ✅
444
- python3 src/python_testing/TC_CHIME_2_2.py --endpoint 2
445
- python3 src/python_testing/TC_CHIME_2_3.py --endpoint 2
446
- python3 src/python_testing/TC_CHIME_2_5.py --endpoint 2
447
- python3 src/python_testing/TC_CHIME_2_6.py --endpoint 2
448
-
449
- # Camera AV Stream Management
450
- python3 src/python_testing/TC_AVSM_2_1.py
451
- python3 src/python_testing/TC_AVSM_2_2.py
452
- python3 src/python_testing/TC_AVSM_2_3.py
453
- python3 src/python_testing/TC_AVSM_2_4.py
454
- python3 src/python_testing/TC_AVSM_2_5.py
455
- python3 src/python_testing/TC_AVSM_2_6.py
456
- python3 src/python_testing/TC_AVSM_2_7.py
457
- python3 src/python_testing/TC_AVSM_2_8.py
458
- python3 src/python_testing/TC_AVSM_2_9.py
459
- python3 src/python_testing/TC_AVSM_2_10.py
460
- python3 src/python_testing/TC_AVSM_2_11.py
461
- python3 src/python_testing/TC_AVSM_2_12.py
462
- python3 src/python_testing/TC_AVSM_2_13.py
463
- python3 src/python_testing/TC_AVSM_2_14.py
464
- python3 src/python_testing/TC_AVSM_2_15.py
465
- python3 src/python_testing/TC_AVSM_2_16.py
466
- python3 src/python_testing/TC_AVSM_2_17.py
467
- python3 src/python_testing/TC_AVSM_2_18.py
468
- python3 src/python_testing/TC_AVSM_2_19.py
469
- python3 src/python_testing/TC_AVSM_2_20.py
470
- python3 src/python_testing/TC_AVSM_2_21.py
471
-
472
- # Additional Camera AV Stream Management tests
473
- python3 src/python_testing/TC_AVSM_StreamReuseRangeParams.py
474
- python3 src/python_testing/TC_AVSM_VideoStreamsPersistence.py
475
-
476
- # Audio/Video Stream Usage Management
477
- python3 src/python_testing/TC_AVSUM_2_1.py
478
- python3 src/python_testing/TC_AVSUM_2_2.py
479
- python3 src/python_testing/TC_AVSUM_2_3.py
480
- python3 src/python_testing/TC_AVSUM_2_4.py
481
- python3 src/python_testing/TC_AVSUM_2_5.py
482
- python3 src/python_testing/TC_AVSUM_2_6.py
483
- python3 src/python_testing/TC_AVSUM_2_7.py
484
- python3 src/python_testing/TC_AVSUM_2_8.py
485
- python3 src/python_testing/TC_AVSUM_2_9.py
486
-
487
- # Push AV Stream Transport
488
- python3 src/python_testing/TC_PAVST_2_1.py
489
- python3 src/python_testing/TC_PAVST_2_2.py
490
- python3 src/python_testing/TC_PAVST_2_3.py
491
- python3 src/python_testing/TC_PAVST_2_4.py
492
- python3 src/python_testing/TC_PAVST_2_5.py
493
- python3 src/python_testing/TC_PAVST_2_6.py
494
- python3 src/python_testing/TC_PAVST_2_7.py
495
- python3 src/python_testing/TC_PAVST_2_8.py
496
- python3 src/python_testing/TC_PAVST_2_9.py
497
- python3 src/python_testing/TC_PAVST_2_10.py
498
- python3 src/python_testing/TC_PAVST_2_11.py
499
- python3 src/python_testing/TC_PAVST_2_12.py
500
- python3 src/python_testing/TC_PAVST_2_13.py
501
-
502
- # WebRTC Transport Provider
503
- python3 src/python_testing/TC_WEBRTCP_2_1.py
504
- python3 src/python_testing/TC_WEBRTCP_2_2.py
505
- python3 src/python_testing/TC_WEBRTCP_2_3.py
506
- python3 src/python_testing/TC_WEBRTCP_2_4.py
507
- python3 src/python_testing/TC_WEBRTCP_2_5.py
508
- python3 src/python_testing/TC_WEBRTCP_2_6.py
509
- python3 src/python_testing/TC_WEBRTCP_2_7.py
510
- python3 src/python_testing/TC_WEBRTCP_2_8.py
511
- python3 src/python_testing/TC_WEBRTCP_2_9.py
512
- python3 src/python_testing/TC_WEBRTCP_2_10.py
513
- python3 src/python_testing/TC_WEBRTCP_2_11.py
514
- python3 src/python_testing/TC_WEBRTCP_2_12.py
515
- python3 src/python_testing/TC_WEBRTCP_2_13.py
516
- python3 src/python_testing/TC_WEBRTCP_2_14.py
517
- python3 src/python_testing/TC_WEBRTCP_2_15.py
518
- python3 src/python_testing/TC_WEBRTCP_2_16.py
519
- python3 src/python_testing/TC_WEBRTCP_2_17.py
520
- python3 src/python_testing/TC_WEBRTCP_2_18.py
521
- python3 src/python_testing/TC_WEBRTCP_2_19.py
522
- python3 src/python_testing/TC_WEBRTCP_2_20.py
523
- python3 src/python_testing/TC_WEBRTCP_2_21.py
524
- python3 src/python_testing/TC_WEBRTCP_2_22.py
525
- python3 src/python_testing/TC_WEBRTCP_2_23.py
526
- python3 src/python_testing/TC_WEBRTCP_2_24.py
527
- python3 src/python_testing/TC_WEBRTCP_2_25.py
528
- python3 src/python_testing/TC_WEBRTCP_2_26.py
529
- python3 src/python_testing/TC_WEBRTCP_2_27.py
530
- python3 src/python_testing/TC_WEBRTCP_2_28.py
531
- python3 src/python_testing/TC_WEBRTCP_2_29.py
532
- python3 src/python_testing/TC_WEBRTCP_2_30.py
533
- python3 src/python_testing/TC_WEBRTCP_2_31.py
534
- python3 src/python_testing/TC_WEBRTCP_2_32.py
535
-
536
- # Zone Management
537
- python3 src/python_testing/TC_ZONEMGMT_2_4.py
538
- ```
539
-
540
- ### Stop the container and link the local matterbridge instance
541
-
542
- ```shell
543
- docker stop plugin-chip-test
544
- npm run link
545
- ```
@@ -9,6 +9,9 @@ export class MatterbridgeCameraAvSettingsUserLevelManagementServer extends Camer
9
9
  mptzSetPosition(request) {
10
10
  const device = this.endpoint.stateOf(MatterbridgeServer);
11
11
  const { pan, tilt, zoom } = request;
12
+ if (pan === undefined && tilt === undefined && zoom === undefined) {
13
+ throw new StatusResponseError('MPTZSetPosition requires at least one of pan, tilt or zoom to be present', Status.InvalidCommand);
14
+ }
12
15
  if (pan !== undefined && (pan < this.state.panMin || pan > this.state.panMax)) {
13
16
  throw new StatusResponseError(`Pan ${pan} is outside of the supported range [${this.state.panMin}, ${this.state.panMax}]`, Status.ConstraintError);
14
17
  }
@@ -27,6 +30,9 @@ export class MatterbridgeCameraAvSettingsUserLevelManagementServer extends Camer
27
30
  }
28
31
  mptzRelativeMove(request) {
29
32
  const device = this.endpoint.stateOf(MatterbridgeServer);
33
+ if (request.panDelta === undefined && request.tiltDelta === undefined && request.zoomDelta === undefined) {
34
+ throw new StatusResponseError('MPTZRelativeMove requires at least one of panDelta, tiltDelta or zoomDelta to be present', Status.InvalidCommand);
35
+ }
30
36
  const current = this.state.mptzPosition;
31
37
  const pan = request.panDelta === undefined ? current.pan : clamp((current.pan ?? 0) + request.panDelta, this.state.panMin, this.state.panMax);
32
38
  const tilt = request.tiltDelta === undefined ? current.tilt : clamp((current.tilt ?? 0) + request.tiltDelta, this.state.tiltMin, this.state.tiltMax);
@@ -2,8 +2,14 @@ import { readFileSync } from 'node:fs';
2
2
  import { MatterbridgeServer } from 'matterbridge/behaviors';
3
3
  import { CameraAvStreamManagementServer } from 'matterbridge/matter/behaviors';
4
4
  import { CameraAvStreamManagement } from 'matterbridge/matter/clusters';
5
- import { Status, StatusResponseError } from 'matterbridge/matter/types';
5
+ import { Status, StatusResponseError, StreamUsage } from 'matterbridge/matter/types';
6
6
  const DEFAULT_CAMERA_COLOR_TEST_RESOLUTION = '640x480';
7
+ const AUDIO_STREAM_BIT_DEPTHS = [8, 16, 24, 32];
8
+ function numericEnumValues(enumObject) {
9
+ return Object.values(enumObject).filter((value) => typeof value === 'number');
10
+ }
11
+ const AUDIO_CODECS = numericEnumValues(CameraAvStreamManagement.AudioCodec);
12
+ const VIDEO_CODECS = numericEnumValues(CameraAvStreamManagement.VideoCodec);
7
13
  const cameraColorTestJpegs = {
8
14
  '640x480': { data: readFileSync(new URL('../../assets/camera-color-test-640-480.jpeg', import.meta.url)), resolution: { width: 640, height: 480 } },
9
15
  '1280x720': { data: readFileSync(new URL('../../assets/camera-color-test-1280-720.jpeg', import.meta.url)), resolution: { width: 1280, height: 720 } },
@@ -13,6 +19,83 @@ export function cameraColorTestJpegForResolution(requestedResolution) {
13
19
  return cameraColorTestJpegs[`${requestedResolution.width}x${requestedResolution.height}`] ?? cameraColorTestJpegs[DEFAULT_CAMERA_COLOR_TEST_RESOLUTION];
14
20
  }
15
21
  export class MatterbridgeCameraAvStreamManagementServer extends CameraAvStreamManagementServer.with(CameraAvStreamManagement.Feature.Video, CameraAvStreamManagement.Feature.Audio, CameraAvStreamManagement.Feature.Snapshot, CameraAvStreamManagement.Feature.ImageControl) {
22
+ #isAutoAllocateSkipped() {
23
+ return process.env.MATTERBRIDGE_SKIP_AUTO_ALLOCATE_CAMERA_AV_STREAM_MANAGEMENT === '1';
24
+ }
25
+ initialize() {
26
+ if (this.#isAutoAllocateSkipped())
27
+ return;
28
+ if (this.features.video && this.state.allocatedVideoStreams.length === 0 && this.state.rateDistortionTradeOffPoints.length > 0 && this.state.streamUsagePriorities.length > 0) {
29
+ const { rateDistortionTradeOffPoints } = this.state;
30
+ let largestTradeOffPoint = rateDistortionTradeOffPoints[0];
31
+ for (const point of rateDistortionTradeOffPoints) {
32
+ if (point.resolution.width * point.resolution.height > largestTradeOffPoint.resolution.width * largestTradeOffPoint.resolution.height)
33
+ largestTradeOffPoint = point;
34
+ }
35
+ const { codec, resolution, minBitRate } = largestTradeOffPoint;
36
+ this.state.allocatedVideoStreams = [
37
+ {
38
+ videoStreamId: 0,
39
+ streamUsage: this.state.streamUsagePriorities[0],
40
+ videoCodec: codec,
41
+ minFrameRate: 1,
42
+ maxFrameRate: this.state.videoSensorParams.maxFps,
43
+ minResolution: this.state.minViewportResolution,
44
+ maxResolution: resolution,
45
+ minBitRate,
46
+ maxBitRate: minBitRate * 4,
47
+ keyFrameInterval: 4000,
48
+ ...(this.features.watermark ? { watermarkEnabled: false } : {}),
49
+ ...(this.features.onScreenDisplay ? { osdEnabled: false } : {}),
50
+ referenceCount: 0,
51
+ },
52
+ ];
53
+ }
54
+ if (this.features.audio &&
55
+ this.state.allocatedAudioStreams.length === 0 &&
56
+ this.state.microphoneCapabilities.supportedCodecs.length > 0 &&
57
+ this.state.streamUsagePriorities.length > 0) {
58
+ const { microphoneCapabilities } = this.state;
59
+ this.state.allocatedAudioStreams = [
60
+ {
61
+ audioStreamId: 0,
62
+ streamUsage: this.state.streamUsagePriorities[0],
63
+ audioCodec: microphoneCapabilities.supportedCodecs[0],
64
+ channelCount: microphoneCapabilities.maxNumberOfChannels,
65
+ sampleRate: microphoneCapabilities.supportedSampleRates[0],
66
+ bitRate: 32_000,
67
+ bitDepth: microphoneCapabilities.supportedBitDepths[0],
68
+ referenceCount: 0,
69
+ },
70
+ ];
71
+ }
72
+ if (this.features.snapshot && this.state.allocatedSnapshotStreams.length === 0 && this.state.snapshotCapabilities.length > 0) {
73
+ const { snapshotCapabilities } = this.state;
74
+ let smallestCapability = snapshotCapabilities[0];
75
+ let largestCapability = snapshotCapabilities[0];
76
+ for (const capability of snapshotCapabilities) {
77
+ if (capability.resolution.width * capability.resolution.height < smallestCapability.resolution.width * smallestCapability.resolution.height)
78
+ smallestCapability = capability;
79
+ if (capability.resolution.width * capability.resolution.height > largestCapability.resolution.width * largestCapability.resolution.height)
80
+ largestCapability = capability;
81
+ }
82
+ this.state.allocatedSnapshotStreams = [
83
+ {
84
+ snapshotStreamId: 0,
85
+ imageCodec: largestCapability.imageCodec,
86
+ frameRate: largestCapability.maxFrameRate,
87
+ minResolution: smallestCapability.resolution,
88
+ maxResolution: largestCapability.resolution,
89
+ quality: 90,
90
+ referenceCount: 0,
91
+ encodedPixels: false,
92
+ hardwareEncoder: false,
93
+ ...(this.features.watermark ? { watermarkEnabled: false } : {}),
94
+ ...(this.features.onScreenDisplay ? { osdEnabled: false } : {}),
95
+ },
96
+ ];
97
+ }
98
+ }
16
99
  setStreamPriorities(request) {
17
100
  const device = this.endpoint.stateOf(MatterbridgeServer);
18
101
  if ((this.features.snapshot && this.state.allocatedSnapshotStreams.length > 0) ||
@@ -31,8 +114,47 @@ export class MatterbridgeCameraAvStreamManagementServer extends CameraAvStreamMa
31
114
  }
32
115
  videoStreamAllocate(request) {
33
116
  const device = this.endpoint.stateOf(MatterbridgeServer);
34
- if (!this.state.supportedStreamUsages.includes(request.streamUsage)) {
35
- throw new StatusResponseError(`Stream usage ${request.streamUsage} is not present in supportedStreamUsages`, Status.ConstraintError);
117
+ if (request.streamUsage === StreamUsage.Internal) {
118
+ throw new StatusResponseError('Stream usage Internal is not allowed for VideoStreamAllocate', Status.ConstraintError);
119
+ }
120
+ if (!this.state.streamUsagePriorities.includes(request.streamUsage)) {
121
+ throw new StatusResponseError(`Stream usage ${request.streamUsage} is not present in streamUsagePriorities`, Status.InvalidInState);
122
+ }
123
+ if (!VIDEO_CODECS.includes(request.videoCodec)) {
124
+ throw new StatusResponseError(`VideoCodec ${request.videoCodec} is not a valid VideoCodecEnum value`, Status.ConstraintError);
125
+ }
126
+ if (request.minFrameRate > request.maxFrameRate) {
127
+ throw new StatusResponseError(`MinFrameRate ${request.minFrameRate} must not be greater than MaxFrameRate ${request.maxFrameRate}`, Status.ConstraintError);
128
+ }
129
+ if (request.minBitRate > request.maxBitRate) {
130
+ throw new StatusResponseError(`MinBitRate ${request.minBitRate} must not be greater than MaxBitRate ${request.maxBitRate}`, Status.ConstraintError);
131
+ }
132
+ const matchesTradeOffPoint = this.state.rateDistortionTradeOffPoints.some((point) => point.codec === request.videoCodec &&
133
+ point.resolution.width >= request.minResolution.width &&
134
+ point.resolution.width <= request.maxResolution.width &&
135
+ point.resolution.height >= request.minResolution.height &&
136
+ point.resolution.height <= request.maxResolution.height &&
137
+ point.minBitRate <= request.maxBitRate);
138
+ if (!matchesTradeOffPoint || request.maxFrameRate > this.state.videoSensorParams.maxFps) {
139
+ throw new StatusResponseError('VideoStreamAllocate requested parameters do not match any entry in rateDistortionTradeOffPoints or exceed videoSensorParams', Status.DynamicConstraintError);
140
+ }
141
+ const existingStream = this.state.allocatedVideoStreams.find((stream) => stream.streamUsage === request.streamUsage &&
142
+ stream.videoCodec === request.videoCodec &&
143
+ stream.minFrameRate === request.minFrameRate &&
144
+ stream.maxFrameRate === request.maxFrameRate &&
145
+ stream.minResolution.width === request.minResolution.width &&
146
+ stream.minResolution.height === request.minResolution.height &&
147
+ stream.maxResolution.width === request.maxResolution.width &&
148
+ stream.maxResolution.height === request.maxResolution.height &&
149
+ stream.minBitRate === request.minBitRate &&
150
+ stream.maxBitRate === request.maxBitRate &&
151
+ stream.keyFrameInterval === request.keyFrameInterval);
152
+ if (existingStream) {
153
+ device.log.info(`Reused video stream ${existingStream.videoStreamId} for usage ${request.streamUsage} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
154
+ return { videoStreamId: existingStream.videoStreamId };
155
+ }
156
+ if (this.state.allocatedVideoStreams.length >= this.state.maxConcurrentEncoders) {
157
+ throw new StatusResponseError(`VideoStreamAllocate would exceed maxConcurrentEncoders (${this.state.maxConcurrentEncoders})`, Status.ResourceExhausted);
36
158
  }
37
159
  let videoStreamId = 0;
38
160
  for (const stream of this.state.allocatedVideoStreams) {
@@ -69,8 +191,35 @@ export class MatterbridgeCameraAvStreamManagementServer extends CameraAvStreamMa
69
191
  }
70
192
  audioStreamAllocate(request) {
71
193
  const device = this.endpoint.stateOf(MatterbridgeServer);
72
- if (!this.state.supportedStreamUsages.includes(request.streamUsage)) {
73
- throw new StatusResponseError(`Stream usage ${request.streamUsage} is not present in supportedStreamUsages`, Status.ConstraintError);
194
+ if (request.streamUsage === StreamUsage.Internal) {
195
+ throw new StatusResponseError('Stream usage Internal is not allowed for AudioStreamAllocate', Status.ConstraintError);
196
+ }
197
+ if (!this.state.streamUsagePriorities.includes(request.streamUsage)) {
198
+ throw new StatusResponseError(`Stream usage ${request.streamUsage} is not present in streamUsagePriorities`, Status.InvalidInState);
199
+ }
200
+ if (!AUDIO_CODECS.includes(request.audioCodec)) {
201
+ throw new StatusResponseError(`AudioCodec ${request.audioCodec} is not a valid AudioCodecEnum value`, Status.ConstraintError);
202
+ }
203
+ if (!AUDIO_STREAM_BIT_DEPTHS.includes(request.bitDepth)) {
204
+ throw new StatusResponseError(`BitDepth ${request.bitDepth} is not one of ${AUDIO_STREAM_BIT_DEPTHS.join(', ')}`, Status.ConstraintError);
205
+ }
206
+ const { microphoneCapabilities } = this.state;
207
+ if (!microphoneCapabilities.supportedCodecs.includes(request.audioCodec) ||
208
+ request.channelCount < 1 ||
209
+ request.channelCount > microphoneCapabilities.maxNumberOfChannels ||
210
+ !microphoneCapabilities.supportedSampleRates.includes(request.sampleRate) ||
211
+ !microphoneCapabilities.supportedBitDepths.includes(request.bitDepth)) {
212
+ throw new StatusResponseError('AudioStreamAllocate requested audioCodec, channelCount, sampleRate or bitDepth is not supported by microphoneCapabilities', Status.DynamicConstraintError);
213
+ }
214
+ const existingStream = this.state.allocatedAudioStreams.find((stream) => stream.streamUsage === request.streamUsage &&
215
+ stream.audioCodec === request.audioCodec &&
216
+ stream.channelCount === request.channelCount &&
217
+ stream.sampleRate === request.sampleRate &&
218
+ stream.bitRate === request.bitRate &&
219
+ stream.bitDepth === request.bitDepth);
220
+ if (existingStream) {
221
+ device.log.info(`Reused audio stream ${existingStream.audioStreamId} for usage ${request.streamUsage} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
222
+ return { audioStreamId: existingStream.audioStreamId };
74
223
  }
75
224
  let audioStreamId = 0;
76
225
  for (const stream of this.state.allocatedAudioStreams) {
@@ -102,6 +251,42 @@ export class MatterbridgeCameraAvStreamManagementServer extends CameraAvStreamMa
102
251
  }
103
252
  async snapshotStreamAllocate(request) {
104
253
  const device = this.endpoint.stateOf(MatterbridgeServer);
254
+ const { minResolution, maxResolution } = request;
255
+ const matchesCapability = this.state.snapshotCapabilities.some((capability) => capability.resolution.width >= minResolution.width &&
256
+ capability.resolution.width <= maxResolution.width &&
257
+ capability.resolution.height >= minResolution.height &&
258
+ capability.resolution.height <= maxResolution.height);
259
+ if (!matchesCapability) {
260
+ throw new StatusResponseError('SnapshotStreamAllocate requested minResolution/maxResolution range does not match any entry in snapshotCapabilities', Status.DynamicConstraintError);
261
+ }
262
+ const existingStream = this.state.allocatedSnapshotStreams.find((stream) => stream.imageCodec === request.imageCodec &&
263
+ stream.frameRate === request.maxFrameRate &&
264
+ stream.quality === request.quality &&
265
+ stream.watermarkEnabled === request.watermarkEnabled &&
266
+ stream.osdEnabled === request.osdEnabled &&
267
+ stream.minResolution.width <= request.maxResolution.width &&
268
+ stream.maxResolution.width >= request.minResolution.width &&
269
+ stream.minResolution.height <= request.maxResolution.height &&
270
+ stream.maxResolution.height >= request.minResolution.height);
271
+ if (existingStream) {
272
+ this.state.allocatedSnapshotStreams = this.state.allocatedSnapshotStreams.map((stream) => stream.snapshotStreamId === existingStream.snapshotStreamId
273
+ ? {
274
+ snapshotStreamId: stream.snapshotStreamId,
275
+ imageCodec: stream.imageCodec,
276
+ frameRate: stream.frameRate,
277
+ minResolution: request.minResolution,
278
+ maxResolution: request.maxResolution,
279
+ quality: stream.quality,
280
+ referenceCount: stream.referenceCount,
281
+ encodedPixels: stream.encodedPixels,
282
+ hardwareEncoder: stream.hardwareEncoder,
283
+ watermarkEnabled: stream.watermarkEnabled,
284
+ osdEnabled: stream.osdEnabled,
285
+ }
286
+ : stream);
287
+ device.log.info(`Reused snapshot stream ${existingStream.snapshotStreamId} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
288
+ return { snapshotStreamId: existingStream.snapshotStreamId };
289
+ }
105
290
  let snapshotStreamId = 0;
106
291
  for (const stream of this.state.allocatedSnapshotStreams) {
107
292
  snapshotStreamId = Math.max(snapshotStreamId, stream.snapshotStreamId + 1);
@@ -133,9 +318,14 @@ export class MatterbridgeCameraAvStreamManagementServer extends CameraAvStreamMa
133
318
  this.state.allocatedSnapshotStreams = this.state.allocatedSnapshotStreams.filter((stream) => stream.snapshotStreamId !== request.snapshotStreamId);
134
319
  device.log.info(`Deallocated snapshot stream ${request.snapshotStreamId} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
135
320
  }
136
- async captureSnapshot(request) {
321
+ captureSnapshot(request) {
137
322
  const device = this.endpoint.stateOf(MatterbridgeServer);
138
- device.log.info(`Capturing snapshot ${request.snapshotStreamId ?? 'auto'} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
323
+ const { snapshotStreamId } = request;
324
+ const stream = this.state.allocatedSnapshotStreams.find((s) => snapshotStreamId === null || s.snapshotStreamId === snapshotStreamId);
325
+ if (!stream) {
326
+ throw new StatusResponseError(`Snapshot stream ${snapshotStreamId ?? 'auto'} is not present in allocatedSnapshotStreams`, Status.NotFound);
327
+ }
328
+ device.log.info(`Capturing snapshot ${snapshotStreamId ?? 'auto'} (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
139
329
  device.log.debug(`MatterbridgeCameraAvStreamManagementServer: captureSnapshot called with snapshotStreamId ${request.snapshotStreamId}`);
140
330
  const { data, resolution } = cameraColorTestJpegForResolution(request.requestedResolution);
141
331
  return {
@@ -3,6 +3,14 @@ import { ChimeServer } from 'matterbridge/matter/behaviors';
3
3
  import { Status, StatusResponseError } from 'matterbridge/matter/types';
4
4
  const ChimeServerBase = ChimeServer.enable({ events: { chimeStartedPlaying: true } });
5
5
  export class MatterbridgeChimeServer extends ChimeServerBase {
6
+ initialize() {
7
+ this.reactTo(this.events.selectedChime$Changing, this.#assertSelectedChime);
8
+ }
9
+ #assertSelectedChime(chimeId) {
10
+ if (!this.state.installedChimeSounds.some((chimeSound) => chimeSound.chimeId === chimeId)) {
11
+ throw new StatusResponseError(`MatterbridgeChimeServer: chime sound ${chimeId} is not present in installedChimeSounds (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`, Status.NotFound);
12
+ }
13
+ }
6
14
  async playChimeSound(request) {
7
15
  const device = this.endpoint.stateOf(MatterbridgeServer);
8
16
  if (!this.state.enabled) {