Skip to content

Ariadne: video: and audio: widgets; cvcMedia's FFmpeg + SDL3 player (media M5, stacked on #933 + #934) - #935

Merged
transfix merged 59 commits into
masterfrom
feat/ariadne-media-video
Nov 2, 2026
Merged

transfix merged 59 commits into
masterfrom
feat/ariadne-media-video

Conversation

@transfix

@transfix transfix commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Media M5 from the design (#929). Stacked: this branch merges #933 (which carries #932 and #931) and #934. Review only 24d392a (and the merge commits). It targets master so the full CI runs.

- video: clip
  src: https://media.example/p/9.webm      # a URI, or a computed expression giving one
  auth: example
  poster: https://media.example/p/9.jpg
  size: [480, 270]
  bind: feed.items.{i}.player              # state keys below
  autoplay: false
  loop: false
  muted: false
- audio: voice note
  src: https://media.example/p/10.opus
  bind: feed.items.{i}.voice

Reference: docs/ARIADNE.md §5.13.

Core (media_player.h, no deps). The Runtime owns each player widget:

  • Picture box. It shows the newest frame. Before that it shows the poster through Ariadne: image: shows a picture by URL (media M1) #931's cache, else a placeholder. A terminal gets at most 8 frames a second.
  • Controls. Built from every backend's widgets: Play/Pause, a seek slider whose value text is m:ss / m:ss (a no-conversion format, which prints as-is in ImGui and FTXUI), Mute, and Open.
  • State keys. state (idle|loading|ready|playing|paused|ended|failed|remote|unsupported), playing (writable), position (at most 4 Hz while playing), duration, seek (writable, consumed), muted (writable) and error.
  • When a walk doesn't draw the widget (its window closed, its item scrolled out of a repeat), the player pauses at once and is closed 5 s later. Snapshots wait while a player is loading.
  • Hosts register a media::Player factory. Without one, the widget is unsupported and offers Open.
  • SSH and policy. With SSH_CONNECTION, SSH_CLIENT or SSH_TTY set, the widget is remote and nothing is opened. Open runs (open-url URL) where the host has it (Ariadne: sign in with any OpenID Connect provider (oidc-sign-in, open-url; nicotina L7, L9) #916), and the tooltip says an auth: source needs the browser's own sign-in. --media-play auto|always|never is a new general flag.
  • Capability tokens media and media.player. ari info shows the player.

cvcMedia's player (cvc/media/player.h, FFmpeg optional, linked shared: cvcpkg's ffmpeg-lgpl):

  • It fetches the source whole through fetch_bytes, so the policy and auth: hold for http(s) and file/cvc/state work. The cap is 64 MiB, read through an AVIOContext.
  • It decodes on its own thread, scales frames to the box with libswscale, and resamples to 48 kHz stereo f32 with libswresample.
  • Sound plays through SDL3 audio and is the clock (the wall clock without sound). Mute keeps the clock by playing silence.
  • SDL's device is opened and closed on the frame thread, as SDL requires.
  • Pause flushes the queued tail; seek decodes up to the target so the paused picture moves; at the end, play starts over.
  • FFmpeg's stderr logging is silenced (CVC_MEDIA_FFMPEG_LOG=1 turns it back on), because it would corrupt a terminal backend's screen.
  • ari-media and arigl call register_ariadne_player(). The ari-media recipe now depends on ffmpeg-lgpl.

Tests

  • MediaPlayer.* (6): the controller with a fake player. It covers the policy and time format, the loader, unsupported with Open, remote (nothing opened, the sign-in tooltip), the controls and state keys driving the player (Play button, writes to playing/seek/muted, the seek slider, the Mute checkbox), autoplay, failure, and a hidden widget pausing.
  • cvcmedia_player: FFmpeg on a committed 2 s VP8/Opus WebM (14 KB) and a 1.5 s Opus tone (3 KB). It checks ready with the first frame scaled into the box, play with new frames and a moving clock, seek, pause (clock stopped), end, replay, sound-only, and failures (a missing file, a PNG as audio).
  • AriMedia.* +3: the lean ari says unsupported; ari-media shows testsrc's colour bars from decoded frames; over SSH it is remote, and --media-play always|never and a bad value exit 2.
  • ari_run_media_player_{ftxui,tvision}: ari-media plays under ari run in tmux on SDL's dummy driver.
  • cvcgl_imgui_media: ImGui gets 5+ distinct frames and a Pause button while the clip autoplays.

Verified locally (GCC 13, Release; system FFmpeg 6.1 headers and libs, cvcpkg SDL3): ctest Ariadne|Ari|ari_|Media|cvcgl_imgui|cvcgl_ari|cvcgl_*(audio|media|mic)|cvcmedia|x11|Net|Uri|AsyncCalls passed 796/796 (one skip as on master). ffmpeg_player.cpp compiles without FFmpeg. clang-format 18 is clean.

Not done here / follow-ups

  • CI runners likely have no FFmpeg, so cvcmedia_player and the ari-media playback tests skip there, while the controller tests always run.
  • The cvcgl recipe doesn't depend on ffmpeg-lgpl, so a packaged arigl has no player yet. Adding it would put FFmpeg in every cvcGL consumer; that's the owner's call.
  • The browser players are M6.
  • cvcpkg's alsa-lib bakes its build path in for alsa.conf, so SDL's ALSA backend prints errors at device open. That's a packaging bug in cvcpkg.

Since opening:

Joe Rivera added 9 commits October 30, 2026 22:24
An image: whose src (or bound value, or computed expression) is a URI now
loads that picture: http(s) through the host's network policy, with
auth: NAME sending the host's credential on the http verbs' terms; file://
relative to the document. The media cache (media.h) fetches, decodes,
downscales and fits off the frame on the app's background pool (a step per
drain in a browser build without threads), shares one fetch between boxes,
evicts idle pictures and retries failures. Widgets draw a placeholder of
their box until the picture arrives and a darker one on failure, with the
reason in the tooltip and at an optional status: key.

