Repository navigation
Ariadne: animated GIF/WebP pictures and decorative video (media M7, stacked on #936) - #938
Merged
Merged
Conversation
added 30 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.
…media M6) In a wasm build (ari.html, arigl-web) the player is the page's own media element, never FFmpeg compiled to wasm (media_browser.cpp, register_browser_player). Each player is a hidden element the page keeps; it plays the sound itself, and a video's new frames (requestVideoFrameCallback or a moved currentTime) are drawn into a canvas the size of the box and copied into the widget's picture with getImageData, so both pages and every widget path (windows, menus, clipping) show them alike. The policy and credentials are decided in C++ before the element sees anything: an allowed http(s) URL without auth: is the element's src (it streams and seeks); with auth: the page fetches it with the bearer token only (credentials omit, redirect error, no-store) into a blob; file://, cvc:// and state:// are read from the page's files into a blob. A refused origin or a missing credential is a failed player saying why. A picture from another origin without CORS can't be read back (the error says so; the sound plays), and a browser that blocks sound until a click says to press Play. ari and arigl register it in their wasm builds. Checked in Chrome (the built-in pane) on a local single-threaded ari.html build: a picture by URL ready, a preloaded file:// video and an http video both played to the end with frames captured (96x54, testsrc's colours), an Opus tone ready.
…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.
…rge had interleaved them)
… 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.
… release bumped them before this one landed)
…dne-media-background
#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.
…t/ariadne-media-card
#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.
#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.
#936'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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Media M7. Stacked on #936. Review only 48d1028. It targets master so the full CI runs.
It answers nicotina's asks, as the owner pointed out: avatars, banners and backgrounds can be animated pictures or videos, as in the TX.WTF web app (
isVideoMediaUrl,applyAvatarMedia).Animated pictures.
image:andbackground:animate a GIF or an animated WebP.cvc::decode_image_animationdecodes every frame and is bounded before decoding. A GIF's frames are counted from its block structure, so stb never decodes an oversized animation; a WebP's come fromWebPAnimDecoder(libwebpdemux). Past 512 frames or 128 MiB decoded, it shows the first frame.Decorative video.
video:takescontrols: false. That means no controls;autoplay,loopandmuteddefault to on;shape:andfit:apply to the frames; andstatus:holds the state.PlayerSource::audiois false: the FFmpeg player skips the audio stream, and the browser's element stays muted. So it plays over SSH too, since it makes no sound..mp4,.webm,.mov,.m4v, query or fragment allowed: the web clients' rule) inimage:orbackground:plays as one. Without a player it shows the placeholder, andstatus:saysunsupported(orremote,failed) where a picture would sayready.image.animatedandvideo.decorative, alongside Ariadne: image: shows a picture by URL (media M1) #931'simage.url, Ariadne: background: on a window or group (media M2, stacked on #931) #932'simage.backgroundand Ariadne: video: and audio: widgets; cvcMedia's FFmpeg + SDL3 player (media M5, stacked on #933 + #934) #935'smedia/media.player.emit_playeris split intoplayer_slotandplayer_frame, so a background reuses the player plumbing.Tests
MediaDecode.AnimatedGifAndWebpKeepTheirFrames: a committed 4-frame GIF (1.7 KB) and an animated WebP (534 B), plus the frame cap.MediaAnimated.TheWidgetShowsTheFramesOnTheClock: at least 3 new frames published within 0.9 s, circle-masked.MediaPlayer.ADecorativeVideoPlaysSilentlyWithNoControlsAnywhere: a decorativevideo:, a.movavatar inimage:and a.mp4background play withaudio=false, loop and mute, under--media-play never, with no buttons or slider,status:keysplaying, the backdrop showing the player's frames, and the avatar's frame circle-masked.MediaPlayer.WithoutAPlayerAVideoAvatarIsAPlaceholderItsStatusNamesandMediaParse.VideoUris.AriMedia.TheLeanAriAnimatesPicturesAndNamesTheVideosItCannotPlay.ari_run_media_animated_{ftxui,tvision}: ari-media in tmux plays the video avatar, the decorative video and the video background, with no sound device configured.Verified locally: ariadne_media_test 36/36, ari_media_test 8/8, and the tmux tests on both backends. clang-format 18 is clean.