Skip to content
Open
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
5 changes: 4 additions & 1 deletion examples/camera_streamer/argus_sender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ if(WITH_SIPL)
find_library(NVSCIBUF_LIBRARY NAMES nvscibuf HINTS ${NVIDIA_LIBRARY_DIRS})
find_library(NVSCISYNC_LIBRARY NAMES nvscisync HINTS ${NVIDIA_LIBRARY_DIRS})
find_library(NVBUFSURFACE_NVSCI_LIBRARY NAMES nvbufsurface_nvsci HINTS ${NVIDIA_LIBRARY_DIRS})
# The VIC converts a YUV camera's UYVY capture output to NV12 for the encoder.
find_library(NVBUFSURFTRANSFORM_LIBRARY NAMES nvbufsurftransform HINTS ${NVIDIA_LIBRARY_DIRS})
foreach(sipl_var SIPL_INCLUDE_DIR SIPL_QUERY_INCLUDE_DIR NVSCI_INCLUDE_DIR NVSIPL_LIBRARY NVSIPL_QUERY_LIBRARY
NVSCIBUF_LIBRARY NVSCISYNC_LIBRARY NVBUFSURFACE_NVSCI_LIBRARY)
NVSCIBUF_LIBRARY NVSCISYNC_LIBRARY NVBUFSURFACE_NVSCI_LIBRARY NVBUFSURFTRANSFORM_LIBRARY)
if(NOT ${sipl_var})
message(FATAL_ERROR "WITH_SIPL=ON but ${sipl_var} was not found")
endif()
Expand All @@ -220,6 +222,7 @@ if(WITH_SIPL)
${NVSCISYNC_LIBRARY}
${NVBUFSURFACE_LIBRARY}
${NVBUFSURFACE_NVSCI_LIBRARY}
${NVBUFSURFTRANSFORM_LIBRARY}
Threads::Threads
)
target_sources(argus_sender PRIVATE src/SiplSender.cpp)
Expand Down
4 changes: 3 additions & 1 deletion examples/camera_streamer/argus_sender/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ acquire average/max and selected-frame gaps once per `runtime.log_interval_s`
(one second by default), even with `runtime.kpi: false`; set the interval to
zero to disable it. The SOF latency is `n/a` when comparable TSC metadata is
unavailable. With KPI enabled, `[head-handoff:<stream-id>]` also reports
priority slot overwrites and alignment drops once per interval. A priority
priority slot overwrites and alignment drops once per interval, and the SIPL
backend reports each YUV camera's UYVY-to-NV12 conversion time (mean and
maximum) and the captures it dropped with no free NV12 picture. A priority
camera exits after 10 seconds without its first new frame or 1 second without
a subsequent new frame, including repeated acquisitions of the same frame
number; the service can then restart it.
Expand Down
8 changes: 5 additions & 3 deletions examples/camera_streamer/argus_sender/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,16 @@ bool loadConfigFile(const std::string& path, AppConfig* config, std::string* err
if (root["sipl"])
{
const YAML::Node sipl = root["sipl"];
const std::set<std::string> allowed = { "platform_config_json", "platform_config_name", "link_masks",
"nito_dir", "isp0_buffers" };
const std::set<std::string> allowed = { "platform_config_json", "platform_config_name",
"link_masks", "nito_dir",
"isp0_buffers", "yuv_cameras" };
if (!rejectUnknown(sipl, allowed, "sipl", error) ||
!readOptional(sipl, "platform_config_json", "sipl", &config->sipl.platformConfigJson, error) ||
!readOptional(sipl, "platform_config_name", "sipl", &config->sipl.platformConfigName, error) ||
!readOptional(sipl, "link_masks", "sipl", &config->sipl.linkMasks, error) ||
!readOptional(sipl, "nito_dir", "sipl", &config->sipl.nitoDir, error) ||
!readUint32(sipl, "isp0_buffers", "sipl", &config->sipl.isp0Buffers, error))
!readUint32(sipl, "isp0_buffers", "sipl", &config->sipl.isp0Buffers, error) ||
!readOptional(sipl, "yuv_cameras", "sipl", &config->sipl.yuvCameras, error))
{
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions examples/camera_streamer/argus_sender/src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ struct SiplSettings
std::vector<uint32_t> linkMasks;
std::string nitoDir = "/var/nvidia/nvcam/settings/sipl";
uint32_t isp0Buffers = 6;
// Pipeline indexes of the YUV422/UYVY cameras, which bypass the ISP.
std::vector<uint32_t> yuvCameras;
};

struct AppConfig
Expand Down
409 changes: 359 additions & 50 deletions examples/camera_streamer/argus_sender/src/SiplCapture.cpp

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions examples/camera_streamer/argus_sender/src/SiplCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#ifndef ARGUS_SENDER_SIPL_CAPTURE_H
#define ARGUS_SENDER_SIPL_CAPTURE_H

// SIPL capture of every sensor in one platform configuration, ISP0 native NV12 out. The SIPL and NvSci headers stay
// SIPL capture of every sensor in one platform configuration, native NV12 out: ISP0's for a raw sensor, the VIC's
// conversion of the capture output for a YUV camera. The SIPL and NvSci headers stay
// inside SiplCapture.cpp: they pull in macros that collide with other libraries.

#include "CameraCapture.h"
Expand All @@ -30,9 +31,13 @@ struct SiplConfig
// Directory holding <module>.nito; the ISP has no tuning without it.
std::string nitoDir = "/var/nvidia/nvcam/settings/sipl";
int gpuId = 0;
// ISP0 buffers per sensor. A frame an encoder still holds is one fewer for the ISP.
// Pipeline indexes of the YUV422/UYVY cameras, which bypass the ISP.
std::vector<uint32_t> yuvCameras;
// Picture buffers per sensor. A frame an encoder still holds is one fewer for capture.
uint32_t isp0Buffers = 6;
uint32_t frameTimeoutMs = 1000;
// Seconds between a YUV camera's conversion summaries; 0 prints none.
uint32_t logIntervalSeconds = 0;
// Stamped on every frame; the caller changes it whenever capture is rebuilt.
uint64_t sessionEpoch = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions examples/camera_streamer/argus_sender/src/SiplSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ bool runSiplSender(const AppConfig& config, bool* receiverDisconnected, bool app
siplConfig.linkMasks = config.sipl.linkMasks;
siplConfig.nitoDir = config.sipl.nitoDir;
siplConfig.isp0Buffers = config.sipl.isp0Buffers;
siplConfig.yuvCameras = config.sipl.yuvCameras;
siplConfig.logIntervalSeconds = config.runtime.kpi ? config.runtime.logIntervalSeconds : 0;
const uint64_t sessionId = createCaptureSessionId();
siplConfig.sessionEpoch = sessionId;

Expand Down
4 changes: 4 additions & 0 deletions examples/camera_streamer/argus_sender/tests/test_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ int main()
test, static_cast<int>(backend.captureBackend), static_cast<int>(argus_sender::CAPTURE_BACKEND_SIPL));
TEST_CHECK_EQ(test, backend.sipl.linkMasks.size(), static_cast<size_t>(2));
TEST_CHECK_EQ(test, backend.sipl.platformConfigName, std::string("RIG"));
TEST_CHECK(test, backend.sipl.yuvCameras.empty());
TEST_CHECK(test, loadText("version: 1\ncapture_backend: sipl\n" + sipl + " yuv_cameras: [4, 5]\n" + streams,
&backend, &error));
TEST_CHECK_EQ(test, backend.sipl.yuvCameras.size(), static_cast<size_t>(2));
TEST_CHECK(
test,
!loadText(
Expand Down
12 changes: 9 additions & 3 deletions examples/egocap/CAMERA_SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ camera on the SIPL backend: HEVC at 30 fps and 4 Mbit/s.
The file is specific to that rig. A different SIPL platform or camera changes the `sipl` block (platform file, config
name, link masks, tuning directory) and possibly the stream id and size. The Argus backend has no `sipl` block: it
selects a sensor mode with `cameras[].mode`, can set `capture.mode` and `alignment`, enforces `output.fps` with a rate
limiter and can set output dimensions. Keep one file per rig and pass the right one with `--sender-config`. The launcher itself supports one stream per
file and requires an explicit `output.fps`.
limiter and can set output dimensions. Keep one file per rig and pass the right one with `--sender-config`. The launcher itself supports
mono streams only: each becomes one receiver stream and one LiveKit track named `sensing-<id>`, so the default
profile's `head` stream is on `sensing-head` and a stream with another id is on another track. The streams share one
explicit `output.fps` and each needs its own `id`; a profile with several streams sets every stream's `output.width`
and `output.height`. `--fps` and `--bitrate-mbps` apply to every stream.
`configs/s56c-shf3l-camera-settings.yaml` is such a profile, for an S56C stereo head camera with two SHF3L wrist
cameras.

`tools/start_system.py` loads this file by default. Command-line overrides (`--fps`, `--bitrate-mbps`,
`--sender-port`) are applied to the loaded mapping, and the result is what is uploaded. The same
Expand Down Expand Up @@ -98,7 +103,8 @@ shipped profile.
| `sipl.platform_config_name` | Empty; required for SIPL | Named platform inside the database/JSON. |
| `sipl.link_masks` | Empty; required for SIPL | Sequence of unsigned masks, one per deserializer in transport order; passed to `ApplyMask`. Not an FPS knob. |
| `sipl.nito_dir` | `/var/nvidia/nvcam/settings/sipl` | ISP tuning directory; loads `<module-name>.nito` on the Orin. Not a YAML sensor-mode selector. |
| `sipl.isp0_buffers` | `6`; at least 2 | Number of ISP0 surfaces allocated/registered per sensor. Surface ownership and return timing affect pressure; increasing the count does not directly select FPS. |
| `sipl.isp0_buffers` | `6`; at least 2 | Number of picture surfaces allocated/registered per sensor: ISP0 surfaces for a raw sensor, capture buffers and converted pictures for a YUV camera. Surface ownership and return timing affect pressure; increasing the count does not directly select FPS. |
| `sipl.yuv_cameras` | Empty | SIPL pipeline indexes of the YUV422/UYVY cameras. Their capture output bypasses the ISP and is converted to NV12; a YUV camera that is not listed is refused. |
| `network.bind` | `0.0.0.0`; nonempty | Sender TCP listening address. |
| `network.port` | `5000`; 1–65535 | AVS1 TCP listening port. Receiver must connect here. |
| `network.reconnect_ms` | `1000` | Retry delay for failed listen setup. Not a per-frame sleep or FPS limiter. |
Expand Down
2 changes: 1 addition & 1 deletion examples/egocap/configs/default-camera-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

# Default camera settings for tools/start_system.py: what the Orin's camera sender runs with.
# It is the only profile for now and describes one rig, a single SHW5G head camera on the SIPL backend. Pass another
# It describes one rig, a single SHW5G head camera on the SIPL backend. Pass another
# file with --sender-config for a different rig. CAMERA_SETTINGS.md describes every key.
#
# The launcher uploads this file to the Orin, where the sender reads it once at start; to change a value, stop the
Expand Down
46 changes: 46 additions & 0 deletions examples/egocap/configs/s56c-shf3l-camera-settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Camera settings for an S56C stereo head camera with two SHF3L wrist cameras on the SIPL backend. Pass it to
# tools/start_system.py with --sender-config. CAMERA_SETTINGS.md describes every key.

version: 1
capture_backend: sipl

# These paths are on the Orin. The platform file is the camera vendor's mixed S56C + SHF3L layout, here with the SHF3L
# cameras on deserializer links 0 and 1 and the S56C on link 2.
sipl:
platform_config_json: /opt/isaaccapture/camera-platform.json
platform_config_name: SHF3L_2_S56C_1
link_masks: [273, 0] # 0x0111: links 0, 1 and 2 of the first deserializer
nito_dir: /var/nvidia/nvcam/settings/sipl
yuv_cameras: [4, 5] # the SHF3L cameras output YUV422, which bypasses the ISP

network:
bind: 0.0.0.0
port: 5000

runtime:
frames: 0
kpi: true
log_interval_s: 1

# device is the SIPL pipeline index under this platform file: the S56C's eyes are 7 (left) and 6 (right), the SHF3L
# cameras 5 and 4. The streams share one fps, and several streams each state their size.
streams:
- id: head_left
type: mono
cameras: [{device: 7, mode: 0}]
output: {codec: hevc, fps: 30, bitrate_mbps: 8, width: 2560, height: 1984}
- id: head_right
type: mono
cameras: [{device: 6, mode: 0}]
output: {codec: hevc, fps: 30, bitrate_mbps: 8, width: 2560, height: 1984}
- id: wrist_left
type: mono
cameras: [{device: 5, mode: 0}]
output: {codec: hevc, fps: 30, bitrate_mbps: 4, width: 1920, height: 1536}
- id: wrist_right
type: mono
cameras: [{device: 4, mode: 0}]
output: {codec: hevc, fps: 30, bitrate_mbps: 4, width: 1920, height: 1536}
118 changes: 99 additions & 19 deletions examples/egocap/tests/tools/test_start_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def test_publisher_token_is_a_verifiable_hs256_jwt():


def test_generated_configs_parse_and_carry_parameters():
streams = yaml.safe_load(ss.streams_yaml("ws://h:1", "r", "p", "trk", 640, 480, 30, "b", "head"))
streams = yaml.safe_load(ss.streams_yaml("ws://h:1", "r", "p", [("head", 640, 480)], 30, "b"))
stream = streams["livekit"]["streams"][0]
assert (stream["track"], stream["width"], stream["height"]) == ("trk", 640, 480)
assert (stream["track"], stream["width"], stream["height"]) == ("sensing-head", 640, 480)

receiver = yaml.safe_load(ss.receiver_yaml("h", 5555, "/tmp/s.sock", 640, 480, "head"))
receiver = yaml.safe_load(ss.receiver_yaml("h", 5555, "/tmp/s.sock", [("head", 640, 480)]))
assert receiver["receiver"]["port"] == 5555
assert (receiver["streams"][0]["width"], receiver["streams"][0]["height"]) == (640, 480)

Expand Down Expand Up @@ -172,7 +172,26 @@ def record_start(self, name, command, *_, **__):
def test_default_profile_gives_the_head_camera_settings():
config = ss.load_sender_config(ss.DEFAULT_SENDER_CONFIG)
assert ss.sender_settings(config) == ss.SenderSettings(
port=5000, fps=30, bitrate_mbps=4, stream_id="head", full_range=True, sipl=True
port=5000,
fps=30,
total_bitrate_mbps=4,
stream_ids=("head",),
full_range=True,
sipl=True,
sizes=((None, None),),
)


def test_s56c_shf3l_profile_gives_four_sized_streams():
config = ss.load_sender_config(ss.EGOCAP_ROOT / "configs/s56c-shf3l-camera-settings.yaml")
assert ss.sender_settings(config) == ss.SenderSettings(
port=5000,
fps=30,
total_bitrate_mbps=24,
stream_ids=("head_left", "head_right", "wrist_left", "wrist_right"),
full_range=True,
sipl=True,
sizes=((2560, 1984), (2560, 1984), (1920, 1536), (1920, 1536)),
)


Expand All @@ -185,10 +204,16 @@ def test_argus_backend_is_not_full_range():
def test_overrides_replace_only_their_values():
config = ss.load_sender_config(ss.DEFAULT_SENDER_CONFIG, 60, 9, 5100)
assert ss.sender_settings(config) == ss.SenderSettings(
port=5100, fps=60, bitrate_mbps=9, stream_id="head", full_range=True, sipl=True
port=5100,
fps=60,
total_bitrate_mbps=9,
stream_ids=("head",),
full_range=True,
sipl=True,
sizes=((None, None),),
)
partial = ss.sender_settings(ss.load_sender_config(ss.DEFAULT_SENDER_CONFIG, fps=15))
assert (partial.fps, partial.bitrate_mbps, partial.port) == (15, 4, 5000)
assert (partial.fps, partial.total_bitrate_mbps, partial.port) == (15, 4, 5000)


@pytest.mark.parametrize(
Expand All @@ -209,13 +234,13 @@ def test_sender_settings_rejects_an_incomplete_profile(mutate):
ss.sender_settings(config)


def test_load_sender_config_rejects_missing_file_and_two_streams(tmp_path: Path):
def test_load_sender_config_rejects_missing_file_and_no_streams(tmp_path: Path):
with pytest.raises(ss.StartupError):
ss.load_sender_config(tmp_path / "absent.yaml")
two = tmp_path / "two.yaml"
two.write_text("streams:\n - {id: a}\n - {id: b}\n")
empty = tmp_path / "empty.yaml"
empty.write_text("streams: []\n")
with pytest.raises(ss.StartupError):
ss.load_sender_config(two)
ss.load_sender_config(empty)


def _profile_with(tmp_path: Path, mutate) -> Path:
Expand Down Expand Up @@ -441,7 +466,7 @@ def interrupted_wait(*args, **kwargs):

def test_mock_sender_command_follows_the_profile():
settings = ss.sender_settings(ss.load_sender_config(ss.DEFAULT_SENDER_CONFIG))
command = ss.mock_sender_command("python", Path("mock.py"), settings, 2560, 1984)
command = ss.mock_sender_command("python", Path("mock.py"), settings, [("head", 2560, 1984)])
assert command == ["python", "mock.py", "--port", "5000", "--stream", "head:2560x1984@30"]


Expand Down Expand Up @@ -1046,29 +1071,84 @@ def test_load_sender_config_refuses_a_stream_that_is_not_mono(tmp_path: Path):
ss.load_sender_config(_profile_with(tmp_path, _stereo_profile))


def _head_and_wrist(config: dict) -> None:
head = config["streams"][0]
head["output"].update(width=2560, height=1984)
wrist = {
**head,
"id": "wrist",
"cameras": [{"device": 1, "mode": 0}],
"output": {**head["output"], "width": 1920, "height": 1536},
}
config["streams"] = [head, wrist]


def test_streams_keep_their_own_sizes_and_must_share_the_rate(tmp_path: Path):
config = ss.load_sender_config(_profile_with(tmp_path, _head_and_wrist), bitrate_mbps=6)
settings = ss.sender_settings(config)
assert (settings.stream_ids, settings.total_bitrate_mbps) == (("head", "wrist"), 12)
assert settings.sizes == ((2560, 1984), (1920, 1536))
config["streams"][1]["output"]["fps"] = 60
with pytest.raises(ss.StartupError, match="share"):
ss.sender_settings(config)


def test_several_streams_need_their_own_ids_and_sizes(tmp_path: Path):
config = ss.load_sender_config(_profile_with(tmp_path, _head_and_wrist))
del config["streams"][1]["output"]["width"]
with pytest.raises(ss.StartupError, match="every stream's output.width"):
ss.sender_settings(config)
config["streams"][1]["output"]["width"] = 0
with pytest.raises(ss.StartupError, match=r"streams\[1\].output.width"):
ss.sender_settings(config)
config["streams"][1]["output"]["width"] = 1920
config["streams"][1]["id"] = "head"
with pytest.raises(ss.StartupError, match="its own id"):
ss.sender_settings(config)


def test_main_carries_every_stream_at_its_own_size(recorded_main, tmp_path: Path):
mock_sender = tmp_path / "mock_sender.py"
mock_sender.write_text("")
argv = ["--mock", "--bridge", "b", "--livekit-server", "l", "--mock-sender", str(mock_sender)]
assert ss.main([*argv, "--sender-config", str(_profile_with(tmp_path, _head_and_wrist))]) == 0
assert "--stream head:2560x1984@30 --stream wrist:1920x1536@30" in _command(recorded_main, "mock-sender")
assert "--stream head=sensing-head:2 --stream wrist=sensing-wrist:2" in _command(recorded_main, "bridge")
received = yaml.safe_load((recorded_main.workdir / "receiver.yaml").read_text())["streams"]
assert [(r["index"], r["name"], r["width"], r["height"]) for r in received] == [
(0, "head", 2560, 1984),
(1, "wrist", 1920, 1536),
]
declared = yaml.safe_load((recorded_main.workdir / "streams.yaml").read_text())["livekit"]["streams"]
assert [(d["name"], d["track"], d["width"], d["height"]) for d in declared] == [
("head", "sensing-head", 1280, 992),
("wrist", "sensing-wrist", 960, 768),
]


def test_frame_size_defaults_to_the_sensor_size_and_follows_the_flags():
settings = ss.sender_settings(ss.load_sender_config(ss.DEFAULT_SENDER_CONFIG))
assert ss.frame_size(settings, None, None) == (2560, 1984)
assert ss.frame_size(settings, 640, 480) == (640, 480)
assert ss.frame_size(settings.sizes[0], None, None) == (2560, 1984)
assert ss.frame_size(settings.sizes[0], 640, 480) == (640, 480)
with pytest.raises(ss.StartupError, match="divide"):
ss.frame_size(settings, 641, 480)
ss.frame_size(settings.sizes[0], 641, 480)


def test_frame_size_follows_the_profile_and_refuses_contradicting_flags(tmp_path: Path):
config = yaml.safe_load(_profile_with(tmp_path, _sized(1280, 960)).read_text())
settings = ss.sender_settings(config)
assert ss.frame_size(settings, None, None) == (1280, 960)
assert ss.frame_size(settings, 1280, 960) == (1280, 960)
assert ss.frame_size(settings.sizes[0], None, None) == (1280, 960)
assert ss.frame_size(settings.sizes[0], 1280, 960) == (1280, 960)
with pytest.raises(ss.StartupError, match="--width 2560 contradicts"):
ss.frame_size(settings, 2560, None)
ss.frame_size(settings.sizes[0], 2560, None)
with pytest.raises(ss.StartupError, match="--height"):
ss.frame_size(settings, None, 1984)
ss.frame_size(settings.sizes[0], None, 1984)


def test_frame_size_refuses_a_profile_that_sets_only_one_dimension(tmp_path: Path):
config = ss.load_sender_config(_profile_with(tmp_path, _sized(1280, None)))
with pytest.raises(ss.StartupError, match="both"):
ss.frame_size(ss.sender_settings(config), None, None)
ss.frame_size(ss.sender_settings(config).sizes[0], None, None)


def test_main_writes_the_profile_output_size_into_the_receiver_and_the_descriptor(recorded_main, tmp_path: Path):
Expand Down
Loading
Loading