Skip to content

video: record never, when armed, or always - #60

Draft
tridge wants to merge 5 commits into
ArduPilot:mainfrom
tridge:pr-record-armed
Draft

tridge wants to merge 5 commits into
ArduPilot:mainfrom
tridge:pr-record-armed

Conversation

@tridge

@tridge tridge commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Each video slot's record option is now never, when armed or always. "When armed" records only while the vehicle reports itself armed, so each flight gets its own segments and the disk budget isn't spent on a camera idling on the ground.

Arming

  • The armed state comes from the vehicle's HEARTBEAT on the entry's MAVLink session. Only the autopilot component (compid 1, not a GCS, not MAV_AUTOPILOT_INVALID) counts, and only the entry's FC system ID when one is set.
  • With no system ID set, any armed vehicle on the link counts. A reconnecting session holds back a disarm for 3 s after its first heartbeat, so that a vehicle still armed elsewhere on the link is heard first.
  • Changing the FC system ID ends the old vehicle's armed state at once, whether or not a session is running.
  • The last armed state outlives the session. A telemetry dropout in flight keeps recording, and reconnecting to a still-armed vehicle does not split the file.
  • Turning video on during a session now starts the heartbeat parsing it needs; before, that took a reconnect.

Recording

  • An MPEG-TS recording opens on a join point: the latest keyframe still in the ring, which is usually just before arming, or else the next one to arrive. The file therefore always starts playable.
  • Matroska starts at the next complete cluster.
  • Disarm closes the segment. Every re-arm starts a new segment, even if the video child missed the disarm in between.
  • A replacement publisher no longer appends to its predecessor's open segment.

Shared state

  • EntryLive is a small per-entry MAP_SHARED|MAP_ANONYMOUS page. The parent allocates it when it adds an entry, before any child is forked, so the parent, the session child and the video child share one copy.
  • The parent keeps the video flag and FC system ID in it current on each keys reload. The session child publishes the armed state and an arm counter. The video child reads them on every loop pass, without opening a database.
  • The armed word carries a generation that the parent bumps when its state no longer applies (another FC selected, the port reused). The session writes it only by compare-and-swap on the generation it last saw, so it can never restore a state the parent just cleared.
  • Video stays independent of the MAVLink session: the video child is still a child of the parent, and nothing in it depends on a session being alive.

Configuration

  • The webadmin's per-slot record checkbox becomes a selector. A form from before the change posts the checkbox's y, which still means always.
  • Choosing "when armed" seeds the default video budget and retention, as "always" did.
  • In keys.tdb it is the new VIDEO_SLOT_REC_ARMED bit alongside VIDEO_SLOT_RECORD. From the CLI that is ./keydb.py videoflag PORT2 SLOT record_armed.

Testing

  • New end-to-end daemon tests cover:
    • recording only while armed, with a new segment for a quick re-arm;
    • a re-arm the video child misses because it is SIGSTOPped across the transitions;
    • recording through a telemetry dropout;
    • ignoring GCS and non-selected-sysid heartbeats;
    • an FC system ID change with and without a session;
    • enabling video mid-session;
    • a disarmed reconnect that goes quiet, which stops recording after the settle time rather than at the idle exit.
  • The armed segment is checked to open on a PAT and to be a verbatim span of what was sent.
  • Webadmin tests cover the selector, the legacy y and default seeding.
  • The webadmin, recording, video child, bidi pre-auth, connection, binlog, tlog and sysid tests pass.

Known limits

  • A removed entry's EntryLive page (4 KB) stays mapped until the daemon restarts. It is reused if the port is re-added.
  • A re-arm within one video-loop pass of a disarm is handled by the arm counter. A disarm and re-arm both inside one heartbeat interval cannot be seen at all.
  • This changes the daemon, so deploying it needs a supportproxy restart, not just the webadmin.

VIDEO_SLOT_REC_ARMED, with VIDEO_SLOT_RECORD, records a slot only while
the vehicle is armed. RECORD alone keeps recording always.
EntryLive is a small per-entry shared mapping the parent allocates when
it adds an entry, keeping its video flag and FC sysid current on each
keys reload. The session child tracks SAFETY_ARMED from the autopilot's
HEARTBEAT and publishes it there from the first qualifying heartbeat on,
and turning video on during a session now starts the heartbeat parsing
it needs.

The video child reads the armed state on every pass of its loop without
touching a database. A recording opens on a join point, the latest
still in the ring or the next to arrive, so the file starts on a
keyframe. Disarm closes the segment and a re-arm always starts a new
one. The last armed state outlives the session, so a telemetry dropout
in flight keeps recording.
The per-slot record checkbox becomes a choice. A form from before posts
the checkbox's 'y', which still means always.
@tridge tridge added the AIReview Request an automated AI review; picked up by the reviewprs sweep label Dec 2, 2026
@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head d66282e955.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/supportproxy/60/1.html#prSupportProxy-60

Record-when-armed looks sound: the generation/CAS handoff, the arm-count ordering and the webadmin mode mapping all check out, and no blocking issue was found.

Should fix

  • video.cpp:795: a slot keeps ARMED after the session ends and has no expiry, so a new publisher with no MAVLink session records until a later session reports disarm. This is the documented dropout policy, but README.md:225 ('without one, a when-armed slot never records') overstates it. Reword the README, or let a stale ARMED lapse after a bounded time with no session.
Minor (2)
  • supportproxy.cpp:871: on a bidi-signed UDP entry the heartbeat in the first validated datagram is consumed by the pre-latch validation loop and never reaches observe_armed. Call observe_armed(vmsg) inside that loop.
  • video.cpp:2022: armed-only MPEG-TS recording waits for an RAI join point with no fallback, so a muxer that never sets random_access_indicator gets nothing recorded, while 'always' works. At least log why, or fall back after a bounded wait.

Withdrawn: README placement in the webadmin commit, which matches this repo's history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIReview Request an automated AI review; picked up by the reviewprs sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants