fix(camera): report the camera's negotiation role, not the client's - #256
Merged
Merged
Conversation
The ep/webrtc negotiationRole resource is the camera's data model, so it now reports the CAMERA's WebRTC role — offerer when the camera generates the offer (SolicitOffer flow), answerer when it answers the client's offer (ProvideOffer flow) — instead of the role the client must take. An intrinsic cameraIsOfferer() predicate drives both the reported role and the (unchanged) Matter flow selection. The reference app inverts the reported value to choose its own role. The Matter signaling sequence is unchanged. Driver, reference app, the camera unit test (adds NegotiationRoleReportsCameraRole), and the webrtc-signaling- endpoint / camera-stream-reference-command specs are updated to the camera perspective; archives the openspec change.
cleithner-comcast
requested review from
kfundecmcsa,
mkkoch,
rchowdcmcsa and
tleacmcsa
as code owners
August 4, 2026 02:45
Contributor
There was a problem hiding this comment.
Pull request overview
This PR inverts the ep/webrtc/r/negotiationRole contract so it reports the camera’s WebRTC negotiation role (offerer/answerer) rather than the client’s, and updates the in-tree consumer (reference app), SBMD driver logic, specs, and unit tests to match.
Changes:
- SBMD driver: introduce a
cameraIsOfferer()predicate and use it to (a) report the camera’s role viareadNegotiationRoleand (b) keepexecuteLocalSdp’s Matter flow selection unchanged. - Reference app: invert the reported camera role to derive the client’s
webrtcbinrole. - OpenSpec + tests: update specs to the camera perspective and add a unit test asserting the updated role mapping.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| reference/src/cameraDeviceSession.h | Clarifies GetRole() returns the camera’s role (client uses opposite). |
| reference/src/cameraDeviceSession.c | Updates role caching/read commentary to camera-perspective semantics. |
| reference/src/cameraCategory.c | Inverts negotiation role interpretation to derive the client’s role. |
| core/deviceDrivers/matter/sbmd/specs/camera.sbmd.js | Implements camera-perspective role reporting via cameraIsOfferer(); keeps signaling flow selection aligned. |
| core/test/src/SbmdCameraWebrtcTest.cpp | Adds NegotiationRoleReportsCameraRole and a helper to invoke read handlers with supplements. |
| openspec/specs/webrtc-signaling-endpoint/spec.md | Updates endpoint contract: negotiationRole now reports the camera’s role and defaults accordingly. |
| openspec/specs/camera-stream-reference-command/spec.md | Updates reference-app command contract to invert the camera-reported role. |
| openspec/changes/archive/2026-08-03-negotiation-role-camera-perspective/tasks.md | Archives implementation checklist for the contract inversion. |
| openspec/changes/archive/2026-08-03-negotiation-role-camera-perspective/specs/webrtc-signaling-endpoint/spec.md | Archived delta spec reflecting the updated negotiationRole requirement. |
| openspec/changes/archive/2026-08-03-negotiation-role-camera-perspective/specs/camera-stream-reference-command/spec.md | Archived delta spec reflecting reference-app inversion behavior. |
| openspec/changes/archive/2026-08-03-negotiation-role-camera-perspective/proposal.md | Archived proposal describing the breaking contract inversion and scope. |
| openspec/changes/archive/2026-08-03-negotiation-role-camera-perspective/design.md | Archived design describing predicate-based refactor and unchanged Matter flow selection. |
| openspec/changes/archive/2026-08-03-negotiation-role-camera-perspective/.openspec.yaml | Archives change metadata. |
tleacmcsa
approved these changes
Aug 4, 2026
tleacmcsa
left a comment
Contributor
There was a problem hiding this comment.
I'm good with it after addressing copilot's comments.
- cameraCategory.c: validate the camera's negotiation role and fail early with a clear error on NULL/unknown, instead of silently defaulting to a role that could drive the wrong signaling flow. - SbmdCameraWebrtcTest.cpp: rename OFFERER_ACCEPTED_CMDS -> CAMERA_ANSWERER_ ACCEPTED_CMDS and SOLICIT_ACCEPTED_CMDS -> CAMERA_OFFERER_ACCEPTED_CMDS to match the camera-perspective contract; un-wrap a header-comment bullet.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
Suppressed comments (1)
openspec/specs/webrtc-signaling-endpoint/spec.md:14
- The Purpose section still describes
negotiationRoleas telling the client whether it is the offerer/answerer, which contradicts the updated contract below (the table row now says it reports the camera’s role and the client adopts the opposite). Updating the Purpose text avoids ambiguity for spec readers.
| `localSdp` | `function` | execute | Client posts its local SDP (offer or answer) to drive signaling |
| `negotiationRole` | `string` | [read] | Reports the **camera's** negotiation role (`offerer` or `answerer`); the client adopts the opposite role |
| `remoteSdp` | `string` | [] (events only) | Delivers the camera's remote SDP (offer or answer) to client |
kfundecmcsa
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ep/webrtc negotiationRole resource is the camera's data model, so it now reports the CAMERA's WebRTC role — offerer when the camera generates the offer (SolicitOffer flow), answerer when it answers the client's offer (ProvideOffer flow) — instead of the role the client must take. An intrinsic cameraIsOfferer() predicate drives both the reported role and the (unchanged) Matter flow selection. The reference app inverts the reported value to choose its own role.
The Matter signaling sequence is unchanged. Driver, reference app, the camera unit test (adds NegotiationRoleReportsCameraRole), and the webrtc-signaling- endpoint / camera-stream-reference-command specs are updated to the camera perspective; archives the openspec change.