Repository navigation
Conversation
… capture plugin First step of the unified camera capture plugin (milestone M0). camera_core tracks which pool slots hold which frame sets and who may still read them. It uses the standard library only and never touches slot memory, so it builds and is tested on every platform. - A group is one or more hardware-synchronised streams published as one frame set. - A reader subscribes with a window (frame sets kept for it at a time) and a delivery order, newest or in order. - A subscription is accepted only when the pool covers it: slots >= ring history + sum of reader windows + backend reserve. - A backend either takes a free slot and writes it, or hands over a slot the camera SDK filled and is told the moment nobody holds it any more. - Every frame event carries its timeline, the group's generation and the number of frame sets the reader skipped. Tests: tests/cpp/core/camera_core (Catch2), run with `ctest -L camera_core`. Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com> Co-Authored-By: Claude <noreply@anthropic.com>
…format H.264 and H.265 are codecs, so they do not belong in PixelFormat. A stream description now has a Codec (NONE for pixels) next to its PixelFormat, and is_encoded() reads the codec. Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com> Co-Authored-By: Claude <noreply@anthropic.com>
Two more places where the stream description and the publisher were too coarse for real cameras: - A stream had a single stride. NV12 has two planes, and on Jetson each plane has its own offset and stride, so a stream now lists its planes. add_group rejects a pixel stream without a size or without one stride per plane of its format, and an encoded stream that lists planes. - Counters were totals over every group. They are now kept per group, so a tool can tell which camera drops frames. Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com> Co-Authored-By: Claude <noreply@anthropic.com>
…ory kind The README explains the terms (stream, group, frame set, window, order, lease, generation), the two ways a backend gets a slot, and the pool budget, so a reviewer does not need anything outside the repository. MemoryKind listed kinds that nothing implements yet. It now has HOST only; each further kind is added together with its pool. Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com> Co-Authored-By: Claude <noreply@anthropic.com>
Core tests carry the unit tag, which becomes the CTest label that `ctest -L unit` selects. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
The tests start threads. Without the link, std::thread fails at run time on C libraries that keep threads in a separate library. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
add_group now checks that every plane of a pixel stream lies inside the slot (row length against stride, last row against the slot size) and that a pool can hold one frame set on top of the backend's reserve. publish refuses an image larger than its slot. EventSink::send_event is noexcept: it runs on the capture path with the publisher's lock held, and a throwing sink would have left a slot held. A group with a slot-free callback hands out its slots with claim_slot only, so a slot cannot be taken again before its callback has run. Adds agent notes for the module. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
HostPool is one stream's slots in shared host memory: a single anonymous memory file with the slots a page-aligned stride apart. The owner maps it writable and then seals it, so a process that is sent the descriptor can map it for reading only and cannot resize it. HostPoolView is that reader's mapping; both sides derive the layout from the slot count and slot size. UniqueFd owns a file descriptor. An anonymous sealed file is used rather than named shared memory: there is no name to collide or to clean up after a crash, and only a process that was handed the descriptor can map it. Linux only, so the module and its tests are added under a platform check. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
MessageSocket and MessageListener are a connection between two processes on one machine: a Unix domain socket of the sequenced-packet kind that carries whole messages in order, each with optional file descriptors. This is how a pool's descriptor, and later the per-frame events, reach a reader. - Sending never blocks. A full queue and a closed peer are statuses, so capture cannot stall on a reader that stopped reading. - Receiving waits with a timeout and returns the descriptors as owned UniqueFds. A message that does not fit is an error, not a silent cut. - A lock file next to the socket file decides which process owns the path. The kernel drops the lock when its holder dies, so a socket file found while holding it is stale and is replaced; anything that is not a socket is left alone. - The socket file is created with mode 0600. The README explains why a Unix socket and shared memory are used rather than a messaging library. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
…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>
Endpoint puts a Publisher on a socket and speaks the camera_wire messages: it tells each reader what is published, and on a subscription sends the group's pool descriptors and from then on its frame events. One thread accepts readers and handles the handshake, subscriptions and releases. Frame events are not sent from it: they are encoded and sent on the publishing thread, inside Publisher::publish, with a send that does not block, so nothing sits between a frame set being published and its event being on the socket. A closed connection ends the reader's subscription and returns every frame set it held, whether the reader exited or was killed. A reader that breaks the protocol is dropped without affecting the others. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
6 tasks done
stop() ended the endpoint's thread but kept the listening socket, so a reader that connected afterwards was accepted by the kernel and then waited for an answer nobody would send. stop() now closes the listener, which removes the socket file and releases the path: a reader that tries to connect is refused at once. start() takes the path again. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
…meras CameraReader::open subscribes to one group of the camera plugin and next() hands out frame sets. A FrameSet is a hold on the frames: its images are the plugin's own buffers, mapped read-only, and stay as they are until the object is destroyed or released. Nothing is copied. With newest order and a window larger than one, next() takes the newest frame set that is waiting, gives the older ones back and counts them as skipped. Frame sets that arrive before the plugin's answer to the subscription are kept and handed out first. A frame set can be given back from another thread and after its reader is gone. A plugin that goes away is reported as CameraDisconnected; opening fails with the plugin's own reason when a subscription is refused. camera_core now exposes the two rules the reader shares with the publisher, resolved_order and plane_size_of, instead of keeping them private. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
A backend opens cameras through one SDK. It implements CameraSource for a configured camera: describe() says what the camera publishes, start() gets a FrameOutput to acquire slots from and publish frame sets to. CameraHost is the plugin process without its main(): it allocates each camera's pools in shared host memory, registers the camera with one publisher, and serves all cameras to readers on one endpoint. A camera is configured as ID:BACKEND[:KEY=VALUE,...]. OptionReader makes a backend refuse options it does not read, so a misspelt option is an error instead of a setting that is silently ignored. A camera that names a backend the build does not have is refused with the list of those it has. The executable, the list of built backends and the synthetic backend follow in the next pull request. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Farbod Motlagh <fmotlagh@nvidia.com>
farbod-nv
force-pushed
the
fm/camera_capture_m0_plugin_core
branch
from
November 14, 2026 01:21
0abaa8f to
d11f913
Compare
farbod-nv
force-pushed
the
fm/camera_capture_m0_reader
branch
from
November 14, 2026 01:21
139c051 to
363e246
Compare
farbod-nv
force-pushed
the
fm/camera_capture_m0_reader
branch
from
November 14, 2026 02:53
363e246 to
643b236
Compare
This branch was successfully deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Seventh pull request of the camera interface, stacked on #1528 (
camera_reader), whose branch is this one's base.It adds the core of the camera plugin under
src/plugins/camera/core: what a camera backend implements, and the host that turns a set of cameras into something readers can connect to. The executable and the first backend follow in the next pull request.CameraSourceis one configured camera, implemented by a backend for its SDK.describe()says what it publishes (the group, its streams, the size of a slot).start()hands it aFrameOutput: acquire a free slot per stream, write the image, publish the frame set. When no slot is free the camera drops the frame set and carries on; nothing on the capture path waits for readers.CameraHostis the plugin process without itsmain(). It allocates each camera's pools in shared host memory, registers the camera with one publisher, and serves all cameras on one endpoint.ID:BACKEND[:KEY=VALUE,...]: the id readers ask for, the backend that opens it, and that backend's options.OptionReader, and an option that was set but never read is an error that names the camera, the backend and the option, so a misspelt option is not silently ignored.find_backendrefuses a camera whose backend is not in the build and lists the ones that are. The module'sAGENTS.mdrecords this and the other rules for backends.Type of change
Testing
tests/cpp/plugins/camera/test_camera_host.cpp(Catch2, 5 cases, taggedunit), with a camera that publishes when the test says so: camera arguments are parsed and malformed ones refused; options a backend does not read are refused, as are values that are not whole numbers in range; a backend that is not in the build is named with the ones that are; a host gives two cameras their pools, serves both on one endpoint, and readers see the pixels each camera wrote; a camera drops a frame set when its pool is full and never overwrites one a reader holds. Run withctest -L camera_plugin.BUILD_PLUGINS=ON) with the project warning set promoted to errors.clang-format-14reports no changes;SKIP=check-copyright-year pre-commit run --all-filespasses.Checklist
SKIP=check-copyright-year pre-commit run --all-filesgit commit -s) per the DCO🤖 Generated with Claude Code