- cvc::decode_image: PNG/JPEG/GIF/BMP via stb, WebP via libwebp (now linked
  directly, optional), TIFF/AVIF/HEIC via ImageMagick with the coder named
  from the magic bytes; size caps checked before decoding.
- fit: contain|cover|fill and shape: circle, made by the core so every
  backend draws the raster unchanged; size: [w, h] is a box.
- FTXUI half-blocks honour alpha (a transparent half keeps the terminal's
  background); Backend::drop_image frees an evicted picture (ImGui deletes
  its texture).
- host_get + net_host_access: a host-side GET on the verbs' terms.
- ari/arigl snapshot (and ari test) wait for the pictures a frame drew.
- Tests: ariadne_media_test (decode, fit, cache, widget over a local server
  with a credential and a token scan), ari_media_test (the ari binary),
  ari_run_media_images_{ftxui,tvision} (tmux), cvcgl_imgui_media.
A window, overlay or group may take background: {src|bind, auth, fit,
opacity, terminal, banner_rows, status} (or a bare URL): a picture by URI
through the media cache, or a published image name, drawn behind the
content. The core brackets the content with the new Backend::begin_backdrop
/ end_backdrop; each backend fits the picture to the area the content takes.

- ImGui: the content goes on a draw-list channel above the picture, which is
  drawn (cover/contain/fill UVs, opacity as tint alpha) once the area is
  known: a window's inner rect, a group's rect, full width unless size: says
  otherwise and at least size:'s height.
- FTXUI and tvision: terminal: behind draws dimmed half-blocks under the
  content and turns each cell the content wrote text into readable (the
  picture's colour as background, dimmed to <= 40%, the terminal's own
  foreground); terminal: banner draws the picture as a row above the
  content, in Kitty/Sixel/iTerm pixels once its width is known; none draws
  nothing. No background in mono.
- Tests: loader, core bracketing (ariadne_media_test), FTXUI behind/banner
  layout, ImGui split/merge and the authored height (cvcgl_imgui_media), and
  the tmux test now checks a window background on both terminal backends.
card.ari in the component library: a bordered card (a one-column grid with
an outer border) with an avatar / title / subtitle / timestamp header, a
body text, a media slot and an action row. Its args are state keys, so a
repeat: includes one per item of a feed; a part whose key is empty is not
drawn. Generic: a post, a message, a search hit.

Args only take strings, so units gain slots: a '- slot: NAME' item in a
unit's widget list is replaced by the include site's slots: {NAME: [...]}
widgets (a single widget map works too; an unfilled slot is dropped; the
unit's args are not substituted into the include site's own widgets).

Tests: AriadneModularity.SlotsTakeTheIncludeSitesWidgets; the shipped
components test checks card.ari (an embeddable unit, not a window);
AriMedia card snapshot over a local server (avatar, a 404 attachment's
failed box, the action row); ari_run_media_card_{ftxui,tvision} in tmux;
the card's avatar in ImGui (cvcgl_imgui_media).
…media M4)

