Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_subdirectory(camera_core)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_subdirectory(camera_ipc)
add_subdirectory(camera_wire)
add_subdirectory(camera_endpoint)
endif()

# Build OXR library (depends on oxr_utils for types)
Expand Down
15 changes: 15 additions & 0 deletions src/core/camera_endpoint/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->

# Agent notes — `camera_endpoint`

**CRITICAL (non-optional):** Before editing this package, complete the mandatory **`AGENTS.md` preflight** in [`../../../AGENTS.md`](../../../AGENTS.md) (read every applicable `AGENTS.md` on your paths, not just this file).

Read [`README.md`](README.md) for what runs on which thread before changing it.

- **Nothing sits between publish and the socket.** A frame event is encoded and sent inside `send_event`, on the publishing thread. Do not add a queue or a thread hop there, and do not log per frame.
- **`send_event` holds the publisher's lock.** It must not take another lock, block or call the publisher. That lock is also what serialises each connection's event encoder.
- **Unsubscribe before a connection is destroyed.** `Publisher::unsubscribe` returning is the guarantee that no `send_event` is running or will start for that sink.
- **A reader is untrusted.** Whatever it sends can at most get it dropped; it must not stop the thread or affect other readers.
6 changes: 6 additions & 0 deletions src/core/camera_endpoint/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20)

add_subdirectory(cpp)
49 changes: 49 additions & 0 deletions src/core/camera_endpoint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->

# Camera interface: the endpoint

The camera plugin's side of the conversation with readers. It puts a
[`camera_core`](../camera_core) `Publisher` on a socket ([`camera_ipc`](../camera_ipc)) and
speaks the messages of [`camera_wire`](../camera_wire).

```cpp
Publisher publisher;
const GroupId head = publisher.add_group(description);
HostPool left(slots, bytes, "head.left"), right(slots, bytes, "head.right");

Endpoint endpoint(publisher, socket_path);
endpoint.set_group_memory(head, { left.descriptor(), right.descriptor() });
endpoint.start();
// ... the backend acquires slots, writes pixels and publishes; readers come and go ...
```

## What runs where

- **One thread of its own** accepts readers and handles what they send: the handshake,
subscriptions and releases. It sleeps in `poll` until a reader sends something.
- **Frame events are sent from the thread that publishes**, straight from
`Publisher::publish`, with a send that does not block. There is no queue and no hand-over
to another thread between a frame set being published and its event being on the socket.
The event that follows a release is sent from the endpoint's thread for the same reason.
- A reader's subscription takes effect before the answer to it is sent, so a `Frame` can
reach the reader ahead of `Subscribed`.

## When a reader goes away

A closed connection is the signal, whether the reader exited, crashed or was killed. Its
subscription ends and every frame set it held goes back to the pool. A reader that sends
bytes that are not a message, or a message only a plugin sends, is dropped the same way;
other readers are not affected.

## Logging

`isaaccapture.camera_endpoint.Endpoint` logs readers arriving, subscribing, being refused and
leaving. Nothing is logged per frame.

## Tests

`tests/cpp/core/camera_endpoint`, run with `ctest -L camera_endpoint`. They are tagged `unit`
and play the reader's part with the socket and the codec directly.
27 changes: 27 additions & 0 deletions src/core/camera_endpoint/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20)

find_package(Threads REQUIRED)

# The plugin's side of the conversation with readers: serves a Publisher's groups over a socket.
add_library(camera_endpoint STATIC
endpoint.cpp
)

target_include_directories(camera_endpoint INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)

target_link_libraries(camera_endpoint
PUBLIC
camera::camera_core
PRIVATE
camera::camera_ipc
camera::camera_wire
log_bridge::log_bridge_core
Threads::Threads
)

add_library(camera::camera_endpoint ALIAS camera_endpoint)
Loading
Loading