Skip to content

Capture: binding crate for libargus - #1357

Draft
ladvoc wants to merge 6 commits into
ladvoc/capture-source-device-v4l2from
ladvoc/libargus-sys
Draft

ladvoc wants to merge 6 commits into
ladvoc/capture-source-device-v4l2from
ladvoc/libargus-sys

Conversation

@ladvoc

@ladvoc ladvoc commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Add a libargus-sys crate with bindings to the NVIDIA Jetson libargus camera API.

Closes BOT-553

@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 278e398 to 5cff9e8 Compare August 25, 2026 21:35
@github-actions

Copy link
Copy Markdown
Contributor

Changeset ✓

This PR includes a changeset covering all affected packages:

Package Bump
libargus-sys minor

@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 3bc5485 to 7959b92 Compare August 25, 2026 23:13
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 7959b92 to 1730dd2 Compare August 28, 2026 03:09
enum {
LK_ARGUS_OK = 0,
/* Invalid arguments crossed the FFI boundary (caller bug). */
LK_ARGUS_ERR_INVALID_ARG = -1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It makes sense for error-codes, but typically I don't see negative values used for enums like this (I'm not a C developer so maybe it's common there)

#define LK_ARGUS_MAX_DMA_BUFS 16

/* Status codes. 0 is success; negative values are errors. */
enum {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

enum class is a little more modern. This code looks like C though which doesn't have that, but the .cpp has lots of C++ in it, so a bit puzzled

#if defined(__GNUC__)
__attribute__((format(printf, 2, 3)))
#endif
void lk_log(int32_t level, const char* fmt, ...) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we actually need another logger vs. just a std::cout/cerr or fprintf? This one is simple enough, just clarifying

Comment on lines +15 to +27
// C shim around NVIDIA libargus for MIPI CSI camera capture on Jetson.
// See lk_argus.h for the ABI and the thread-safety contract.

#include "lk_argus.h"

#include <atomic>
#include <chrono>
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <mutex>
#include <thread>
#include <vector>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Says C shim but lots of C++ in here

return LK_ARGUS_OK;
}

void lk_argus_session_destroy(LkArgusSession* s) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From AI-pairing, take with grain of salt:

P1: lk_argus_session_destroy can delete s while another thread is blocked in lk_argus_frame_acquire; when acquireFrame returns, that function continues dereferencing s. This contradicts the documented “interrupts any pending acquire” shutdown behavior and is a use-after-free. Please add an in-flight-operation count plus condition variable (destroy sets interrupted, stops capture, then waits for acquire/copy operations to exit before freeing surfaces and s), or change the API contract to require callers to interrupt and join the acquisition thread before destruction.

@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 94bd3e1 to 17fd029 Compare August 28, 2026 23:01
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 17fd029 to bc3d828 Compare August 31, 2026 18:43
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch 2 times, most recently from 74429d0 to 77dbd74 Compare September 9, 2026 23:55
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch 2 times, most recently from 6377b94 to f633156 Compare September 17, 2026 18:07
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 53180dd to 10b81c8 Compare September 17, 2026 20:37
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 10b81c8 to 94dee1e Compare September 17, 2026 21:59
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from 94dee1e to cf2336f Compare September 18, 2026 18:37
@ladvoc
ladvoc force-pushed the ladvoc/libargus-sys branch from cf2336f to f7de04c Compare September 18, 2026 19:31
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.

2 participants