cvcMedia (src/cvcMedia) is libcvc's GL-free media library, its own package
like cvcGL (find_package(cvcMedia), cvc::cvcMedia), so the cvc package's
single-target contract and the lean libcvc are untouched. It holds the SDL3
audio output and the auto-pumped stream player that were cvcGL's, now
cvc::media::playback (cvc/media/playback/*.h); SDL3 is optional and only its
audio subsystem is used. cvcGL links it and keeps the cvc::gl::playback names
as aliases, so the conference app and media verbs are unchanged; a
standalone cvcGL build (the cvcgl recipe) builds and installs it beside
itself, and the recipe ships it.

ari-media is the same ari with cvcMedia linked: sound with no window,
display, GL, VTK or ImGui (ari-media info lists the playback devices). It is
built with cvcGL or -DCVC_BUILD_ARI_MEDIA=ON in-tree, and by the new
ari-media recipe from src/ari with -DARI_WITH_MEDIA=ON, which links cvcMedia
statically, so the package is bin/ari-media alone (deps: libcvc, sdl3). The
lean ari links libcvc only, as before.

Test: cvcmedia_audio_output plays through SDL's dummy driver with the video
subsystem never initialized and no GL/VTK/ImGui/cvcGL loaded.
…media M5)

video: / audio: take src (a URI or a computed expression), auth, poster,
size/fit, bind (the player's state keys), autoplay, loop and muted. The core
(media_player.h) owns the widget: a picture box (the newest frame, else the
poster, else a placeholder; at most 8 frames/s in a terminal), controls
drawn with every backend's widgets (Play/Pause, a seek slider whose value is
'm:ss / m:ss', Mute, Open), and state keys: state, playing (writable),
position, duration, seek (writable, consumed), muted (writable), error.

A host registers the player behind media::Player. cvcMedia's FFmpeg player
(cvc/media/player.h) fetches the source whole through fetch_bytes (policy,
auth:, file/cvc/state), decodes on its own thread (libavformat/libavcodec),
scales frames to the box (libswscale), resamples to 48 kHz stereo f32
(libswresample) and plays through SDL3 audio, which is the clock (the wall
clock without sound); SDL's device is opened and closed on the frame thread.
FFmpeg is optional and linked shared (ffmpeg-lgpl). ari-media and arigl
register it; the lean ari has none, so its players say unsupported.

Over SSH (SSH_CONNECTION/SSH_CLIENT/SSH_TTY) players say remote and open
nothing; Open runs (open-url URL) where the host has it. --media-play
auto|always|never sets it. Capability tokens media and media.player; ari
info shows the player. A player whose widget a walk did not draw pauses at
once and closes after 5 s; snapshots wait while a player loads.

Tests: MediaPlayer.* (the controller with a fake player: unsupported,
remote, controls, state keys, autoplay, failure, hidden pauses);
cvcmedia_player (FFmpeg on a 2 s VP8/Opus clip and an Opus tone: ready with
a first frame, play, seek, pause, end, replay, failures); AriMedia.* with
ari-media (frames' colours, SSH default, --media-play);
ari_run_media_player_{ftxui,tvision} (tmux); the ImGui frames
(cvcgl_imgui_media).
X11 headers define None, so x11_macro_headers_test failed to compile
widget.h. The YAML value stays terminal: none.
transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
…layer

A card's first video or recording, and each one in a post opened whole, is a
video: or audio: (transfix/libcvc#935) with its controls (Play/Pause, seek,
Mute), where the host has a player (media.player: ari-media and arigl).
Elsewhere, and on a host without the widgets (which warns and draws nothing),
they stay rows. The card's picture and video are 192 px wide (24 x 7 cells).

The launcher runs ari-media, ari with sound and video, in a terminal where it is
installed (bin/nicotina and nicotina.cmd); NICOTINA_ARI still wins.

run.sh, on a host with a player: the players are there, the recordings were
fetched without the session token, and in tmux Play runs the video to its end;
the Tab counts take the players' stops into account. The launcher's dry run
picks ari-media from PATH.
Joe Rivera added 12 commits October 31, 2026 00:01
…k tests without FFmpeg

A cross build's pkg-config could find the host's FFmpeg for cvcGL's wasm
build; the pages use the browser's own media elements instead. On a runner
whose cvcMedia has no FFmpeg, ari-media's players say unsupported, so the
tmux playback test is not registered and the SSH test skips.
…a reply names

image.url holds in every host that loads a picture by URI, so a document for
older hosts gates its pictures on (has? "image.url") and keeps its own
placeholder elsewhere (an older host prints an unknown URI as text).

A picture whose URL a reply puts in state was drawn as its loading
placeholder by ari snapshot / arigl --terminal snapshot: no frame had asked
for it while the request was out, so the settle loop never waited for it.
AppRuntime::settle_and_render settles, draws, and while that frame drew a
picture still loading, settles and draws again (within the same 10 s).
Test: AriMedia.SnapshotWaitsForAPictureWhoseUrlComesFromAReply.
… the image.background token

A text: with color: wraps its row in a colour decorator, which recoloured
the backdrop's half-blocks after the text (solid bars in the text's colour).
BackdropText now gives a cell that is still the backdrop's own (its
character and background) the picture's foreground back. Test:
MediaBackground.ColouredTextDoesNotPaintTheBackdropBesideIt.
image.background holds where background: draws.
import: entries may be {uri: URI, optional: true}: a library the host may
not have, whose absence is no warning (so ari test passes on older hosts).
A document's own unit with fallback: true stands in only where no import
defines the name, so a document adopts cvc://components/card.ari and keeps
its own card for hosts without it. card.ari gains slots note (above the
header), extra (under the byline) and body (after the body text).
Test: AriadneModularity.OptionalImportsAndFallbackUnits.
transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
…13)

The home feed is the first screen after signing in, as the web app's home is: Show Following (GET /social/timeline/home) or Everyone (/public), ten posts a page with mode=latest, and Load more by before_id. Each post is a bordered card: the author's avatar, name, full handle and time; the text, wrapped, three lines at most; the first picture inline; attachment rows; the counts; Open, which shows the whole post with its reactions (GET /social/posts/{id}). Pictures show where the host has image.url (transfix/libcvc#931); video and audio play with their controls where it has a player (media.player: ari-media and arigl, transfix/libcvc#935), and are rows elsewhere. The launcher prefers ari-media in a terminal; --start profile opens the profile first. Terminal first: 76 columns by 86% of the screen, scrolling by focus. Tests: a stub feed with pictures, a video, a recording, a PDF, a repost, a paid post and two pages; Open, Load more, Everyone and the 80x24 fit in tmux in both backends; players and pictures where the host has them.
Joe Rivera added 3 commits October 31, 2026 00:14
… and audio:

The cvcgl package builds cvcMedia beside cvcGL; with ffmpeg-lgpl (shared) in
its prefix, cvcMedia has its FFmpeg player. Scoped to linux, macos and
windows; the wasm pages use the browser's media elements.
Joe Rivera and others added 25 commits October 31, 2026 01:10
… clang-format

encode() removed its temporary file while the ifstream reading it was still open. Windows
refuses to delete an open file, so every MediaDecode/MediaCache/MediaWidget case that encodes
a picture threw from std::filesystem::remove there (8 cases in recipe/windows, the same in the
three package-windows builds). The stream now closes first.

Also the changed lines clang-format 18 reformats: ari_media_test.cpp, the two hosts' snapshot
settle calls and two include blocks the master merge touched.
The three MediaBackground cases shared temp/ariadne_media_test_backdrop, and each removed it
when done. ctest runs the cases as separate processes at the same time, so one case removed
(or rewrote) bg.png while another was still loading it; that picture never reached ready and
the case timed out at 5 s. Seen on recipe/ubuntu Debug and Release and on macOS Debug once
the stack above added cases and changed which ones run together. The directory now carries
the running test's name.
… release bumped them before this one landed)
#931's changes are already here from its branch, so this keeps this tree
and makes the squash an ancestor, so the branch merges into master.
#932's changes are already here from its branch, so this keeps this tree
and makes the squash an ancestor, so the branch merges into master.
…-media-video

Their changes are already here from their branches, so this keeps this tree
and makes the squashes ancestors, so the branch merges into master.
@transfix
transfix merged commit 6dc404c into master Nov 2, 2026
1 of 27 checks passed
@transfix
transfix deleted the feat/ariadne-media-video branch November 2, 2026 06:32
transfix added a commit that referenced this pull request Nov 2, 2026
#935's changes are already here from its branch, so this keeps this tree
and makes the squash an ancestor, so the branch merges into master.
transfix added a commit that referenced this pull request Nov 2, 2026
…media M6, stacked on #935) (#936)

Media M6: in wasm builds (ari.html, arigl-web) `video:` and `audio:` play
through the page's own <video>/<audio> elements (media_browser.cpp,
register_browser_player()), so FFmpeg is never compiled to wasm. Play from a
click or Enter plays sound without hitting the browser's autoplay block.
transfix added a commit that referenced this pull request Nov 2, 2026
#935 took docs/ARIADNE.md §5.13 for video and audio; the phone section
is now §5.14.
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.

1 participant