Skip to content

feat: add initial Matter camera driver#222

Open
cleithner-comcast wants to merge 5 commits into
feature/camerasfrom
cleith/dev/initialCameraDriver
Open

feat: add initial Matter camera driver#222
cleithner-comcast wants to merge 5 commits into
feature/camerasfrom
cleith/dev/initialCameraDriver

Conversation

@cleithner-comcast
Copy link
Copy Markdown
Contributor

  • Add camera.sbmd with session lifecycle resources (createSession, stream, takePicture, destroySession, sessionStatus)
  • Add Output operation type to SBMD execute pipeline for local-only mappers that return a value without Matter interaction
  • Add SessionManager to sbmd-utils.js for per-device session tracking
  • Add Response.output() helper for returning output from execute mappers
  • Add chip-camera-app to Dockerfile for integration testing
  • Add unit tests for Output type and SessionManager functionality

Refs: BARTON-380

- Add camera.sbmd with session lifecycle resources (createSession,
  stream, takePicture, destroySession, sessionStatus)
- Add Output operation type to SBMD execute pipeline for local-only
  mappers that return a value without Matter interaction
- Add SessionManager to sbmd-utils.js for per-device session tracking
- Add Response.output() helper for returning output from execute mappers
- Add chip-camera-app to Dockerfile for integration testing
- Add unit tests for Output type and SessionManager functionality

Refs: BARTON-380
@cleithner-comcast
Copy link
Copy Markdown
Contributor Author

@Copilot review this

@cleithner-comcast cleithner-comcast marked this pull request as ready for review May 27, 2026 20:47
Copilot AI review requested due to automatic review settings May 27, 2026 20:47
}

// Check for 'invoke' operation (command invocation) - the only valid operation for execute
// Check for 'output' operation (local-only, no Matter interaction)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This 'output' operation stuff was just a kludge to enable execute resource commands to return a response to the caller that doesn't change the resource value (since it's not a write resource command). I'm not married to it, I just needed it initially. It may be replaced by the work Raiyan is doing for standardizing the return types.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an initial Matter camera driver scaffold. Introduces a new Output execute-mapper result type so SBMD scripts can return values without performing a Matter operation, a JS-side SessionManager keyed per device UUID, a camera.sbmd spec describing the session lifecycle (createSession/stream/takePicture/destroySession/sessionStatus), Docker support for chip-camera-app/chip-camera-controller, and unit tests for the new behaviors.

Changes:

  • Add Output operation type to ScriptWriteResult with handling in MatterDevice::HandleResourceExecute and the mquickjs MapExecute backend.
  • Add Response.output() helper and a per-device SessionManager in sbmd-utils.js, consumed by the new camera.sbmd.
  • Extend Docker image with GStreamer/FFmpeg deps and Matter camera sample apps; bump docker version to 2.10.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
core/deviceDrivers/matter/sbmd/SbmdScript.h Adds Output enum value and std::optional<std::string> output field on ScriptWriteResult.
core/deviceDrivers/matter/sbmd/mquickjs/SbmdScriptImpl.cpp Recognizes {output: ...} execute results in the mquickjs backend (quickjs backend not updated).
core/deviceDrivers/matter/MatterDevice.cpp Short-circuits execute pipeline for Output results, writing the string to the response out-param.
core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js Adds Response.output, SessionManager, and per-device registry; reformats existing Response helpers.
core/deviceDrivers/matter/sbmd/specs/camera.sbmd New camera spec with session lifecycle execute mappers and a sessionStatus event resource.
core/test/src/SbmdScriptTest.cpp Adds Output and SessionManager tests inside the mquickjs-only #if block.
docker/Dockerfile Adds GStreamer/FFmpeg packages and builds/copies chip-camera-app and chip-camera-controller.
docker/version Bumps image version 2.9 → 2.10.

Comment thread core/deviceDrivers/matter/sbmd/mquickjs/SbmdScriptImpl.cpp
Comment thread core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js Outdated
Comment thread core/test/src/SbmdScriptTest.cpp Outdated
Comment thread core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js
Comment thread core/deviceDrivers/matter/sbmd/SbmdScript.h
Comment thread core/deviceDrivers/matter/MatterDevice.cpp
@github-advanced-security
Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

- Add Output operation handling to quickjs backend (parity with mquickjs)
- Add SessionManager.removeForDevice() for cleanup on device removal
- Normalize SessionManager keys to String(id) for unambiguous lookups
- Add icWarn when Output value cannot be delivered (null response ptr)
- Move Output/SessionManager tests outside #if BCORE_USE_MQUICKJS guard
- Update docs/SBMD.md with output form documentation
- Update sbmd-script.d.ts with SbmdUtils, SessionManager, and output types
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.

Comment thread docs/SBMD.md Outdated
Comment thread core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js
Comment thread core/deviceDrivers/matter/sbmd/quickjs/SbmdScriptImpl.cpp
Comment thread core/deviceDrivers/matter/sbmd/mquickjs/SbmdScriptImpl.cpp Outdated
Comment thread core/deviceDrivers/matter/sbmd/mquickjs/SbmdScriptImpl.cpp
Comment thread core/test/src/SbmdScriptTest.cpp
- Add JS_IsException check on output property access in both engines
- Wire SessionManager.removeForDevice() into SbmdScriptImpl destructors
  to clean up per-device session state on device removal
- Convert SbmdCommandResult to discriminated union type in d.ts
- Fix SBMD.md output example to use valid JS literal instead of <string>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (1)

core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js:988

  • The new Response helper formatting switches to inline brace style (e.g., var Response = { and invoke: function(...) {), but the rest of this file consistently uses braces on the next line (e.g., Tlv.decode at sbmd-utils.js:798). Please keep a consistent style within this shared script bundle (or run the project’s formatter/linter if one exists for JS).
    var Response = {
        /**
         * Create an invoke (command) response
         * @param {number} clusterId - Matter cluster ID
         * @param {number} commandId - Matter command ID

Comment thread core/deviceDrivers/matter/sbmd/quickjs/SbmdScriptImpl.cpp
Comment thread core/deviceDrivers/matter/sbmd/mquickjs/SbmdScriptImpl.cpp
Comment thread core/deviceDrivers/matter/sbmd/quickjs/SbmdScriptImpl.cpp Outdated
Comment thread core/deviceDrivers/matter/sbmd/mquickjs/SbmdScriptImpl.cpp Outdated
Comment thread core/deviceDrivers/matter/sbmd/scriptCommon/sbmd-utils.js
- JSON-escape deviceId in destructor cleanup scripts to prevent injection
- Treat JS_ToCString failure on output as hard error (return false) in
  both mquickjs and quickjs engines instead of silently returning empty
- Use Object.create(null) for sessionManagers registry to avoid prototype
  pollution with special keys like __proto__/constructor
Copilot AI review requested due to automatic review settings May 28, 2026 18:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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