Skip to content

fix(camera): add Barton session metadata - #264

Open
kfundecmcsa wants to merge 1 commit into
mainfrom
kfu/dev/add-sessionId-to-cam-resource
Open

fix(camera): add Barton session metadata#264
kfundecmcsa wants to merge 1 commit into
mainfrom
kfu/dev/add-sessionId-to-cam-resource

Conversation

@kfundecmcsa

Copy link
Copy Markdown
Contributor
  • Attach bartonSessionId metadata to remoteSdp and remoteIceCandidates so the client can correlate incoming WebRTC updates to the correct Barton session.

Previously, when incoming WebRTC updates arrived, we inferred the session from the active streaming state. That worked when only one client was active, but it became ambiguous once multiple clients could be streaming at the same time.

  • To resolve that ambiguity, use the camera's webRTCSessionID to infer the Barton session directly when it is available.

- Attach bartonSessionId metadata to remoteSdp and
  remoteIceCandidates so the client can correlate incoming WebRTC
  updates to the correct Barton session.

Previously, when incoming WebRTC updates arrived, we inferred the
session from the active streaming state. That worked when only one
client was active, but it became ambiguous once multiple clients could
be streaming at the same time.

- To resolve that ambiguity, use the camera's webRTCSessionID to infer
  the Barton session directly when it is available.
Copilot AI lite review requested due to automatic review settings August 12, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the SBMD camera WebRTC driver logic to attach session-correlation metadata to incoming WebRTC signaling updates, so clients can attribute remote SDP / ICE / end events to the correct Barton session when multiple sessions may be active.

Changes:

  • Add metadata assertions to WebRTC unit tests for remoteSdp, remoteIceCandidates, and webrtcError updates (including “unknown” session cases).
  • Introduce findSessionIdByWebRTCSessionID() and use it to resolve the Barton session from camera-provided webRTCSessionID for incoming ICE candidates and end-session events.
  • Add defensive handling for null/undefined session maps in findStreamingSessionId().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
core/test/src/SbmdCameraWebrtcTest.cpp Extends tests to validate that incoming WebRTC updates emit session metadata (including unknown-session fallbacks).
core/deviceDrivers/matter/sbmd/specs/camera.sbmd.js Adds WebRTCSessionID→sessionId lookup and attaches session metadata to WebRTC resource updates to disambiguate multi-session scenarios.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 963 to 967
var sessionsJson = args.supplements.transientData[TD_SESSIONS];
var sessions = parseSessions(sessionsJson);
var sessionId = findStreamingSessionId(sessions);
var metadata = {sessionId: sessionId || 'unknown'};

Comment on lines 1004 to +1007
var sessionsJson = args.supplements.transientData[TD_SESSIONS];
var sessions = parseSessions(sessionsJson);
var sessionId = findStreamingSessionId(sessions);
var metadata = {sessionId: sessionId || 'unknown'};
var sessions = parseSessions(sessionsJson);
var sessionId = findSessionIdByWebRTCSessionID(sessions, webRTCSessionID);

var metadata = {sessionId: sessionId || 'unknown'};
EXPECT_TRUE(ur->metadata->find("reason") != std::string::npos);
}

TEST_F(SbmdCameraWebrtcTest, HandleIncomingEndWithUnknownWebRTCSessionIDReturnsError)
Comment on lines 338 to +342
function findStreamingSessionId(sessions) {
if (sessions === null || sessions === undefined)
{
return null;
}

@cleithner-comcast cleithner-comcast left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any needed changes in the reference app? I suppose that you'd never have multiple clients with the reference app in the current increment so likely this metadata can just be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants