Skip to content

[CameraInterface] Add camera_wire: the messages between the plugin and a reader - #1526

Closed
farbod-nv wants to merge 1 commit into
fm/camera_capture_m0_socketfrom
fm/camera_capture_m0_wire
Closed

farbod-nv wants to merge 1 commit into
fm/camera_capture_m0_socketfrom
fm/camera_capture_m0_wire

Conversation

@farbod-nv

Copy link
Copy Markdown
Contributor

Description

Fourth pull request of the camera interface, stacked on #1523 (the message socket), whose branch is this one's base.

It adds camera_wire: what the camera plugin and a reader say to each other over their socket. There are six messages:

reader                               plugin
  |  Hello (protocol version)           |
  |------------------------------------>|
  |       Welcome (what is published)   |
  |<------------------------------------|
  |  Subscribe (group, window, order)   |
  |------------------------------------>|
  |  Subscribed + one pool descriptor   |
  |             per stream              |
  |<------------------------------------|
  |       Frame (lease, slot per image) |   once per frame set
  |<------------------------------------|
  |  Release (lease)                    |
  |------------------------------------>|
  • One subscription per connection. A reader that wants two groups opens two connections; closing a connection ends its subscription and returns what the reader held. This keeps both ends free of demultiplexing.
  • FlatBuffers, in a schema inside the module (src/core/camera_wire/fbs/camera_wire.fbs). A reader and a plugin can come from different builds (a wheel and a locally built plugin, say), so the format has to tolerate added fields. The schema only grows: fields are appended with fresh ids, everything is a table, and a message type a build does not know is ignored rather than treated as an error. It is not under src/core/schema because that directory holds what goes into recordings, with golden files, and these messages are never recorded.
  • A codec keeps FlatBuffers out of everything else. WireEncoder and decode_wire_message convert to and from camera_core types. The generated header is exposed by a separate target (camera::camera_wire_schema) that only the codec and its tests link.
  • The per-frame path allocates nothing once the encoder's buffer has grown to the size of a frame event.
  • Decoding trusts nothing. The bytes come from another process: the buffer is verified, every count is bounded against the fixed arrays it fills, and a body type without a body is refused (the FlatBuffers verifier accepts it).

The endpoint (the plugin's side of the conversation) and the reader come next and use these messages; nothing sends them yet.

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

  • tests/cpp/core/camera_wire/test_codec.cpp (Catch2, 7 cases, tagged unit): every message survives encoding and decoding with all its fields, including unknown times and defaults; an encoder is reused across messages; empty, random and cut-short bytes are rejected, and every prefix of a valid message is either refused or read without going out of bounds (checked under AddressSanitizer); too many streams, planes or images, an unknown pixel format, a body type without a body and an oversized message are rejected; a union member from a newer peer and a message with no body are ignored. Run with ctest -L camera_wire.
  • Built through the repository's own build with the project warning set promoted to errors. All camera tests pass there and in a second build under AddressSanitizer with UBSan.
  • Ubuntu 22.04 x86_64, GCC 11.4.
  • clang-format-14 reports no changes; SKIP=check-copyright-year pre-commit run --all-files passes.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the linter and formatter with SKIP=check-copyright-year pre-commit run --all-files
  • I have made corresponding changes to the documentation (a README in the module; user documentation comes with the plugin executable)
  • I have added tests that prove my fix/feature works (or explained why not)
  • I have signed off all my commits (git commit -s) per the DCO

🤖 Generated with Claude Code

…reader

The plugin and a reader exchange six messages over their socket: Hello and
Welcome (the catalog of what is published), Subscribe and Subscribed (with
one pool descriptor per stream), then Frame per frame set and Release when
the reader is done with it. A connection carries one subscription.

The messages are FlatBuffers tables in a schema kept inside the module, so
a reader and a plugin from different builds keep understanding each other:
the schema only grows, and a message type a build does not know is ignored.
It is not under src/core/schema because these messages are never recorded.

WireEncoder and decode_wire_message convert to and from camera_core types,
so nothing outside the module sees FlatBuffers. Encoding a frame event
allocates nothing once the encoder's buffer has grown. Decoding treats its
input as coming from another process and checks it in full.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@farbod-nv

Copy link
Copy Markdown
Contributor Author

Folded into #1528. The first milestone of the camera interface is now four pull requests instead of twelve: #1521, #1528, #1530 and #1534.

This branch was successfully deployed

1 active deployment
dev — 1572f956 Deployed Nov 14, 2026 by farbod-nv via publish-wheel #6937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants